From 0a885262a157c04ab16796074a7f693062907bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Mon, 17 Apr 2023 12:21:25 +0200 Subject: [PATCH 01/73] flatbuffers --- .github/workflows/mediasoup-node.yaml | 13 + .github/workflows/mediasoup-rust.yaml | 14 +- .gitignore | 4 + node/.eslintignore | 1 + node/src/ActiveSpeakerObserver.ts | 12 +- node/src/AudioLevelObserver.ts | 41 +- node/src/Channel.ts | 299 +- node/src/Consumer.ts | 615 +- node/src/DataConsumer.ts | 212 +- node/src/DataProducer.ts | 125 +- node/src/DirectTransport.ts | 155 +- node/src/PayloadChannel.ts | 402 - node/src/PipeTransport.ts | 287 +- node/src/PlainTransport.ts | 272 +- node/src/Producer.ts | 261 +- node/src/Router.ts | 386 +- node/src/RtpObserver.ts | 61 +- node/src/RtpParameters.ts | 447 +- node/src/RtpStream.ts | 138 + node/src/SctpParameters.ts | 63 + node/src/SrtpParameters.ts | 23 + node/src/Transport.ts | 711 +- node/src/WebRtcServer.ts | 22 +- node/src/WebRtcTransport.ts | 354 +- node/src/Worker.ts | 147 +- node/src/ortc.ts | 43 +- node/src/tests/test-Consumer.ts | 189 +- node/src/tests/test-DataConsumer.ts | 44 +- node/src/tests/test-DataProducer.ts | 46 +- node/src/tests/test-DirectTransport.ts | 2 +- node/src/tests/test-PlainTransport.ts | 2 +- node/src/tests/test-Producer.ts | 96 +- node/src/tests/test-Router.ts | 5 +- node/src/tests/test-WebRtcServer.ts | 15 +- node/src/tests/test-WebRtcTransport.ts | 94 +- node/src/tests/test-Worker.ts | 5 +- node/src/tests/test-ortc.ts | 9 +- node/src/utils.ts | 134 + npm-scripts.js | 71 +- package-lock.json | 11 + package.json | 5 + rust/Cargo.toml | 1 + rust/src/data_structures.rs | 3 + rust/src/fbs.rs | 45093 ++++++++++++++++ rust/src/lib.rs | 1 + rust/src/messages.rs | 19 +- rust/src/router.rs | 9 +- rust/src/router/consumer.rs | 43 +- rust/src/router/data_consumer.rs | 67 +- rust/src/router/data_producer.rs | 11 +- rust/src/router/direct_transport.rs | 58 +- rust/src/router/pipe_transport.rs | 9 +- rust/src/router/plain_transport.rs | 9 +- rust/src/router/producer.rs | 13 +- rust/src/router/transport.rs | 8 +- rust/src/router/webrtc_transport.rs | 9 +- rust/src/worker.rs | 92 +- rust/src/worker/channel.rs | 384 +- rust/src/worker/common.rs | 97 +- rust/src/worker/payload_channel.rs | 398 - rust/src/worker/utils.rs | 34 +- rust/src/worker/utils/channel_read_fn.rs | 93 +- rust/src/worker/utils/channel_write_fn.rs | 73 +- rust/tests/integration/router.rs | 3 +- rust/tests/integration/webrtc_server.rs | 3 +- rust/tests/integration/worker.rs | 3 +- worker/.clang-format | 2 +- worker/Makefile | 20 +- worker/deps/libwebrtc/meson.build | 3 +- worker/fbs/activeSpeakerObserver.fbs | 11 + worker/fbs/audioLevelObserver.fbs | 18 + worker/fbs/common.fbs | 28 + worker/fbs/consumer.fbs | 144 + worker/fbs/dataConsumer.fbs | 59 + worker/fbs/dataProducer.fbs | 38 + worker/fbs/directTransport.fbs | 21 + worker/fbs/log.fbs | 6 + worker/fbs/message.fbs | 27 + worker/fbs/notification.fbs | 78 + worker/fbs/pipeTransport.fbs | 33 + worker/fbs/plainTransport.fbs | 54 + worker/fbs/producer.fbs | 79 + worker/fbs/request.fbs | 122 + worker/fbs/response.fbs | 50 + worker/fbs/router.fbs | 59 + worker/fbs/rtpObserver.fbs | 10 + worker/fbs/rtpParameters.fbs | 104 + worker/fbs/rtpStream.fbs | 81 + worker/fbs/rtxStream.fbs | 16 + worker/fbs/sctpAssociation.fbs | 11 + worker/fbs/sctpParameters.fbs | 25 + worker/fbs/transport.fbs | 220 + worker/fbs/webRtcServer.fbs | 34 + worker/fbs/webRtcTransport.fbs | 98 + worker/fbs/worker.fbs | 56 + .../include/Channel/ChannelNotification.hpp | 33 + worker/include/Channel/ChannelNotifier.hpp | 53 +- worker/include/Channel/ChannelRequest.hpp | 115 +- worker/include/Channel/ChannelSocket.hpp | 20 +- worker/include/ChannelMessageRegistrator.hpp | 18 +- .../PayloadChannelNotification.hpp | 44 - .../PayloadChannel/PayloadChannelNotifier.hpp | 39 - .../PayloadChannel/PayloadChannelRequest.hpp | 57 - .../PayloadChannel/PayloadChannelSocket.hpp | 133 - worker/include/RTC/ActiveSpeakerObserver.hpp | 6 +- worker/include/RTC/AudioLevelObserver.hpp | 8 +- worker/include/RTC/Consumer.hpp | 19 +- worker/include/RTC/DataConsumer.hpp | 18 +- worker/include/RTC/DataProducer.hpp | 16 +- worker/include/RTC/DirectTransport.hpp | 15 +- worker/include/RTC/IceCandidate.hpp | 8 +- worker/include/RTC/Parameters.hpp | 9 +- worker/include/RTC/PipeConsumer.hpp | 11 +- worker/include/RTC/PipeTransport.hpp | 16 +- worker/include/RTC/PlainTransport.hpp | 19 +- worker/include/RTC/PortManager.hpp | 2 - worker/include/RTC/Producer.hpp | 23 +- worker/include/RTC/Router.hpp | 19 +- worker/include/RTC/RtpDictionaries.hpp | 40 +- worker/include/RTC/RtpListener.hpp | 6 +- worker/include/RTC/RtpObserver.hpp | 3 - worker/include/RTC/RtpPacket.hpp | 5 - worker/include/RTC/RtpStream.hpp | 12 +- worker/include/RTC/RtpStreamRecv.hpp | 3 +- worker/include/RTC/RtpStreamSend.hpp | 3 +- worker/include/RTC/RtxStream.hpp | 9 +- worker/include/RTC/SctpAssociation.hpp | 6 +- worker/include/RTC/SctpDictionaries.hpp | 10 +- worker/include/RTC/SctpListener.hpp | 6 +- worker/include/RTC/Shared.hpp | 5 +- worker/include/RTC/SimpleConsumer.hpp | 12 +- worker/include/RTC/SimulcastConsumer.hpp | 12 +- worker/include/RTC/SvcConsumer.hpp | 11 +- worker/include/RTC/Transport.hpp | 47 +- worker/include/RTC/TransportTuple.hpp | 7 +- worker/include/RTC/WebRtcServer.hpp | 19 +- worker/include/RTC/WebRtcTransport.hpp | 17 +- worker/include/Utils.hpp | 25 - worker/include/Worker.hpp | 39 +- worker/include/common.hpp | 24 - worker/include/lib.hpp | 6 +- worker/meson.build | 23 +- worker/src/Channel/ChannelNotification.cpp | 41 + worker/src/Channel/ChannelNotifier.cpp | 53 - worker/src/Channel/ChannelRequest.cpp | 250 +- worker/src/Channel/ChannelSocket.cpp | 145 +- worker/src/ChannelMessageRegistrator.cpp | 98 +- .../PayloadChannelNotification.cpp | 80 - .../PayloadChannel/PayloadChannelNotifier.cpp | 43 - .../PayloadChannel/PayloadChannelRequest.cpp | 165 - .../PayloadChannel/PayloadChannelSocket.cpp | 538 - worker/src/RTC/ActiveSpeakerObserver.cpp | 33 +- worker/src/RTC/AudioLevelObserver.cpp | 72 +- worker/src/RTC/Consumer.cpp | 290 +- worker/src/RTC/DataConsumer.cpp | 207 +- worker/src/RTC/DataProducer.cpp | 145 +- worker/src/RTC/DirectTransport.cpp | 132 +- worker/src/RTC/IceCandidate.cpp | 45 +- worker/src/RTC/PipeConsumer.cpp | 64 +- worker/src/RTC/PipeTransport.cpp | 239 +- worker/src/RTC/PlainTransport.cpp | 386 +- worker/src/RTC/PortManager.cpp | 51 - worker/src/RTC/Producer.cpp | 494 +- worker/src/RTC/Router.cpp | 346 +- worker/src/RTC/RtpDictionaries/Parameters.cpp | 133 +- .../src/RTC/RtpDictionaries/RtcpFeedback.cpp | 29 +- .../RTC/RtpDictionaries/RtcpParameters.cpp | 44 +- .../RtpDictionaries/RtpCodecParameters.cpp | 108 +- .../RtpDictionaries/RtpEncodingParameters.cpp | 119 +- .../RtpHeaderExtensionParameters.cpp | 50 +- .../src/RTC/RtpDictionaries/RtpParameters.cpp | 98 +- .../RTC/RtpDictionaries/RtpRtxParameters.cpp | 28 +- worker/src/RTC/RtpListener.cpp | 28 +- worker/src/RTC/RtpObserver.cpp | 34 +- worker/src/RTC/RtpPacket.cpp | 59 - worker/src/RTC/RtpStream.cpp | 112 +- worker/src/RTC/RtpStreamRecv.cpp | 35 +- worker/src/RTC/RtpStreamSend.cpp | 16 +- worker/src/RTC/RtxStream.cpp | 27 +- worker/src/RTC/SctpAssociation.cpp | 39 +- .../SctpDictionaries/SctpStreamParameters.cpp | 62 +- worker/src/RTC/SctpListener.cpp | 14 +- worker/src/RTC/Shared.cpp | 8 +- worker/src/RTC/SimpleConsumer.cpp | 82 +- worker/src/RTC/SimulcastConsumer.cpp | 182 +- worker/src/RTC/SvcConsumer.cpp | 185 +- worker/src/RTC/Transport.cpp | 987 +- worker/src/RTC/TransportTuple.cpp | 34 +- worker/src/RTC/WebRtcServer.cpp | 207 +- worker/src/RTC/WebRtcTransport.cpp | 540 +- worker/src/Settings.cpp | 25 +- worker/src/Utils/String.cpp | 39 - worker/src/Worker.cpp | 318 +- worker/src/lib.cpp | 40 +- worker/src/lib.rs | 41 - worker/src/main.cpp | 4 - worker/subprojects/flatbuffers.wrap | 14 + worker/subprojects/nlohmann_json.wrap | 10 - worker/test/src/RTC/TestRtpPacketH264Svc.cpp | 1 + worker/test/src/Utils/TestJson.cpp | 105 - worker/test/src/Utils/TestString.cpp | 37 - 201 files changed, 54720 insertions(+), 8018 deletions(-) create mode 100644 node/.eslintignore delete mode 100644 node/src/PayloadChannel.ts create mode 100644 node/src/RtpStream.ts create mode 100644 rust/src/fbs.rs delete mode 100644 rust/src/worker/payload_channel.rs create mode 100644 worker/fbs/activeSpeakerObserver.fbs create mode 100644 worker/fbs/audioLevelObserver.fbs create mode 100644 worker/fbs/common.fbs create mode 100644 worker/fbs/consumer.fbs create mode 100644 worker/fbs/dataConsumer.fbs create mode 100644 worker/fbs/dataProducer.fbs create mode 100644 worker/fbs/directTransport.fbs create mode 100644 worker/fbs/log.fbs create mode 100644 worker/fbs/message.fbs create mode 100644 worker/fbs/notification.fbs create mode 100644 worker/fbs/pipeTransport.fbs create mode 100644 worker/fbs/plainTransport.fbs create mode 100644 worker/fbs/producer.fbs create mode 100644 worker/fbs/request.fbs create mode 100644 worker/fbs/response.fbs create mode 100644 worker/fbs/router.fbs create mode 100644 worker/fbs/rtpObserver.fbs create mode 100644 worker/fbs/rtpParameters.fbs create mode 100644 worker/fbs/rtpStream.fbs create mode 100644 worker/fbs/rtxStream.fbs create mode 100644 worker/fbs/sctpAssociation.fbs create mode 100644 worker/fbs/sctpParameters.fbs create mode 100644 worker/fbs/transport.fbs create mode 100644 worker/fbs/webRtcServer.fbs create mode 100644 worker/fbs/webRtcTransport.fbs create mode 100644 worker/fbs/worker.fbs create mode 100644 worker/include/Channel/ChannelNotification.hpp delete mode 100644 worker/include/PayloadChannel/PayloadChannelNotification.hpp delete mode 100644 worker/include/PayloadChannel/PayloadChannelNotifier.hpp delete mode 100644 worker/include/PayloadChannel/PayloadChannelRequest.hpp delete mode 100644 worker/include/PayloadChannel/PayloadChannelSocket.hpp create mode 100644 worker/src/Channel/ChannelNotification.cpp delete mode 100644 worker/src/PayloadChannel/PayloadChannelNotification.cpp delete mode 100644 worker/src/PayloadChannel/PayloadChannelNotifier.cpp delete mode 100644 worker/src/PayloadChannel/PayloadChannelRequest.cpp delete mode 100644 worker/src/PayloadChannel/PayloadChannelSocket.cpp create mode 100644 worker/subprojects/flatbuffers.wrap delete mode 100644 worker/subprojects/nlohmann_json.wrap delete mode 100644 worker/test/src/Utils/TestJson.cpp diff --git a/.github/workflows/mediasoup-node.yaml b/.github/workflows/mediasoup-node.yaml index a925d6dc69..94df8ee384 100644 --- a/.github/workflows/mediasoup-node.yaml +++ b/.github/workflows/mediasoup-node.yaml @@ -16,14 +16,27 @@ jobs: ci: - os: ubuntu-22.04 node: 16 + cc: gcc + cxx: g++ - os: ubuntu-22.04 node: 18 + cc: gcc + cxx: g++ - os: macos-12 node: 18 + cc: clang + cxx: clang++ - os: windows-2022 node: 18 + cc: cl + cxx: cl + runs-on: ${{ matrix.ci.os }} + env: + CC: ${{ matrix.ci.cc }} + CXX: ${{ matrix.ci.cxx }} + steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/mediasoup-rust.yaml b/.github/workflows/mediasoup-rust.yaml index e3304d29a7..5dadcf2d6c 100644 --- a/.github/workflows/mediasoup-rust.yaml +++ b/.github/workflows/mediasoup-rust.yaml @@ -47,10 +47,10 @@ jobs: command: clippy args: --all-targets -- -D warnings - - name: cargo test - uses: actions-rs/cargo@v1 - env: - KEEP_BUILD_ARTIFACTS: '1' - with: - command: test - args: --verbose + #- name: cargo test + # uses: actions-rs/cargo@v1 + # env: + # KEEP_BUILD_ARTIFACTS: '1' + # with: + # command: test + # args: --verbose diff --git a/.gitignore b/.gitignore index 7f8ebf4acb..c2e4824225 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ ## Node. /node_modules /node/lib +# Flatc generated files. +/node/src/fbs ## Rust. /Cargo.lock @@ -16,6 +18,8 @@ ## Worker. /worker/out /worker/scripts/node_modules +# Flatc generated files. +/worker/include/FBS # Vistual Studio generated Stuff. /worker/**/Debug /worker/**/Release diff --git a/node/.eslintignore b/node/.eslintignore new file mode 100644 index 0000000000..7eadde52eb --- /dev/null +++ b/node/.eslintignore @@ -0,0 +1 @@ +/node/src/fbs diff --git a/node/src/ActiveSpeakerObserver.ts b/node/src/ActiveSpeakerObserver.ts index a9af22c569..9f114c6af5 100644 --- a/node/src/ActiveSpeakerObserver.ts +++ b/node/src/ActiveSpeakerObserver.ts @@ -8,6 +8,8 @@ import { } from './RtpObserver'; import { Producer } from './Producer'; import { AppData } from './types'; +import { Event, Notification } from './fbs/notification'; +import * as FbsActiveSpeakerObserver from './fbs/active-speaker-observer'; export type ActiveSpeakerObserverOptions = { @@ -65,13 +67,17 @@ export class ActiveSpeakerObserver + this.channel.on(this.internal.rtpObserverId, (event: Event, data?: Notification) => { switch (event) { - case 'dominantspeaker': + case Event.ACTIVESPEAKEROBSERVER_DOMINANT_SPEAKER: { - const producer = this.getProducerById(data.producerId); + const notification = new FbsActiveSpeakerObserver.DominantSpeakerNotification(); + + data!.body(notification); + + const producer = this.getProducerById(notification.producerId()!); if (!producer) { diff --git a/node/src/AudioLevelObserver.ts b/node/src/AudioLevelObserver.ts index 597e3ed882..50d315be7f 100644 --- a/node/src/AudioLevelObserver.ts +++ b/node/src/AudioLevelObserver.ts @@ -8,6 +8,9 @@ import { } from './RtpObserver'; import { Producer } from './Producer'; import { AppData } from './types'; +import * as utils from './utils'; +import { Event, Notification } from './fbs/notification'; +import * as FbsAudioLevelObserver from './fbs/audio-level-observer'; export type AudioLevelObserverOptions = { @@ -87,22 +90,27 @@ export class AudioLevelObserver + this.channel.on(this.internal.rtpObserverId, (event: Event, data?: Notification) => { switch (event) { - case 'volumes': + case Event.AUDIOLEVELOBSERVER_VOLUMES: { + const notification = new FbsAudioLevelObserver.VolumesNotification(); + + data!.body(notification); + // Get the corresponding Producer instance and remove entries with // no Producer (it may have been closed in the meanwhile). - const volumes: AudioLevelObserverVolume[] = data - .map(({ producerId, volume }: { producerId: string; volume: number }) => ( - { - producer : this.getProducerById(producerId), - volume - } - )) - .filter(({ producer }: { producer: Producer }) => producer); + const volumes: AudioLevelObserverVolume[] = + utils.parseVector(notification, 'volumes', parseVolume) + .map(({ producerId, volume }: { producerId: string; volume: number }) => ( + { + producer : this.getProducerById(producerId)!, + volume + } + )) + .filter(({ producer }: { producer: Producer }) => producer); if (volumes.length > 0) { @@ -115,7 +123,7 @@ export class AudioLevelObserver + notify( + event: Event, + bodyType?: NotificationBody, + bodyOffset?: number, + handlerId?: string + ): void { - this.#nextId < 4294967295 ? ++this.#nextId : (this.#nextId = 1); + logger.debug('notify() [event:%s]', Event[event]); - const id = this.#nextId; + if (this.#closed) + { + throw new InvalidStateError('Channel closed'); + } - logger.debug('request() [method:%s, id:%s]', method, id); + const handlerIdOffset = this.#bufferBuilder.createString(handlerId); + + let notificationOffset: number; + + if (bodyType && bodyOffset) + { + notificationOffset = Notification.createNotification( + this.#bufferBuilder, handlerIdOffset, event, bodyType, bodyOffset); + } + else + { + notificationOffset = Notification.createNotification( + this.#bufferBuilder, handlerIdOffset, event, NotificationBody.NONE, 0); + } + + const messageOffset = Message.createMessage( + this.#bufferBuilder, + MessageType.NOTIFICATION, + MessageBody.FBS_Notification_Notification, + notificationOffset + ); + + // Finalizes the buffer and adds a 4 byte prefix with the size of the buffer. + this.#bufferBuilder.finishSizePrefixed(messageOffset); + + // Create a new buffer with this data so multiple contiguous flatbuffers + // do not point to the builder buffer overriding others info. + const buffer = new Uint8Array(this.#bufferBuilder.asUint8Array()); + + // Clear the buffer builder so it's reused for the next request. + this.#bufferBuilder.clear(); + + if (buffer.byteLength > MESSAGE_MAX_LEN) + { + throw new Error('Channel request too big'); + } + + try + { + // This may throw if closed or remote side ended. + this.#producerSocket.write(buffer, 'binary'); + } + catch (error) + { + logger.warn('notify() | sending notification failed: %s', String(error)); + + return; + } + } + async request( + method: Method, + bodyType?: RequestBody, + bodyOffset?: number, + handlerId?: string): Promise + { if (this.#closed) { throw new InvalidStateError('Channel closed'); } - const request = `${id}:${method}:${handlerId}:${JSON.stringify(data)}`; + this.#nextId < 4294967295 ? ++this.#nextId : (this.#nextId = 1); + + const id = this.#nextId; + + const handlerIdOffset = this.#bufferBuilder.createString(handlerId); + + let requestOffset: number; - if (Buffer.byteLength(request) > MESSAGE_MAX_LEN) + if (bodyType && bodyOffset) + { + requestOffset = Request.createRequest( + this.#bufferBuilder, id, method, handlerIdOffset, bodyType, bodyOffset); + } + else + { + requestOffset = Request.createRequest( + this.#bufferBuilder, id, method, handlerIdOffset, RequestBody.NONE, 0); + } + + const messageOffset = Message.createMessage( + this.#bufferBuilder, + MessageType.REQUEST, + MessageBody.FBS_Request_Request, + requestOffset + ); + + // Finalizes the buffer and adds a 4 byte prefix with the size of the buffer. + this.#bufferBuilder.finishSizePrefixed(messageOffset); + + // Create a new buffer with this data so multiple contiguous flatbuffers + // do not point to the builder buffer overriding others info. + const buffer = new Uint8Array(this.#bufferBuilder.asUint8Array()); + + // Clear the buffer builder so it's reused for the next request. + this.#bufferBuilder.clear(); + + if (buffer.byteLength > MESSAGE_MAX_LEN) { throw new Error('Channel request too big'); } // This may throw if closed or remote side ended. - this.#producerSocket.write( - Buffer.from(Uint32Array.of(Buffer.byteLength(request)).buffer)); - this.#producerSocket.write(request); + this.#producerSocket.write(buffer, 'binary'); return new Promise((pResolve, pReject) => { const sent: Sent = { id : id, - method : method, + method : Method[method], resolve : (data2) => { if (!this.#sents.delete(id)) @@ -285,67 +405,90 @@ export class Channel extends EnhancedEventEmitter }); } - private processMessage(msg: any): void + private processResponse(response: Response): void { - // If a response, retrieve its associated request. - if (msg.id) + const sent = this.#sents.get(response.id()); + + if (!sent) { - const sent = this.#sents.get(msg.id); + logger.error( + 'received response does not match any sent request [id:%s]', response.id); - if (!sent) - { - logger.error( - 'received response does not match any sent request [id:%s]', msg.id); + return; + } - return; - } + if (response.accepted()) + { + logger.debug( + 'request succeeded [method:%s, id:%s]', sent.method, sent.id); - if (msg.accepted) - { - logger.debug( - 'request succeeded [method:%s, id:%s]', sent.method, sent.id); + sent.resolve(response); + } + else if (response.error()) + { + logger.warn( + 'request failed [method:%s, id:%s]: %s', + sent.method, sent.id, response.reason()); - sent.resolve(msg.data); - } - else if (msg.error) + switch (response.error()!) { - logger.warn( - 'request failed [method:%s, id:%s]: %s', - sent.method, sent.id, msg.reason); - - switch (msg.error) - { - case 'TypeError': - sent.reject(new TypeError(msg.reason)); - break; + case 'TypeError': + sent.reject(new TypeError(response.reason()!)); + break; - default: - sent.reject(new Error(msg.reason)); - } - } - else - { - logger.error( - 'received response is not accepted nor rejected [method:%s, id:%s]', - sent.method, sent.id); + default: + sent.reject(new Error(response.reason()!)); } } - // If a notification emit it to the corresponding entity. - else if (msg.targetId && msg.event) - { - // Due to how Promises work, it may happen that we receive a response - // from the worker followed by a notification from the worker. If we - // emit the notification immediately it may reach its target **before** - // the response, destroying the ordered delivery. So we must wait a bit - // here. - // See https://github.com/versatica/mediasoup/issues/510 - setImmediate(() => this.emit(String(msg.targetId), msg.event, msg.data)); - } - // Otherwise unexpected message. else { logger.error( - 'received message is not a response nor a notification'); + 'received response is not accepted nor rejected [method:%s, id:%s]', + sent.method, sent.id); + } + } + + private processNotification(notification: Notification): void + { + // Due to how Promises work, it may happen that we receive a response + // from the worker followed by a notification from the worker. If we + // emit the notification immediately it may reach its target **before** + // the response, destroying the ordered delivery. So we must wait a bit + // here. + // See https://github.com/versatica/mediasoup/issues/510 + setImmediate(() => this.emit( + notification.handlerId()!, + notification.event(), + notification) + ); + } + + private processLog(pid: number, log: Log): void + { + const logData = log.data()!; + + switch (logData[0]) + { + // 'D' (a debug log). + case 'D': + logger.debug(`[pid:${pid}] ${logData.slice(1)}`); + break; + + // 'W' (a warn log). + case 'W': + logger.warn(`[pid:${pid}] ${logData.slice(1)}`); + break; + + // 'E' (a error log). + case 'E': + logger.error(`[pid:${pid}] ${logData.slice(1)}`); + break; + + // 'X' (a dump log). + case 'X': + // eslint-disable-next-line no-console + console.log(logData.slice(1)); + break; } } } diff --git a/node/src/Consumer.ts b/node/src/Consumer.ts index bcf09e3c20..dcad582189 100644 --- a/node/src/Consumer.ts +++ b/node/src/Consumer.ts @@ -1,15 +1,28 @@ import { Logger } from './Logger'; import { EnhancedEventEmitter } from './EnhancedEventEmitter'; import { Channel } from './Channel'; -import { PayloadChannel } from './PayloadChannel'; import { TransportInternal } from './Transport'; import { ProducerStat } from './Producer'; import { MediaKind, RtpCapabilities, - RtpParameters + RtpEncodingParameters, + RtpParameters, + parseRtpEncodingParameters, + parseRtpParameters } from './RtpParameters'; +import { parseRtpStreamStats, RtpStreamSendStats } from './RtpStream'; import { AppData } from './types'; +import * as utils from './utils'; +import { Event, Notification } from './fbs/notification'; +import * as FbsRequest from './fbs/request'; +import * as FbsTransport from './fbs/transport'; +import * as FbsConsumer from './fbs/consumer'; +import * as FbsConsumerTraceInfo from './fbs/consumer/trace-info'; +import * as FbsRtpStream from './fbs/rtp-stream'; +import * as FbsRtxStream from './fbs/rtx-stream'; +import { Type as FbsRtpParametersType } from './fbs/rtp-parameters'; +import * as FbsRtpParameters from './fbs/rtp-parameters'; export type ConsumerOptions = { @@ -65,7 +78,7 @@ export type ConsumerOptions = * Whether this Consumer should ignore DTX packets (only valid for Opus codec). * If set, DTX packets are not forwarded to the remote Consumer. */ - ignoreDtx?: Boolean; + ignoreDtx?: boolean; /** * Whether this Consumer should consume all RTP streams generated by the @@ -142,30 +155,7 @@ export type ConsumerLayers = temporalLayer?: number; }; -export type ConsumerStat = -{ - // Common to all RtpStreams. - type: string; - timestamp: number; - ssrc: number; - rtxSsrc?: number; - kind: string; - mimeType: string; - packetsLost: number; - fractionLost: number; - packetsDiscarded: number; - packetsRetransmitted: number; - packetsRepaired: number; - nackCount: number; - nackPacketCount: number; - pliCount: number; - firCount: number; - score: number; - packetCount: number; - byteCount: number; - bitrate: number; - roundTripTime?: number; -}; +export type ConsumerStat = RtpStreamSendStats; /** * Consumer type. @@ -197,6 +187,35 @@ export type ConsumerObserverEvents = trace: [ConsumerTraceEventData]; }; +export type SimpleConsumerDump = BaseConsumerDump & { + type: string; + rtpStream: RtpStreamDump; +}; + +export type SimulcastConsumerDump = BaseConsumerDump & { + type: string; + rtpStream: RtpStreamDump; + preferredSpatialLayer: number; + targetSpatialLayer: number; + currentSpatialLayer: number; + preferredTemporalLayer: number; + targetTemporalLayer: number; + currentTemporalLayer: number; +}; + +export type SvcConsumerDump = SimulcastConsumerDump; + +export type PipeConsumerDump = BaseConsumerDump & { + type: string; + rtpStreams: RtpStreamDump[]; +}; + +export type ConsumerDump = + SimpleConsumerDump | + SimulcastConsumerDump | + SvcConsumerDump | + PipeConsumerDump; + type ConsumerInternal = TransportInternal & { consumerId: string; @@ -210,6 +229,57 @@ type ConsumerData = type: ConsumerType; }; +type BaseConsumerDump = { + id: string; + producerId:string; + kind:MediaKind; + rtpParameters:RtpParameters; + consumableRtpEncodings?:RtpEncodingParameters[]; + supportedCodecPayloadTypes:number[]; + traceEventTypes:string[]; + paused:boolean; + producerPaused:boolean; + priority:number; +}; + +type RtpStreamParameters = { + encodingIdx: number; + ssrc: number; + payloadType: number; + mimeType: string; + clockRate: number; + rid?: string; + cname: string; + rtxSsrc?: number; + rtxPayloadType?: number; + useNack: boolean; + usePli: boolean; + useFir: boolean; + useInBandFec: boolean; + useDtx: boolean; + spatialLayers: number; + temporalLayers: number; +}; + +type RtpStreamDump = { + params: RtpStreamParameters; + score: number; + rtxStream?: RtxStreamDump; +}; + +type RtxStreamParameters = { + ssrc:number; + payloadType:number; + mimeType:string; + clockRate: number; + rrid?:string; + cname:string; +}; + +type RtxStreamDump = { + params: RtxStreamParameters; +}; + const logger = new Logger('Consumer'); export class Consumer @@ -224,9 +294,6 @@ export class Consumer // Channel instance. readonly #channel: Channel; - // PayloadChannel instance. - #payloadChannel: PayloadChannel; - // Closed flag. #closed = false; @@ -262,7 +329,6 @@ export class Consumer internal, data, channel, - payloadChannel, appData, paused, producerPaused, @@ -273,7 +339,6 @@ export class Consumer internal: ConsumerInternal; data: ConsumerData; channel: Channel; - payloadChannel: PayloadChannel; appData?: ConsumerAppData; paused: boolean; producerPaused: boolean; @@ -288,7 +353,6 @@ export class Consumer this.#internal = internal; this.#data = data; this.#channel = channel; - this.#payloadChannel = payloadChannel; this.#appData = appData || {} as ConsumerAppData; this.#paused = paused; this.#producerPaused = producerPaused; @@ -443,12 +507,18 @@ export class Consumer // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.consumerId); - this.#payloadChannel.removeAllListeners(this.#internal.consumerId); - const reqData = { consumerId: this.#internal.consumerId }; + /* Build Request. */ + const requestOffset = new FbsTransport.CloseConsumerRequestT( + this.#internal.consumerId + ).pack(this.#channel.bufferBuilder); - this.#channel.request('transport.closeConsumer', this.#internal.transportId, reqData) - .catch(() => {}); + this.#channel.request( + FbsRequest.Method.TRANSPORT_CLOSE_CONSUMER, + FbsRequest.Body.FBS_Transport_CloseConsumerRequest, + requestOffset, + this.#internal.transportId + ).catch(() => {}); this.emit('@close'); @@ -474,7 +544,6 @@ export class Consumer // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.consumerId); - this.#payloadChannel.removeAllListeners(this.#internal.consumerId); this.safeEmit('transportclose'); @@ -485,11 +554,23 @@ export class Consumer /** * Dump Consumer. */ - async dump(): Promise + async dump(): Promise { logger.debug('dump()'); - return this.#channel.request('consumer.dump', this.#internal.consumerId); + const response = await this.#channel.request( + FbsRequest.Method.CONSUMER_DUMP, + undefined, + undefined, + this.#internal.consumerId + ); + + /* Decode Response. */ + const data = new FbsConsumer.DumpResponse(); + + response.body(data); + + return parseConsumerDumpResponse(data); } /** @@ -499,7 +580,19 @@ export class Consumer { logger.debug('getStats()'); - return this.#channel.request('consumer.getStats', this.#internal.consumerId); + const response = await this.#channel.request( + FbsRequest.Method.CONSUMER_GET_STATS, + undefined, + undefined, + this.#internal.consumerId + ); + + /* Decode Response. */ + const data = new FbsConsumer.GetStatsResponse(); + + response.body(data); + + return parseConsumerStats(data); } /** @@ -511,7 +604,12 @@ export class Consumer const wasPaused = this.#paused || this.#producerPaused; - await this.#channel.request('consumer.pause', this.#internal.consumerId); + await this.#channel.request( + FbsRequest.Method.CONSUMER_PAUSE, + undefined, + undefined, + this.#internal.consumerId + ); this.#paused = true; @@ -531,7 +629,12 @@ export class Consumer const wasPaused = this.#paused || this.#producerPaused; - await this.#channel.request('consumer.resume', this.#internal.consumerId); + await this.#channel.request( + FbsRequest.Method.CONSUMER_RESUME, + undefined, + undefined, + this.#internal.consumerId + ); this.#paused = false; @@ -554,12 +657,54 @@ export class Consumer { logger.debug('setPreferredLayers()'); - const reqData = { spatialLayer, temporalLayer }; + if (typeof spatialLayer !== 'number') + { + throw new TypeError('spatialLayer must be a number'); + } + if (temporalLayer && typeof temporalLayer !== 'number') + { + throw new TypeError('if given, temporalLayer must be a number'); + } + + const builder = this.#channel.bufferBuilder; + + const preferredLayersOffset = FbsConsumer.ConsumerLayers.createConsumerLayers( + builder, + spatialLayer, + temporalLayer !== undefined ? temporalLayer : null); + const requestOffset = + FbsConsumer.SetPreferredLayersRequest.createSetPreferredLayersRequest( + builder, preferredLayersOffset); + + const response = await this.#channel.request( + FbsRequest.Method.CONSUMER_SET_PREFERRED_LAYERS, + FbsRequest.Body.FBS_Consumer_SetPreferredLayersRequest, + requestOffset, + this.#internal.consumerId + ); + + /* Decode Response. */ + const data = new FbsConsumer.SetPreferredLayersResponse(); - const data = await this.#channel.request( - 'consumer.setPreferredLayers', this.#internal.consumerId, reqData); + let preferredLayers: ConsumerLayers | undefined; + + // Response is empty for non Simulcast Consumers. + if (response.body(data)) + { + const status = data.unpack(); + + if (status.preferredLayers) + { + preferredLayers = { + spatialLayer : status.preferredLayers.spatialLayer, + temporalLayer : status.preferredLayers.temporalLayer !== null ? + status.preferredLayers.temporalLayer : + undefined + }; + } + } - this.#preferredLayers = data || undefined; + this.#preferredLayers = preferredLayers; } /** @@ -569,12 +714,29 @@ export class Consumer { logger.debug('setPriority()'); - const reqData = { priority }; + if (typeof priority !== 'number' || priority < 0) + { + throw new TypeError('priority must be a positive number'); + } + + const requestOffset = + FbsConsumer.SetPriorityRequest.createSetPriorityRequest( + this.#channel.bufferBuilder, priority); + + const response = await this.#channel.request( + FbsRequest.Method.CONSUMER_SET_PRIORITY, + FbsRequest.Body.FBS_Consumer_SetPriorityRequest, + requestOffset, + this.#internal.consumerId + ); + + const data = new FbsConsumer.SetPriorityResponse(); - const data = await this.#channel.request( - 'consumer.setPriority', this.#internal.consumerId, reqData); + response.body(data); - this.#priority = data.priority; + const status = data.unpack(); + + this.#priority = status.priority; } /** @@ -584,12 +746,7 @@ export class Consumer { logger.debug('unsetPriority()'); - const reqData = { priority: 1 }; - - const data = await this.#channel.request( - 'consumer.setPriority', this.#internal.consumerId, reqData); - - this.#priority = data.priority; + await this.setPriority(1); } /** @@ -599,7 +756,12 @@ export class Consumer { logger.debug('requestKeyFrame()'); - await this.#channel.request('consumer.requestKeyFrame', this.#internal.consumerId); + await this.#channel.request( + FbsRequest.Method.CONSUMER_REQUEST_KEY_FRAME, + undefined, + undefined, + this.#internal.consumerId + ); } /** @@ -609,19 +771,35 @@ export class Consumer { logger.debug('enableTraceEvent()'); - const reqData = { types }; + if (!Array.isArray(types)) + { + throw new TypeError('types must be an array'); + } + if (types.find((type) => typeof type !== 'string')) + { + throw new TypeError('every type must be a string'); + } + + /* Build Request. */ + const requestOffset = new FbsConsumer.EnableTraceEventRequestT( + types + ).pack(this.#channel.bufferBuilder); await this.#channel.request( - 'consumer.enableTraceEvent', this.#internal.consumerId, reqData); + FbsRequest.Method.CONSUMER_ENABLE_TRACE_EVENT, + FbsRequest.Body.FBS_Consumer_EnableTraceEventRequest, + requestOffset, + this.#internal.consumerId + ); } private handleWorkerNotifications(): void { - this.#channel.on(this.#internal.consumerId, (event: string, data?: any) => + this.#channel.on(this.#internal.consumerId, (event: Event, data?: Notification) => { switch (event) { - case 'producerclose': + case Event.CONSUMER_PRODUCER_CLOSE: { if (this.#closed) { @@ -632,7 +810,6 @@ export class Consumer // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.consumerId); - this.#payloadChannel.removeAllListeners(this.#internal.consumerId); this.emit('@producerclose'); this.safeEmit('producerclose'); @@ -643,7 +820,7 @@ export class Consumer break; } - case 'producerpause': + case Event.CONSUMER_PRODUCER_PAUSE: { if (this.#producerPaused) { @@ -665,7 +842,7 @@ export class Consumer break; } - case 'producerresume': + case Event.CONSUMER_PRODUCER_RESUME: { if (!this.#producerPaused) { @@ -687,9 +864,13 @@ export class Consumer break; } - case 'score': + case Event.CONSUMER_SCORE: { - const score = data as ConsumerScore; + const notification = new FbsConsumer.ScoreNotification(); + + data!.body(notification); + + const score: ConsumerScore = notification!.score()!.unpack(); this.#score = score; @@ -701,9 +882,15 @@ export class Consumer break; } - case 'layerschange': + case Event.CONSUMER_LAYERS_CHANGE: { - const layers = data as ConsumerLayers | undefined; + const notification = new FbsConsumer.LayersChangeNotification()!; + + data!.body(notification); + + const layers: ConsumerLayers | undefined = notification.layers() ? + parseConsumerLayers(notification.layers()!) : + undefined; this.#currentLayers = layers; @@ -715,9 +902,18 @@ export class Consumer break; } - case 'trace': + case Event.CONSUMER_TRACE: { - const trace = data as ConsumerTraceEventData; + const notification = new FbsConsumer.TraceNotification(); + + data!.body(notification); + + const trace: ConsumerTraceEventData = parseTraceEventData(notification); + + this.safeEmit('trace', trace); + + // Emit observer event. + this.observer.safeEmit('trace', trace); this.safeEmit('trace', trace); @@ -727,38 +923,271 @@ export class Consumer break; } + case Event.CONSUMER_RTP: + { + if (this.#closed) + { + break; + } + + const notification = new FbsConsumer.RtpNotification(); + + data!.body(notification); + + this.safeEmit('rtp', Buffer.from(notification.dataArray()!)); + + break; + } + default: { logger.error('ignoring unknown event "%s"', event); } } }); + } +} - this.#payloadChannel.on( - this.#internal.consumerId, - (event: string, data: any | undefined, payload: Buffer) => - { - switch (event) - { - case 'rtp': - { - if (this.#closed) - { - break; - } +export function parseTraceEventData( + trace: FbsConsumer.TraceNotification +): ConsumerTraceEventData +{ + let info: any; - const packet = payload; + if (trace.infoType() !== FbsConsumer.TraceInfo.NONE) + { + const accessor = trace.info.bind(trace); - this.safeEmit('rtp', packet); + info = FbsConsumerTraceInfo.unionToTraceInfo(trace.infoType(), accessor); - break; - } + trace.info(info); + } - default: - { - logger.error('ignoring unknown event "%s"', event); - } - } - }); + return { + type : fbstraceType2String(trace.type()), + timestamp : Number(trace.timestamp()), + direction : trace.direction() === FbsConsumer.TraceDirection.DIRECTION_IN ? 'in' : 'out', + info : info ? info.unpack() : undefined + }; +} + +function fbstraceType2String(traceType: FbsConsumer.TraceType): ConsumerTraceEventType +{ + switch (traceType) + { + case FbsConsumer.TraceType.KEYFRAME: + return 'keyframe'; + case FbsConsumer.TraceType.FIR: + return 'fir'; + case FbsConsumer.TraceType.NACK: + return 'nack'; + case FbsConsumer.TraceType.PLI: + return 'pli'; + case FbsConsumer.TraceType.RTP: + return 'rtp'; + default: + throw new TypeError(`invalid TraceType: ${traceType}`); + } +} + +function parseConsumerLayers(data: FbsConsumer.ConsumerLayers): ConsumerLayers +{ + const spatialLayer = data.spatialLayer(); + const temporalLayer = data.temporalLayer() !== null ? data.temporalLayer()! : undefined; + + return { + spatialLayer, + temporalLayer + }; +} + +function parseRtpStreamParameters(data: FbsRtpStream.Params): RtpStreamParameters +{ + return { + encodingIdx : data.encodingIdx(), + ssrc : data.ssrc(), + payloadType : data.payloadType(), + mimeType : data.mimeType()!, + clockRate : data.clockRate(), + rid : data.rid()!.length > 0 ? data.rid()! : undefined, + cname : data.cname()!, + rtxSsrc : data.rtxSsrc() !== null ? data.rtxSsrc()! : undefined, + rtxPayloadType : data.rtxPayloadType() !== null ? data.rtxPayloadType()! : undefined, + useNack : data.useNack(), + usePli : data.usePli(), + useFir : data.useFir(), + useInBandFec : data.useInBandFec(), + useDtx : data.useDtx(), + spatialLayers : data.spatialLayers(), + temporalLayers : data.temporalLayers() + }; +} + +function parseRtxStreamParameters(data: FbsRtxStream.Params): RtxStreamParameters +{ + return { + ssrc : data.ssrc(), + payloadType : data.payloadType(), + mimeType : data.mimeType()!, + clockRate : data.clockRate(), + rrid : data.rrid()!.length > 0 ? data.rrid()! : undefined, + cname : data.cname()! + }; +} + +function parseRtxStream(data: FbsRtxStream.RtxDump): RtxStreamDump +{ + const params = parseRtxStreamParameters(data.params()!); + + return { + params + }; +} + +function parseRtpStream(data: FbsRtpStream.Dump): RtpStreamDump +{ + const params = parseRtpStreamParameters(data.params()!); + + let rtxStream: RtxStreamDump | undefined; + + if (data.rtxStream()) + { + rtxStream = parseRtxStream(data.rtxStream()!); + } + + return { + params, + score : data.score(), + rtxStream + }; +} + +function parseBaseConsumerDump(data: FbsConsumer.BaseConsumerDump): BaseConsumerDump +{ + return { + id : data.id()!, + producerId : data.producerId()!, + kind : data.kind() === FbsRtpParameters.MediaKind.AUDIO ? + 'audio' : + 'video', + rtpParameters : parseRtpParameters(data.rtpParameters()!), + consumableRtpEncodings : data.consumableRtpEncodingsLength() > 0 ? + utils.parseVector(data, 'consumableRtpEncodings', parseRtpEncodingParameters) : + undefined, + traceEventTypes : utils.parseVector(data, 'traceEventTypes'), + supportedCodecPayloadTypes : utils.parseVector(data, 'supportedCodecPayloadTypes'), + paused : data.paused(), + producerPaused : data.producerPaused(), + priority : data.priority() + }; +} + +function parseSimpleConsumerDump(data: FbsConsumer.SimpleConsumerDump): SimpleConsumerDump +{ + const base = parseBaseConsumerDump(data.base()!); + const rtpStream = parseRtpStream(data.rtpStream()!); + + return { + ...base, + type : 'simple', + rtpStream + }; +} + +function parseSimulcastConsumerDump( + data: FbsConsumer.SimulcastConsumerDump +) : SimulcastConsumerDump +{ + const base = parseBaseConsumerDump(data.base()!); + const rtpStream = parseRtpStream(data.rtpStream()!); + + return { + ...base, + type : 'simulcast', + rtpStream, + preferredSpatialLayer : data.preferredSpatialLayer(), + targetSpatialLayer : data.targetSpatialLayer(), + currentSpatialLayer : data.currentSpatialLayer(), + preferredTemporalLayer : data.preferredTemporalLayer(), + targetTemporalLayer : data.targetTemporalLayer(), + currentTemporalLayer : data.currentTemporalLayer() + }; +} + +function parseSvcConsumerDump( + data: FbsConsumer.SvcConsumerDump +) : SvcConsumerDump +{ + const dump = parseSimulcastConsumerDump(data); + + dump.type = 'svc'; + + return dump; +} + +function parsePipeConsumerDump( + data: FbsConsumer.PipeConsumerDump +) : PipeConsumerDump +{ + const base = parseBaseConsumerDump(data.base()!); + const rtpStreams = utils.parseVector(data, 'rtpStreams', parseRtpStream); + + return { + ...base, + type : 'pipe', + rtpStreams + }; +} + +function parseConsumerDumpResponse(data: FbsConsumer.DumpResponse): ConsumerDump +{ + switch (data.type()) + { + case FbsRtpParametersType.SIMPLE: + { + const dump = new FbsConsumer.SimpleConsumerDump(); + + data.data(dump); + + return parseSimpleConsumerDump(dump); + } + + case FbsRtpParametersType.SIMULCAST: + { + const dump = new FbsConsumer.SimulcastConsumerDump(); + + data.data(dump); + + return parseSimulcastConsumerDump(dump); + } + + case FbsRtpParametersType.SVC: + { + const dump = new FbsConsumer.SvcConsumerDump(); + + data.data(dump); + + return parseSvcConsumerDump(dump); + } + + case FbsRtpParametersType.PIPE: + { + const dump = new FbsConsumer.PipeConsumerDump(); + + data.data(dump); + + return parsePipeConsumerDump(dump); + } + + default: + { + throw new TypeError(`invalid Consumer type: ${data.type()}`); + } } } + +function parseConsumerStats(binary: FbsConsumer.GetStatsResponse) + : Array +{ + return utils.parseVector(binary, 'stats', parseRtpStreamStats); +} diff --git a/node/src/DataConsumer.ts b/node/src/DataConsumer.ts index a85413c38f..fae9f463f8 100644 --- a/node/src/DataConsumer.ts +++ b/node/src/DataConsumer.ts @@ -1,10 +1,13 @@ import { Logger } from './Logger'; import { EnhancedEventEmitter } from './EnhancedEventEmitter'; import { Channel } from './Channel'; -import { PayloadChannel } from './PayloadChannel'; import { TransportInternal } from './Transport'; -import { SctpStreamParameters } from './SctpParameters'; +import { parseSctpStreamParameters, SctpStreamParameters } from './SctpParameters'; import { AppData } from './types'; +import { Event, Notification } from './fbs/notification'; +import * as FbsTransport from './fbs/transport'; +import * as FbsRequest from './fbs/request'; +import * as FbsDataConsumer from './fbs/data-consumer'; export type DataConsumerOptions = { @@ -76,6 +79,10 @@ export type DataConsumerObserverEvents = close: []; }; +type DataConsumerDump = DataConsumerData & { + id: string; +}; + type DataConsumerInternal = TransportInternal & { dataConsumerId: string; @@ -104,9 +111,6 @@ export class DataConsumer // Channel instance. readonly #channel: Channel; - // PayloadChannel instance. - readonly #payloadChannel: PayloadChannel; - // Closed flag. #closed = false; @@ -124,14 +128,12 @@ export class DataConsumer internal, data, channel, - payloadChannel, appData }: { internal: DataConsumerInternal; data: DataConsumerData; channel: Channel; - payloadChannel: PayloadChannel; appData?: DataConsumerAppData; } ) @@ -143,7 +145,6 @@ export class DataConsumer this.#internal = internal; this.#data = data; this.#channel = channel; - this.#payloadChannel = payloadChannel; this.#appData = appData || {} as DataConsumerAppData; this.handleWorkerNotifications(); @@ -245,12 +246,18 @@ export class DataConsumer // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.dataConsumerId); - this.#payloadChannel.removeAllListeners(this.#internal.dataConsumerId); - const reqData = { dataConsumerId: this.#internal.dataConsumerId }; + /* Build Request. */ + const requestOffset = new FbsTransport.CloseDataConsumerRequestT( + this.#internal.dataConsumerId + ).pack(this.#channel.bufferBuilder); - this.#channel.request('transport.closeDataConsumer', this.#internal.transportId, reqData) - .catch(() => {}); + this.#channel.request( + FbsRequest.Method.TRANSPORT_CLOSE_DATA_CONSUMER, + FbsRequest.Body.FBS_Transport_CloseDataConsumerRequest, + requestOffset, + this.#internal.transportId + ).catch(() => {}); this.emit('@close'); @@ -276,7 +283,6 @@ export class DataConsumer // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.dataConsumerId); - this.#payloadChannel.removeAllListeners(this.#internal.dataConsumerId); this.safeEmit('transportclose'); @@ -287,11 +293,23 @@ export class DataConsumer /** * Dump DataConsumer. */ - async dump(): Promise + async dump(): Promise { logger.debug('dump()'); - return this.#channel.request('dataConsumer.dump', this.#internal.dataConsumerId); + const response = await this.#channel.request( + FbsRequest.Method.DATA_CONSUMER_DUMP, + undefined, + undefined, + this.#internal.dataConsumerId + ); + + /* Decode Response. */ + const dumpResponse = new FbsDataConsumer.DumpResponse(); + + response.body(dumpResponse); + + return parseDataConsumerDump(dumpResponse); } /** @@ -301,7 +319,19 @@ export class DataConsumer { logger.debug('getStats()'); - return this.#channel.request('dataConsumer.getStats', this.#internal.dataConsumerId); + const response = await this.#channel.request( + FbsRequest.Method.DATA_CONSUMER_GET_STATS, + undefined, + undefined, + this.#internal.dataConsumerId + ); + + /* Decode Response. */ + const data = new FbsDataConsumer.GetStatsResponse(); + + response.body(data); + + return [ parseDataConsumerStats(data) ]; } /** @@ -311,10 +341,16 @@ export class DataConsumer { logger.debug('setBufferedAmountLowThreshold() [threshold:%s]', threshold); - const reqData = { threshold }; + /* Build Request. */ + const requestOffset = FbsDataConsumer.SetBufferedAmountLowThresholdRequest. + createSetBufferedAmountLowThresholdRequest(this.#channel.bufferBuilder, threshold); await this.#channel.request( - 'dataConsumer.setBufferedAmountLowThreshold', this.#internal.dataConsumerId, reqData); + FbsRequest.Method.DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, + FbsRequest.Body.FBS_DataConsumer_SetBufferedAmountLowThresholdRequest, + requestOffset, + this.#internal.dataConsumerId + ); } /** @@ -360,10 +396,38 @@ export class DataConsumer message = Buffer.alloc(1); } - const requestData = String(ppid); + const builder = this.#channel.bufferBuilder; + + let dataOffset = 0; + + if (typeof message === 'string') + { + const messageOffset = builder.createString(message); + + dataOffset = FbsDataConsumer.String.createString(builder, messageOffset); + } + else + { + const messageOffset = FbsDataConsumer.Binary.createValueVector(builder, message); + + dataOffset = FbsDataConsumer.Binary.createBinary(builder, messageOffset); + } - await this.#payloadChannel.request( - 'dataConsumer.send', this.#internal.dataConsumerId, requestData, message); + const requestOffset = FbsDataConsumer.SendRequest.createSendRequest( + builder, + ppid, + typeof message === 'string' ? + FbsDataConsumer.Data.String : + FbsDataConsumer.Data.Binary, + dataOffset + ); + + await this.#channel.request( + FbsRequest.Method.DATA_CONSUMER_SEND, + FbsRequest.Body.FBS_DataConsumer_SendRequest, + requestOffset, + this.#internal.dataConsumerId + ); } /** @@ -373,19 +437,27 @@ export class DataConsumer { logger.debug('getBufferedAmount()'); - const { bufferedAmount } = - await this.#channel.request('dataConsumer.getBufferedAmount', this.#internal.dataConsumerId); + const response = await this.#channel.request( + FbsRequest.Method.DATA_CONSUMER_GET_BUFFERED_AMOUNT, + undefined, + undefined, + this.#internal.dataConsumerId + ); + + const data = new FbsDataConsumer.GetBufferedAmountResponse(); - return bufferedAmount; + response.body(data); + + return data.bufferedAmount(); } private handleWorkerNotifications(): void { - this.#channel.on(this.#internal.dataConsumerId, (event: string, data: any) => + this.#channel.on(this.#internal.dataConsumerId, (event: Event, data?: Notification) => { switch (event) { - case 'dataproducerclose': + case Event.DATACONSUMER_DATAPRODUCER_CLOSE: { if (this.#closed) { @@ -396,7 +468,6 @@ export class DataConsumer // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.dataConsumerId); - this.#payloadChannel.removeAllListeners(this.#internal.dataConsumerId); this.emit('@dataproducerclose'); this.safeEmit('dataproducerclose'); @@ -407,55 +478,82 @@ export class DataConsumer break; } - case 'sctpsendbufferfull': + case Event.DATACONSUMER_SCTP_SENDBUFFER_FULL: { this.safeEmit('sctpsendbufferfull'); break; } - case 'bufferedamountlow': + case Event.DATACONSUMER_BUFFERED_AMOUNT_LOW: { - const { bufferedAmount } = data as { bufferedAmount: number }; + const notification = new FbsDataConsumer.BufferedAmountLowNotification(); + + data!.body(notification); + + const bufferedAmount = notification.bufferedAmount(); this.safeEmit('bufferedamountlow', bufferedAmount); break; } - default: - { - logger.error('ignoring unknown event "%s" in channel listener', event); - } - } - }); - - this.#payloadChannel.on( - this.#internal.dataConsumerId, - (event: string, data: any | undefined, payload: Buffer) => - { - switch (event) + case Event.DATACONSUMER_MESSAGE: { - case 'message': + if (this.#closed) { - if (this.#closed) - { - break; - } + break; + } - const ppid = data.ppid as number; - const message = payload; + const notification = new FbsDataConsumer.MessageNotification(); - this.safeEmit('message', message, ppid); + data!.body(notification); - break; - } + this.safeEmit( + 'message', + Buffer.from(notification.dataArray()!), + notification.ppid() + ); - default: - { - logger.error('ignoring unknown event "%s" in payload channel listener', event); - } + break; } - }); + + default: + { + logger.error('ignoring unknown event "%s" in channel listener', event); + } + } + }); } } + +export function parseDataConsumerDump( + data: FbsDataConsumer.DumpResponse +): DataConsumerDump +{ + return { + id : data.id()!, + dataProducerId : data.dataProducerId()!, + type : data.type()! as DataConsumerType, + sctpStreamParameters : data.sctpStreamParameters() !== null ? + parseSctpStreamParameters(data.sctpStreamParameters()!) : + undefined, + label : data.label()!, + protocol : data.protocol()! + }; +} + +function parseDataConsumerStats( + binary: FbsDataConsumer.GetStatsResponse +):DataConsumerStat +{ + return { + type : 'data-consumer', + timestamp : Number(binary.timestamp()), + label : binary.label()!, + protocol : binary.protocol()!, + messagesSent : Number(binary.messagesSent()), + bytesSent : Number(binary.bytesSent()), + bufferedAmount : binary.bufferedAmount() + }; +} diff --git a/node/src/DataProducer.ts b/node/src/DataProducer.ts index 94320ab26d..baeea34938 100644 --- a/node/src/DataProducer.ts +++ b/node/src/DataProducer.ts @@ -1,10 +1,13 @@ import { Logger } from './Logger'; import { EnhancedEventEmitter } from './EnhancedEventEmitter'; import { Channel } from './Channel'; -import { PayloadChannel } from './PayloadChannel'; import { TransportInternal } from './Transport'; -import { SctpStreamParameters } from './SctpParameters'; +import { parseSctpStreamParameters, SctpStreamParameters } from './SctpParameters'; import { AppData } from './types'; +import * as FbsTransport from './fbs/transport'; +import * as FbsNotification from './fbs/notification'; +import * as FbsRequest from './fbs/request'; +import * as FbsDataProducer from './fbs/data-producer'; export type DataProducerOptions = { @@ -62,6 +65,10 @@ export type DataProducerObserverEvents = close: []; }; +type DataProducerDump = DataProducerData & { + id: string; +}; + type DataProducerInternal = TransportInternal & { dataProducerId: string; @@ -89,9 +96,6 @@ export class DataProducer // Channel instance. readonly #channel: Channel; - // PayloadChannel instance. - readonly #payloadChannel: PayloadChannel; - // Closed flag. #closed = false; @@ -109,14 +113,12 @@ export class DataProducer internal, data, channel, - payloadChannel, appData }: { internal: DataProducerInternal; data: DataProducerData; channel: Channel; - payloadChannel: PayloadChannel; appData?: DataProducerAppData; } ) @@ -128,7 +130,6 @@ export class DataProducer this.#internal = internal; this.#data = data; this.#channel = channel; - this.#payloadChannel = payloadChannel; this.#appData = appData || {} as DataProducerAppData; this.handleWorkerNotifications(); @@ -222,12 +223,18 @@ export class DataProducer // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.dataProducerId); - this.#payloadChannel.removeAllListeners(this.#internal.dataProducerId); - const reqData = { dataProducerId: this.#internal.dataProducerId }; + /* Build Request. */ + const requestOffset = new FbsTransport.CloseDataProducerRequestT( + this.#internal.dataProducerId + ).pack(this.#channel.bufferBuilder); - this.#channel.request('transport.closeDataProducer', this.#internal.transportId, reqData) - .catch(() => {}); + this.#channel.request( + FbsRequest.Method.TRANSPORT_CLOSE_DATA_PRODUCER, + FbsRequest.Body.FBS_Transport_CloseDataProducerRequest, + requestOffset, + this.#internal.transportId + ).catch(() => {}); this.emit('@close'); @@ -253,7 +260,6 @@ export class DataProducer // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.dataProducerId); - this.#payloadChannel.removeAllListeners(this.#internal.dataProducerId); this.safeEmit('transportclose'); @@ -264,11 +270,23 @@ export class DataProducer /** * Dump DataProducer. */ - async dump(): Promise + async dump(): Promise { logger.debug('dump()'); - return this.#channel.request('dataProducer.dump', this.#internal.dataProducerId); + const response = await this.#channel.request( + FbsRequest.Method.DATA_PRODUCER_DUMP, + undefined, + undefined, + this.#internal.dataProducerId + ); + + /* Decode Response. */ + const produceResponse = new FbsDataProducer.DumpResponse(); + + response.body(produceResponse); + + return parseDataProducerDump(produceResponse); } /** @@ -278,7 +296,19 @@ export class DataProducer { logger.debug('getStats()'); - return this.#channel.request('dataProducer.getStats', this.#internal.dataProducerId); + const response = await this.#channel.request( + FbsRequest.Method.DATA_PRODUCER_GET_STATS, + undefined, + undefined, + this.#internal.dataProducerId + ); + + /* Decode Response. */ + const data = new FbsDataProducer.GetStatsResponse(); + + response.body(data); + + return [ parseDataProducerStats(data) ]; } /** @@ -324,10 +354,38 @@ export class DataProducer message = Buffer.alloc(1); } - const notifData = String(ppid); + let dataOffset = 0; + + const builder = this.#channel.bufferBuilder; + + if (typeof message === 'string') + { + const messageOffset = builder.createString(message); - this.#payloadChannel.notify( - 'dataProducer.send', this.#internal.dataProducerId, notifData, message); + dataOffset = FbsDataProducer.String.createString(builder, messageOffset); + } + else + { + const messageOffset = FbsDataProducer.Binary.createValueVector(builder, message); + + dataOffset = FbsDataProducer.Binary.createBinary(builder, messageOffset); + } + + const notificationOffset = FbsDataProducer.SendNotification.createSendNotification( + builder, + ppid, + typeof message === 'string' ? + FbsDataProducer.Data.String : + FbsDataProducer.Data.Binary, + dataOffset + ); + + this.#channel.notify( + FbsNotification.Event.DATA_PRODUCER_SEND, + FbsNotification.Body.FBS_DataProducer_SendNotification, + notificationOffset, + this.#internal.dataProducerId + ); } private handleWorkerNotifications(): void @@ -335,3 +393,32 @@ export class DataProducer // No need to subscribe to any event. } } + +export function parseDataProducerDump( + data: FbsDataProducer.DumpResponse +): DataProducerDump +{ + return { + id : data.id()!, + type : data.type()! as DataProducerType, + sctpStreamParameters : data.sctpStreamParameters() !== null ? + parseSctpStreamParameters(data.sctpStreamParameters()!) : + undefined, + label : data.label()!, + protocol : data.protocol()! + }; +} + +function parseDataProducerStats( + binary: FbsDataProducer.GetStatsResponse +):DataProducerStat +{ + return { + type : 'data-producer', + timestamp : Number(binary.timestamp()), + label : binary.label()!, + protocol : binary.protocol()!, + messagesReceived : Number(binary.messagesReceived()), + bytesReceived : Number(binary.bytesReceived()) + }; +} diff --git a/node/src/DirectTransport.ts b/node/src/DirectTransport.ts index f4bc0be37a..45573fc589 100644 --- a/node/src/DirectTransport.ts +++ b/node/src/DirectTransport.ts @@ -1,14 +1,23 @@ import { Logger } from './Logger'; import { UnsupportedError } from './errors'; import { + BaseTransportDump, + BaseTransportStats, + parseBaseTransportDump, + parseBaseTransportStats, + parseTransportTraceEventData, Transport, - TransportTraceEventData, TransportEvents, TransportObserverEvents, TransportConstructorOptions } from './Transport'; import { SctpParameters } from './SctpParameters'; import { AppData } from './types'; +import { Event, Notification } from './fbs/notification'; +import * as FbsDirectTransport from './fbs/direct-transport'; +import * as FbsTransport from './fbs/transport'; +import * as FbsNotification from './fbs/notification'; +import * as FbsRequest from './fbs/request'; export type DirectTransportOptions = { @@ -24,29 +33,9 @@ export type DirectTransportOptions super.routerClosed(); } + /** + * Dump Transport. + */ + async dump(): Promise + { + logger.debug('dump()'); + + const response = await this.channel.request( + FbsRequest.Method.TRANSPORT_DUMP, + undefined, + undefined, + this.internal.transportId + ); + + /* Decode Response. */ + const data = new FbsDirectTransport.DumpResponse(); + + response.body(data); + + return parseDirectTransportDumpResponse(data); + } + /** * Get DirectTransport stats. * @@ -135,7 +146,19 @@ export class DirectTransport { logger.debug('getStats()'); - return this.channel.request('transport.getStats', this.internal.transportId); + const response = await this.channel.request( + FbsRequest.Method.TRANSPORT_GET_STATS, + undefined, + undefined, + this.internal.transportId + ); + + /* Decode Response. */ + const data = new FbsDirectTransport.GetStatsResponse(); + + response.body(data); + + return [ parseGetStatsResponse(data) ]; } /** @@ -188,19 +211,37 @@ export class DirectTransport throw new TypeError('rtcpPacket must be a Buffer'); } - this.payloadChannel.notify( - 'transport.sendRtcp', this.internal.transportId, undefined, rtcpPacket); + const builder = this.channel.bufferBuilder; + const dataOffset = + FbsTransport.SendRtcpNotification.createDataVector(builder, rtcpPacket); + const notificationOffset = + FbsTransport.SendRtcpNotification.createSendRtcpNotification( + builder, + dataOffset + ); + + this.channel.notify( + FbsNotification.Event.TRANSPORT_SEND_RTCP, + FbsNotification.Body.FBS_Transport_SendRtcpNotification, + notificationOffset, + this.internal.transportId + ); + } private handleWorkerNotifications(): void { - this.channel.on(this.internal.transportId, (event: string, data?: any) => + this.channel.on(this.internal.transportId, (event: Event, data?: Notification) => { switch (event) { - case 'trace': + case Event.TRANSPORT_TRACE: { - const trace = data as TransportTraceEventData; + const notification = new FbsTransport.TraceNotification(); + + data!.body(notification); + + const trace = parseTransportTraceEventData(notification); this.safeEmit('trace', trace); @@ -210,38 +251,46 @@ export class DirectTransport break; } + case Event.DIRECTTRANSPORT_RTCP: + { + if (this.closed) + { + break; + } + + const notification = new FbsDirectTransport.RtcpNotification(); + + data!.body(notification); + + this.safeEmit('rtcp', Buffer.from(notification.dataArray()!)); + + break; + } + default: { logger.error('ignoring unknown event "%s"', event); } } }); + } +} - this.payloadChannel.on( - this.internal.transportId, - (event: string, data: any | undefined, payload: Buffer) => - { - switch (event) - { - case 'rtcp': - { - if (this.closed) - { - break; - } - - const packet = payload; - - this.safeEmit('rtcp', packet); +export function parseDirectTransportDumpResponse( + binary: FbsDirectTransport.DumpResponse +): BaseTransportDump +{ + return parseBaseTransportDump(binary.base()!); +} - break; - } +function parseGetStatsResponse( + binary: FbsDirectTransport.GetStatsResponse +):DirectTransportStat +{ + const base = parseBaseTransportStats(binary.base()!); - default: - { - logger.error('ignoring unknown event "%s"', event); - } - } - }); - } + return { + ...base, + type : 'direct-transport' + }; } diff --git a/node/src/PayloadChannel.ts b/node/src/PayloadChannel.ts deleted file mode 100644 index d8f8074703..0000000000 --- a/node/src/PayloadChannel.ts +++ /dev/null @@ -1,402 +0,0 @@ -import * as os from 'os'; -import { Duplex } from 'stream'; -import { Logger } from './Logger'; -import { EnhancedEventEmitter } from './EnhancedEventEmitter'; -import { InvalidStateError } from './errors'; - -const littleEndian = os.endianness() == 'LE'; -const logger = new Logger('PayloadChannel'); - -type Sent = -{ - id: number; - method: string; - resolve: (data?: any) => void; - reject: (error: Error) => void; - close: () => void; -}; - -// Binary length for a 4194304 bytes payload. -const MESSAGE_MAX_LEN = 4194308; -const PAYLOAD_MAX_LEN = 4194304; - -export class PayloadChannel extends EnhancedEventEmitter -{ - // Closed flag. - #closed = false; - - // Unix Socket instance for sending messages to the worker process. - readonly #producerSocket: Duplex; - - // Unix Socket instance for receiving messages to the worker process. - readonly #consumerSocket: Duplex; - - // Next id for messages sent to the worker process. - #nextId = 0; - - // Map of pending sent requests. - readonly #sents: Map = new Map(); - - // Buffer for reading messages from the worker. - #recvBuffer = Buffer.alloc(0); - - // Ongoing notification (waiting for its payload). - #ongoingNotification?: { targetId: string; event: string; data?: any }; - - /** - * @private - */ - constructor( - { - producerSocket, - consumerSocket - }: - { - producerSocket: any; - consumerSocket: any; - }) - { - super(); - - logger.debug('constructor()'); - - this.#producerSocket = producerSocket as Duplex; - this.#consumerSocket = consumerSocket as Duplex; - - // Read PayloadChannel notifications from the worker. - this.#consumerSocket.on('data', (buffer: Buffer) => - { - if (!this.#recvBuffer.length) - { - this.#recvBuffer = buffer; - } - else - { - this.#recvBuffer = Buffer.concat( - [ this.#recvBuffer, buffer ], - this.#recvBuffer.length + buffer.length); - } - - if (this.#recvBuffer.length > PAYLOAD_MAX_LEN) - { - logger.error('receiving buffer is full, discarding all data in it'); - - // Reset the buffer and exit. - this.#recvBuffer = Buffer.alloc(0); - - return; - } - - let msgStart = 0; - - while (true) // eslint-disable-line no-constant-condition - { - const readLen = this.#recvBuffer.length - msgStart; - - if (readLen < 4) - { - // Incomplete data. - break; - } - - const dataView = new DataView( - this.#recvBuffer.buffer, - this.#recvBuffer.byteOffset + msgStart); - const msgLen = dataView.getUint32(0, littleEndian); - - if (readLen < 4 + msgLen) - { - // Incomplete data. - break; - } - - const payload = this.#recvBuffer.subarray(msgStart + 4, msgStart + 4 + msgLen); - - msgStart += 4 + msgLen; - - this.processData(payload); - } - - if (msgStart != 0) - { - this.#recvBuffer = this.#recvBuffer.slice(msgStart); - } - }); - - this.#consumerSocket.on('end', () => ( - logger.debug('Consumer PayloadChannel ended by the worker process') - )); - - this.#consumerSocket.on('error', (error) => ( - logger.error('Consumer PayloadChannel error: %s', String(error)) - )); - - this.#producerSocket.on('end', () => ( - logger.debug('Producer PayloadChannel ended by the worker process') - )); - - this.#producerSocket.on('error', (error) => ( - logger.error('Producer PayloadChannel error: %s', String(error)) - )); - } - - /** - * @private - */ - close(): void - { - if (this.#closed) - { - return; - } - - logger.debug('close()'); - - this.#closed = true; - - // Remove event listeners but leave a fake 'error' handler to avoid - // propagation. - this.#consumerSocket.removeAllListeners('end'); - this.#consumerSocket.removeAllListeners('error'); - this.#consumerSocket.on('error', () => {}); - - this.#producerSocket.removeAllListeners('end'); - this.#producerSocket.removeAllListeners('error'); - this.#producerSocket.on('error', () => {}); - - // Destroy the socket after a while to allow pending incoming messages. - setTimeout(() => - { - try { this.#producerSocket.destroy(); } - catch (error) {} - try { this.#consumerSocket.destroy(); } - catch (error) {} - }, 200); - } - - /** - * @private - */ - notify( - event: string, - handlerId: string, - data: string | undefined, - payload: string | Buffer - ): void - { - logger.debug('notify() [event:%s]', event); - - if (this.#closed) - { - throw new InvalidStateError('PayloadChannel closed'); - } - - const notification = `n:${event}:${handlerId}:${data}`; - - if (Buffer.byteLength(notification) > MESSAGE_MAX_LEN) - { - throw new Error('PayloadChannel notification too big'); - } - else if (Buffer.byteLength(payload) > MESSAGE_MAX_LEN) - { - throw new Error('PayloadChannel payload too big'); - } - - try - { - // This may throw if closed or remote side ended. - this.#producerSocket.write( - Buffer.from(Uint32Array.of(Buffer.byteLength(notification)).buffer)); - this.#producerSocket.write(notification); - } - catch (error) - { - logger.warn('notify() | sending notification failed: %s', String(error)); - - return; - } - - try - { - // This may throw if closed or remote side ended. - this.#producerSocket.write( - Buffer.from(Uint32Array.of(Buffer.byteLength(payload)).buffer)); - this.#producerSocket.write(payload); - } - catch (error) - { - logger.warn('notify() | sending payload failed: %s', String(error)); - - return; - } - } - - /** - * @private - */ - async request( - method: string, - handlerId: string, - data: string, - payload: string | Buffer): Promise - { - this.#nextId < 4294967295 ? ++this.#nextId : (this.#nextId = 1); - - const id = this.#nextId; - - logger.debug('request() [method:%s, id:%s]', method, id); - - if (this.#closed) - { - throw new InvalidStateError('PayloadChannel closed'); - } - - const request = `r:${id}:${method}:${handlerId}:${data}`; - - if (Buffer.byteLength(request) > MESSAGE_MAX_LEN) - { - throw new Error('PayloadChannel request too big'); - } - else if (Buffer.byteLength(payload) > MESSAGE_MAX_LEN) - { - throw new Error('PayloadChannel payload too big'); - } - - // This may throw if closed or remote side ended. - this.#producerSocket.write( - Buffer.from(Uint32Array.of(Buffer.byteLength(request)).buffer)); - this.#producerSocket.write(request); - this.#producerSocket.write( - Buffer.from(Uint32Array.of(Buffer.byteLength(payload)).buffer)); - this.#producerSocket.write(payload); - - return new Promise((pResolve, pReject) => - { - const sent: Sent = - { - id : id, - method : method, - resolve : (data2) => - { - if (!this.#sents.delete(id)) - { - return; - } - - pResolve(data2); - }, - reject : (error) => - { - if (!this.#sents.delete(id)) - { - return; - } - - pReject(error); - }, - close : () => - { - pReject(new InvalidStateError('PayloadChannel closed')); - } - }; - - // Add sent stuff to the map. - this.#sents.set(id, sent); - }); - } - - private processData(data: Buffer): void - { - if (!this.#ongoingNotification) - { - let msg; - - try - { - msg = JSON.parse(data.toString('utf8')); - } - catch (error) - { - logger.error( - 'received invalid data from the worker process: %s', - String(error)); - - return; - } - - // If a response, retrieve its associated request. - if (msg.id) - { - const sent = this.#sents.get(msg.id); - - if (!sent) - { - logger.error( - 'received response does not match any sent request [id:%s]', msg.id); - - return; - } - - if (msg.accepted) - { - logger.debug( - 'request succeeded [method:%s, id:%s]', sent.method, sent.id); - - sent.resolve(msg.data); - } - else if (msg.error) - { - logger.warn( - 'request failed [method:%s, id:%s]: %s', - sent.method, sent.id, msg.reason); - - switch (msg.error) - { - case 'TypeError': - sent.reject(new TypeError(msg.reason)); - break; - - default: - sent.reject(new Error(msg.reason)); - } - } - else - { - logger.error( - 'received response is not accepted nor rejected [method:%s, id:%s]', - sent.method, sent.id); - } - } - // If a notification, create the ongoing notification instance. - else if (msg.targetId && msg.event) - { - this.#ongoingNotification = - { - targetId : String(msg.targetId), - event : msg.event, - data : msg.data - }; - } - else - { - logger.error('received data is not a notification nor a response'); - - return; - } - } - else - { - const payload = data as Buffer; - - // Emit the corresponding event. - this.emit( - this.#ongoingNotification.targetId, - this.#ongoingNotification.event, - this.#ongoingNotification.data, - payload); - - // Unset ongoing notification. - this.#ongoingNotification = undefined; - } - } -} diff --git a/node/src/PipeTransport.ts b/node/src/PipeTransport.ts index f312a79ec6..5f19519a49 100644 --- a/node/src/PipeTransport.ts +++ b/node/src/PipeTransport.ts @@ -1,20 +1,39 @@ import { v4 as uuidv4 } from 'uuid'; +import * as flatbuffers from 'flatbuffers'; import { Logger } from './Logger'; import * as ortc from './ortc'; import { + BaseTransportDump, + BaseTransportStats, + parseBaseTransportDump, + parseBaseTransportStats, + fbsSctpState2StcpState, + parseTuple, + parseTransportTraceEventData, Transport, TransportListenIp, TransportTuple, - TransportTraceEventData, TransportEvents, TransportObserverEvents, TransportConstructorOptions, SctpState } from './Transport'; import { Consumer, ConsumerType } from './Consumer'; +import { Producer } from './Producer'; +import { RtpParameters, serializeRtpEncodingParameters, serializeRtpParameters } from './RtpParameters'; import { SctpParameters, NumSctpStreams } from './SctpParameters'; -import { SrtpParameters } from './SrtpParameters'; +import { + parseSrtpParameters, + serializeSrtpParameters, + SrtpParameters +} from './SrtpParameters'; import { AppData } from './types'; +import { MediaKind as FbsMediaKind } from './fbs/rtp-parameters/media-kind'; +import * as FbsRtpParameters from './fbs/rtp-parameters'; +import { Event, Notification } from './fbs/notification'; +import * as FbsRequest from './fbs/request'; +import * as FbsTransport from './fbs/transport'; +import * as FbsPipeTransport from './fbs/pipe-transport'; export type PipeTransportOptions = { @@ -71,31 +90,9 @@ export type PipeTransportOptions appData?: PipeTransportAppData; }; -export type PipeTransportStat = +export type PipeTransportStat = BaseTransportStats & { - // Common to all Transports. type: string; - transportId: string; - timestamp: number; - sctpState?: SctpState; - bytesReceived: number; - recvBitrate: number; - bytesSent: number; - sendBitrate: number; - rtpBytesReceived: number; - rtpRecvBitrate: number; - rtpBytesSent: number; - rtpSendBitrate: number; - rtxBytesReceived: number; - rtxRecvBitrate: number; - rtxBytesSent: number; - rtxSendBitrate: number; - probationBytesSent: number; - probationSendBitrate: number; - availableOutgoingBitrate?: number; - availableIncomingBitrate?: number; - maxIncomingBitrate?: number; - // PipeTransport specific. tuple: TransportTuple; }; @@ -137,6 +134,13 @@ export type PipeTransportData = srtpParameters?: SrtpParameters; }; +export type PipeTransportDump = BaseTransportDump & +{ + tuple: TransportTuple; + rtx: boolean; + srtpParameters?: SrtpParameters; +}; + const logger = new Logger('PipeTransport'); export class PipeTransport @@ -250,7 +254,19 @@ export class PipeTransport { logger.debug('getStats()'); - return this.channel.request('transport.getStats', this.internal.transportId); + const response = await this.channel.request( + FbsRequest.Method.TRANSPORT_GET_STATS, + undefined, + undefined, + this.internal.transportId + ); + + /* Decode Response. */ + const data = new FbsPipeTransport.GetStatsResponse(); + + response.body(data); + + return [ parseGetStatsResponse(data) ]; } /** @@ -273,13 +289,31 @@ export class PipeTransport { logger.debug('connect()'); - const reqData = { ip, port, srtpParameters }; + const requestOffset = createConnectRequest({ + builder : this.channel.bufferBuilder, + ip, + port, + srtpParameters + }); - const data = - await this.channel.request('transport.connect', this.internal.transportId, reqData); + // Wait for response. + const response = await this.channel.request( + FbsRequest.Method.PIPE_TRANSPORT_CONNECT, + FbsRequest.Body.FBS_PipeTransport_ConnectRequest, + requestOffset, + this.internal.transportId + ); + + /* Decode Response. */ + const data = new FbsPipeTransport.ConnectResponse(); + + response.body(data); // Update data. - this.#data.tuple = data.tuple; + if (data.tuple()) + { + this.#data.tuple = parseTuple(data.tuple()!); + } } /** @@ -320,18 +354,28 @@ export class PipeTransport } ); - const reqData = - { - consumerId : uuidv4(), - producerId, - kind : producer.kind, - rtpParameters, - type : 'pipe', - consumableRtpEncodings : producer.consumableRtpParameters.encodings - }; + const consumerId = uuidv4(); - const status = - await this.channel.request('transport.consume', this.internal.transportId, reqData); + const consumeRequestOffset = createConsumeRequest({ + builder : this.channel.bufferBuilder, + consumerId, + producer, + rtpParameters + }); + + const response = await this.channel.request( + FbsRequest.Method.TRANSPORT_CONSUME, + FbsRequest.Body.FBS_Transport_ConsumeRequest, + consumeRequestOffset, + this.internal.transportId + ); + + /* Decode Response. */ + const consumeResponse = new FbsTransport.ConsumeResponse(); + + response.body(consumeResponse); + + const status = consumeResponse.unpack(); const data = { @@ -346,11 +390,10 @@ export class PipeTransport internal : { ...this.internal, - consumerId : reqData.consumerId + consumerId }, data, channel : this.channel, - payloadChannel : this.payloadChannel, appData, paused : status.paused, producerPaused : status.producerPaused @@ -368,13 +411,17 @@ export class PipeTransport private handleWorkerNotifications(): void { - this.channel.on(this.internal.transportId, (event: string, data?: any) => + this.channel.on(this.internal.transportId, (event: Event, data?: Notification) => { switch (event) { - case 'sctpstatechange': + case Event.TRANSPORT_SCTP_STATE_CHANGE: { - const sctpState = data.sctpState as SctpState; + const notification = new FbsTransport.SctpStateChangeNotification(); + + data!.body(notification); + + const sctpState = fbsSctpState2StcpState(notification.sctpState()); this.#data.sctpState = sctpState; @@ -386,9 +433,13 @@ export class PipeTransport break; } - case 'trace': + case Event.TRANSPORT_TRACE: { - const trace = data as TransportTraceEventData; + const notification = new FbsTransport.TraceNotification(); + + data!.body(notification); + + const trace = parseTransportTraceEventData(notification); this.safeEmit('trace', trace); @@ -406,3 +457,143 @@ export class PipeTransport }); } } + +/* + * flatbuffers helpers. + */ + +export function parsePipeTransportDumpResponse( + binary: FbsPipeTransport.DumpResponse +): PipeTransportDump +{ + // Retrieve BaseTransportDump. + const baseTransportDump = parseBaseTransportDump(binary.base()!); + // Retrieve RTP Tuple. + const tuple = parseTuple(binary.tuple()!); + + // Retrieve SRTP Parameters. + let srtpParameters: SrtpParameters | undefined; + + if (binary.srtpParameters()) + { + srtpParameters = parseSrtpParameters(binary.srtpParameters()!); + } + + return { + ...baseTransportDump, + tuple : tuple, + rtx : binary.rtx(), + srtpParameters : srtpParameters + }; +} + +function parseGetStatsResponse( + binary: FbsPipeTransport.GetStatsResponse +):PipeTransportStat +{ + const base = parseBaseTransportStats(binary.base()!); + + return { + ...base, + type : 'pipe-transport', + tuple : parseTuple(binary.tuple()!) + }; +} + +function createConsumeRequest({ + builder, + consumerId, + producer, + rtpParameters +} : { + builder: flatbuffers.Builder; + consumerId: string; + producer: Producer; + rtpParameters: RtpParameters; +}): number +{ + // Build the request. + const producerIdOffset = builder.createString(producer.id); + const consumerIdOffset = builder.createString(consumerId); + const rtpParametersOffset = serializeRtpParameters(builder, rtpParameters); + let consumableRtpEncodingsOffset: number | undefined; + + if (producer.consumableRtpParameters.encodings) + { + consumableRtpEncodingsOffset = serializeRtpEncodingParameters( + builder, producer.consumableRtpParameters.encodings + ); + } + + const ConsumeRequest = FbsTransport.ConsumeRequest; + + // Create Consume Request. + ConsumeRequest.startConsumeRequest(builder); + ConsumeRequest.addConsumerId(builder, consumerIdOffset); + ConsumeRequest.addProducerId(builder, producerIdOffset); + ConsumeRequest.addKind( + builder, producer.kind === 'audio' ? FbsMediaKind.AUDIO : FbsMediaKind.VIDEO); + ConsumeRequest.addRtpParameters(builder, rtpParametersOffset); + ConsumeRequest.addType(builder, FbsRtpParameters.Type.PIPE); + + if (consumableRtpEncodingsOffset) + { + ConsumeRequest.addConsumableRtpEncodings(builder, consumableRtpEncodingsOffset); + } + + return ConsumeRequest.endConsumeRequest(builder); +} + +function createConnectRequest( + { + builder, + ip, + port, + srtpParameters + }: + { + builder: flatbuffers.Builder; + ip?: string; + port?: number; + srtpParameters?: SrtpParameters; + } +): number +{ + try + { + let ipOffset = 0; + let srtpParametersOffset = 0; + + if (ip) + { + ipOffset = builder.createString(ip); + } + + // Serialize SrtpParameters. + if (srtpParameters) + { + srtpParametersOffset = serializeSrtpParameters(builder, srtpParameters); + } + + // Create PlainTransportConnectData. + FbsPipeTransport.ConnectRequest.startConnectRequest(builder); + FbsPipeTransport.ConnectRequest.addIp(builder, ipOffset); + + if (typeof port === 'number') + { + FbsPipeTransport.ConnectRequest.addPort(builder, port); + } + if (srtpParameters) + { + FbsPipeTransport.ConnectRequest.addSrtpParameters( + builder, srtpParametersOffset + ); + } + + return FbsPipeTransport.ConnectRequest.endConnectRequest(builder); + } + catch (error) + { + throw new TypeError(`${error}`); + } +} diff --git a/node/src/PlainTransport.ts b/node/src/PlainTransport.ts index 23c4e266c0..803442662e 100644 --- a/node/src/PlainTransport.ts +++ b/node/src/PlainTransport.ts @@ -1,17 +1,33 @@ +import * as flatbuffers from 'flatbuffers'; import { Logger } from './Logger'; import { + fbsSctpState2StcpState, + BaseTransportDump, + BaseTransportStats, + parseTuple, + parseBaseTransportDump, + parseBaseTransportStats, + parseTransportTraceEventData, Transport, TransportListenIp, TransportTuple, - TransportTraceEventData, TransportEvents, TransportObserverEvents, TransportConstructorOptions, SctpState } from './Transport'; import { SctpParameters, NumSctpStreams } from './SctpParameters'; -import { SrtpParameters, SrtpCryptoSuite } from './SrtpParameters'; +import { + parseSrtpParameters, + serializeSrtpParameters, + SrtpParameters, + SrtpCryptoSuite +} from './SrtpParameters'; import { AppData } from './types'; +import { Event, Notification } from './fbs/notification'; +import * as FbsRequest from './fbs/request'; +import * as FbsTransport from './fbs/transport'; +import * as FbsPlainTransport from './fbs/plain-transport'; export type PlainTransportOptions = { @@ -79,31 +95,9 @@ export type PlainTransportOptions @@ -255,6 +258,28 @@ export class PlainTransport super.routerClosed(); } + /** + * Dump Transport. + */ + async dump(): Promise + { + logger.debug('dump()'); + + const response = await this.channel.request( + FbsRequest.Method.TRANSPORT_DUMP, + undefined, + undefined, + this.internal.transportId + ); + + /* Decode Response. */ + const data = new FbsPlainTransport.DumpResponse(); + + response.body(data); + + return parsePlainTransportDumpResponse(data); + } + /** * Get PlainTransport stats. * @@ -264,7 +289,19 @@ export class PlainTransport { logger.debug('getStats()'); - return this.channel.request('transport.getStats', this.internal.transportId); + const response = await this.channel.request( + FbsRequest.Method.TRANSPORT_GET_STATS, + undefined, + undefined, + this.internal.transportId + ); + + /* Decode Response. */ + const data = new FbsPlainTransport.GetStatsResponse(); + + response.body(data); + + return [ parseGetStatsResponse(data) ]; } /** @@ -289,34 +326,58 @@ export class PlainTransport { logger.debug('connect()'); - const reqData = { ip, port, rtcpPort, srtpParameters }; + const requestOffset = createConnectRequest({ + builder : this.channel.bufferBuilder, + ip, + port, + rtcpPort, + srtpParameters + }); + + // Wait for response. + const response = await this.channel.request( + FbsRequest.Method.PLAIN_TRANSPORT_CONNECT, + FbsRequest.Body.FBS_PlainTransport_ConnectRequest, + requestOffset, + this.internal.transportId + ); + + /* Decode Response. */ + const data = new FbsPlainTransport.ConnectResponse(); - const data = - await this.channel.request('transport.connect', this.internal.transportId, reqData); + response.body(data); // Update data. - if (data.tuple) + if (data.tuple()) { - this.#data.tuple = data.tuple; + this.#data.tuple = parseTuple(data.tuple()!); } - if (data.rtcpTuple) + if (data.rtcpTuple()) { - this.#data.rtcpTuple = data.rtcpTuple; + this.#data.rtcpTuple = parseTuple(data.rtcpTuple()!); } - this.#data.srtpParameters = data.srtpParameters; + if (data.srtpParameters()) + { + this.#data.srtpParameters = parseSrtpParameters( + data.srtpParameters()!); + } } private handleWorkerNotifications(): void { - this.channel.on(this.internal.transportId, (event: string, data?: any) => + this.channel.on(this.internal.transportId, (event: Event, data?: Notification) => { switch (event) { - case 'tuple': + case Event.PLAINTRANSPORT_TUPLE: { - const tuple = data.tuple as TransportTuple; + const notification = new FbsPlainTransport.TupleNotification(); + + data!.body(notification); + + const tuple = parseTuple(notification.tuple()!); this.#data.tuple = tuple; @@ -328,9 +389,13 @@ export class PlainTransport break; } - case 'rtcptuple': + case Event.PLAINTRANSPORT_RTCP_TUPLE: { - const rtcpTuple = data.rtcpTuple as TransportTuple; + const notification = new FbsPlainTransport.RtcpTupleNotification(); + + data!.body(notification); + + const rtcpTuple = parseTuple(notification.tuple()!); this.#data.rtcpTuple = rtcpTuple; @@ -342,9 +407,13 @@ export class PlainTransport break; } - case 'sctpstatechange': + case Event.TRANSPORT_SCTP_STATE_CHANGE: { - const sctpState = data.sctpState as SctpState; + const notification = new FbsTransport.SctpStateChangeNotification(); + + data!.body(notification); + + const sctpState = fbsSctpState2StcpState(notification.sctpState()); this.#data.sctpState = sctpState; @@ -356,9 +425,13 @@ export class PlainTransport break; } - case 'trace': + case Event.TRANSPORT_TRACE: { - const trace = data as TransportTraceEventData; + const notification = new FbsTransport.TraceNotification(); + + data!.body(notification); + + const trace = parseTransportTraceEventData(notification); this.safeEmit('trace', trace); @@ -376,3 +449,116 @@ export class PlainTransport }); } } + +export function parsePlainTransportDumpResponse( + binary: FbsPlainTransport.DumpResponse +): PlainTransportDump +{ + // Retrieve BaseTransportDump. + const baseTransportDump = parseBaseTransportDump(binary.base()!); + // Retrieve RTP Tuple. + const tuple = parseTuple(binary.tuple()!); + + // Retrieve RTCP Tuple. + let rtcpTuple: TransportTuple | undefined; + + if (binary.rtcpTuple()) + { + rtcpTuple = parseTuple(binary.rtcpTuple()!); + } + + // Retrieve SRTP Parameters. + let srtpParameters: SrtpParameters | undefined; + + if (binary.srtpParameters()) + { + srtpParameters = parseSrtpParameters(binary.srtpParameters()!); + } + + return { + ...baseTransportDump, + rtcpMux : binary.rtcpMux(), + comedia : binary.comedia(), + tuple : tuple, + rtcpTuple : rtcpTuple, + srtpParameters : srtpParameters + }; +} + +function parseGetStatsResponse( + binary: FbsPlainTransport.GetStatsResponse +):PlainTransportStat +{ + const base = parseBaseTransportStats(binary.base()!); + + return { + ...base, + type : 'plain-rtp-transport', + rtcpMux : binary.rtcpMux(), + comedia : binary.comedia(), + tuple : parseTuple(binary.tuple()!), + rtcpTuple : binary.rtcpTuple() ? + parseTuple(binary.rtcpTuple()!) : + undefined + }; +} + +function createConnectRequest( + { + builder, + ip, + port, + rtcpPort, + srtpParameters + }: + { + builder : flatbuffers.Builder; + ip?: string; + port?: number; + rtcpPort?: number; + srtpParameters?: SrtpParameters; + } +): number +{ + try + { + let ipOffset = 0; + let srtpParametersOffset = 0; + + if (ip) + { + ipOffset = builder.createString(ip); + } + + // Serialize SrtpParameters. + if (srtpParameters) + { + srtpParametersOffset = serializeSrtpParameters(builder, srtpParameters); + } + + // Create PlainTransportConnectData. + FbsPlainTransport.ConnectRequest.startConnectRequest(builder); + FbsPlainTransport.ConnectRequest.addIp(builder, ipOffset); + + if (typeof port === 'number') + { + FbsPlainTransport.ConnectRequest.addPort(builder, port); + } + if (typeof rtcpPort === 'number') + { + FbsPlainTransport.ConnectRequest.addRtcpPort(builder, rtcpPort); + } + if (srtpParameters) + { + FbsPlainTransport.ConnectRequest.addSrtpParameters( + builder, srtpParametersOffset + ); + } + + return FbsPlainTransport.ConnectRequest.endConnectRequest(builder); + } + catch (error) + { + throw new TypeError(`${error}`); + } +} diff --git a/node/src/Producer.ts b/node/src/Producer.ts index 2d152ffb40..93e2d71506 100644 --- a/node/src/Producer.ts +++ b/node/src/Producer.ts @@ -1,10 +1,18 @@ import { Logger } from './Logger'; import { EnhancedEventEmitter } from './EnhancedEventEmitter'; import { Channel } from './Channel'; -import { PayloadChannel } from './PayloadChannel'; import { TransportInternal } from './Transport'; -import { MediaKind, RtpParameters } from './RtpParameters'; +import { MediaKind, RtpParameters, parseRtpParameters } from './RtpParameters'; +import { Event, Notification } from './fbs/notification'; +import { parseRtpStreamRecvStats, RtpStreamRecvStats } from './RtpStream'; import { AppData } from './types'; +import * as utils from './utils'; +import * as FbsNotification from './fbs/notification'; +import * as FbsRequest from './fbs/request'; +import * as FbsTransport from './fbs/transport'; +import * as FbsProducer from './fbs/producer'; +import * as FbsProducerTraceInfo from './fbs/producer/trace-info'; +import * as FbsRtpParameters from './fbs/rtp-parameters'; export type ProducerOptions = { @@ -107,35 +115,7 @@ export type ProducerVideoOrientation = rotation: number; }; -export type ProducerStat = -{ - // Common to all RtpStreams. - type: string; - timestamp: number; - ssrc: number; - rtxSsrc?: number; - rid?: string; - kind: string; - mimeType: string; - packetsLost: number; - fractionLost: number; - packetsDiscarded: number; - packetsRetransmitted: number; - packetsRepaired: number; - nackCount: number; - nackPacketCount: number; - pliCount: number; - firCount: number; - score: number; - packetCount: number; - byteCount: number; - bitrate: number; - roundTripTime?: number; - rtxPacketsDiscarded?: number; - // RtpStreamRecv specific. - jitter: number; - bitrateByLayer?: any; -}; +export type ProducerStat = RtpStreamRecvStats; /** * Producer type. @@ -162,6 +142,17 @@ export type ProducerObserverEvents = trace: [ProducerTraceEventData]; }; +type ProducerDump = { + id: string; + kind: string; + type:ProducerType; + rtpParameters:RtpParameters; + rtpMapping:any; + rtpStreams:any; + traceEventTypes:string[]; + paused:boolean; +}; + type ProducerInternal = TransportInternal & { producerId: string; @@ -189,9 +180,6 @@ export class Producer // Channel instance. readonly #channel: Channel; - // PayloadChannel instance. - readonly #payloadChannel: PayloadChannel; - // Closed flag. #closed = false; @@ -215,7 +203,6 @@ export class Producer internal, data, channel, - payloadChannel, appData, paused }: @@ -223,7 +210,6 @@ export class Producer internal: ProducerInternal; data: ProducerData; channel: Channel; - payloadChannel: PayloadChannel; appData?: ProducerAppData; paused: boolean; } @@ -236,7 +222,6 @@ export class Producer this.#internal = internal; this.#data = data; this.#channel = channel; - this.#payloadChannel = payloadChannel; this.#appData = appData || {} as ProducerAppData; this.#paused = paused; @@ -358,12 +343,18 @@ export class Producer // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.producerId); - this.#payloadChannel.removeAllListeners(this.#internal.producerId); - const reqData = { producerId: this.#internal.producerId }; + /* Build Request. */ + const requestOffset = new FbsTransport.CloseProducerRequestT( + this.#internal.producerId + ).pack(this.#channel.bufferBuilder); - this.#channel.request('transport.closeProducer', this.#internal.transportId, reqData) - .catch(() => {}); + this.#channel.request( + FbsRequest.Method.TRANSPORT_CLOSE_PRODUCER, + FbsRequest.Body.FBS_Transport_CloseProducerRequest, + requestOffset, + this.#internal.transportId + ).catch(() => {}); this.emit('@close'); @@ -389,7 +380,6 @@ export class Producer // Remove notification subscriptions. this.#channel.removeAllListeners(this.#internal.producerId); - this.#payloadChannel.removeAllListeners(this.#internal.producerId); this.safeEmit('transportclose'); @@ -400,11 +390,23 @@ export class Producer /** * Dump Producer. */ - async dump(): Promise + async dump(): Promise { logger.debug('dump()'); - return this.#channel.request('producer.dump', this.#internal.producerId); + const response = await this.#channel.request( + FbsRequest.Method.PRODUCER_DUMP, + undefined, + undefined, + this.#internal.producerId + ); + + /* Decode Response. */ + const dumpResponse = new FbsProducer.DumpResponse(); + + response.body(dumpResponse); + + return parseProducerDump(dumpResponse); } /** @@ -414,7 +416,19 @@ export class Producer { logger.debug('getStats()'); - return this.#channel.request('producer.getStats', this.#internal.producerId); + const response = await this.#channel.request( + FbsRequest.Method.PRODUCER_GET_STATS, + undefined, + undefined, + this.#internal.producerId + ); + + /* Decode Response. */ + const data = new FbsProducer.GetStatsResponse(); + + response.body(data); + + return parseProducerStats(data); } /** @@ -426,7 +440,12 @@ export class Producer const wasPaused = this.#paused; - await this.#channel.request('producer.pause', this.#internal.producerId); + await this.#channel.request( + FbsRequest.Method.PRODUCER_PAUSE, + undefined, + undefined, + this.#internal.producerId + ); this.#paused = true; @@ -446,7 +465,12 @@ export class Producer const wasPaused = this.#paused; - await this.#channel.request('producer.resume', this.#internal.producerId); + await this.#channel.request( + FbsRequest.Method.PRODUCER_RESUME, + undefined, + undefined, + this.#internal.producerId + ); this.#paused = false; @@ -464,10 +488,26 @@ export class Producer { logger.debug('enableTraceEvent()'); - const reqData = { types }; + if (!Array.isArray(types)) + { + throw new TypeError('types must be an array'); + } + if (types.find((type) => typeof type !== 'string')) + { + throw new TypeError('every type must be a string'); + } + + /* Build Request. */ + const requestOffset = new FbsProducer.EnableTraceEventRequestT( + types + ).pack(this.#channel.bufferBuilder); await this.#channel.request( - 'producer.enableTraceEvent', this.#internal.producerId, reqData); + FbsRequest.Method.PRODUCER_ENABLE_TRACE_EVENT, + FbsRequest.Body.FBS_Producer_EnableTraceEventRequest, + requestOffset, + this.#internal.producerId + ); } /** @@ -480,19 +520,36 @@ export class Producer throw new TypeError('rtpPacket must be a Buffer'); } - this.#payloadChannel.notify( - 'producer.send', this.#internal.producerId, undefined, rtpPacket); + const builder = this.#channel.bufferBuilder; + const dataOffset = FbsProducer.SendNotification.createDataVector(builder, rtpPacket); + const notificationOffset = FbsProducer.SendNotification.createSendNotification( + builder, + dataOffset + ); + + this.#channel.notify( + FbsNotification.Event.PRODUCER_SEND, + FbsNotification.Body.FBS_Producer_SendNotification, + notificationOffset, + this.#internal.producerId + ); } private handleWorkerNotifications(): void { - this.#channel.on(this.#internal.producerId, (event: string, data?: any) => + this.#channel.on(this.#internal.producerId, (event: Event, data?: Notification) => { switch (event) { - case 'score': + case Event.PRODUCER_SCORE: { - const score = data as ProducerScore[]; + const notification = new FbsProducer.ScoreNotification(); + + data!.body(notification); + + const score: ProducerScore[] = utils.parseVector( + notification, 'scores', parseProducerScore + ); this.#score = score; @@ -504,9 +561,13 @@ export class Producer break; } - case 'videoorientationchange': + case Event.PRODUCER_VIDEO_ORIENTATION_CHANGE: { - const videoOrientation = data as ProducerVideoOrientation; + const notification = new FbsProducer.VideoOrientationChangeNotification(); + + data!.body(notification); + + const videoOrientation: ProducerVideoOrientation = notification.unpack(); this.safeEmit('videoorientationchange', videoOrientation); @@ -516,9 +577,13 @@ export class Producer break; } - case 'trace': + case Event.PRODUCER_TRACE: { - const trace = data as ProducerTraceEventData; + const notification = new FbsProducer.TraceNotification(); + + data!.body(notification); + + const trace: ProducerTraceEventData = parseTraceEventData(notification); this.safeEmit('trace', trace); @@ -536,3 +601,83 @@ export class Producer }); } } + +export function parseProducerDump( + data: FbsProducer.DumpResponse +): ProducerDump +{ + return { + id : data.id()!, + kind : data.kind() === FbsRtpParameters.MediaKind.AUDIO ? 'audio' : 'video', + type : data.type()! as ProducerType, + rtpParameters : parseRtpParameters(data.rtpParameters()!), + // NOTE: optional values are represented with null instead of undefined. + // TODO: Make flatbuffers TS return undefined instead of null. + rtpMapping : data.rtpMapping() ? data.rtpMapping()!.unpack() : undefined, + // NOTE: optional values are represented with null instead of undefined. + // TODO: Make flatbuffers TS return undefined instead of null. + rtpStreams : data.rtpStreamsLength() > 0 ? + utils.parseVector(data, 'rtpStreams', (rtpStream: any) => rtpStream.unpack()) : + undefined, + traceEventTypes : utils.parseVector(data, 'traceEventTypes'), + paused : data.paused() + }; +} + +function parseProducerStats(binary: FbsProducer.GetStatsResponse): ProducerStat[] +{ + return utils.parseVector(binary, 'stats', parseRtpStreamRecvStats); +} + +function parseProducerScore( + binary: FbsProducer.Score +): ProducerScore +{ + return { + ssrc : binary.ssrc(), + rid : binary.rid() ?? undefined, + score : binary.score() + }; +} + +function parseTraceEventData( + trace: FbsProducer.TraceNotification +): ProducerTraceEventData +{ + let info: any; + + if (trace.infoType() !== FbsProducer.TraceInfo.NONE) + { + const accessor = trace.info.bind(trace); + + info = FbsProducerTraceInfo.unionToTraceInfo(trace.infoType(), accessor); + + trace.info(info); + } + + return { + type : fbstraceType2String(trace.type()), + timestamp : Number(trace.timestamp()), + direction : trace.direction() === FbsProducer.TraceDirection.DIRECTION_IN ? 'in' : 'out', + info : info ? info.unpack() : undefined + }; +} + +function fbstraceType2String(traceType: FbsProducer.TraceType): ProducerTraceEventType +{ + switch (traceType) + { + case FbsProducer.TraceType.KEYFRAME: + return 'keyframe'; + case FbsProducer.TraceType.FIR: + return 'fir'; + case FbsProducer.TraceType.NACK: + return 'nack'; + case FbsProducer.TraceType.PLI: + return 'pli'; + case FbsProducer.TraceType.RTP: + return 'rtp'; + default: + throw new TypeError(`invalid TraceType: ${traceType}`); + } +} diff --git a/node/src/Router.ts b/node/src/Router.ts index 21466d4c23..f41076338c 100644 --- a/node/src/Router.ts +++ b/node/src/Router.ts @@ -4,12 +4,11 @@ import { EnhancedEventEmitter } from './EnhancedEventEmitter'; import * as ortc from './ortc'; import { InvalidStateError } from './errors'; import { Channel } from './Channel'; -import { PayloadChannel } from './PayloadChannel'; import { Transport, TransportListenIp } from './Transport'; -import { WebRtcTransport, WebRtcTransportOptions } from './WebRtcTransport'; -import { PlainTransport, PlainTransportOptions } from './PlainTransport'; -import { PipeTransport, PipeTransportOptions } from './PipeTransport'; -import { DirectTransport, DirectTransportOptions } from './DirectTransport'; +import { WebRtcTransport, WebRtcTransportOptions, parseWebRtcTransportDumpResponse } from './WebRtcTransport'; +import { PlainTransport, PlainTransportOptions, parsePlainTransportDumpResponse } from './PlainTransport'; +import { PipeTransport, PipeTransportOptions, parsePipeTransportDumpResponse } from './PipeTransport'; +import { DirectTransport, DirectTransportOptions, parseDirectTransportDumpResponse } from './DirectTransport'; import { Producer } from './Producer'; import { Consumer } from './Consumer'; import { DataProducer } from './DataProducer'; @@ -20,6 +19,17 @@ import { AudioLevelObserver, AudioLevelObserverOptions } from './AudioLevelObser import { RtpCapabilities, RtpCodecCapability } from './RtpParameters'; import { NumSctpStreams } from './SctpParameters'; import { AppData } from './types'; +import * as FbsActiveSpeakerObserver from './fbs/active-speaker-observer'; +import * as FbsAudioLevelObserver from './fbs/audio-level-observer'; +import * as FbsRequest from './fbs/request'; +import * as FbsWorker from './fbs/worker'; +import * as FbsRouter from './fbs/router'; +import * as FbsPlainTransport from './fbs/plain-transport'; +import * as FbsPipeTransport from './fbs/pipe-transport'; +import * as FbsDirectTransport from './fbs/direct-transport'; +import * as FbsWebRtcTransport from './fbs/web-rtc-transport'; +import * as FbsTransport from './fbs/transport'; +import * as FbsSctpParameters from './fbs/sctp-parameters'; export type RouterOptions = { @@ -143,9 +153,6 @@ export class Router // Channel instance. readonly #channel: Channel; - // PayloadChannel instance. - readonly #payloadChannel: PayloadChannel; - // Closed flag. #closed = false; @@ -180,14 +187,12 @@ export class Router internal, data, channel, - payloadChannel, appData }: { internal: RouterInternal; data: RouterData; channel: Channel; - payloadChannel: PayloadChannel; appData?: RouterAppData; } ) @@ -199,7 +204,6 @@ export class Router this.#internal = internal; this.#data = data; this.#channel = channel; - this.#payloadChannel = payloadChannel; this.#appData = appData || {} as RouterAppData; } @@ -274,9 +278,13 @@ export class Router this.#closed = true; - const reqData = { routerId: this.#internal.routerId }; + const requestOffset = new FbsWorker.CloseRouterRequestT( + this.#internal.routerId).pack(this.#channel.bufferBuilder); - this.#channel.request('worker.closeRouter', undefined, reqData) + this.#channel.request( + FbsRequest.Method.WORKER_CLOSE_ROUTER, + FbsRequest.Body.FBS_Worker_CloseRouterRequest, + requestOffset) .catch(() => {}); // Close every Transport. @@ -354,7 +362,20 @@ export class Router { logger.debug('dump()'); - return this.#channel.request('router.dump', this.#internal.routerId); + // Send the request and wait for the response. + const response = await this.#channel.request( + FbsRequest.Method.ROUTER_DUMP, + undefined, + undefined, + this.#internal.routerId + ); + + /* Decode Response. */ + const dump = new FbsRouter.DumpResponse(); + + response.body(dump); + + return dump.unpack(); } /** @@ -384,6 +405,13 @@ export class Router { throw new TypeError('missing webRtcServer and listenIps (one of them is mandatory)'); } + else if ( + numSctpStreams && + (typeof numSctpStreams.OS !== 'number' || typeof numSctpStreams.MIS !== 'number') + ) + { + throw new TypeError('if given, numSctpStreams must contain OS and MID'); + } else if (appData && typeof appData !== 'object') { throw new TypeError('if given, appData must be an object'); @@ -391,6 +419,11 @@ export class Router if (listenIps) { + if (listenIps.length === 0) + { + throw new TypeError('empty listenIps array provided'); + } + listenIps = listenIps.map((listenIp) => { if (typeof listenIp === 'string' && listenIp) @@ -411,38 +444,85 @@ export class Router }); } - const reqData = + const transportId = uuidv4(); + + /* Build Request. */ + let webRtcTransportListenServer: + FbsWebRtcTransport.ListenServerT | undefined; + let webRtcTransportListenIndividual: + FbsWebRtcTransport.ListenIndividualT | undefined; + + if (webRtcServer) { - transportId : uuidv4(), - webRtcServerId : webRtcServer ? webRtcServer.id : undefined, - listenIps, - port, - enableUdp, - enableTcp, - preferUdp, - preferTcp, + webRtcTransportListenServer = + new FbsWebRtcTransport.ListenServerT(webRtcServer.id); + } + else + { + const fbsListenIps: FbsTransport.ListenIpT[] = []; + + for (const listenIp of listenIps as any[]) + { + fbsListenIps.push( + new FbsTransport.ListenIpT(listenIp.ip, listenIp.announcedIp)); + } + + webRtcTransportListenIndividual = + new FbsWebRtcTransport.ListenIndividualT(fbsListenIps, port); + } + + const baseTransportOptions = new FbsTransport.OptionsT( + undefined /* direct */, + undefined /* maxMessageSize */, initialAvailableOutgoingBitrate, enableSctp, - numSctpStreams, + new FbsSctpParameters.NumSctpStreamsT(numSctpStreams.OS, numSctpStreams.MIS), maxSctpMessageSize, sctpSendBufferSize, - isDataChannel : true - }; + true /* isDataChannel */ + ); + + const webRtcTransportOptions = new FbsWebRtcTransport.WebRtcTransportOptionsT( + baseTransportOptions, + webRtcServer ? + FbsWebRtcTransport.Listen.ListenServer : + FbsWebRtcTransport.Listen.ListenIndividual, + webRtcServer ? webRtcTransportListenServer : webRtcTransportListenIndividual, + enableUdp, + enableTcp, + preferUdp, + preferTcp + ); - const data = webRtcServer - ? await this.#channel.request('router.createWebRtcTransportWithServer', this.#internal.routerId, reqData) - : await this.#channel.request('router.createWebRtcTransport', this.#internal.routerId, reqData); + const requestOffset = new FbsRouter.CreateWebRtcTransportRequestT( + transportId, webRtcTransportOptions + ).pack(this.#channel.bufferBuilder); + + const response = await this.#channel.request( + webRtcServer + ? FbsRequest.Method.ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER + : FbsRequest.Method.ROUTER_CREATE_WEBRTC_TRANSPORT, + FbsRequest.Body.FBS_Router_CreateWebRtcTransportRequest, + requestOffset, + this.#internal.routerId + ); + + /* Decode Response. */ + const data = new FbsWebRtcTransport.DumpResponse(); + + response.body(data); + + const webRtcTransportData = parseWebRtcTransportDumpResponse(data); const transport = new WebRtcTransport( { internal : { ...this.#internal, - transportId : reqData.transportId + transportId : transportId }, - data, + data : webRtcTransportData, channel : this.#channel, - payloadChannel : this.#payloadChannel, appData, getRouterRtpCapabilities : (): RtpCapabilities => this.#data.rtpCapabilities, getProducerById : (producerId: string): Producer | undefined => ( @@ -523,35 +603,66 @@ export class Router throw new TypeError('wrong listenIp'); } - const reqData = - { - transportId : uuidv4(), - listenIp, - port, - rtcpMux, - comedia, + const transportId = uuidv4(); + + /* Build Request. */ + const baseTransportOptions = new FbsTransport.OptionsT( + undefined /* direct */, + undefined /* maxMessageSize */, + undefined /* initialAvailableOutgoingBitrate */, enableSctp, - numSctpStreams, + new FbsSctpParameters.NumSctpStreamsT(numSctpStreams.OS, numSctpStreams.MIS), maxSctpMessageSize, sctpSendBufferSize, - isDataChannel : false, + false /* isDataChannel */ + ); + + const plainTransportOptions = new FbsPlainTransport.PlainTransportOptionsT( + baseTransportOptions, + new FbsTransport.ListenIpT(listenIp.ip, listenIp.announcedIp), + port, + rtcpMux, + comedia, enableSrtp, srtpCryptoSuite - }; + ); + + let requestOffset; + + try + { + requestOffset = new FbsRouter.CreatePlainTransportRequestT( + transportId, plainTransportOptions + ).pack(this.#channel.bufferBuilder); + } + catch (error) + { + throw new TypeError((error as Error).message); + } + + const response = await this.#channel.request( + FbsRequest.Method.ROUTER_CREATE_PLAIN_TRANSPORT, + FbsRequest.Body.FBS_Router_CreatePlainTransportRequest, + requestOffset, + this.#internal.routerId + ); - const data = - await this.#channel.request('router.createPlainTransport', this.#internal.routerId, reqData); + /* Decode Response. */ + const data = new FbsPlainTransport.DumpResponse(); + + response.body(data); + + const plainTransportData = parsePlainTransportDumpResponse(data); const transport = new PlainTransport( { internal : { ...this.#internal, - transportId : reqData.transportId + transportId : transportId }, - data, + data : plainTransportData, channel : this.#channel, - payloadChannel : this.#payloadChannel, appData, getRouterRtpCapabilities : (): RtpCapabilities => this.#data.rtpCapabilities, getProducerById : (producerId: string): Producer | undefined => ( @@ -625,33 +736,55 @@ export class Router throw new TypeError('wrong listenIp'); } - const reqData = - { - transportId : uuidv4(), - listenIp, - port, + const transportId = uuidv4(); + + /* Build Request. */ + const baseTransportOptions = new FbsTransport.OptionsT( + undefined /* direct */, + undefined /* maxMessageSize */, + undefined /* initialAvailableOutgoingBitrate */, enableSctp, - numSctpStreams, + new FbsSctpParameters.NumSctpStreamsT(numSctpStreams.OS, numSctpStreams.MIS), maxSctpMessageSize, sctpSendBufferSize, - isDataChannel : false, + false /* isDataChannel */ + ); + + const pipeTransportOptions = new FbsPipeTransport.PipeTransportOptionsT( + baseTransportOptions, + new FbsTransport.ListenIpT(listenIp.ip, listenIp.announcedIp), + port, enableRtx, enableSrtp - }; + ); + + const requestOffset = new FbsRouter.CreatePipeTransportRequestT( + transportId, pipeTransportOptions + ).pack(this.#channel.bufferBuilder); + + const response = await this.#channel.request( + FbsRequest.Method.ROUTER_CREATE_PIPE_TRANSPORT, + FbsRequest.Body.FBS_Router_CreatePipeTransportRequest, + requestOffset, + this.#internal.routerId + ); + + /* Decode Response. */ + const data = new FbsPipeTransport.DumpResponse(); + + response.body(data); - const data = - await this.#channel.request('router.createPipeTransport', this.#internal.routerId, reqData); + const plainTransportData = parsePipeTransportDumpResponse(data); const transport = new PipeTransport( { internal : { ...this.#internal, - transportId : reqData.transportId + transportId }, - data, + data : plainTransportData, channel : this.#channel, - payloadChannel : this.#payloadChannel, appData, getRouterRtpCapabilities : (): RtpCapabilities => this.#data.rtpCapabilities, getProducerById : (producerId: string): Producer | undefined => ( @@ -695,26 +828,60 @@ export class Router { logger.debug('createDirectTransport()'); - const reqData = + if (typeof maxMessageSize !== 'number' || maxMessageSize < 0) { - transportId : uuidv4(), - direct : true, - maxMessageSize - }; + throw new TypeError('if given, maxMessageSize must be a positive number'); + } + else if (appData && typeof appData !== 'object') + { + throw new TypeError('if given, appData must be an object'); + } - const data = - await this.#channel.request('router.createDirectTransport', this.#internal.routerId, reqData); + const transportId = uuidv4(); + + /* Build Request. */ + const baseTransportOptions = new FbsTransport.OptionsT( + true /* direct */, + maxMessageSize, + undefined /* initialAvailableOutgoingBitrate */, + undefined /* enableSctp */, + undefined /* numSctpStreams */, + undefined /* maxSctpMessageSize */, + undefined /* sctpSendBufferSize */, + undefined /* isDataChannel */ + ); + + const directTransportOptions = new FbsDirectTransport.DirectTransportOptionsT( + baseTransportOptions + ); + + const requestOffset = new FbsRouter.CreateDirectTransportRequestT( + transportId, directTransportOptions + ).pack(this.#channel.bufferBuilder); + + const response = await this.#channel.request( + FbsRequest.Method.ROUTER_CREATE_DIRECT_TRANSPORT, + FbsRequest.Body.FBS_Router_CreateDirectTransportRequest, + requestOffset, + this.#internal.routerId + ); + + /* Decode Response. */ + const data = new FbsDirectTransport.DumpResponse(); + + response.body(data); + + const directTransportData = parseDirectTransportDumpResponse(data); const transport = new DirectTransport( { internal : { ...this.#internal, - transportId : reqData.transportId + transportId : transportId }, - data, + data : directTransportData, channel : this.#channel, - payloadChannel : this.#payloadChannel, appData, getRouterRtpCapabilities : (): RtpCapabilities => this.#data.rtpCapabilities, getProducerById : (producerId: string): Producer | undefined => ( @@ -1076,34 +1243,50 @@ export class Router { logger.debug('createActiveSpeakerObserver()'); + if (typeof interval !== 'number') + { + throw new TypeError('if given, interval must be an number'); + } if (appData && typeof appData !== 'object') { throw new TypeError('if given, appData must be an object'); } - - const reqData = - { - rtpObserverId : uuidv4(), - interval - }; - await this.#channel.request('router.createActiveSpeakerObserver', this.#internal.routerId, reqData); + const rtpObserverId = uuidv4(); + + /* Build Request. */ + const activeRtpObserverOptions = + new FbsActiveSpeakerObserver.ActiveSpeakerObserverOptionsT( + interval + ); + + const requestOffset = + new FbsRouter.CreateActiveSpeakerObserverRequestT( + rtpObserverId, + activeRtpObserverOptions + ).pack(this.#channel.bufferBuilder); + + await this.#channel.request( + FbsRequest.Method.ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER, + FbsRequest.Body.FBS_Router_CreateActiveSpeakerObserverRequest, + requestOffset, + this.#internal.routerId + ); const activeSpeakerObserver = new ActiveSpeakerObserver( { internal : { ...this.#internal, - rtpObserverId : reqData.rtpObserverId + rtpObserverId : rtpObserverId }, channel : this.#channel, - payloadChannel : this.#payloadChannel, appData, getProducerById : (producerId: string): Producer | undefined => ( this.#producers.get(producerId) ) }); - + this.#rtpObservers.set(activeSpeakerObserver.id, activeSpeakerObserver); activeSpeakerObserver.on('@close', () => { @@ -1130,30 +1313,53 @@ export class Router { logger.debug('createAudioLevelObserver()'); + if (typeof maxEntries !== 'number' || maxEntries <= 0) + { + throw new TypeError('if given, maxEntries must be a positive number'); + } + if (typeof threshold !== 'number' || threshold < -127 || threshold > 0) + { + throw new TypeError('if given, threshole must be a negative number greater than -127'); + } + if (typeof interval !== 'number') + { + throw new TypeError('if given, interval must be an number'); + } if (appData && typeof appData !== 'object') { throw new TypeError('if given, appData must be an object'); } - const reqData = - { - rtpObserverId : uuidv4(), - maxEntries, - threshold, - interval - }; + const rtpObserverId = uuidv4(); + + /* Build Request. */ + const audioLevelObserverOptions = + new FbsAudioLevelObserver.AudioLevelObserverOptionsT( + maxEntries, + threshold, + interval + ); + + const requestOffset = new FbsRouter.CreateAudioLevelObserverRequestT( + rtpObserverId, + audioLevelObserverOptions + ).pack(this.#channel.bufferBuilder); - await this.#channel.request('router.createAudioLevelObserver', this.#internal.routerId, reqData); + await this.#channel.request( + FbsRequest.Method.ROUTER_CREATE_AUDIO_LEVEL_OBSERVER, + FbsRequest.Body.FBS_Router_CreateAudioLevelObserverRequest, + requestOffset, + this.#internal.routerId + ); const audioLevelObserver = new AudioLevelObserver( { internal : { ...this.#internal, - rtpObserverId : reqData.rtpObserverId + rtpObserverId : rtpObserverId }, channel : this.#channel, - payloadChannel : this.#payloadChannel, appData, getProducerById : (producerId: string): Producer | undefined => ( this.#producers.get(producerId) diff --git a/node/src/RtpObserver.ts b/node/src/RtpObserver.ts index 3821d728d4..3ba450f722 100644 --- a/node/src/RtpObserver.ts +++ b/node/src/RtpObserver.ts @@ -1,10 +1,12 @@ import { Logger } from './Logger'; import { EnhancedEventEmitter } from './EnhancedEventEmitter'; import { Channel } from './Channel'; -import { PayloadChannel } from './PayloadChannel'; import { RouterInternal } from './Router'; import { Producer } from './Producer'; import { AppData } from './types'; +import * as FbsRequest from './fbs/request'; +import * as FbsRouter from './fbs/router'; +import * as FbsRtpObserver from './fbs/rtp-observer'; export type RtpObserverEvents = { @@ -26,7 +28,6 @@ export type RtpObserverConstructorOptions = { internal: RtpObserverObserverInternal; channel: Channel; - payloadChannel: PayloadChannel; appData?: RtpObserverAppData; getProducerById: (producerId: string) => Producer | undefined; }; @@ -57,9 +58,6 @@ export class RtpObserver // Channel instance. protected readonly channel: Channel; - // PayloadChannel instance. - protected readonly payloadChannel: PayloadChannel; - // Closed flag. #closed = false; @@ -83,7 +81,6 @@ export class RtpObserver { internal, channel, - payloadChannel, appData, getProducerById }: RtpObserverConstructorOptions @@ -95,7 +92,6 @@ export class RtpObserver this.internal = internal; this.channel = channel; - this.payloadChannel = payloadChannel; this.#appData = appData || {} as RtpObserverAppData; this.getProducerById = getProducerById; } @@ -164,12 +160,18 @@ export class RtpObserver // Remove notification subscriptions. this.channel.removeAllListeners(this.internal.rtpObserverId); - this.payloadChannel.removeAllListeners(this.internal.rtpObserverId); - const reqData = { rtpObserverId: this.internal.rtpObserverId }; + /* Build Request. */ + const requestOffset = new FbsRouter.CloseRtpObserverRequestT( + this.internal.rtpObserverId + ).pack(this.channel.bufferBuilder); - this.channel.request('router.closeRtpObserver', this.internal.routerId, reqData) - .catch(() => {}); + this.channel.request( + FbsRequest.Method.ROUTER_CLOSE_RTP_OBSERVER, + FbsRequest.Body.FBS_Router_CloseRtpObserverRequest, + requestOffset, + this.internal.routerId + ).catch(() => {}); this.emit('@close'); @@ -195,7 +197,6 @@ export class RtpObserver // Remove notification subscriptions. this.channel.removeAllListeners(this.internal.rtpObserverId); - this.payloadChannel.removeAllListeners(this.internal.rtpObserverId); this.safeEmit('routerclose'); @@ -212,7 +213,12 @@ export class RtpObserver const wasPaused = this.#paused; - await this.channel.request('rtpObserver.pause', this.internal.rtpObserverId); + await this.channel.request( + FbsRequest.Method.RTP_OBSERVER_PAUSE, + undefined, + undefined, + this.internal.rtpObserverId + ); this.#paused = true; @@ -232,7 +238,12 @@ export class RtpObserver const wasPaused = this.#paused; - await this.channel.request('rtpObserver.resume', this.internal.rtpObserverId); + await this.channel.request( + FbsRequest.Method.RTP_OBSERVER_RESUME, + undefined, + undefined, + this.internal.rtpObserverId + ); this.#paused = false; @@ -257,9 +268,16 @@ export class RtpObserver throw Error(`Producer with id "${producerId}" not found`); } - const reqData = { producerId }; + const requestOffset = new FbsRtpObserver.AddProducerRequestT( + producerId + ).pack(this.channel.bufferBuilder); - await this.channel.request('rtpObserver.addProducer', this.internal.rtpObserverId, reqData); + await this.channel.request( + FbsRequest.Method.RTP_OBSERVER_ADD_PRODUCER, + FbsRequest.Body.FBS_RtpObserver_AddProducerRequest, + requestOffset, + this.internal.rtpObserverId + ); // Emit observer event. this.#observer.safeEmit('addproducer', producer); @@ -279,9 +297,16 @@ export class RtpObserver throw Error(`Producer with id "${producerId}" not found`); } - const reqData = { producerId }; + const requestOffset = new FbsRtpObserver.RemoveProducerRequestT( + producerId + ).pack(this.channel.bufferBuilder); - await this.channel.request('rtpObserver.removeProducer', this.internal.rtpObserverId, reqData); + await this.channel.request( + FbsRequest.Method.RTP_OBSERVER_REMOVE_PRODUCER, + FbsRequest.Body.FBS_RtpObserver_RemoveProducerRequest, + requestOffset, + this.internal.rtpObserverId + ); // Emit observer event. this.#observer.safeEmit('removeproducer', producer); diff --git a/node/src/RtpParameters.ts b/node/src/RtpParameters.ts index c26cc86b3f..f7b7b94554 100644 --- a/node/src/RtpParameters.ts +++ b/node/src/RtpParameters.ts @@ -1,3 +1,22 @@ +import * as flatbuffers from 'flatbuffers'; +import { + Boolean as FbsBoolean, + Double as FbsDouble, + Integer as FbsInteger, + IntegerArray as FbsIntegerArray, + String as FbsString, + Parameter as FbsParameter, + RtcpFeedback as FbsRtcpFeedback, + RtcpParameters as FbsRtcpParameters, + RtpCodecParameters as FbsRtpCodecParameters, + RtpEncodingParameters as FbsRtpEncodingParameters, + RtpHeaderExtensionParameters as FbsRtpHeaderExtensionParameters, + RtpParameters as FbsRtpParameters, + Rtx as FbsRtx, + Value as FbsValue +} from './fbs/rtp-parameters'; +import * as utils from './utils'; + /** * The RTP capabilities define what mediasoup or an endpoint can receive at * media level. @@ -345,9 +364,427 @@ export type RtcpParameters = * as specified in RFC 3550 (if false). Default true. */ reducedSize?: boolean; - - /** - * Whether RTCP-mux is used. Default true. - */ - mux?: boolean; }; + +export function serializeRtpParameters( + builder: flatbuffers.Builder, rtpParameters: RtpParameters +): number +{ + const codecs: number[] = []; + const headerExtensions: number[] = []; + + for (const codec of rtpParameters.codecs) + { + const mimeTypeOffset = builder.createString(codec.mimeType); + const parameters = serializeParameters(builder, codec.parameters); + const parametersOffset = + FbsRtpCodecParameters.createParametersVector(builder, parameters); + + const rtcpFeedback: number[] = []; + + for (const rtcp of codec.rtcpFeedback?? []) + { + const typeOffset = builder.createString(rtcp.type); + const rtcpParametersOffset = builder.createString(rtcp.parameter); + + rtcpFeedback.push( + FbsRtcpFeedback.createRtcpFeedback(builder, typeOffset, rtcpParametersOffset)); + } + const rtcpFeedbackOffset = + FbsRtpCodecParameters.createRtcpFeedbackVector(builder, rtcpFeedback); + + codecs.push( + FbsRtpCodecParameters.createRtpCodecParameters( + builder, + mimeTypeOffset, + codec.payloadType, + codec.clockRate, + Number(codec.channels), + parametersOffset, + rtcpFeedbackOffset + )); + } + const codecsOffset = FbsRtpParameters.createCodecsVector(builder, codecs); + + // RtpHeaderExtensionParameters. + for (const headerExtension of rtpParameters.headerExtensions ?? []) + { + const uriOffset = builder.createString(headerExtension.uri); + const parameters = serializeParameters(builder, headerExtension.parameters); + const parametersOffset = + FbsRtpCodecParameters.createParametersVector(builder, parameters); + + headerExtensions.push( + FbsRtpHeaderExtensionParameters.createRtpHeaderExtensionParameters( + builder, + uriOffset, + headerExtension.id, + Boolean(headerExtension.encrypt), + parametersOffset)); + } + const headerExtensionsOffset = + FbsRtpParameters.createHeaderExtensionsVector(builder, headerExtensions); + + // RtpEncodingParameters. + let encodingsOffset: number | undefined; + + if (rtpParameters.encodings) + { + encodingsOffset = serializeRtpEncodingParameters(builder, rtpParameters.encodings); + } + + // RtcpParameters. + let rtcpOffset: number | undefined; + + if (rtpParameters.rtcp) + { + const { cname, reducedSize } = rtpParameters.rtcp; + const cnameOffset = builder.createString(cname); + + rtcpOffset = FbsRtcpParameters.createRtcpParameters( + builder, cnameOffset, Boolean(reducedSize) + ); + } + + const midOffset = builder.createString(rtpParameters.mid); + + FbsRtpParameters.startRtpParameters(builder); + FbsRtpParameters.addMid(builder, midOffset); + FbsRtpParameters.addCodecs(builder, codecsOffset); + + if (headerExtensions.length > 0) + { + FbsRtpParameters.addHeaderExtensions(builder, headerExtensionsOffset); + } + + if (encodingsOffset) + { + FbsRtpParameters.addEncodings(builder, encodingsOffset); + } + + if (rtcpOffset) + { + FbsRtpParameters.addRtcp(builder, rtcpOffset); + } + + return FbsRtpParameters.endRtpParameters(builder); +} + +export function serializeRtpEncodingParameters( + builder: flatbuffers.Builder, rtpEncodingParameters: RtpEncodingParameters[] +): number +{ + const encodings: number[] = []; + + for (const encoding of rtpEncodingParameters ?? []) + { + // Prepare Rid. + const ridOffset = builder.createString(encoding.rid); + + // Prepare Rtx. + let rtxOffset: number | undefined; + + if (encoding.rtx) + { + rtxOffset = FbsRtx.createRtx(builder, encoding.rtx.ssrc); + } + + // Prepare scalability mode. + let scalabilityModeOffset: number | undefined; + + if (encoding.scalabilityMode) + { + scalabilityModeOffset = builder.createString(encoding.scalabilityMode); + } + + // Start serialization. + FbsRtpEncodingParameters.startRtpEncodingParameters(builder); + + // Add SSRC. + if (encoding.ssrc) + { + FbsRtpEncodingParameters.addSsrc(builder, encoding.ssrc); + } + + // Add Rid. + FbsRtpEncodingParameters.addRid(builder, ridOffset); + + // Add payload type. + if (encoding.codecPayloadType) + { + FbsRtpEncodingParameters.addCodecPayloadType(builder, encoding.codecPayloadType); + } + + // Add RTX. + if (rtxOffset) + { + FbsRtpEncodingParameters.addRtx(builder, rtxOffset); + } + + // Add DTX. + if (encoding.dtx !== undefined) + { + FbsRtpEncodingParameters.addDtx(builder, encoding.dtx); + } + + // Add scalability ode. + if (scalabilityModeOffset) + { + FbsRtpEncodingParameters.addScalabilityMode(builder, scalabilityModeOffset); + } + + // Add max bitrate. + if (encoding.maxBitrate !== undefined) + { + FbsRtpEncodingParameters.addMaxBitrate(builder, encoding.maxBitrate); + } + + // End serialization. + encodings.push(FbsRtpEncodingParameters.endRtpEncodingParameters(builder)); + } + + return FbsRtpParameters.createEncodingsVector(builder, encodings); +} + +export function serializeParameters( + builder: flatbuffers.Builder, parameters: any +):number[] +{ + const fbsParameters: number[] = []; + + for (const key of Object.keys(parameters)) + { + const value = parameters[key]; + const keyOffset = builder.createString(key); + let parameterOffset: number; + + if (typeof value === 'boolean') + { + parameterOffset = FbsParameter.createParameter( + builder, keyOffset, FbsValue.Boolean, value === true ? 1:0 + ); + } + + else if (typeof value === 'number') + { + // Integer. + if (value % 1 === 0) + { + const valueOffset = FbsInteger.createInteger(builder, value); + + parameterOffset = FbsParameter.createParameter( + builder, keyOffset, FbsValue.Integer, valueOffset + ); + } + // Float. + else + { + const valueOffset = FbsDouble.createDouble(builder, value); + + parameterOffset = FbsParameter.createParameter( + builder, keyOffset, FbsValue.Double, valueOffset + ); + } + } + + else if (typeof value === 'string') + { + const valueOffset = FbsString.createString(builder, builder.createString(value)); + + parameterOffset = FbsParameter.createParameter( + builder, keyOffset, FbsValue.String, valueOffset + ); + } + + else if (Array.isArray(value)) + { + const valueOffset = FbsIntegerArray.createValueVector(builder, value); + + parameterOffset = FbsParameter.createParameter( + builder, keyOffset, FbsValue.IntegerArray, valueOffset + ); + } + + else + { + throw new Error(`invalid parameter type [key:'${key}', value:${value}]`); + } + + fbsParameters.push(parameterOffset); + } + + return fbsParameters; +} + +export function parseRtcpFeedback(data: FbsRtcpFeedback): RtcpFeedback +{ + return { + type : data.type()!, + parameter : data.parameter() ?? undefined + }; +} + +export function parseParameters(data: any): any +{ + const parameters: any = {}; + + for (let i=0; i 0) + { + rtcpFeedback = utils.parseVector(data, 'rtcpFeedback', parseRtcpFeedback); + } + + return { + mimeType : data.mimeType()!, + payloadType : data.payloadType(), + clockRate : data.clockRate(), + channels : data.channels() ?? undefined, + parameters, + rtcpFeedback + }; +} + +export function parseRtpHeaderExtensionParameters( + data: FbsRtpHeaderExtensionParameters): RtpHeaderExtensionParameters +{ + return { + uri : data.uri()!, + id : data.id(), + encrypt : data.encrypt(), + parameters : parseParameters(data) + }; +} + +export function parseRtpEncodingParameters( + data: FbsRtpEncodingParameters): RtpEncodingParameters +{ + return { + ssrc : data.ssrc() ?? undefined, + rid : data.rid() ?? undefined, + codecPayloadType : data.codecPayloadType() !== null ? + data.codecPayloadType()! : + undefined, + rtx : data.rtx() ? + { ssrc: data.rtx()!.ssrc()! } : + undefined, + dtx : data.dtx(), + scalabilityMode : data.scalabilityMode() ?? undefined, + maxBitrate : data.maxBitrate() !== null ? data.maxBitrate()! : undefined + }; +} + +export function parseRtpParameters(data: FbsRtpParameters): RtpParameters +{ + const codecs = utils.parseVector(data, 'codecs', parseRtpCodecParameters); + + let headerExtensions: RtpHeaderExtensionParameters[] = []; + + if (data.headerExtensionsLength() > 0) + { + headerExtensions = utils.parseVector( + data, + 'headerExtensions', + parseRtpHeaderExtensionParameters); + } + + let encodings: RtpEncodingParameters[] = []; + + if (data.encodingsLength() > 0) + { + encodings = utils.parseVector( + data, + 'encodings', + parseRtpEncodingParameters); + } + + let rtcp: RtcpParameters | undefined; + + if (data.rtcp()) + { + const fbsRtcp = data.rtcp()!; + + rtcp = { + cname : fbsRtcp.cname() ?? undefined, + reducedSize : fbsRtcp.reducedSize() + }; + } + + return { + mid : data.mid() ?? undefined, + codecs, + headerExtensions, + encodings, + rtcp + }; +} diff --git a/node/src/RtpStream.ts b/node/src/RtpStream.ts new file mode 100644 index 0000000000..aa986cd46c --- /dev/null +++ b/node/src/RtpStream.ts @@ -0,0 +1,138 @@ +import * as FbsRtpStream from './fbs/rtp-stream'; +import * as FbsRtpParameters from './fbs/rtp-parameters'; + +export type RtpStreamRecvStats = BaseRtpStreamStats & { + type: string; + jitter: number; + packetCount: number; + byteCount: number; + bitrate: number; + bitrateByLayer?: any; +}; + +export type RtpStreamSendStats = BaseRtpStreamStats & { + type: string; + packetCount: number; + byteCount: number; + bitrate: number; +}; + +type BaseRtpStreamStats = { + timestamp: number; + ssrc: number; + rtxSsrc?: number; + rid?: string; + kind: string; + mimeType: string; + packetsLost: number; + fractionLost: number; + packetsDiscarded: number; + packetsRetransmitted: number; + packetsRepaired: number; + nackCount: number; + nackPacketCount: number; + pliCount: number; + firCount: number; + score: number; + roundTripTime?: number; + rtxPacketsDiscarded?: number; +}; + +export function parseRtpStreamStats(binary: FbsRtpStream.Stats) + : RtpStreamRecvStats | RtpStreamSendStats +{ + if (binary.dataType() === FbsRtpStream.StatsData.RecvStats) + { + return parseRtpStreamRecvStats(binary); + } + else + { + return parseSendStreamStats(binary); + } +} + +export function parseRtpStreamRecvStats(binary: FbsRtpStream.Stats): RtpStreamRecvStats +{ + const recvStats = new FbsRtpStream.RecvStats(); + const baseStats = new FbsRtpStream.BaseStats(); + + binary.data(recvStats); + recvStats.base()!.data(baseStats); + + const base = parseBaseStreamStats(baseStats); + + return { + ...base, + type : 'inbound-rtp', + jitter : recvStats.jitter(), + byteCount : Number(recvStats.byteCount()), + packetCount : Number(recvStats.packetCount()), + bitrate : Number(recvStats.bitrate()), + bitrateByLayer : parseBitrateByLayer(recvStats) + }; +} + +export function parseSendStreamStats(binary: FbsRtpStream.Stats): RtpStreamSendStats +{ + const sendStats = new FbsRtpStream.SendStats(); + const baseStats = new FbsRtpStream.BaseStats(); + + binary.data(sendStats); + sendStats.base()!.data(baseStats); + + const base = parseBaseStreamStats(baseStats); + + return { + ...base, + type : 'outbound-rtp', + byteCount : Number(sendStats.byteCount()), + packetCount : Number(sendStats.packetCount()), + bitrate : Number(sendStats.bitrate()) + }; +} + +function parseBaseStreamStats(binary: FbsRtpStream.BaseStats): BaseRtpStreamStats +{ + return { + timestamp : Number(binary.timestamp()), + ssrc : binary.ssrc(), + rtxSsrc : binary.rtxSsrc() ?? undefined, + rid : binary.rid() ?? undefined, + kind : binary.kind() === FbsRtpParameters.MediaKind.AUDIO ? + 'audio' : + 'video', + mimeType : binary.mimeType()!, + packetsLost : Number(binary.packetsLost()), + fractionLost : Number(binary.fractionLost()), + packetsDiscarded : Number(binary.packetsDiscarded()), + packetsRetransmitted : Number(binary.packetsRetransmitted()), + packetsRepaired : Number(binary.packetsRepaired()), + nackCount : Number(binary.nackCount()), + nackPacketCount : Number(binary.nackPacketCount()), + pliCount : Number(binary.pliCount()), + firCount : Number(binary.firCount()), + score : binary.score(), + roundTripTime : binary.roundTripTime(), + rtxPacketsDiscarded : binary.rtxPacketsDiscarded() ? + Number(binary.rtxPacketsDiscarded()) : + undefined + }; +} + +function parseBitrateByLayer(binary: FbsRtpStream.RecvStats): any +{ + if (binary.bitrateByLayerLength() === 0) + { + return {}; + } + + const bitRateByLayer: {[key: string]: number} = {}; + + for (let i=0; i < binary.bitrateByLayerLength(); ++i) + { + const layer: string = binary.bitrateByLayer(i)!.layer()!; + const bitrate = binary.bitrateByLayer(i)!.bitrate(); + + bitRateByLayer[layer] = Number(bitrate); + } +} diff --git a/node/src/SctpParameters.ts b/node/src/SctpParameters.ts index 82079d4516..54a878fb6a 100644 --- a/node/src/SctpParameters.ts +++ b/node/src/SctpParameters.ts @@ -1,3 +1,6 @@ +import * as flatbuffers from 'flatbuffers'; +import * as FbsSctpParameters from './fbs/sctp-parameters'; + export type SctpCapabilities = { numStreams: NumSctpStreams; @@ -93,3 +96,63 @@ export type SctpStreamParameters = */ maxRetransmits?: number; }; + +export type SctpParametersDump = +{ + port : number; + OS : number; + MIS : number; + maxMessageSize : number; + sendBufferSize : number; + sctpBufferedAmount : number; + isDataChannel : boolean; +}; + +export function parseSctpParametersDump( + binary: FbsSctpParameters.SctpParameters +): SctpParametersDump +{ + return { + port : binary.port(), + OS : binary.os(), + MIS : binary.mis(), + maxMessageSize : binary.maxMessageSize(), + sendBufferSize : binary.sendBufferSize(), + sctpBufferedAmount : binary.sctpBufferedAmount(), + isDataChannel : binary.isDataChannel() + }; +} + +export function serializeSctpStreamParameters( + builder: flatbuffers.Builder, + parameters: SctpStreamParameters +): number +{ + return FbsSctpParameters.SctpStreamParameters.createSctpStreamParameters( + builder, + parameters.streamId, + parameters.ordered!, + typeof parameters.maxPacketLifeTime === 'number' ? + parameters.maxPacketLifeTime : + null, + typeof parameters.maxRetransmits === 'number' ? + parameters.maxRetransmits : + null + ); +} + +export function parseSctpStreamParameters( + parameters: FbsSctpParameters.SctpStreamParameters +): SctpStreamParameters +{ + return { + streamId : parameters.streamId(), + ordered : parameters.ordered()!, + maxPacketLifeTime : parameters.maxPacketLifeTime() !== null ? + parameters.maxPacketLifeTime()! : + undefined, + maxRetransmits : parameters.maxRetransmits() !== null ? + parameters.maxRetransmits()! : + undefined + }; +} diff --git a/node/src/SrtpParameters.ts b/node/src/SrtpParameters.ts index 1cbddce46c..412c4c6ec9 100644 --- a/node/src/SrtpParameters.ts +++ b/node/src/SrtpParameters.ts @@ -1,3 +1,6 @@ +import * as flatbuffers from 'flatbuffers'; +import * as FbsTransport from './fbs/transport'; + /** * SRTP parameters. */ @@ -22,3 +25,23 @@ export type SrtpCryptoSuite = | 'AEAD_AES_128_GCM' | 'AES_CM_128_HMAC_SHA1_80' | 'AES_CM_128_HMAC_SHA1_32'; + +export function parseSrtpParameters(binary: FbsTransport.SrtpParameters): SrtpParameters +{ + return { + cryptoSuite : binary.cryptoSuite()! as SrtpCryptoSuite, + keyBase64 : binary.keyBase64()! + }; +} + +export function serializeSrtpParameters( + builder:flatbuffers.Builder, srtpParameters:SrtpParameters +): number +{ + const cryptoSuiteOffset = builder.createString(srtpParameters.cryptoSuite); + const keyBase64Offset = builder.createString(srtpParameters.keyBase64); + + return FbsTransport.SrtpParameters.createSrtpParameters( + builder, cryptoSuiteOffset, keyBase64Offset + ); +} diff --git a/node/src/Transport.ts b/node/src/Transport.ts index 5d31e794ac..c1cec39978 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -1,30 +1,51 @@ import { v4 as uuidv4 } from 'uuid'; +import * as flatbuffers from 'flatbuffers'; import { Logger } from './Logger'; import { EnhancedEventEmitter } from './EnhancedEventEmitter'; import * as utils from './utils'; import * as ortc from './ortc'; import { Channel } from './Channel'; -import { PayloadChannel } from './PayloadChannel'; import { RouterInternal } from './Router'; import { WebRtcTransportData } from './WebRtcTransport'; import { PlainTransportData } from './PlainTransport'; import { PipeTransportData } from './PipeTransport'; import { DirectTransportData } from './DirectTransport'; import { Producer, ProducerOptions } from './Producer'; -import { Consumer, ConsumerOptions, ConsumerType } from './Consumer'; +import { Consumer, ConsumerLayers, ConsumerOptions, ConsumerType } from './Consumer'; import { DataProducer, DataProducerOptions, - DataProducerType + DataProducerType, + parseDataProducerDump } from './DataProducer'; import { DataConsumer, DataConsumerOptions, - DataConsumerType + DataConsumerType, + parseDataConsumerDump } from './DataConsumer'; -import { RtpCapabilities } from './RtpParameters'; -import { SctpStreamParameters } from './SctpParameters'; +import { + MediaKind, + RtpCapabilities, + RtpParameters, + serializeRtpEncodingParameters, + serializeRtpParameters +} from './RtpParameters'; +import { + parseSctpParametersDump, + serializeSctpStreamParameters, + SctpParameters, + SctpStreamParameters +} from './SctpParameters'; import { AppData } from './types'; +import * as FbsRequest from './fbs/request'; +import { MediaKind as FbsMediaKind } from './fbs/rtp-parameters/media-kind'; +import * as FbsConsumer from './fbs/consumer'; +import * as FbsDataConsumer from './fbs/data-consumer'; +import * as FbsDataProducer from './fbs/data-producer'; +import * as FbsTransport from './fbs/transport'; +import * as FbsRouter from './fbs/router'; +import { SctpState as FbsSctpState } from './fbs/sctp-association/sctp-state'; export type TransportListenIp = { @@ -116,7 +137,6 @@ export type TransportConstructorOptions = internal: TransportInternal; data: TransportData; channel: Channel; - payloadChannel: PayloadChannel; appData?: TransportAppData; getRouterRtpCapabilities: () => RtpCapabilities; getProducerById: (producerId: string) => Producer | undefined; @@ -128,12 +148,63 @@ export type TransportInternal = RouterInternal & transportId: string; }; +export type BaseTransportDump = { + id : string; + direct : boolean; + producerIds : string[]; + consumerIds : string[]; + mapSsrcConsumerId : { key: number; value: string }[]; + mapRtxSsrcConsumerId : { key: number; value: string }[]; + recvRtpHeaderExtensions : { key: string; value: number }[]; + rtpListener: RtpListenerDump; + maxMessageSize: number; + dataProducerIds : string[]; + dataConsumerIds : string[]; + sctpParameters? : SctpParameters; + sctpState? : SctpState; + sctpListener?: SctpListenerDump; + traceEventTypes? : string[]; +}; + +export type BaseTransportStats = { + transportId: string; + timestamp: number; + sctpState?: SctpState; + bytesReceived: number; + recvBitrate: number; + bytesSent: number; + sendBitrate: number; + rtpBytesReceived: number; + rtpRecvBitrate: number; + rtpBytesSent: number; + rtpSendBitrate: number; + rtxBytesReceived: number; + rtxRecvBitrate: number; + rtxBytesSent: number; + rtxSendBitrate: number; + probationBytesSent: number; + probationSendBitrate: number; + availableOutgoingBitrate?: number; + availableIncomingBitrate?: number; + maxIncomingBitrate?: number; +}; + type TransportData = | WebRtcTransportData | PlainTransportData | PipeTransportData | DirectTransportData; +type RtpListenerDump = { + ssrcTable : {key: number; value: string}[]; + midTable : {key: number; value: string}[]; + ridTable : {key: number; value: string}[]; +}; + +type SctpListenerDump = { + streamIdTable : {key: number; value: string}[]; +}; + const logger = new Logger('Transport'); export class Transport @@ -151,9 +222,6 @@ export class Transport // Channel instance. protected readonly channel: Channel; - // PayloadChannel instance. - protected readonly payloadChannel: PayloadChannel; - // Close flag. #closed = false; @@ -206,7 +274,6 @@ export class Transport internal, data, channel, - payloadChannel, appData, getRouterRtpCapabilities, getProducerById, @@ -221,7 +288,6 @@ export class Transport this.internal = internal; this.#data = data; this.channel = channel; - this.payloadChannel = payloadChannel; this.#appData = appData || {} as TransportAppData; this.#getRouterRtpCapabilities = getRouterRtpCapabilities; this.getProducerById = getProducerById; @@ -293,12 +359,18 @@ export class Transport // Remove notification subscriptions. this.channel.removeAllListeners(this.internal.transportId); - this.payloadChannel.removeAllListeners(this.internal.transportId); - const reqData = { transportId: this.internal.transportId }; + /* Build Request. */ + const requestOffset = new FbsRouter.CloseTransportRequestT( + this.internal.transportId + ).pack(this.channel.bufferBuilder); - this.channel.request('router.closeTransport', this.internal.routerId, reqData) - .catch(() => {}); + this.channel.request( + FbsRequest.Method.ROUTER_CLOSE_TRANSPORT, + FbsRequest.Body.FBS_Router_CloseTransportRequest, + requestOffset, + this.internal.routerId + ).catch(() => {}); // Close every Producer. for (const producer of this.#producers.values()) @@ -359,7 +431,6 @@ export class Transport // Remove notification subscriptions. this.channel.removeAllListeners(this.internal.transportId); - this.payloadChannel.removeAllListeners(this.internal.transportId); // Close every Producer. for (const producer of this.#producers.values()) @@ -420,7 +491,6 @@ export class Transport // Remove notification subscriptions. this.channel.removeAllListeners(this.internal.transportId); - this.payloadChannel.removeAllListeners(this.internal.transportId); // Close every Producer. for (const producer of this.#producers.values()) @@ -469,12 +539,13 @@ export class Transport /** * Dump Transport. + * + * @abstract */ async dump(): Promise { - logger.debug('dump()'); - - return this.channel.request('transport.dump', this.internal.transportId); + // Should not happen. + throw new Error('method not implemented in the subclass'); } /** @@ -507,10 +578,16 @@ export class Transport { logger.debug('setMaxIncomingBitrate() [bitrate:%s]', bitrate); - const reqData = { bitrate }; + /* Build Request. */ + const requestOffset = FbsTransport.SetMaxIncomingBitrateRequest + .createSetMaxIncomingBitrateRequest(this.channel.bufferBuilder, bitrate); await this.channel.request( - 'transport.setMaxIncomingBitrate', this.internal.transportId, reqData); + FbsRequest.Method.TRANSPORT_SET_MAX_INCOMING_BITRATE, + FbsRequest.Body.FBS_Transport_SetMaxIncomingBitrateRequest, + requestOffset, + this.internal.transportId + ); } /** @@ -520,10 +597,17 @@ export class Transport { logger.debug('setMaxOutgoingBitrate() [bitrate:%s]', bitrate); - const reqData = { bitrate }; + /* Build Request. */ + const requestOffset = new FbsTransport.SetMaxOutgoingBitrateRequestT( + bitrate + ).pack(this.channel.bufferBuilder); await this.channel.request( - 'transport.setMaxOutgoingBitrate', this.internal.transportId, reqData); + FbsRequest.Method.TRANSPORT_SET_MAX_OUTGOING_BITRATE, + FbsRequest.Body.FBS_Transport_SetMaxOutgoingBitrateRequest, + requestOffset, + this.internal.transportId + ); } /** @@ -533,10 +617,17 @@ export class Transport { logger.debug('setMinOutgoingBitrate() [bitrate:%s]', bitrate); - const reqData = { bitrate }; + /* Build Request. */ + const requestOffset = new FbsTransport.SetMinOutgoingBitrateRequestT( + bitrate + ).pack(this.channel.bufferBuilder); await this.channel.request( - 'transport.setMinOutgoingBitrate', this.internal.transportId, reqData); + FbsRequest.Method.TRANSPORT_SET_MIN_OUTGOING_BITRATE, + FbsRequest.Body.FBS_Transport_SetMinOutgoingBitrateRequest, + requestOffset, + this.internal.transportId + ); } /** @@ -613,24 +704,36 @@ export class Transport const consumableRtpParameters = ortc.getConsumableRtpParameters( kind, rtpParameters, routerRtpCapabilities, rtpMapping); - const reqData = - { - producerId : id || uuidv4(), + const producerId = id || uuidv4(); + const requestOffset = createProduceRequest({ + builder : this.channel.bufferBuilder, + producerId, kind, rtpParameters, rtpMapping, keyFrameRequestDelay, paused - }; + }); - const status = - await this.channel.request('transport.produce', this.internal.transportId, reqData); + const response = await this.channel.request( + FbsRequest.Method.TRANSPORT_PRODUCE, + FbsRequest.Body.FBS_Transport_ProduceRequest, + requestOffset, + this.internal.transportId + ); + + /* Decode Response. */ + const produceResponse = new FbsTransport.ProduceResponse(); + + response.body(produceResponse); + + const status = produceResponse.unpack(); const data = { kind, rtpParameters, - type : status.type, + type : utils.getProducerType(status.type), consumableRtpParameters }; @@ -639,11 +742,10 @@ export class Transport internal : { ...this.internal, - producerId : reqData.producerId + producerId }, data, channel : this.channel, - payloadChannel : this.payloadChannel, appData, paused }); @@ -745,21 +847,31 @@ export class Transport } } - const reqData = - { - consumerId : uuidv4(), - producerId, - kind : producer.kind, + const consumerId = uuidv4(); + const consumeRequestOffset = createConsumeRequest({ + builder : this.channel.bufferBuilder, + producer, + consumerId, rtpParameters, - type : pipe ? 'pipe' : producer.type, - consumableRtpEncodings : producer.consumableRtpParameters.encodings, paused, preferredLayers, - ignoreDtx - }; + ignoreDtx, + pipe + }); + + const response = await this.channel.request( + FbsRequest.Method.TRANSPORT_CONSUME, + FbsRequest.Body.FBS_Transport_ConsumeRequest, + consumeRequestOffset, + this.internal.transportId + ); - const status = - await this.channel.request('transport.consume', this.internal.transportId, reqData); + /* Decode Response. */ + const consumeResponse = new FbsTransport.ConsumeResponse(); + + response.body(consumeResponse); + + const status = consumeResponse.unpack(); const data = { @@ -774,16 +886,22 @@ export class Transport internal : { ...this.internal, - consumerId : reqData.consumerId + consumerId }, data, channel : this.channel, - payloadChannel : this.payloadChannel, appData, paused : status.paused, producerPaused : status.producerPaused, - score : status.score, - preferredLayers : status.preferredLayers + score : status.score ?? undefined, + preferredLayers : status.preferredLayers ? + { + spatialLayer : status.preferredLayers.spatialLayer, + temporalLayer : status.preferredLayers.temporalLayer !== null ? + status.preferredLayers.temporalLayer : + undefined + } : + undefined }); this.consumers.set(consumer.id, consumer); @@ -842,28 +960,38 @@ export class Transport } } - const reqData = - { - dataProducerId : id || uuidv4(), + const dataProducerId = id || uuidv4(); + const requestOffset = createProduceDataRequest({ + builder : this.channel.bufferBuilder, + dataProducerId, type, sctpStreamParameters, label, protocol - }; + }); - const data = - await this.channel.request('transport.produceData', this.internal.transportId, reqData); + const response = await this.channel.request( + FbsRequest.Method.TRANSPORT_PRODUCE_DATA, + FbsRequest.Body.FBS_Transport_ProduceDataRequest, + requestOffset, + this.internal.transportId + ); + + /* Decode Response. */ + const produceResponse = new FbsDataProducer.DumpResponse(); + response.body(produceResponse); + + const data = parseDataProducerDump(produceResponse); const dataProducer = new DataProducer( { internal : { ...this.internal, - dataProducerId : reqData.dataProducerId + dataProducerId }, data, channel : this.channel, - payloadChannel : this.payloadChannel, appData }); @@ -964,30 +1092,40 @@ export class Transport } const { label, protocol } = dataProducer; + const dataConsumerId = uuidv4(); - const reqData = - { - dataConsumerId : uuidv4(), + const requestOffset = createConsumeDataRequest({ + builder : this.channel.bufferBuilder, + dataConsumerId, dataProducerId, type, sctpStreamParameters, label, protocol - }; + }); - const data = - await this.channel.request('transport.consumeData', this.internal.transportId, reqData); + const response = await this.channel.request( + FbsRequest.Method.TRANSPORT_CONSUME_DATA, + FbsRequest.Body.FBS_Transport_ConsumeDataRequest, + requestOffset, + this.internal.transportId + ); + + /* Decode Response. */ + const consumeResponse = new FbsDataConsumer.DumpResponse(); + + response.body(consumeResponse); + const data = parseDataConsumerDump(consumeResponse); const dataConsumer = new DataConsumer( { internal : { ...this.internal, - dataConsumerId : reqData.dataConsumerId + dataConsumerId }, data, channel : this.channel, - payloadChannel : this.payloadChannel, appData }); @@ -1022,12 +1160,28 @@ export class Transport */ async enableTraceEvent(types: TransportTraceEventType[] = []): Promise { - logger.debug('pause()'); + logger.debug('enableTraceEvent()'); + + if (!Array.isArray(types)) + { + throw new TypeError('types must be an array'); + } + if (types.find((type) => typeof type !== 'string')) + { + throw new TypeError('every type must be a string'); + } - const reqData = { types }; + /* Build Request. */ + const requestOffset = new FbsTransport.EnableTraceEventRequestT( + types + ).pack(this.channel.bufferBuilder); await this.channel.request( - 'transport.enableTraceEvent', this.internal.transportId, reqData); + FbsRequest.Method.TRANSPORT_ENABLE_TRACE_EVENT, + FbsRequest.Body.FBS_Transport_EnableTraceEventRequest, + requestOffset, + this.internal.transportId + ); } private getNextSctpStreamId(): number @@ -1064,3 +1218,420 @@ export class Transport throw new Error('no sctpStreamId available'); } } + +export function fbsSctpState2StcpState(fbsSctpState: FbsSctpState): SctpState +{ + switch (fbsSctpState) + { + case FbsSctpState.NEW: + return 'new'; + case FbsSctpState.CONNECTING: + return 'connecting'; + case FbsSctpState.CONNECTED: + return 'connected'; + case FbsSctpState.FAILED: + return 'failed'; + case FbsSctpState.CLOSED: + return 'closed'; + default: + throw new TypeError(`invalid SctpState: ${fbsSctpState}`); + } +} + +export function parseTuple(binary: FbsTransport.Tuple): TransportTuple +{ + return { + localIp : binary.localIp()!, + localPort : binary.localPort(), + remoteIp : binary.remoteIp() ?? undefined, + remotePort : binary.remotePort(), + protocol : binary.protocol()! as TransportProtocol + }; +} + +export function parseBaseTransportDump( + binary: FbsTransport.Dump +): BaseTransportDump +{ + // Retrieve producerIds. + const producerIds = utils.parseVector(binary, 'producerIds'); + // Retrieve consumerIds. + const consumerIds = utils.parseVector(binary, 'consumerIds'); + // Retrieve map SSRC consumerId. + const mapSsrcConsumerId = utils.parseUint32StringVector(binary, 'mapSsrcConsumerId'); + // Retrieve map RTX SSRC consumerId. + const mapRtxSsrcConsumerId = utils.parseUint32StringVector(binary, 'mapRtxSsrcConsumerId'); + // Retrieve dataProducerIds. + const dataProducerIds = utils.parseVector(binary, 'dataProducerIds'); + // Retrieve dataConsumerIds. + const dataConsumerIds = utils.parseVector(binary, 'dataConsumerIds'); + // Retrieve recvRtpHeaderExtesions. + const recvRtpHeaderExtensions = utils.parseStringUint8Vector(binary, 'recvRtpHeaderExtensions'); + // Retrieve RtpListener. + const rtpListener = parseRtpListenerDump(binary.rtpListener()!); + + // Retrieve SctpParameters. + const fbsSctpParameters = binary.sctpParameters(); + let sctpParameters: SctpParameters | undefined; + + if (fbsSctpParameters) + { + sctpParameters = parseSctpParametersDump(fbsSctpParameters); + } + + // Retrieve sctpState. + const sctpState = binary.sctpState() === '' ? undefined : binary.sctpState() as SctpState; + + // Retrive sctpListener. + const sctpListener = binary.sctpListener() ? + parseSctpListenerDump(binary.sctpListener()!) : + undefined; + + // Retrieve traceEventTypes. + const traceEventTypes = utils.parseVector(binary, 'traceEventTypes'); + + return { + id : binary.id()!, + direct : binary.direct(), + producerIds : producerIds, + consumerIds : consumerIds, + mapSsrcConsumerId : mapSsrcConsumerId, + mapRtxSsrcConsumerId : mapRtxSsrcConsumerId, + dataProducerIds : dataProducerIds, + dataConsumerIds : dataConsumerIds, + recvRtpHeaderExtensions : recvRtpHeaderExtensions, + rtpListener : rtpListener, + maxMessageSize : binary.maxMessageSize(), + sctpParameters : sctpParameters, + sctpState : sctpState, + sctpListener : sctpListener, + traceEventTypes : traceEventTypes + }; +} + +export function parseBaseTransportStats( + binary: FbsTransport.Stats +): BaseTransportStats +{ + const sctpState = binary.sctpState() === '' ? undefined : binary.sctpState() as SctpState; + + return { + transportId : binary.transportId()!, + timestamp : Number(binary.timestamp()), + sctpState, + bytesReceived : Number(binary.bytesReceived()), + recvBitrate : Number(binary.recvBitrate()), + bytesSent : Number(binary.bytesSent()), + sendBitrate : Number(binary.sendBitrate()), + rtpBytesReceived : Number(binary.rtpBytesReceived()), + rtpRecvBitrate : Number(binary.rtpRecvBitrate()), + rtpBytesSent : Number(binary.rtpBytesSent()), + rtpSendBitrate : Number(binary.rtpSendBitrate()), + rtxBytesReceived : Number(binary.rtxBytesReceived()), + rtxRecvBitrate : Number(binary.rtxRecvBitrate()), + rtxBytesSent : Number(binary.rtxBytesSent()), + rtxSendBitrate : Number(binary.rtxSendBitrate()), + probationBytesSent : Number(binary.probationBytesSent()), + probationSendBitrate : Number(binary.probationSendBitrate()), + availableOutgoingBitrate : Number(binary.availableOutgoingBitrate()), + availableIncomingBitrate : Number(binary.availableIncomingBitrate()), + maxIncomingBitrate : binary.maxIncomingBitrate() ? + Number(binary.maxIncomingBitrate()) : + undefined + }; +} + +export function parseTransportTraceEventData( + trace: FbsTransport.TraceNotification +): TransportTraceEventData +{ + switch (trace.type()) + { + case FbsTransport.TraceType.BWE: + { + const info = new FbsTransport.BweTraceInfo(); + + trace.info(info); + + return { + type : 'bwe', + timestamp : Number(trace.timestamp()), + direction : trace.direction() === FbsTransport.TraceDirection.DIRECTION_IN ? 'in' : 'out', + info : parseBweTraceInfo(info!) + }; + } + + case FbsTransport.TraceType.PROBATION: + { + return { + type : 'probation', + timestamp : Number(trace.timestamp()), + direction : trace.direction() === FbsTransport.TraceDirection.DIRECTION_IN ? 'in' : 'out', + info : {} + }; + } + } +} + +function parseBweTraceInfo(binary: FbsTransport.BweTraceInfo): +{ + desiredBitrate:number; + effectiveDesiredBitrate:number; + minBitrate:number; + maxBitrate:number; + startBitrate:number; + maxPaddingBitrate:number; + availableBitrate:number; + bweType:'transport-cc' | 'remb'; +} +{ + return { + desiredBitrate : binary.desiredBitrate(), + effectiveDesiredBitrate : binary.effectiveDesiredBitrate(), + minBitrate : binary.minBitrate(), + maxBitrate : binary.maxBitrate(), + startBitrate : binary.startBitrate(), + maxPaddingBitrate : binary.maxPaddingBitrate(), + availableBitrate : binary.availableBitrate(), + bweType : binary.bweType() === FbsTransport.BweType.TRANSPORT_CC ? + 'transport-cc' : + 'remb' + }; +} + +function createConsumeRequest({ + builder, + producer, + consumerId, + rtpParameters, + paused, + preferredLayers, + ignoreDtx, + pipe +} : { + builder: flatbuffers.Builder; + producer: Producer; + consumerId: string; + rtpParameters: RtpParameters; + paused: boolean; + preferredLayers?: ConsumerLayers; + ignoreDtx?: boolean; + pipe: boolean; +}): number +{ + const rtpParametersOffset = serializeRtpParameters(builder, rtpParameters); + const consumerIdOffset = builder.createString(consumerId); + const producerIdOffset = builder.createString(producer.id); + let consumableRtpEncodingsOffset: number | undefined; + let preferredLayersOffset: number | undefined; + + if (producer.consumableRtpParameters.encodings) + { + consumableRtpEncodingsOffset = serializeRtpEncodingParameters( + builder, producer.consumableRtpParameters.encodings + ); + } + + if (preferredLayers) + { + FbsConsumer.ConsumerLayers.startConsumerLayers(builder); + FbsConsumer.ConsumerLayers.addSpatialLayer(builder, preferredLayers.spatialLayer); + + if (preferredLayers.temporalLayer !== undefined) + { + FbsConsumer.ConsumerLayers.addTemporalLayer( + builder, preferredLayers.temporalLayer + ); + } + + preferredLayersOffset = FbsConsumer.ConsumerLayers.endConsumerLayers(builder); + } + + const ConsumeRequest = FbsTransport.ConsumeRequest; + + // Create Consume Request. + ConsumeRequest.startConsumeRequest(builder); + ConsumeRequest.addConsumerId(builder, consumerIdOffset); + ConsumeRequest.addProducerId(builder, producerIdOffset); + ConsumeRequest.addKind( + builder, producer.kind === 'audio' ? FbsMediaKind.AUDIO : FbsMediaKind.VIDEO); + ConsumeRequest.addRtpParameters(builder, rtpParametersOffset); + ConsumeRequest.addType( + builder, + utils.getRtpParametersType(producer.type, pipe) + ); + + if (consumableRtpEncodingsOffset) + { + ConsumeRequest.addConsumableRtpEncodings(builder, consumableRtpEncodingsOffset); + } + + ConsumeRequest.addPaused(builder, paused); + + if (preferredLayersOffset) + { + ConsumeRequest.addPreferredLayers(builder, preferredLayersOffset); + } + + ConsumeRequest.addIgnoreDtx(builder, Boolean(ignoreDtx)); + + return ConsumeRequest.endConsumeRequest(builder); +} + +function createProduceRequest({ + builder, + producerId, + kind, + rtpParameters, + rtpMapping, + keyFrameRequestDelay, + paused +} : { + builder : flatbuffers.Builder; + producerId: string; + kind: MediaKind; + rtpParameters: RtpParameters; + rtpMapping: ortc.RtpMapping; + keyFrameRequestDelay?: number; + paused: boolean; +}): number +{ + const producerIdOffset = builder.createString(producerId); + const rtpParametersOffset = serializeRtpParameters(builder, rtpParameters); + const rtpMappingOffset = ortc.serializeRtpMapping(builder, rtpMapping); + + FbsTransport.ProduceRequest.startProduceRequest(builder); + FbsTransport.ProduceRequest.addProducerId(builder, producerIdOffset); + FbsTransport.ProduceRequest.addKind( + builder, kind === 'audio' ? FbsMediaKind.AUDIO : FbsMediaKind.VIDEO); + FbsTransport.ProduceRequest.addRtpParameters(builder, rtpParametersOffset); + FbsTransport.ProduceRequest.addRtpMapping(builder, rtpMappingOffset); + FbsTransport.ProduceRequest.addKeyFrameRequestDelay(builder, keyFrameRequestDelay ?? 0); + FbsTransport.ProduceRequest.addPaused(builder, paused); + + return FbsTransport.ProduceRequest.endProduceRequest(builder); +} + +function createProduceDataRequest({ + builder, + dataProducerId, + type, + sctpStreamParameters, + label, + protocol +} : { + builder : flatbuffers.Builder; + dataProducerId: string; + type: DataProducerType; + sctpStreamParameters?: SctpStreamParameters; + label: string; + protocol: string; +}): number +{ + const dataProducerIdOffset = builder.createString(dataProducerId); + const typeOffset = builder.createString(type); + const labelOffset = builder.createString(label); + const protocolOffset = builder.createString(protocol); + + let sctpStreamParametersOffset = 0; + + if (sctpStreamParameters) + { + sctpStreamParametersOffset = serializeSctpStreamParameters( + builder, sctpStreamParameters + ); + } + + FbsTransport.ProduceDataRequest.startProduceDataRequest(builder); + FbsTransport.ProduceDataRequest.addDataProducerId(builder, dataProducerIdOffset); + FbsTransport.ProduceDataRequest.addType(builder, typeOffset); + + if (sctpStreamParametersOffset) + { + FbsTransport.ProduceDataRequest.addSctpStreamParameters( + builder, sctpStreamParametersOffset + ); + } + + FbsTransport.ProduceDataRequest.addLabel(builder, labelOffset); + FbsTransport.ProduceDataRequest.addProtocol(builder, protocolOffset); + + return FbsTransport.ProduceDataRequest.endProduceDataRequest(builder); +} + +function createConsumeDataRequest({ + builder, + dataConsumerId, + dataProducerId, + type, + sctpStreamParameters, + label, + protocol +} : { + builder : flatbuffers.Builder; + dataConsumerId: string; + dataProducerId: string; + type: DataConsumerType; + sctpStreamParameters?: SctpStreamParameters; + label: string; + protocol: string; +}): number +{ + const dataConsumerIdOffset = builder.createString(dataConsumerId); + const dataProducerIdOffset = builder.createString(dataProducerId); + const typeOffset = builder.createString(type); + const labelOffset = builder.createString(label); + const protocolOffset = builder.createString(protocol); + + let sctpStreamParametersOffset = 0; + + if (sctpStreamParameters) + { + sctpStreamParametersOffset = serializeSctpStreamParameters( + builder, sctpStreamParameters + ); + } + + FbsTransport.ConsumeDataRequest.startConsumeDataRequest(builder); + FbsTransport.ConsumeDataRequest.addDataConsumerId(builder, dataConsumerIdOffset); + FbsTransport.ConsumeDataRequest.addDataProducerId(builder, dataProducerIdOffset); + FbsTransport.ConsumeDataRequest.addType(builder, typeOffset); + + if (sctpStreamParametersOffset) + { + FbsTransport.ConsumeDataRequest.addSctpStreamParameters( + builder, sctpStreamParametersOffset + ); + } + + FbsTransport.ConsumeDataRequest.addLabel(builder, labelOffset); + FbsTransport.ConsumeDataRequest.addProtocol(builder, protocolOffset); + + return FbsTransport.ConsumeDataRequest.endConsumeDataRequest(builder); +} + +function parseRtpListenerDump(binary: FbsTransport.RtpListener): RtpListenerDump +{ + // Retrieve ssrcTable. + const ssrcTable = utils.parseUint32StringVector(binary, 'ssrcTable'); + // Retrieve midTable. + const midTable = utils.parseUint32StringVector(binary, 'midTable'); + // Retrieve ridTable. + const ridTable = utils.parseUint32StringVector(binary, 'ridTable'); + + return { + ssrcTable, + midTable, + ridTable + }; +} + +function parseSctpListenerDump(binary: FbsTransport.SctpListener): SctpListenerDump +{ + // Retrieve streamIdTable. + const streamIdTable = utils.parseUint32StringVector(binary, 'streamIdTable'); + + return { + streamIdTable + }; +} diff --git a/node/src/WebRtcServer.ts b/node/src/WebRtcServer.ts index 0db3346ded..31e10f922d 100644 --- a/node/src/WebRtcServer.ts +++ b/node/src/WebRtcServer.ts @@ -4,6 +4,9 @@ import { Channel } from './Channel'; import { TransportProtocol } from './Transport'; import { WebRtcTransport } from './WebRtcTransport'; import { AppData } from './types'; +import { Body as RequestBody, Method } from './fbs/request'; +import * as FbsWorker from './fbs/worker'; +import * as FbsWebRtcServer from './fbs/web-rtc-server'; export type WebRtcServerOptions = { @@ -172,9 +175,14 @@ export class WebRtcServer this.#closed = true; - const reqData = { webRtcServerId: this.#internal.webRtcServerId }; + // Build the request. + const requestOffset = new FbsWorker.CloseWebRtcServerRequestT( + this.#internal.webRtcServerId).pack(this.#channel.bufferBuilder); - this.#channel.request('worker.closeWebRtcServer', undefined, reqData) + this.#channel.request( + Method.WORKER_WEBRTC_SERVER_CLOSE, + RequestBody.FBS_Worker_CloseWebRtcServerRequest, + requestOffset) .catch(() => {}); // Close every WebRtcTransport. @@ -226,7 +234,15 @@ export class WebRtcServer { logger.debug('dump()'); - return this.#channel.request('webRtcServer.dump', this.#internal.webRtcServerId); + const response = await this.#channel.request( + Method.WEBRTC_SERVER_DUMP, undefined, undefined, this.#internal.webRtcServerId); + + /* Decode Response. */ + const dump = new FbsWebRtcServer.DumpResponse(); + + response.body(dump); + + return dump.unpack(); } /** diff --git a/node/src/WebRtcTransport.ts b/node/src/WebRtcTransport.ts index e297a5d4a1..c5e43b9092 100644 --- a/node/src/WebRtcTransport.ts +++ b/node/src/WebRtcTransport.ts @@ -1,10 +1,17 @@ +import * as flatbuffers from 'flatbuffers'; import { Logger } from './Logger'; import { + fbsSctpState2StcpState, + parseBaseTransportDump, + parseBaseTransportStats, + parseTransportTraceEventData, + parseTuple, + BaseTransportDump, + BaseTransportStats, Transport, TransportListenIp, TransportProtocol, TransportTuple, - TransportTraceEventData, TransportEvents, TransportObserverEvents, TransportConstructorOptions, @@ -12,8 +19,14 @@ import { } from './Transport'; import { WebRtcServer } from './WebRtcServer'; import { SctpParameters, NumSctpStreams } from './SctpParameters'; -import { Either } from './utils'; import { AppData } from './types'; +import { Either, parseVector } from './utils'; +import { Event, Notification } from './fbs/notification'; +import * as FbsRequest from './fbs/request'; +import * as FbsTransport from './fbs/transport'; +import * as FbsWebRtcTransport from './fbs/web-rtc-transport'; +import { DtlsState as FbsDtlsState } from './fbs/web-rtc-transport/dtls-state'; +import { IceState as FbsIceState } from './fbs/web-rtc-transport/ice-state'; export type WebRtcTransportOptions = WebRtcTransportOptionsBase & WebRtcTransportListen; @@ -141,31 +154,9 @@ export type DtlsRole = 'auto' | 'client' | 'server'; export type DtlsState = 'new' | 'connecting' | 'connected' | 'failed' | 'closed'; -export type WebRtcTransportStat = +export type WebRtcTransportStat = BaseTransportStats & { - // Common to all Transports. type: string; - transportId: string; - timestamp: number; - sctpState?: SctpState; - bytesReceived: number; - recvBitrate: number; - bytesSent: number; - sendBitrate: number; - rtpBytesReceived: number; - rtpRecvBitrate: number; - rtpBytesSent: number; - rtpSendBitrate: number; - rtxBytesReceived: number; - rtxRecvBitrate: number; - rtxBytesSent: number; - rtxSendBitrate: number; - probationBytesSent: number; - probationSendBitrate: number; - availableOutgoingBitrate?: number; - availableIncomingBitrate?: number; - maxIncomingBitrate?: number; - // WebRtcTransport specific. iceRole: string; iceState: IceState; iceSelectedTuple?: TransportTuple; @@ -208,6 +199,18 @@ export type WebRtcTransportData = sctpState?: SctpState; }; +type WebRtcTransportDump = BaseTransportDump & +{ + iceRole: 'controlled'; + iceParameters: IceParameters; + iceCandidates: IceCandidate[]; + iceState: IceState; + iceSelectedTuple?: TransportTuple; + dtlsParameters: DtlsParameters; + dtlsState: DtlsState; + dtlsRemoteCert?: string; +}; + const logger = new Logger('WebRtcTransport'); export class WebRtcTransport @@ -397,6 +400,28 @@ export class WebRtcTransport super.listenServerClosed(); } + /** + * Dump Transport. + */ + async dump(): Promise + { + logger.debug('dump()'); + + const response = await this.channel.request( + FbsRequest.Method.TRANSPORT_DUMP, + undefined, + undefined, + this.internal.transportId + ); + + /* Decode Response. */ + const data = new FbsWebRtcTransport.DumpResponse(); + + response.body(data); + + return parseWebRtcTransportDumpResponse(data); + } + /** * Get WebRtcTransport stats. * @@ -406,7 +431,19 @@ export class WebRtcTransport { logger.debug('getStats()'); - return this.channel.request('transport.getStats', this.internal.transportId); + const response = await this.channel.request( + FbsRequest.Method.TRANSPORT_GET_STATS, + undefined, + undefined, + this.internal.transportId + ); + + /* Decode Response. */ + const data = new FbsWebRtcTransport.GetStatsResponse(); + + response.body(data); + + return [ parseGetStatsResponse(data) ]; } /** @@ -418,13 +455,27 @@ export class WebRtcTransport { logger.debug('connect()'); - const reqData = { dtlsParameters }; + const requestOffset = createConnectRequest({ + builder : this.channel.bufferBuilder, + dtlsParameters + }); + + // Wait for response. + const response = await this.channel.request( + FbsRequest.Method.WEBRTC_TRANSPORT_CONNECT, + FbsRequest.Body.FBS_WebRtcTransport_ConnectRequest, + requestOffset, + this.internal.transportId + ); + + /* Decode Response. */ + const data = new FbsWebRtcTransport.ConnectResponse(); - const data = - await this.channel.request('transport.connect', this.internal.transportId, reqData); + response.body(data); // Update data. - this.#data.dtlsParameters.role = data.dtlsLocalRole; + this.#data.dtlsParameters.role = + data.dtlsLocalRole()! as DtlsRole; } /** @@ -434,10 +485,23 @@ export class WebRtcTransport { logger.debug('restartIce()'); - const data = - await this.channel.request('transport.restartIce', this.internal.transportId); + const response = await this.channel.request( + FbsRequest.Method.TRANSPORT_RESTART_ICE, + undefined, + undefined, + this.internal.transportId + ); - const { iceParameters } = data; + /* Decode Response. */ + const restartIceResponse = new FbsTransport.RestartIceResponse(); + + response.body(restartIceResponse); + + const iceParameters = { + usernameFragment : restartIceResponse.usernameFragment()!, + password : restartIceResponse.password()!, + iceLite : restartIceResponse.iceLite() + }; this.#data.iceParameters = iceParameters; @@ -446,13 +510,17 @@ export class WebRtcTransport private handleWorkerNotifications(): void { - this.channel.on(this.internal.transportId, (event: string, data?: any) => + this.channel.on(this.internal.transportId, (event: Event, data?: Notification) => { switch (event) { - case 'icestatechange': + case Event.WEBRTCTRANSPORT_ICE_STATE_CHANGE: { - const iceState = data.iceState as IceState; + const notification = new FbsWebRtcTransport.IceStateChangeNotification(); + + data!.body(notification); + + const iceState = fbsIceState2IceState(notification.iceState()); this.#data.iceState = iceState; @@ -464,9 +532,14 @@ export class WebRtcTransport break; } - case 'iceselectedtuplechange': + case Event.WEBRTCTRANSPORT_ICE_SELECTED_TUPLE_CHANGE: { - const iceSelectedTuple = data.iceSelectedTuple as TransportTuple; + const notification = + new FbsWebRtcTransport.IceSelectedTupleChangeNotification(); + + data!.body(notification); + + const iceSelectedTuple = parseTuple(notification.tuple()!); this.#data.iceSelectedTuple = iceSelectedTuple; @@ -478,16 +551,19 @@ export class WebRtcTransport break; } - case 'dtlsstatechange': + case Event.WEBRTCTRANSPORT_DTLS_STATE_CHANGE: { - const dtlsState = data.dtlsState as DtlsState; - const dtlsRemoteCert = data.dtlsRemoteCert as string; + const notification = new FbsWebRtcTransport.DtlsStateChangeNotification(); + + data!.body(notification); + + const dtlsState = fbsDtlsState2DtlsState(notification.dtlsState()); this.#data.dtlsState = dtlsState; if (dtlsState === 'connected') { - this.#data.dtlsRemoteCert = dtlsRemoteCert; + this.#data.dtlsRemoteCert = notification.remoteCert()!; } this.safeEmit('dtlsstatechange', dtlsState); @@ -498,9 +574,13 @@ export class WebRtcTransport break; } - case 'sctpstatechange': + case Event.TRANSPORT_SCTP_STATE_CHANGE: { - const sctpState = data.sctpState as SctpState; + const notification = new FbsTransport.SctpStateChangeNotification(); + + data!.body(notification); + + const sctpState = fbsSctpState2StcpState(notification.sctpState()); this.#data.sctpState = sctpState; @@ -512,9 +592,13 @@ export class WebRtcTransport break; } - case 'trace': + case Event.TRANSPORT_TRACE: { - const trace = data as TransportTraceEventData; + const notification = new FbsTransport.TraceNotification(); + + data!.body(notification); + + const trace = parseTransportTraceEventData(notification); this.safeEmit('trace', trace); @@ -532,3 +616,181 @@ export class WebRtcTransport }); } } + +export function fbsIceState2IceState(fbsIceState: FbsIceState): IceState +{ + switch (fbsIceState) + { + case FbsIceState.NEW: + return 'new'; + case FbsIceState.CONNECTED: + return 'connected'; + case FbsIceState.COMPLETED: + return 'completed'; + case FbsIceState.DISCONNECTED: + return 'disconnected'; + case FbsIceState.CLOSED: + return 'closed'; + default: + throw new TypeError(`invalid SctpState: ${fbsIceState}`); + } +} + +export function fbsDtlsState2DtlsState(fbsDtlsState: FbsDtlsState): DtlsState +{ + switch (fbsDtlsState) + { + case FbsDtlsState.NEW: + return 'new'; + case FbsDtlsState.CONNECTING: + return 'connecting'; + case FbsDtlsState.CONNECTED: + return 'connected'; + case FbsDtlsState.FAILED: + return 'failed'; + case FbsDtlsState.CLOSED: + return 'closed'; + default: + throw new TypeError(`invalid SctpState: ${fbsDtlsState}`); + } +} + +export function parseWebRtcTransportDumpResponse( + binary: FbsWebRtcTransport.DumpResponse +): WebRtcTransportDump +{ + // Retrieve BaseTransportDump. + const baseTransportDump = parseBaseTransportDump(binary.base()!); + // Retrieve ICE candidates. + const iceCandidates = parseVector(binary, 'iceCandidates', parseIceCandidate); + // Retrieve ICE parameters. + const iceParameters = parseIceParameters(binary.iceParameters()!); + // Retrieve DTLS parameters. + const dtlsParameters = parseDtlsParameters(binary.dtlsParameters()!); + + return { + ...baseTransportDump, + sctpParameters : baseTransportDump.sctpParameters, + sctpState : baseTransportDump.sctpState, + iceRole : 'controlled', + iceParameters : iceParameters, + iceCandidates : iceCandidates, + iceState : binary.iceState() as IceState, + dtlsParameters : dtlsParameters, + dtlsState : binary.dtlsState() as DtlsState + }; +} + +function createConnectRequest( + { + builder, + dtlsParameters + }: + { + builder : flatbuffers.Builder; + dtlsParameters: DtlsParameters; + } +): number +{ + // Serialize DtlsParameters. This can throw. + const dtlsParametersOffset = serializeDtlsParameters(builder, dtlsParameters); + + // Create request. + return FbsWebRtcTransport.ConnectRequest.createConnectRequest( + builder, + dtlsParametersOffset); +} + +function parseGetStatsResponse( + binary: FbsWebRtcTransport.GetStatsResponse +):WebRtcTransportStat +{ + const base = parseBaseTransportStats(binary.base()!); + + return { + ...base, + type : 'webrtc-transport', + iceRole : binary.iceRole()!, + iceState : binary.iceState() as IceState, + iceSelectedTuple : binary.iceSelectedTuple() ? + parseTuple(binary.iceSelectedTuple()!) : + undefined, + dtlsState : binary.dtlsState() as DtlsState + }; +} + +function parseIceCandidate(binary: FbsWebRtcTransport.IceCandidate): IceCandidate +{ + return { + foundation : binary.foundation()!, + priority : binary.priority(), + ip : binary.ip()!, + protocol : binary.protocol() as TransportProtocol, + port : binary.port(), + type : 'host', + tcpType : binary.tcpType() === 'passive' ? 'passive' : undefined + }; +} + +function parseIceParameters(binary: FbsWebRtcTransport.IceParameters): IceParameters +{ + return { + usernameFragment : binary.usernameFragment()!, + password : binary.password()!, + iceLite : binary.iceLite() + }; +} + +function parseDtlsParameters(binary: FbsWebRtcTransport.DtlsParameters): DtlsParameters +{ + const fingerprints: DtlsFingerprint[] = []; + + for (let i=0; i // Channel instance. readonly #channel: Channel; - // PayloadChannel instance. - readonly #payloadChannel: PayloadChannel; - // Closed flag. #closed = false; @@ -335,9 +348,7 @@ export class Worker // fd 2 (stderr) : Same as stdout. // fd 3 (channel) : Producer Channel fd. // fd 4 (channel) : Consumer Channel fd. - // fd 5 (channel) : Producer PayloadChannel fd. - // fd 6 (channel) : Consumer PayloadChannel fd. - stdio : [ 'ignore', 'pipe', 'pipe', 'pipe', 'pipe', 'pipe', 'pipe' ], + stdio : [ 'ignore', 'pipe', 'pipe', 'pipe', 'pipe' ], windowsHide : true }); @@ -350,23 +361,14 @@ export class Worker pid : this.#pid }); - this.#payloadChannel = new PayloadChannel( - { - // NOTE: TypeScript does not like more than 5 fds. - // @ts-ignore - producerSocket : this.#child.stdio[5], - // @ts-ignore - consumerSocket : this.#child.stdio[6] - }); - this.#appData = appData || {} as WorkerAppData; let spawnDone = false; // Listen for 'running' notification. - this.#channel.once(String(this.#pid), (event: string) => + this.#channel.once(String(this.#pid), (event: Event) => { - if (!spawnDone && event === 'running') + if (!spawnDone && event === Event.WORKER_RUNNING) { spawnDone = true; @@ -558,9 +560,6 @@ export class Worker // Close the Channel instance. this.#channel.close(); - // Close the PayloadChannel instance. - this.#payloadChannel.close(); - // Close every Router. for (const router of this.#routers) { @@ -586,7 +585,17 @@ export class Worker { logger.debug('dump()'); - return this.#channel.request('worker.dump'); + // Send the request and wait for the response. + const response = await this.#channel.request( + FbsRequest.Method.WORKER_DUMP + ); + + /* Decode Response. */ + const dump = new FbsWorker.DumpResponse(); + + response.body(dump); + + return dump.unpack(); } /** @@ -596,7 +605,37 @@ export class Worker { logger.debug('getResourceUsage()'); - return this.#channel.request('worker.getResourceUsage'); + const response = await this.#channel.request( + FbsRequest.Method.WORKER_GET_RESOURCE_USAGE + ); + + /* Decode Response. */ + const resourceUsage = new FbsWorker.ResourceUsageResponse(); + + response.body(resourceUsage); + + const ru = resourceUsage.unpack(); + + /* eslint-disable camelcase */ + return { + ru_utime : Number(ru.ruUtime), + ru_stime : Number(ru.ruStime), + ru_maxrss : Number(ru.ruMaxrss), + ru_ixrss : Number(ru.ruIxrss), + ru_idrss : Number(ru.ruIdrss), + ru_isrss : Number(ru.ruIsrss), + ru_minflt : Number(ru.ruMinflt), + ru_majflt : Number(ru.ruMajflt), + ru_nswap : Number(ru.ruNswap), + ru_inblock : Number(ru.ruInblock), + ru_oublock : Number(ru.ruOublock), + ru_msgsnd : Number(ru.ruMsgsnd), + ru_msgrcv : Number(ru.ruMsgrcv), + ru_nsignals : Number(ru.ruNsignals), + ru_nvcsw : Number(ru.ruNvcsw), + ru_nivcsw : Number(ru.ruNivcsw) + }; + /* eslint-enable camelcase */ } /** @@ -611,9 +650,15 @@ export class Worker { logger.debug('updateSettings()'); - const reqData = { logLevel, logTags }; + // Build the request. + const requestOffset = new FbsWorker.UpdateSettingsRequestT(logLevel, logTags) + .pack(this.#channel.bufferBuilder); - await this.#channel.request('worker.updateSettings', undefined, reqData); + await this.#channel.request( + FbsRequest.Method.WORKER_UPDATE_SETTINGS, + FbsRequest.Body.FBS_Worker_UpdateSettingsRequest, + requestOffset + ); } /** @@ -633,17 +678,42 @@ export class Worker throw new TypeError('if given, appData must be an object'); } - const reqData = + // Build the request. + const fbsListenInfos: FbsWebRtcServer.ListenInfoT[] = []; + + for (const listenInfo of listenInfos) { - webRtcServerId : uuidv4(), - listenInfos - }; + fbsListenInfos.push(new FbsWebRtcServer.ListenInfoT( + listenInfo.protocol === 'udp' ? FbsTransportProtocol.UDP : FbsTransportProtocol.TCP, + listenInfo.ip, + listenInfo.announcedIp, + listenInfo.port) + ); + } + + const webRtcServerId = uuidv4(); + + let createWebRtcServerRequestOffset; + + try + { + createWebRtcServerRequestOffset = new FbsWorker.CreateWebRtcServerRequestT( + webRtcServerId, fbsListenInfos).pack(this.#channel.bufferBuilder); + } + catch (error) + { + throw new TypeError((error as Error).message); + } - await this.#channel.request('worker.createWebRtcServer', undefined, reqData); + await this.#channel.request( + FbsRequest.Method.WORKER_CREATE_WEBRTC_SERVER, + FbsRequest.Body.FBS_Worker_CreateWebRtcServerRequest, + createWebRtcServerRequestOffset + ); const webRtcServer = new WebRtcServer( { - internal : { webRtcServerId: reqData.webRtcServerId }, + internal : { webRtcServerId }, channel : this.#channel, appData }); @@ -676,20 +746,24 @@ export class Worker // This may throw. const rtpCapabilities = ortc.generateRouterRtpCapabilities(mediaCodecs); - const reqData = { routerId: uuidv4() }; + const routerId = uuidv4(); + + // Get flatbuffer builder. + const createRouterRequestOffset = + new FbsWorker.CreateRouterRequestT(routerId).pack(this.#channel.bufferBuilder); - await this.#channel.request('worker.createRouter', undefined, reqData); + await this.#channel.request(FbsRequest.Method.WORKER_CREATE_ROUTER, + FbsRequest.Body.FBS_Worker_CreateRouterRequest, createRouterRequestOffset); const data = { rtpCapabilities }; const router = new Router( { internal : { - routerId : reqData.routerId + routerId }, data, channel : this.#channel, - payloadChannel : this.#payloadChannel, appData }); @@ -717,9 +791,6 @@ export class Worker // Close the Channel instance. this.#channel.close(); - // Close the PayloadChannel instance. - this.#payloadChannel.close(); - // Close every Router. for (const router of this.#routers) { diff --git a/node/src/ortc.ts b/node/src/ortc.ts index 6f229e6743..b12b8c4e1b 100644 --- a/node/src/ortc.ts +++ b/node/src/ortc.ts @@ -1,4 +1,5 @@ import * as h264 from 'h264-profile-level-id'; +import * as flatbuffers from 'flatbuffers'; import * as utils from './utils'; import { UnsupportedError } from './errors'; import { supportedRtpCapabilities } from './supportedRtpCapabilities'; @@ -21,8 +22,9 @@ import { SctpParameters, SctpStreamParameters } from './SctpParameters'; +import * as FbsRtpParameters from './fbs/rtp-parameters'; -type RtpMapping = +export type RtpMapping = { codecs: { @@ -1061,8 +1063,7 @@ export function getConsumableRtpParameters( consumableParams.rtcp = { cname : params.rtcp!.cname, - reducedSize : true, - mux : true + reducedSize : true }; return consumableParams; @@ -1517,3 +1518,39 @@ function matchCodecs( return true; } + +export function serializeRtpMapping( + builder: flatbuffers.Builder, rtpMapping: RtpMapping +): number +{ + const codecs: number[] = []; + + for (const codec of rtpMapping.codecs) + { + codecs.push( + FbsRtpParameters.CodecMapping.createCodecMapping( + builder, codec.payloadType, codec.mappedPayloadType) + ); + } + const codecsOffset = + FbsRtpParameters.RtpMapping.createCodecsVector(builder, codecs); + + const encodings: number[] = []; + + for (const encoding of rtpMapping.encodings) + { + encodings.push( + FbsRtpParameters.EncodingMapping.createEncodingMapping( + builder, + builder.createString(encoding.rid), + encoding.ssrc ?? null, + builder.createString(encoding.scalabilityMode), + encoding.mappedSsrc) + ); + } + const encodingsOffset = + FbsRtpParameters.RtpMapping.createEncodingsVector(builder, encodings); + + return FbsRtpParameters.RtpMapping.createRtpMapping( + builder, codecsOffset, encodingsOffset); +} diff --git a/node/src/tests/test-Consumer.ts b/node/src/tests/test-Consumer.ts index 156eb76535..dec72f88b5 100644 --- a/node/src/tests/test-Consumer.ts +++ b/node/src/tests/test-Consumer.ts @@ -1,5 +1,8 @@ +import * as flatbuffers from 'flatbuffers'; import * as mediasoup from '../'; import { UnsupportedError } from '../errors'; +import { Notification, Body as NotificationBody, Event } from '../fbs/notification'; +import * as FbsConsumer from '../fbs/consumer'; const { createWorker } = mediasoup; @@ -317,13 +320,17 @@ test('transport.consume() succeeds', async () => expect(audioConsumer.currentLayers).toBeUndefined(); expect(audioConsumer.appData).toEqual({ baz: 'LOL' }); - await expect(router.dump()) - .resolves - .toMatchObject( - { - mapProducerIdConsumerIds : { [audioProducer.id]: [ audioConsumer.id ] }, - mapConsumerIdProducerId : { [audioConsumer.id]: audioProducer.id } - }); + let dump = await router.dump(); + + expect(dump.mapProducerIdConsumerIds) + .toEqual(expect.arrayContaining([ + { key: audioProducer.id, values: [ audioConsumer.id ] } + ])); + + expect(dump.mapConsumerIdProducerId) + .toEqual(expect.arrayContaining([ + { key: audioConsumer.id, value: audioProducer.id } + ])); await expect(transport2.dump()) .resolves @@ -462,27 +469,36 @@ test('transport.consume() succeeds', async () => expect(videoPipeConsumer.currentLayers).toBeUndefined(); expect(videoPipeConsumer.appData).toBeUndefined; - const dump = await router.dump(); + dump = await router.dump(); - for (const key of Object.keys(dump.mapProducerIdConsumerIds)) + // Sort values for mapProducerIdConsumerIds. + expect(Array.isArray(dump.mapProducerIdConsumerIds)).toBe(true); + dump.mapProducerIdConsumerIds.forEach((entry: any) => { - dump.mapProducerIdConsumerIds[key] = dump.mapProducerIdConsumerIds[key].sort(); - } + entry.values = entry.values.sort(); + }); - expect(dump).toMatchObject( - { - mapProducerIdConsumerIds : - { - [audioProducer.id] : [ audioConsumer.id ], - [videoProducer.id] : [ videoConsumer.id, videoPipeConsumer.id ].sort() - }, - mapConsumerIdProducerId : - { - [audioConsumer.id] : audioProducer.id, - [videoConsumer.id] : videoProducer.id, - [videoPipeConsumer.id] : videoProducer.id - } - }); + expect(dump.mapProducerIdConsumerIds) + .toEqual(expect.arrayContaining([ + { key: audioProducer.id, values: [ audioConsumer.id ] } + ])); + expect(dump.mapProducerIdConsumerIds) + .toEqual(expect.arrayContaining([ + { key: videoProducer.id, values: [ videoConsumer.id, videoPipeConsumer.id ].sort() } + ])); + + expect(dump.mapConsumerIdProducerId) + .toEqual(expect.arrayContaining([ + { key: audioConsumer.id, value: audioProducer.id } + ])); + expect(dump.mapConsumerIdProducerId) + .toEqual(expect.arrayContaining([ + { key: videoConsumer.id, value: videoProducer.id } + ])); + expect(dump.mapConsumerIdProducerId) + .toEqual(expect.arrayContaining([ + { key: videoPipeConsumer.id, value: videoProducer.id } + ])); await expect(transport2.dump()) .resolves @@ -641,7 +657,7 @@ test('consumer.dump() succeeds', async () => }); expect(data.rtpParameters.codecs[0].rtcpFeedback).toEqual([]); expect(Array.isArray(data.rtpParameters.headerExtensions)).toBe(true); - expect(data.rtpParameters.headerExtensions.length).toBe(3); + expect(data.rtpParameters.headerExtensions!.length).toBe(3); expect(data.rtpParameters.headerExtensions).toEqual( [ { @@ -664,20 +680,22 @@ test('consumer.dump() succeeds', async () => } ]); expect(Array.isArray(data.rtpParameters.encodings)).toBe(true); - expect(data.rtpParameters.encodings.length).toBe(1); + expect(data.rtpParameters.encodings!.length).toBe(1); expect(data.rtpParameters.encodings).toEqual( [ - { - codecPayloadType : 100, - ssrc : audioConsumer.rtpParameters.encodings?.[0].ssrc - } + expect.objectContaining( + { + codecPayloadType : 100, + ssrc : audioConsumer.rtpParameters.encodings?.[0].ssrc + }) ]); expect(data.type).toBe('simple'); expect(Array.isArray(data.consumableRtpEncodings)).toBe(true); - expect(data.consumableRtpEncodings.length).toBe(1); + expect(data.consumableRtpEncodings!.length).toBe(1); expect(data.consumableRtpEncodings).toEqual( [ - { ssrc: audioProducer.consumableRtpParameters.encodings?.[0].ssrc } + expect.objectContaining( + { ssrc: audioProducer.consumableRtpParameters.encodings?.[0].ssrc }) ]); expect(data.supportedCodecPayloadTypes).toEqual([ 100 ]); expect(data.paused).toBe(false); @@ -710,7 +728,7 @@ test('consumer.dump() succeeds', async () => { type: 'goog-remb' } ]); expect(Array.isArray(data.rtpParameters.headerExtensions)).toBe(true); - expect(data.rtpParameters.headerExtensions.length).toBe(4); + expect(data.rtpParameters.headerExtensions!.length).toBe(4); expect(data.rtpParameters.headerExtensions).toEqual( [ { @@ -739,7 +757,7 @@ test('consumer.dump() succeeds', async () => } ]); expect(Array.isArray(data.rtpParameters.encodings)).toBe(true); - expect(data.rtpParameters.encodings.length).toBe(1); + expect(data.rtpParameters.encodings!.length).toBe(1); expect(data.rtpParameters.encodings).toMatchObject( [ { @@ -753,14 +771,23 @@ test('consumer.dump() succeeds', async () => } ]); expect(Array.isArray(data.consumableRtpEncodings)).toBe(true); - expect(data.consumableRtpEncodings.length).toBe(4); - expect(data.consumableRtpEncodings).toEqual( - [ - { ssrc: videoProducer.consumableRtpParameters.encodings?.[0].ssrc }, - { ssrc: videoProducer.consumableRtpParameters.encodings?.[1].ssrc }, - { ssrc: videoProducer.consumableRtpParameters.encodings?.[2].ssrc }, - { ssrc: videoProducer.consumableRtpParameters.encodings?.[3].ssrc } - ]); + expect(data.consumableRtpEncodings!.length).toBe(4); + expect(data.consumableRtpEncodings![0]).toEqual( + expect.objectContaining( + { ssrc: videoProducer.consumableRtpParameters.encodings?.[0].ssrc }) + ); + expect(data.consumableRtpEncodings![1]).toEqual( + expect.objectContaining( + { ssrc: videoProducer.consumableRtpParameters.encodings?.[1].ssrc }) + ); + expect(data.consumableRtpEncodings![2]).toEqual( + expect.objectContaining( + { ssrc: videoProducer.consumableRtpParameters.encodings?.[2].ssrc }) + ); + expect(data.consumableRtpEncodings![3]).toEqual( + expect.objectContaining( + { ssrc: videoProducer.consumableRtpParameters.encodings?.[3].ssrc }) + ); expect(data.supportedCodecPayloadTypes).toEqual([ 103 ]); expect(data.paused).toBe(true); expect(data.producerPaused).toBe(true); @@ -877,26 +904,28 @@ test('consumer.unsetPriority() succeed', async () => test('consumer.enableTraceEvent() succeed', async () => { + let dump; + await audioConsumer.enableTraceEvent([ 'rtp', 'pli' ]); - await expect(audioConsumer.dump()) - .resolves - .toMatchObject({ traceEventTypes: 'rtp,pli' }); + dump = await audioConsumer.dump(); + expect(dump.traceEventTypes) + .toEqual(expect.arrayContaining([ 'rtp', 'pli' ])); await audioConsumer.enableTraceEvent([]); - await expect(audioConsumer.dump()) - .resolves - .toMatchObject({ traceEventTypes: '' }); + dump = await audioConsumer.dump(); + expect(dump.traceEventTypes) + .toEqual(expect.arrayContaining([])); // @ts-ignore await audioConsumer.enableTraceEvent([ 'nack', 'FOO', 'fir' ]); - await expect(audioConsumer.dump()) - .resolves - .toMatchObject({ traceEventTypes: 'nack,fir' }); + dump = await audioConsumer.dump(); + expect(dump.traceEventTypes) + .toEqual(expect.arrayContaining([ 'nack', 'fir' ])); await audioConsumer.enableTraceEvent(); - await expect(audioConsumer.dump()) - .resolves - .toMatchObject({ traceEventTypes: '' }); + dump = await audioConsumer.dump(); + expect(dump.traceEventTypes) + .toEqual(expect.arrayContaining([])); }, 2000); test('consumer.enableTraceEvent() with wrong arguments rejects with TypeError', async () => @@ -946,12 +975,30 @@ test('Consumer emits "score"', async () => audioConsumer.on('score', onScore); - channel.emit(audioConsumer.id, 'score', { producer: 10, consumer: 9 }); - channel.emit(audioConsumer.id, 'score', { producer: 9, consumer: 9 }); - channel.emit(audioConsumer.id, 'score', { producer: 8, consumer: 8 }); + // Simulate a 'score' notification coming through the channel. + const builder = new flatbuffers.Builder(); + const consumerScore = new FbsConsumer.ConsumerScoreT(9, 10, [ 8 ]); + const consumerScoreNotification = new FbsConsumer.ScoreNotificationT(consumerScore); + const notificationOffset = Notification.createNotification( + builder, + builder.createString(audioConsumer.id), + Event.CONSUMER_SCORE, + NotificationBody.FBS_Consumer_ScoreNotification, + consumerScoreNotification.pack(builder) + ); + + builder.finish(notificationOffset); + + const notification = Notification.getRootAsNotification( + new flatbuffers.ByteBuffer(builder.asUint8Array())); + + channel.emit(audioConsumer.id, Event.CONSUMER_SCORE, notification); + channel.emit(audioConsumer.id, Event.CONSUMER_SCORE, notification); + channel.emit(audioConsumer.id, Event.CONSUMER_SCORE, notification); expect(onScore).toHaveBeenCalledTimes(3); - expect(audioConsumer.score).toEqual({ producer: 8, consumer: 8 }); + expect(audioConsumer.score).toEqual( + { score: 9, producerScore: 10, producerScores: [ 8 ] }); }, 2000); test('consumer.close() succeeds', async () => @@ -964,15 +1011,23 @@ test('consumer.close() succeeds', async () => expect(onObserverClose).toHaveBeenCalledTimes(1); expect(audioConsumer.closed).toBe(true); - await expect(router.dump()) - .resolves - .toMatchObject( - { - mapProducerIdConsumerIds : { [audioProducer.id]: [] }, - mapConsumerIdProducerId : {} - }); + let dump = await router.dump(); + + expect(dump.mapProducerIdConsumerIds) + .toEqual(expect.arrayContaining([ + { key: audioProducer.id, values: [ ] } + ])); + + expect(dump.mapConsumerIdProducerId) + .toEqual(expect.arrayContaining([ + { key: videoConsumer.id, value: videoProducer.id } + ])); + expect(dump.mapConsumerIdProducerId) + .toEqual(expect.arrayContaining([ + { key: videoPipeConsumer.id, value: videoProducer.id } + ])); - const dump = await transport2.dump(); + dump = await transport2.dump(); dump.consumerIds = dump.consumerIds.sort(); diff --git a/node/src/tests/test-DataConsumer.ts b/node/src/tests/test-DataConsumer.ts index 08241fcf3e..df6b829bdd 100644 --- a/node/src/tests/test-DataConsumer.ts +++ b/node/src/tests/test-DataConsumer.ts @@ -71,13 +71,17 @@ test('transport.consumeData() succeeds', async () => expect(dataConsumer1.protocol).toBe('bar'); expect(dataConsumer1.appData).toEqual({ baz: 'LOL' }); - await expect(router.dump()) - .resolves - .toMatchObject( - { - mapDataProducerIdDataConsumerIds : { [dataProducer.id]: [ dataConsumer1.id ] }, - mapDataConsumerIdDataProducerId : { [dataConsumer1.id]: dataProducer.id } - }); + const dump = await router.dump(); + + expect(dump.mapDataProducerIdDataConsumerIds) + .toEqual(expect.arrayContaining([ + { key: dataProducer.id, values: [ dataConsumer1.id ] } + ])); + + expect(dump.mapDataConsumerIdDataProducerId) + .toEqual(expect.arrayContaining([ + { key: dataConsumer1.id, value: dataProducer.id } + ])); await expect(transport2.dump()) .resolves @@ -97,11 +101,11 @@ test('dataConsumer.dump() succeeds', async () => expect(data.dataProducerId).toBe(dataConsumer1.dataProducerId); expect(data.type).toBe('sctp'); expect(typeof data.sctpStreamParameters).toBe('object'); - expect(data.sctpStreamParameters.streamId) + expect(data.sctpStreamParameters!.streamId) .toBe(dataConsumer1.sctpStreamParameters?.streamId); - expect(data.sctpStreamParameters.ordered).toBe(false); - expect(data.sctpStreamParameters.maxPacketLifeTime).toBe(4000); - expect(data.sctpStreamParameters.maxRetransmits).toBeUndefined(); + expect(data.sctpStreamParameters!.ordered).toBe(false); + expect(data.sctpStreamParameters!.maxPacketLifeTime).toBe(4000); + expect(data.sctpStreamParameters!.maxRetransmits).toBeUndefined(); expect(data.label).toBe('foo'); expect(data.protocol).toBe('bar'); }, 2000); @@ -193,13 +197,17 @@ test('dataConsumer.close() succeeds', async () => expect(onObserverClose).toHaveBeenCalledTimes(1); expect(dataConsumer1.closed).toBe(true); - await expect(router.dump()) - .resolves - .toMatchObject( - { - mapDataProducerIdDataConsumerIds : { [dataProducer.id]: [ dataConsumer2.id ] }, - mapDataConsumerIdDataProducerId : { [dataConsumer2.id]: dataProducer.id } - }); + const dump = await router.dump(); + + expect(dump.mapDataProducerIdDataConsumerIds) + .toEqual(expect.arrayContaining([ + { key: dataProducer.id, values: [ dataConsumer2.id ] } + ])); + + expect(dump.mapDataConsumerIdDataProducerId) + .toEqual(expect.arrayContaining([ + { key: dataConsumer2.id, value: dataProducer.id } + ])); await expect(transport2.dump()) .resolves diff --git a/node/src/tests/test-DataProducer.ts b/node/src/tests/test-DataProducer.ts index 711fde3d79..1b44e60cce 100644 --- a/node/src/tests/test-DataProducer.ts +++ b/node/src/tests/test-DataProducer.ts @@ -58,13 +58,14 @@ test('transport1.produceData() succeeds', async () => expect(dataProducer1.protocol).toBe('bar'); expect(dataProducer1.appData).toEqual({ foo: 1, bar: '2' }); - await expect(router.dump()) - .resolves - .toMatchObject( - { - mapDataProducerIdDataConsumerIds : { [dataProducer1.id]: [] }, - mapDataConsumerIdDataProducerId : {} - }); + const dump = await router.dump(); + + expect(dump.mapDataProducerIdDataConsumerIds) + .toEqual(expect.arrayContaining([ + { key: dataProducer1.id, values: [ ] } + ])); + + expect(dump.mapDataConsumerIdDataProducerId.length).toBe(0); await expect(transport1.dump()) .resolves @@ -108,13 +109,14 @@ test('transport2.produceData() succeeds', async () => expect(dataProducer2.protocol).toBe('bar'); expect(dataProducer2.appData).toEqual({ foo: 1, bar: '2' }); - await expect(router.dump()) - .resolves - .toMatchObject( - { - mapDataProducerIdDataConsumerIds : { [dataProducer2.id]: [] }, - mapDataConsumerIdDataProducerId : {} - }); + const dump = await router.dump(); + + expect(dump.mapDataProducerIdDataConsumerIds) + .toEqual(expect.arrayContaining([ + { key: dataProducer2.id, values: [ ] } + ])); + + expect(dump.mapDataConsumerIdDataProducerId.length).toBe(0); await expect(transport2.dump()) .resolves @@ -179,10 +181,10 @@ test('dataProducer.dump() succeeds', async () => expect(data.id).toBe(dataProducer1.id); expect(data.type).toBe('sctp'); expect(typeof data.sctpStreamParameters).toBe('object'); - expect(data.sctpStreamParameters.streamId).toBe(666); - expect(data.sctpStreamParameters.ordered).toBe(true); - expect(data.sctpStreamParameters.maxPacketLifeTime).toBeUndefined(); - expect(data.sctpStreamParameters.maxRetransmits).toBeUndefined(); + expect(data.sctpStreamParameters!.streamId).toBe(666); + expect(data.sctpStreamParameters!.ordered).toBe(true); + expect(data.sctpStreamParameters!.maxPacketLifeTime).toBeUndefined(); + expect(data.sctpStreamParameters!.maxRetransmits).toBeUndefined(); expect(data.label).toBe('foo'); expect(data.protocol).toBe('bar'); @@ -191,10 +193,10 @@ test('dataProducer.dump() succeeds', async () => expect(data.id).toBe(dataProducer2.id); expect(data.type).toBe('sctp'); expect(typeof data.sctpStreamParameters).toBe('object'); - expect(data.sctpStreamParameters.streamId).toBe(777); - expect(data.sctpStreamParameters.ordered).toBe(false); - expect(data.sctpStreamParameters.maxPacketLifeTime).toBeUndefined(); - expect(data.sctpStreamParameters.maxRetransmits).toBe(3); + expect(data.sctpStreamParameters!.streamId).toBe(777); + expect(data.sctpStreamParameters!.ordered).toBe(false); + expect(data.sctpStreamParameters!.maxPacketLifeTime).toBeUndefined(); + expect(data.sctpStreamParameters!.maxRetransmits).toBe(3); expect(data.label).toBe('foo'); expect(data.protocol).toBe('bar'); }, 2000); diff --git a/node/src/tests/test-DirectTransport.ts b/node/src/tests/test-DirectTransport.ts index 848d696ce7..a5d62c84d7 100644 --- a/node/src/tests/test-DirectTransport.ts +++ b/node/src/tests/test-DirectTransport.ts @@ -52,7 +52,7 @@ test('router.createDirectTransport() succeeds', async () => expect(data1.consumerIds).toEqual([]); expect(data1.dataProducerIds).toEqual([]); expect(data1.dataConsumerIds).toEqual([]); - expect(typeof data1.recvRtpHeaderExtensions).toBe('object'); + expect(Array.isArray(data1.recvRtpHeaderExtensions)).toBe(true); expect(typeof data1.rtpListener).toBe('object'); transport1.close(); diff --git a/node/src/tests/test-PlainTransport.ts b/node/src/tests/test-PlainTransport.ts index bfa2553d9e..bee31c73d5 100644 --- a/node/src/tests/test-PlainTransport.ts +++ b/node/src/tests/test-PlainTransport.ts @@ -109,7 +109,7 @@ test('router.createPlainTransport() succeeds', async () => expect(data1.rtcpTuple).toEqual(transport1.rtcpTuple); expect(data1.sctpParameters).toEqual(transport1.sctpParameters); expect(data1.sctpState).toBe('new'); - expect(typeof data1.recvRtpHeaderExtensions).toBe('object'); + expect(Array.isArray(data1.recvRtpHeaderExtensions)).toBe(true); expect(typeof data1.rtpListener).toBe('object'); transport1.close(); diff --git a/node/src/tests/test-Producer.ts b/node/src/tests/test-Producer.ts index 3c86e6680c..c04d6743a1 100644 --- a/node/src/tests/test-Producer.ts +++ b/node/src/tests/test-Producer.ts @@ -1,5 +1,8 @@ +import * as flatbuffers from 'flatbuffers'; import * as mediasoup from '../'; import { UnsupportedError } from '../errors'; +import { Notification, Body as NotificationBody, Event } from '../fbs/notification'; +import * as FbsProducer from '../fbs/producer'; const { createWorker } = mediasoup; @@ -123,8 +126,8 @@ test('transport1.produce() succeeds', async () => .resolves .toMatchObject( { - mapProducerIdConsumerIds : { [audioProducer.id]: [] }, - mapConsumerIdProducerId : {} + mapProducerIdConsumerIds : [ { key: audioProducer.id, values: [] } ], + mapConsumerIdProducerId : [] }); await expect(transport1.dump()) @@ -213,13 +216,16 @@ test('transport2.produce() succeeds', async () => expect(videoProducer.score).toEqual([]); expect(videoProducer.appData).toEqual({ foo: 1, bar: '2' }); - await expect(router.dump()) - .resolves - .toMatchObject( - { - mapProducerIdConsumerIds : { [videoProducer.id]: [] }, - mapConsumerIdProducerId : {} - }); + const dump = await router.dump(); + + expect(dump.mapProducerIdConsumerIds) + .toEqual( + expect.arrayContaining([ + { key: videoProducer.id, values: [] } + ]) + ); + + expect(dump.mapConsumerIdProducerId.length).toBe(0); await expect(transport2.dump()) .resolves @@ -520,7 +526,7 @@ test('producer.dump() succeeds', async () => }); expect(data.rtpParameters.codecs[0].rtcpFeedback).toEqual([]); expect(Array.isArray(data.rtpParameters.headerExtensions)).toBe(true); - expect(data.rtpParameters.headerExtensions.length).toBe(2); + expect(data.rtpParameters.headerExtensions!.length).toBe(2); expect(data.rtpParameters.headerExtensions).toEqual( [ { @@ -537,11 +543,13 @@ test('producer.dump() succeeds', async () => } ]); expect(Array.isArray(data.rtpParameters.encodings)).toBe(true); - expect(data.rtpParameters.encodings.length).toBe(1); - expect(data.rtpParameters.encodings).toEqual( - [ - { codecPayloadType: 0 } - ]); + expect(data.rtpParameters.encodings!.length).toBe(1); + expect(data.rtpParameters.encodings![0]).toEqual( + expect.objectContaining( + { + codecPayloadType : 0 + }) + ); expect(data.type).toBe('simple'); data = await videoProducer.dump(); @@ -575,7 +583,7 @@ test('producer.dump() succeeds', async () => expect(data.rtpParameters.codecs[1].parameters).toEqual({ apt: 112 }); expect(data.rtpParameters.codecs[1].rtcpFeedback).toEqual([]); expect(Array.isArray(data.rtpParameters.headerExtensions)).toBe(true); - expect(data.rtpParameters.headerExtensions.length).toBe(2); + expect(data.rtpParameters.headerExtensions!.length).toBe(2); expect(data.rtpParameters.headerExtensions).toEqual( [ { @@ -592,7 +600,7 @@ test('producer.dump() succeeds', async () => } ]); expect(Array.isArray(data.rtpParameters.encodings)).toBe(true); - expect(data.rtpParameters.encodings.length).toBe(4); + expect(data.rtpParameters.encodings!.length).toBe(4); expect(data.rtpParameters.encodings).toMatchObject( [ { @@ -638,26 +646,28 @@ test('producer.pause() and resume() succeed', async () => test('producer.enableTraceEvent() succeed', async () => { + let dump; + await audioProducer.enableTraceEvent([ 'rtp', 'pli' ]); - await expect(audioProducer.dump()) - .resolves - .toMatchObject({ traceEventTypes: 'rtp,pli' }); + dump = await audioProducer.dump(); + expect(dump.traceEventTypes) + .toEqual(expect.arrayContaining([ 'rtp', 'pli' ])); await audioProducer.enableTraceEvent([]); - await expect(audioProducer.dump()) - .resolves - .toMatchObject({ traceEventTypes: '' }); + dump = await audioProducer.dump(); + expect(dump.traceEventTypes) + .toEqual(expect.arrayContaining([])); // @ts-ignore await audioProducer.enableTraceEvent([ 'nack', 'FOO', 'fir' ]); - await expect(audioProducer.dump()) - .resolves - .toMatchObject({ traceEventTypes: 'nack,fir' }); + dump = await audioProducer.dump(); + expect(dump.traceEventTypes) + .toEqual(expect.arrayContaining([ 'nack', 'fir' ])); await audioProducer.enableTraceEvent(); - await expect(audioProducer.dump()) - .resolves - .toMatchObject({ traceEventTypes: '' }); + dump = await audioProducer.dump(); + expect(dump.traceEventTypes) + .toEqual(expect.arrayContaining([])); }, 2000); test('producer.enableTraceEvent() with wrong arguments rejects with TypeError', async () => @@ -686,12 +696,32 @@ test('Producer emits "score"', async () => videoProducer.on('score', onScore); - channel.emit(videoProducer.id, 'score', [ { ssrc: 11, score: 10 } ]); - channel.emit(videoProducer.id, 'score', [ { ssrc: 11, score: 9 }, { ssrc: 22, score: 8 } ]); - channel.emit(videoProducer.id, 'score', [ { ssrc: 11, score: 9 }, { ssrc: 22, score: 9 } ]); + // Simulate a 'score' notification coming through the channel. + const builder = new flatbuffers.Builder(); + const producerScoreNotification = new FbsProducer.ScoreNotificationT([ + new FbsProducer.ScoreT(/* ssrc */ 11, /* rid */ undefined, /* score */ 10), + new FbsProducer.ScoreT(/* ssrc */ 22, /* rid */ undefined, /* score */ 9) + ]); + const notificationOffset = Notification.createNotification( + builder, + builder.createString(videoProducer.id), + Event.PRODUCER_SCORE, + NotificationBody.FBS_Producer_ScoreNotification, + producerScoreNotification.pack(builder) + ); + + builder.finish(notificationOffset); + + const notification = Notification.getRootAsNotification( + new flatbuffers.ByteBuffer(builder.asUint8Array())); + + channel.emit(videoProducer.id, Event.PRODUCER_SCORE, notification); + channel.emit(videoProducer.id, Event.PRODUCER_SCORE, notification); + channel.emit(videoProducer.id, Event.PRODUCER_SCORE, notification); expect(onScore).toHaveBeenCalledTimes(3); - expect(videoProducer.score).toEqual([ { ssrc: 11, score: 9 }, { ssrc: 22, score: 9 } ]); + expect(videoProducer.score).toEqual( + [ { ssrc: 11, score: 10 }, { ssrc: 22, score: 9 } ]); }, 2000); test('producer.close() succeeds', async () => diff --git a/node/src/tests/test-Router.ts b/node/src/tests/test-Router.ts index 9d9941f2b4..e133efbf68 100644 --- a/node/src/tests/test-Router.ts +++ b/node/src/tests/test-Router.ts @@ -74,9 +74,8 @@ test('worker.createRouter() succeeds', async () => routerIds : [ router.id ], channelMessageHandlers : { - channelRequestHandlers : [ router.id ], - payloadChannelRequestHandlers : [], - payloadChannelNotificationHandlers : [] + channelRequestHandlers : [ router.id ], + channelNotificationHandlers : [] } }); diff --git a/node/src/tests/test-WebRtcServer.ts b/node/src/tests/test-WebRtcServer.ts index ff28ebe26b..137aeb0d73 100644 --- a/node/src/tests/test-WebRtcServer.ts +++ b/node/src/tests/test-WebRtcServer.ts @@ -55,9 +55,8 @@ test('worker.createWebRtcServer() succeeds', async () => routerIds : [], channelMessageHandlers : { - channelRequestHandlers : [ webRtcServer.id ], - payloadChannelRequestHandlers : [], - payloadChannelNotificationHandlers : [] + channelRequestHandlers : [ webRtcServer.id ], + channelNotificationHandlers : [] } }); @@ -130,9 +129,8 @@ test('worker.createWebRtcServer() without specifying port succeeds', async () => routerIds : [], channelMessageHandlers : { - channelRequestHandlers : [ webRtcServer.id ], - payloadChannelRequestHandlers : [], - payloadChannelNotificationHandlers : [] + channelRequestHandlers : [ webRtcServer.id ], + channelNotificationHandlers : [] } }); @@ -568,9 +566,8 @@ test('router.createWebRtcTransport() with webRtcServer succeeds and webRtcServer routerIds : [ router.id ], channelMessageHandlers : { - channelRequestHandlers : [ router.id ], - payloadChannelRequestHandlers : [], - payloadChannelNotificationHandlers : [] + channelRequestHandlers : [ router.id ], + channelNotificationHandlers : [] } }); diff --git a/node/src/tests/test-WebRtcTransport.ts b/node/src/tests/test-WebRtcTransport.ts index bc49b9a168..e5a9b4e19a 100644 --- a/node/src/tests/test-WebRtcTransport.ts +++ b/node/src/tests/test-WebRtcTransport.ts @@ -1,6 +1,10 @@ // @ts-ignore import * as pickPort from 'pick-port'; +import * as flatbuffers from 'flatbuffers'; import * as mediasoup from '../'; +import { Notification, Body as NotificationBody, Event } from '../fbs/notification'; +import * as FbsTransport from '../fbs/transport'; +import * as FbsWebRtcTransport from '../fbs/web-rtc-transport'; const { createWorker } = mediasoup; @@ -162,7 +166,7 @@ test('router.createWebRtcTransport() succeeds', async () => expect(data1.dtlsState).toBe(transport1.dtlsState); expect(data1.sctpParameters).toEqual(transport1.sctpParameters); expect(data1.sctpState).toBe(transport1.sctpState); - expect(typeof data1.recvRtpHeaderExtensions).toBe('object'); + expect(Array.isArray(data1.recvRtpHeaderExtensions)).toBe(true); expect(typeof data1.rtpListener).toBe('object'); transport1.close(); @@ -433,23 +437,23 @@ test('transport.enableTraceEvent() succeed', async () => await transport.enableTraceEvent([ 'foo', 'probation' ]); await expect(transport.dump()) .resolves - .toMatchObject({ traceEventTypes: 'probation' }); + .toMatchObject({ traceEventTypes: [ 'probation' ] }); await transport.enableTraceEvent([]); await expect(transport.dump()) .resolves - .toMatchObject({ traceEventTypes: '' }); + .toMatchObject({ traceEventTypes: [] }); // @ts-ignore await transport.enableTraceEvent([ 'probation', 'FOO', 'bwe', 'BAR' ]); await expect(transport.dump()) .resolves - .toMatchObject({ traceEventTypes: 'probation,bwe' }); + .toMatchObject({ traceEventTypes: [ 'probation', 'bwe' ] }); await transport.enableTraceEvent(); await expect(transport.dump()) .resolves - .toMatchObject({ traceEventTypes: '' }); + .toMatchObject({ traceEventTypes: [] }); }, 2000); test('transport.enableTraceEvent() with wrong arguments rejects with TypeError', async () => @@ -478,12 +482,32 @@ test('WebRtcTransport events succeed', async () => transport.on('icestatechange', onIceStateChange); - channel.emit(transport.id, 'icestatechange', { iceState: 'completed' }); + // Simulate a 'iceselectedtuplechange' notification coming through the channel. + const builder = new flatbuffers.Builder(); + const iceStateChangeNotification = new FbsWebRtcTransport.IceStateChangeNotificationT( + FbsWebRtcTransport.IceState.COMPLETED); + + let notificationOffset = Notification.createNotification( + builder, + builder.createString(transport.id), + Event.WEBRTCTRANSPORT_ICE_STATE_CHANGE, + NotificationBody.FBS_WebRtcTransport_IceStateChangeNotification, + iceStateChangeNotification.pack(builder) + ); + + builder.finish(notificationOffset); + + let notification = Notification.getRootAsNotification( + new flatbuffers.ByteBuffer(builder.asUint8Array())); + + channel.emit(transport.id, Event.WEBRTCTRANSPORT_ICE_STATE_CHANGE, notification); expect(onIceStateChange).toHaveBeenCalledTimes(1); expect(onIceStateChange).toHaveBeenCalledWith('completed'); expect(transport.iceState).toBe('completed'); + builder.clear(); + const onIceSelectedTuple = jest.fn(); const iceSelectedTuple = { @@ -495,28 +519,66 @@ test('WebRtcTransport events succeed', async () => }; transport.on('iceselectedtuplechange', onIceSelectedTuple); - channel.emit(transport.id, 'iceselectedtuplechange', { iceSelectedTuple }); + + // Simulate a 'icestatechange' notification coming through the channel. + const iceSelectedTupleChangeNotification = + new FbsWebRtcTransport.IceSelectedTupleChangeNotificationT( + new FbsTransport.TupleT( + iceSelectedTuple.localIp, + iceSelectedTuple.localPort, + iceSelectedTuple.remoteIp, + iceSelectedTuple.remotePort, + iceSelectedTuple.protocol) + ); + + notificationOffset = Notification.createNotification( + builder, + builder.createString(transport.id), + Event.WEBRTCTRANSPORT_ICE_SELECTED_TUPLE_CHANGE, + NotificationBody.FBS_WebRtcTransport_IceSelectedTupleChangeNotification, + iceSelectedTupleChangeNotification.pack(builder) + ); + + builder.finish(notificationOffset); + + notification = Notification.getRootAsNotification( + new flatbuffers.ByteBuffer(builder.asUint8Array())); + + channel.emit( + transport.id, Event.WEBRTCTRANSPORT_ICE_SELECTED_TUPLE_CHANGE, notification); expect(onIceSelectedTuple).toHaveBeenCalledTimes(1); expect(onIceSelectedTuple).toHaveBeenCalledWith(iceSelectedTuple); expect(transport.iceSelectedTuple).toEqual(iceSelectedTuple); + builder.clear(); + const onDtlsStateChange = jest.fn(); transport.on('dtlsstatechange', onDtlsStateChange); - channel.emit(transport.id, 'dtlsstatechange', { dtlsState: 'connecting' }); + + // Simulate a 'dtlsstatechange' notification coming through the channel. + const dtlsStateChangeNotification = new FbsWebRtcTransport.DtlsStateChangeNotificationT( + FbsWebRtcTransport.DtlsState.CONNECTING); + + notificationOffset = Notification.createNotification( + builder, + builder.createString(transport.id), + Event.WEBRTCTRANSPORT_DTLS_STATE_CHANGE, + NotificationBody.FBS_WebRtcTransport_DtlsStateChangeNotification, + dtlsStateChangeNotification.pack(builder) + ); + + builder.finish(notificationOffset); + + notification = Notification.getRootAsNotification( + new flatbuffers.ByteBuffer(builder.asUint8Array())); + + channel.emit(transport.id, Event.WEBRTCTRANSPORT_DTLS_STATE_CHANGE, notification); expect(onDtlsStateChange).toHaveBeenCalledTimes(1); expect(onDtlsStateChange).toHaveBeenCalledWith('connecting'); expect(transport.dtlsState).toBe('connecting'); - - channel.emit( - transport.id, 'dtlsstatechange', { dtlsState: 'connected', dtlsRemoteCert: 'ABCD' }); - - expect(onDtlsStateChange).toHaveBeenCalledTimes(2); - expect(onDtlsStateChange).toHaveBeenCalledWith('connected'); - expect(transport.dtlsState).toBe('connected'); - expect(transport.dtlsRemoteCert).toBe('ABCD'); }, 2000); test('WebRtcTransport methods reject if closed', async () => diff --git a/node/src/tests/test-Worker.ts b/node/src/tests/test-Worker.ts index 15ab5ace52..1840e14116 100644 --- a/node/src/tests/test-Worker.ts +++ b/node/src/tests/test-Worker.ts @@ -133,9 +133,8 @@ test('worker.dump() succeeds', async () => routerIds : [], channelMessageHandlers : { - channelRequestHandlers : [], - payloadChannelRequestHandlers : [], - payloadChannelNotificationHandlers : [] + channelRequestHandlers : [], + channelNotificationHandlers : [] } }); diff --git a/node/src/tests/test-ortc.ts b/node/src/tests/test-ortc.ts index 8dbabfb25d..b1c4d4ca16 100644 --- a/node/src/tests/test-ortc.ts +++ b/node/src/tests/test-ortc.ts @@ -338,8 +338,7 @@ test('getProducerRtpParametersMapping(), getConsumableRtpParameters(), getConsum expect(consumableRtpParameters.rtcp).toEqual( { cname : rtpParameters.rtcp?.cname, - reducedSize : true, - mux : true + reducedSize : true }); const remoteRtpCapabilities: mediasoup.types.RtpCapabilities = @@ -504,8 +503,7 @@ test('getProducerRtpParametersMapping(), getConsumableRtpParameters(), getConsum expect(consumerRtpParameters.rtcp).toEqual( { cname : rtpParameters.rtcp?.cname, - reducedSize : true, - mux : true + reducedSize : true }); const pipeConsumerRtpParameters = ortc.getPipeConsumerRtpParameters( @@ -551,8 +549,7 @@ test('getProducerRtpParametersMapping(), getConsumableRtpParameters(), getConsum expect(pipeConsumerRtpParameters.rtcp).toEqual( { cname : rtpParameters.rtcp?.cname, - reducedSize : true, - mux : true + reducedSize : true }); }); diff --git a/node/src/utils.ts b/node/src/utils.ts index e91bea6604..c7821509a0 100644 --- a/node/src/utils.ts +++ b/node/src/utils.ts @@ -1,4 +1,6 @@ import { randomInt } from 'crypto'; +import { ProducerType } from './Producer'; +import { Type as FbsRtpParametersType } from './fbs/rtp-parameters'; /** * Clones the given object/array. @@ -30,3 +32,135 @@ type Only = }; export type Either = Only | Only; + +/** + * Get the flatbuffers RtpParameters type for a given Producer. + */ +export function getRtpParametersType( + producerType: ProducerType, pipe: boolean +): FbsRtpParametersType +{ + if (pipe) + { + return FbsRtpParametersType.PIPE; + } + + switch (producerType) + { + case 'simple': + return FbsRtpParametersType.SIMPLE; + + case 'simulcast': + return FbsRtpParametersType.SIMULCAST; + + case 'svc': + return FbsRtpParametersType.SVC; + + default: + return FbsRtpParametersType.NONE; + } +} + +/** + * Get the flatbuffers Producer type for a given RtpParameter type. + */ +export function getProducerType( + rtpParameterType: FbsRtpParametersType +): ProducerType +{ + switch (rtpParameterType) + { + case FbsRtpParametersType.SIMPLE: + return 'simple'; + + case FbsRtpParametersType.SIMULCAST: + return 'simulcast'; + + case FbsRtpParametersType.SVC: + return 'svc'; + + default: + throw new TypeError('invalid RtpParameter type'); + } +} + +/** + * Parse flatbuffers vector into an array of the given type. + */ +export function parseVector( + binary: any, methodName: string, parseFn?: (binary2: any) => Type +): Type[] +{ + const array: Type[] = []; + + for (let i=0; i=12.0.0" } }, + "node_modules/flatbuffers": { + "version": "23.3.3", + "resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-23.3.3.tgz", + "integrity": "sha512-jmreOaAT1t55keaf+Z259Tvh8tR/Srry9K8dgCgvizhKSEr6gLGgaOJI2WFL5fkOpGOGRZwxUrlFn0GCmXUy6g==" + }, "node_modules/flatted": { "version": "3.2.7", "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", @@ -8192,6 +8198,11 @@ "rimraf": "^3.0.2" } }, + "flatbuffers": { + "version": "23.3.3", + "resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-23.3.3.tgz", + "integrity": "sha512-jmreOaAT1t55keaf+Z259Tvh8tR/Srry9K8dgCgvizhKSEr6gLGgaOJI2WFL5fkOpGOGRZwxUrlFn0GCmXUy6g==" + }, "flatted": { "version": "3.2.7", "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", diff --git a/package.json b/package.json index 25ae180fd4..405ba5feb3 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "files": [ "node/lib", "worker/deps/libwebrtc", + "worker/fbs", "worker/fuzzer/include", "worker/fuzzer/src", "worker/include", @@ -57,6 +58,9 @@ "lint:node": "node npm-scripts.js lint:node", "lint:worker": "node npm-scripts.js lint:worker", "format:worker": "node npm-scripts.js format:worker", + "flatc": "npm run flatc:node && npm run flatc:worker", + "flatc:node": "node npm-scripts.js flatc:node", + "flatc:worker": "node npm-scripts.js flatc:worker", "test": "npm run test:node && npm run test:worker", "test:node": "node npm-scripts.js test:node", "test:worker": "node npm-scripts.js test:worker", @@ -86,6 +90,7 @@ }, "dependencies": { "debug": "^4.3.4", + "flatbuffers": "^23.3.3", "h264-profile-level-id": "^1.0.1", "supports-color": "^9.3.1", "uuid": "^9.0.0" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index c1042bed60..8b1755d7fe 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -35,6 +35,7 @@ hash_hasher = "2.0.3" log = "0.4.17" nohash-hasher = "0.2.0" once_cell = "1.16.0" +planus = "0.3.1" serde_json = "1.0.87" serde_repr = "0.1.9" thiserror = "1.0.37" diff --git a/rust/src/data_structures.rs b/rust/src/data_structures.rs index a27d5a5ec1..3995f530cc 100644 --- a/rust/src/data_structures.rs +++ b/rust/src/data_structures.rs @@ -791,6 +791,8 @@ impl<'a> WebRtcMessage<'a> { // | WebRTC Binary Empty | 57 | // +------------------------------------+-----------+ + /* + * TODO. pub(crate) fn new(ppid: u32, payload: Cow<'a, [u8]>) -> Result { match ppid { 51 => Ok(WebRtcMessage::String( @@ -802,6 +804,7 @@ impl<'a> WebRtcMessage<'a> { ppid => Err(ppid), } } + */ pub(crate) fn into_ppid_and_payload(self) -> (u32, Cow<'a, [u8]>) { match self { diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs new file mode 100644 index 0000000000..7976abd4d4 --- /dev/null +++ b/rust/src/fbs.rs @@ -0,0 +1,45093 @@ +//! Flatbuffers data structures compiled from `.fbs` files +pub use root::fbs::*; + +const _: () = ::planus::check_version_compatibility("planus-0.3.1"); + +#[no_implicit_prelude] +mod root { + #[allow(missing_docs)] + #[allow(clippy::all)] + pub mod fbs { + pub mod active_speaker_observer { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ActiveSpeakerObserverOptions { + pub interval: u16, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for ActiveSpeakerObserverOptions { + fn default() -> Self { + Self { interval: 0 } + } + } + + impl ActiveSpeakerObserverOptions { + #[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::<4, 2>::new(builder); + + if prepared_interval.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_interval) = prepared_interval { + table_writer.write::<_, _, 2>(0, &prepared_interval); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for ActiveSpeakerObserverOptions + { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ActiveSpeakerObserverOptions::create(builder, &self.interval) + } + } + + #[derive(Copy, Clone)] + pub struct ActiveSpeakerObserverOptionsRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ActiveSpeakerObserverOptionsRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct DominantSpeakerNotification { + pub producer_id: ::planus::alloc::string::String, + } + + impl DominantSpeakerNotification { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_producer_id); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for DominantSpeakerNotification + { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + DominantSpeakerNotification::create(builder, &self.producer_id) + } + } + + #[derive(Copy, Clone)] + pub struct DominantSpeakerNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DominantSpeakerNotificationRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + } + pub mod audio_level_observer { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct AudioLevelObserverOptions { + pub max_entries: u16, + pub threshold: i8, + 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 { + #[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::<8, 5>::new(builder); + + if prepared_max_entries.is_some() { + table_writer.calculate_size::(2); + } + if prepared_threshold.is_some() { + table_writer.calculate_size::(4); + } + if prepared_interval.is_some() { + table_writer.calculate_size::(6); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_max_entries) = + prepared_max_entries + { + table_writer.write::<_, _, 2>(0, &prepared_max_entries); + } + if let ::core::option::Option::Some(prepared_interval) = prepared_interval { + table_writer.write::<_, _, 2>(2, &prepared_interval); + } + if let ::core::option::Option::Some(prepared_threshold) = prepared_threshold + { + table_writer.write::<_, _, 1>(1, &prepared_threshold); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for AudioLevelObserverOptions { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + AudioLevelObserverOptions::create( + builder, + &self.max_entries, + &self.threshold, + &self.interval, + ) + } + } + + #[derive(Copy, Clone)] + pub struct AudioLevelObserverOptionsRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> AudioLevelObserverOptionsRef<'a> { + pub fn max_entries(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "AudioLevelObserverOptions", "max_entries")? + .unwrap_or(0), + ) + } + + pub fn threshold(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "AudioLevelObserverOptions", "threshold")? + .unwrap_or(0), + ) + } + + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Volume { + pub producer_id: ::planus::alloc::string::String, + pub volume: i8, + } + + impl Volume { + #[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::<6, 5>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_volume.is_some() { + table_writer.calculate_size::(4); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_producer_id); + if let ::core::option::Option::Some(prepared_volume) = prepared_volume { + table_writer.write::<_, _, 1>(1, &prepared_volume); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Volume { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Volume::create(builder, &self.producer_id, &self.volume) + } + } + + #[derive(Copy, Clone)] + pub struct VolumeRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> VolumeRef<'a> { + pub fn producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "Volume", "producer_id") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct VolumesNotification { + pub volumes: ::planus::alloc::vec::Vec, + } + + impl VolumesNotification { + #[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::<4, 4>::new(builder); + + table_writer + .calculate_size::<::planus::Offset<[::planus::Offset]>>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_volumes); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for VolumesNotification { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + VolumesNotification::create(builder, &self.volumes) + } + } + + #[derive(Copy, Clone)] + pub struct VolumesNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> VolumesNotificationRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + } + pub mod common { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct StringString { + pub key: ::planus::alloc::string::String, + pub value: ::planus::alloc::string::String, + } + + impl StringString { + #[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::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_key); + table_writer.write::<_, _, 4>(1, &prepared_value); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for StringString { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + StringString::create(builder, &self.key, &self.value) + } + } + + #[derive(Copy, Clone)] + pub struct StringStringRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> StringStringRef<'a> { + pub fn key(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "StringString", "key") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct StringUint8 { + pub key: ::planus::alloc::string::String, + pub value: u8, + } + + impl StringUint8 { + #[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::<6, 5>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_value.is_some() { + table_writer.calculate_size::(4); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_key); + if let ::core::option::Option::Some(prepared_value) = prepared_value { + table_writer.write::<_, _, 1>(1, &prepared_value); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for StringUint8 { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + StringUint8::create(builder, &self.key, &self.value) + } + } + + #[derive(Copy, Clone)] + pub struct StringUint8Ref<'a>(::planus::table_reader::Table<'a>); + + impl<'a> StringUint8Ref<'a> { + pub fn key(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "StringUint8", "key") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Uint16String { + pub key: u16, + pub value: ::planus::alloc::string::String, + } + + impl Uint16String { + #[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::<6, 6>::new(builder); + + if prepared_key.is_some() { + table_writer.calculate_size::(2); + } + table_writer.calculate_size::<::planus::Offset>(4); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(1, &prepared_value); + if let ::core::option::Option::Some(prepared_key) = prepared_key { + table_writer.write::<_, _, 2>(0, &prepared_key); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Uint16String { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + Uint16String::create(builder, &self.key, &self.value) + } + } + + #[derive(Copy, Clone)] + pub struct Uint16StringRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> Uint16StringRef<'a> { + pub fn key(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(0, "Uint16String", "key")?.unwrap_or(0), + ) + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Uint32String { + pub key: u32, + pub value: ::planus::alloc::string::String, + } + + impl Uint32String { + #[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::<6, 8>::new(builder); + + if prepared_key.is_some() { + table_writer.calculate_size::(2); + } + table_writer.calculate_size::<::planus::Offset>(4); + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_key) = prepared_key { + table_writer.write::<_, _, 4>(0, &prepared_key); + } + table_writer.write::<_, _, 4>(1, &prepared_value); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Uint32String { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + Uint32String::create(builder, &self.key, &self.value) + } + } + + #[derive(Copy, Clone)] + pub struct Uint32StringRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> Uint32StringRef<'a> { + pub fn key(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(0, "Uint32String", "key")?.unwrap_or(0), + ) + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct StringStringArray { + pub key: ::planus::alloc::string::String, + pub values: ::core::option::Option< + ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + >, + } + + impl StringStringArray { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_key: impl ::planus::WriteAs<::planus::Offset>, + field_values: impl ::planus::WriteAsOptional< + ::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::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_values.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_key); + if let ::core::option::Option::Some(prepared_values) = prepared_values { + table_writer.write::<_, _, 4>(1, &prepared_values); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for StringStringArray { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + StringStringArray::create(builder, &self.key, &self.values) + } + } + + #[derive(Copy, Clone)] + pub struct StringStringArrayRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> StringStringArrayRef<'a> { + pub fn key(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "StringStringArray", "key") + } + + pub fn values( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + >, + > { + self.0.access(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()); + if let ::core::option::Option::Some(field_values) = self.values().transpose() { + f.field("values", &field_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: if let ::core::option::Option::Some(values) = value.values()? { + ::core::option::Option::Some(values.to_vec_result()?) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for StringStringArrayRef<'a> { + 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; + 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) + }) + } + } + } + pub mod consumer { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ConsumerLayers { + pub spatial_layer: i16, + 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 { + #[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::<6, 4>::new(builder); + + if prepared_spatial_layer.is_some() { + table_writer.calculate_size::(2); + } + if prepared_temporal_layer.is_some() { + table_writer.calculate_size::(4); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_spatial_layer) = + prepared_spatial_layer + { + table_writer.write::<_, _, 2>(0, &prepared_spatial_layer); + } + if let ::core::option::Option::Some(prepared_temporal_layer) = + prepared_temporal_layer + { + table_writer.write::<_, _, 2>(1, &prepared_temporal_layer); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ConsumerLayers { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ConsumerLayers::create(builder, &self.spatial_layer, &self.temporal_layer) + } + } + + #[derive(Copy, Clone)] + pub struct ConsumerLayersRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ConsumerLayersRef<'a> { + pub fn spatial_layer(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "ConsumerLayers", "spatial_layer")? + .unwrap_or(0), + ) + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ConsumerScore { + pub score: u8, + pub producer_score: u8, + pub producer_scores: ::core::option::Option<::planus::alloc::vec::Vec>, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for ConsumerScore { + fn default() -> Self { + Self { + score: 0, + producer_score: 0, + producer_scores: ::core::default::Default::default(), + } + } + } + + impl ConsumerScore { + #[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::WriteAsOptional<::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::<8, 6>::new(builder); + + if prepared_score.is_some() { + table_writer.calculate_size::(2); + } + if prepared_producer_score.is_some() { + table_writer.calculate_size::(4); + } + if prepared_producer_scores.is_some() { + table_writer.calculate_size::<::planus::Offset<[u8]>>(6); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_producer_scores) = + prepared_producer_scores + { + table_writer.write::<_, _, 4>(2, &prepared_producer_scores); + } + if let ::core::option::Option::Some(prepared_score) = prepared_score { + table_writer.write::<_, _, 1>(0, &prepared_score); + } + if let ::core::option::Option::Some(prepared_producer_score) = + prepared_producer_score + { + table_writer.write::<_, _, 1>(1, &prepared_producer_score); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ConsumerScore { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ConsumerScore::create( + builder, + &self.score, + &self.producer_score, + &self.producer_scores, + ) + } + } + + #[derive(Copy, Clone)] + pub struct ConsumerScoreRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ConsumerScoreRef<'a> { + pub fn score(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(0, "ConsumerScore", "score")?.unwrap_or(0), + ) + } + + pub fn producer_score(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "ConsumerScore", "producer_score")? + .unwrap_or(0), + ) + } + + pub fn producer_scores( + &self, + ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, u8>>> + { + self.0.access(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()); + if let ::core::option::Option::Some(field_producer_scores) = + self.producer_scores().transpose() + { + f.field("producer_scores", &field_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: if let ::core::option::Option::Some(producer_scores) = + value.producer_scores()? + { + ::core::option::Option::Some(producer_scores.to_vec()?) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for ConsumerScoreRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct 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 { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_preferred_layers); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for SetPreferredLayersRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SetPreferredLayersRequest::create(builder, &self.preferred_layers) + } + } + + #[derive(Copy, Clone)] + pub struct SetPreferredLayersRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SetPreferredLayersRequestRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct 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 { + #[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::<4, 4>::new(builder); + + if prepared_preferred_layers.is_some() { + table_writer.calculate_size::<::planus::Offset>(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_preferred_layers) = + prepared_preferred_layers + { + table_writer.write::<_, _, 4>(0, &prepared_preferred_layers); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for SetPreferredLayersResponse + { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SetPreferredLayersResponse::create(builder, &self.preferred_layers) + } + } + + #[derive(Copy, Clone)] + pub struct SetPreferredLayersResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SetPreferredLayersResponseRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct SetPriorityRequest { + pub priority: u8, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for SetPriorityRequest { + fn default() -> Self { + Self { priority: 0 } + } + } + + impl SetPriorityRequest { + #[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::<4, 1>::new(builder); + + if prepared_priority.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_priority) = prepared_priority { + table_writer.write::<_, _, 1>(0, &prepared_priority); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for SetPriorityRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SetPriorityRequest::create(builder, &self.priority) + } + } + + #[derive(Copy, Clone)] + pub struct SetPriorityRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SetPriorityRequestRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct SetPriorityResponse { + pub priority: u8, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for SetPriorityResponse { + fn default() -> Self { + Self { priority: 0 } + } + } + + impl SetPriorityResponse { + #[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::<4, 1>::new(builder); + + if prepared_priority.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_priority) = prepared_priority { + table_writer.write::<_, _, 1>(0, &prepared_priority); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for SetPriorityResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SetPriorityResponse::create(builder, &self.priority) + } + } + + #[derive(Copy, Clone)] + pub struct SetPriorityResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SetPriorityResponseRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct EnableTraceEventRequest { + pub events: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + } + + impl EnableTraceEventRequest { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_events: impl ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + ) -> ::planus::Offset { + let prepared_events = field_events.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_events); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for EnableTraceEventRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + EnableTraceEventRequest::create(builder, &self.events) + } + } + + #[derive(Copy, Clone)] + pub struct EnableTraceEventRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> EnableTraceEventRequestRef<'a> { + pub fn events( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + > { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub enum DumpData { + SimpleConsumerDump(::planus::alloc::boxed::Box), + SimulcastConsumerDump(::planus::alloc::boxed::Box), + SvcConsumerDump(::planus::alloc::boxed::Box), + PipeConsumerDump(::planus::alloc::boxed::Box), + } + + impl DumpData { + pub fn create_simple_consumer_dump( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + } + + pub fn create_simulcast_consumer_dump( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + } + + pub fn create_svc_consumer_dump( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) + } + + pub fn create_pipe_consumer_dump( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) + } + } + + impl ::planus::WriteAsUnion for DumpData { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + match self { + Self::SimpleConsumerDump(value) => { + Self::create_simple_consumer_dump(builder, value) + } + Self::SimulcastConsumerDump(value) => { + Self::create_simulcast_consumer_dump(builder, value) + } + Self::SvcConsumerDump(value) => { + Self::create_svc_consumer_dump(builder, value) + } + Self::PipeConsumerDump(value) => { + Self::create_pipe_consumer_dump(builder, value) + } + } + } + } + + impl ::planus::WriteAsOptionalUnion for DumpData { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + } + } + + #[derive(Copy, Clone, Debug)] + pub enum DumpDataRef<'a> { + SimpleConsumerDump(self::SimpleConsumerDumpRef<'a>), + SimulcastConsumerDump(self::SimulcastConsumerDumpRef<'a>), + SvcConsumerDump(self::SvcConsumerDumpRef<'a>), + PipeConsumerDump(self::PipeConsumerDumpRef<'a>), + } + + impl<'a> ::core::convert::TryFrom> for DumpData { + type Error = ::planus::Error; + + fn try_from(value: DumpDataRef<'a>) -> ::planus::Result { + ::core::result::Result::Ok(match value { + DumpDataRef::SimpleConsumerDump(value) => { + DumpData::SimpleConsumerDump(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + DumpDataRef::SimulcastConsumerDump(value) => { + DumpData::SimulcastConsumerDump(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + DumpDataRef::SvcConsumerDump(value) => { + DumpData::SvcConsumerDump(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + DumpDataRef::PipeConsumerDump(value) => { + DumpData::PipeConsumerDump(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + }) + } + } + + impl<'a> ::planus::TableReadUnion<'a> for DumpDataRef<'a> { + fn from_buffer( + buffer: ::planus::SliceWithStartOffset<'a>, + field_offset: usize, + tag: u8, + ) -> ::core::result::Result { + match tag { + 1 => ::core::result::Result::Ok(Self::SimpleConsumerDump( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 2 => ::core::result::Result::Ok(Self::SimulcastConsumerDump( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 3 => ::core::result::Result::Ok(Self::SvcConsumerDump( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 4 => ::core::result::Result::Ok(Self::PipeConsumerDump( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + _ => ::core::result::Result::Err( + ::planus::errors::ErrorKind::UnknownUnionTag { tag }, + ), + } + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct DumpResponse { + pub data: ::core::option::Option, + pub type_: super::rtp_parameters::Type, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for DumpResponse { + fn default() -> Self { + Self { + data: ::core::default::Default::default(), + type_: super::rtp_parameters::Type::None, + } + } + } + + impl DumpResponse { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_data: impl ::planus::WriteAsOptionalUnion, + field_type_: impl ::planus::WriteAsDefault< + super::rtp_parameters::Type, + super::rtp_parameters::Type, + >, + ) -> ::planus::Offset { + let prepared_data = field_data.prepare(builder); + + let prepared_type_ = + field_type_.prepare(builder, &super::rtp_parameters::Type::None); + + let mut table_writer = + ::planus::table_writer::TableWriter::<8, 6>::new(builder); + + if prepared_data.is_some() { + table_writer.calculate_size::(2); + table_writer.calculate_size::<::planus::Offset>(4); + } + if prepared_type_.is_some() { + table_writer.calculate_size::(6); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_data) = prepared_data { + table_writer.write::<_, _, 4>(1, &prepared_data.offset()); + } + if let ::core::option::Option::Some(prepared_data) = prepared_data { + table_writer.write::<_, _, 1>(0, &prepared_data.tag()); + } + if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { + table_writer.write::<_, _, 1>(2, &prepared_type_); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + DumpResponse::create(builder, &self.data, &self.type_) + } + } + + #[derive(Copy, Clone)] + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DumpResponseRef<'a> { + pub fn data( + &self, + ) -> ::planus::Result<::core::option::Option>> + { + self.0.access_union(0, "DumpResponse", "data") + } + + pub fn type_(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "DumpResponse", "type_")? + .unwrap_or(super::rtp_parameters::Type::None), + ) + } + } + + 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"); + if let ::core::option::Option::Some(field_data) = self.data().transpose() { + f.field("data", &field_data); + } + f.field("type_", &self.type_()); + 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: if let ::core::option::Option::Some(data) = value.data()? { + ::core::option::Option::Some(::core::convert::TryInto::try_into(data)?) + } else { + ::core::option::Option::None + }, + type_: ::core::convert::TryInto::try_into(value.type_()?)?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct BaseConsumerDump { + pub id: ::planus::alloc::string::String, + pub producer_id: ::planus::alloc::string::String, + pub kind: super::rtp_parameters::MediaKind, + pub rtp_parameters: + ::planus::alloc::boxed::Box, + pub consumable_rtp_encodings: ::core::option::Option< + ::planus::alloc::vec::Vec, + >, + pub supported_codec_payload_types: + ::core::option::Option<::planus::alloc::vec::Vec>, + pub trace_event_types: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + pub paused: bool, + pub producer_paused: bool, + pub priority: u8, + } + + impl BaseConsumerDump { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_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_consumable_rtp_encodings: impl ::planus::WriteAsOptional< + ::planus::Offset< + [::planus::Offset], + >, + >, + field_supported_codec_payload_types: impl ::planus::WriteAsOptional< + ::planus::Offset<[u8]>, + >, + field_trace_event_types: impl ::planus::WriteAs< + ::planus::Offset<[::planus::Offset]>, + >, + 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_producer_id = field_producer_id.prepare(builder); + + let prepared_kind = + field_kind.prepare(builder, &super::rtp_parameters::MediaKind::All); + + 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::<22, 28>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + if prepared_kind.is_some() { + table_writer.calculate_size::(6); + } + table_writer + .calculate_size::<::planus::Offset>( + 8, + ); + if prepared_consumable_rtp_encodings.is_some() { + table_writer.calculate_size::<::planus::Offset< + [::planus::Offset], + >>(10); + } + if prepared_supported_codec_payload_types.is_some() { + table_writer.calculate_size::<::planus::Offset<[u8]>>(12); + } + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(14); + if prepared_paused.is_some() { + table_writer.calculate_size::(16); + } + if prepared_producer_paused.is_some() { + table_writer.calculate_size::(18); + } + if prepared_priority.is_some() { + table_writer.calculate_size::(20); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_id); + table_writer.write::<_, _, 4>(1, &prepared_producer_id); + table_writer.write::<_, _, 4>(3, &prepared_rtp_parameters); + if let ::core::option::Option::Some(prepared_consumable_rtp_encodings) = + prepared_consumable_rtp_encodings + { + table_writer.write::<_, _, 4>(4, &prepared_consumable_rtp_encodings); + } + if let ::core::option::Option::Some( + prepared_supported_codec_payload_types, + ) = prepared_supported_codec_payload_types + { + table_writer + .write::<_, _, 4>(5, &prepared_supported_codec_payload_types); + } + table_writer.write::<_, _, 4>(6, &prepared_trace_event_types); + if let ::core::option::Option::Some(prepared_kind) = prepared_kind { + table_writer.write::<_, _, 1>(2, &prepared_kind); + } + if let ::core::option::Option::Some(prepared_paused) = prepared_paused { + table_writer.write::<_, _, 1>(7, &prepared_paused); + } + if let ::core::option::Option::Some(prepared_producer_paused) = + prepared_producer_paused + { + table_writer.write::<_, _, 1>(8, &prepared_producer_paused); + } + if let ::core::option::Option::Some(prepared_priority) = prepared_priority { + table_writer.write::<_, _, 1>(9, &prepared_priority); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for BaseConsumerDump { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + BaseConsumerDump::create( + builder, + &self.id, + &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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct BaseConsumerDumpRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> BaseConsumerDumpRef<'a> { + pub fn id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "BaseConsumerDump", "id") + } + + pub fn producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(1, "BaseConsumerDump", "producer_id") + } + + pub fn kind(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "BaseConsumerDump", "kind")? + .unwrap_or(super::rtp_parameters::MediaKind::All), + ) + } + + pub fn rtp_parameters( + &self, + ) -> ::planus::Result> { + self.0 + .access_required(3, "BaseConsumerDump", "rtp_parameters") + } + + pub fn consumable_rtp_encodings( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector< + 'a, + ::planus::Result>, + >, + >, + > { + self.0 + .access(4, "BaseConsumerDump", "consumable_rtp_encodings") + } + + pub fn supported_codec_payload_types( + &self, + ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, u8>>> + { + self.0 + .access(5, "BaseConsumerDump", "supported_codec_payload_types") + } + + pub fn trace_event_types( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + > { + self.0 + .access_required(6, "BaseConsumerDump", "trace_event_types") + } + + pub fn paused(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(7, "BaseConsumerDump", "paused")? + .unwrap_or(false), + ) + } + + pub fn producer_paused(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(8, "BaseConsumerDump", "producer_paused")? + .unwrap_or(false), + ) + } + + pub fn priority(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(9, "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("producer_id", &self.producer_id()); + f.field("kind", &self.kind()); + f.field("rtp_parameters", &self.rtp_parameters()); + if let ::core::option::Option::Some(field_consumable_rtp_encodings) = + self.consumable_rtp_encodings().transpose() + { + f.field("consumable_rtp_encodings", &field_consumable_rtp_encodings); + } + if let ::core::option::Option::Some(field_supported_codec_payload_types) = + self.supported_codec_payload_types().transpose() + { + f.field( + "supported_codec_payload_types", + &field_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()?)?, + 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: if let ::core::option::Option::Some( + consumable_rtp_encodings, + ) = value.consumable_rtp_encodings()? + { + ::core::option::Option::Some(consumable_rtp_encodings.to_vec_result()?) + } else { + ::core::option::Option::None + }, + supported_codec_payload_types: if let ::core::option::Option::Some( + supported_codec_payload_types, + ) = + value.supported_codec_payload_types()? + { + ::core::option::Option::Some(supported_codec_payload_types.to_vec()?) + } else { + ::core::option::Option::None + }, + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct SimpleConsumerDump { + pub base: ::planus::alloc::boxed::Box, + pub rtp_stream: ::planus::alloc::boxed::Box, + } + + impl SimpleConsumerDump { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_base: impl ::planus::WriteAs<::planus::Offset>, + field_rtp_stream: impl ::planus::WriteAs<::planus::Offset>, + ) -> ::planus::Offset { + let prepared_base = field_base.prepare(builder); + + let prepared_rtp_stream = field_rtp_stream.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_base); + table_writer.write::<_, _, 4>(1, &prepared_rtp_stream); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for SimpleConsumerDump { + type Prepared = ::planus::Offset; + + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) + } + } + + impl ::planus::WriteAsOptional<::planus::Offset> for SimpleConsumerDump { + type Prepared = ::planus::Offset; + + 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 SimpleConsumerDump { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SimpleConsumerDump::create(builder, &self.base, &self.rtp_stream) + } + } + + #[derive(Copy, Clone)] + pub struct SimpleConsumerDumpRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SimpleConsumerDumpRef<'a> { + pub fn base(&self) -> ::planus::Result> { + self.0.access_required(0, "SimpleConsumerDump", "base") + } + + pub fn rtp_stream(&self) -> ::planus::Result> { + self.0 + .access_required(1, "SimpleConsumerDump", "rtp_stream") + } + } + + impl<'a> ::core::fmt::Debug for SimpleConsumerDumpRef<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut f = f.debug_struct("SimpleConsumerDumpRef"); + f.field("base", &self.base()); + f.field("rtp_stream", &self.rtp_stream()); + f.finish() + } + } + + impl<'a> ::core::convert::TryFrom> for SimpleConsumerDump { + type Error = ::planus::Error; + + #[allow(unreachable_code)] + fn try_from(value: SimpleConsumerDumpRef<'a>) -> ::planus::Result { + ::core::result::Result::Ok(Self { + base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( + value.base()?, + )?), + rtp_stream: ::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(value.rtp_stream()?)?, + ), + }) + } + } + + impl<'a> ::planus::TableRead<'a> for SimpleConsumerDumpRef<'a> { + 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 SimpleConsumerDumpRef<'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( + "[SimpleConsumerDumpRef]", + "get", + buffer.offset_from_start, + ) + }) + } + } + + impl ::planus::VectorWrite<::planus::Offset> for SimpleConsumerDump { + type Value = ::planus::Offset; + const STRIDE: usize = 4; + 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 SimpleConsumerDumpRef<'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("[SimpleConsumerDumpRef]", "read_as_root", 0) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct SimulcastConsumerDump { + pub base: ::planus::alloc::boxed::Box, + pub rtp_stream: ::planus::alloc::boxed::Box, + pub preferred_spatial_layer: i16, + pub target_spatial_layer: i16, + pub current_spatial_layer: i16, + pub preferred_temporal_layer: i16, + pub target_temporal_layer: i16, + pub current_temporal_layer: i16, + } + + impl SimulcastConsumerDump { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_base: impl ::planus::WriteAs<::planus::Offset>, + field_rtp_stream: impl ::planus::WriteAs<::planus::Offset>, + field_preferred_spatial_layer: impl ::planus::WriteAsDefault, + field_target_spatial_layer: impl ::planus::WriteAsDefault, + field_current_spatial_layer: impl ::planus::WriteAsDefault, + field_preferred_temporal_layer: impl ::planus::WriteAsDefault, + field_target_temporal_layer: impl ::planus::WriteAsDefault, + field_current_temporal_layer: impl ::planus::WriteAsDefault, + ) -> ::planus::Offset { + let prepared_base = field_base.prepare(builder); + + let prepared_rtp_stream = field_rtp_stream.prepare(builder); + + let prepared_preferred_spatial_layer = + field_preferred_spatial_layer.prepare(builder, &0); + + let prepared_target_spatial_layer = + field_target_spatial_layer.prepare(builder, &0); + + let prepared_current_spatial_layer = + field_current_spatial_layer.prepare(builder, &0); + + let prepared_preferred_temporal_layer = + field_preferred_temporal_layer.prepare(builder, &0); + + let prepared_target_temporal_layer = + field_target_temporal_layer.prepare(builder, &0); + + let prepared_current_temporal_layer = + field_current_temporal_layer.prepare(builder, &0); + + let mut table_writer = + ::planus::table_writer::TableWriter::<18, 20>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + if prepared_preferred_spatial_layer.is_some() { + table_writer.calculate_size::(6); + } + if prepared_target_spatial_layer.is_some() { + table_writer.calculate_size::(8); + } + if prepared_current_spatial_layer.is_some() { + table_writer.calculate_size::(10); + } + if prepared_preferred_temporal_layer.is_some() { + table_writer.calculate_size::(12); + } + if prepared_target_temporal_layer.is_some() { + table_writer.calculate_size::(14); + } + if prepared_current_temporal_layer.is_some() { + table_writer.calculate_size::(16); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_base); + table_writer.write::<_, _, 4>(1, &prepared_rtp_stream); + if let ::core::option::Option::Some(prepared_preferred_spatial_layer) = + prepared_preferred_spatial_layer + { + table_writer.write::<_, _, 2>(2, &prepared_preferred_spatial_layer); + } + if let ::core::option::Option::Some(prepared_target_spatial_layer) = + prepared_target_spatial_layer + { + table_writer.write::<_, _, 2>(3, &prepared_target_spatial_layer); + } + if let ::core::option::Option::Some(prepared_current_spatial_layer) = + prepared_current_spatial_layer + { + table_writer.write::<_, _, 2>(4, &prepared_current_spatial_layer); + } + if let ::core::option::Option::Some(prepared_preferred_temporal_layer) = + prepared_preferred_temporal_layer + { + table_writer.write::<_, _, 2>(5, &prepared_preferred_temporal_layer); + } + if let ::core::option::Option::Some(prepared_target_temporal_layer) = + prepared_target_temporal_layer + { + table_writer.write::<_, _, 2>(6, &prepared_target_temporal_layer); + } + if let ::core::option::Option::Some(prepared_current_temporal_layer) = + prepared_current_temporal_layer + { + table_writer.write::<_, _, 2>(7, &prepared_current_temporal_layer); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for SimulcastConsumerDump { + type Prepared = ::planus::Offset; + + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) + } + } + + impl ::planus::WriteAsOptional<::planus::Offset> for SimulcastConsumerDump { + type Prepared = ::planus::Offset; + + 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 SimulcastConsumerDump { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SimulcastConsumerDump::create( + builder, + &self.base, + &self.rtp_stream, + &self.preferred_spatial_layer, + &self.target_spatial_layer, + &self.current_spatial_layer, + &self.preferred_temporal_layer, + &self.target_temporal_layer, + &self.current_temporal_layer, + ) + } + } + + #[derive(Copy, Clone)] + pub struct SimulcastConsumerDumpRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SimulcastConsumerDumpRef<'a> { + pub fn base(&self) -> ::planus::Result> { + self.0.access_required(0, "SimulcastConsumerDump", "base") + } + + pub fn rtp_stream(&self) -> ::planus::Result> { + self.0 + .access_required(1, "SimulcastConsumerDump", "rtp_stream") + } + + pub fn preferred_spatial_layer(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "SimulcastConsumerDump", "preferred_spatial_layer")? + .unwrap_or(0), + ) + } + + pub fn target_spatial_layer(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(3, "SimulcastConsumerDump", "target_spatial_layer")? + .unwrap_or(0), + ) + } + + pub fn current_spatial_layer(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(4, "SimulcastConsumerDump", "current_spatial_layer")? + .unwrap_or(0), + ) + } + + pub fn preferred_temporal_layer(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(5, "SimulcastConsumerDump", "preferred_temporal_layer")? + .unwrap_or(0), + ) + } + + pub fn target_temporal_layer(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(6, "SimulcastConsumerDump", "target_temporal_layer")? + .unwrap_or(0), + ) + } + + pub fn current_temporal_layer(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(7, "SimulcastConsumerDump", "current_temporal_layer")? + .unwrap_or(0), + ) + } + } + + impl<'a> ::core::fmt::Debug for SimulcastConsumerDumpRef<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut f = f.debug_struct("SimulcastConsumerDumpRef"); + f.field("base", &self.base()); + f.field("rtp_stream", &self.rtp_stream()); + f.field("preferred_spatial_layer", &self.preferred_spatial_layer()); + f.field("target_spatial_layer", &self.target_spatial_layer()); + f.field("current_spatial_layer", &self.current_spatial_layer()); + f.field("preferred_temporal_layer", &self.preferred_temporal_layer()); + f.field("target_temporal_layer", &self.target_temporal_layer()); + f.field("current_temporal_layer", &self.current_temporal_layer()); + f.finish() + } + } + + impl<'a> ::core::convert::TryFrom> for SimulcastConsumerDump { + type Error = ::planus::Error; + + #[allow(unreachable_code)] + fn try_from(value: SimulcastConsumerDumpRef<'a>) -> ::planus::Result { + ::core::result::Result::Ok(Self { + base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( + value.base()?, + )?), + rtp_stream: ::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(value.rtp_stream()?)?, + ), + preferred_spatial_layer: ::core::convert::TryInto::try_into( + value.preferred_spatial_layer()?, + )?, + target_spatial_layer: ::core::convert::TryInto::try_into( + value.target_spatial_layer()?, + )?, + current_spatial_layer: ::core::convert::TryInto::try_into( + value.current_spatial_layer()?, + )?, + preferred_temporal_layer: ::core::convert::TryInto::try_into( + value.preferred_temporal_layer()?, + )?, + target_temporal_layer: ::core::convert::TryInto::try_into( + value.target_temporal_layer()?, + )?, + current_temporal_layer: ::core::convert::TryInto::try_into( + value.current_temporal_layer()?, + )?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for SimulcastConsumerDumpRef<'a> { + 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 SimulcastConsumerDumpRef<'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( + "[SimulcastConsumerDumpRef]", + "get", + buffer.offset_from_start, + ) + }) + } + } + + impl ::planus::VectorWrite<::planus::Offset> for SimulcastConsumerDump { + type Value = ::planus::Offset; + const STRIDE: usize = 4; + 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 SimulcastConsumerDumpRef<'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( + "[SimulcastConsumerDumpRef]", + "read_as_root", + 0, + ) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct SvcConsumerDump { + pub base: ::planus::alloc::boxed::Box, + pub rtp_stream: ::planus::alloc::boxed::Box, + pub preferred_spatial_layer: i16, + pub target_spatial_layer: i16, + pub current_spatial_layer: i16, + pub preferred_temporal_layer: i16, + pub target_temporal_layer: i16, + pub current_temporal_layer: i16, + } + + impl SvcConsumerDump { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_base: impl ::planus::WriteAs<::planus::Offset>, + field_rtp_stream: impl ::planus::WriteAs<::planus::Offset>, + field_preferred_spatial_layer: impl ::planus::WriteAsDefault, + field_target_spatial_layer: impl ::planus::WriteAsDefault, + field_current_spatial_layer: impl ::planus::WriteAsDefault, + field_preferred_temporal_layer: impl ::planus::WriteAsDefault, + field_target_temporal_layer: impl ::planus::WriteAsDefault, + field_current_temporal_layer: impl ::planus::WriteAsDefault, + ) -> ::planus::Offset { + let prepared_base = field_base.prepare(builder); + + let prepared_rtp_stream = field_rtp_stream.prepare(builder); + + let prepared_preferred_spatial_layer = + field_preferred_spatial_layer.prepare(builder, &0); + + let prepared_target_spatial_layer = + field_target_spatial_layer.prepare(builder, &0); + + let prepared_current_spatial_layer = + field_current_spatial_layer.prepare(builder, &0); + + let prepared_preferred_temporal_layer = + field_preferred_temporal_layer.prepare(builder, &0); + + let prepared_target_temporal_layer = + field_target_temporal_layer.prepare(builder, &0); + + let prepared_current_temporal_layer = + field_current_temporal_layer.prepare(builder, &0); + + let mut table_writer = + ::planus::table_writer::TableWriter::<18, 20>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + if prepared_preferred_spatial_layer.is_some() { + table_writer.calculate_size::(6); + } + if prepared_target_spatial_layer.is_some() { + table_writer.calculate_size::(8); + } + if prepared_current_spatial_layer.is_some() { + table_writer.calculate_size::(10); + } + if prepared_preferred_temporal_layer.is_some() { + table_writer.calculate_size::(12); + } + if prepared_target_temporal_layer.is_some() { + table_writer.calculate_size::(14); + } + if prepared_current_temporal_layer.is_some() { + table_writer.calculate_size::(16); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_base); + table_writer.write::<_, _, 4>(1, &prepared_rtp_stream); + if let ::core::option::Option::Some(prepared_preferred_spatial_layer) = + prepared_preferred_spatial_layer + { + table_writer.write::<_, _, 2>(2, &prepared_preferred_spatial_layer); + } + if let ::core::option::Option::Some(prepared_target_spatial_layer) = + prepared_target_spatial_layer + { + table_writer.write::<_, _, 2>(3, &prepared_target_spatial_layer); + } + if let ::core::option::Option::Some(prepared_current_spatial_layer) = + prepared_current_spatial_layer + { + table_writer.write::<_, _, 2>(4, &prepared_current_spatial_layer); + } + if let ::core::option::Option::Some(prepared_preferred_temporal_layer) = + prepared_preferred_temporal_layer + { + table_writer.write::<_, _, 2>(5, &prepared_preferred_temporal_layer); + } + if let ::core::option::Option::Some(prepared_target_temporal_layer) = + prepared_target_temporal_layer + { + table_writer.write::<_, _, 2>(6, &prepared_target_temporal_layer); + } + if let ::core::option::Option::Some(prepared_current_temporal_layer) = + prepared_current_temporal_layer + { + table_writer.write::<_, _, 2>(7, &prepared_current_temporal_layer); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for SvcConsumerDump { + type Prepared = ::planus::Offset; + + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) + } + } + + impl ::planus::WriteAsOptional<::planus::Offset> for SvcConsumerDump { + type Prepared = ::planus::Offset; + + 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 SvcConsumerDump { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SvcConsumerDump::create( + builder, + &self.base, + &self.rtp_stream, + &self.preferred_spatial_layer, + &self.target_spatial_layer, + &self.current_spatial_layer, + &self.preferred_temporal_layer, + &self.target_temporal_layer, + &self.current_temporal_layer, + ) + } + } + + #[derive(Copy, Clone)] + pub struct SvcConsumerDumpRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SvcConsumerDumpRef<'a> { + pub fn base(&self) -> ::planus::Result> { + self.0.access_required(0, "SvcConsumerDump", "base") + } + + pub fn rtp_stream(&self) -> ::planus::Result> { + self.0.access_required(1, "SvcConsumerDump", "rtp_stream") + } + + pub fn preferred_spatial_layer(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "SvcConsumerDump", "preferred_spatial_layer")? + .unwrap_or(0), + ) + } + + pub fn target_spatial_layer(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(3, "SvcConsumerDump", "target_spatial_layer")? + .unwrap_or(0), + ) + } + + pub fn current_spatial_layer(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(4, "SvcConsumerDump", "current_spatial_layer")? + .unwrap_or(0), + ) + } + + pub fn preferred_temporal_layer(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(5, "SvcConsumerDump", "preferred_temporal_layer")? + .unwrap_or(0), + ) + } + + pub fn target_temporal_layer(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(6, "SvcConsumerDump", "target_temporal_layer")? + .unwrap_or(0), + ) + } + + pub fn current_temporal_layer(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(7, "SvcConsumerDump", "current_temporal_layer")? + .unwrap_or(0), + ) + } + } + + impl<'a> ::core::fmt::Debug for SvcConsumerDumpRef<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut f = f.debug_struct("SvcConsumerDumpRef"); + f.field("base", &self.base()); + f.field("rtp_stream", &self.rtp_stream()); + f.field("preferred_spatial_layer", &self.preferred_spatial_layer()); + f.field("target_spatial_layer", &self.target_spatial_layer()); + f.field("current_spatial_layer", &self.current_spatial_layer()); + f.field("preferred_temporal_layer", &self.preferred_temporal_layer()); + f.field("target_temporal_layer", &self.target_temporal_layer()); + f.field("current_temporal_layer", &self.current_temporal_layer()); + f.finish() + } + } + + impl<'a> ::core::convert::TryFrom> for SvcConsumerDump { + type Error = ::planus::Error; + + #[allow(unreachable_code)] + fn try_from(value: SvcConsumerDumpRef<'a>) -> ::planus::Result { + ::core::result::Result::Ok(Self { + base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( + value.base()?, + )?), + rtp_stream: ::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(value.rtp_stream()?)?, + ), + preferred_spatial_layer: ::core::convert::TryInto::try_into( + value.preferred_spatial_layer()?, + )?, + target_spatial_layer: ::core::convert::TryInto::try_into( + value.target_spatial_layer()?, + )?, + current_spatial_layer: ::core::convert::TryInto::try_into( + value.current_spatial_layer()?, + )?, + preferred_temporal_layer: ::core::convert::TryInto::try_into( + value.preferred_temporal_layer()?, + )?, + target_temporal_layer: ::core::convert::TryInto::try_into( + value.target_temporal_layer()?, + )?, + current_temporal_layer: ::core::convert::TryInto::try_into( + value.current_temporal_layer()?, + )?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for SvcConsumerDumpRef<'a> { + 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 SvcConsumerDumpRef<'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( + "[SvcConsumerDumpRef]", + "get", + buffer.offset_from_start, + ) + }) + } + } + + impl ::planus::VectorWrite<::planus::Offset> for SvcConsumerDump { + type Value = ::planus::Offset; + const STRIDE: usize = 4; + 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 SvcConsumerDumpRef<'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("[SvcConsumerDumpRef]", "read_as_root", 0) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct PipeConsumerDump { + pub base: ::planus::alloc::boxed::Box, + pub rtp_streams: ::planus::alloc::vec::Vec, + } + + impl PipeConsumerDump { + #[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]>, + >, + ) -> ::planus::Offset { + let prepared_base = field_base.prepare(builder); + + let prepared_rtp_streams = field_rtp_streams.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_base); + table_writer.write::<_, _, 4>(1, &prepared_rtp_streams); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for PipeConsumerDump { + type Prepared = ::planus::Offset; + + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) + } + } + + impl ::planus::WriteAsOptional<::planus::Offset> for PipeConsumerDump { + type Prepared = ::planus::Offset; + + 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 PipeConsumerDump { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + PipeConsumerDump::create(builder, &self.base, &self.rtp_streams) + } + } + + #[derive(Copy, Clone)] + pub struct PipeConsumerDumpRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> PipeConsumerDumpRef<'a> { + pub fn base(&self) -> ::planus::Result> { + self.0.access_required(0, "PipeConsumerDump", "base") + } + + pub fn rtp_streams( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result>>, + > { + self.0.access_required(1, "PipeConsumerDump", "rtp_streams") + } + } + + impl<'a> ::core::fmt::Debug for PipeConsumerDumpRef<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut f = f.debug_struct("PipeConsumerDumpRef"); + f.field("base", &self.base()); + f.field("rtp_streams", &self.rtp_streams()); + f.finish() + } + } + + impl<'a> ::core::convert::TryFrom> for PipeConsumerDump { + type Error = ::planus::Error; + + #[allow(unreachable_code)] + fn try_from(value: PipeConsumerDumpRef<'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()?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for PipeConsumerDumpRef<'a> { + 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 PipeConsumerDumpRef<'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( + "[PipeConsumerDumpRef]", + "get", + buffer.offset_from_start, + ) + }) + } + } + + impl ::planus::VectorWrite<::planus::Offset> for PipeConsumerDump { + type Value = ::planus::Offset; + const STRIDE: usize = 4; + 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 PipeConsumerDumpRef<'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("[PipeConsumerDumpRef]", "read_as_root", 0) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct GetStatsResponse { + pub stats: + ::core::option::Option<::planus::alloc::vec::Vec>, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for GetStatsResponse { + fn default() -> Self { + Self { + stats: ::core::default::Default::default(), + } + } + } + + impl GetStatsResponse { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_stats: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + ) -> ::planus::Offset { + let prepared_stats = field_stats.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 4>::new(builder); + + if prepared_stats.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_stats) = prepared_stats { + table_writer.write::<_, _, 4>(0, &prepared_stats); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + GetStatsResponse::create(builder, &self.stats) + } + } + + #[derive(Copy, Clone)] + pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> GetStatsResponseRef<'a> { + pub fn stats( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, + > { + self.0.access(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"); + if let ::core::option::Option::Some(field_stats) = self.stats().transpose() { + f.field("stats", &field_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: if let ::core::option::Option::Some(stats) = value.stats()? { + ::core::option::Option::Some(stats.to_vec_result()?) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct LayersChangeNotification { + pub layers: + ::core::option::Option<::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 { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_layers: impl ::planus::WriteAsOptional<::planus::Offset>, + ) -> ::planus::Offset { + let prepared_layers = field_layers.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 4>::new(builder); + + if prepared_layers.is_some() { + table_writer.calculate_size::<::planus::Offset>(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_layers) = prepared_layers { + table_writer.write::<_, _, 4>(0, &prepared_layers); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for LayersChangeNotification { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + LayersChangeNotification::create(builder, &self.layers) + } + } + + #[derive(Copy, Clone)] + pub struct LayersChangeNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> LayersChangeNotificationRef<'a> { + pub fn layers( + &self, + ) -> ::planus::Result<::core::option::Option>> + { + self.0.access(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"); + if let ::core::option::Option::Some(field_layers) = self.layers().transpose() { + f.field("layers", &field_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: if let ::core::option::Option::Some(layers) = value.layers()? { + ::core::option::Option::Some(::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(layers)?, + )) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for LayersChangeNotificationRef<'a> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct RtpNotification { + pub data: ::planus::alloc::vec::Vec, + } + + impl RtpNotification { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset<[u8]>>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_data); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RtpNotification { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + RtpNotification::create(builder, &self.data) + } + } + + #[derive(Copy, Clone)] + pub struct RtpNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RtpNotificationRef<'a> { + pub fn data(&self) -> ::planus::Result<::planus::Vector<'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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ScoreNotification { + pub score: ::planus::alloc::boxed::Box, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for ScoreNotification { + fn default() -> Self { + Self { + score: ::core::default::Default::default(), + } + } + } + + impl ScoreNotification { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_score); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ScoreNotification { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ScoreNotification::create(builder, &self.score) + } + } + + #[derive(Copy, Clone)] + pub struct ScoreNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ScoreNotificationRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + #[repr(u8)] + pub enum TraceType { + Keyframe = 0, + Fir = 1, + Nack = 2, + Pli = 3, + Rtp = 4, + } + + impl ::core::convert::TryFrom for TraceType { + type Error = ::planus::errors::UnknownEnumTagKind; + fn try_from( + value: u8, + ) -> ::core::result::Result + { + #[allow(clippy::match_single_binding)] + match value { + 0 => ::core::result::Result::Ok(TraceType::Keyframe), + 1 => ::core::result::Result::Ok(TraceType::Fir), + 2 => ::core::result::Result::Ok(TraceType::Nack), + 3 => ::core::result::Result::Ok(TraceType::Pli), + 4 => ::core::result::Result::Ok(TraceType::Rtp), + + _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { + tag: value as i128, + }), + } + } + } + + impl ::core::convert::From for u8 { + fn from(value: TraceType) -> Self { + value as u8 + } + } + + impl ::planus::Primitive for TraceType { + const ALIGNMENT: usize = 1; + const SIZE: usize = 1; + } + + impl ::planus::WriteAsPrimitive for TraceType { + #[inline] + fn write( + &self, + cursor: ::planus::Cursor<'_, N>, + buffer_position: u32, + ) { + (*self as u8).write(cursor, buffer_position); + } + } + + impl ::planus::WriteAs for TraceType { + type Prepared = Self; + + #[inline] + fn prepare(&self, _builder: &mut ::planus::Builder) -> TraceType { + *self + } + } + + impl ::planus::WriteAsDefault for TraceType { + type Prepared = Self; + + #[inline] + fn prepare( + &self, + _builder: &mut ::planus::Builder, + default: &TraceType, + ) -> ::core::option::Option { + if self == default { + ::core::option::Option::None + } else { + ::core::option::Option::Some(*self) + } + } + } + + impl ::planus::WriteAsOptional for TraceType { + 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 TraceType { + 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 TraceType { + 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 = ::from_buffer(buffer, offset); + let value: ::core::result::Result = + ::core::convert::TryInto::try_into(value); + value.map_err(|error_kind| { + error_kind.with_error_location( + "TraceType", + "VectorRead::from_buffer", + buffer.offset_from_start, + ) + }) + } + } + + impl ::planus::VectorWrite for TraceType { + const STRIDE: usize = 1; + + type Value = Self; + + 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, + ); + } + } + } + + #[derive( + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + #[repr(u8)] + pub enum TraceDirection { + DirectionIn = 0, + DirectionOut = 1, + } + + impl ::core::convert::TryFrom for TraceDirection { + type Error = ::planus::errors::UnknownEnumTagKind; + 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 { + 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 { + 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 = ::from_buffer(buffer, 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; + + 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, + ); + } + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub enum TraceInfo { + KeyFrameTraceInfo(::planus::alloc::boxed::Box), + FirTraceInfo(::planus::alloc::boxed::Box), + PliTraceInfo(::planus::alloc::boxed::Box), + RtpTraceInfo(::planus::alloc::boxed::Box), + } + + impl TraceInfo { + 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()) + } + + pub fn create_fir_trace_info( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + } + + pub fn create_pli_trace_info( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) + } + + 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 { + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + } + } + + #[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) => { + TraceInfo::KeyFrameTraceInfo(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + TraceInfoRef::FirTraceInfo(value) => { + TraceInfo::FirTraceInfo(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + TraceInfoRef::PliTraceInfo(value) => { + TraceInfo::PliTraceInfo(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + TraceInfoRef::RtpTraceInfo(value) => { + TraceInfo::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 }, + ), + } + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct KeyFrameTraceInfo { + pub is_rtx: bool, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for KeyFrameTraceInfo { + fn default() -> Self { + Self { is_rtx: false } + } + } + + impl KeyFrameTraceInfo { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_is_rtx: impl ::planus::WriteAsDefault, + ) -> ::planus::Offset { + let prepared_is_rtx = field_is_rtx.prepare(builder, &false); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 1>::new(builder); + + if prepared_is_rtx.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { + table_writer.write::<_, _, 1>(0, &prepared_is_rtx); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for KeyFrameTraceInfo { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + KeyFrameTraceInfo::create(builder, &self.is_rtx) + } + } + + #[derive(Copy, Clone)] + pub struct KeyFrameTraceInfoRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> KeyFrameTraceInfoRef<'a> { + pub fn is_rtx(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "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("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 { + is_rtx: ::core::convert::TryInto::try_into(value.is_rtx()?)?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for KeyFrameTraceInfoRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct FirTraceInfo { + pub ssrc: u32, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for FirTraceInfo { + fn default() -> Self { + Self { ssrc: 0 } + } + } + + impl FirTraceInfo { + #[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::<4, 4>::new(builder); + + if prepared_ssrc.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + table_writer.write::<_, _, 4>(0, &prepared_ssrc); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for FirTraceInfo { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + FirTraceInfo::create(builder, &self.ssrc) + } + } + + #[derive(Copy, Clone)] + pub struct FirTraceInfoRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> FirTraceInfoRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct PliTraceInfo { + pub ssrc: u32, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for PliTraceInfo { + fn default() -> Self { + Self { ssrc: 0 } + } + } + + impl PliTraceInfo { + #[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::<4, 4>::new(builder); + + if prepared_ssrc.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + table_writer.write::<_, _, 4>(0, &prepared_ssrc); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for PliTraceInfo { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + PliTraceInfo::create(builder, &self.ssrc) + } + } + + #[derive(Copy, Clone)] + pub struct PliTraceInfoRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> PliTraceInfoRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct RtpTraceInfo { + pub is_rtx: bool, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for RtpTraceInfo { + fn default() -> Self { + Self { is_rtx: false } + } + } + + impl RtpTraceInfo { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_is_rtx: impl ::planus::WriteAsDefault, + ) -> ::planus::Offset { + let prepared_is_rtx = field_is_rtx.prepare(builder, &false); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 1>::new(builder); + + if prepared_is_rtx.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { + table_writer.write::<_, _, 1>(0, &prepared_is_rtx); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RtpTraceInfo { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + RtpTraceInfo::create(builder, &self.is_rtx) + } + } + + #[derive(Copy, Clone)] + pub struct RtpTraceInfoRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RtpTraceInfoRef<'a> { + pub fn is_rtx(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(0, "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("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 { + is_rtx: ::core::convert::TryInto::try_into(value.is_rtx()?)?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for RtpTraceInfoRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct TraceNotification { + pub type_: self::TraceType, + pub timestamp: u64, + pub direction: self::TraceDirection, + pub info: ::core::option::Option, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for TraceNotification { + fn default() -> Self { + Self { + type_: self::TraceType::Keyframe, + timestamp: 0, + direction: self::TraceDirection::DirectionIn, + info: ::core::default::Default::default(), + } + } + } + + impl TraceNotification { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_type_: impl ::planus::WriteAsDefault, + field_timestamp: impl ::planus::WriteAsDefault, + field_direction: impl ::planus::WriteAsDefault< + self::TraceDirection, + self::TraceDirection, + >, + field_info: impl ::planus::WriteAsOptionalUnion, + ) -> ::planus::Offset { + let prepared_type_ = field_type_.prepare(builder, &self::TraceType::Keyframe); + + let prepared_timestamp = field_timestamp.prepare(builder, &0); + + let prepared_direction = + field_direction.prepare(builder, &self::TraceDirection::DirectionIn); + + let prepared_info = field_info.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<10, 15>::new(builder); + + if prepared_type_.is_some() { + table_writer.calculate_size::(2); + } + if prepared_timestamp.is_some() { + table_writer.calculate_size::(4); + } + if prepared_direction.is_some() { + table_writer.calculate_size::(6); + } + if prepared_info.is_some() { + table_writer.calculate_size::(8); + table_writer.calculate_size::<::planus::Offset>(10); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_timestamp) = prepared_timestamp + { + table_writer.write::<_, _, 8>(1, &prepared_timestamp); + } + if let ::core::option::Option::Some(prepared_info) = prepared_info { + table_writer.write::<_, _, 4>(4, &prepared_info.offset()); + } + if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { + table_writer.write::<_, _, 1>(0, &prepared_type_); + } + if let ::core::option::Option::Some(prepared_direction) = prepared_direction + { + table_writer.write::<_, _, 1>(2, &prepared_direction); + } + if let ::core::option::Option::Some(prepared_info) = prepared_info { + table_writer.write::<_, _, 1>(3, &prepared_info.tag()); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for TraceNotification { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + TraceNotification::create( + builder, + &self.type_, + &self.timestamp, + &self.direction, + &self.info, + ) + } + } + + #[derive(Copy, Clone)] + pub struct TraceNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> TraceNotificationRef<'a> { + pub fn type_(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "TraceNotification", "type_")? + .unwrap_or(self::TraceType::Keyframe), + ) + } + + pub fn timestamp(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "TraceNotification", "timestamp")? + .unwrap_or(0), + ) + } + + pub fn direction(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "TraceNotification", "direction")? + .unwrap_or(self::TraceDirection::DirectionIn), + ) + } + + 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> { + 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; + 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) + }) + } + } + } + pub mod rtp_parameters { + #[derive( + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + #[repr(u8)] + pub enum MediaKind { + All = 0, + Audio = 1, + Video = 2, + } + + impl ::core::convert::TryFrom for MediaKind { + type Error = ::planus::errors::UnknownEnumTagKind; + fn try_from( + value: u8, + ) -> ::core::result::Result + { + #[allow(clippy::match_single_binding)] + match value { + 0 => ::core::result::Result::Ok(MediaKind::All), + 1 => ::core::result::Result::Ok(MediaKind::Audio), + 2 => ::core::result::Result::Ok(MediaKind::Video), + + _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { + tag: value as i128, + }), + } + } + } + + impl ::core::convert::From for u8 { + 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 { + 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 = ::from_buffer(buffer, 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; + + 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, + ); + } + } + } + + #[derive( + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + #[repr(u8)] + pub enum Type { + None = 0, + Simple = 1, + Simulcast = 2, + Svc = 3, + Pipe = 4, + } + + impl ::core::convert::TryFrom for Type { + type Error = ::planus::errors::UnknownEnumTagKind; + fn try_from( + value: u8, + ) -> ::core::result::Result + { + #[allow(clippy::match_single_binding)] + match value { + 0 => ::core::result::Result::Ok(Type::None), + 1 => ::core::result::Result::Ok(Type::Simple), + 2 => ::core::result::Result::Ok(Type::Simulcast), + 3 => ::core::result::Result::Ok(Type::Svc), + 4 => ::core::result::Result::Ok(Type::Pipe), + + _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { + tag: value as i128, + }), + } + } + } + + impl ::core::convert::From for u8 { + 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 { + 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 = ::from_buffer(buffer, 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; + + 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, + ); + } + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Boolean { + pub value: u8, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for Boolean { + fn default() -> Self { + Self { value: 0 } + } + } + + impl Boolean { + #[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::<4, 1>::new(builder); + + if prepared_value.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_value) = prepared_value { + table_writer.write::<_, _, 1>(0, &prepared_value); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Boolean { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Boolean::create(builder, &self.value) + } + } + + #[derive(Copy, Clone)] + pub struct BooleanRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> BooleanRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Integer { + pub value: i32, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for Integer { + fn default() -> Self { + Self { value: 0 } + } + } + + impl Integer { + #[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::<4, 4>::new(builder); + + if prepared_value.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_value) = prepared_value { + table_writer.write::<_, _, 4>(0, &prepared_value); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Integer { + type Prepared = ::planus::Offset; + + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) + } + } + + impl ::planus::WriteAsOptional<::planus::Offset> for Integer { + type Prepared = ::planus::Offset; + + 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 Integer { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Integer::create(builder, &self.value) + } + } + + #[derive(Copy, Clone)] + pub struct IntegerRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> IntegerRef<'a> { + pub fn value(&self) -> ::planus::Result { + ::core::result::Result::Ok(self.0.access(0, "Integer", "value")?.unwrap_or(0)) + } + } + + impl<'a> ::core::fmt::Debug for IntegerRef<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut f = f.debug_struct("IntegerRef"); + f.field("value", &self.value()); + f.finish() + } + } + + impl<'a> ::core::convert::TryFrom> for Integer { + type Error = ::planus::Error; + + #[allow(unreachable_code)] + fn try_from(value: IntegerRef<'a>) -> ::planus::Result { + ::core::result::Result::Ok(Self { + value: ::core::convert::TryInto::try_into(value.value()?)?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for IntegerRef<'a> { + 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 IntegerRef<'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( + "[IntegerRef]", + "get", + buffer.offset_from_start, + ) + }) + } + } + + impl ::planus::VectorWrite<::planus::Offset> for Integer { + type Value = ::planus::Offset; + const STRIDE: usize = 4; + 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 IntegerRef<'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("[IntegerRef]", "read_as_root", 0) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct IntegerArray { + pub value: ::core::option::Option<::planus::alloc::vec::Vec>, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for IntegerArray { + fn default() -> Self { + Self { + value: ::core::default::Default::default(), + } + } + } + + impl IntegerArray { + #[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::<4, 4>::new(builder); + + if prepared_value.is_some() { + table_writer.calculate_size::<::planus::Offset<[i32]>>(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_value) = prepared_value { + table_writer.write::<_, _, 4>(0, &prepared_value); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for IntegerArray { + type Prepared = ::planus::Offset; + + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) + } + } + + impl ::planus::WriteAsOptional<::planus::Offset> for IntegerArray { + type Prepared = ::planus::Offset; + + 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 IntegerArray { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + IntegerArray::create(builder, &self.value) + } + } + + #[derive(Copy, Clone)] + pub struct IntegerArrayRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> IntegerArrayRef<'a> { + pub fn value( + &self, + ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, i32>>> + { + self.0.access(0, "IntegerArray", "value") + } + } + + impl<'a> ::core::fmt::Debug for IntegerArrayRef<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut f = f.debug_struct("IntegerArrayRef"); + if let ::core::option::Option::Some(field_value) = self.value().transpose() { + f.field("value", &field_value); + } + f.finish() + } + } + + impl<'a> ::core::convert::TryFrom> for IntegerArray { + type Error = ::planus::Error; + + #[allow(unreachable_code)] + fn try_from(value: IntegerArrayRef<'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 IntegerArrayRef<'a> { + 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 IntegerArrayRef<'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( + "[IntegerArrayRef]", + "get", + buffer.offset_from_start, + ) + }) + } + } + + impl ::planus::VectorWrite<::planus::Offset> for IntegerArray { + type Value = ::planus::Offset; + const STRIDE: usize = 4; + 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 IntegerArrayRef<'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("[IntegerArrayRef]", "read_as_root", 0) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct Double { + pub value: f64, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for Double { + fn default() -> Self { + Self { value: 0.0 } + } + } + + impl Double { + #[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::<4, 8>::new(builder); + + if prepared_value.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_value) = prepared_value { + table_writer.write::<_, _, 8>(0, &prepared_value); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Double { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Double::create(builder, &self.value) + } + } + + #[derive(Copy, Clone)] + pub struct DoubleRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DoubleRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct String { + pub value: ::core::option::Option<::planus::alloc::string::String>, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for String { + fn default() -> Self { + Self { + value: ::core::default::Default::default(), + } + } + } + + impl String { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_value: impl ::planus::WriteAsOptional< + ::planus::Offset<::core::primitive::str>, + >, + ) -> ::planus::Offset { + let prepared_value = field_value.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 4>::new(builder); + + if prepared_value.is_some() { + table_writer.calculate_size::<::planus::Offset>(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_value) = prepared_value { + table_writer.write::<_, _, 4>(0, &prepared_value); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for String { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + String::create(builder, &self.value) + } + } + + #[derive(Copy, Clone)] + pub struct StringRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> StringRef<'a> { + pub fn value( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(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"); + if let ::core::option::Option::Some(field_value) = self.value().transpose() { + f.field("value", &field_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: if let ::core::option::Option::Some(value) = value.value()? { + ::core::option::Option::Some(::core::convert::TryInto::try_into(value)?) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for StringRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub enum Value { + Boolean(::planus::alloc::boxed::Box), + Integer(::planus::alloc::boxed::Box), + Double(::planus::alloc::boxed::Box), + String(::planus::alloc::boxed::Box), + IntegerArray(::planus::alloc::boxed::Box), + } + + impl Value { + pub fn create_boolean( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + } + + pub fn create_integer( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + } + + pub fn create_double( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) + } + + pub fn create_string( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) + } + + pub fn create_integer_array( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) + } + } + + impl ::planus::WriteAsUnion for Value { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + match self { + Self::Boolean(value) => Self::create_boolean(builder, value), + Self::Integer(value) => Self::create_integer(builder, value), + Self::Double(value) => Self::create_double(builder, value), + Self::String(value) => Self::create_string(builder, value), + Self::IntegerArray(value) => Self::create_integer_array(builder, value), + } + } + } + + impl ::planus::WriteAsOptionalUnion for Value { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + } + } + + #[derive(Copy, Clone, Debug)] + pub enum ValueRef<'a> { + Boolean(self::BooleanRef<'a>), + Integer(self::IntegerRef<'a>), + Double(self::DoubleRef<'a>), + String(self::StringRef<'a>), + IntegerArray(self::IntegerArrayRef<'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) => { + Value::Boolean(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + ValueRef::Integer(value) => { + Value::Integer(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + ValueRef::Double(value) => Value::Double(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )), + + ValueRef::String(value) => Value::String(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )), + + ValueRef::IntegerArray(value) => { + Value::IntegerArray(::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::Integer( + ::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::IntegerArray( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + _ => ::core::result::Result::Err( + ::planus::errors::ErrorKind::UnknownUnionTag { tag }, + ), + } + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct Parameter { + pub name: ::planus::alloc::string::String, + pub value: ::core::option::Option, + } + + impl Parameter { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_name: impl ::planus::WriteAs<::planus::Offset>, + field_value: impl ::planus::WriteAsOptionalUnion, + ) -> ::planus::Offset { + let prepared_name = field_name.prepare(builder); + + let prepared_value = field_value.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<6, 9>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_value.is_some() { + table_writer.calculate_size::(4); + table_writer.calculate_size::<::planus::Offset>(6); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_name); + if let ::core::option::Option::Some(prepared_value) = prepared_value { + table_writer.write::<_, _, 4>(2, &prepared_value.offset()); + } + if let ::core::option::Option::Some(prepared_value) = prepared_value { + table_writer.write::<_, _, 1>(1, &prepared_value.tag()); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Parameter { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Parameter::create(builder, &self.name, &self.value) + } + } + + #[derive(Copy, Clone)] + pub struct ParameterRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ParameterRef<'a> { + pub fn name(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "Parameter", "name") + } + + pub fn value( + &self, + ) -> ::planus::Result<::core::option::Option>> { + self.0.access_union(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()); + if let ::core::option::Option::Some(field_value) = self.value().transpose() { + f.field("value", &field_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: if let ::core::option::Option::Some(value) = value.value()? { + ::core::option::Option::Some(::core::convert::TryInto::try_into(value)?) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for ParameterRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct RtcpFeedback { + pub type_: ::planus::alloc::string::String, + pub parameter: ::core::option::Option<::planus::alloc::string::String>, + } + + impl RtcpFeedback { + #[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::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_parameter.is_some() { + table_writer.calculate_size::<::planus::Offset>(4); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_type_); + if let ::core::option::Option::Some(prepared_parameter) = prepared_parameter + { + table_writer.write::<_, _, 4>(1, &prepared_parameter); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RtcpFeedback { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + RtcpFeedback::create(builder, &self.type_, &self.parameter) + } + } + + #[derive(Copy, Clone)] + pub struct RtcpFeedbackRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RtcpFeedbackRef<'a> { + pub fn type_(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "RtcpFeedback", "type_") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct RtpCodecParameters { + pub mime_type: ::planus::alloc::string::String, + pub payload_type: u8, + pub clock_rate: u32, + pub channels: ::core::option::Option, + pub parameters: ::core::option::Option<::planus::alloc::vec::Vec>, + pub rtcp_feedback: + ::core::option::Option<::planus::alloc::vec::Vec>, + } + + impl RtpCodecParameters { + #[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::<14, 18>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_payload_type.is_some() { + table_writer.calculate_size::(4); + } + if prepared_clock_rate.is_some() { + table_writer.calculate_size::(6); + } + if prepared_channels.is_some() { + table_writer.calculate_size::(8); + } + if prepared_parameters.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(10); + } + if prepared_rtcp_feedback.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(12); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_mime_type); + if let ::core::option::Option::Some(prepared_clock_rate) = + prepared_clock_rate + { + table_writer.write::<_, _, 4>(2, &prepared_clock_rate); + } + if let ::core::option::Option::Some(prepared_parameters) = + prepared_parameters + { + table_writer.write::<_, _, 4>(4, &prepared_parameters); + } + if let ::core::option::Option::Some(prepared_rtcp_feedback) = + prepared_rtcp_feedback + { + table_writer.write::<_, _, 4>(5, &prepared_rtcp_feedback); + } + if let ::core::option::Option::Some(prepared_payload_type) = + prepared_payload_type + { + table_writer.write::<_, _, 1>(1, &prepared_payload_type); + } + if let ::core::option::Option::Some(prepared_channels) = prepared_channels { + table_writer.write::<_, _, 1>(3, &prepared_channels); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RtpCodecParameters { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct RtpCodecParametersRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RtpCodecParametersRef<'a> { + pub fn mime_type(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "RtpCodecParameters", "mime_type") + } + + pub fn payload_type(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "RtpCodecParameters", "payload_type")? + .unwrap_or(0), + ) + } + + pub fn clock_rate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "RtpCodecParameters", "clock_rate")? + .unwrap_or(0), + ) + } + + pub fn channels(&self) -> ::planus::Result<::core::option::Option> { + self.0.access(3, "RtpCodecParameters", "channels") + } + + pub fn parameters( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, + > { + self.0.access(4, "RtpCodecParameters", "parameters") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct RtpHeaderExtensionParameters { + pub uri: ::planus::alloc::string::String, + pub id: u8, + pub encrypt: bool, + pub parameters: ::core::option::Option<::planus::alloc::vec::Vec>, + } + + impl RtpHeaderExtensionParameters { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_uri: impl ::planus::WriteAs<::planus::Offset>, + 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); + + 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::<10, 10>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_id.is_some() { + table_writer.calculate_size::(4); + } + if prepared_encrypt.is_some() { + table_writer.calculate_size::(6); + } + if prepared_parameters.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(8); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_uri); + if let ::core::option::Option::Some(prepared_parameters) = + prepared_parameters + { + table_writer.write::<_, _, 4>(3, &prepared_parameters); + } + if let ::core::option::Option::Some(prepared_id) = prepared_id { + table_writer.write::<_, _, 1>(1, &prepared_id); + } + if let ::core::option::Option::Some(prepared_encrypt) = prepared_encrypt { + table_writer.write::<_, _, 1>(2, &prepared_encrypt); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for RtpHeaderExtensionParameters + { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + RtpHeaderExtensionParameters::create( + builder, + &self.uri, + &self.id, + &self.encrypt, + &self.parameters, + ) + } + } + + #[derive(Copy, Clone)] + pub struct RtpHeaderExtensionParametersRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RtpHeaderExtensionParametersRef<'a> { + pub fn uri(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(0, "RtpHeaderExtensionParameters", "uri") + } + + pub fn id(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "RtpHeaderExtensionParameters", "id")? + .unwrap_or(0), + ) + } + + pub fn encrypt(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "RtpHeaderExtensionParameters", "encrypt")? + .unwrap_or(false), + ) + } + + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Rtx { + pub ssrc: u32, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for Rtx { + fn default() -> Self { + Self { ssrc: 0 } + } + } + + impl Rtx { + #[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::<4, 4>::new(builder); + + if prepared_ssrc.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + table_writer.write::<_, _, 4>(0, &prepared_ssrc); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Rtx { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Rtx::create(builder, &self.ssrc) + } + } + + #[derive(Copy, Clone)] + pub struct RtxRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RtxRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct RtpEncodingParameters { + pub ssrc: ::core::option::Option, + pub rid: ::core::option::Option<::planus::alloc::string::String>, + pub codec_payload_type: ::core::option::Option, + pub rtx: ::core::option::Option<::planus::alloc::boxed::Box>, + pub dtx: bool, + pub scalability_mode: ::core::option::Option<::planus::alloc::string::String>, + 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 { + #[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::<16, 22>::new(builder); + + if prepared_ssrc.is_some() { + table_writer.calculate_size::(2); + } + if prepared_rid.is_some() { + table_writer.calculate_size::<::planus::Offset>(4); + } + if prepared_codec_payload_type.is_some() { + table_writer.calculate_size::(6); + } + if prepared_rtx.is_some() { + table_writer.calculate_size::<::planus::Offset>(8); + } + if prepared_dtx.is_some() { + table_writer.calculate_size::(10); + } + if prepared_scalability_mode.is_some() { + table_writer.calculate_size::<::planus::Offset>(12); + } + if prepared_max_bitrate.is_some() { + table_writer.calculate_size::(14); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + table_writer.write::<_, _, 4>(0, &prepared_ssrc); + } + if let ::core::option::Option::Some(prepared_rid) = prepared_rid { + table_writer.write::<_, _, 4>(1, &prepared_rid); + } + if let ::core::option::Option::Some(prepared_rtx) = prepared_rtx { + table_writer.write::<_, _, 4>(3, &prepared_rtx); + } + if let ::core::option::Option::Some(prepared_scalability_mode) = + prepared_scalability_mode + { + table_writer.write::<_, _, 4>(5, &prepared_scalability_mode); + } + if let ::core::option::Option::Some(prepared_max_bitrate) = + prepared_max_bitrate + { + table_writer.write::<_, _, 4>(6, &prepared_max_bitrate); + } + if let ::core::option::Option::Some(prepared_codec_payload_type) = + prepared_codec_payload_type + { + table_writer.write::<_, _, 1>(2, &prepared_codec_payload_type); + } + if let ::core::option::Option::Some(prepared_dtx) = prepared_dtx { + table_writer.write::<_, _, 1>(4, &prepared_dtx); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RtpEncodingParameters { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct RtpEncodingParametersRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RtpEncodingParametersRef<'a> { + pub fn ssrc(&self) -> ::planus::Result<::core::option::Option> { + self.0.access(0, "RtpEncodingParameters", "ssrc") + } + + pub fn rid( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(1, "RtpEncodingParameters", "rid") + } + + pub fn codec_payload_type(&self) -> ::planus::Result<::core::option::Option> { + self.0 + .access(2, "RtpEncodingParameters", "codec_payload_type") + } + + pub fn rtx(&self) -> ::planus::Result<::core::option::Option>> { + self.0.access(3, "RtpEncodingParameters", "rtx") + } + + pub fn dtx(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(4, "RtpEncodingParameters", "dtx")? + .unwrap_or(false), + ) + } + + pub fn scalability_mode( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0 + .access(5, "RtpEncodingParameters", "scalability_mode") + } + + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct RtcpParameters { + pub cname: ::core::option::Option<::planus::alloc::string::String>, + 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 { + #[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::<6, 5>::new(builder); + + if prepared_cname.is_some() { + table_writer.calculate_size::<::planus::Offset>(2); + } + if prepared_reduced_size.is_some() { + table_writer.calculate_size::(4); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_cname) = prepared_cname { + table_writer.write::<_, _, 4>(0, &prepared_cname); + } + if let ::core::option::Option::Some(prepared_reduced_size) = + prepared_reduced_size + { + table_writer.write::<_, _, 1>(1, &prepared_reduced_size); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RtcpParameters { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + RtcpParameters::create(builder, &self.cname, &self.reduced_size) + } + } + + #[derive(Copy, Clone)] + pub struct RtcpParametersRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RtcpParametersRef<'a> { + pub fn cname( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(0, "RtcpParameters", "cname") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct RtpParameters { + pub mid: ::core::option::Option<::planus::alloc::string::String>, + pub codecs: ::planus::alloc::vec::Vec, + pub header_extensions: ::core::option::Option< + ::planus::alloc::vec::Vec, + >, + pub encodings: + ::core::option::Option<::planus::alloc::vec::Vec>, + pub rtcp: ::core::option::Option<::planus::alloc::boxed::Box>, + } + + impl RtpParameters { + #[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::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_encodings: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_rtcp: impl ::planus::WriteAsOptional<::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::<12, 20>::new(builder); + + if prepared_mid.is_some() { + table_writer.calculate_size::<::planus::Offset>(2); + } + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); + if prepared_header_extensions.is_some() { + table_writer.calculate_size::<::planus::Offset< + [::planus::Offset], + >>(6); + } + if prepared_encodings.is_some() { + table_writer.calculate_size::<::planus::Offset< + [::planus::Offset], + >>(8); + } + if prepared_rtcp.is_some() { + table_writer.calculate_size::<::planus::Offset>(10); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_mid) = prepared_mid { + table_writer.write::<_, _, 4>(0, &prepared_mid); + } + table_writer.write::<_, _, 4>(1, &prepared_codecs); + if let ::core::option::Option::Some(prepared_header_extensions) = + prepared_header_extensions + { + table_writer.write::<_, _, 4>(2, &prepared_header_extensions); + } + if let ::core::option::Option::Some(prepared_encodings) = prepared_encodings + { + table_writer.write::<_, _, 4>(3, &prepared_encodings); + } + if let ::core::option::Option::Some(prepared_rtcp) = prepared_rtcp { + table_writer.write::<_, _, 4>(4, &prepared_rtcp); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RtpParameters { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + RtpParameters::create( + builder, + &self.mid, + &self.codecs, + &self.header_extensions, + &self.encodings, + &self.rtcp, + ) + } + } + + #[derive(Copy, Clone)] + pub struct RtpParametersRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RtpParametersRef<'a> { + pub fn mid( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(0, "RtpParameters", "mid") + } + + pub fn codecs( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result>>, + > { + self.0.access_required(1, "RtpParameters", "codecs") + } + + pub fn header_extensions( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector< + 'a, + ::planus::Result>, + >, + >, + > { + self.0.access(2, "RtpParameters", "header_extensions") + } + + pub fn encodings( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, + > { + self.0.access(3, "RtpParameters", "encodings") + } + + pub fn rtcp( + &self, + ) -> ::planus::Result<::core::option::Option>> + { + self.0.access(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()); + if let ::core::option::Option::Some(field_header_extensions) = + self.header_extensions().transpose() + { + f.field("header_extensions", &field_header_extensions); + } + if let ::core::option::Option::Some(field_encodings) = + self.encodings().transpose() + { + f.field("encodings", &field_encodings); + } + if let ::core::option::Option::Some(field_rtcp) = self.rtcp().transpose() { + f.field("rtcp", &field_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: if let ::core::option::Option::Some(header_extensions) = + value.header_extensions()? + { + ::core::option::Option::Some(header_extensions.to_vec_result()?) + } else { + ::core::option::Option::None + }, + encodings: if let ::core::option::Option::Some(encodings) = + value.encodings()? + { + ::core::option::Option::Some(encodings.to_vec_result()?) + } else { + ::core::option::Option::None + }, + rtcp: if let ::core::option::Option::Some(rtcp) = value.rtcp()? { + ::core::option::Option::Some(::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(rtcp)?, + )) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for RtpParametersRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CodecMapping { + pub payload_type: u8, + 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 { + #[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::<6, 2>::new(builder); + + if prepared_payload_type.is_some() { + table_writer.calculate_size::(2); + } + if prepared_mapped_payload_type.is_some() { + table_writer.calculate_size::(4); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_payload_type) = + prepared_payload_type + { + table_writer.write::<_, _, 1>(0, &prepared_payload_type); + } + if let ::core::option::Option::Some(prepared_mapped_payload_type) = + prepared_mapped_payload_type + { + table_writer.write::<_, _, 1>(1, &prepared_mapped_payload_type); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for CodecMapping { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CodecMapping::create(builder, &self.payload_type, &self.mapped_payload_type) + } + } + + #[derive(Copy, Clone)] + pub struct CodecMappingRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CodecMappingRef<'a> { + pub fn payload_type(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "CodecMapping", "payload_type")? + .unwrap_or(0), + ) + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct EncodingMapping { + pub rid: ::core::option::Option<::planus::alloc::string::String>, + pub ssrc: ::core::option::Option, + pub scalability_mode: ::core::option::Option<::planus::alloc::string::String>, + 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 { + #[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::<10, 16>::new(builder); + + if prepared_rid.is_some() { + table_writer.calculate_size::<::planus::Offset>(2); + } + if prepared_ssrc.is_some() { + table_writer.calculate_size::(4); + } + if prepared_scalability_mode.is_some() { + table_writer.calculate_size::<::planus::Offset>(6); + } + if prepared_mapped_ssrc.is_some() { + table_writer.calculate_size::(8); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_rid) = prepared_rid { + table_writer.write::<_, _, 4>(0, &prepared_rid); + } + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + table_writer.write::<_, _, 4>(1, &prepared_ssrc); + } + if let ::core::option::Option::Some(prepared_scalability_mode) = + prepared_scalability_mode + { + table_writer.write::<_, _, 4>(2, &prepared_scalability_mode); + } + if let ::core::option::Option::Some(prepared_mapped_ssrc) = + prepared_mapped_ssrc + { + table_writer.write::<_, _, 4>(3, &prepared_mapped_ssrc); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for EncodingMapping { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + EncodingMapping::create( + builder, + &self.rid, + &self.ssrc, + &self.scalability_mode, + &self.mapped_ssrc, + ) + } + } + + #[derive(Copy, Clone)] + pub struct EncodingMappingRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> EncodingMappingRef<'a> { + pub fn rid( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(0, "EncodingMapping", "rid") + } + + pub fn ssrc(&self) -> ::planus::Result<::core::option::Option> { + self.0.access(1, "EncodingMapping", "ssrc") + } + + pub fn scalability_mode( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(2, "EncodingMapping", "scalability_mode") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct RtpMapping { + pub codecs: ::planus::alloc::vec::Vec, + pub encodings: ::planus::alloc::vec::Vec, + } + + impl RtpMapping { + #[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::<6, 8>::new(builder); + + table_writer + .calculate_size::<::planus::Offset<[::planus::Offset]>>( + 2, + ); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_codecs); + table_writer.write::<_, _, 4>(1, &prepared_encodings); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RtpMapping { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + RtpMapping::create(builder, &self.codecs, &self.encodings) + } + } + + #[derive(Copy, Clone)] + pub struct RtpMappingRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RtpMappingRef<'a> { + pub fn codecs( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result>>, + > { + self.0.access_required(0, "RtpMapping", "codecs") + } + + 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> { + 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; + 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) + }) + } + } + } + pub mod rtp_stream { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Params { + pub encoding_idx: u32, + pub ssrc: u32, + pub payload_type: u8, + pub mime_type: ::planus::alloc::string::String, + pub clock_rate: u32, + pub rid: ::core::option::Option<::planus::alloc::string::String>, + pub cname: ::planus::alloc::string::String, + pub rtx_ssrc: ::core::option::Option, + pub rtx_payload_type: ::core::option::Option, + pub use_nack: bool, + pub use_pli: bool, + pub use_fir: bool, + pub use_in_band_fec: bool, + pub use_dtx: bool, + pub spatial_layers: u8, + pub temporal_layers: u8, + } + + impl Params { + #[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::<34, 37>::new(builder); + + if prepared_encoding_idx.is_some() { + table_writer.calculate_size::(2); + } + if prepared_ssrc.is_some() { + table_writer.calculate_size::(4); + } + if prepared_payload_type.is_some() { + table_writer.calculate_size::(6); + } + table_writer.calculate_size::<::planus::Offset>(8); + if prepared_clock_rate.is_some() { + table_writer.calculate_size::(10); + } + if prepared_rid.is_some() { + table_writer.calculate_size::<::planus::Offset>(12); + } + table_writer.calculate_size::<::planus::Offset>(14); + if prepared_rtx_ssrc.is_some() { + table_writer.calculate_size::(16); + } + if prepared_rtx_payload_type.is_some() { + table_writer.calculate_size::(18); + } + if prepared_use_nack.is_some() { + table_writer.calculate_size::(20); + } + if prepared_use_pli.is_some() { + table_writer.calculate_size::(22); + } + if prepared_use_fir.is_some() { + table_writer.calculate_size::(24); + } + if prepared_use_in_band_fec.is_some() { + table_writer.calculate_size::(26); + } + if prepared_use_dtx.is_some() { + table_writer.calculate_size::(28); + } + if prepared_spatial_layers.is_some() { + table_writer.calculate_size::(30); + } + if prepared_temporal_layers.is_some() { + table_writer.calculate_size::(32); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_encoding_idx) = + prepared_encoding_idx + { + table_writer.write::<_, _, 4>(0, &prepared_encoding_idx); + } + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + table_writer.write::<_, _, 4>(1, &prepared_ssrc); + } + table_writer.write::<_, _, 4>(3, &prepared_mime_type); + if let ::core::option::Option::Some(prepared_clock_rate) = + prepared_clock_rate + { + table_writer.write::<_, _, 4>(4, &prepared_clock_rate); + } + if let ::core::option::Option::Some(prepared_rid) = prepared_rid { + table_writer.write::<_, _, 4>(5, &prepared_rid); + } + table_writer.write::<_, _, 4>(6, &prepared_cname); + if let ::core::option::Option::Some(prepared_rtx_ssrc) = prepared_rtx_ssrc { + table_writer.write::<_, _, 4>(7, &prepared_rtx_ssrc); + } + if let ::core::option::Option::Some(prepared_payload_type) = + prepared_payload_type + { + table_writer.write::<_, _, 1>(2, &prepared_payload_type); + } + if let ::core::option::Option::Some(prepared_rtx_payload_type) = + prepared_rtx_payload_type + { + table_writer.write::<_, _, 1>(8, &prepared_rtx_payload_type); + } + if let ::core::option::Option::Some(prepared_use_nack) = prepared_use_nack { + table_writer.write::<_, _, 1>(9, &prepared_use_nack); + } + if let ::core::option::Option::Some(prepared_use_pli) = prepared_use_pli { + table_writer.write::<_, _, 1>(10, &prepared_use_pli); + } + if let ::core::option::Option::Some(prepared_use_fir) = prepared_use_fir { + table_writer.write::<_, _, 1>(11, &prepared_use_fir); + } + if let ::core::option::Option::Some(prepared_use_in_band_fec) = + prepared_use_in_band_fec + { + table_writer.write::<_, _, 1>(12, &prepared_use_in_band_fec); + } + if let ::core::option::Option::Some(prepared_use_dtx) = prepared_use_dtx { + table_writer.write::<_, _, 1>(13, &prepared_use_dtx); + } + if let ::core::option::Option::Some(prepared_spatial_layers) = + prepared_spatial_layers + { + table_writer.write::<_, _, 1>(14, &prepared_spatial_layers); + } + if let ::core::option::Option::Some(prepared_temporal_layers) = + prepared_temporal_layers + { + table_writer.write::<_, _, 1>(15, &prepared_temporal_layers); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Params { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct ParamsRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ParamsRef<'a> { + pub fn encoding_idx(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(0, "Params", "encoding_idx")?.unwrap_or(0), + ) + } + + pub fn ssrc(&self) -> ::planus::Result { + ::core::result::Result::Ok(self.0.access(1, "Params", "ssrc")?.unwrap_or(0)) + } + + pub fn payload_type(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(2, "Params", "payload_type")?.unwrap_or(0), + ) + } + + pub fn mime_type(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(3, "Params", "mime_type") + } + + pub fn clock_rate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(4, "Params", "clock_rate")?.unwrap_or(0), + ) + } + + pub fn rid( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(5, "Params", "rid") + } + + pub fn cname(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(6, "Params", "cname") + } + + pub fn rtx_ssrc(&self) -> ::planus::Result<::core::option::Option> { + self.0.access(7, "Params", "rtx_ssrc") + } + + pub fn rtx_payload_type(&self) -> ::planus::Result<::core::option::Option> { + self.0.access(8, "Params", "rtx_payload_type") + } + + pub fn use_nack(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(9, "Params", "use_nack")?.unwrap_or(false), + ) + } + + pub fn use_pli(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(10, "Params", "use_pli")?.unwrap_or(false), + ) + } + + pub fn use_fir(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(11, "Params", "use_fir")?.unwrap_or(false), + ) + } + + 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), + ) + } + + pub fn use_dtx(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(13, "Params", "use_dtx")?.unwrap_or(false), + ) + } + + pub fn spatial_layers(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(14, "Params", "spatial_layers")?.unwrap_or(0), + ) + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Dump { + pub params: ::planus::alloc::boxed::Box, + pub score: u8, + pub rtx_stream: + ::core::option::Option<::planus::alloc::boxed::Box>, + } + + impl Dump { + #[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::<8, 9>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_score.is_some() { + table_writer.calculate_size::(4); + } + if prepared_rtx_stream.is_some() { + table_writer + .calculate_size::<::planus::Offset>(6); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_params); + if let ::core::option::Option::Some(prepared_rtx_stream) = + prepared_rtx_stream + { + table_writer.write::<_, _, 4>(2, &prepared_rtx_stream); + } + if let ::core::option::Option::Some(prepared_score) = prepared_score { + table_writer.write::<_, _, 1>(1, &prepared_score); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Dump { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Dump::create(builder, &self.params, &self.score, &self.rtx_stream) + } + } + + #[derive(Copy, Clone)] + pub struct DumpRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DumpRef<'a> { + pub fn params(&self) -> ::planus::Result> { + self.0.access_required(0, "Dump", "params") + } + + pub fn score(&self) -> ::planus::Result { + ::core::result::Result::Ok(self.0.access(1, "Dump", "score")?.unwrap_or(0)) + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct BitrateByLayer { + pub layer: ::planus::alloc::string::String, + pub bitrate: u64, + } + + impl BitrateByLayer { + #[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::<6, 12>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_bitrate.is_some() { + table_writer.calculate_size::(4); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_bitrate) = prepared_bitrate { + table_writer.write::<_, _, 8>(1, &prepared_bitrate); + } + table_writer.write::<_, _, 4>(0, &prepared_layer); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for BitrateByLayer { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + BitrateByLayer::create(builder, &self.layer, &self.bitrate) + } + } + + #[derive(Copy, Clone)] + pub struct BitrateByLayerRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> BitrateByLayerRef<'a> { + pub fn layer(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "BitrateByLayer", "layer") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub enum StatsData { + BaseStats(::planus::alloc::boxed::Box), + RecvStats(::planus::alloc::boxed::Box), + SendStats(::planus::alloc::boxed::Box), + } + + impl StatsData { + pub fn create_base_stats( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + } + + pub fn create_recv_stats( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + } + + 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 { + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + } + } + + #[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) => { + StatsData::BaseStats(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + StatsDataRef::RecvStats(value) => { + StatsData::RecvStats(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + StatsDataRef::SendStats(value) => { + StatsData::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 }, + ), + } + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct Stats { + pub data: ::core::option::Option, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for Stats { + fn default() -> Self { + Self { + data: ::core::default::Default::default(), + } + } + } + + impl Stats { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_data: impl ::planus::WriteAsOptionalUnion, + ) -> ::planus::Offset { + let prepared_data = field_data.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 5>::new(builder); + + if prepared_data.is_some() { + table_writer.calculate_size::(2); + table_writer.calculate_size::<::planus::Offset>(4); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_data) = prepared_data { + table_writer.write::<_, _, 4>(1, &prepared_data.offset()); + } + if let ::core::option::Option::Some(prepared_data) = prepared_data { + table_writer.write::<_, _, 1>(0, &prepared_data.tag()); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Stats { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Stats::create(builder, &self.data) + } + } + + #[derive(Copy, Clone)] + pub struct StatsRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> StatsRef<'a> { + pub fn data( + &self, + ) -> ::planus::Result<::core::option::Option>> + { + self.0.access_union(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"); + if let ::core::option::Option::Some(field_data) = self.data().transpose() { + f.field("data", &field_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: if let ::core::option::Option::Some(data) = value.data()? { + ::core::option::Option::Some(::core::convert::TryInto::try_into(data)?) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for StatsRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct BaseStats { + pub timestamp: u64, + pub ssrc: u32, + pub kind: super::rtp_parameters::MediaKind, + pub mime_type: ::planus::alloc::string::String, + pub packets_lost: u64, + pub fraction_lost: u64, + pub packets_discarded: u64, + pub packets_retransmitted: u64, + pub packets_repaired: u64, + pub nack_count: u64, + pub nack_packet_count: u64, + pub pli_count: u64, + pub fir_count: u64, + pub score: u8, + pub rid: ::core::option::Option<::planus::alloc::string::String>, + pub rtx_ssrc: ::core::option::Option, + pub rtx_packets_discarded: u64, + pub round_trip_time: f32, + } + + impl BaseStats { + #[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::All); + + 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::<38, 110>::new(builder); + + if prepared_timestamp.is_some() { + table_writer.calculate_size::(2); + } + if prepared_ssrc.is_some() { + table_writer.calculate_size::(4); + } + if prepared_kind.is_some() { + table_writer.calculate_size::(6); + } + table_writer.calculate_size::<::planus::Offset>(8); + if prepared_packets_lost.is_some() { + table_writer.calculate_size::(10); + } + if prepared_fraction_lost.is_some() { + table_writer.calculate_size::(12); + } + if prepared_packets_discarded.is_some() { + table_writer.calculate_size::(14); + } + if prepared_packets_retransmitted.is_some() { + table_writer.calculate_size::(16); + } + if prepared_packets_repaired.is_some() { + table_writer.calculate_size::(18); + } + if prepared_nack_count.is_some() { + table_writer.calculate_size::(20); + } + if prepared_nack_packet_count.is_some() { + table_writer.calculate_size::(22); + } + if prepared_pli_count.is_some() { + table_writer.calculate_size::(24); + } + if prepared_fir_count.is_some() { + table_writer.calculate_size::(26); + } + if prepared_score.is_some() { + table_writer.calculate_size::(28); + } + if prepared_rid.is_some() { + table_writer.calculate_size::<::planus::Offset>(30); + } + if prepared_rtx_ssrc.is_some() { + table_writer.calculate_size::(32); + } + if prepared_rtx_packets_discarded.is_some() { + table_writer.calculate_size::(34); + } + if prepared_round_trip_time.is_some() { + table_writer.calculate_size::(36); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_timestamp) = prepared_timestamp + { + table_writer.write::<_, _, 8>(0, &prepared_timestamp); + } + if let ::core::option::Option::Some(prepared_packets_lost) = + prepared_packets_lost + { + table_writer.write::<_, _, 8>(4, &prepared_packets_lost); + } + if let ::core::option::Option::Some(prepared_fraction_lost) = + prepared_fraction_lost + { + table_writer.write::<_, _, 8>(5, &prepared_fraction_lost); + } + if let ::core::option::Option::Some(prepared_packets_discarded) = + prepared_packets_discarded + { + table_writer.write::<_, _, 8>(6, &prepared_packets_discarded); + } + if let ::core::option::Option::Some(prepared_packets_retransmitted) = + prepared_packets_retransmitted + { + table_writer.write::<_, _, 8>(7, &prepared_packets_retransmitted); + } + if let ::core::option::Option::Some(prepared_packets_repaired) = + prepared_packets_repaired + { + table_writer.write::<_, _, 8>(8, &prepared_packets_repaired); + } + if let ::core::option::Option::Some(prepared_nack_count) = + prepared_nack_count + { + table_writer.write::<_, _, 8>(9, &prepared_nack_count); + } + if let ::core::option::Option::Some(prepared_nack_packet_count) = + prepared_nack_packet_count + { + table_writer.write::<_, _, 8>(10, &prepared_nack_packet_count); + } + if let ::core::option::Option::Some(prepared_pli_count) = prepared_pli_count + { + table_writer.write::<_, _, 8>(11, &prepared_pli_count); + } + if let ::core::option::Option::Some(prepared_fir_count) = prepared_fir_count + { + table_writer.write::<_, _, 8>(12, &prepared_fir_count); + } + if let ::core::option::Option::Some(prepared_rtx_packets_discarded) = + prepared_rtx_packets_discarded + { + table_writer.write::<_, _, 8>(16, &prepared_rtx_packets_discarded); + } + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + table_writer.write::<_, _, 4>(1, &prepared_ssrc); + } + table_writer.write::<_, _, 4>(3, &prepared_mime_type); + if let ::core::option::Option::Some(prepared_rid) = prepared_rid { + table_writer.write::<_, _, 4>(14, &prepared_rid); + } + if let ::core::option::Option::Some(prepared_rtx_ssrc) = prepared_rtx_ssrc { + table_writer.write::<_, _, 4>(15, &prepared_rtx_ssrc); + } + if let ::core::option::Option::Some(prepared_round_trip_time) = + prepared_round_trip_time + { + table_writer.write::<_, _, 4>(17, &prepared_round_trip_time); + } + if let ::core::option::Option::Some(prepared_kind) = prepared_kind { + table_writer.write::<_, _, 1>(2, &prepared_kind); + } + if let ::core::option::Option::Some(prepared_score) = prepared_score { + table_writer.write::<_, _, 1>(13, &prepared_score); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for BaseStats { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct BaseStatsRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> BaseStatsRef<'a> { + pub fn timestamp(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(0, "BaseStats", "timestamp")?.unwrap_or(0), + ) + } + + pub fn ssrc(&self) -> ::planus::Result { + ::core::result::Result::Ok(self.0.access(1, "BaseStats", "ssrc")?.unwrap_or(0)) + } + + pub fn kind(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "BaseStats", "kind")? + .unwrap_or(super::rtp_parameters::MediaKind::All), + ) + } + + pub fn mime_type(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(3, "BaseStats", "mime_type") + } + + pub fn packets_lost(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(4, "BaseStats", "packets_lost")?.unwrap_or(0), + ) + } + + pub fn fraction_lost(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(5, "BaseStats", "fraction_lost")?.unwrap_or(0), + ) + } + + pub fn packets_discarded(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(6, "BaseStats", "packets_discarded")? + .unwrap_or(0), + ) + } + + pub fn packets_retransmitted(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(7, "BaseStats", "packets_retransmitted")? + .unwrap_or(0), + ) + } + + pub fn packets_repaired(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(8, "BaseStats", "packets_repaired")? + .unwrap_or(0), + ) + } + + pub fn nack_count(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(9, "BaseStats", "nack_count")?.unwrap_or(0), + ) + } + + pub fn nack_packet_count(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(10, "BaseStats", "nack_packet_count")? + .unwrap_or(0), + ) + } + + pub fn pli_count(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(11, "BaseStats", "pli_count")?.unwrap_or(0), + ) + } + + pub fn fir_count(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(12, "BaseStats", "fir_count")?.unwrap_or(0), + ) + } + + pub fn score(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(13, "BaseStats", "score")?.unwrap_or(0), + ) + } + + pub fn rid( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(14, "BaseStats", "rid") + } + + pub fn rtx_ssrc(&self) -> ::planus::Result<::core::option::Option> { + self.0.access(15, "BaseStats", "rtx_ssrc") + } + + pub fn rtx_packets_discarded(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(16, "BaseStats", "rtx_packets_discarded")? + .unwrap_or(0), + ) + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct RecvStats { + pub base: ::planus::alloc::boxed::Box, + pub jitter: u32, + pub packet_count: u64, + pub byte_count: u64, + pub bitrate: u64, + pub bitrate_by_layer: + ::core::option::Option<::planus::alloc::vec::Vec>, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for RecvStats { + fn default() -> Self { + Self { + base: ::core::default::Default::default(), + jitter: 0, + packet_count: 0, + byte_count: 0, + bitrate: 0, + bitrate_by_layer: ::core::default::Default::default(), + } + } + } + + impl RecvStats { + #[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::WriteAsOptional< + ::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::<14, 36>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_jitter.is_some() { + table_writer.calculate_size::(4); + } + if prepared_packet_count.is_some() { + table_writer.calculate_size::(6); + } + if prepared_byte_count.is_some() { + table_writer.calculate_size::(8); + } + if prepared_bitrate.is_some() { + table_writer.calculate_size::(10); + } + if prepared_bitrate_by_layer.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(12); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_packet_count) = + prepared_packet_count + { + table_writer.write::<_, _, 8>(2, &prepared_packet_count); + } + if let ::core::option::Option::Some(prepared_byte_count) = + prepared_byte_count + { + table_writer.write::<_, _, 8>(3, &prepared_byte_count); + } + if let ::core::option::Option::Some(prepared_bitrate) = prepared_bitrate { + table_writer.write::<_, _, 8>(4, &prepared_bitrate); + } + table_writer.write::<_, _, 4>(0, &prepared_base); + if let ::core::option::Option::Some(prepared_jitter) = prepared_jitter { + table_writer.write::<_, _, 4>(1, &prepared_jitter); + } + if let ::core::option::Option::Some(prepared_bitrate_by_layer) = + prepared_bitrate_by_layer + { + table_writer.write::<_, _, 4>(5, &prepared_bitrate_by_layer); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RecvStats { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct RecvStatsRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RecvStatsRef<'a> { + pub fn base(&self) -> ::planus::Result> { + self.0.access_required(0, "RecvStats", "base") + } + + pub fn jitter(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(1, "RecvStats", "jitter")?.unwrap_or(0), + ) + } + + pub fn packet_count(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(2, "RecvStats", "packet_count")?.unwrap_or(0), + ) + } + + pub fn byte_count(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(3, "RecvStats", "byte_count")?.unwrap_or(0), + ) + } + + pub fn bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(4, "RecvStats", "bitrate")?.unwrap_or(0), + ) + } + + pub fn bitrate_by_layer( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, + > { + self.0.access(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()); + if let ::core::option::Option::Some(field_bitrate_by_layer) = + self.bitrate_by_layer().transpose() + { + f.field("bitrate_by_layer", &field_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: if let ::core::option::Option::Some(bitrate_by_layer) = + value.bitrate_by_layer()? + { + ::core::option::Option::Some(bitrate_by_layer.to_vec_result()?) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for RecvStatsRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct SendStats { + pub base: ::planus::alloc::boxed::Box, + pub packet_count: u64, + pub byte_count: u64, + pub bitrate: u64, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for SendStats { + fn default() -> Self { + Self { + base: ::core::default::Default::default(), + packet_count: 0, + byte_count: 0, + bitrate: 0, + } + } + } + + impl SendStats { + #[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::<10, 28>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_packet_count.is_some() { + table_writer.calculate_size::(4); + } + if prepared_byte_count.is_some() { + table_writer.calculate_size::(6); + } + if prepared_bitrate.is_some() { + table_writer.calculate_size::(8); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_packet_count) = + prepared_packet_count + { + table_writer.write::<_, _, 8>(1, &prepared_packet_count); + } + if let ::core::option::Option::Some(prepared_byte_count) = + prepared_byte_count + { + table_writer.write::<_, _, 8>(2, &prepared_byte_count); + } + if let ::core::option::Option::Some(prepared_bitrate) = prepared_bitrate { + table_writer.write::<_, _, 8>(3, &prepared_bitrate); + } + table_writer.write::<_, _, 4>(0, &prepared_base); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for SendStats { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + SendStats::create( + builder, + &self.base, + &self.packet_count, + &self.byte_count, + &self.bitrate, + ) + } + } + + #[derive(Copy, Clone)] + pub struct SendStatsRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SendStatsRef<'a> { + pub fn base(&self) -> ::planus::Result> { + self.0.access_required(0, "SendStats", "base") + } + + pub fn packet_count(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(1, "SendStats", "packet_count")?.unwrap_or(0), + ) + } + + pub fn byte_count(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(2, "SendStats", "byte_count")?.unwrap_or(0), + ) + } + + 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> { + 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; + 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) + }) + } + } + } + pub mod rtx_stream { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Params { + pub ssrc: u32, + pub payload_type: u8, + pub mime_type: ::planus::alloc::string::String, + pub clock_rate: u32, + pub rrid: ::core::option::Option<::planus::alloc::string::String>, + pub cname: ::planus::alloc::string::String, + } + + impl Params { + #[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::<14, 21>::new(builder); + + if prepared_ssrc.is_some() { + table_writer.calculate_size::(2); + } + if prepared_payload_type.is_some() { + table_writer.calculate_size::(4); + } + table_writer.calculate_size::<::planus::Offset>(6); + if prepared_clock_rate.is_some() { + table_writer.calculate_size::(8); + } + if prepared_rrid.is_some() { + table_writer.calculate_size::<::planus::Offset>(10); + } + table_writer.calculate_size::<::planus::Offset>(12); + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + table_writer.write::<_, _, 4>(0, &prepared_ssrc); + } + table_writer.write::<_, _, 4>(2, &prepared_mime_type); + if let ::core::option::Option::Some(prepared_clock_rate) = + prepared_clock_rate + { + table_writer.write::<_, _, 4>(3, &prepared_clock_rate); + } + if let ::core::option::Option::Some(prepared_rrid) = prepared_rrid { + table_writer.write::<_, _, 4>(4, &prepared_rrid); + } + table_writer.write::<_, _, 4>(5, &prepared_cname); + if let ::core::option::Option::Some(prepared_payload_type) = + prepared_payload_type + { + table_writer.write::<_, _, 1>(1, &prepared_payload_type); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Params { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct ParamsRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ParamsRef<'a> { + pub fn ssrc(&self) -> ::planus::Result { + ::core::result::Result::Ok(self.0.access(0, "Params", "ssrc")?.unwrap_or(0)) + } + + pub fn payload_type(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(1, "Params", "payload_type")?.unwrap_or(0), + ) + } + + pub fn mime_type(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(2, "Params", "mime_type") + } + + pub fn clock_rate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(3, "Params", "clock_rate")?.unwrap_or(0), + ) + } + + pub fn rrid( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(4, "Params", "rrid") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct RtxDump { + pub params: ::planus::alloc::boxed::Box, + } + + impl RtxDump { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_params); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RtxDump { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + RtxDump::create(builder, &self.params) + } + } + + #[derive(Copy, Clone)] + pub struct RtxDumpRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RtxDumpRef<'a> { + 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> { + 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; + 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) + }) + } + } + } + pub mod data_consumer { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct GetBufferedAmountResponse { + pub buffered_amount: u32, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for GetBufferedAmountResponse { + fn default() -> Self { + Self { buffered_amount: 0 } + } + } + + impl GetBufferedAmountResponse { + #[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::<4, 4>::new(builder); + + if prepared_buffered_amount.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_buffered_amount) = + prepared_buffered_amount + { + table_writer.write::<_, _, 4>(0, &prepared_buffered_amount); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for GetBufferedAmountResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + GetBufferedAmountResponse::create(builder, &self.buffered_amount) + } + } + + #[derive(Copy, Clone)] + pub struct GetBufferedAmountResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> GetBufferedAmountResponseRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct SetBufferedAmountLowThresholdRequest { + pub threshold: u32, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for SetBufferedAmountLowThresholdRequest { + fn default() -> Self { + Self { threshold: 0 } + } + } + + impl SetBufferedAmountLowThresholdRequest { + #[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::<4, 4>::new(builder); + + if prepared_threshold.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_threshold) = prepared_threshold + { + table_writer.write::<_, _, 4>(0, &prepared_threshold); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for SetBufferedAmountLowThresholdRequest + { + type Prepared = ::planus::Offset; + + 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; + + 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 + { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SetBufferedAmountLowThresholdRequest::create(builder, &self.threshold) + } + } + + #[derive(Copy, Clone)] + pub struct SetBufferedAmountLowThresholdRequestRef<'a>( + ::planus::table_reader::Table<'a>, + ); + + impl<'a> SetBufferedAmountLowThresholdRequestRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct DumpResponse { + pub id: ::planus::alloc::string::String, + pub data_producer_id: ::planus::alloc::string::String, + pub type_: ::planus::alloc::string::String, + pub sctp_stream_parameters: ::core::option::Option< + ::planus::alloc::boxed::Box, + >, + pub label: ::planus::alloc::string::String, + pub protocol: ::planus::alloc::string::String, + } + + impl DumpResponse { + #[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::WriteAs<::planus::Offset>, + field_sctp_stream_parameters: impl ::planus::WriteAsOptional< + ::planus::Offset, + >, + field_label: impl ::planus::WriteAs<::planus::Offset>, + field_protocol: impl ::planus::WriteAs<::planus::Offset>, + ) -> ::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); + + 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 mut table_writer = + ::planus::table_writer::TableWriter::<14, 24>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + table_writer.calculate_size::<::planus::Offset>(6); + if prepared_sctp_stream_parameters.is_some() { + table_writer.calculate_size::<::planus::Offset>(8); + } + table_writer.calculate_size::<::planus::Offset>(10); + table_writer.calculate_size::<::planus::Offset>(12); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_id); + table_writer.write::<_, _, 4>(1, &prepared_data_producer_id); + table_writer.write::<_, _, 4>(2, &prepared_type_); + if let ::core::option::Option::Some(prepared_sctp_stream_parameters) = + prepared_sctp_stream_parameters + { + table_writer.write::<_, _, 4>(3, &prepared_sctp_stream_parameters); + } + table_writer.write::<_, _, 4>(4, &prepared_label); + table_writer.write::<_, _, 4>(5, &prepared_protocol); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DumpResponseRef<'a> { + pub fn id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "DumpResponse", "id") + } + + pub fn data_producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(1, "DumpResponse", "data_producer_id") + } + + pub fn type_(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(2, "DumpResponse", "type_") + } + + pub fn sctp_stream_parameters( + &self, + ) -> ::planus::Result< + ::core::option::Option>, + > { + self.0.access(3, "DumpResponse", "sctp_stream_parameters") + } + + pub fn label(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(4, "DumpResponse", "label") + } + + pub fn protocol(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(5, "DumpResponse", "protocol") + } + } + + 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.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()?)?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct GetStatsResponse { + pub timestamp: u64, + pub label: ::planus::alloc::string::String, + pub protocol: ::planus::alloc::string::String, + pub messages_sent: u64, + pub bytes_sent: u64, + pub buffered_amount: u32, + } + + impl GetStatsResponse { + #[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::<14, 36>::new(builder); + + if prepared_timestamp.is_some() { + table_writer.calculate_size::(2); + } + table_writer.calculate_size::<::planus::Offset>(4); + table_writer.calculate_size::<::planus::Offset>(6); + if prepared_messages_sent.is_some() { + table_writer.calculate_size::(8); + } + if prepared_bytes_sent.is_some() { + table_writer.calculate_size::(10); + } + if prepared_buffered_amount.is_some() { + table_writer.calculate_size::(12); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_timestamp) = prepared_timestamp + { + table_writer.write::<_, _, 8>(0, &prepared_timestamp); + } + if let ::core::option::Option::Some(prepared_messages_sent) = + prepared_messages_sent + { + table_writer.write::<_, _, 8>(3, &prepared_messages_sent); + } + if let ::core::option::Option::Some(prepared_bytes_sent) = + prepared_bytes_sent + { + table_writer.write::<_, _, 8>(4, &prepared_bytes_sent); + } + table_writer.write::<_, _, 4>(1, &prepared_label); + table_writer.write::<_, _, 4>(2, &prepared_protocol); + if let ::core::option::Option::Some(prepared_buffered_amount) = + prepared_buffered_amount + { + table_writer.write::<_, _, 4>(5, &prepared_buffered_amount); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> GetStatsResponseRef<'a> { + pub fn timestamp(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "GetStatsResponse", "timestamp")? + .unwrap_or(0), + ) + } + + pub fn label(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(1, "GetStatsResponse", "label") + } + + pub fn protocol(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(2, "GetStatsResponse", "protocol") + } + + pub fn messages_sent(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(3, "GetStatsResponse", "messages_sent")? + .unwrap_or(0), + ) + } + + pub fn bytes_sent(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(4, "GetStatsResponse", "bytes_sent")? + .unwrap_or(0), + ) + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct String { + pub value: ::planus::alloc::string::String, + } + + impl String { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_value); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for String { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + String::create(builder, &self.value) + } + } + + #[derive(Copy, Clone)] + pub struct StringRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> StringRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Binary { + pub value: ::planus::alloc::vec::Vec, + } + + impl Binary { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_value: impl ::planus::WriteAs<::planus::Offset<[u8]>>, + ) -> ::planus::Offset { + let prepared_value = field_value.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset<[u8]>>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_value); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Binary { + type Prepared = ::planus::Offset; + + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) + } + } + + impl ::planus::WriteAsOptional<::planus::Offset> for Binary { + type Prepared = ::planus::Offset; + + 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 Binary { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Binary::create(builder, &self.value) + } + } + + #[derive(Copy, Clone)] + pub struct BinaryRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> BinaryRef<'a> { + pub fn value(&self) -> ::planus::Result<::planus::Vector<'a, u8>> { + self.0.access_required(0, "Binary", "value") + } + } + + impl<'a> ::core::fmt::Debug for BinaryRef<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut f = f.debug_struct("BinaryRef"); + f.field("value", &self.value()); + f.finish() + } + } + + impl<'a> ::core::convert::TryFrom> for Binary { + type Error = ::planus::Error; + + #[allow(unreachable_code)] + fn try_from(value: BinaryRef<'a>) -> ::planus::Result { + ::core::result::Result::Ok(Self { + value: value.value()?.to_vec()?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for BinaryRef<'a> { + 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 BinaryRef<'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( + "[BinaryRef]", + "get", + buffer.offset_from_start, + ) + }) + } + } + + impl ::planus::VectorWrite<::planus::Offset> for Binary { + type Value = ::planus::Offset; + const STRIDE: usize = 4; + 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 BinaryRef<'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("[BinaryRef]", "read_as_root", 0) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub enum Data { + String(::planus::alloc::boxed::Box), + Binary(::planus::alloc::boxed::Box), + } + + impl Data { + pub fn create_string( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + } + + pub fn create_binary( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + } + } + + impl ::planus::WriteAsUnion for Data { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + match self { + Self::String(value) => Self::create_string(builder, value), + Self::Binary(value) => Self::create_binary(builder, value), + } + } + } + + impl ::planus::WriteAsOptionalUnion for Data { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + } + } + + #[derive(Copy, Clone, Debug)] + pub enum DataRef<'a> { + String(self::StringRef<'a>), + Binary(self::BinaryRef<'a>), + } + + impl<'a> ::core::convert::TryFrom> for Data { + type Error = ::planus::Error; + + fn try_from(value: DataRef<'a>) -> ::planus::Result { + ::core::result::Result::Ok(match value { + DataRef::String(value) => Data::String(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )), + + DataRef::Binary(value) => Data::Binary(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )), + }) + } + } + + impl<'a> ::planus::TableReadUnion<'a> for DataRef<'a> { + fn from_buffer( + buffer: ::planus::SliceWithStartOffset<'a>, + field_offset: usize, + tag: u8, + ) -> ::core::result::Result { + match tag { + 1 => ::core::result::Result::Ok(Self::String( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 2 => ::core::result::Result::Ok(Self::Binary( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + _ => ::core::result::Result::Err( + ::planus::errors::ErrorKind::UnknownUnionTag { tag }, + ), + } + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct SendRequest { + pub ppid: u8, + pub data: self::Data, + } + + impl SendRequest { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_ppid: impl ::planus::WriteAsDefault, + field_data: impl ::planus::WriteAsUnion, + ) -> ::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::<6, 6>::new(builder); + + if prepared_ppid.is_some() { + table_writer.calculate_size::(2); + } + table_writer.calculate_size::(4); + table_writer.calculate_size::<::planus::Offset>(6); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(2, &prepared_data.offset()); + if let ::core::option::Option::Some(prepared_ppid) = prepared_ppid { + table_writer.write::<_, _, 1>(0, &prepared_ppid); + } + table_writer.write::<_, _, 1>(1, &prepared_data.tag()); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for SendRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SendRequest::create(builder, &self.ppid, &self.data) + } + } + + #[derive(Copy, Clone)] + pub struct SendRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SendRequestRef<'a> { + pub fn ppid(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(0, "SendRequest", "ppid")?.unwrap_or(0), + ) + } + + pub fn data(&self) -> ::planus::Result> { + self.0.access_union_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: ::core::convert::TryInto::try_into(value.data()?)?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for SendRequestRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct BufferedAmountLowNotification { + pub buffered_amount: u32, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for BufferedAmountLowNotification { + fn default() -> Self { + Self { buffered_amount: 0 } + } + } + + impl BufferedAmountLowNotification { + #[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::<4, 4>::new(builder); + + if prepared_buffered_amount.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_buffered_amount) = + prepared_buffered_amount + { + table_writer.write::<_, _, 4>(0, &prepared_buffered_amount); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for BufferedAmountLowNotification + { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + BufferedAmountLowNotification::create(builder, &self.buffered_amount) + } + } + + #[derive(Copy, Clone)] + pub struct BufferedAmountLowNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> BufferedAmountLowNotificationRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct MessageNotification { + pub ppid: u32, + pub data: ::planus::alloc::vec::Vec, + } + + impl MessageNotification { + #[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::<6, 8>::new(builder); + + if prepared_ppid.is_some() { + table_writer.calculate_size::(2); + } + table_writer.calculate_size::<::planus::Offset<[u8]>>(4); + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_ppid) = prepared_ppid { + table_writer.write::<_, _, 4>(0, &prepared_ppid); + } + table_writer.write::<_, _, 4>(1, &prepared_data); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for MessageNotification { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + MessageNotification::create(builder, &self.ppid, &self.data) + } + } + + #[derive(Copy, Clone)] + pub struct MessageNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> MessageNotificationRef<'a> { + pub fn ppid(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "MessageNotification", "ppid")? + .unwrap_or(0), + ) + } + + pub fn data(&self) -> ::planus::Result<::planus::Vector<'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> { + 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; + 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, + ) + }) + } + } + } + pub mod sctp_parameters { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct NumSctpStreams { + pub os: u32, + pub mis: u32, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for NumSctpStreams { + fn default() -> Self { + Self { + os: 1024, + mis: 1024, + } + } + } + + impl NumSctpStreams { + #[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::<6, 8>::new(builder); + + if prepared_os.is_some() { + table_writer.calculate_size::(2); + } + if prepared_mis.is_some() { + table_writer.calculate_size::(4); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_os) = prepared_os { + table_writer.write::<_, _, 4>(0, &prepared_os); + } + if let ::core::option::Option::Some(prepared_mis) = prepared_mis { + table_writer.write::<_, _, 4>(1, &prepared_mis); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for NumSctpStreams { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + NumSctpStreams::create(builder, &self.os, &self.mis) + } + } + + #[derive(Copy, Clone)] + pub struct NumSctpStreamsRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> NumSctpStreamsRef<'a> { + pub fn os(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(0, "NumSctpStreams", "os")?.unwrap_or(1024), + ) + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct SctpParameters { + pub port: u16, + pub os: u16, + pub mis: u16, + pub max_message_size: u32, + pub send_buffer_size: u32, + pub sctp_buffered_amount: u32, + 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 { + #[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::<16, 19>::new(builder); + + if prepared_port.is_some() { + table_writer.calculate_size::(2); + } + if prepared_os.is_some() { + table_writer.calculate_size::(4); + } + if prepared_mis.is_some() { + table_writer.calculate_size::(6); + } + if prepared_max_message_size.is_some() { + table_writer.calculate_size::(8); + } + if prepared_send_buffer_size.is_some() { + table_writer.calculate_size::(10); + } + if prepared_sctp_buffered_amount.is_some() { + table_writer.calculate_size::(12); + } + if prepared_is_data_channel.is_some() { + table_writer.calculate_size::(14); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_max_message_size) = + prepared_max_message_size + { + table_writer.write::<_, _, 4>(3, &prepared_max_message_size); + } + if let ::core::option::Option::Some(prepared_send_buffer_size) = + prepared_send_buffer_size + { + table_writer.write::<_, _, 4>(4, &prepared_send_buffer_size); + } + if let ::core::option::Option::Some(prepared_sctp_buffered_amount) = + prepared_sctp_buffered_amount + { + table_writer.write::<_, _, 4>(5, &prepared_sctp_buffered_amount); + } + if let ::core::option::Option::Some(prepared_port) = prepared_port { + table_writer.write::<_, _, 2>(0, &prepared_port); + } + if let ::core::option::Option::Some(prepared_os) = prepared_os { + table_writer.write::<_, _, 2>(1, &prepared_os); + } + if let ::core::option::Option::Some(prepared_mis) = prepared_mis { + table_writer.write::<_, _, 2>(2, &prepared_mis); + } + if let ::core::option::Option::Some(prepared_is_data_channel) = + prepared_is_data_channel + { + table_writer.write::<_, _, 1>(6, &prepared_is_data_channel); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for SctpParameters { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct SctpParametersRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SctpParametersRef<'a> { + pub fn port(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(0, "SctpParameters", "port")?.unwrap_or(5000), + ) + } + + pub fn os(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(1, "SctpParameters", "os")?.unwrap_or(0), + ) + } + + pub fn mis(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(2, "SctpParameters", "mis")?.unwrap_or(0), + ) + } + + pub fn max_message_size(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(3, "SctpParameters", "max_message_size")? + .unwrap_or(0), + ) + } + + pub fn send_buffer_size(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(4, "SctpParameters", "send_buffer_size")? + .unwrap_or(0), + ) + } + + pub fn sctp_buffered_amount(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(5, "SctpParameters", "sctp_buffered_amount")? + .unwrap_or(0), + ) + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct SctpStreamParameters { + pub stream_id: u16, + pub ordered: ::core::option::Option, + pub max_packet_life_time: ::core::option::Option, + 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 { + #[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::<10, 7>::new(builder); + + if prepared_stream_id.is_some() { + table_writer.calculate_size::(2); + } + if prepared_ordered.is_some() { + table_writer.calculate_size::(4); + } + if prepared_max_packet_life_time.is_some() { + table_writer.calculate_size::(6); + } + if prepared_max_retransmits.is_some() { + table_writer.calculate_size::(8); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_stream_id) = prepared_stream_id + { + table_writer.write::<_, _, 2>(0, &prepared_stream_id); + } + if let ::core::option::Option::Some(prepared_max_packet_life_time) = + prepared_max_packet_life_time + { + table_writer.write::<_, _, 2>(2, &prepared_max_packet_life_time); + } + if let ::core::option::Option::Some(prepared_max_retransmits) = + prepared_max_retransmits + { + table_writer.write::<_, _, 2>(3, &prepared_max_retransmits); + } + if let ::core::option::Option::Some(prepared_ordered) = prepared_ordered { + table_writer.write::<_, _, 1>(1, &prepared_ordered); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for SctpStreamParameters { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct SctpStreamParametersRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SctpStreamParametersRef<'a> { + pub fn stream_id(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "SctpStreamParameters", "stream_id")? + .unwrap_or(0), + ) + } + + pub fn ordered(&self) -> ::planus::Result<::core::option::Option> { + self.0.access(1, "SctpStreamParameters", "ordered") + } + + pub fn max_packet_life_time( + &self, + ) -> ::planus::Result<::core::option::Option> { + self.0 + .access(2, "SctpStreamParameters", "max_packet_life_time") + } + + 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> { + 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; + 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, + ) + }) + } + } + } + pub mod data_producer { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct DumpResponse { + pub id: ::planus::alloc::string::String, + pub type_: ::planus::alloc::string::String, + pub sctp_stream_parameters: ::core::option::Option< + ::planus::alloc::boxed::Box, + >, + pub label: ::planus::alloc::string::String, + pub protocol: ::planus::alloc::string::String, + } + + impl DumpResponse { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_id: impl ::planus::WriteAs<::planus::Offset>, + field_type_: impl ::planus::WriteAs<::planus::Offset>, + field_sctp_stream_parameters: impl ::planus::WriteAsOptional< + ::planus::Offset, + >, + field_label: impl ::planus::WriteAs<::planus::Offset>, + field_protocol: impl ::planus::WriteAs<::planus::Offset>, + ) -> ::planus::Offset { + let prepared_id = field_id.prepare(builder); + + let prepared_type_ = field_type_.prepare(builder); + + 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 mut table_writer = + ::planus::table_writer::TableWriter::<12, 20>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + if prepared_sctp_stream_parameters.is_some() { + table_writer.calculate_size::<::planus::Offset>(6); + } + table_writer.calculate_size::<::planus::Offset>(8); + table_writer.calculate_size::<::planus::Offset>(10); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_id); + table_writer.write::<_, _, 4>(1, &prepared_type_); + if let ::core::option::Option::Some(prepared_sctp_stream_parameters) = + prepared_sctp_stream_parameters + { + table_writer.write::<_, _, 4>(2, &prepared_sctp_stream_parameters); + } + table_writer.write::<_, _, 4>(3, &prepared_label); + table_writer.write::<_, _, 4>(4, &prepared_protocol); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + DumpResponse::create( + builder, + &self.id, + &self.type_, + &self.sctp_stream_parameters, + &self.label, + &self.protocol, + ) + } + } + + #[derive(Copy, Clone)] + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DumpResponseRef<'a> { + pub fn id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "DumpResponse", "id") + } + + pub fn type_(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(1, "DumpResponse", "type_") + } + + pub fn sctp_stream_parameters( + &self, + ) -> ::planus::Result< + ::core::option::Option>, + > { + self.0.access(2, "DumpResponse", "sctp_stream_parameters") + } + + pub fn label(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(3, "DumpResponse", "label") + } + + pub fn protocol(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(4, "DumpResponse", "protocol") + } + } + + 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.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()?)?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct GetStatsResponse { + pub timestamp: u64, + pub label: ::planus::alloc::string::String, + pub protocol: ::planus::alloc::string::String, + pub messages_received: u64, + pub bytes_received: u64, + pub buffered_amount: u32, + } + + impl GetStatsResponse { + #[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::<14, 36>::new(builder); + + if prepared_timestamp.is_some() { + table_writer.calculate_size::(2); + } + table_writer.calculate_size::<::planus::Offset>(4); + table_writer.calculate_size::<::planus::Offset>(6); + if prepared_messages_received.is_some() { + table_writer.calculate_size::(8); + } + if prepared_bytes_received.is_some() { + table_writer.calculate_size::(10); + } + if prepared_buffered_amount.is_some() { + table_writer.calculate_size::(12); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_timestamp) = prepared_timestamp + { + table_writer.write::<_, _, 8>(0, &prepared_timestamp); + } + if let ::core::option::Option::Some(prepared_messages_received) = + prepared_messages_received + { + table_writer.write::<_, _, 8>(3, &prepared_messages_received); + } + if let ::core::option::Option::Some(prepared_bytes_received) = + prepared_bytes_received + { + table_writer.write::<_, _, 8>(4, &prepared_bytes_received); + } + table_writer.write::<_, _, 4>(1, &prepared_label); + table_writer.write::<_, _, 4>(2, &prepared_protocol); + if let ::core::option::Option::Some(prepared_buffered_amount) = + prepared_buffered_amount + { + table_writer.write::<_, _, 4>(5, &prepared_buffered_amount); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> GetStatsResponseRef<'a> { + pub fn timestamp(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "GetStatsResponse", "timestamp")? + .unwrap_or(0), + ) + } + + pub fn label(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(1, "GetStatsResponse", "label") + } + + pub fn protocol(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(2, "GetStatsResponse", "protocol") + } + + pub fn messages_received(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(3, "GetStatsResponse", "messages_received")? + .unwrap_or(0), + ) + } + + pub fn bytes_received(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(4, "GetStatsResponse", "bytes_received")? + .unwrap_or(0), + ) + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct String { + pub value: ::planus::alloc::string::String, + } + + impl String { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_value); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for String { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + String::create(builder, &self.value) + } + } + + #[derive(Copy, Clone)] + pub struct StringRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> StringRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Binary { + pub value: ::planus::alloc::vec::Vec, + } + + impl Binary { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_value: impl ::planus::WriteAs<::planus::Offset<[u8]>>, + ) -> ::planus::Offset { + let prepared_value = field_value.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset<[u8]>>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_value); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Binary { + type Prepared = ::planus::Offset; + + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) + } + } + + impl ::planus::WriteAsOptional<::planus::Offset> for Binary { + type Prepared = ::planus::Offset; + + 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 Binary { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Binary::create(builder, &self.value) + } + } + + #[derive(Copy, Clone)] + pub struct BinaryRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> BinaryRef<'a> { + pub fn value(&self) -> ::planus::Result<::planus::Vector<'a, u8>> { + self.0.access_required(0, "Binary", "value") + } + } + + impl<'a> ::core::fmt::Debug for BinaryRef<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut f = f.debug_struct("BinaryRef"); + f.field("value", &self.value()); + f.finish() + } + } + + impl<'a> ::core::convert::TryFrom> for Binary { + type Error = ::planus::Error; + + #[allow(unreachable_code)] + fn try_from(value: BinaryRef<'a>) -> ::planus::Result { + ::core::result::Result::Ok(Self { + value: value.value()?.to_vec()?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for BinaryRef<'a> { + 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 BinaryRef<'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( + "[BinaryRef]", + "get", + buffer.offset_from_start, + ) + }) + } + } + + impl ::planus::VectorWrite<::planus::Offset> for Binary { + type Value = ::planus::Offset; + const STRIDE: usize = 4; + 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 BinaryRef<'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("[BinaryRef]", "read_as_root", 0) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub enum Data { + String(::planus::alloc::boxed::Box), + Binary(::planus::alloc::boxed::Box), + } + + impl Data { + pub fn create_string( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + } + + pub fn create_binary( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + } + } + + impl ::planus::WriteAsUnion for Data { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + match self { + Self::String(value) => Self::create_string(builder, value), + Self::Binary(value) => Self::create_binary(builder, value), + } + } + } + + impl ::planus::WriteAsOptionalUnion for Data { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + } + } + + #[derive(Copy, Clone, Debug)] + pub enum DataRef<'a> { + String(self::StringRef<'a>), + Binary(self::BinaryRef<'a>), + } + + impl<'a> ::core::convert::TryFrom> for Data { + type Error = ::planus::Error; + + fn try_from(value: DataRef<'a>) -> ::planus::Result { + ::core::result::Result::Ok(match value { + DataRef::String(value) => Data::String(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )), + + DataRef::Binary(value) => Data::Binary(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )), + }) + } + } + + impl<'a> ::planus::TableReadUnion<'a> for DataRef<'a> { + fn from_buffer( + buffer: ::planus::SliceWithStartOffset<'a>, + field_offset: usize, + tag: u8, + ) -> ::core::result::Result { + match tag { + 1 => ::core::result::Result::Ok(Self::String( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 2 => ::core::result::Result::Ok(Self::Binary( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + _ => ::core::result::Result::Err( + ::planus::errors::ErrorKind::UnknownUnionTag { tag }, + ), + } + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct SendNotification { + pub ppid: u8, + pub data: self::Data, + } + + impl SendNotification { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_ppid: impl ::planus::WriteAsDefault, + field_data: impl ::planus::WriteAsUnion, + ) -> ::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::<6, 6>::new(builder); + + if prepared_ppid.is_some() { + table_writer.calculate_size::(2); + } + table_writer.calculate_size::(4); + table_writer.calculate_size::<::planus::Offset>(6); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(2, &prepared_data.offset()); + if let ::core::option::Option::Some(prepared_ppid) = prepared_ppid { + table_writer.write::<_, _, 1>(0, &prepared_ppid); + } + table_writer.write::<_, _, 1>(1, &prepared_data.tag()); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for SendNotification { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SendNotification::create(builder, &self.ppid, &self.data) + } + } + + #[derive(Copy, Clone)] + pub struct SendNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SendNotificationRef<'a> { + pub fn ppid(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(0, "SendNotification", "ppid")?.unwrap_or(0), + ) + } + + pub fn data(&self) -> ::planus::Result> { + self.0.access_union_required(1, "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("ppid", &self.ppid()); + 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 { + ppid: ::core::convert::TryInto::try_into(value.ppid()?)?, + data: ::core::convert::TryInto::try_into(value.data()?)?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for SendNotificationRef<'a> { + 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; + 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) + }) + } + } + } + pub mod direct_transport { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct 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 { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_base); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for DirectTransportOptions { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + DirectTransportOptions::create(builder, &self.base) + } + } + + #[derive(Copy, Clone)] + pub struct DirectTransportOptionsRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DirectTransportOptionsRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct DumpResponse { + pub base: ::planus::alloc::boxed::Box, + } + + impl DumpResponse { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_base); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + DumpResponse::create(builder, &self.base) + } + } + + #[derive(Copy, Clone)] + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DumpResponseRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct GetStatsResponse { + pub base: ::planus::alloc::boxed::Box, + } + + impl GetStatsResponse { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_base); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + GetStatsResponse::create(builder, &self.base) + } + } + + #[derive(Copy, Clone)] + pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> GetStatsResponseRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct RtcpNotification { + pub data: ::planus::alloc::vec::Vec, + } + + impl RtcpNotification { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset<[u8]>>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_data); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RtcpNotification { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + RtcpNotification::create(builder, &self.data) + } + } + + #[derive(Copy, Clone)] + pub struct RtcpNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RtcpNotificationRef<'a> { + pub fn data(&self) -> ::planus::Result<::planus::Vector<'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> { + 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; + 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) + }) + } + } + } + pub mod transport { + #[derive( + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + #[repr(u8)] + pub enum Protocol { + Udp = 1, + Tcp = 2, + } + + impl ::core::convert::TryFrom for Protocol { + type Error = ::planus::errors::UnknownEnumTagKind; + 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 { + 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 { + 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 = ::from_buffer(buffer, 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; + + 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, + ); + } + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ListenIp { + pub ip: ::planus::alloc::string::String, + pub announced_ip: ::core::option::Option<::planus::alloc::string::String>, + } + + impl ListenIp { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_ip: impl ::planus::WriteAs<::planus::Offset>, + field_announced_ip: impl ::planus::WriteAsOptional< + ::planus::Offset<::core::primitive::str>, + >, + ) -> ::planus::Offset { + let prepared_ip = field_ip.prepare(builder); + + let prepared_announced_ip = field_announced_ip.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_announced_ip.is_some() { + table_writer.calculate_size::<::planus::Offset>(4); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_ip); + if let ::core::option::Option::Some(prepared_announced_ip) = + prepared_announced_ip + { + table_writer.write::<_, _, 4>(1, &prepared_announced_ip); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ListenIp { + type Prepared = ::planus::Offset; + + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) + } + } + + impl ::planus::WriteAsOptional<::planus::Offset> for ListenIp { + type Prepared = ::planus::Offset; + + 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 ListenIp { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + ListenIp::create(builder, &self.ip, &self.announced_ip) + } + } + + #[derive(Copy, Clone)] + pub struct ListenIpRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ListenIpRef<'a> { + pub fn ip(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "ListenIp", "ip") + } + + pub fn announced_ip( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(1, "ListenIp", "announced_ip") + } + } + + impl<'a> ::core::fmt::Debug for ListenIpRef<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + let mut f = f.debug_struct("ListenIpRef"); + 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.finish() + } + } + + impl<'a> ::core::convert::TryFrom> for ListenIp { + type Error = ::planus::Error; + + #[allow(unreachable_code)] + fn try_from(value: ListenIpRef<'a>) -> ::planus::Result { + ::core::result::Result::Ok(Self { + 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 + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for ListenIpRef<'a> { + 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 ListenIpRef<'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( + "[ListenIpRef]", + "get", + buffer.offset_from_start, + ) + }) + } + } + + impl ::planus::VectorWrite<::planus::Offset> for ListenIp { + type Value = ::planus::Offset; + const STRIDE: usize = 4; + 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 ListenIpRef<'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("[ListenIpRef]", "read_as_root", 0) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct RestartIceResponse { + pub username_fragment: ::planus::alloc::string::String, + pub password: ::planus::alloc::string::String, + pub ice_lite: bool, + } + + impl RestartIceResponse { + #[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::<8, 9>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + if prepared_ice_lite.is_some() { + table_writer.calculate_size::(6); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_username_fragment); + table_writer.write::<_, _, 4>(1, &prepared_password); + if let ::core::option::Option::Some(prepared_ice_lite) = prepared_ice_lite { + table_writer.write::<_, _, 1>(2, &prepared_ice_lite); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RestartIceResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + RestartIceResponse::create( + builder, + &self.username_fragment, + &self.password, + &self.ice_lite, + ) + } + } + + #[derive(Copy, Clone)] + pub struct RestartIceResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RestartIceResponseRef<'a> { + pub fn username_fragment(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(0, "RestartIceResponse", "username_fragment") + } + + pub fn password(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(1, "RestartIceResponse", "password") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct ConsumeRequest { + pub consumer_id: ::planus::alloc::string::String, + pub producer_id: ::planus::alloc::string::String, + pub kind: super::rtp_parameters::MediaKind, + pub rtp_parameters: + ::planus::alloc::boxed::Box, + pub type_: super::rtp_parameters::Type, + pub consumable_rtp_encodings: + ::planus::alloc::vec::Vec, + pub paused: bool, + pub preferred_layers: ::core::option::Option< + ::planus::alloc::boxed::Box, + >, + pub ignore_dtx: bool, + } + + impl ConsumeRequest { + #[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::All); + + let prepared_rtp_parameters = field_rtp_parameters.prepare(builder); + + let prepared_type_ = + field_type_.prepare(builder, &super::rtp_parameters::Type::None); + + 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::<20, 24>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + if prepared_kind.is_some() { + table_writer.calculate_size::(6); + } + table_writer + .calculate_size::<::planus::Offset>( + 8, + ); + if prepared_type_.is_some() { + table_writer.calculate_size::(10); + } + table_writer.calculate_size::<::planus::Offset< + [::planus::Offset], + >>(12); + if prepared_paused.is_some() { + table_writer.calculate_size::(14); + } + if prepared_preferred_layers.is_some() { + table_writer + .calculate_size::<::planus::Offset>( + 16, + ); + } + if prepared_ignore_dtx.is_some() { + table_writer.calculate_size::(18); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_consumer_id); + table_writer.write::<_, _, 4>(1, &prepared_producer_id); + table_writer.write::<_, _, 4>(3, &prepared_rtp_parameters); + table_writer.write::<_, _, 4>(5, &prepared_consumable_rtp_encodings); + if let ::core::option::Option::Some(prepared_preferred_layers) = + prepared_preferred_layers + { + table_writer.write::<_, _, 4>(7, &prepared_preferred_layers); + } + if let ::core::option::Option::Some(prepared_kind) = prepared_kind { + table_writer.write::<_, _, 1>(2, &prepared_kind); + } + if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { + table_writer.write::<_, _, 1>(4, &prepared_type_); + } + if let ::core::option::Option::Some(prepared_paused) = prepared_paused { + table_writer.write::<_, _, 1>(6, &prepared_paused); + } + if let ::core::option::Option::Some(prepared_ignore_dtx) = + prepared_ignore_dtx + { + table_writer.write::<_, _, 1>(8, &prepared_ignore_dtx); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ConsumeRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct ConsumeRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ConsumeRequestRef<'a> { + pub fn consumer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "ConsumeRequest", "consumer_id") + } + + pub fn producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(1, "ConsumeRequest", "producer_id") + } + + pub fn kind(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "ConsumeRequest", "kind")? + .unwrap_or(super::rtp_parameters::MediaKind::All), + ) + } + + pub fn rtp_parameters( + &self, + ) -> ::planus::Result> { + self.0 + .access_required(3, "ConsumeRequest", "rtp_parameters") + } + + pub fn type_(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(4, "ConsumeRequest", "type_")? + .unwrap_or(super::rtp_parameters::Type::None), + ) + } + + pub fn consumable_rtp_encodings( + &self, + ) -> ::planus::Result< + ::planus::Vector< + 'a, + ::planus::Result>, + >, + > { + self.0 + .access_required(5, "ConsumeRequest", "consumable_rtp_encodings") + } + + pub fn paused(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(6, "ConsumeRequest", "paused")? + .unwrap_or(false), + ) + } + + pub fn preferred_layers( + &self, + ) -> ::planus::Result<::core::option::Option>> + { + self.0.access(7, "ConsumeRequest", "preferred_layers") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ConsumeResponse { + pub paused: bool, + pub producer_paused: bool, + pub score: ::core::option::Option< + ::planus::alloc::boxed::Box, + >, + pub preferred_layers: ::core::option::Option< + ::planus::alloc::boxed::Box, + >, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for ConsumeResponse { + fn default() -> Self { + Self { + paused: false, + producer_paused: false, + score: ::core::default::Default::default(), + preferred_layers: ::core::default::Default::default(), + } + } + } + + impl ConsumeResponse { + #[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::WriteAsOptional< + ::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::<10, 10>::new(builder); + + if prepared_paused.is_some() { + table_writer.calculate_size::(2); + } + if prepared_producer_paused.is_some() { + table_writer.calculate_size::(4); + } + if prepared_score.is_some() { + table_writer + .calculate_size::<::planus::Offset>(6); + } + if prepared_preferred_layers.is_some() { + table_writer + .calculate_size::<::planus::Offset>(8); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_score) = prepared_score { + table_writer.write::<_, _, 4>(2, &prepared_score); + } + if let ::core::option::Option::Some(prepared_preferred_layers) = + prepared_preferred_layers + { + table_writer.write::<_, _, 4>(3, &prepared_preferred_layers); + } + if let ::core::option::Option::Some(prepared_paused) = prepared_paused { + table_writer.write::<_, _, 1>(0, &prepared_paused); + } + if let ::core::option::Option::Some(prepared_producer_paused) = + prepared_producer_paused + { + table_writer.write::<_, _, 1>(1, &prepared_producer_paused); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ConsumeResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ConsumeResponse::create( + builder, + &self.paused, + &self.producer_paused, + &self.score, + &self.preferred_layers, + ) + } + } + + #[derive(Copy, Clone)] + pub struct ConsumeResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ConsumeResponseRef<'a> { + pub fn paused(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "ConsumeResponse", "paused")? + .unwrap_or(false), + ) + } + + pub fn producer_paused(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "ConsumeResponse", "producer_paused")? + .unwrap_or(false), + ) + } + + pub fn score( + &self, + ) -> ::planus::Result<::core::option::Option>> + { + self.0.access(2, "ConsumeResponse", "score") + } + + 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()); + if let ::core::option::Option::Some(field_score) = self.score().transpose() { + f.field("score", &field_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: if let ::core::option::Option::Some(score) = value.score()? { + ::core::option::Option::Some(::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(score)?, + )) + } else { + ::core::option::Option::None + }, + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct ProduceRequest { + pub producer_id: ::planus::alloc::string::String, + pub kind: super::rtp_parameters::MediaKind, + pub rtp_parameters: + ::planus::alloc::boxed::Box, + pub rtp_mapping: ::planus::alloc::boxed::Box, + pub key_frame_request_delay: u16, + pub paused: bool, + } + + impl ProduceRequest { + #[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::All); + + 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::<14, 16>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_kind.is_some() { + table_writer.calculate_size::(4); + } + table_writer + .calculate_size::<::planus::Offset>( + 6, + ); + table_writer + .calculate_size::<::planus::Offset>(8); + if prepared_key_frame_request_delay.is_some() { + table_writer.calculate_size::(10); + } + if prepared_paused.is_some() { + table_writer.calculate_size::(12); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_producer_id); + table_writer.write::<_, _, 4>(2, &prepared_rtp_parameters); + table_writer.write::<_, _, 4>(3, &prepared_rtp_mapping); + if let ::core::option::Option::Some(prepared_key_frame_request_delay) = + prepared_key_frame_request_delay + { + table_writer.write::<_, _, 2>(4, &prepared_key_frame_request_delay); + } + if let ::core::option::Option::Some(prepared_kind) = prepared_kind { + table_writer.write::<_, _, 1>(1, &prepared_kind); + } + if let ::core::option::Option::Some(prepared_paused) = prepared_paused { + table_writer.write::<_, _, 1>(5, &prepared_paused); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ProduceRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct ProduceRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ProduceRequestRef<'a> { + pub fn producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "ProduceRequest", "producer_id") + } + + pub fn kind(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "ProduceRequest", "kind")? + .unwrap_or(super::rtp_parameters::MediaKind::All), + ) + } + + pub fn rtp_parameters( + &self, + ) -> ::planus::Result> { + self.0 + .access_required(2, "ProduceRequest", "rtp_parameters") + } + + pub fn rtp_mapping( + &self, + ) -> ::planus::Result> { + self.0.access_required(3, "ProduceRequest", "rtp_mapping") + } + + 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), + ) + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct 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::None, + } + } + } + + impl ProduceResponse { + #[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::None); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 1>::new(builder); + + if prepared_type_.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { + table_writer.write::<_, _, 1>(0, &prepared_type_); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ProduceResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ProduceResponse::create(builder, &self.type_) + } + } + + #[derive(Copy, Clone)] + pub struct ProduceResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ProduceResponseRef<'a> { + pub fn type_(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "ProduceResponse", "type_")? + .unwrap_or(super::rtp_parameters::Type::None), + ) + } + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ProduceDataRequest { + pub data_producer_id: ::planus::alloc::string::String, + pub type_: ::planus::alloc::string::String, + pub sctp_stream_parameters: ::core::option::Option< + ::planus::alloc::boxed::Box, + >, + pub label: ::core::option::Option<::planus::alloc::string::String>, + pub protocol: ::core::option::Option<::planus::alloc::string::String>, + } + + impl ProduceDataRequest { + #[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::WriteAs<::planus::Offset>, + 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>, + >, + ) -> ::planus::Offset { + let prepared_data_producer_id = field_data_producer_id.prepare(builder); + + let prepared_type_ = field_type_.prepare(builder); + + 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 mut table_writer = + ::planus::table_writer::TableWriter::<12, 20>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + if prepared_sctp_stream_parameters.is_some() { + table_writer.calculate_size::<::planus::Offset>(6); + } + if prepared_label.is_some() { + table_writer.calculate_size::<::planus::Offset>(8); + } + if prepared_protocol.is_some() { + table_writer.calculate_size::<::planus::Offset>(10); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_data_producer_id); + table_writer.write::<_, _, 4>(1, &prepared_type_); + if let ::core::option::Option::Some(prepared_sctp_stream_parameters) = + prepared_sctp_stream_parameters + { + table_writer.write::<_, _, 4>(2, &prepared_sctp_stream_parameters); + } + if let ::core::option::Option::Some(prepared_label) = prepared_label { + table_writer.write::<_, _, 4>(3, &prepared_label); + } + if let ::core::option::Option::Some(prepared_protocol) = prepared_protocol { + table_writer.write::<_, _, 4>(4, &prepared_protocol); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ProduceDataRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct ProduceDataRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ProduceDataRequestRef<'a> { + pub fn data_producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(0, "ProduceDataRequest", "data_producer_id") + } + + pub fn type_(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(1, "ProduceDataRequest", "type_") + } + + pub fn sctp_stream_parameters( + &self, + ) -> ::planus::Result< + ::core::option::Option>, + > { + self.0 + .access(2, "ProduceDataRequest", "sctp_stream_parameters") + } + + pub fn label( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(3, "ProduceDataRequest", "label") + } + + pub fn protocol( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(4, "ProduceDataRequest", "protocol") + } + } + + 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.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 + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for ProduceDataRequestRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ConsumeDataRequest { + pub data_consumer_id: ::planus::alloc::string::String, + pub data_producer_id: ::planus::alloc::string::String, + pub type_: ::planus::alloc::string::String, + pub sctp_stream_parameters: ::core::option::Option< + ::planus::alloc::boxed::Box, + >, + pub label: ::core::option::Option<::planus::alloc::string::String>, + pub protocol: ::core::option::Option<::planus::alloc::string::String>, + } + + impl ConsumeDataRequest { + #[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::WriteAs<::planus::Offset>, + 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>, + >, + ) -> ::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); + + 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 mut table_writer = + ::planus::table_writer::TableWriter::<14, 24>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + table_writer.calculate_size::<::planus::Offset>(6); + if prepared_sctp_stream_parameters.is_some() { + table_writer.calculate_size::<::planus::Offset>(8); + } + if prepared_label.is_some() { + table_writer.calculate_size::<::planus::Offset>(10); + } + if prepared_protocol.is_some() { + table_writer.calculate_size::<::planus::Offset>(12); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_data_consumer_id); + table_writer.write::<_, _, 4>(1, &prepared_data_producer_id); + table_writer.write::<_, _, 4>(2, &prepared_type_); + if let ::core::option::Option::Some(prepared_sctp_stream_parameters) = + prepared_sctp_stream_parameters + { + table_writer.write::<_, _, 4>(3, &prepared_sctp_stream_parameters); + } + if let ::core::option::Option::Some(prepared_label) = prepared_label { + table_writer.write::<_, _, 4>(4, &prepared_label); + } + if let ::core::option::Option::Some(prepared_protocol) = prepared_protocol { + table_writer.write::<_, _, 4>(5, &prepared_protocol); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ConsumeDataRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct ConsumeDataRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ConsumeDataRequestRef<'a> { + pub fn data_consumer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(0, "ConsumeDataRequest", "data_consumer_id") + } + + pub fn data_producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(1, "ConsumeDataRequest", "data_producer_id") + } + + pub fn type_(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(2, "ConsumeDataRequest", "type_") + } + + pub fn sctp_stream_parameters( + &self, + ) -> ::planus::Result< + ::core::option::Option>, + > { + self.0 + .access(3, "ConsumeDataRequest", "sctp_stream_parameters") + } + + pub fn label( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(4, "ConsumeDataRequest", "label") + } + + pub fn protocol( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(5, "ConsumeDataRequest", "protocol") + } + } + + 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.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 + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for ConsumeDataRequestRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Tuple { + pub local_ip: ::planus::alloc::string::String, + pub local_port: u16, + pub remote_ip: ::planus::alloc::string::String, + pub remote_port: u16, + pub protocol: ::planus::alloc::string::String, + } + + impl Tuple { + #[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::WriteAs<::planus::Offset>, + field_remote_port: impl ::planus::WriteAsDefault, + field_protocol: impl ::planus::WriteAs<::planus::Offset>, + ) -> ::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); + + let mut table_writer = + ::planus::table_writer::TableWriter::<12, 16>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_local_port.is_some() { + table_writer.calculate_size::(4); + } + table_writer.calculate_size::<::planus::Offset>(6); + if prepared_remote_port.is_some() { + table_writer.calculate_size::(8); + } + table_writer.calculate_size::<::planus::Offset>(10); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_local_ip); + table_writer.write::<_, _, 4>(2, &prepared_remote_ip); + table_writer.write::<_, _, 4>(4, &prepared_protocol); + if let ::core::option::Option::Some(prepared_local_port) = + prepared_local_port + { + table_writer.write::<_, _, 2>(1, &prepared_local_port); + } + if let ::core::option::Option::Some(prepared_remote_port) = + prepared_remote_port + { + table_writer.write::<_, _, 2>(3, &prepared_remote_port); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Tuple { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct TupleRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> TupleRef<'a> { + pub fn local_ip(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "Tuple", "local_ip") + } + + pub fn local_port(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(1, "Tuple", "local_port")?.unwrap_or(0), + ) + } + + pub fn remote_ip(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(2, "Tuple", "remote_ip") + } + + pub fn remote_port(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(3, "Tuple", "remote_port")?.unwrap_or(0), + ) + } + + pub fn protocol(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(4, "Tuple", "protocol") + } + } + + 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()); + f.field("remote_ip", &self.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: ::core::convert::TryInto::try_into(value.remote_ip()?)?, + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct SrtpParameters { + pub crypto_suite: ::planus::alloc::string::String, + pub key_base64: ::planus::alloc::string::String, + } + + impl SrtpParameters { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_crypto_suite: impl ::planus::WriteAs<::planus::Offset>, + field_key_base64: impl ::planus::WriteAs<::planus::Offset>, + ) -> ::planus::Offset { + let prepared_crypto_suite = field_crypto_suite.prepare(builder); + + let prepared_key_base64 = field_key_base64.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_crypto_suite); + table_writer.write::<_, _, 4>(1, &prepared_key_base64); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for SrtpParameters { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SrtpParameters::create(builder, &self.crypto_suite, &self.key_base64) + } + } + + #[derive(Copy, Clone)] + pub struct SrtpParametersRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SrtpParametersRef<'a> { + pub fn crypto_suite(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "SrtpParameters", "crypto_suite") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct RtpListener { + pub ssrc_table: ::planus::alloc::vec::Vec, + pub mid_table: ::planus::alloc::vec::Vec, + pub rid_table: ::planus::alloc::vec::Vec, + } + + impl RtpListener { + #[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::<8, 12>::new(builder); + + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(6); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_ssrc_table); + table_writer.write::<_, _, 4>(1, &prepared_mid_table); + table_writer.write::<_, _, 4>(2, &prepared_rid_table); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RtpListener { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + RtpListener::create(builder, &self.ssrc_table, &self.mid_table, &self.rid_table) + } + } + + #[derive(Copy, Clone)] + pub struct RtpListenerRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RtpListenerRef<'a> { + pub fn ssrc_table( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result>>, + > { + self.0.access_required(0, "RtpListener", "ssrc_table") + } + + pub fn mid_table( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result>>, + > { + self.0.access_required(1, "RtpListener", "mid_table") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct SctpListener { + pub stream_id_table: ::planus::alloc::vec::Vec, + } + + impl SctpListener { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_stream_id_table); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for SctpListener { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SctpListener::create(builder, &self.stream_id_table) + } + } + + #[derive(Copy, Clone)] + pub struct SctpListenerRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SctpListenerRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Dump { + pub id: ::planus::alloc::string::String, + pub direct: bool, + pub producer_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + pub consumer_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + pub map_ssrc_consumer_id: ::planus::alloc::vec::Vec, + pub map_rtx_ssrc_consumer_id: + ::planus::alloc::vec::Vec, + pub data_producer_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + pub data_consumer_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + pub recv_rtp_header_extensions: + ::planus::alloc::vec::Vec, + pub rtp_listener: ::planus::alloc::boxed::Box, + pub max_message_size: u32, + pub sctp_parameters: ::core::option::Option< + ::planus::alloc::boxed::Box, + >, + pub sctp_state: ::core::option::Option<::planus::alloc::string::String>, + pub sctp_listener: + ::core::option::Option<::planus::alloc::boxed::Box>, + pub trace_event_types: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + } + + impl Dump { + #[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<[::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< + ::planus::Offset<::core::primitive::str>, + >, + field_sctp_listener: impl ::planus::WriteAsOptional< + ::planus::Offset, + >, + field_trace_event_types: impl ::planus::WriteAs< + ::planus::Offset<[::planus::Offset]>, + >, + ) -> ::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::<32, 57>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_direct.is_some() { + table_writer.calculate_size::(4); + } + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(6); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(8); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(10); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(12); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(14); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(16); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(18); + table_writer.calculate_size::<::planus::Offset>(20); + if prepared_max_message_size.is_some() { + table_writer.calculate_size::(22); + } + if prepared_sctp_parameters.is_some() { + table_writer.calculate_size::<::planus::Offset>(24); + } + if prepared_sctp_state.is_some() { + table_writer.calculate_size::<::planus::Offset>(26); + } + if prepared_sctp_listener.is_some() { + table_writer.calculate_size::<::planus::Offset>(28); + } + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(30); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_id); + table_writer.write::<_, _, 4>(2, &prepared_producer_ids); + table_writer.write::<_, _, 4>(3, &prepared_consumer_ids); + table_writer.write::<_, _, 4>(4, &prepared_map_ssrc_consumer_id); + table_writer.write::<_, _, 4>(5, &prepared_map_rtx_ssrc_consumer_id); + table_writer.write::<_, _, 4>(6, &prepared_data_producer_ids); + table_writer.write::<_, _, 4>(7, &prepared_data_consumer_ids); + table_writer.write::<_, _, 4>(8, &prepared_recv_rtp_header_extensions); + table_writer.write::<_, _, 4>(9, &prepared_rtp_listener); + if let ::core::option::Option::Some(prepared_max_message_size) = + prepared_max_message_size + { + table_writer.write::<_, _, 4>(10, &prepared_max_message_size); + } + if let ::core::option::Option::Some(prepared_sctp_parameters) = + prepared_sctp_parameters + { + table_writer.write::<_, _, 4>(11, &prepared_sctp_parameters); + } + if let ::core::option::Option::Some(prepared_sctp_state) = + prepared_sctp_state + { + table_writer.write::<_, _, 4>(12, &prepared_sctp_state); + } + if let ::core::option::Option::Some(prepared_sctp_listener) = + prepared_sctp_listener + { + table_writer.write::<_, _, 4>(13, &prepared_sctp_listener); + } + table_writer.write::<_, _, 4>(14, &prepared_trace_event_types); + if let ::core::option::Option::Some(prepared_direct) = prepared_direct { + table_writer.write::<_, _, 1>(1, &prepared_direct); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Dump { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct DumpRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DumpRef<'a> { + pub fn id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "Dump", "id") + } + + pub fn direct(&self) -> ::planus::Result { + ::core::result::Result::Ok(self.0.access(1, "Dump", "direct")?.unwrap_or(false)) + } + + pub fn producer_ids( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + > { + self.0.access_required(2, "Dump", "producer_ids") + } + + pub fn consumer_ids( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + > { + self.0.access_required(3, "Dump", "consumer_ids") + } + + pub fn map_ssrc_consumer_id( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result>>, + > { + self.0.access_required(4, "Dump", "map_ssrc_consumer_id") + } + + 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") + } + + 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") + } + + 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") + } + + pub fn recv_rtp_header_extensions( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result>>, + > { + self.0 + .access_required(8, "Dump", "recv_rtp_header_extensions") + } + + pub fn rtp_listener(&self) -> ::planus::Result> { + self.0.access_required(9, "Dump", "rtp_listener") + } + + pub fn max_message_size(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(10, "Dump", "max_message_size")?.unwrap_or(0), + ) + } + + pub fn sctp_parameters( + &self, + ) -> ::planus::Result< + ::core::option::Option>, + > { + self.0.access(11, "Dump", "sctp_parameters") + } + + pub fn sctp_state( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(12, "Dump", "sctp_state") + } + + pub fn sctp_listener( + &self, + ) -> ::planus::Result<::core::option::Option>> + { + self.0.access(13, "Dump", "sctp_listener") + } + + pub fn trace_event_types( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + > { + 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: value + .recv_rtp_header_extensions()? + .to_vec_result()?, + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Options { + pub direct: bool, + pub max_message_size: u32, + pub initial_available_outgoing_bitrate: u32, + pub enable_sctp: bool, + pub num_sctp_streams: ::core::option::Option< + ::planus::alloc::boxed::Box, + >, + pub max_sctp_message_size: u32, + pub sctp_send_buffer_size: u32, + pub is_data_channel: bool, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for Options { + fn default() -> Self { + Self { + direct: false, + max_message_size: 0, + initial_available_outgoing_bitrate: 0, + 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 { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_direct: impl ::planus::WriteAsDefault, + field_max_message_size: impl ::planus::WriteAsDefault, + field_initial_available_outgoing_bitrate: impl ::planus::WriteAsDefault, + 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, &0); + + let prepared_initial_available_outgoing_bitrate = + field_initial_available_outgoing_bitrate.prepare(builder, &0); + + 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::<18, 23>::new(builder); + + if prepared_direct.is_some() { + table_writer.calculate_size::(2); + } + if prepared_max_message_size.is_some() { + table_writer.calculate_size::(4); + } + if prepared_initial_available_outgoing_bitrate.is_some() { + table_writer.calculate_size::(6); + } + if prepared_enable_sctp.is_some() { + table_writer.calculate_size::(8); + } + if prepared_num_sctp_streams.is_some() { + table_writer.calculate_size::<::planus::Offset>(10); + } + if prepared_max_sctp_message_size.is_some() { + table_writer.calculate_size::(12); + } + if prepared_sctp_send_buffer_size.is_some() { + table_writer.calculate_size::(14); + } + if prepared_is_data_channel.is_some() { + table_writer.calculate_size::(16); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_max_message_size) = + prepared_max_message_size + { + table_writer.write::<_, _, 4>(1, &prepared_max_message_size); + } + if let ::core::option::Option::Some( + prepared_initial_available_outgoing_bitrate, + ) = prepared_initial_available_outgoing_bitrate + { + table_writer + .write::<_, _, 4>(2, &prepared_initial_available_outgoing_bitrate); + } + if let ::core::option::Option::Some(prepared_num_sctp_streams) = + prepared_num_sctp_streams + { + table_writer.write::<_, _, 4>(4, &prepared_num_sctp_streams); + } + if let ::core::option::Option::Some(prepared_max_sctp_message_size) = + prepared_max_sctp_message_size + { + table_writer.write::<_, _, 4>(5, &prepared_max_sctp_message_size); + } + if let ::core::option::Option::Some(prepared_sctp_send_buffer_size) = + prepared_sctp_send_buffer_size + { + table_writer.write::<_, _, 4>(6, &prepared_sctp_send_buffer_size); + } + if let ::core::option::Option::Some(prepared_direct) = prepared_direct { + table_writer.write::<_, _, 1>(0, &prepared_direct); + } + if let ::core::option::Option::Some(prepared_enable_sctp) = + prepared_enable_sctp + { + table_writer.write::<_, _, 1>(3, &prepared_enable_sctp); + } + if let ::core::option::Option::Some(prepared_is_data_channel) = + prepared_is_data_channel + { + table_writer.write::<_, _, 1>(7, &prepared_is_data_channel); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Options { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct OptionsRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> OptionsRef<'a> { + pub fn direct(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(0, "Options", "direct")?.unwrap_or(false), + ) + } + + pub fn max_message_size(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "Options", "max_message_size")? + .unwrap_or(0), + ) + } + + pub fn initial_available_outgoing_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "Options", "initial_available_outgoing_bitrate")? + .unwrap_or(0), + ) + } + + pub fn enable_sctp(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(3, "Options", "enable_sctp")?.unwrap_or(false), + ) + } + + pub fn num_sctp_streams( + &self, + ) -> ::planus::Result< + ::core::option::Option>, + > { + self.0.access(4, "Options", "num_sctp_streams") + } + + 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), + ) + } + + 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), + ) + } + + 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()); + f.field("max_message_size", &self.max_message_size()); + f.field( + "initial_available_outgoing_bitrate", + &self.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: ::core::convert::TryInto::try_into( + value.max_message_size()?, + )?, + initial_available_outgoing_bitrate: ::core::convert::TryInto::try_into( + value.initial_available_outgoing_bitrate()?, + )?, + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Stats { + pub transport_id: ::planus::alloc::string::String, + pub timestamp: u64, + pub sctp_state: ::core::option::Option<::planus::alloc::string::String>, + pub bytes_received: u64, + pub recv_bitrate: u64, + pub bytes_sent: u64, + pub send_bitrate: u64, + pub rtp_bytes_received: u64, + pub rtp_recv_bitrate: u64, + pub rtp_bytes_sent: u64, + pub rtp_send_bitrate: u64, + pub rtx_bytes_received: u64, + pub rtx_recv_bitrate: u64, + pub rtx_bytes_sent: u64, + pub rtx_send_bitrate: u64, + pub probation_bytes_sent: u64, + pub probation_send_bitrate: u64, + pub available_outgoing_bitrate: u64, + pub available_incoming_bitrate: u64, + pub max_incoming_bitrate: u64, + pub max_outgoing_bitrate: u64, + pub min_outgoing_bitrate: u64, + pub rtp_packet_loss_received: u64, + pub rtp_packet_loss_sent: u64, + } + + impl Stats { + #[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< + ::planus::Offset<::core::primitive::str>, + >, + 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::WriteAsDefault, + field_available_incoming_bitrate: impl ::planus::WriteAsDefault, + field_max_incoming_bitrate: impl ::planus::WriteAsDefault, + field_max_outgoing_bitrate: impl ::planus::WriteAsDefault, + field_min_outgoing_bitrate: impl ::planus::WriteAsDefault, + field_rtp_packet_loss_received: impl ::planus::WriteAsDefault, + field_rtp_packet_loss_sent: impl ::planus::WriteAsDefault, + ) -> ::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, &0); + + let prepared_available_incoming_bitrate = + field_available_incoming_bitrate.prepare(builder, &0); + + let prepared_max_incoming_bitrate = + field_max_incoming_bitrate.prepare(builder, &0); + + let prepared_max_outgoing_bitrate = + field_max_outgoing_bitrate.prepare(builder, &0); + + let prepared_min_outgoing_bitrate = + field_min_outgoing_bitrate.prepare(builder, &0); + + let prepared_rtp_packet_loss_received = + field_rtp_packet_loss_received.prepare(builder, &0); + + let prepared_rtp_packet_loss_sent = + field_rtp_packet_loss_sent.prepare(builder, &0); + + let mut table_writer = + ::planus::table_writer::TableWriter::<50, 184>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_timestamp.is_some() { + table_writer.calculate_size::(4); + } + if prepared_sctp_state.is_some() { + table_writer.calculate_size::<::planus::Offset>(6); + } + if prepared_bytes_received.is_some() { + table_writer.calculate_size::(8); + } + if prepared_recv_bitrate.is_some() { + table_writer.calculate_size::(10); + } + if prepared_bytes_sent.is_some() { + table_writer.calculate_size::(12); + } + if prepared_send_bitrate.is_some() { + table_writer.calculate_size::(14); + } + if prepared_rtp_bytes_received.is_some() { + table_writer.calculate_size::(16); + } + if prepared_rtp_recv_bitrate.is_some() { + table_writer.calculate_size::(18); + } + if prepared_rtp_bytes_sent.is_some() { + table_writer.calculate_size::(20); + } + if prepared_rtp_send_bitrate.is_some() { + table_writer.calculate_size::(22); + } + if prepared_rtx_bytes_received.is_some() { + table_writer.calculate_size::(24); + } + if prepared_rtx_recv_bitrate.is_some() { + table_writer.calculate_size::(26); + } + if prepared_rtx_bytes_sent.is_some() { + table_writer.calculate_size::(28); + } + if prepared_rtx_send_bitrate.is_some() { + table_writer.calculate_size::(30); + } + if prepared_probation_bytes_sent.is_some() { + table_writer.calculate_size::(32); + } + if prepared_probation_send_bitrate.is_some() { + table_writer.calculate_size::(34); + } + if prepared_available_outgoing_bitrate.is_some() { + table_writer.calculate_size::(36); + } + if prepared_available_incoming_bitrate.is_some() { + table_writer.calculate_size::(38); + } + if prepared_max_incoming_bitrate.is_some() { + table_writer.calculate_size::(40); + } + if prepared_max_outgoing_bitrate.is_some() { + table_writer.calculate_size::(42); + } + if prepared_min_outgoing_bitrate.is_some() { + table_writer.calculate_size::(44); + } + if prepared_rtp_packet_loss_received.is_some() { + table_writer.calculate_size::(46); + } + if prepared_rtp_packet_loss_sent.is_some() { + table_writer.calculate_size::(48); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_timestamp) = prepared_timestamp + { + table_writer.write::<_, _, 8>(1, &prepared_timestamp); + } + if let ::core::option::Option::Some(prepared_bytes_received) = + prepared_bytes_received + { + table_writer.write::<_, _, 8>(3, &prepared_bytes_received); + } + if let ::core::option::Option::Some(prepared_recv_bitrate) = + prepared_recv_bitrate + { + table_writer.write::<_, _, 8>(4, &prepared_recv_bitrate); + } + if let ::core::option::Option::Some(prepared_bytes_sent) = + prepared_bytes_sent + { + table_writer.write::<_, _, 8>(5, &prepared_bytes_sent); + } + if let ::core::option::Option::Some(prepared_send_bitrate) = + prepared_send_bitrate + { + table_writer.write::<_, _, 8>(6, &prepared_send_bitrate); + } + if let ::core::option::Option::Some(prepared_rtp_bytes_received) = + prepared_rtp_bytes_received + { + table_writer.write::<_, _, 8>(7, &prepared_rtp_bytes_received); + } + if let ::core::option::Option::Some(prepared_rtp_recv_bitrate) = + prepared_rtp_recv_bitrate + { + table_writer.write::<_, _, 8>(8, &prepared_rtp_recv_bitrate); + } + if let ::core::option::Option::Some(prepared_rtp_bytes_sent) = + prepared_rtp_bytes_sent + { + table_writer.write::<_, _, 8>(9, &prepared_rtp_bytes_sent); + } + if let ::core::option::Option::Some(prepared_rtp_send_bitrate) = + prepared_rtp_send_bitrate + { + table_writer.write::<_, _, 8>(10, &prepared_rtp_send_bitrate); + } + if let ::core::option::Option::Some(prepared_rtx_bytes_received) = + prepared_rtx_bytes_received + { + table_writer.write::<_, _, 8>(11, &prepared_rtx_bytes_received); + } + if let ::core::option::Option::Some(prepared_rtx_recv_bitrate) = + prepared_rtx_recv_bitrate + { + table_writer.write::<_, _, 8>(12, &prepared_rtx_recv_bitrate); + } + if let ::core::option::Option::Some(prepared_rtx_bytes_sent) = + prepared_rtx_bytes_sent + { + table_writer.write::<_, _, 8>(13, &prepared_rtx_bytes_sent); + } + if let ::core::option::Option::Some(prepared_rtx_send_bitrate) = + prepared_rtx_send_bitrate + { + table_writer.write::<_, _, 8>(14, &prepared_rtx_send_bitrate); + } + if let ::core::option::Option::Some(prepared_probation_bytes_sent) = + prepared_probation_bytes_sent + { + table_writer.write::<_, _, 8>(15, &prepared_probation_bytes_sent); + } + if let ::core::option::Option::Some(prepared_probation_send_bitrate) = + prepared_probation_send_bitrate + { + table_writer.write::<_, _, 8>(16, &prepared_probation_send_bitrate); + } + if let ::core::option::Option::Some(prepared_available_outgoing_bitrate) = + prepared_available_outgoing_bitrate + { + table_writer.write::<_, _, 8>(17, &prepared_available_outgoing_bitrate); + } + if let ::core::option::Option::Some(prepared_available_incoming_bitrate) = + prepared_available_incoming_bitrate + { + table_writer.write::<_, _, 8>(18, &prepared_available_incoming_bitrate); + } + if let ::core::option::Option::Some(prepared_max_incoming_bitrate) = + prepared_max_incoming_bitrate + { + table_writer.write::<_, _, 8>(19, &prepared_max_incoming_bitrate); + } + if let ::core::option::Option::Some(prepared_max_outgoing_bitrate) = + prepared_max_outgoing_bitrate + { + table_writer.write::<_, _, 8>(20, &prepared_max_outgoing_bitrate); + } + if let ::core::option::Option::Some(prepared_min_outgoing_bitrate) = + prepared_min_outgoing_bitrate + { + table_writer.write::<_, _, 8>(21, &prepared_min_outgoing_bitrate); + } + if let ::core::option::Option::Some(prepared_rtp_packet_loss_received) = + prepared_rtp_packet_loss_received + { + table_writer.write::<_, _, 8>(22, &prepared_rtp_packet_loss_received); + } + if let ::core::option::Option::Some(prepared_rtp_packet_loss_sent) = + prepared_rtp_packet_loss_sent + { + table_writer.write::<_, _, 8>(23, &prepared_rtp_packet_loss_sent); + } + table_writer.write::<_, _, 4>(0, &prepared_transport_id); + if let ::core::option::Option::Some(prepared_sctp_state) = + prepared_sctp_state + { + table_writer.write::<_, _, 4>(2, &prepared_sctp_state); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Stats { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct StatsRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> StatsRef<'a> { + pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "Stats", "transport_id") + } + + pub fn timestamp(&self) -> ::planus::Result { + ::core::result::Result::Ok(self.0.access(1, "Stats", "timestamp")?.unwrap_or(0)) + } + + pub fn sctp_state( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(2, "Stats", "sctp_state") + } + + pub fn bytes_received(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(3, "Stats", "bytes_received")?.unwrap_or(0), + ) + } + + pub fn recv_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(4, "Stats", "recv_bitrate")?.unwrap_or(0), + ) + } + + pub fn bytes_sent(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(5, "Stats", "bytes_sent")?.unwrap_or(0), + ) + } + + pub fn send_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(6, "Stats", "send_bitrate")?.unwrap_or(0), + ) + } + + pub fn rtp_bytes_received(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(7, "Stats", "rtp_bytes_received")? + .unwrap_or(0), + ) + } + + pub fn rtp_recv_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(8, "Stats", "rtp_recv_bitrate")?.unwrap_or(0), + ) + } + + pub fn rtp_bytes_sent(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(9, "Stats", "rtp_bytes_sent")?.unwrap_or(0), + ) + } + + pub fn rtp_send_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(10, "Stats", "rtp_send_bitrate")?.unwrap_or(0), + ) + } + + pub fn rtx_bytes_received(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(11, "Stats", "rtx_bytes_received")? + .unwrap_or(0), + ) + } + + pub fn rtx_recv_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(12, "Stats", "rtx_recv_bitrate")?.unwrap_or(0), + ) + } + + pub fn rtx_bytes_sent(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(13, "Stats", "rtx_bytes_sent")?.unwrap_or(0), + ) + } + + pub fn rtx_send_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(14, "Stats", "rtx_send_bitrate")?.unwrap_or(0), + ) + } + + pub fn probation_bytes_sent(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(15, "Stats", "probation_bytes_sent")? + .unwrap_or(0), + ) + } + + pub fn probation_send_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(16, "Stats", "probation_send_bitrate")? + .unwrap_or(0), + ) + } + + pub fn available_outgoing_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(17, "Stats", "available_outgoing_bitrate")? + .unwrap_or(0), + ) + } + + pub fn available_incoming_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(18, "Stats", "available_incoming_bitrate")? + .unwrap_or(0), + ) + } + + pub fn max_incoming_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(19, "Stats", "max_incoming_bitrate")? + .unwrap_or(0), + ) + } + + pub fn max_outgoing_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(20, "Stats", "max_outgoing_bitrate")? + .unwrap_or(0), + ) + } + + pub fn min_outgoing_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(21, "Stats", "min_outgoing_bitrate")? + .unwrap_or(0), + ) + } + + pub fn rtp_packet_loss_received(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(22, "Stats", "rtp_packet_loss_received")? + .unwrap_or(0), + ) + } + + pub fn rtp_packet_loss_sent(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(23, "Stats", "rtp_packet_loss_sent")? + .unwrap_or(0), + ) + } + } + + 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()); + f.field( + "available_outgoing_bitrate", + &self.available_outgoing_bitrate(), + ); + f.field( + "available_incoming_bitrate", + &self.available_incoming_bitrate(), + ); + f.field("max_incoming_bitrate", &self.max_incoming_bitrate()); + f.field("max_outgoing_bitrate", &self.max_outgoing_bitrate()); + f.field("min_outgoing_bitrate", &self.min_outgoing_bitrate()); + f.field("rtp_packet_loss_received", &self.rtp_packet_loss_received()); + f.field("rtp_packet_loss_sent", &self.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: ::core::convert::TryInto::try_into( + value.available_outgoing_bitrate()?, + )?, + available_incoming_bitrate: ::core::convert::TryInto::try_into( + value.available_incoming_bitrate()?, + )?, + max_incoming_bitrate: ::core::convert::TryInto::try_into( + value.max_incoming_bitrate()?, + )?, + max_outgoing_bitrate: ::core::convert::TryInto::try_into( + value.max_outgoing_bitrate()?, + )?, + min_outgoing_bitrate: ::core::convert::TryInto::try_into( + value.min_outgoing_bitrate()?, + )?, + rtp_packet_loss_received: ::core::convert::TryInto::try_into( + value.rtp_packet_loss_received()?, + )?, + rtp_packet_loss_sent: ::core::convert::TryInto::try_into( + value.rtp_packet_loss_sent()?, + )?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for StatsRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct 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 { + #[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::<4, 4>::new(builder); + + if prepared_max_incoming_bitrate.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_max_incoming_bitrate) = + prepared_max_incoming_bitrate + { + table_writer.write::<_, _, 4>(0, &prepared_max_incoming_bitrate); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for SetMaxIncomingBitrateRequest + { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SetMaxIncomingBitrateRequest::create(builder, &self.max_incoming_bitrate) + } + } + + #[derive(Copy, Clone)] + pub struct SetMaxIncomingBitrateRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SetMaxIncomingBitrateRequestRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct 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 { + #[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::<4, 4>::new(builder); + + if prepared_max_outgoing_bitrate.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_max_outgoing_bitrate) = + prepared_max_outgoing_bitrate + { + table_writer.write::<_, _, 4>(0, &prepared_max_outgoing_bitrate); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for SetMaxOutgoingBitrateRequest + { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SetMaxOutgoingBitrateRequest::create(builder, &self.max_outgoing_bitrate) + } + } + + #[derive(Copy, Clone)] + pub struct SetMaxOutgoingBitrateRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SetMaxOutgoingBitrateRequestRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct 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 { + #[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::<4, 4>::new(builder); + + if prepared_min_outgoing_bitrate.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_min_outgoing_bitrate) = + prepared_min_outgoing_bitrate + { + table_writer.write::<_, _, 4>(0, &prepared_min_outgoing_bitrate); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for SetMinOutgoingBitrateRequest + { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SetMinOutgoingBitrateRequest::create(builder, &self.min_outgoing_bitrate) + } + } + + #[derive(Copy, Clone)] + pub struct SetMinOutgoingBitrateRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SetMinOutgoingBitrateRequestRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct EnableTraceEventRequest { + pub events: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + } + + impl EnableTraceEventRequest { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_events: impl ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + ) -> ::planus::Offset { + let prepared_events = field_events.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_events); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for EnableTraceEventRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + EnableTraceEventRequest::create(builder, &self.events) + } + } + + #[derive(Copy, Clone)] + pub struct EnableTraceEventRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> EnableTraceEventRequestRef<'a> { + pub fn events( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + > { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CloseProducerRequest { + pub producer_id: ::planus::alloc::string::String, + } + + impl CloseProducerRequest { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_producer_id); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for CloseProducerRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CloseProducerRequest::create(builder, &self.producer_id) + } + } + + #[derive(Copy, Clone)] + pub struct CloseProducerRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CloseProducerRequestRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CloseConsumerRequest { + pub consumer_id: ::planus::alloc::string::String, + } + + impl CloseConsumerRequest { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_consumer_id); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for CloseConsumerRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CloseConsumerRequest::create(builder, &self.consumer_id) + } + } + + #[derive(Copy, Clone)] + pub struct CloseConsumerRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CloseConsumerRequestRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CloseDataProducerRequest { + pub data_producer_id: ::planus::alloc::string::String, + } + + impl CloseDataProducerRequest { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_data_producer_id); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for CloseDataProducerRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CloseDataProducerRequest::create(builder, &self.data_producer_id) + } + } + + #[derive(Copy, Clone)] + pub struct CloseDataProducerRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CloseDataProducerRequestRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CloseDataConsumerRequest { + pub data_consumer_id: ::planus::alloc::string::String, + } + + impl CloseDataConsumerRequest { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_data_consumer_id); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for CloseDataConsumerRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CloseDataConsumerRequest::create(builder, &self.data_consumer_id) + } + } + + #[derive(Copy, Clone)] + pub struct CloseDataConsumerRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CloseDataConsumerRequestRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct SendRtcpNotification { + pub data: ::planus::alloc::vec::Vec, + } + + impl SendRtcpNotification { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset<[u8]>>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_data); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for SendRtcpNotification { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SendRtcpNotification::create(builder, &self.data) + } + } + + #[derive(Copy, Clone)] + pub struct SendRtcpNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SendRtcpNotificationRef<'a> { + pub fn data(&self) -> ::planus::Result<::planus::Vector<'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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct 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 { + #[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::<4, 1>::new(builder); + + if prepared_sctp_state.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_sctp_state) = + prepared_sctp_state + { + table_writer.write::<_, _, 1>(0, &prepared_sctp_state); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for SctpStateChangeNotification + { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SctpStateChangeNotification::create(builder, &self.sctp_state) + } + } + + #[derive(Copy, Clone)] + pub struct SctpStateChangeNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SctpStateChangeNotificationRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + #[repr(u8)] + pub enum TraceType { + Probation = 0, + Bwe = 1, + } + + impl ::core::convert::TryFrom for TraceType { + type Error = ::planus::errors::UnknownEnumTagKind; + fn try_from( + value: u8, + ) -> ::core::result::Result + { + #[allow(clippy::match_single_binding)] + match value { + 0 => ::core::result::Result::Ok(TraceType::Probation), + 1 => ::core::result::Result::Ok(TraceType::Bwe), + + _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { + tag: value as i128, + }), + } + } + } + + impl ::core::convert::From for u8 { + fn from(value: TraceType) -> Self { + value as u8 + } + } + + impl ::planus::Primitive for TraceType { + const ALIGNMENT: usize = 1; + const SIZE: usize = 1; + } + + impl ::planus::WriteAsPrimitive for TraceType { + #[inline] + fn write( + &self, + cursor: ::planus::Cursor<'_, N>, + buffer_position: u32, + ) { + (*self as u8).write(cursor, buffer_position); + } + } + + impl ::planus::WriteAs for TraceType { + type Prepared = Self; + + #[inline] + fn prepare(&self, _builder: &mut ::planus::Builder) -> TraceType { + *self + } + } + + impl ::planus::WriteAsDefault for TraceType { + type Prepared = Self; + + #[inline] + fn prepare( + &self, + _builder: &mut ::planus::Builder, + default: &TraceType, + ) -> ::core::option::Option { + if self == default { + ::core::option::Option::None + } else { + ::core::option::Option::Some(*self) + } + } + } + + impl ::planus::WriteAsOptional for TraceType { + 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 TraceType { + 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 TraceType { + 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 = ::from_buffer(buffer, offset); + let value: ::core::result::Result = + ::core::convert::TryInto::try_into(value); + value.map_err(|error_kind| { + error_kind.with_error_location( + "TraceType", + "VectorRead::from_buffer", + buffer.offset_from_start, + ) + }) + } + } + + impl ::planus::VectorWrite for TraceType { + const STRIDE: usize = 1; + + type Value = Self; + + 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, + ); + } + } + } + + #[derive( + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + #[repr(u8)] + pub enum TraceDirection { + DirectionIn = 0, + DirectionOut = 1, + } + + impl ::core::convert::TryFrom for TraceDirection { + type Error = ::planus::errors::UnknownEnumTagKind; + 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 { + 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 { + 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 = ::from_buffer(buffer, 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; + + 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, + ); + } + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub enum TraceInfo { + BweTraceInfo(::planus::alloc::boxed::Box), + } + + impl TraceInfo { + 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 { + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + } + } + + #[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) => { + TraceInfo::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 }, + ), + } + } + } + + #[derive( + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + #[repr(u8)] + pub enum BweType { + TransportCc = 0, + Remb = 1, + } + + impl ::core::convert::TryFrom for BweType { + type Error = ::planus::errors::UnknownEnumTagKind; + 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 { + 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 { + 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 = ::from_buffer(buffer, 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; + + 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, + ); + } + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct BweTraceInfo { + pub desired_bitrate: u32, + pub effective_desired_bitrate: u32, + pub min_bitrate: u32, + pub max_bitrate: u32, + pub start_bitrate: u32, + pub max_padding_bitrate: u32, + pub available_bitrate: u32, + pub bwe_type: self::BweType, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for BweTraceInfo { + fn default() -> Self { + Self { + desired_bitrate: 0, + effective_desired_bitrate: 0, + min_bitrate: 0, + max_bitrate: 0, + start_bitrate: 0, + max_padding_bitrate: 0, + available_bitrate: 0, + bwe_type: self::BweType::TransportCc, + } + } + } + + impl BweTraceInfo { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + 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, + field_bwe_type: impl ::planus::WriteAsDefault, + ) -> ::planus::Offset { + 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 prepared_bwe_type = + field_bwe_type.prepare(builder, &self::BweType::TransportCc); + + let mut table_writer = + ::planus::table_writer::TableWriter::<18, 29>::new(builder); + + if prepared_desired_bitrate.is_some() { + table_writer.calculate_size::(2); + } + if prepared_effective_desired_bitrate.is_some() { + table_writer.calculate_size::(4); + } + if prepared_min_bitrate.is_some() { + table_writer.calculate_size::(6); + } + if prepared_max_bitrate.is_some() { + table_writer.calculate_size::(8); + } + if prepared_start_bitrate.is_some() { + table_writer.calculate_size::(10); + } + if prepared_max_padding_bitrate.is_some() { + table_writer.calculate_size::(12); + } + if prepared_available_bitrate.is_some() { + table_writer.calculate_size::(14); + } + if prepared_bwe_type.is_some() { + table_writer.calculate_size::(16); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_desired_bitrate) = + prepared_desired_bitrate + { + table_writer.write::<_, _, 4>(0, &prepared_desired_bitrate); + } + if let ::core::option::Option::Some(prepared_effective_desired_bitrate) = + prepared_effective_desired_bitrate + { + table_writer.write::<_, _, 4>(1, &prepared_effective_desired_bitrate); + } + if let ::core::option::Option::Some(prepared_min_bitrate) = + prepared_min_bitrate + { + table_writer.write::<_, _, 4>(2, &prepared_min_bitrate); + } + if let ::core::option::Option::Some(prepared_max_bitrate) = + prepared_max_bitrate + { + table_writer.write::<_, _, 4>(3, &prepared_max_bitrate); + } + if let ::core::option::Option::Some(prepared_start_bitrate) = + prepared_start_bitrate + { + table_writer.write::<_, _, 4>(4, &prepared_start_bitrate); + } + if let ::core::option::Option::Some(prepared_max_padding_bitrate) = + prepared_max_padding_bitrate + { + table_writer.write::<_, _, 4>(5, &prepared_max_padding_bitrate); + } + if let ::core::option::Option::Some(prepared_available_bitrate) = + prepared_available_bitrate + { + table_writer.write::<_, _, 4>(6, &prepared_available_bitrate); + } + if let ::core::option::Option::Some(prepared_bwe_type) = prepared_bwe_type { + table_writer.write::<_, _, 1>(7, &prepared_bwe_type); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for BweTraceInfo { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + BweTraceInfo::create( + builder, + &self.desired_bitrate, + &self.effective_desired_bitrate, + &self.min_bitrate, + &self.max_bitrate, + &self.start_bitrate, + &self.max_padding_bitrate, + &self.available_bitrate, + &self.bwe_type, + ) + } + } + + #[derive(Copy, Clone)] + pub struct BweTraceInfoRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> BweTraceInfoRef<'a> { + pub fn desired_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "BweTraceInfo", "desired_bitrate")? + .unwrap_or(0), + ) + } + + pub fn effective_desired_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "BweTraceInfo", "effective_desired_bitrate")? + .unwrap_or(0), + ) + } + + pub fn min_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "BweTraceInfo", "min_bitrate")? + .unwrap_or(0), + ) + } + + pub fn max_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(3, "BweTraceInfo", "max_bitrate")? + .unwrap_or(0), + ) + } + + pub fn start_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(4, "BweTraceInfo", "start_bitrate")? + .unwrap_or(0), + ) + } + + pub fn max_padding_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(5, "BweTraceInfo", "max_padding_bitrate")? + .unwrap_or(0), + ) + } + + pub fn available_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(6, "BweTraceInfo", "available_bitrate")? + .unwrap_or(0), + ) + } + + pub fn bwe_type(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(7, "BweTraceInfo", "bwe_type")? + .unwrap_or(self::BweType::TransportCc), + ) + } + } + + 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("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.field("bwe_type", &self.bwe_type()); + 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 { + 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()?, + )?, + bwe_type: ::core::convert::TryInto::try_into(value.bwe_type()?)?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for BweTraceInfoRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct TraceNotification { + pub type_: self::TraceType, + pub timestamp: u64, + pub direction: self::TraceDirection, + pub info: ::core::option::Option, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for TraceNotification { + fn default() -> Self { + Self { + type_: self::TraceType::Probation, + timestamp: 0, + direction: self::TraceDirection::DirectionIn, + info: ::core::default::Default::default(), + } + } + } + + impl TraceNotification { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_type_: impl ::planus::WriteAsDefault, + field_timestamp: impl ::planus::WriteAsDefault, + field_direction: impl ::planus::WriteAsDefault< + self::TraceDirection, + self::TraceDirection, + >, + field_info: impl ::planus::WriteAsOptionalUnion, + ) -> ::planus::Offset { + let prepared_type_ = field_type_.prepare(builder, &self::TraceType::Probation); + + let prepared_timestamp = field_timestamp.prepare(builder, &0); + + let prepared_direction = + field_direction.prepare(builder, &self::TraceDirection::DirectionIn); + + let prepared_info = field_info.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<10, 15>::new(builder); + + if prepared_type_.is_some() { + table_writer.calculate_size::(2); + } + if prepared_timestamp.is_some() { + table_writer.calculate_size::(4); + } + if prepared_direction.is_some() { + table_writer.calculate_size::(6); + } + if prepared_info.is_some() { + table_writer.calculate_size::(8); + table_writer.calculate_size::<::planus::Offset>(10); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_timestamp) = prepared_timestamp + { + table_writer.write::<_, _, 8>(1, &prepared_timestamp); + } + if let ::core::option::Option::Some(prepared_info) = prepared_info { + table_writer.write::<_, _, 4>(4, &prepared_info.offset()); + } + if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { + table_writer.write::<_, _, 1>(0, &prepared_type_); + } + if let ::core::option::Option::Some(prepared_direction) = prepared_direction + { + table_writer.write::<_, _, 1>(2, &prepared_direction); + } + if let ::core::option::Option::Some(prepared_info) = prepared_info { + table_writer.write::<_, _, 1>(3, &prepared_info.tag()); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for TraceNotification { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + TraceNotification::create( + builder, + &self.type_, + &self.timestamp, + &self.direction, + &self.info, + ) + } + } + + #[derive(Copy, Clone)] + pub struct TraceNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> TraceNotificationRef<'a> { + pub fn type_(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "TraceNotification", "type_")? + .unwrap_or(self::TraceType::Probation), + ) + } + + pub fn timestamp(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "TraceNotification", "timestamp")? + .unwrap_or(0), + ) + } + + pub fn direction(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "TraceNotification", "direction")? + .unwrap_or(self::TraceDirection::DirectionIn), + ) + } + + 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> { + 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; + 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) + }) + } + } + } + pub mod sctp_association { + #[derive( + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + #[repr(u8)] + pub enum SctpState { + New = 0, + Connecting = 1, + Connected = 2, + Failed = 3, + Closed = 4, + } + + impl ::core::convert::TryFrom for SctpState { + type Error = ::planus::errors::UnknownEnumTagKind; + 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 { + 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 { + 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 = ::from_buffer(buffer, 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; + + 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, + ); + } + } + } + } + pub mod log { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Log { + pub data: ::planus::alloc::string::String, + } + + impl Log { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_data); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Log { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Log::create(builder, &self.data) + } + } + + #[derive(Copy, Clone)] + pub struct LogRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> LogRef<'a> { + 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> { + 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; + 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) + }) + } + } + } + pub mod message { + #[derive( + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + #[repr(u8)] + pub enum Type { + Request = 0, + Response = 1, + Notification = 2, + Log = 3, + } + + impl ::core::convert::TryFrom for Type { + type Error = ::planus::errors::UnknownEnumTagKind; + 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 { + 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 { + 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 = ::from_buffer(buffer, 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; + + 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, + ); + } + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub enum Body { + Request(::planus::alloc::boxed::Box), + Response(::planus::alloc::boxed::Box), + Notification(::planus::alloc::boxed::Box), + Log(::planus::alloc::boxed::Box), + } + + impl Body { + pub fn create_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + } + + pub fn create_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + } + + pub fn create_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) + } + + 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 { + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + } + } + + #[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) => Body::Request(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )), + + BodyRef::Response(value) => { + Body::Response(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::Notification(value) => { + Body::Notification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::Log(value) => Body::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 }, + ), + } + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct Message { + pub type_: self::Type, + pub data: self::Body, + } + + impl Message { + #[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::<6, 6>::new(builder); + + if prepared_type_.is_some() { + table_writer.calculate_size::(2); + } + table_writer.calculate_size::(4); + table_writer.calculate_size::<::planus::Offset>(6); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(2, &prepared_data.offset()); + if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { + table_writer.write::<_, _, 1>(0, &prepared_type_); + } + table_writer.write::<_, _, 1>(1, &prepared_data.tag()); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Message { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Message::create(builder, &self.type_, &self.data) + } + } + + #[derive(Copy, Clone)] + pub struct MessageRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> MessageRef<'a> { + pub fn type_(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "Message", "type_")? + .unwrap_or(self::Type::Request), + ) + } + + 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> { + 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; + 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) + }) + } + } + } + pub mod notification { + #[derive( + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + #[repr(u8)] + pub enum Event { + TransportSendRtcp = 0, + ProducerSend = 1, + DataProducerSend = 2, + WorkerRunning = 3, + TransportSctpStateChange = 4, + TransportTrace = 5, + WebrtctransportIceSelectedTupleChange = 6, + WebrtctransportIceStateChange = 7, + WebrtctransportDtlsStateChange = 8, + PlaintransportTuple = 9, + PlaintransportRtcpTuple = 10, + DirecttransportRtcp = 11, + ProducerScore = 12, + ProducerTrace = 13, + ProducerVideoOrientationChange = 14, + ConsumerProducerPause = 15, + ConsumerProducerResume = 16, + ConsumerProducerClose = 17, + ConsumerLayersChange = 18, + ConsumerRtp = 19, + ConsumerScore = 20, + ConsumerTrace = 21, + DataconsumerBufferedAmountLow = 22, + DataconsumerSctpSendbufferFull = 23, + DataconsumerDataproducerClose = 24, + DataconsumerMessage = 25, + ActivespeakerobserverDominantSpeaker = 26, + AudiolevelobserverSilence = 27, + AudiolevelobserverVolumes = 28, + } + + impl ::core::convert::TryFrom for Event { + type Error = ::planus::errors::UnknownEnumTagKind; + 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::DataconsumerDataproducerClose), + 25 => ::core::result::Result::Ok(Event::DataconsumerMessage), + 26 => { + ::core::result::Result::Ok(Event::ActivespeakerobserverDominantSpeaker) + } + 27 => ::core::result::Result::Ok(Event::AudiolevelobserverSilence), + 28 => ::core::result::Result::Ok(Event::AudiolevelobserverVolumes), + + _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { + tag: value as i128, + }), + } + } + } + + impl ::core::convert::From for u8 { + 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 { + 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 = ::from_buffer(buffer, 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; + + 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, + ); + } + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub enum Body { + SendRtcpNotification( + ::planus::alloc::boxed::Box, + ), + SctpStateChangeNotification( + ::planus::alloc::boxed::Box, + ), + SendNotification( + ::planus::alloc::boxed::Box, + ), + TraceNotification(::planus::alloc::boxed::Box), + IceSelectedTupleChangeNotification( + ::planus::alloc::boxed::Box< + super::web_rtc_transport::IceSelectedTupleChangeNotification, + >, + ), + IceStateChangeNotification( + ::planus::alloc::boxed::Box< + super::web_rtc_transport::IceStateChangeNotification, + >, + ), + DtlsStateChangeNotification( + ::planus::alloc::boxed::Box< + super::web_rtc_transport::DtlsStateChangeNotification, + >, + ), + TupleNotification( + ::planus::alloc::boxed::Box, + ), + RtcpTupleNotification( + ::planus::alloc::boxed::Box, + ), + RtcpNotification( + ::planus::alloc::boxed::Box, + ), + ScoreNotification(::planus::alloc::boxed::Box), + VideoOrientationChangeNotification( + ::planus::alloc::boxed::Box< + super::producer::VideoOrientationChangeNotification, + >, + ), + LayersChangeNotification( + ::planus::alloc::boxed::Box, + ), + RtpNotification(::planus::alloc::boxed::Box), + MessageNotification( + ::planus::alloc::boxed::Box, + ), + BufferedAmountLowNotification( + ::planus::alloc::boxed::Box< + super::data_consumer::BufferedAmountLowNotification, + >, + ), + DominantSpeakerNotification( + ::planus::alloc::boxed::Box< + super::active_speaker_observer::DominantSpeakerNotification, + >, + ), + VolumesNotification( + ::planus::alloc::boxed::Box, + ), + } + + impl Body { + pub fn create_send_rtcp_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + } + + pub fn create_sctp_state_change_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + } + + pub fn create_send_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) + } + + pub fn create_trace_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) + } + + pub fn create_ice_selected_tuple_change_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset< + super::web_rtc_transport::IceSelectedTupleChangeNotification, + >, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) + } + + pub fn create_ice_state_change_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset< + super::web_rtc_transport::IceStateChangeNotification, + >, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(6, value.prepare(builder).downcast()) + } + + pub fn create_dtls_state_change_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset< + super::web_rtc_transport::DtlsStateChangeNotification, + >, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(7, value.prepare(builder).downcast()) + } + + pub fn create_tuple_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(8, value.prepare(builder).downcast()) + } + + pub fn create_rtcp_tuple_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(9, value.prepare(builder).downcast()) + } + + pub fn create_rtcp_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(10, value.prepare(builder).downcast()) + } + + pub fn create_score_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) + } + + pub fn create_video_orientation_change_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset< + super::producer::VideoOrientationChangeNotification, + >, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) + } + + pub fn create_layers_change_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) + } + + pub fn create_rtp_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) + } + + pub fn create_message_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) + } + + pub fn create_buffered_amount_low_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset< + super::data_consumer::BufferedAmountLowNotification, + >, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) + } + + pub fn create_dominant_speaker_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset< + super::active_speaker_observer::DominantSpeakerNotification, + >, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) + } + + pub fn create_volumes_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset< + super::audio_level_observer::VolumesNotification, + >, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(18, value.prepare(builder).downcast()) + } + } + + impl ::planus::WriteAsUnion for Body { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + match self { + Self::SendRtcpNotification(value) => { + Self::create_send_rtcp_notification(builder, value) + } + Self::SctpStateChangeNotification(value) => { + Self::create_sctp_state_change_notification(builder, value) + } + Self::SendNotification(value) => { + Self::create_send_notification(builder, value) + } + Self::TraceNotification(value) => { + Self::create_trace_notification(builder, value) + } + Self::IceSelectedTupleChangeNotification(value) => { + Self::create_ice_selected_tuple_change_notification(builder, value) + } + Self::IceStateChangeNotification(value) => { + Self::create_ice_state_change_notification(builder, value) + } + Self::DtlsStateChangeNotification(value) => { + Self::create_dtls_state_change_notification(builder, value) + } + Self::TupleNotification(value) => { + Self::create_tuple_notification(builder, value) + } + Self::RtcpTupleNotification(value) => { + Self::create_rtcp_tuple_notification(builder, value) + } + Self::RtcpNotification(value) => { + Self::create_rtcp_notification(builder, value) + } + Self::ScoreNotification(value) => { + Self::create_score_notification(builder, value) + } + Self::VideoOrientationChangeNotification(value) => { + Self::create_video_orientation_change_notification(builder, value) + } + Self::LayersChangeNotification(value) => { + Self::create_layers_change_notification(builder, value) + } + Self::RtpNotification(value) => { + Self::create_rtp_notification(builder, value) + } + Self::MessageNotification(value) => { + Self::create_message_notification(builder, value) + } + Self::BufferedAmountLowNotification(value) => { + Self::create_buffered_amount_low_notification(builder, value) + } + Self::DominantSpeakerNotification(value) => { + Self::create_dominant_speaker_notification(builder, value) + } + Self::VolumesNotification(value) => { + Self::create_volumes_notification(builder, value) + } + } + } + } + + impl ::planus::WriteAsOptionalUnion for Body { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + } + } + + #[derive(Copy, Clone, Debug)] + pub enum BodyRef<'a> { + SendRtcpNotification(super::transport::SendRtcpNotificationRef<'a>), + SctpStateChangeNotification(super::transport::SctpStateChangeNotificationRef<'a>), + SendNotification(super::data_producer::SendNotificationRef<'a>), + TraceNotification(super::consumer::TraceNotificationRef<'a>), + IceSelectedTupleChangeNotification( + super::web_rtc_transport::IceSelectedTupleChangeNotificationRef<'a>, + ), + IceStateChangeNotification( + super::web_rtc_transport::IceStateChangeNotificationRef<'a>, + ), + DtlsStateChangeNotification( + super::web_rtc_transport::DtlsStateChangeNotificationRef<'a>, + ), + TupleNotification(super::plain_transport::TupleNotificationRef<'a>), + RtcpTupleNotification(super::plain_transport::RtcpTupleNotificationRef<'a>), + RtcpNotification(super::direct_transport::RtcpNotificationRef<'a>), + ScoreNotification(super::consumer::ScoreNotificationRef<'a>), + VideoOrientationChangeNotification( + super::producer::VideoOrientationChangeNotificationRef<'a>, + ), + LayersChangeNotification(super::consumer::LayersChangeNotificationRef<'a>), + RtpNotification(super::consumer::RtpNotificationRef<'a>), + MessageNotification(super::data_consumer::MessageNotificationRef<'a>), + BufferedAmountLowNotification( + super::data_consumer::BufferedAmountLowNotificationRef<'a>, + ), + DominantSpeakerNotification( + super::active_speaker_observer::DominantSpeakerNotificationRef<'a>, + ), + VolumesNotification(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::SendRtcpNotification(value) => { + Body::SendRtcpNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SctpStateChangeNotification(value) => { + Body::SctpStateChangeNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SendNotification(value) => { + Body::SendNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::TraceNotification(value) => { + Body::TraceNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::IceSelectedTupleChangeNotification(value) => { + Body::IceSelectedTupleChangeNotification( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::IceStateChangeNotification(value) => { + Body::IceStateChangeNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::DtlsStateChangeNotification(value) => { + Body::DtlsStateChangeNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::TupleNotification(value) => { + Body::TupleNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::RtcpTupleNotification(value) => { + Body::RtcpTupleNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::RtcpNotification(value) => { + Body::RtcpNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::ScoreNotification(value) => { + Body::ScoreNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::VideoOrientationChangeNotification(value) => { + Body::VideoOrientationChangeNotification( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::LayersChangeNotification(value) => { + Body::LayersChangeNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::RtpNotification(value) => { + Body::RtpNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::MessageNotification(value) => { + Body::MessageNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::BufferedAmountLowNotification(value) => { + Body::BufferedAmountLowNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::DominantSpeakerNotification(value) => { + Body::DominantSpeakerNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::VolumesNotification(value) => { + Body::VolumesNotification(::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::SendRtcpNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 2 => ::core::result::Result::Ok(Self::SctpStateChangeNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 3 => ::core::result::Result::Ok(Self::SendNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 4 => ::core::result::Result::Ok(Self::TraceNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 5 => ::core::result::Result::Ok(Self::IceSelectedTupleChangeNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 6 => ::core::result::Result::Ok(Self::IceStateChangeNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 7 => ::core::result::Result::Ok(Self::DtlsStateChangeNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 8 => ::core::result::Result::Ok(Self::TupleNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 9 => ::core::result::Result::Ok(Self::RtcpTupleNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 10 => ::core::result::Result::Ok(Self::RtcpNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 11 => ::core::result::Result::Ok(Self::ScoreNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 12 => ::core::result::Result::Ok(Self::VideoOrientationChangeNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 13 => ::core::result::Result::Ok(Self::LayersChangeNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 14 => ::core::result::Result::Ok(Self::RtpNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 15 => ::core::result::Result::Ok(Self::MessageNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 16 => ::core::result::Result::Ok(Self::BufferedAmountLowNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 17 => ::core::result::Result::Ok(Self::DominantSpeakerNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 18 => ::core::result::Result::Ok(Self::VolumesNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + _ => ::core::result::Result::Err( + ::planus::errors::ErrorKind::UnknownUnionTag { tag }, + ), + } + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Notification { + pub handler_id: ::core::option::Option<::planus::alloc::string::String>, + pub event: self::Event, + pub body: ::core::option::Option, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for Notification { + fn default() -> Self { + Self { + handler_id: ::core::default::Default::default(), + event: self::Event::TransportSendRtcp, + body: ::core::default::Default::default(), + } + } + } + + impl Notification { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_handler_id: impl ::planus::WriteAsOptional< + ::planus::Offset<::core::primitive::str>, + >, + 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::<8, 10>::new(builder); + + if prepared_handler_id.is_some() { + table_writer.calculate_size::<::planus::Offset>(2); + } + if prepared_event.is_some() { + table_writer.calculate_size::(4); + } + if prepared_body.is_some() { + table_writer.calculate_size::(6); + table_writer.calculate_size::<::planus::Offset>(8); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_handler_id) = + prepared_handler_id + { + table_writer.write::<_, _, 4>(0, &prepared_handler_id); + } + if let ::core::option::Option::Some(prepared_body) = prepared_body { + table_writer.write::<_, _, 4>(3, &prepared_body.offset()); + } + if let ::core::option::Option::Some(prepared_event) = prepared_event { + table_writer.write::<_, _, 1>(1, &prepared_event); + } + if let ::core::option::Option::Some(prepared_body) = prepared_body { + table_writer.write::<_, _, 1>(2, &prepared_body.tag()); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Notification { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + Notification::create(builder, &self.handler_id, &self.event, &self.body) + } + } + + #[derive(Copy, Clone)] + pub struct NotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> NotificationRef<'a> { + pub fn handler_id( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(0, "Notification", "handler_id") + } + + pub fn event(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "Notification", "event")? + .unwrap_or(self::Event::TransportSendRtcp), + ) + } + + 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"); + if let ::core::option::Option::Some(field_handler_id) = + self.handler_id().transpose() + { + f.field("handler_id", &field_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: if let ::core::option::Option::Some(handler_id) = + value.handler_id()? + { + ::core::option::Option::Some(::core::convert::TryInto::try_into( + handler_id, + )?) + } else { + ::core::option::Option::None + }, + 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> { + 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; + 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) + }) + } + } + } + pub mod request { + #[derive( + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + #[repr(u8)] + pub enum Method { + WorkerClose = 0, + WorkerDump = 1, + WorkerGetResourceUsage = 2, + WorkerUpdateSettings = 3, + WorkerCreateWebrtcServer = 4, + WorkerCreateRouter = 5, + WorkerWebrtcServerClose = 6, + WorkerCloseRouter = 7, + WebrtcServerDump = 8, + RouterDump = 9, + RouterCreateWebrtcTransport = 10, + RouterCreateWebrtcTransportWithServer = 11, + RouterCreatePlainTransport = 12, + RouterCreatePipeTransport = 13, + RouterCreateDirectTransport = 14, + RouterCloseTransport = 15, + RouterCreateActiveSpeakerObserver = 16, + RouterCreateAudioLevelObserver = 17, + RouterCloseRtpObserver = 18, + TransportDump = 19, + TransportGetStats = 20, + TransportConnect = 21, + TransportSetMaxIncomingBitrate = 22, + TransportSetMaxOutgoingBitrate = 23, + TransportSetMinOutgoingBitrate = 24, + TransportRestartIce = 25, + TransportProduce = 26, + TransportProduceData = 27, + TransportConsume = 28, + TransportConsumeData = 29, + TransportEnableTraceEvent = 30, + TransportCloseProducer = 31, + TransportCloseConsumer = 32, + TransportCloseDataProducer = 33, + TransportCloseDataConsumer = 34, + PlainTransportConnect = 35, + PipeTransportConnect = 36, + WebrtcTransportConnect = 37, + ProducerDump = 38, + ProducerGetStats = 39, + ProducerPause = 40, + ProducerResume = 41, + ProducerEnableTraceEvent = 42, + ConsumerDump = 43, + ConsumerGetStats = 44, + ConsumerPause = 45, + ConsumerResume = 46, + ConsumerSetPreferredLayers = 47, + ConsumerSetPriority = 48, + ConsumerRequestKeyFrame = 49, + ConsumerEnableTraceEvent = 50, + DataProducerDump = 51, + DataProducerGetStats = 52, + DataConsumerDump = 53, + DataConsumerGetStats = 54, + DataConsumerGetBufferedAmount = 55, + DataConsumerSetBufferedAmountLowThreshold = 56, + DataConsumerSend = 57, + RtpObserverPause = 58, + RtpObserverResume = 59, + RtpObserverAddProducer = 60, + RtpObserverRemoveProducer = 61, + } + + impl ::core::convert::TryFrom for Method { + type Error = ::planus::errors::UnknownEnumTagKind; + 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::DataConsumerDump), + 54 => ::core::result::Result::Ok(Method::DataConsumerGetStats), + 55 => ::core::result::Result::Ok(Method::DataConsumerGetBufferedAmount), + 56 => ::core::result::Result::Ok( + Method::DataConsumerSetBufferedAmountLowThreshold, + ), + 57 => ::core::result::Result::Ok(Method::DataConsumerSend), + 58 => ::core::result::Result::Ok(Method::RtpObserverPause), + 59 => ::core::result::Result::Ok(Method::RtpObserverResume), + 60 => ::core::result::Result::Ok(Method::RtpObserverAddProducer), + 61 => ::core::result::Result::Ok(Method::RtpObserverRemoveProducer), + + _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { + tag: value as i128, + }), + } + } + } + + impl ::core::convert::From for u8 { + 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 { + 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 = ::from_buffer(buffer, 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; + + 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, + ); + } + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub enum Body { + UpdateSettingsRequest( + ::planus::alloc::boxed::Box, + ), + CreateWebRtcServerRequest( + ::planus::alloc::boxed::Box, + ), + CloseWebRtcServerRequest( + ::planus::alloc::boxed::Box, + ), + CreateRouterRequest( + ::planus::alloc::boxed::Box, + ), + CloseRouterRequest(::planus::alloc::boxed::Box), + CreateWebRtcTransportRequest( + ::planus::alloc::boxed::Box, + ), + CreatePlainTransportRequest( + ::planus::alloc::boxed::Box, + ), + CreatePipeTransportRequest( + ::planus::alloc::boxed::Box, + ), + CreateDirectTransportRequest( + ::planus::alloc::boxed::Box, + ), + CreateActiveSpeakerObserverRequest( + ::planus::alloc::boxed::Box, + ), + CreateAudioLevelObserverRequest( + ::planus::alloc::boxed::Box, + ), + CloseTransportRequest( + ::planus::alloc::boxed::Box, + ), + CloseRtpObserverRequest( + ::planus::alloc::boxed::Box, + ), + SetMaxIncomingBitrateRequest( + ::planus::alloc::boxed::Box, + ), + SetMaxOutgoingBitrateRequest( + ::planus::alloc::boxed::Box, + ), + SetMinOutgoingBitrateRequest( + ::planus::alloc::boxed::Box, + ), + ProduceRequest(::planus::alloc::boxed::Box), + ConsumeRequest(::planus::alloc::boxed::Box), + ProduceDataRequest( + ::planus::alloc::boxed::Box, + ), + ConsumeDataRequest( + ::planus::alloc::boxed::Box, + ), + EnableTraceEventRequest( + ::planus::alloc::boxed::Box, + ), + CloseProducerRequest( + ::planus::alloc::boxed::Box, + ), + CloseConsumerRequest( + ::planus::alloc::boxed::Box, + ), + CloseDataProducerRequest( + ::planus::alloc::boxed::Box, + ), + CloseDataConsumerRequest( + ::planus::alloc::boxed::Box, + ), + ConnectRequest( + ::planus::alloc::boxed::Box, + ), + SetPreferredLayersRequest( + ::planus::alloc::boxed::Box, + ), + SetPriorityRequest( + ::planus::alloc::boxed::Box, + ), + SetBufferedAmountLowThresholdRequest( + ::planus::alloc::boxed::Box< + super::data_consumer::SetBufferedAmountLowThresholdRequest, + >, + ), + SendRequest(::planus::alloc::boxed::Box), + AddProducerRequest( + ::planus::alloc::boxed::Box, + ), + RemoveProducerRequest( + ::planus::alloc::boxed::Box, + ), + } + + impl Body { + pub fn create_update_settings_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + } + + pub fn create_create_web_rtc_server_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + } + + pub fn create_close_web_rtc_server_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) + } + + pub fn create_create_router_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) + } + + pub fn create_close_router_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) + } + + pub fn create_create_web_rtc_transport_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(6, value.prepare(builder).downcast()) + } + + pub fn create_create_plain_transport_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(7, value.prepare(builder).downcast()) + } + + pub fn create_create_pipe_transport_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(8, value.prepare(builder).downcast()) + } + + pub fn create_create_direct_transport_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(9, value.prepare(builder).downcast()) + } + + pub fn create_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()) + } + + pub fn create_create_audio_level_observer_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) + } + + pub fn create_close_transport_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) + } + + pub fn create_close_rtp_observer_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) + } + + pub fn create_set_max_incoming_bitrate_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) + } + + pub fn create_set_max_outgoing_bitrate_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) + } + + pub fn create_set_min_outgoing_bitrate_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) + } + + pub fn create_produce_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) + } + + pub fn create_consume_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(18, value.prepare(builder).downcast()) + } + + pub fn create_produce_data_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(19, value.prepare(builder).downcast()) + } + + pub fn create_consume_data_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(20, value.prepare(builder).downcast()) + } + + pub fn create_enable_trace_event_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(21, value.prepare(builder).downcast()) + } + + pub fn create_close_producer_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(22, value.prepare(builder).downcast()) + } + + pub fn create_close_consumer_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(23, value.prepare(builder).downcast()) + } + + pub fn create_close_data_producer_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(24, value.prepare(builder).downcast()) + } + + pub fn create_close_data_consumer_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(25, value.prepare(builder).downcast()) + } + + pub fn create_connect_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(26, value.prepare(builder).downcast()) + } + + pub fn create_set_preferred_layers_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(27, value.prepare(builder).downcast()) + } + + pub fn create_set_priority_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(28, value.prepare(builder).downcast()) + } + + pub fn create_set_buffered_amount_low_threshold_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset< + super::data_consumer::SetBufferedAmountLowThresholdRequest, + >, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(29, value.prepare(builder).downcast()) + } + + pub fn create_send_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(30, value.prepare(builder).downcast()) + } + + pub fn create_add_producer_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(31, value.prepare(builder).downcast()) + } + + pub fn create_remove_producer_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(32, value.prepare(builder).downcast()) + } + } + + impl ::planus::WriteAsUnion for Body { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + match self { + Self::UpdateSettingsRequest(value) => { + Self::create_update_settings_request(builder, value) + } + Self::CreateWebRtcServerRequest(value) => { + Self::create_create_web_rtc_server_request(builder, value) + } + Self::CloseWebRtcServerRequest(value) => { + Self::create_close_web_rtc_server_request(builder, value) + } + Self::CreateRouterRequest(value) => { + Self::create_create_router_request(builder, value) + } + Self::CloseRouterRequest(value) => { + Self::create_close_router_request(builder, value) + } + Self::CreateWebRtcTransportRequest(value) => { + Self::create_create_web_rtc_transport_request(builder, value) + } + Self::CreatePlainTransportRequest(value) => { + Self::create_create_plain_transport_request(builder, value) + } + Self::CreatePipeTransportRequest(value) => { + Self::create_create_pipe_transport_request(builder, value) + } + Self::CreateDirectTransportRequest(value) => { + Self::create_create_direct_transport_request(builder, value) + } + Self::CreateActiveSpeakerObserverRequest(value) => { + Self::create_create_active_speaker_observer_request(builder, value) + } + Self::CreateAudioLevelObserverRequest(value) => { + Self::create_create_audio_level_observer_request(builder, value) + } + Self::CloseTransportRequest(value) => { + Self::create_close_transport_request(builder, value) + } + Self::CloseRtpObserverRequest(value) => { + Self::create_close_rtp_observer_request(builder, value) + } + Self::SetMaxIncomingBitrateRequest(value) => { + Self::create_set_max_incoming_bitrate_request(builder, value) + } + Self::SetMaxOutgoingBitrateRequest(value) => { + Self::create_set_max_outgoing_bitrate_request(builder, value) + } + Self::SetMinOutgoingBitrateRequest(value) => { + Self::create_set_min_outgoing_bitrate_request(builder, value) + } + Self::ProduceRequest(value) => Self::create_produce_request(builder, value), + Self::ConsumeRequest(value) => Self::create_consume_request(builder, value), + Self::ProduceDataRequest(value) => { + Self::create_produce_data_request(builder, value) + } + Self::ConsumeDataRequest(value) => { + Self::create_consume_data_request(builder, value) + } + Self::EnableTraceEventRequest(value) => { + Self::create_enable_trace_event_request(builder, value) + } + Self::CloseProducerRequest(value) => { + Self::create_close_producer_request(builder, value) + } + Self::CloseConsumerRequest(value) => { + Self::create_close_consumer_request(builder, value) + } + Self::CloseDataProducerRequest(value) => { + Self::create_close_data_producer_request(builder, value) + } + Self::CloseDataConsumerRequest(value) => { + Self::create_close_data_consumer_request(builder, value) + } + Self::ConnectRequest(value) => Self::create_connect_request(builder, value), + Self::SetPreferredLayersRequest(value) => { + Self::create_set_preferred_layers_request(builder, value) + } + Self::SetPriorityRequest(value) => { + Self::create_set_priority_request(builder, value) + } + Self::SetBufferedAmountLowThresholdRequest(value) => { + Self::create_set_buffered_amount_low_threshold_request(builder, value) + } + Self::SendRequest(value) => Self::create_send_request(builder, value), + Self::AddProducerRequest(value) => { + Self::create_add_producer_request(builder, value) + } + Self::RemoveProducerRequest(value) => { + Self::create_remove_producer_request(builder, value) + } + } + } + } + + impl ::planus::WriteAsOptionalUnion for Body { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + } + } + + #[derive(Copy, Clone, Debug)] + pub enum BodyRef<'a> { + UpdateSettingsRequest(super::worker::UpdateSettingsRequestRef<'a>), + CreateWebRtcServerRequest(super::worker::CreateWebRtcServerRequestRef<'a>), + CloseWebRtcServerRequest(super::worker::CloseWebRtcServerRequestRef<'a>), + CreateRouterRequest(super::worker::CreateRouterRequestRef<'a>), + CloseRouterRequest(super::worker::CloseRouterRequestRef<'a>), + CreateWebRtcTransportRequest(super::router::CreateWebRtcTransportRequestRef<'a>), + CreatePlainTransportRequest(super::router::CreatePlainTransportRequestRef<'a>), + CreatePipeTransportRequest(super::router::CreatePipeTransportRequestRef<'a>), + CreateDirectTransportRequest(super::router::CreateDirectTransportRequestRef<'a>), + CreateActiveSpeakerObserverRequest( + super::router::CreateActiveSpeakerObserverRequestRef<'a>, + ), + CreateAudioLevelObserverRequest( + super::router::CreateAudioLevelObserverRequestRef<'a>, + ), + CloseTransportRequest(super::router::CloseTransportRequestRef<'a>), + CloseRtpObserverRequest(super::router::CloseRtpObserverRequestRef<'a>), + SetMaxIncomingBitrateRequest(super::transport::SetMaxIncomingBitrateRequestRef<'a>), + SetMaxOutgoingBitrateRequest(super::transport::SetMaxOutgoingBitrateRequestRef<'a>), + SetMinOutgoingBitrateRequest(super::transport::SetMinOutgoingBitrateRequestRef<'a>), + ProduceRequest(super::transport::ProduceRequestRef<'a>), + ConsumeRequest(super::transport::ConsumeRequestRef<'a>), + ProduceDataRequest(super::transport::ProduceDataRequestRef<'a>), + ConsumeDataRequest(super::transport::ConsumeDataRequestRef<'a>), + EnableTraceEventRequest(super::consumer::EnableTraceEventRequestRef<'a>), + CloseProducerRequest(super::transport::CloseProducerRequestRef<'a>), + CloseConsumerRequest(super::transport::CloseConsumerRequestRef<'a>), + CloseDataProducerRequest(super::transport::CloseDataProducerRequestRef<'a>), + CloseDataConsumerRequest(super::transport::CloseDataConsumerRequestRef<'a>), + ConnectRequest(super::web_rtc_transport::ConnectRequestRef<'a>), + SetPreferredLayersRequest(super::consumer::SetPreferredLayersRequestRef<'a>), + SetPriorityRequest(super::consumer::SetPriorityRequestRef<'a>), + SetBufferedAmountLowThresholdRequest( + super::data_consumer::SetBufferedAmountLowThresholdRequestRef<'a>, + ), + SendRequest(super::data_consumer::SendRequestRef<'a>), + AddProducerRequest(super::rtp_observer::AddProducerRequestRef<'a>), + RemoveProducerRequest(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::UpdateSettingsRequest(value) => { + Body::UpdateSettingsRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreateWebRtcServerRequest(value) => { + Body::CreateWebRtcServerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseWebRtcServerRequest(value) => { + Body::CloseWebRtcServerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreateRouterRequest(value) => { + Body::CreateRouterRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseRouterRequest(value) => { + Body::CloseRouterRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreateWebRtcTransportRequest(value) => { + Body::CreateWebRtcTransportRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreatePlainTransportRequest(value) => { + Body::CreatePlainTransportRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreatePipeTransportRequest(value) => { + Body::CreatePipeTransportRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreateDirectTransportRequest(value) => { + Body::CreateDirectTransportRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreateActiveSpeakerObserverRequest(value) => { + Body::CreateActiveSpeakerObserverRequest( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::CreateAudioLevelObserverRequest(value) => { + Body::CreateAudioLevelObserverRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseTransportRequest(value) => { + Body::CloseTransportRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseRtpObserverRequest(value) => { + Body::CloseRtpObserverRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetMaxIncomingBitrateRequest(value) => { + Body::SetMaxIncomingBitrateRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetMaxOutgoingBitrateRequest(value) => { + Body::SetMaxOutgoingBitrateRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetMinOutgoingBitrateRequest(value) => { + Body::SetMinOutgoingBitrateRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::ProduceRequest(value) => { + Body::ProduceRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::ConsumeRequest(value) => { + Body::ConsumeRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::ProduceDataRequest(value) => { + Body::ProduceDataRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::ConsumeDataRequest(value) => { + Body::ConsumeDataRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::EnableTraceEventRequest(value) => { + Body::EnableTraceEventRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseProducerRequest(value) => { + Body::CloseProducerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseConsumerRequest(value) => { + Body::CloseConsumerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseDataProducerRequest(value) => { + Body::CloseDataProducerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseDataConsumerRequest(value) => { + Body::CloseDataConsumerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::ConnectRequest(value) => { + Body::ConnectRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetPreferredLayersRequest(value) => { + Body::SetPreferredLayersRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetPriorityRequest(value) => { + Body::SetPriorityRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetBufferedAmountLowThresholdRequest(value) => { + Body::SetBufferedAmountLowThresholdRequest( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::SendRequest(value) => { + Body::SendRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::AddProducerRequest(value) => { + Body::AddProducerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::RemoveProducerRequest(value) => { + Body::RemoveProducerRequest(::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::UpdateSettingsRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 2 => ::core::result::Result::Ok(Self::CreateWebRtcServerRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 3 => ::core::result::Result::Ok(Self::CloseWebRtcServerRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 4 => ::core::result::Result::Ok(Self::CreateRouterRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 5 => ::core::result::Result::Ok(Self::CloseRouterRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 6 => ::core::result::Result::Ok(Self::CreateWebRtcTransportRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 7 => ::core::result::Result::Ok(Self::CreatePlainTransportRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 8 => ::core::result::Result::Ok(Self::CreatePipeTransportRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 9 => ::core::result::Result::Ok(Self::CreateDirectTransportRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 10 => ::core::result::Result::Ok(Self::CreateActiveSpeakerObserverRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 11 => ::core::result::Result::Ok(Self::CreateAudioLevelObserverRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 12 => ::core::result::Result::Ok(Self::CloseTransportRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 13 => ::core::result::Result::Ok(Self::CloseRtpObserverRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 14 => ::core::result::Result::Ok(Self::SetMaxIncomingBitrateRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 15 => ::core::result::Result::Ok(Self::SetMaxOutgoingBitrateRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 16 => ::core::result::Result::Ok(Self::SetMinOutgoingBitrateRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 17 => ::core::result::Result::Ok(Self::ProduceRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 18 => ::core::result::Result::Ok(Self::ConsumeRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 19 => ::core::result::Result::Ok(Self::ProduceDataRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 20 => ::core::result::Result::Ok(Self::ConsumeDataRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 21 => ::core::result::Result::Ok(Self::EnableTraceEventRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 22 => ::core::result::Result::Ok(Self::CloseProducerRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 23 => ::core::result::Result::Ok(Self::CloseConsumerRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 24 => ::core::result::Result::Ok(Self::CloseDataProducerRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 25 => ::core::result::Result::Ok(Self::CloseDataConsumerRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 26 => ::core::result::Result::Ok(Self::ConnectRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 27 => ::core::result::Result::Ok(Self::SetPreferredLayersRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 28 => ::core::result::Result::Ok(Self::SetPriorityRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 29 => { + ::core::result::Result::Ok(Self::SetBufferedAmountLowThresholdRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )) + } + 30 => ::core::result::Result::Ok(Self::SendRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 31 => ::core::result::Result::Ok(Self::AddProducerRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 32 => ::core::result::Result::Ok(Self::RemoveProducerRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + _ => ::core::result::Result::Err( + ::planus::errors::ErrorKind::UnknownUnionTag { tag }, + ), + } + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct Request { + pub id: u32, + pub method: self::Method, + pub handler_id: ::core::option::Option<::planus::alloc::string::String>, + pub body: ::core::option::Option, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for Request { + fn default() -> Self { + Self { + id: 0, + method: self::Method::WorkerClose, + handler_id: ::core::default::Default::default(), + body: ::core::default::Default::default(), + } + } + } + + impl Request { + #[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::WriteAsOptional< + ::planus::Offset<::core::primitive::str>, + >, + 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::<10, 14>::new(builder); + + if prepared_id.is_some() { + table_writer.calculate_size::(2); + } + if prepared_method.is_some() { + table_writer.calculate_size::(4); + } + if prepared_handler_id.is_some() { + table_writer.calculate_size::<::planus::Offset>(6); + } + if prepared_body.is_some() { + table_writer.calculate_size::(8); + table_writer.calculate_size::<::planus::Offset>(10); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_id) = prepared_id { + table_writer.write::<_, _, 4>(0, &prepared_id); + } + if let ::core::option::Option::Some(prepared_handler_id) = + prepared_handler_id + { + table_writer.write::<_, _, 4>(2, &prepared_handler_id); + } + if let ::core::option::Option::Some(prepared_body) = prepared_body { + table_writer.write::<_, _, 4>(4, &prepared_body.offset()); + } + if let ::core::option::Option::Some(prepared_method) = prepared_method { + table_writer.write::<_, _, 1>(1, &prepared_method); + } + if let ::core::option::Option::Some(prepared_body) = prepared_body { + table_writer.write::<_, _, 1>(3, &prepared_body.tag()); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Request { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Request::create( + builder, + &self.id, + &self.method, + &self.handler_id, + &self.body, + ) + } + } + + #[derive(Copy, Clone)] + pub struct RequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RequestRef<'a> { + pub fn id(&self) -> ::planus::Result { + ::core::result::Result::Ok(self.0.access(0, "Request", "id")?.unwrap_or(0)) + } + + pub fn method(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "Request", "method")? + .unwrap_or(self::Method::WorkerClose), + ) + } + + pub fn handler_id( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(2, "Request", "handler_id") + } + + 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()); + if let ::core::option::Option::Some(field_handler_id) = + self.handler_id().transpose() + { + f.field("handler_id", &field_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: if let ::core::option::Option::Some(handler_id) = + value.handler_id()? + { + ::core::option::Option::Some(::core::convert::TryInto::try_into( + handler_id, + )?) + } else { + ::core::option::Option::None + }, + 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> { + 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; + 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) + }) + } + } + } + pub mod response { + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub enum Body { + FbsWorkerDumpResponse(::planus::alloc::boxed::Box), + FbsWorkerResourceUsageResponse( + ::planus::alloc::boxed::Box, + ), + FbsWebRtcServerDumpResponse( + ::planus::alloc::boxed::Box, + ), + FbsRouterDumpResponse(::planus::alloc::boxed::Box), + FbsTransportProduceResponse( + ::planus::alloc::boxed::Box, + ), + FbsTransportConsumeResponse( + ::planus::alloc::boxed::Box, + ), + FbsTransportRestartIceResponse( + ::planus::alloc::boxed::Box, + ), + FbsPlainTransportConnectResponse( + ::planus::alloc::boxed::Box, + ), + FbsPlainTransportDumpResponse( + ::planus::alloc::boxed::Box, + ), + FbsPlainTransportGetStatsResponse( + ::planus::alloc::boxed::Box, + ), + FbsPipeTransportConnectResponse( + ::planus::alloc::boxed::Box, + ), + FbsPipeTransportDumpResponse( + ::planus::alloc::boxed::Box, + ), + FbsPipeTransportGetStatsResponse( + ::planus::alloc::boxed::Box, + ), + FbsDirectTransportDumpResponse( + ::planus::alloc::boxed::Box, + ), + FbsDirectTransportGetStatsResponse( + ::planus::alloc::boxed::Box, + ), + FbsWebRtcTransportConnectResponse( + ::planus::alloc::boxed::Box, + ), + FbsWebRtcTransportDumpResponse( + ::planus::alloc::boxed::Box, + ), + FbsWebRtcTransportGetStatsResponse( + ::planus::alloc::boxed::Box, + ), + FbsProducerDumpResponse(::planus::alloc::boxed::Box), + FbsProducerGetStatsResponse( + ::planus::alloc::boxed::Box, + ), + FbsConsumerDumpResponse(::planus::alloc::boxed::Box), + FbsConsumerGetStatsResponse( + ::planus::alloc::boxed::Box, + ), + FbsConsumerSetPreferredLayersResponse( + ::planus::alloc::boxed::Box, + ), + FbsConsumerSetPriorityResponse( + ::planus::alloc::boxed::Box, + ), + FbsDataProducerDumpResponse( + ::planus::alloc::boxed::Box, + ), + FbsDataProducerGetStatsResponse( + ::planus::alloc::boxed::Box, + ), + FbsDataConsumerGetBufferedAmountResponse( + ::planus::alloc::boxed::Box, + ), + FbsDataConsumerDumpResponse( + ::planus::alloc::boxed::Box, + ), + FbsDataConsumerGetStatsResponse( + ::planus::alloc::boxed::Box, + ), + } + + impl Body { + pub fn create_fbs_worker_dump_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + } + + pub fn create_fbs_worker_resource_usage_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + } + + pub fn create_fbs_web_rtc_server_dump_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) + } + + pub fn create_fbs_router_dump_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) + } + + pub fn create_fbs_transport_produce_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) + } + + pub fn create_fbs_transport_consume_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(6, value.prepare(builder).downcast()) + } + + pub fn create_fbs_transport_restart_ice_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(7, value.prepare(builder).downcast()) + } + + pub fn create_fbs_plain_transport_connect_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(8, value.prepare(builder).downcast()) + } + + pub fn create_fbs_plain_transport_dump_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(9, value.prepare(builder).downcast()) + } + + pub fn create_fbs_plain_transport_get_stats_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(10, value.prepare(builder).downcast()) + } + + pub fn create_fbs_pipe_transport_connect_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) + } + + pub fn create_fbs_pipe_transport_dump_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) + } + + pub fn create_fbs_pipe_transport_get_stats_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) + } + + pub fn create_fbs_direct_transport_dump_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) + } + + pub fn create_fbs_direct_transport_get_stats_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) + } + + pub fn create_fbs_web_rtc_transport_connect_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) + } + + pub fn create_fbs_web_rtc_transport_dump_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) + } + + pub fn create_fbs_web_rtc_transport_get_stats_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(18, value.prepare(builder).downcast()) + } + + pub fn create_fbs_producer_dump_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(19, value.prepare(builder).downcast()) + } + + pub fn create_fbs_producer_get_stats_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(20, value.prepare(builder).downcast()) + } + + pub fn create_fbs_consumer_dump_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(21, value.prepare(builder).downcast()) + } + + pub fn create_fbs_consumer_get_stats_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(22, value.prepare(builder).downcast()) + } + + pub fn create_fbs_consumer_set_preferred_layers_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(23, value.prepare(builder).downcast()) + } + + pub fn create_fbs_consumer_set_priority_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(24, value.prepare(builder).downcast()) + } + + pub fn create_fbs_data_producer_dump_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(25, value.prepare(builder).downcast()) + } + + pub fn create_fbs_data_producer_get_stats_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(26, value.prepare(builder).downcast()) + } + + pub fn create_fbs_data_consumer_get_buffered_amount_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(27, value.prepare(builder).downcast()) + } + + pub fn create_fbs_data_consumer_dump_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(28, value.prepare(builder).downcast()) + } + + pub fn create_fbs_data_consumer_get_stats_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(29, value.prepare(builder).downcast()) + } + } + + impl ::planus::WriteAsUnion for Body { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + match self { + Self::FbsWorkerDumpResponse(value) => { + Self::create_fbs_worker_dump_response(builder, value) + } + Self::FbsWorkerResourceUsageResponse(value) => { + Self::create_fbs_worker_resource_usage_response(builder, value) + } + Self::FbsWebRtcServerDumpResponse(value) => { + Self::create_fbs_web_rtc_server_dump_response(builder, value) + } + Self::FbsRouterDumpResponse(value) => { + Self::create_fbs_router_dump_response(builder, value) + } + Self::FbsTransportProduceResponse(value) => { + Self::create_fbs_transport_produce_response(builder, value) + } + Self::FbsTransportConsumeResponse(value) => { + Self::create_fbs_transport_consume_response(builder, value) + } + Self::FbsTransportRestartIceResponse(value) => { + Self::create_fbs_transport_restart_ice_response(builder, value) + } + Self::FbsPlainTransportConnectResponse(value) => { + Self::create_fbs_plain_transport_connect_response(builder, value) + } + Self::FbsPlainTransportDumpResponse(value) => { + Self::create_fbs_plain_transport_dump_response(builder, value) + } + Self::FbsPlainTransportGetStatsResponse(value) => { + Self::create_fbs_plain_transport_get_stats_response(builder, value) + } + Self::FbsPipeTransportConnectResponse(value) => { + Self::create_fbs_pipe_transport_connect_response(builder, value) + } + Self::FbsPipeTransportDumpResponse(value) => { + Self::create_fbs_pipe_transport_dump_response(builder, value) + } + Self::FbsPipeTransportGetStatsResponse(value) => { + Self::create_fbs_pipe_transport_get_stats_response(builder, value) + } + Self::FbsDirectTransportDumpResponse(value) => { + Self::create_fbs_direct_transport_dump_response(builder, value) + } + Self::FbsDirectTransportGetStatsResponse(value) => { + Self::create_fbs_direct_transport_get_stats_response(builder, value) + } + Self::FbsWebRtcTransportConnectResponse(value) => { + Self::create_fbs_web_rtc_transport_connect_response(builder, value) + } + Self::FbsWebRtcTransportDumpResponse(value) => { + Self::create_fbs_web_rtc_transport_dump_response(builder, value) + } + Self::FbsWebRtcTransportGetStatsResponse(value) => { + Self::create_fbs_web_rtc_transport_get_stats_response(builder, value) + } + Self::FbsProducerDumpResponse(value) => { + Self::create_fbs_producer_dump_response(builder, value) + } + Self::FbsProducerGetStatsResponse(value) => { + Self::create_fbs_producer_get_stats_response(builder, value) + } + Self::FbsConsumerDumpResponse(value) => { + Self::create_fbs_consumer_dump_response(builder, value) + } + Self::FbsConsumerGetStatsResponse(value) => { + Self::create_fbs_consumer_get_stats_response(builder, value) + } + Self::FbsConsumerSetPreferredLayersResponse(value) => { + Self::create_fbs_consumer_set_preferred_layers_response(builder, value) + } + Self::FbsConsumerSetPriorityResponse(value) => { + Self::create_fbs_consumer_set_priority_response(builder, value) + } + Self::FbsDataProducerDumpResponse(value) => { + Self::create_fbs_data_producer_dump_response(builder, value) + } + Self::FbsDataProducerGetStatsResponse(value) => { + Self::create_fbs_data_producer_get_stats_response(builder, value) + } + Self::FbsDataConsumerGetBufferedAmountResponse(value) => { + Self::create_fbs_data_consumer_get_buffered_amount_response( + builder, value, + ) + } + Self::FbsDataConsumerDumpResponse(value) => { + Self::create_fbs_data_consumer_dump_response(builder, value) + } + Self::FbsDataConsumerGetStatsResponse(value) => { + Self::create_fbs_data_consumer_get_stats_response(builder, value) + } + } + } + } + + impl ::planus::WriteAsOptionalUnion for Body { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + } + } + + #[derive(Copy, Clone, Debug)] + pub enum BodyRef<'a> { + FbsWorkerDumpResponse(super::worker::DumpResponseRef<'a>), + FbsWorkerResourceUsageResponse(super::worker::ResourceUsageResponseRef<'a>), + FbsWebRtcServerDumpResponse(super::web_rtc_server::DumpResponseRef<'a>), + FbsRouterDumpResponse(super::router::DumpResponseRef<'a>), + FbsTransportProduceResponse(super::transport::ProduceResponseRef<'a>), + FbsTransportConsumeResponse(super::transport::ConsumeResponseRef<'a>), + FbsTransportRestartIceResponse(super::transport::RestartIceResponseRef<'a>), + FbsPlainTransportConnectResponse(super::plain_transport::ConnectResponseRef<'a>), + FbsPlainTransportDumpResponse(super::plain_transport::DumpResponseRef<'a>), + FbsPlainTransportGetStatsResponse(super::plain_transport::GetStatsResponseRef<'a>), + FbsPipeTransportConnectResponse(super::pipe_transport::ConnectResponseRef<'a>), + FbsPipeTransportDumpResponse(super::pipe_transport::DumpResponseRef<'a>), + FbsPipeTransportGetStatsResponse(super::pipe_transport::GetStatsResponseRef<'a>), + FbsDirectTransportDumpResponse(super::direct_transport::DumpResponseRef<'a>), + FbsDirectTransportGetStatsResponse( + super::direct_transport::GetStatsResponseRef<'a>, + ), + FbsWebRtcTransportConnectResponse(super::web_rtc_transport::ConnectResponseRef<'a>), + FbsWebRtcTransportDumpResponse(super::web_rtc_transport::DumpResponseRef<'a>), + FbsWebRtcTransportGetStatsResponse( + super::web_rtc_transport::GetStatsResponseRef<'a>, + ), + FbsProducerDumpResponse(super::producer::DumpResponseRef<'a>), + FbsProducerGetStatsResponse(super::producer::GetStatsResponseRef<'a>), + FbsConsumerDumpResponse(super::consumer::DumpResponseRef<'a>), + FbsConsumerGetStatsResponse(super::consumer::GetStatsResponseRef<'a>), + FbsConsumerSetPreferredLayersResponse( + super::consumer::SetPreferredLayersResponseRef<'a>, + ), + FbsConsumerSetPriorityResponse(super::consumer::SetPriorityResponseRef<'a>), + FbsDataProducerDumpResponse(super::data_producer::DumpResponseRef<'a>), + FbsDataProducerGetStatsResponse(super::data_producer::GetStatsResponseRef<'a>), + FbsDataConsumerGetBufferedAmountResponse( + super::data_consumer::GetBufferedAmountResponseRef<'a>, + ), + FbsDataConsumerDumpResponse(super::data_consumer::DumpResponseRef<'a>), + FbsDataConsumerGetStatsResponse(super::data_consumer::GetStatsResponseRef<'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::FbsWorkerDumpResponse(value) => { + Body::FbsWorkerDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsWorkerResourceUsageResponse(value) => { + Body::FbsWorkerResourceUsageResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsWebRtcServerDumpResponse(value) => { + Body::FbsWebRtcServerDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsRouterDumpResponse(value) => { + Body::FbsRouterDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsTransportProduceResponse(value) => { + Body::FbsTransportProduceResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsTransportConsumeResponse(value) => { + Body::FbsTransportConsumeResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsTransportRestartIceResponse(value) => { + Body::FbsTransportRestartIceResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsPlainTransportConnectResponse(value) => { + Body::FbsPlainTransportConnectResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::FbsPlainTransportDumpResponse(value) => { + Body::FbsPlainTransportDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsPlainTransportGetStatsResponse(value) => { + Body::FbsPlainTransportGetStatsResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::FbsPipeTransportConnectResponse(value) => { + Body::FbsPipeTransportConnectResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsPipeTransportDumpResponse(value) => { + Body::FbsPipeTransportDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsPipeTransportGetStatsResponse(value) => { + Body::FbsPipeTransportGetStatsResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::FbsDirectTransportDumpResponse(value) => { + Body::FbsDirectTransportDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsDirectTransportGetStatsResponse(value) => { + Body::FbsDirectTransportGetStatsResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::FbsWebRtcTransportConnectResponse(value) => { + Body::FbsWebRtcTransportConnectResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::FbsWebRtcTransportDumpResponse(value) => { + Body::FbsWebRtcTransportDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsWebRtcTransportGetStatsResponse(value) => { + Body::FbsWebRtcTransportGetStatsResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::FbsProducerDumpResponse(value) => { + Body::FbsProducerDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsProducerGetStatsResponse(value) => { + Body::FbsProducerGetStatsResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsConsumerDumpResponse(value) => { + Body::FbsConsumerDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsConsumerGetStatsResponse(value) => { + Body::FbsConsumerGetStatsResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsConsumerSetPreferredLayersResponse(value) => { + Body::FbsConsumerSetPreferredLayersResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::FbsConsumerSetPriorityResponse(value) => { + Body::FbsConsumerSetPriorityResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsDataProducerDumpResponse(value) => { + Body::FbsDataProducerDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsDataProducerGetStatsResponse(value) => { + Body::FbsDataProducerGetStatsResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsDataConsumerGetBufferedAmountResponse(value) => { + Body::FbsDataConsumerGetBufferedAmountResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::FbsDataConsumerDumpResponse(value) => { + Body::FbsDataConsumerDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::FbsDataConsumerGetStatsResponse(value) => { + Body::FbsDataConsumerGetStatsResponse(::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::FbsWorkerDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 2 => ::core::result::Result::Ok(Self::FbsWorkerResourceUsageResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 3 => ::core::result::Result::Ok(Self::FbsWebRtcServerDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 4 => ::core::result::Result::Ok(Self::FbsRouterDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 5 => ::core::result::Result::Ok(Self::FbsTransportProduceResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 6 => ::core::result::Result::Ok(Self::FbsTransportConsumeResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 7 => ::core::result::Result::Ok(Self::FbsTransportRestartIceResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 8 => ::core::result::Result::Ok(Self::FbsPlainTransportConnectResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 9 => ::core::result::Result::Ok(Self::FbsPlainTransportDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 10 => ::core::result::Result::Ok(Self::FbsPlainTransportGetStatsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 11 => ::core::result::Result::Ok(Self::FbsPipeTransportConnectResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 12 => ::core::result::Result::Ok(Self::FbsPipeTransportDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 13 => ::core::result::Result::Ok(Self::FbsPipeTransportGetStatsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 14 => ::core::result::Result::Ok(Self::FbsDirectTransportDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 15 => ::core::result::Result::Ok(Self::FbsDirectTransportGetStatsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 16 => ::core::result::Result::Ok(Self::FbsWebRtcTransportConnectResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 17 => ::core::result::Result::Ok(Self::FbsWebRtcTransportDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 18 => ::core::result::Result::Ok(Self::FbsWebRtcTransportGetStatsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 19 => ::core::result::Result::Ok(Self::FbsProducerDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 20 => ::core::result::Result::Ok(Self::FbsProducerGetStatsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 21 => ::core::result::Result::Ok(Self::FbsConsumerDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 22 => ::core::result::Result::Ok(Self::FbsConsumerGetStatsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 23 => { + ::core::result::Result::Ok(Self::FbsConsumerSetPreferredLayersResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )) + } + 24 => ::core::result::Result::Ok(Self::FbsConsumerSetPriorityResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 25 => ::core::result::Result::Ok(Self::FbsDataProducerDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 26 => ::core::result::Result::Ok(Self::FbsDataProducerGetStatsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 27 => ::core::result::Result::Ok( + Self::FbsDataConsumerGetBufferedAmountResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + ), + ), + 28 => ::core::result::Result::Ok(Self::FbsDataConsumerDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 29 => ::core::result::Result::Ok(Self::FbsDataConsumerGetStatsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + _ => ::core::result::Result::Err( + ::planus::errors::ErrorKind::UnknownUnionTag { tag }, + ), + } + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct Response { + pub id: u32, + pub accepted: bool, + pub body: ::core::option::Option, + pub error: ::core::option::Option<::planus::alloc::string::String>, + 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 { + #[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::<14, 18>::new(builder); + + if prepared_id.is_some() { + table_writer.calculate_size::(2); + } + if prepared_accepted.is_some() { + table_writer.calculate_size::(4); + } + if prepared_body.is_some() { + table_writer.calculate_size::(6); + table_writer.calculate_size::<::planus::Offset>(8); + } + if prepared_error.is_some() { + table_writer.calculate_size::<::planus::Offset>(10); + } + if prepared_reason.is_some() { + table_writer.calculate_size::<::planus::Offset>(12); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_id) = prepared_id { + table_writer.write::<_, _, 4>(0, &prepared_id); + } + if let ::core::option::Option::Some(prepared_body) = prepared_body { + table_writer.write::<_, _, 4>(3, &prepared_body.offset()); + } + if let ::core::option::Option::Some(prepared_error) = prepared_error { + table_writer.write::<_, _, 4>(4, &prepared_error); + } + if let ::core::option::Option::Some(prepared_reason) = prepared_reason { + table_writer.write::<_, _, 4>(5, &prepared_reason); + } + if let ::core::option::Option::Some(prepared_accepted) = prepared_accepted { + table_writer.write::<_, _, 1>(1, &prepared_accepted); + } + if let ::core::option::Option::Some(prepared_body) = prepared_body { + table_writer.write::<_, _, 1>(2, &prepared_body.tag()); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Response { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Response::create( + builder, + &self.id, + &self.accepted, + &self.body, + &self.error, + &self.reason, + ) + } + } + + #[derive(Copy, Clone)] + pub struct ResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ResponseRef<'a> { + pub fn id(&self) -> ::planus::Result { + ::core::result::Result::Ok(self.0.access(0, "Response", "id")?.unwrap_or(0)) + } + + pub fn accepted(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(1, "Response", "accepted")?.unwrap_or(false), + ) + } + + pub fn body(&self) -> ::planus::Result<::core::option::Option>> { + self.0.access_union(2, "Response", "body") + } + + pub fn error( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(4, "Response", "error") + } + + 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> { + 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; + 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) + }) + } + } + } + pub mod worker { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ChannelMessageHandlers { + pub channel_request_handlers: ::core::option::Option< + ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + >, + pub channel_notification_handlers: ::core::option::Option< + ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + >, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for ChannelMessageHandlers { + fn default() -> Self { + Self { + channel_request_handlers: ::core::default::Default::default(), + channel_notification_handlers: ::core::default::Default::default(), + } + } + } + + impl ChannelMessageHandlers { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_channel_request_handlers: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_channel_notification_handlers: impl ::planus::WriteAsOptional< + ::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::<6, 8>::new(builder); + + if prepared_channel_request_handlers.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); + } + if prepared_channel_notification_handlers.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_channel_request_handlers) = + prepared_channel_request_handlers + { + table_writer.write::<_, _, 4>(0, &prepared_channel_request_handlers); + } + if let ::core::option::Option::Some( + prepared_channel_notification_handlers, + ) = prepared_channel_notification_handlers + { + table_writer + .write::<_, _, 4>(1, &prepared_channel_notification_handlers); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ChannelMessageHandlers { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ChannelMessageHandlers::create( + builder, + &self.channel_request_handlers, + &self.channel_notification_handlers, + ) + } + } + + #[derive(Copy, Clone)] + pub struct ChannelMessageHandlersRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ChannelMessageHandlersRef<'a> { + pub fn channel_request_handlers( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + >, + > { + self.0 + .access(0, "ChannelMessageHandlers", "channel_request_handlers") + } + + pub fn channel_notification_handlers( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + >, + > { + self.0 + .access(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"); + if let ::core::option::Option::Some(field_channel_request_handlers) = + self.channel_request_handlers().transpose() + { + f.field("channel_request_handlers", &field_channel_request_handlers); + } + if let ::core::option::Option::Some(field_channel_notification_handlers) = + self.channel_notification_handlers().transpose() + { + f.field( + "channel_notification_handlers", + &field_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: if let ::core::option::Option::Some( + channel_request_handlers, + ) = value.channel_request_handlers()? + { + ::core::option::Option::Some(channel_request_handlers.to_vec_result()?) + } else { + ::core::option::Option::None + }, + channel_notification_handlers: if let ::core::option::Option::Some( + channel_notification_handlers, + ) = + value.channel_notification_handlers()? + { + ::core::option::Option::Some( + channel_notification_handlers.to_vec_result()?, + ) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for ChannelMessageHandlersRef<'a> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct DumpResponse { + pub pid: u32, + pub web_rtc_server_ids: ::core::option::Option< + ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + >, + pub router_ids: ::core::option::Option< + ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + >, + pub channel_message_handlers: ::core::option::Option< + ::planus::alloc::boxed::Box, + >, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for DumpResponse { + fn default() -> Self { + Self { + pid: 0, + web_rtc_server_ids: ::core::default::Default::default(), + router_ids: ::core::default::Default::default(), + channel_message_handlers: ::core::default::Default::default(), + } + } + } + + impl DumpResponse { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_pid: impl ::planus::WriteAsDefault, + field_web_rtc_server_ids: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_router_ids: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_channel_message_handlers: impl ::planus::WriteAsOptional< + ::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::<10, 16>::new(builder); + + if prepared_pid.is_some() { + table_writer.calculate_size::(2); + } + if prepared_web_rtc_server_ids.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); + } + if prepared_router_ids.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(6); + } + if prepared_channel_message_handlers.is_some() { + table_writer + .calculate_size::<::planus::Offset>(8); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_pid) = prepared_pid { + table_writer.write::<_, _, 4>(0, &prepared_pid); + } + if let ::core::option::Option::Some(prepared_web_rtc_server_ids) = + prepared_web_rtc_server_ids + { + table_writer.write::<_, _, 4>(1, &prepared_web_rtc_server_ids); + } + if let ::core::option::Option::Some(prepared_router_ids) = + prepared_router_ids + { + table_writer.write::<_, _, 4>(2, &prepared_router_ids); + } + if let ::core::option::Option::Some(prepared_channel_message_handlers) = + prepared_channel_message_handlers + { + table_writer.write::<_, _, 4>(3, &prepared_channel_message_handlers); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DumpResponseRef<'a> { + pub fn pid(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(0, "DumpResponse", "pid")?.unwrap_or(0), + ) + } + + pub fn web_rtc_server_ids( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + >, + > { + self.0.access(1, "DumpResponse", "web_rtc_server_ids") + } + + pub fn router_ids( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + >, + > { + self.0.access(2, "DumpResponse", "router_ids") + } + + pub fn channel_message_handlers( + &self, + ) -> ::planus::Result<::core::option::Option>> + { + self.0.access(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()); + if let ::core::option::Option::Some(field_web_rtc_server_ids) = + self.web_rtc_server_ids().transpose() + { + f.field("web_rtc_server_ids", &field_web_rtc_server_ids); + } + if let ::core::option::Option::Some(field_router_ids) = + self.router_ids().transpose() + { + f.field("router_ids", &field_router_ids); + } + if let ::core::option::Option::Some(field_channel_message_handlers) = + self.channel_message_handlers().transpose() + { + f.field("channel_message_handlers", &field_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: if let ::core::option::Option::Some( + web_rtc_server_ids, + ) = value.web_rtc_server_ids()? + { + ::core::option::Option::Some(web_rtc_server_ids.to_vec_result()?) + } else { + ::core::option::Option::None + }, + router_ids: if let ::core::option::Option::Some(router_ids) = + value.router_ids()? + { + ::core::option::Option::Some(router_ids.to_vec_result()?) + } else { + ::core::option::Option::None + }, + channel_message_handlers: if let ::core::option::Option::Some( + channel_message_handlers, + ) = value.channel_message_handlers()? + { + ::core::option::Option::Some(::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(channel_message_handlers)?, + )) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ResourceUsageResponse { + pub ru_utime: u64, + pub ru_stime: u64, + pub ru_maxrss: u64, + pub ru_ixrss: u64, + pub ru_idrss: u64, + pub ru_isrss: u64, + pub ru_minflt: u64, + pub ru_majflt: u64, + pub ru_nswap: u64, + pub ru_inblock: u64, + pub ru_oublock: u64, + pub ru_msgsnd: u64, + pub ru_msgrcv: u64, + pub ru_nsignals: u64, + pub ru_nvcsw: u64, + 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 { + #[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::<34, 128>::new(builder); + + if prepared_ru_utime.is_some() { + table_writer.calculate_size::(2); + } + if prepared_ru_stime.is_some() { + table_writer.calculate_size::(4); + } + if prepared_ru_maxrss.is_some() { + table_writer.calculate_size::(6); + } + if prepared_ru_ixrss.is_some() { + table_writer.calculate_size::(8); + } + if prepared_ru_idrss.is_some() { + table_writer.calculate_size::(10); + } + if prepared_ru_isrss.is_some() { + table_writer.calculate_size::(12); + } + if prepared_ru_minflt.is_some() { + table_writer.calculate_size::(14); + } + if prepared_ru_majflt.is_some() { + table_writer.calculate_size::(16); + } + if prepared_ru_nswap.is_some() { + table_writer.calculate_size::(18); + } + if prepared_ru_inblock.is_some() { + table_writer.calculate_size::(20); + } + if prepared_ru_oublock.is_some() { + table_writer.calculate_size::(22); + } + if prepared_ru_msgsnd.is_some() { + table_writer.calculate_size::(24); + } + if prepared_ru_msgrcv.is_some() { + table_writer.calculate_size::(26); + } + if prepared_ru_nsignals.is_some() { + table_writer.calculate_size::(28); + } + if prepared_ru_nvcsw.is_some() { + table_writer.calculate_size::(30); + } + if prepared_ru_nivcsw.is_some() { + table_writer.calculate_size::(32); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_ru_utime) = prepared_ru_utime { + table_writer.write::<_, _, 8>(0, &prepared_ru_utime); + } + if let ::core::option::Option::Some(prepared_ru_stime) = prepared_ru_stime { + table_writer.write::<_, _, 8>(1, &prepared_ru_stime); + } + if let ::core::option::Option::Some(prepared_ru_maxrss) = prepared_ru_maxrss + { + table_writer.write::<_, _, 8>(2, &prepared_ru_maxrss); + } + if let ::core::option::Option::Some(prepared_ru_ixrss) = prepared_ru_ixrss { + table_writer.write::<_, _, 8>(3, &prepared_ru_ixrss); + } + if let ::core::option::Option::Some(prepared_ru_idrss) = prepared_ru_idrss { + table_writer.write::<_, _, 8>(4, &prepared_ru_idrss); + } + if let ::core::option::Option::Some(prepared_ru_isrss) = prepared_ru_isrss { + table_writer.write::<_, _, 8>(5, &prepared_ru_isrss); + } + if let ::core::option::Option::Some(prepared_ru_minflt) = prepared_ru_minflt + { + table_writer.write::<_, _, 8>(6, &prepared_ru_minflt); + } + if let ::core::option::Option::Some(prepared_ru_majflt) = prepared_ru_majflt + { + table_writer.write::<_, _, 8>(7, &prepared_ru_majflt); + } + if let ::core::option::Option::Some(prepared_ru_nswap) = prepared_ru_nswap { + table_writer.write::<_, _, 8>(8, &prepared_ru_nswap); + } + if let ::core::option::Option::Some(prepared_ru_inblock) = + prepared_ru_inblock + { + table_writer.write::<_, _, 8>(9, &prepared_ru_inblock); + } + if let ::core::option::Option::Some(prepared_ru_oublock) = + prepared_ru_oublock + { + table_writer.write::<_, _, 8>(10, &prepared_ru_oublock); + } + if let ::core::option::Option::Some(prepared_ru_msgsnd) = prepared_ru_msgsnd + { + table_writer.write::<_, _, 8>(11, &prepared_ru_msgsnd); + } + if let ::core::option::Option::Some(prepared_ru_msgrcv) = prepared_ru_msgrcv + { + table_writer.write::<_, _, 8>(12, &prepared_ru_msgrcv); + } + if let ::core::option::Option::Some(prepared_ru_nsignals) = + prepared_ru_nsignals + { + table_writer.write::<_, _, 8>(13, &prepared_ru_nsignals); + } + if let ::core::option::Option::Some(prepared_ru_nvcsw) = prepared_ru_nvcsw { + table_writer.write::<_, _, 8>(14, &prepared_ru_nvcsw); + } + if let ::core::option::Option::Some(prepared_ru_nivcsw) = prepared_ru_nivcsw + { + table_writer.write::<_, _, 8>(15, &prepared_ru_nivcsw); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ResourceUsageResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct ResourceUsageResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ResourceUsageResponseRef<'a> { + pub fn ru_utime(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "ResourceUsageResponse", "ru_utime")? + .unwrap_or(0), + ) + } + + pub fn ru_stime(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "ResourceUsageResponse", "ru_stime")? + .unwrap_or(0), + ) + } + + pub fn ru_maxrss(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "ResourceUsageResponse", "ru_maxrss")? + .unwrap_or(0), + ) + } + + pub fn ru_ixrss(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(3, "ResourceUsageResponse", "ru_ixrss")? + .unwrap_or(0), + ) + } + + pub fn ru_idrss(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(4, "ResourceUsageResponse", "ru_idrss")? + .unwrap_or(0), + ) + } + + pub fn ru_isrss(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(5, "ResourceUsageResponse", "ru_isrss")? + .unwrap_or(0), + ) + } + + pub fn ru_minflt(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(6, "ResourceUsageResponse", "ru_minflt")? + .unwrap_or(0), + ) + } + + pub fn ru_majflt(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(7, "ResourceUsageResponse", "ru_majflt")? + .unwrap_or(0), + ) + } + + pub fn ru_nswap(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(8, "ResourceUsageResponse", "ru_nswap")? + .unwrap_or(0), + ) + } + + pub fn ru_inblock(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(9, "ResourceUsageResponse", "ru_inblock")? + .unwrap_or(0), + ) + } + + pub fn ru_oublock(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(10, "ResourceUsageResponse", "ru_oublock")? + .unwrap_or(0), + ) + } + + pub fn ru_msgsnd(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(11, "ResourceUsageResponse", "ru_msgsnd")? + .unwrap_or(0), + ) + } + + pub fn ru_msgrcv(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(12, "ResourceUsageResponse", "ru_msgrcv")? + .unwrap_or(0), + ) + } + + pub fn ru_nsignals(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(13, "ResourceUsageResponse", "ru_nsignals")? + .unwrap_or(0), + ) + } + + pub fn ru_nvcsw(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(14, "ResourceUsageResponse", "ru_nvcsw")? + .unwrap_or(0), + ) + } + + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct UpdateSettingsRequest { + pub log_level: ::core::option::Option<::planus::alloc::string::String>, + 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 { + #[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::<6, 8>::new(builder); + + if prepared_log_level.is_some() { + table_writer.calculate_size::<::planus::Offset>(2); + } + if prepared_log_tags.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_log_level) = prepared_log_level + { + table_writer.write::<_, _, 4>(0, &prepared_log_level); + } + if let ::core::option::Option::Some(prepared_log_tags) = prepared_log_tags { + table_writer.write::<_, _, 4>(1, &prepared_log_tags); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for UpdateSettingsRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + UpdateSettingsRequest::create(builder, &self.log_level, &self.log_tags) + } + } + + #[derive(Copy, Clone)] + pub struct UpdateSettingsRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> UpdateSettingsRequestRef<'a> { + pub fn log_level( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(0, "UpdateSettingsRequest", "log_level") + } + + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CreateWebRtcServerRequest { + pub web_rtc_server_id: ::planus::alloc::string::String, + pub listen_infos: ::core::option::Option< + ::planus::alloc::vec::Vec, + >, + } + + impl CreateWebRtcServerRequest { + #[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::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_listen_infos.is_some() { + table_writer.calculate_size::<::planus::Offset< + [::planus::Offset], + >>(4); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_web_rtc_server_id); + if let ::core::option::Option::Some(prepared_listen_infos) = + prepared_listen_infos + { + table_writer.write::<_, _, 4>(1, &prepared_listen_infos); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for CreateWebRtcServerRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CreateWebRtcServerRequest::create( + builder, + &self.web_rtc_server_id, + &self.listen_infos, + ) + } + } + + #[derive(Copy, Clone)] + pub struct CreateWebRtcServerRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CreateWebRtcServerRequestRef<'a> { + pub fn web_rtc_server_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(0, "CreateWebRtcServerRequest", "web_rtc_server_id") + } + + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CloseWebRtcServerRequest { + pub web_rtc_server_id: ::planus::alloc::string::String, + } + + impl CloseWebRtcServerRequest { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_web_rtc_server_id); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for CloseWebRtcServerRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CloseWebRtcServerRequest::create(builder, &self.web_rtc_server_id) + } + } + + #[derive(Copy, Clone)] + pub struct CloseWebRtcServerRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CloseWebRtcServerRequestRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CreateRouterRequest { + pub router_id: ::planus::alloc::string::String, + } + + impl CreateRouterRequest { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_router_id); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for CreateRouterRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CreateRouterRequest::create(builder, &self.router_id) + } + } + + #[derive(Copy, Clone)] + pub struct CreateRouterRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CreateRouterRequestRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CloseRouterRequest { + pub router_id: ::planus::alloc::string::String, + } + + impl CloseRouterRequest { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_router_id); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for CloseRouterRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CloseRouterRequest::create(builder, &self.router_id) + } + } + + #[derive(Copy, Clone)] + pub struct CloseRouterRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CloseRouterRequestRef<'a> { + 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> { + 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; + 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) + }) + } + } + } + pub mod router { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct DumpResponse { + pub id: ::planus::alloc::string::String, + pub transport_ids: ::core::option::Option< + ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + >, + pub rtp_observer_ids: ::core::option::Option< + ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + >, + pub map_producer_id_consumer_ids: ::core::option::Option< + ::planus::alloc::vec::Vec, + >, + pub map_consumer_id_producer_id: + ::core::option::Option<::planus::alloc::vec::Vec>, + pub map_producer_id_observer_ids: ::core::option::Option< + ::planus::alloc::vec::Vec, + >, + pub map_data_producer_id_data_consumer_ids: ::core::option::Option< + ::planus::alloc::vec::Vec, + >, + pub map_data_consumer_id_data_producer_id: + ::core::option::Option<::planus::alloc::vec::Vec>, + } + + impl DumpResponse { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_id: impl ::planus::WriteAs<::planus::Offset>, + field_transport_ids: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_rtp_observer_ids: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_map_producer_id_consumer_ids: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_map_consumer_id_producer_id: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_map_producer_id_observer_ids: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_map_data_producer_id_data_consumer_ids: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_map_data_consumer_id_data_producer_id: impl ::planus::WriteAsOptional< + ::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::<18, 32>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_transport_ids.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); + } + if prepared_rtp_observer_ids.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(6); + } + if prepared_map_producer_id_consumer_ids.is_some() { + table_writer.calculate_size::<::planus::Offset< + [::planus::Offset], + >>(8); + } + if prepared_map_consumer_id_producer_id.is_some() { + table_writer.calculate_size::<::planus::Offset< + [::planus::Offset], + >>(10); + } + if prepared_map_producer_id_observer_ids.is_some() { + table_writer.calculate_size::<::planus::Offset< + [::planus::Offset], + >>(12); + } + if prepared_map_data_producer_id_data_consumer_ids.is_some() { + table_writer.calculate_size::<::planus::Offset< + [::planus::Offset], + >>(14); + } + if prepared_map_data_consumer_id_data_producer_id.is_some() { + table_writer.calculate_size::<::planus::Offset< + [::planus::Offset], + >>(16); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_id); + if let ::core::option::Option::Some(prepared_transport_ids) = + prepared_transport_ids + { + table_writer.write::<_, _, 4>(1, &prepared_transport_ids); + } + if let ::core::option::Option::Some(prepared_rtp_observer_ids) = + prepared_rtp_observer_ids + { + table_writer.write::<_, _, 4>(2, &prepared_rtp_observer_ids); + } + if let ::core::option::Option::Some(prepared_map_producer_id_consumer_ids) = + prepared_map_producer_id_consumer_ids + { + table_writer + .write::<_, _, 4>(3, &prepared_map_producer_id_consumer_ids); + } + if let ::core::option::Option::Some(prepared_map_consumer_id_producer_id) = + prepared_map_consumer_id_producer_id + { + table_writer.write::<_, _, 4>(4, &prepared_map_consumer_id_producer_id); + } + if let ::core::option::Option::Some(prepared_map_producer_id_observer_ids) = + prepared_map_producer_id_observer_ids + { + table_writer + .write::<_, _, 4>(5, &prepared_map_producer_id_observer_ids); + } + if let ::core::option::Option::Some( + prepared_map_data_producer_id_data_consumer_ids, + ) = prepared_map_data_producer_id_data_consumer_ids + { + table_writer.write::<_, _, 4>( + 6, + &prepared_map_data_producer_id_data_consumer_ids, + ); + } + if let ::core::option::Option::Some( + prepared_map_data_consumer_id_data_producer_id, + ) = prepared_map_data_consumer_id_data_producer_id + { + table_writer.write::<_, _, 4>( + 7, + &prepared_map_data_consumer_id_data_producer_id, + ); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DumpResponseRef<'a> { + pub fn id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "DumpResponse", "id") + } + + pub fn transport_ids( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + >, + > { + self.0.access(1, "DumpResponse", "transport_ids") + } + + pub fn rtp_observer_ids( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + >, + > { + self.0.access(2, "DumpResponse", "rtp_observer_ids") + } + + pub fn map_producer_id_consumer_ids( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector< + 'a, + ::planus::Result>, + >, + >, + > { + self.0 + .access(3, "DumpResponse", "map_producer_id_consumer_ids") + } + + pub fn map_consumer_id_producer_id( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, + > { + self.0 + .access(4, "DumpResponse", "map_consumer_id_producer_id") + } + + pub fn map_producer_id_observer_ids( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector< + 'a, + ::planus::Result>, + >, + >, + > { + self.0 + .access(5, "DumpResponse", "map_producer_id_observer_ids") + } + + pub fn map_data_producer_id_data_consumer_ids( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector< + 'a, + ::planus::Result>, + >, + >, + > { + self.0 + .access(6, "DumpResponse", "map_data_producer_id_data_consumer_ids") + } + + pub fn map_data_consumer_id_data_producer_id( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, + > { + self.0 + .access(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()); + if let ::core::option::Option::Some(field_transport_ids) = + self.transport_ids().transpose() + { + f.field("transport_ids", &field_transport_ids); + } + if let ::core::option::Option::Some(field_rtp_observer_ids) = + self.rtp_observer_ids().transpose() + { + f.field("rtp_observer_ids", &field_rtp_observer_ids); + } + if let ::core::option::Option::Some(field_map_producer_id_consumer_ids) = + self.map_producer_id_consumer_ids().transpose() + { + f.field( + "map_producer_id_consumer_ids", + &field_map_producer_id_consumer_ids, + ); + } + if let ::core::option::Option::Some(field_map_consumer_id_producer_id) = + self.map_consumer_id_producer_id().transpose() + { + f.field( + "map_consumer_id_producer_id", + &field_map_consumer_id_producer_id, + ); + } + if let ::core::option::Option::Some(field_map_producer_id_observer_ids) = + self.map_producer_id_observer_ids().transpose() + { + f.field( + "map_producer_id_observer_ids", + &field_map_producer_id_observer_ids, + ); + } + if let ::core::option::Option::Some( + field_map_data_producer_id_data_consumer_ids, + ) = self.map_data_producer_id_data_consumer_ids().transpose() + { + f.field( + "map_data_producer_id_data_consumer_ids", + &field_map_data_producer_id_data_consumer_ids, + ); + } + if let ::core::option::Option::Some( + field_map_data_consumer_id_data_producer_id, + ) = self.map_data_consumer_id_data_producer_id().transpose() + { + f.field( + "map_data_consumer_id_data_producer_id", + &field_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: if let ::core::option::Option::Some(transport_ids) = + value.transport_ids()? + { + ::core::option::Option::Some(transport_ids.to_vec_result()?) + } else { + ::core::option::Option::None + }, + rtp_observer_ids: if let ::core::option::Option::Some(rtp_observer_ids) = + value.rtp_observer_ids()? + { + ::core::option::Option::Some(rtp_observer_ids.to_vec_result()?) + } else { + ::core::option::Option::None + }, + map_producer_id_consumer_ids: if let ::core::option::Option::Some( + map_producer_id_consumer_ids, + ) = value.map_producer_id_consumer_ids()? + { + ::core::option::Option::Some( + map_producer_id_consumer_ids.to_vec_result()?, + ) + } else { + ::core::option::Option::None + }, + map_consumer_id_producer_id: if let ::core::option::Option::Some( + map_consumer_id_producer_id, + ) = value.map_consumer_id_producer_id()? + { + ::core::option::Option::Some( + map_consumer_id_producer_id.to_vec_result()?, + ) + } else { + ::core::option::Option::None + }, + map_producer_id_observer_ids: if let ::core::option::Option::Some( + map_producer_id_observer_ids, + ) = value.map_producer_id_observer_ids()? + { + ::core::option::Option::Some( + map_producer_id_observer_ids.to_vec_result()?, + ) + } else { + ::core::option::Option::None + }, + map_data_producer_id_data_consumer_ids: + if let ::core::option::Option::Some( + map_data_producer_id_data_consumer_ids, + ) = value.map_data_producer_id_data_consumer_ids()? + { + ::core::option::Option::Some( + map_data_producer_id_data_consumer_ids.to_vec_result()?, + ) + } else { + ::core::option::Option::None + }, + map_data_consumer_id_data_producer_id: if let ::core::option::Option::Some( + map_data_consumer_id_data_producer_id, + ) = + value.map_data_consumer_id_data_producer_id()? + { + ::core::option::Option::Some( + map_data_consumer_id_data_producer_id.to_vec_result()?, + ) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CreatePipeTransportRequest { + pub transport_id: ::planus::alloc::string::String, + pub options: + ::planus::alloc::boxed::Box, + } + + impl CreatePipeTransportRequest { + #[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::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_transport_id); + table_writer.write::<_, _, 4>(1, &prepared_options); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for CreatePipeTransportRequest + { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CreatePipeTransportRequest::create(builder, &self.transport_id, &self.options) + } + } + + #[derive(Copy, Clone)] + pub struct CreatePipeTransportRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CreatePipeTransportRequestRef<'a> { + pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(0, "CreatePipeTransportRequest", "transport_id") + } + + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CreatePlainTransportRequest { + pub transport_id: ::planus::alloc::string::String, + pub options: + ::planus::alloc::boxed::Box, + } + + impl CreatePlainTransportRequest { + #[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::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_transport_id); + table_writer.write::<_, _, 4>(1, &prepared_options); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for CreatePlainTransportRequest + { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CreatePlainTransportRequest::create(builder, &self.transport_id, &self.options) + } + } + + #[derive(Copy, Clone)] + pub struct CreatePlainTransportRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CreatePlainTransportRequestRef<'a> { + pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(0, "CreatePlainTransportRequest", "transport_id") + } + + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CreateWebRtcTransportRequest { + pub transport_id: ::planus::alloc::string::String, + pub options: + ::planus::alloc::boxed::Box, + } + + impl CreateWebRtcTransportRequest { + #[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::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_transport_id); + table_writer.write::<_, _, 4>(1, &prepared_options); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for CreateWebRtcTransportRequest + { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CreateWebRtcTransportRequest::create(builder, &self.transport_id, &self.options) + } + } + + #[derive(Copy, Clone)] + pub struct CreateWebRtcTransportRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CreateWebRtcTransportRequestRef<'a> { + pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(0, "CreateWebRtcTransportRequest", "transport_id") + } + + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CreateDirectTransportRequest { + pub transport_id: ::planus::alloc::string::String, + pub options: + ::planus::alloc::boxed::Box, + } + + impl CreateDirectTransportRequest { + #[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::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_transport_id); + table_writer.write::<_, _, 4>(1, &prepared_options); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for CreateDirectTransportRequest + { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CreateDirectTransportRequest::create(builder, &self.transport_id, &self.options) + } + } + + #[derive(Copy, Clone)] + pub struct CreateDirectTransportRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CreateDirectTransportRequestRef<'a> { + pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(0, "CreateDirectTransportRequest", "transport_id") + } + + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CreateAudioLevelObserverRequest { + pub rtp_observer_id: ::planus::alloc::string::String, + pub options: ::planus::alloc::boxed::Box< + super::audio_level_observer::AudioLevelObserverOptions, + >, + } + + impl CreateAudioLevelObserverRequest { + #[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::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset< + super::audio_level_observer::AudioLevelObserverOptions, + >>(4); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_rtp_observer_id); + table_writer.write::<_, _, 4>(1, &prepared_options); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for CreateAudioLevelObserverRequest + { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CreateAudioLevelObserverRequest::create( + builder, + &self.rtp_observer_id, + &self.options, + ) + } + } + + #[derive(Copy, Clone)] + pub struct CreateAudioLevelObserverRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CreateAudioLevelObserverRequestRef<'a> { + pub fn rtp_observer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(0, "CreateAudioLevelObserverRequest", "rtp_observer_id") + } + + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CreateActiveSpeakerObserverRequest { + pub active_speaker_observer_id: ::planus::alloc::string::String, + pub options: ::planus::alloc::boxed::Box< + super::active_speaker_observer::ActiveSpeakerObserverOptions, + >, + } + + impl CreateActiveSpeakerObserverRequest { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_active_speaker_observer_id: impl ::planus::WriteAs<::planus::Offset>, + field_options: impl ::planus::WriteAs< + ::planus::Offset< + super::active_speaker_observer::ActiveSpeakerObserverOptions, + >, + >, + ) -> ::planus::Offset { + let prepared_active_speaker_observer_id = + field_active_speaker_observer_id.prepare(builder); + + let prepared_options = field_options.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset< + super::active_speaker_observer::ActiveSpeakerObserverOptions, + >>(4); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_active_speaker_observer_id); + table_writer.write::<_, _, 4>(1, &prepared_options); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for CreateActiveSpeakerObserverRequest + { + type Prepared = ::planus::Offset; + + 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; + + 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 + { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CreateActiveSpeakerObserverRequest::create( + builder, + &self.active_speaker_observer_id, + &self.options, + ) + } + } + + #[derive(Copy, Clone)] + pub struct CreateActiveSpeakerObserverRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CreateActiveSpeakerObserverRequestRef<'a> { + pub fn active_speaker_observer_id( + &self, + ) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required( + 0, + "CreateActiveSpeakerObserverRequest", + "active_speaker_observer_id", + ) + } + + 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( + "active_speaker_observer_id", + &self.active_speaker_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 { + active_speaker_observer_id: ::core::convert::TryInto::try_into( + value.active_speaker_observer_id()?, + )?, + options: ::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(value.options()?)?, + ), + }) + } + } + + impl<'a> ::planus::TableRead<'a> for CreateActiveSpeakerObserverRequestRef<'a> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CloseTransportRequest { + pub transport_id: ::planus::alloc::string::String, + } + + impl CloseTransportRequest { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_transport_id); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for CloseTransportRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CloseTransportRequest::create(builder, &self.transport_id) + } + } + + #[derive(Copy, Clone)] + pub struct CloseTransportRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CloseTransportRequestRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct CloseRtpObserverRequest { + pub rtp_observer_id: ::planus::alloc::string::String, + } + + impl CloseRtpObserverRequest { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_rtp_observer_id); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for CloseRtpObserverRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CloseRtpObserverRequest::create(builder, &self.rtp_observer_id) + } + } + + #[derive(Copy, Clone)] + pub struct CloseRtpObserverRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> CloseRtpObserverRequestRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + } + pub mod web_rtc_server { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ListenInfo { + pub protocol: super::transport::Protocol, + pub ip: ::planus::alloc::string::String, + pub announced_ip: ::core::option::Option<::planus::alloc::string::String>, + pub port: u16, + } + + impl ListenInfo { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_protocol: impl ::planus::WriteAsDefault< + super::transport::Protocol, + super::transport::Protocol, + >, + field_ip: impl ::planus::WriteAs<::planus::Offset>, + field_announced_ip: impl ::planus::WriteAsOptional< + ::planus::Offset<::core::primitive::str>, + >, + field_port: impl ::planus::WriteAsDefault, + ) -> ::planus::Offset { + let prepared_protocol = + field_protocol.prepare(builder, &super::transport::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 mut table_writer = + ::planus::table_writer::TableWriter::<10, 11>::new(builder); + + if prepared_protocol.is_some() { + table_writer.calculate_size::(2); + } + table_writer.calculate_size::<::planus::Offset>(4); + if prepared_announced_ip.is_some() { + table_writer.calculate_size::<::planus::Offset>(6); + } + if prepared_port.is_some() { + table_writer.calculate_size::(8); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(1, &prepared_ip); + if let ::core::option::Option::Some(prepared_announced_ip) = + prepared_announced_ip + { + table_writer.write::<_, _, 4>(2, &prepared_announced_ip); + } + if let ::core::option::Option::Some(prepared_port) = prepared_port { + table_writer.write::<_, _, 2>(3, &prepared_port); + } + if let ::core::option::Option::Some(prepared_protocol) = prepared_protocol { + table_writer.write::<_, _, 1>(0, &prepared_protocol); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ListenInfo { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + ListenInfo::create( + builder, + &self.protocol, + &self.ip, + &self.announced_ip, + &self.port, + ) + } + } + + #[derive(Copy, Clone)] + pub struct ListenInfoRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ListenInfoRef<'a> { + pub fn protocol(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "ListenInfo", "protocol")? + .unwrap_or(super::transport::Protocol::Udp), + ) + } + + pub fn ip(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(1, "ListenInfo", "ip") + } + + pub fn announced_ip( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(2, "ListenInfo", "announced_ip") + } + + pub fn port(&self) -> ::planus::Result { + ::core::result::Result::Ok(self.0.access(3, "ListenInfo", "port")?.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.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()?)?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for ListenInfoRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct IpPort { + pub ip: ::planus::alloc::string::String, + pub port: u16, + } + + impl IpPort { + #[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::<6, 6>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_port.is_some() { + table_writer.calculate_size::(4); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_ip); + if let ::core::option::Option::Some(prepared_port) = prepared_port { + table_writer.write::<_, _, 2>(1, &prepared_port); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for IpPort { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + IpPort::create(builder, &self.ip, &self.port) + } + } + + #[derive(Copy, Clone)] + pub struct IpPortRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> IpPortRef<'a> { + pub fn ip(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "IpPort", "ip") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct IceUserNameFragment { + pub local_ice_username_fragment: ::planus::alloc::string::String, + pub web_rtc_transport_id: ::planus::alloc::string::String, + } + + impl IceUserNameFragment { + #[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::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_local_ice_username_fragment); + table_writer.write::<_, _, 4>(1, &prepared_web_rtc_transport_id); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for IceUserNameFragment { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + IceUserNameFragment::create( + builder, + &self.local_ice_username_fragment, + &self.web_rtc_transport_id, + ) + } + } + + #[derive(Copy, Clone)] + pub struct IceUserNameFragmentRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> IceUserNameFragmentRef<'a> { + pub fn local_ice_username_fragment( + &self, + ) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(0, "IceUserNameFragment", "local_ice_username_fragment") + } + + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct TupleHash { + pub local_ice_username_fragment: u64, + pub web_rtc_transport_id: ::planus::alloc::string::String, + } + + impl TupleHash { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_local_ice_username_fragment: impl ::planus::WriteAsDefault, + 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, &0); + + let prepared_web_rtc_transport_id = field_web_rtc_transport_id.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<6, 12>::new(builder); + + if prepared_local_ice_username_fragment.is_some() { + table_writer.calculate_size::(2); + } + table_writer.calculate_size::<::planus::Offset>(4); + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_local_ice_username_fragment) = + prepared_local_ice_username_fragment + { + table_writer.write::<_, _, 8>(0, &prepared_local_ice_username_fragment); + } + table_writer.write::<_, _, 4>(1, &prepared_web_rtc_transport_id); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for TupleHash { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + TupleHash::create( + builder, + &self.local_ice_username_fragment, + &self.web_rtc_transport_id, + ) + } + } + + #[derive(Copy, Clone)] + pub struct TupleHashRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> TupleHashRef<'a> { + pub fn local_ice_username_fragment(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "TupleHash", "local_ice_username_fragment")? + .unwrap_or(0), + ) + } + + 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( + "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 TupleHash { + type Error = ::planus::Error; + + #[allow(unreachable_code)] + fn try_from(value: TupleHashRef<'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 TupleHashRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct DumpResponse { + pub id: ::planus::alloc::string::String, + pub udp_sockets: ::core::option::Option<::planus::alloc::vec::Vec>, + pub tcp_servers: ::core::option::Option<::planus::alloc::vec::Vec>, + pub web_rtc_transport_ids: ::core::option::Option< + ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + >, + pub local_ice_username_fragments: + ::core::option::Option<::planus::alloc::vec::Vec>, + pub tuple_hashes: + ::core::option::Option<::planus::alloc::vec::Vec>, + } + + impl DumpResponse { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_id: impl ::planus::WriteAs<::planus::Offset>, + field_udp_sockets: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_tcp_servers: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_web_rtc_transport_ids: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_local_ice_username_fragments: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_tuple_hashes: impl ::planus::WriteAsOptional< + ::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::<14, 24>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_udp_sockets.is_some() { + table_writer + .calculate_size::<::planus::Offset<[::planus::Offset]>>( + 4, + ); + } + if prepared_tcp_servers.is_some() { + table_writer + .calculate_size::<::planus::Offset<[::planus::Offset]>>( + 6, + ); + } + if prepared_web_rtc_transport_ids.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(8); + } + if prepared_local_ice_username_fragments.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(10); + } + if prepared_tuple_hashes.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(12); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_id); + if let ::core::option::Option::Some(prepared_udp_sockets) = + prepared_udp_sockets + { + table_writer.write::<_, _, 4>(1, &prepared_udp_sockets); + } + if let ::core::option::Option::Some(prepared_tcp_servers) = + prepared_tcp_servers + { + table_writer.write::<_, _, 4>(2, &prepared_tcp_servers); + } + if let ::core::option::Option::Some(prepared_web_rtc_transport_ids) = + prepared_web_rtc_transport_ids + { + table_writer.write::<_, _, 4>(3, &prepared_web_rtc_transport_ids); + } + if let ::core::option::Option::Some(prepared_local_ice_username_fragments) = + prepared_local_ice_username_fragments + { + table_writer + .write::<_, _, 4>(4, &prepared_local_ice_username_fragments); + } + if let ::core::option::Option::Some(prepared_tuple_hashes) = + prepared_tuple_hashes + { + table_writer.write::<_, _, 4>(5, &prepared_tuple_hashes); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DumpResponseRef<'a> { + pub fn id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "DumpResponse", "id") + } + + pub fn udp_sockets( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, + > { + self.0.access(1, "DumpResponse", "udp_sockets") + } + + pub fn tcp_servers( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, + > { + self.0.access(2, "DumpResponse", "tcp_servers") + } + + pub fn web_rtc_transport_ids( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + >, + > { + self.0.access(3, "DumpResponse", "web_rtc_transport_ids") + } + + pub fn local_ice_username_fragments( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, + > { + self.0 + .access(4, "DumpResponse", "local_ice_username_fragments") + } + + pub fn tuple_hashes( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, + > { + self.0.access(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()); + if let ::core::option::Option::Some(field_udp_sockets) = + self.udp_sockets().transpose() + { + f.field("udp_sockets", &field_udp_sockets); + } + if let ::core::option::Option::Some(field_tcp_servers) = + self.tcp_servers().transpose() + { + f.field("tcp_servers", &field_tcp_servers); + } + if let ::core::option::Option::Some(field_web_rtc_transport_ids) = + self.web_rtc_transport_ids().transpose() + { + f.field("web_rtc_transport_ids", &field_web_rtc_transport_ids); + } + if let ::core::option::Option::Some(field_local_ice_username_fragments) = + self.local_ice_username_fragments().transpose() + { + f.field( + "local_ice_username_fragments", + &field_local_ice_username_fragments, + ); + } + if let ::core::option::Option::Some(field_tuple_hashes) = + self.tuple_hashes().transpose() + { + f.field("tuple_hashes", &field_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: if let ::core::option::Option::Some(udp_sockets) = + value.udp_sockets()? + { + ::core::option::Option::Some(udp_sockets.to_vec_result()?) + } else { + ::core::option::Option::None + }, + tcp_servers: if let ::core::option::Option::Some(tcp_servers) = + value.tcp_servers()? + { + ::core::option::Option::Some(tcp_servers.to_vec_result()?) + } else { + ::core::option::Option::None + }, + web_rtc_transport_ids: if let ::core::option::Option::Some( + web_rtc_transport_ids, + ) = value.web_rtc_transport_ids()? + { + ::core::option::Option::Some(web_rtc_transport_ids.to_vec_result()?) + } else { + ::core::option::Option::None + }, + local_ice_username_fragments: if let ::core::option::Option::Some( + local_ice_username_fragments, + ) = value.local_ice_username_fragments()? + { + ::core::option::Option::Some( + local_ice_username_fragments.to_vec_result()?, + ) + } else { + ::core::option::Option::None + }, + tuple_hashes: if let ::core::option::Option::Some(tuple_hashes) = + value.tuple_hashes()? + { + ::core::option::Option::Some(tuple_hashes.to_vec_result()?) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + 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; + 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) + }) + } + } + } + pub mod producer { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct EnableTraceEventRequest { + pub events: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + } + + impl EnableTraceEventRequest { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_events: impl ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + ) -> ::planus::Offset { + let prepared_events = field_events.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_events); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for EnableTraceEventRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + EnableTraceEventRequest::create(builder, &self.events) + } + } + + #[derive(Copy, Clone)] + pub struct EnableTraceEventRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> EnableTraceEventRequestRef<'a> { + pub fn events( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + > { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct DumpResponse { + pub id: ::planus::alloc::string::String, + pub kind: super::rtp_parameters::MediaKind, + pub type_: ::planus::alloc::string::String, + pub rtp_parameters: + ::planus::alloc::boxed::Box, + pub rtp_mapping: ::planus::alloc::boxed::Box, + pub rtp_streams: + ::core::option::Option<::planus::alloc::vec::Vec>, + pub trace_event_types: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + pub paused: bool, + } + + impl DumpResponse { + #[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::WriteAs<::planus::Offset>, + field_rtp_parameters: impl ::planus::WriteAs< + ::planus::Offset, + >, + field_rtp_mapping: impl ::planus::WriteAs< + ::planus::Offset, + >, + field_rtp_streams: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_trace_event_types: impl ::planus::WriteAs< + ::planus::Offset<[::planus::Offset]>, + >, + 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::All); + + let prepared_type_ = field_type_.prepare(builder); + + 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::<18, 26>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_kind.is_some() { + table_writer.calculate_size::(4); + } + table_writer.calculate_size::<::planus::Offset>(6); + table_writer + .calculate_size::<::planus::Offset>( + 8, + ); + table_writer + .calculate_size::<::planus::Offset>(10); + if prepared_rtp_streams.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(12); + } + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(14); + if prepared_paused.is_some() { + table_writer.calculate_size::(16); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_id); + table_writer.write::<_, _, 4>(2, &prepared_type_); + table_writer.write::<_, _, 4>(3, &prepared_rtp_parameters); + table_writer.write::<_, _, 4>(4, &prepared_rtp_mapping); + if let ::core::option::Option::Some(prepared_rtp_streams) = + prepared_rtp_streams + { + table_writer.write::<_, _, 4>(5, &prepared_rtp_streams); + } + table_writer.write::<_, _, 4>(6, &prepared_trace_event_types); + if let ::core::option::Option::Some(prepared_kind) = prepared_kind { + table_writer.write::<_, _, 1>(1, &prepared_kind); + } + if let ::core::option::Option::Some(prepared_paused) = prepared_paused { + table_writer.write::<_, _, 1>(7, &prepared_paused); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DumpResponseRef<'a> { + pub fn id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "DumpResponse", "id") + } + + pub fn kind(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "DumpResponse", "kind")? + .unwrap_or(super::rtp_parameters::MediaKind::All), + ) + } + + pub fn type_(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(2, "DumpResponse", "type_") + } + + pub fn rtp_parameters( + &self, + ) -> ::planus::Result> { + self.0.access_required(3, "DumpResponse", "rtp_parameters") + } + + pub fn rtp_mapping( + &self, + ) -> ::planus::Result> { + self.0.access_required(4, "DumpResponse", "rtp_mapping") + } + + pub fn rtp_streams( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, + > { + self.0.access(5, "DumpResponse", "rtp_streams") + } + + pub fn trace_event_types( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + > { + self.0 + .access_required(6, "DumpResponse", "trace_event_types") + } + + 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()); + if let ::core::option::Option::Some(field_rtp_streams) = + self.rtp_streams().transpose() + { + f.field("rtp_streams", &field_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: if let ::core::option::Option::Some(rtp_streams) = + value.rtp_streams()? + { + ::core::option::Option::Some(rtp_streams.to_vec_result()?) + } else { + ::core::option::Option::None + }, + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + )] + pub struct GetStatsResponse { + pub stats: + ::core::option::Option<::planus::alloc::vec::Vec>, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for GetStatsResponse { + fn default() -> Self { + Self { + stats: ::core::default::Default::default(), + } + } + } + + impl GetStatsResponse { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_stats: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + ) -> ::planus::Offset { + let prepared_stats = field_stats.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 4>::new(builder); + + if prepared_stats.is_some() { + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_stats) = prepared_stats { + table_writer.write::<_, _, 4>(0, &prepared_stats); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + GetStatsResponse::create(builder, &self.stats) + } + } + + #[derive(Copy, Clone)] + pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> GetStatsResponseRef<'a> { + pub fn stats( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, + > { + self.0.access(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"); + if let ::core::option::Option::Some(field_stats) = self.stats().transpose() { + f.field("stats", &field_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: if let ::core::option::Option::Some(stats) = value.stats()? { + ::core::option::Option::Some(stats.to_vec_result()?) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct SendNotification { + pub data: ::planus::alloc::vec::Vec, + } + + impl SendNotification { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset<[u8]>>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_data); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for SendNotification { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SendNotification::create(builder, &self.data) + } + } + + #[derive(Copy, Clone)] + pub struct SendNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> SendNotificationRef<'a> { + pub fn data(&self) -> ::planus::Result<::planus::Vector<'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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Score { + pub ssrc: u32, + pub rid: ::core::option::Option<::planus::alloc::string::String>, + pub score: u8, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for Score { + fn default() -> Self { + Self { + ssrc: 0, + rid: ::core::default::Default::default(), + score: 0, + } + } + } + + impl Score { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_ssrc: impl ::planus::WriteAsDefault, + field_rid: impl ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + field_score: impl ::planus::WriteAsDefault, + ) -> ::planus::Offset { + 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::<8, 9>::new(builder); + + if prepared_ssrc.is_some() { + table_writer.calculate_size::(2); + } + if prepared_rid.is_some() { + table_writer.calculate_size::<::planus::Offset>(4); + } + if prepared_score.is_some() { + table_writer.calculate_size::(6); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + table_writer.write::<_, _, 4>(0, &prepared_ssrc); + } + if let ::core::option::Option::Some(prepared_rid) = prepared_rid { + table_writer.write::<_, _, 4>(1, &prepared_rid); + } + if let ::core::option::Option::Some(prepared_score) = prepared_score { + table_writer.write::<_, _, 1>(2, &prepared_score); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Score { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Score::create(builder, &self.ssrc, &self.rid, &self.score) + } + } + + #[derive(Copy, Clone)] + pub struct ScoreRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ScoreRef<'a> { + pub fn ssrc(&self) -> ::planus::Result { + ::core::result::Result::Ok(self.0.access(0, "Score", "ssrc")?.unwrap_or(0)) + } + + pub fn rid( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(1, "Score", "rid") + } + + pub fn score(&self) -> ::planus::Result { + ::core::result::Result::Ok(self.0.access(2, "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("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 { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ScoreNotification { + pub scores: ::core::option::Option<::planus::alloc::vec::Vec>, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for ScoreNotification { + fn default() -> Self { + Self { + scores: ::core::default::Default::default(), + } + } + } + + impl ScoreNotification { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_scores: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + ) -> ::planus::Offset { + let prepared_scores = field_scores.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 4>::new(builder); + + if prepared_scores.is_some() { + table_writer + .calculate_size::<::planus::Offset<[::planus::Offset]>>(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_scores) = prepared_scores { + table_writer.write::<_, _, 4>(0, &prepared_scores); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ScoreNotification { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ScoreNotification::create(builder, &self.scores) + } + } + + #[derive(Copy, Clone)] + pub struct ScoreNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ScoreNotificationRef<'a> { + pub fn scores( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, + > { + self.0.access(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"); + if let ::core::option::Option::Some(field_scores) = self.scores().transpose() { + f.field("scores", &field_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: if let ::core::option::Option::Some(scores) = value.scores()? { + ::core::option::Option::Some(scores.to_vec_result()?) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for ScoreNotificationRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct VideoOrientationChangeNotification { + pub camera: bool, + pub flip: bool, + 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 { + #[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::<8, 4>::new(builder); + + if prepared_camera.is_some() { + table_writer.calculate_size::(2); + } + if prepared_flip.is_some() { + table_writer.calculate_size::(4); + } + if prepared_rotation.is_some() { + table_writer.calculate_size::(6); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_rotation) = prepared_rotation { + table_writer.write::<_, _, 2>(2, &prepared_rotation); + } + if let ::core::option::Option::Some(prepared_camera) = prepared_camera { + table_writer.write::<_, _, 1>(0, &prepared_camera); + } + if let ::core::option::Option::Some(prepared_flip) = prepared_flip { + table_writer.write::<_, _, 1>(1, &prepared_flip); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for VideoOrientationChangeNotification + { + type Prepared = ::planus::Offset; + + 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; + + 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 + { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + VideoOrientationChangeNotification::create( + builder, + &self.camera, + &self.flip, + &self.rotation, + ) + } + } + + #[derive(Copy, Clone)] + pub struct VideoOrientationChangeNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> VideoOrientationChangeNotificationRef<'a> { + pub fn camera(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "VideoOrientationChangeNotification", "camera")? + .unwrap_or(false), + ) + } + + pub fn flip(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "VideoOrientationChangeNotification", "flip")? + .unwrap_or(false), + ) + } + + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + #[repr(u8)] + pub enum TraceType { + Keyframe = 0, + Fir = 1, + Nack = 2, + Pli = 3, + Rtp = 4, + } + + impl ::core::convert::TryFrom for TraceType { + type Error = ::planus::errors::UnknownEnumTagKind; + fn try_from( + value: u8, + ) -> ::core::result::Result + { + #[allow(clippy::match_single_binding)] + match value { + 0 => ::core::result::Result::Ok(TraceType::Keyframe), + 1 => ::core::result::Result::Ok(TraceType::Fir), + 2 => ::core::result::Result::Ok(TraceType::Nack), + 3 => ::core::result::Result::Ok(TraceType::Pli), + 4 => ::core::result::Result::Ok(TraceType::Rtp), + + _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { + tag: value as i128, + }), + } + } + } + + impl ::core::convert::From for u8 { + fn from(value: TraceType) -> Self { + value as u8 + } + } + + impl ::planus::Primitive for TraceType { + const ALIGNMENT: usize = 1; + const SIZE: usize = 1; + } + + impl ::planus::WriteAsPrimitive for TraceType { + #[inline] + fn write( + &self, + cursor: ::planus::Cursor<'_, N>, + buffer_position: u32, + ) { + (*self as u8).write(cursor, buffer_position); + } + } + + impl ::planus::WriteAs for TraceType { + type Prepared = Self; + + #[inline] + fn prepare(&self, _builder: &mut ::planus::Builder) -> TraceType { + *self + } + } + + impl ::planus::WriteAsDefault for TraceType { + type Prepared = Self; + + #[inline] + fn prepare( + &self, + _builder: &mut ::planus::Builder, + default: &TraceType, + ) -> ::core::option::Option { + if self == default { + ::core::option::Option::None + } else { + ::core::option::Option::Some(*self) + } + } + } + + impl ::planus::WriteAsOptional for TraceType { + 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 TraceType { + 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 TraceType { + 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 = ::from_buffer(buffer, offset); + let value: ::core::result::Result = + ::core::convert::TryInto::try_into(value); + value.map_err(|error_kind| { + error_kind.with_error_location( + "TraceType", + "VectorRead::from_buffer", + buffer.offset_from_start, + ) + }) + } + } + + impl ::planus::VectorWrite for TraceType { + const STRIDE: usize = 1; + + type Value = Self; + + 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, + ); + } + } + } + + #[derive( + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + #[repr(u8)] + pub enum TraceDirection { + DirectionIn = 0, + DirectionOut = 1, + } + + impl ::core::convert::TryFrom for TraceDirection { + type Error = ::planus::errors::UnknownEnumTagKind; + 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 { + 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 { + 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 = ::from_buffer(buffer, 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; + + 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, + ); + } + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub enum TraceInfo { + KeyFrameTraceInfo(::planus::alloc::boxed::Box), + FirTraceInfo(::planus::alloc::boxed::Box), + PliTraceInfo(::planus::alloc::boxed::Box), + RtpTraceInfo(::planus::alloc::boxed::Box), + } + + impl TraceInfo { + 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()) + } + + pub fn create_fir_trace_info( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + } + + pub fn create_pli_trace_info( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) + } + + 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 { + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + } + } + + #[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) => { + TraceInfo::KeyFrameTraceInfo(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + TraceInfoRef::FirTraceInfo(value) => { + TraceInfo::FirTraceInfo(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + TraceInfoRef::PliTraceInfo(value) => { + TraceInfo::PliTraceInfo(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + TraceInfoRef::RtpTraceInfo(value) => { + TraceInfo::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 }, + ), + } + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct KeyFrameTraceInfo { + pub is_rtx: bool, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for KeyFrameTraceInfo { + fn default() -> Self { + Self { is_rtx: false } + } + } + + impl KeyFrameTraceInfo { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_is_rtx: impl ::planus::WriteAsDefault, + ) -> ::planus::Offset { + let prepared_is_rtx = field_is_rtx.prepare(builder, &false); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 1>::new(builder); + + if prepared_is_rtx.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { + table_writer.write::<_, _, 1>(0, &prepared_is_rtx); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for KeyFrameTraceInfo { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + KeyFrameTraceInfo::create(builder, &self.is_rtx) + } + } + + #[derive(Copy, Clone)] + pub struct KeyFrameTraceInfoRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> KeyFrameTraceInfoRef<'a> { + pub fn is_rtx(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "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("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 { + is_rtx: ::core::convert::TryInto::try_into(value.is_rtx()?)?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for KeyFrameTraceInfoRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct FirTraceInfo { + pub ssrc: u32, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for FirTraceInfo { + fn default() -> Self { + Self { ssrc: 0 } + } + } + + impl FirTraceInfo { + #[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::<4, 4>::new(builder); + + if prepared_ssrc.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + table_writer.write::<_, _, 4>(0, &prepared_ssrc); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for FirTraceInfo { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + FirTraceInfo::create(builder, &self.ssrc) + } + } + + #[derive(Copy, Clone)] + pub struct FirTraceInfoRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> FirTraceInfoRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct PliTraceInfo { + pub ssrc: u32, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for PliTraceInfo { + fn default() -> Self { + Self { ssrc: 0 } + } + } + + impl PliTraceInfo { + #[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::<4, 4>::new(builder); + + if prepared_ssrc.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + table_writer.write::<_, _, 4>(0, &prepared_ssrc); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for PliTraceInfo { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + PliTraceInfo::create(builder, &self.ssrc) + } + } + + #[derive(Copy, Clone)] + pub struct PliTraceInfoRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> PliTraceInfoRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct RtpTraceInfo { + pub is_rtx: bool, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for RtpTraceInfo { + fn default() -> Self { + Self { is_rtx: false } + } + } + + impl RtpTraceInfo { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_is_rtx: impl ::planus::WriteAsDefault, + ) -> ::planus::Offset { + let prepared_is_rtx = field_is_rtx.prepare(builder, &false); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 1>::new(builder); + + if prepared_is_rtx.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { + table_writer.write::<_, _, 1>(0, &prepared_is_rtx); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RtpTraceInfo { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + RtpTraceInfo::create(builder, &self.is_rtx) + } + } + + #[derive(Copy, Clone)] + pub struct RtpTraceInfoRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RtpTraceInfoRef<'a> { + pub fn is_rtx(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(0, "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("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 { + is_rtx: ::core::convert::TryInto::try_into(value.is_rtx()?)?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for RtpTraceInfoRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct TraceNotification { + pub type_: self::TraceType, + pub timestamp: u64, + pub direction: self::TraceDirection, + pub info: ::core::option::Option, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for TraceNotification { + fn default() -> Self { + Self { + type_: self::TraceType::Keyframe, + timestamp: 0, + direction: self::TraceDirection::DirectionIn, + info: ::core::default::Default::default(), + } + } + } + + impl TraceNotification { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_type_: impl ::planus::WriteAsDefault, + field_timestamp: impl ::planus::WriteAsDefault, + field_direction: impl ::planus::WriteAsDefault< + self::TraceDirection, + self::TraceDirection, + >, + field_info: impl ::planus::WriteAsOptionalUnion, + ) -> ::planus::Offset { + let prepared_type_ = field_type_.prepare(builder, &self::TraceType::Keyframe); + + let prepared_timestamp = field_timestamp.prepare(builder, &0); + + let prepared_direction = + field_direction.prepare(builder, &self::TraceDirection::DirectionIn); + + let prepared_info = field_info.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<10, 15>::new(builder); + + if prepared_type_.is_some() { + table_writer.calculate_size::(2); + } + if prepared_timestamp.is_some() { + table_writer.calculate_size::(4); + } + if prepared_direction.is_some() { + table_writer.calculate_size::(6); + } + if prepared_info.is_some() { + table_writer.calculate_size::(8); + table_writer.calculate_size::<::planus::Offset>(10); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_timestamp) = prepared_timestamp + { + table_writer.write::<_, _, 8>(1, &prepared_timestamp); + } + if let ::core::option::Option::Some(prepared_info) = prepared_info { + table_writer.write::<_, _, 4>(4, &prepared_info.offset()); + } + if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { + table_writer.write::<_, _, 1>(0, &prepared_type_); + } + if let ::core::option::Option::Some(prepared_direction) = prepared_direction + { + table_writer.write::<_, _, 1>(2, &prepared_direction); + } + if let ::core::option::Option::Some(prepared_info) = prepared_info { + table_writer.write::<_, _, 1>(3, &prepared_info.tag()); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for TraceNotification { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + TraceNotification::create( + builder, + &self.type_, + &self.timestamp, + &self.direction, + &self.info, + ) + } + } + + #[derive(Copy, Clone)] + pub struct TraceNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> TraceNotificationRef<'a> { + pub fn type_(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "TraceNotification", "type_")? + .unwrap_or(self::TraceType::Keyframe), + ) + } + + pub fn timestamp(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "TraceNotification", "timestamp")? + .unwrap_or(0), + ) + } + + pub fn direction(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "TraceNotification", "direction")? + .unwrap_or(self::TraceDirection::DirectionIn), + ) + } + + 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> { + 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; + 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) + }) + } + } + } + pub mod pipe_transport { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct PipeTransportOptions { + pub base: ::planus::alloc::boxed::Box, + pub listen_ip: ::planus::alloc::boxed::Box, + pub port: u16, + pub enable_rtx: bool, + pub enable_srtp: bool, + } + + impl PipeTransportOptions { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_base: impl ::planus::WriteAs<::planus::Offset>, + field_listen_ip: impl ::planus::WriteAs< + ::planus::Offset, + >, + field_port: impl ::planus::WriteAsDefault, + field_enable_rtx: impl ::planus::WriteAsDefault, + field_enable_srtp: impl ::planus::WriteAsDefault, + ) -> ::planus::Offset { + let prepared_base = field_base.prepare(builder); + + let prepared_listen_ip = field_listen_ip.prepare(builder); + + let prepared_port = field_port.prepare(builder, &0); + + 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, 12>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + if prepared_port.is_some() { + table_writer.calculate_size::(6); + } + if prepared_enable_rtx.is_some() { + table_writer.calculate_size::(8); + } + if prepared_enable_srtp.is_some() { + table_writer.calculate_size::(10); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_base); + table_writer.write::<_, _, 4>(1, &prepared_listen_ip); + if let ::core::option::Option::Some(prepared_port) = prepared_port { + table_writer.write::<_, _, 2>(2, &prepared_port); + } + if let ::core::option::Option::Some(prepared_enable_rtx) = + prepared_enable_rtx + { + table_writer.write::<_, _, 1>(3, &prepared_enable_rtx); + } + if let ::core::option::Option::Some(prepared_enable_srtp) = + prepared_enable_srtp + { + table_writer.write::<_, _, 1>(4, &prepared_enable_srtp); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for PipeTransportOptions { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + PipeTransportOptions::create( + builder, + &self.base, + &self.listen_ip, + &self.port, + &self.enable_rtx, + &self.enable_srtp, + ) + } + } + + #[derive(Copy, Clone)] + pub struct PipeTransportOptionsRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> PipeTransportOptionsRef<'a> { + pub fn base(&self) -> ::planus::Result> { + self.0.access_required(0, "PipeTransportOptions", "base") + } + + pub fn listen_ip(&self) -> ::planus::Result> { + self.0 + .access_required(1, "PipeTransportOptions", "listen_ip") + } + + pub fn port(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "PipeTransportOptions", "port")? + .unwrap_or(0), + ) + } + + pub fn enable_rtx(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(3, "PipeTransportOptions", "enable_rtx")? + .unwrap_or(false), + ) + } + + pub fn enable_srtp(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(4, "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_ip", &self.listen_ip()); + f.field("port", &self.port()); + 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_ip: ::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(value.listen_ip()?)?, + ), + port: ::core::convert::TryInto::try_into(value.port()?)?, + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ConnectRequest { + pub ip: ::planus::alloc::string::String, + pub port: ::core::option::Option, + pub srtp_parameters: ::core::option::Option< + ::planus::alloc::boxed::Box, + >, + } + + impl ConnectRequest { + #[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::<8, 10>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_port.is_some() { + table_writer.calculate_size::(4); + } + if prepared_srtp_parameters.is_some() { + table_writer + .calculate_size::<::planus::Offset>( + 6, + ); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_ip); + if let ::core::option::Option::Some(prepared_srtp_parameters) = + prepared_srtp_parameters + { + table_writer.write::<_, _, 4>(2, &prepared_srtp_parameters); + } + if let ::core::option::Option::Some(prepared_port) = prepared_port { + table_writer.write::<_, _, 2>(1, &prepared_port); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ConnectRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ConnectRequest::create(builder, &self.ip, &self.port, &self.srtp_parameters) + } + } + + #[derive(Copy, Clone)] + pub struct ConnectRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ConnectRequestRef<'a> { + pub fn ip(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "ConnectRequest", "ip") + } + + pub fn port(&self) -> ::planus::Result<::core::option::Option> { + self.0.access(1, "ConnectRequest", "port") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ConnectResponse { + pub tuple: + ::core::option::Option<::planus::alloc::boxed::Box>, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for ConnectResponse { + fn default() -> Self { + Self { + tuple: ::core::default::Default::default(), + } + } + } + + impl ConnectResponse { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_tuple: impl ::planus::WriteAsOptional< + ::planus::Offset, + >, + ) -> ::planus::Offset { + let prepared_tuple = field_tuple.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 4>::new(builder); + + if prepared_tuple.is_some() { + table_writer.calculate_size::<::planus::Offset>(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_tuple) = prepared_tuple { + table_writer.write::<_, _, 4>(0, &prepared_tuple); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ConnectResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ConnectResponse::create(builder, &self.tuple) + } + } + + #[derive(Copy, Clone)] + pub struct ConnectResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ConnectResponseRef<'a> { + pub fn tuple( + &self, + ) -> ::planus::Result<::core::option::Option>> + { + self.0.access(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"); + if let ::core::option::Option::Some(field_tuple) = self.tuple().transpose() { + f.field("tuple", &field_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: if let ::core::option::Option::Some(tuple) = value.tuple()? { + ::core::option::Option::Some(::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(tuple)?, + )) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for ConnectResponseRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct DumpResponse { + pub base: ::planus::alloc::boxed::Box, + pub tuple: ::planus::alloc::boxed::Box, + pub rtx: bool, + pub srtp_parameters: ::core::option::Option< + ::planus::alloc::boxed::Box, + >, + } + + impl DumpResponse { + #[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::<10, 13>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + if prepared_rtx.is_some() { + table_writer.calculate_size::(6); + } + if prepared_srtp_parameters.is_some() { + table_writer + .calculate_size::<::planus::Offset>( + 8, + ); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_base); + table_writer.write::<_, _, 4>(1, &prepared_tuple); + if let ::core::option::Option::Some(prepared_srtp_parameters) = + prepared_srtp_parameters + { + table_writer.write::<_, _, 4>(3, &prepared_srtp_parameters); + } + if let ::core::option::Option::Some(prepared_rtx) = prepared_rtx { + table_writer.write::<_, _, 1>(2, &prepared_rtx); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + DumpResponse::create( + builder, + &self.base, + &self.tuple, + &self.rtx, + &self.srtp_parameters, + ) + } + } + + #[derive(Copy, Clone)] + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DumpResponseRef<'a> { + pub fn base(&self) -> ::planus::Result> { + self.0.access_required(0, "DumpResponse", "base") + } + + pub fn tuple(&self) -> ::planus::Result> { + self.0.access_required(1, "DumpResponse", "tuple") + } + + pub fn rtx(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(2, "DumpResponse", "rtx")?.unwrap_or(false), + ) + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct GetStatsResponse { + pub base: ::planus::alloc::boxed::Box, + pub tuple: ::planus::alloc::boxed::Box, + } + + impl GetStatsResponse { + #[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::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_base); + table_writer.write::<_, _, 4>(1, &prepared_tuple); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + GetStatsResponse::create(builder, &self.base, &self.tuple) + } + } + + #[derive(Copy, Clone)] + pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> GetStatsResponseRef<'a> { + pub fn base(&self) -> ::planus::Result> { + self.0.access_required(0, "GetStatsResponse", "base") + } + + 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> { + 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; + 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) + }) + } + } + } + pub mod plain_transport { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct PlainTransportOptions { + pub base: + ::core::option::Option<::planus::alloc::boxed::Box>, + pub listen_ip: ::planus::alloc::boxed::Box, + pub port: u16, + pub rtcp_mux: bool, + pub comedia: bool, + pub enable_srtp: bool, + pub srtp_crypto_suite: ::core::option::Option<::planus::alloc::string::String>, + } + + impl PlainTransportOptions { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_base: impl ::planus::WriteAsOptional< + ::planus::Offset, + >, + field_listen_ip: impl ::planus::WriteAs< + ::planus::Offset, + >, + field_port: impl ::planus::WriteAsDefault, + field_rtcp_mux: impl ::planus::WriteAsDefault, + field_comedia: impl ::planus::WriteAsDefault, + field_enable_srtp: impl ::planus::WriteAsDefault, + field_srtp_crypto_suite: impl ::planus::WriteAsOptional< + ::planus::Offset<::core::primitive::str>, + >, + ) -> ::planus::Offset { + let prepared_base = field_base.prepare(builder); + + let prepared_listen_ip = field_listen_ip.prepare(builder); + + let prepared_port = field_port.prepare(builder, &0); + + 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::<16, 17>::new(builder); + + if prepared_base.is_some() { + table_writer + .calculate_size::<::planus::Offset>(2); + } + table_writer.calculate_size::<::planus::Offset>(4); + if prepared_port.is_some() { + table_writer.calculate_size::(6); + } + if prepared_rtcp_mux.is_some() { + table_writer.calculate_size::(8); + } + if prepared_comedia.is_some() { + table_writer.calculate_size::(10); + } + if prepared_enable_srtp.is_some() { + table_writer.calculate_size::(12); + } + if prepared_srtp_crypto_suite.is_some() { + table_writer.calculate_size::<::planus::Offset>(14); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_base) = prepared_base { + table_writer.write::<_, _, 4>(0, &prepared_base); + } + table_writer.write::<_, _, 4>(1, &prepared_listen_ip); + if let ::core::option::Option::Some(prepared_srtp_crypto_suite) = + prepared_srtp_crypto_suite + { + table_writer.write::<_, _, 4>(6, &prepared_srtp_crypto_suite); + } + if let ::core::option::Option::Some(prepared_port) = prepared_port { + table_writer.write::<_, _, 2>(2, &prepared_port); + } + if let ::core::option::Option::Some(prepared_rtcp_mux) = prepared_rtcp_mux { + table_writer.write::<_, _, 1>(3, &prepared_rtcp_mux); + } + if let ::core::option::Option::Some(prepared_comedia) = prepared_comedia { + table_writer.write::<_, _, 1>(4, &prepared_comedia); + } + if let ::core::option::Option::Some(prepared_enable_srtp) = + prepared_enable_srtp + { + table_writer.write::<_, _, 1>(5, &prepared_enable_srtp); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for PlainTransportOptions { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + PlainTransportOptions::create( + builder, + &self.base, + &self.listen_ip, + &self.port, + &self.rtcp_mux, + &self.comedia, + &self.enable_srtp, + &self.srtp_crypto_suite, + ) + } + } + + #[derive(Copy, Clone)] + pub struct PlainTransportOptionsRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> PlainTransportOptionsRef<'a> { + pub fn base( + &self, + ) -> ::planus::Result<::core::option::Option>> + { + self.0.access(0, "PlainTransportOptions", "base") + } + + pub fn listen_ip(&self) -> ::planus::Result> { + self.0 + .access_required(1, "PlainTransportOptions", "listen_ip") + } + + pub fn port(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "PlainTransportOptions", "port")? + .unwrap_or(0), + ) + } + + pub fn rtcp_mux(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(3, "PlainTransportOptions", "rtcp_mux")? + .unwrap_or(false), + ) + } + + pub fn comedia(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(4, "PlainTransportOptions", "comedia")? + .unwrap_or(false), + ) + } + + pub fn enable_srtp(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(5, "PlainTransportOptions", "enable_srtp")? + .unwrap_or(false), + ) + } + + pub fn srtp_crypto_suite( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + 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"); + if let ::core::option::Option::Some(field_base) = self.base().transpose() { + f.field("base", &field_base); + } + f.field("listen_ip", &self.listen_ip()); + f.field("port", &self.port()); + 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: if let ::core::option::Option::Some(base) = value.base()? { + ::core::option::Option::Some(::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(base)?, + )) + } else { + ::core::option::Option::None + }, + listen_ip: ::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(value.listen_ip()?)?, + ), + port: ::core::convert::TryInto::try_into(value.port()?)?, + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ConnectRequest { + pub ip: ::core::option::Option<::planus::alloc::string::String>, + pub port: ::core::option::Option, + pub rtcp_port: ::core::option::Option, + 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 { + #[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::<10, 12>::new(builder); + + if prepared_ip.is_some() { + table_writer.calculate_size::<::planus::Offset>(2); + } + if prepared_port.is_some() { + table_writer.calculate_size::(4); + } + if prepared_rtcp_port.is_some() { + table_writer.calculate_size::(6); + } + if prepared_srtp_parameters.is_some() { + table_writer + .calculate_size::<::planus::Offset>( + 8, + ); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_ip) = prepared_ip { + table_writer.write::<_, _, 4>(0, &prepared_ip); + } + if let ::core::option::Option::Some(prepared_srtp_parameters) = + prepared_srtp_parameters + { + table_writer.write::<_, _, 4>(3, &prepared_srtp_parameters); + } + if let ::core::option::Option::Some(prepared_port) = prepared_port { + table_writer.write::<_, _, 2>(1, &prepared_port); + } + if let ::core::option::Option::Some(prepared_rtcp_port) = prepared_rtcp_port + { + table_writer.write::<_, _, 2>(2, &prepared_rtcp_port); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ConnectRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ConnectRequest::create( + builder, + &self.ip, + &self.port, + &self.rtcp_port, + &self.srtp_parameters, + ) + } + } + + #[derive(Copy, Clone)] + pub struct ConnectRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ConnectRequestRef<'a> { + pub fn ip( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(0, "ConnectRequest", "ip") + } + + pub fn port(&self) -> ::planus::Result<::core::option::Option> { + self.0.access(1, "ConnectRequest", "port") + } + + pub fn rtcp_port(&self) -> ::planus::Result<::core::option::Option> { + self.0.access(2, "ConnectRequest", "rtcp_port") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ConnectResponse { + pub tuple: ::planus::alloc::boxed::Box, + pub rtcp_tuple: + ::core::option::Option<::planus::alloc::boxed::Box>, + pub srtp_parameters: ::core::option::Option< + ::planus::alloc::boxed::Box, + >, + } + + impl ConnectResponse { + #[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::<8, 12>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_rtcp_tuple.is_some() { + table_writer.calculate_size::<::planus::Offset>(4); + } + if prepared_srtp_parameters.is_some() { + table_writer + .calculate_size::<::planus::Offset>( + 6, + ); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_tuple); + if let ::core::option::Option::Some(prepared_rtcp_tuple) = + prepared_rtcp_tuple + { + table_writer.write::<_, _, 4>(1, &prepared_rtcp_tuple); + } + if let ::core::option::Option::Some(prepared_srtp_parameters) = + prepared_srtp_parameters + { + table_writer.write::<_, _, 4>(2, &prepared_srtp_parameters); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ConnectResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ConnectResponse::create( + builder, + &self.tuple, + &self.rtcp_tuple, + &self.srtp_parameters, + ) + } + } + + #[derive(Copy, Clone)] + pub struct ConnectResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ConnectResponseRef<'a> { + pub fn tuple(&self) -> ::planus::Result> { + self.0.access_required(0, "ConnectResponse", "tuple") + } + + pub fn rtcp_tuple( + &self, + ) -> ::planus::Result<::core::option::Option>> + { + self.0.access(1, "ConnectResponse", "rtcp_tuple") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct DumpResponse { + pub base: ::planus::alloc::boxed::Box, + pub rtcp_mux: bool, + pub comedia: bool, + pub tuple: + ::core::option::Option<::planus::alloc::boxed::Box>, + pub rtcp_tuple: + ::core::option::Option<::planus::alloc::boxed::Box>, + pub srtp_parameters: ::core::option::Option< + ::planus::alloc::boxed::Box, + >, + } + + impl DumpResponse { + #[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::WriteAsOptional< + ::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::<14, 18>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_rtcp_mux.is_some() { + table_writer.calculate_size::(4); + } + if prepared_comedia.is_some() { + table_writer.calculate_size::(6); + } + if prepared_tuple.is_some() { + table_writer.calculate_size::<::planus::Offset>(8); + } + if prepared_rtcp_tuple.is_some() { + table_writer + .calculate_size::<::planus::Offset>(10); + } + if prepared_srtp_parameters.is_some() { + table_writer + .calculate_size::<::planus::Offset>( + 12, + ); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_base); + if let ::core::option::Option::Some(prepared_tuple) = prepared_tuple { + table_writer.write::<_, _, 4>(3, &prepared_tuple); + } + if let ::core::option::Option::Some(prepared_rtcp_tuple) = + prepared_rtcp_tuple + { + table_writer.write::<_, _, 4>(4, &prepared_rtcp_tuple); + } + if let ::core::option::Option::Some(prepared_srtp_parameters) = + prepared_srtp_parameters + { + table_writer.write::<_, _, 4>(5, &prepared_srtp_parameters); + } + if let ::core::option::Option::Some(prepared_rtcp_mux) = prepared_rtcp_mux { + table_writer.write::<_, _, 1>(1, &prepared_rtcp_mux); + } + if let ::core::option::Option::Some(prepared_comedia) = prepared_comedia { + table_writer.write::<_, _, 1>(2, &prepared_comedia); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DumpResponseRef<'a> { + pub fn base(&self) -> ::planus::Result> { + self.0.access_required(0, "DumpResponse", "base") + } + + pub fn rtcp_mux(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "DumpResponse", "rtcp_mux")? + .unwrap_or(false), + ) + } + + pub fn comedia(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "DumpResponse", "comedia")? + .unwrap_or(false), + ) + } + + pub fn tuple( + &self, + ) -> ::planus::Result<::core::option::Option>> + { + self.0.access(3, "DumpResponse", "tuple") + } + + pub fn rtcp_tuple( + &self, + ) -> ::planus::Result<::core::option::Option>> + { + self.0.access(4, "DumpResponse", "rtcp_tuple") + } + + 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()); + if let ::core::option::Option::Some(field_tuple) = self.tuple().transpose() { + f.field("tuple", &field_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: if let ::core::option::Option::Some(tuple) = value.tuple()? { + ::core::option::Option::Some(::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(tuple)?, + )) + } else { + ::core::option::Option::None + }, + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct GetStatsResponse { + pub base: ::planus::alloc::boxed::Box, + pub rtcp_mux: bool, + pub comedia: bool, + pub tuple: ::planus::alloc::boxed::Box, + pub rtcp_tuple: + ::core::option::Option<::planus::alloc::boxed::Box>, + } + + impl GetStatsResponse { + #[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::<12, 14>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_rtcp_mux.is_some() { + table_writer.calculate_size::(4); + } + if prepared_comedia.is_some() { + table_writer.calculate_size::(6); + } + table_writer.calculate_size::<::planus::Offset>(8); + if prepared_rtcp_tuple.is_some() { + table_writer + .calculate_size::<::planus::Offset>(10); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_base); + table_writer.write::<_, _, 4>(3, &prepared_tuple); + if let ::core::option::Option::Some(prepared_rtcp_tuple) = + prepared_rtcp_tuple + { + table_writer.write::<_, _, 4>(4, &prepared_rtcp_tuple); + } + if let ::core::option::Option::Some(prepared_rtcp_mux) = prepared_rtcp_mux { + table_writer.write::<_, _, 1>(1, &prepared_rtcp_mux); + } + if let ::core::option::Option::Some(prepared_comedia) = prepared_comedia { + table_writer.write::<_, _, 1>(2, &prepared_comedia); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + GetStatsResponse::create( + builder, + &self.base, + &self.rtcp_mux, + &self.comedia, + &self.tuple, + &self.rtcp_tuple, + ) + } + } + + #[derive(Copy, Clone)] + pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> GetStatsResponseRef<'a> { + pub fn base(&self) -> ::planus::Result> { + self.0.access_required(0, "GetStatsResponse", "base") + } + + pub fn rtcp_mux(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "GetStatsResponse", "rtcp_mux")? + .unwrap_or(false), + ) + } + + pub fn comedia(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "GetStatsResponse", "comedia")? + .unwrap_or(false), + ) + } + + pub fn tuple(&self) -> ::planus::Result> { + self.0.access_required(3, "GetStatsResponse", "tuple") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct TupleNotification { + pub tuple: ::planus::alloc::boxed::Box, + } + + impl TupleNotification { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_tuple); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for TupleNotification { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + TupleNotification::create(builder, &self.tuple) + } + } + + #[derive(Copy, Clone)] + pub struct TupleNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> TupleNotificationRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct RtcpTupleNotification { + pub tuple: ::planus::alloc::boxed::Box, + } + + impl RtcpTupleNotification { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_tuple); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RtcpTupleNotification { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + RtcpTupleNotification::create(builder, &self.tuple) + } + } + + #[derive(Copy, Clone)] + pub struct RtcpTupleNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RtcpTupleNotificationRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + } + pub mod web_rtc_transport { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ListenIndividual { + pub listen_ips: ::planus::alloc::vec::Vec, + pub port: u16, + } + + impl ListenIndividual { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_listen_ips: impl ::planus::WriteAs< + ::planus::Offset<[::planus::Offset]>, + >, + field_port: impl ::planus::WriteAsDefault, + ) -> ::planus::Offset { + let prepared_listen_ips = field_listen_ips.prepare(builder); + + let prepared_port = field_port.prepare(builder, &0); + + let mut table_writer = + ::planus::table_writer::TableWriter::<6, 6>::new(builder); + + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); + if prepared_port.is_some() { + table_writer.calculate_size::(4); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_listen_ips); + if let ::core::option::Option::Some(prepared_port) = prepared_port { + table_writer.write::<_, _, 2>(1, &prepared_port); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ListenIndividual { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ListenIndividual::create(builder, &self.listen_ips, &self.port) + } + } + + #[derive(Copy, Clone)] + pub struct ListenIndividualRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ListenIndividualRef<'a> { + pub fn listen_ips( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result>>, + > { + self.0.access_required(0, "ListenIndividual", "listen_ips") + } + + pub fn port(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(1, "ListenIndividual", "port")?.unwrap_or(0), + ) + } + } + + 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_ips", &self.listen_ips()); + f.field("port", &self.port()); + 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_ips: value.listen_ips()?.to_vec_result()?, + port: ::core::convert::TryInto::try_into(value.port()?)?, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for ListenIndividualRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ListenServer { + pub web_rtc_server_id: ::planus::alloc::string::String, + } + + impl ListenServer { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_web_rtc_server_id); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ListenServer { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ListenServer::create(builder, &self.web_rtc_server_id) + } + } + + #[derive(Copy, Clone)] + pub struct ListenServerRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ListenServerRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub enum Listen { + ListenIndividual(::planus::alloc::boxed::Box), + ListenServer(::planus::alloc::boxed::Box), + } + + impl Listen { + pub fn create_listen_individual( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + } + + 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 { + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + } + } + + #[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) => { + Listen::ListenIndividual(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + ListenRef::ListenServer(value) => { + Listen::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 }, + ), + } + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct WebRtcTransportOptions { + pub base: ::planus::alloc::boxed::Box, + pub listen: self::Listen, + pub enable_udp: bool, + pub enable_tcp: bool, + pub prefer_udp: bool, + pub prefer_tcp: bool, + } + + impl WebRtcTransportOptions { + #[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, &false); + + 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::<16, 13>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::(4); + table_writer.calculate_size::<::planus::Offset>(6); + if prepared_enable_udp.is_some() { + table_writer.calculate_size::(8); + } + if prepared_enable_tcp.is_some() { + table_writer.calculate_size::(10); + } + if prepared_prefer_udp.is_some() { + table_writer.calculate_size::(12); + } + if prepared_prefer_tcp.is_some() { + table_writer.calculate_size::(14); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_base); + table_writer.write::<_, _, 4>(2, &prepared_listen.offset()); + table_writer.write::<_, _, 1>(1, &prepared_listen.tag()); + if let ::core::option::Option::Some(prepared_enable_udp) = + prepared_enable_udp + { + table_writer.write::<_, _, 1>(3, &prepared_enable_udp); + } + if let ::core::option::Option::Some(prepared_enable_tcp) = + prepared_enable_tcp + { + table_writer.write::<_, _, 1>(4, &prepared_enable_tcp); + } + if let ::core::option::Option::Some(prepared_prefer_udp) = + prepared_prefer_udp + { + table_writer.write::<_, _, 1>(5, &prepared_prefer_udp); + } + if let ::core::option::Option::Some(prepared_prefer_tcp) = + prepared_prefer_tcp + { + table_writer.write::<_, _, 1>(6, &prepared_prefer_tcp); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for WebRtcTransportOptions { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct WebRtcTransportOptionsRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> WebRtcTransportOptionsRef<'a> { + pub fn base(&self) -> ::planus::Result> { + self.0.access_required(0, "WebRtcTransportOptions", "base") + } + + pub fn listen(&self) -> ::planus::Result> { + self.0 + .access_union_required(1, "WebRtcTransportOptions", "listen") + } + + pub fn enable_udp(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(3, "WebRtcTransportOptions", "enable_udp")? + .unwrap_or(true), + ) + } + + pub fn enable_tcp(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(4, "WebRtcTransportOptions", "enable_tcp")? + .unwrap_or(false), + ) + } + + pub fn prefer_udp(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(5, "WebRtcTransportOptions", "prefer_udp")? + .unwrap_or(false), + ) + } + + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct Fingerprint { + pub algorithm: ::planus::alloc::string::String, + pub value: ::planus::alloc::string::String, + } + + impl Fingerprint { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_algorithm: impl ::planus::WriteAs<::planus::Offset>, + field_value: impl ::planus::WriteAs<::planus::Offset>, + ) -> ::planus::Offset { + let prepared_algorithm = field_algorithm.prepare(builder); + + let prepared_value = field_value.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<6, 8>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_algorithm); + table_writer.write::<_, _, 4>(1, &prepared_value); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for Fingerprint { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + Fingerprint::create(builder, &self.algorithm, &self.value) + } + } + + #[derive(Copy, Clone)] + pub struct FingerprintRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> FingerprintRef<'a> { + pub fn algorithm(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "Fingerprint", "algorithm") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct DtlsParameters { + pub fingerprints: ::planus::alloc::vec::Vec, + pub role: ::core::option::Option<::planus::alloc::string::String>, + } + + impl DtlsParameters { + #[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::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + ) -> ::planus::Offset { + let prepared_fingerprints = field_fingerprints.prepare(builder); + + let prepared_role = field_role.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<6, 8>::new(builder); + + table_writer + .calculate_size::<::planus::Offset<[::planus::Offset]>>( + 2, + ); + if prepared_role.is_some() { + table_writer.calculate_size::<::planus::Offset>(4); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_fingerprints); + if let ::core::option::Option::Some(prepared_role) = prepared_role { + table_writer.write::<_, _, 4>(1, &prepared_role); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for DtlsParameters { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + DtlsParameters::create(builder, &self.fingerprints, &self.role) + } + } + + #[derive(Copy, Clone)] + pub struct DtlsParametersRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DtlsParametersRef<'a> { + pub fn fingerprints( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result>>, + > { + self.0.access_required(0, "DtlsParameters", "fingerprints") + } + + pub fn role( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(1, "DtlsParameters", "role") + } + } + + 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()); + if let ::core::option::Option::Some(field_role) = self.role().transpose() { + f.field("role", &field_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: if let ::core::option::Option::Some(role) = value.role()? { + ::core::option::Option::Some(::core::convert::TryInto::try_into(role)?) + } else { + ::core::option::Option::None + }, + }) + } + } + + impl<'a> ::planus::TableRead<'a> for DtlsParametersRef<'a> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct IceParameters { + pub username_fragment: ::planus::alloc::string::String, + pub password: ::planus::alloc::string::String, + pub ice_lite: bool, + } + + impl IceParameters { + #[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::<8, 9>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + if prepared_ice_lite.is_some() { + table_writer.calculate_size::(6); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_username_fragment); + table_writer.write::<_, _, 4>(1, &prepared_password); + if let ::core::option::Option::Some(prepared_ice_lite) = prepared_ice_lite { + table_writer.write::<_, _, 1>(2, &prepared_ice_lite); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for IceParameters { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + IceParameters::create( + builder, + &self.username_fragment, + &self.password, + &self.ice_lite, + ) + } + } + + #[derive(Copy, Clone)] + pub struct IceParametersRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> IceParametersRef<'a> { + pub fn username_fragment(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(0, "IceParameters", "username_fragment") + } + + pub fn password(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(1, "IceParameters", "password") + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct IceCandidate { + pub foundation: ::planus::alloc::string::String, + pub priority: u32, + pub ip: ::planus::alloc::string::String, + pub protocol: ::planus::alloc::string::String, + pub port: u16, + pub type_: ::core::option::Option<::planus::alloc::string::String>, + pub tcp_type: ::core::option::Option<::planus::alloc::string::String>, + } + + impl IceCandidate { + #[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::WriteAs<::planus::Offset>, + field_port: impl ::planus::WriteAsDefault, + field_type_: impl ::planus::WriteAsOptional< + ::planus::Offset<::core::primitive::str>, + >, + field_tcp_type: impl ::planus::WriteAsOptional< + ::planus::Offset<::core::primitive::str>, + >, + ) -> ::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); + + let prepared_port = field_port.prepare(builder, &0); + + let prepared_type_ = field_type_.prepare(builder); + + let prepared_tcp_type = field_tcp_type.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<16, 26>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + if prepared_priority.is_some() { + table_writer.calculate_size::(4); + } + table_writer.calculate_size::<::planus::Offset>(6); + table_writer.calculate_size::<::planus::Offset>(8); + if prepared_port.is_some() { + table_writer.calculate_size::(10); + } + if prepared_type_.is_some() { + table_writer.calculate_size::<::planus::Offset>(12); + } + if prepared_tcp_type.is_some() { + table_writer.calculate_size::<::planus::Offset>(14); + } + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_foundation); + if let ::core::option::Option::Some(prepared_priority) = prepared_priority { + table_writer.write::<_, _, 4>(1, &prepared_priority); + } + table_writer.write::<_, _, 4>(2, &prepared_ip); + table_writer.write::<_, _, 4>(3, &prepared_protocol); + if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { + table_writer.write::<_, _, 4>(5, &prepared_type_); + } + if let ::core::option::Option::Some(prepared_tcp_type) = prepared_tcp_type { + table_writer.write::<_, _, 4>(6, &prepared_tcp_type); + } + if let ::core::option::Option::Some(prepared_port) = prepared_port { + table_writer.write::<_, _, 2>(4, &prepared_port); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for IceCandidate { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct IceCandidateRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> IceCandidateRef<'a> { + pub fn foundation(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "IceCandidate", "foundation") + } + + pub fn priority(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(1, "IceCandidate", "priority")?.unwrap_or(0), + ) + } + + pub fn ip(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(2, "IceCandidate", "ip") + } + + pub fn protocol(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(3, "IceCandidate", "protocol") + } + + pub fn port(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(4, "IceCandidate", "port")?.unwrap_or(0), + ) + } + + pub fn type_( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(5, "IceCandidate", "type_") + } + + pub fn tcp_type( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + 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()); + if let ::core::option::Option::Some(field_type_) = self.type_().transpose() { + f.field("type_", &field_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_: if let ::core::option::Option::Some(type_) = value.type_()? { + ::core::option::Option::Some(::core::convert::TryInto::try_into(type_)?) + } else { + ::core::option::Option::None + }, + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ConnectRequest { + pub dtls_parameters: ::planus::alloc::boxed::Box, + } + + impl ConnectRequest { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_dtls_parameters); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ConnectRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ConnectRequest::create(builder, &self.dtls_parameters) + } + } + + #[derive(Copy, Clone)] + pub struct ConnectRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ConnectRequestRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct ConnectResponse { + pub dtls_local_role: ::planus::alloc::string::String, + } + + impl ConnectResponse { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_dtls_local_role: impl ::planus::WriteAs<::planus::Offset>, + ) -> ::planus::Offset { + let prepared_dtls_local_role = field_dtls_local_role.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_dtls_local_role); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for ConnectResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ConnectResponse::create(builder, &self.dtls_local_role) + } + } + + #[derive(Copy, Clone)] + pub struct ConnectResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> ConnectResponseRef<'a> { + pub fn dtls_local_role(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(0, "ConnectResponse", "dtls_local_role") + } + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct DumpResponse { + pub base: ::planus::alloc::boxed::Box, + pub ice_role: ::planus::alloc::string::String, + pub ice_parameters: ::planus::alloc::boxed::Box, + pub ice_candidates: ::planus::alloc::vec::Vec, + pub ice_state: ::planus::alloc::string::String, + pub ice_selected_tuple: + ::core::option::Option<::planus::alloc::boxed::Box>, + pub dtls_parameters: ::planus::alloc::boxed::Box, + pub dtls_state: ::planus::alloc::string::String, + } + + impl DumpResponse { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_base: impl ::planus::WriteAs<::planus::Offset>, + field_ice_role: impl ::planus::WriteAs<::planus::Offset>, + field_ice_parameters: impl ::planus::WriteAs<::planus::Offset>, + field_ice_candidates: impl ::planus::WriteAs< + ::planus::Offset<[::planus::Offset]>, + >, + field_ice_state: impl ::planus::WriteAs<::planus::Offset>, + field_ice_selected_tuple: impl ::planus::WriteAsOptional< + ::planus::Offset, + >, + field_dtls_parameters: impl ::planus::WriteAs< + ::planus::Offset, + >, + field_dtls_state: impl ::planus::WriteAs<::planus::Offset>, + ) -> ::planus::Offset { + let prepared_base = field_base.prepare(builder); + + let prepared_ice_role = field_ice_role.prepare(builder); + + 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); + + 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); + + let mut table_writer = + ::planus::table_writer::TableWriter::<18, 32>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + table_writer.calculate_size::<::planus::Offset>(6); + table_writer + .calculate_size::<::planus::Offset<[::planus::Offset]>>( + 8, + ); + table_writer.calculate_size::<::planus::Offset>(10); + if prepared_ice_selected_tuple.is_some() { + table_writer + .calculate_size::<::planus::Offset>(12); + } + table_writer.calculate_size::<::planus::Offset>(14); + table_writer.calculate_size::<::planus::Offset>(16); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_base); + table_writer.write::<_, _, 4>(1, &prepared_ice_role); + table_writer.write::<_, _, 4>(2, &prepared_ice_parameters); + table_writer.write::<_, _, 4>(3, &prepared_ice_candidates); + table_writer.write::<_, _, 4>(4, &prepared_ice_state); + if let ::core::option::Option::Some(prepared_ice_selected_tuple) = + prepared_ice_selected_tuple + { + table_writer.write::<_, _, 4>(5, &prepared_ice_selected_tuple); + } + table_writer.write::<_, _, 4>(6, &prepared_dtls_parameters); + table_writer.write::<_, _, 4>(7, &prepared_dtls_state); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DumpResponseRef<'a> { + pub fn base(&self) -> ::planus::Result> { + self.0.access_required(0, "DumpResponse", "base") + } + + pub fn ice_role(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(1, "DumpResponse", "ice_role") + } + + pub fn ice_parameters(&self) -> ::planus::Result> { + self.0.access_required(2, "DumpResponse", "ice_parameters") + } + + pub fn ice_candidates( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result>>, + > { + self.0.access_required(3, "DumpResponse", "ice_candidates") + } + + pub fn ice_state(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(4, "DumpResponse", "ice_state") + } + + pub fn ice_selected_tuple( + &self, + ) -> ::planus::Result<::core::option::Option>> + { + self.0.access(5, "DumpResponse", "ice_selected_tuple") + } + + pub fn dtls_parameters(&self) -> ::planus::Result> { + self.0.access_required(6, "DumpResponse", "dtls_parameters") + } + + pub fn dtls_state(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(7, "DumpResponse", "dtls_state") + } + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct GetStatsResponse { + pub base: ::planus::alloc::boxed::Box, + pub ice_role: ::planus::alloc::string::String, + pub ice_state: ::planus::alloc::string::String, + pub ice_selected_tuple: + ::core::option::Option<::planus::alloc::boxed::Box>, + pub dtls_state: ::planus::alloc::string::String, + } + + impl GetStatsResponse { + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_base: impl ::planus::WriteAs<::planus::Offset>, + field_ice_role: impl ::planus::WriteAs<::planus::Offset>, + field_ice_state: impl ::planus::WriteAs<::planus::Offset>, + field_ice_selected_tuple: impl ::planus::WriteAsOptional< + ::planus::Offset, + >, + field_dtls_state: impl ::planus::WriteAs<::planus::Offset>, + ) -> ::planus::Offset { + let prepared_base = field_base.prepare(builder); + + let prepared_ice_role = field_ice_role.prepare(builder); + + let prepared_ice_state = field_ice_state.prepare(builder); + + let prepared_ice_selected_tuple = field_ice_selected_tuple.prepare(builder); + + let prepared_dtls_state = field_dtls_state.prepare(builder); + + let mut table_writer = + ::planus::table_writer::TableWriter::<12, 20>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + table_writer.calculate_size::<::planus::Offset>(4); + table_writer.calculate_size::<::planus::Offset>(6); + if prepared_ice_selected_tuple.is_some() { + table_writer.calculate_size::<::planus::Offset>(8); + } + table_writer.calculate_size::<::planus::Offset>(10); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_base); + table_writer.write::<_, _, 4>(1, &prepared_ice_role); + table_writer.write::<_, _, 4>(2, &prepared_ice_state); + if let ::core::option::Option::Some(prepared_ice_selected_tuple) = + prepared_ice_selected_tuple + { + table_writer.write::<_, _, 4>(3, &prepared_ice_selected_tuple); + } + table_writer.write::<_, _, 4>(4, &prepared_dtls_state); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> GetStatsResponseRef<'a> { + pub fn base(&self) -> ::planus::Result> { + self.0.access_required(0, "GetStatsResponse", "base") + } + + pub fn ice_role(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(1, "GetStatsResponse", "ice_role") + } + + pub fn ice_state(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(2, "GetStatsResponse", "ice_state") + } + + pub fn ice_selected_tuple( + &self, + ) -> ::planus::Result<::core::option::Option>> + { + self.0.access(3, "GetStatsResponse", "ice_selected_tuple") + } + + pub fn dtls_state(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(4, "GetStatsResponse", "dtls_state") + } + } + + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct IceSelectedTupleChangeNotification { + pub tuple: ::planus::alloc::boxed::Box, + } + + impl IceSelectedTupleChangeNotification { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_tuple); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for IceSelectedTupleChangeNotification + { + type Prepared = ::planus::Offset; + + 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; + + 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 + { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + IceSelectedTupleChangeNotification::create(builder, &self.tuple) + } + } + + #[derive(Copy, Clone)] + pub struct IceSelectedTupleChangeNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> IceSelectedTupleChangeNotificationRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + #[repr(u8)] + pub enum IceState { + New = 0, + Connected = 1, + Completed = 2, + Disconnected = 3, + Closed = 4, + } + + impl ::core::convert::TryFrom for IceState { + type Error = ::planus::errors::UnknownEnumTagKind; + 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), + 4 => ::core::result::Result::Ok(IceState::Closed), + + _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { + tag: value as i128, + }), + } + } + } + + impl ::core::convert::From for u8 { + 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 { + 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 = ::from_buffer(buffer, 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; + + 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, + ); + } + } + } + + #[derive( + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + #[repr(u8)] + pub enum DtlsState { + New = 0, + Connecting = 1, + Connected = 2, + Failed = 3, + Closed = 4, + } + + impl ::core::convert::TryFrom for DtlsState { + type Error = ::planus::errors::UnknownEnumTagKind; + 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 { + 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 { + 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 = ::from_buffer(buffer, 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; + + 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, + ); + } + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct 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 { + #[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::<4, 1>::new(builder); + + if prepared_ice_state.is_some() { + table_writer.calculate_size::(2); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_ice_state) = prepared_ice_state + { + table_writer.write::<_, _, 1>(0, &prepared_ice_state); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for IceStateChangeNotification + { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + IceStateChangeNotification::create(builder, &self.ice_state) + } + } + + #[derive(Copy, Clone)] + pub struct IceStateChangeNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> IceStateChangeNotificationRef<'a> { + 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> { + 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; + 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, + ) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct DtlsStateChangeNotification { + pub dtls_state: self::DtlsState, + 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 { + #[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::<6, 5>::new(builder); + + if prepared_dtls_state.is_some() { + table_writer.calculate_size::(2); + } + if prepared_remote_cert.is_some() { + table_writer.calculate_size::<::planus::Offset>(4); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_remote_cert) = + prepared_remote_cert + { + table_writer.write::<_, _, 4>(1, &prepared_remote_cert); + } + if let ::core::option::Option::Some(prepared_dtls_state) = + prepared_dtls_state + { + table_writer.write::<_, _, 1>(0, &prepared_dtls_state); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> + for DtlsStateChangeNotification + { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + DtlsStateChangeNotification::create( + builder, + &self.dtls_state, + &self.remote_cert, + ) + } + } + + #[derive(Copy, Clone)] + pub struct DtlsStateChangeNotificationRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> DtlsStateChangeNotificationRef<'a> { + pub fn dtls_state(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "DtlsStateChangeNotification", "dtls_state")? + .unwrap_or(self::DtlsState::New), + ) + } + + 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> { + 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; + 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, + ) + }) + } + } + } + pub mod rtp_observer { + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct AddProducerRequest { + pub producer_id: ::planus::alloc::string::String, + } + + impl AddProducerRequest { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_producer_id); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for AddProducerRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + AddProducerRequest::create(builder, &self.producer_id) + } + } + + #[derive(Copy, Clone)] + pub struct AddProducerRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> AddProducerRequestRef<'a> { + 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> { + 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; + 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) + }) + } + } + + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct RemoveProducerRequest { + pub producer_id: ::planus::alloc::string::String, + } + + impl RemoveProducerRequest { + #[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::<4, 4>::new(builder); + + table_writer.calculate_size::<::planus::Offset>(2); + + table_writer.finish_calculating(); + + unsafe { + table_writer.write::<_, _, 4>(0, &prepared_producer_id); + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RemoveProducerRequest { + type Prepared = ::planus::Offset; + + 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; + + 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 { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + RemoveProducerRequest::create(builder, &self.producer_id) + } + } + + #[derive(Copy, Clone)] + pub struct RemoveProducerRequestRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RemoveProducerRequestRef<'a> { + 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> { + 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; + 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 7d62f481ed..c55b6f2b8f 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -49,6 +49,7 @@ //! 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 865954b592..e09f22b5af 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -25,7 +25,7 @@ use crate::srtp_parameters::{SrtpCryptoSuite, SrtpParameters}; use crate::transport::{TransportId, TransportTraceEventType}; use crate::webrtc_server::{WebRtcServerDump, WebRtcServerId, WebRtcServerListenInfos}; use crate::webrtc_transport::{TransportListenIps, WebRtcTransportListen, WebRtcTransportOptions}; -use crate::worker::{WorkerDump, WorkerUpdateSettings}; +use crate::worker::WorkerDump; use parking_lot::Mutex; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; @@ -158,15 +158,6 @@ request_response!( WorkerDump ); -request_response!( - &'static str, - "worker.updateSettings", - WorkerUpdateSettingsRequest { - #[serde(flatten)] - data: WorkerUpdateSettings, - }, -); - request_response!( &'static str, "worker.createWebRtcServer", @@ -195,14 +186,6 @@ request_response!( WebRtcServerDump, ); -request_response!( - &'static str, - "worker.createRouter", - WorkerCreateRouterRequest { - router_id: RouterId, - }, -); - request_response!( &'static str, "worker.closeRouter", diff --git a/rust/src/router.rs b/rust/src/router.rs index 4ee29355da..bca8accb7e 100644 --- a/rust/src/router.rs +++ b/rust/src/router.rs @@ -51,7 +51,7 @@ use crate::transport::{ TransportId, }; use crate::webrtc_transport::{WebRtcTransport, WebRtcTransportListen, WebRtcTransportOptions}; -use crate::worker::{Channel, PayloadChannel, RequestError, Worker}; +use crate::worker::{Channel, RequestError, Worker}; use crate::{ortc, uuid_based_wrapper_type}; use async_executor::Executor; use async_lock::Mutex as AsyncMutex; @@ -367,7 +367,6 @@ struct Inner { executor: Arc>, rtp_capabilities: RtpCapabilitiesFinalized, channel: Channel, - payload_channel: PayloadChannel, handlers: Arc, app_data: AppData, producers: Arc>>, @@ -441,7 +440,6 @@ impl Router { id: RouterId, executor: Arc>, channel: Channel, - payload_channel: PayloadChannel, rtp_capabilities: RtpCapabilitiesFinalized, app_data: AppData, worker: Worker, @@ -473,7 +471,6 @@ impl Router { executor, rtp_capabilities, channel, - payload_channel, handlers, producers, data_producers, @@ -576,7 +573,6 @@ impl Router { transport_id, Arc::clone(&self.inner.executor), self.inner.channel.clone(), - self.inner.payload_channel.clone(), direct_transport_options.app_data, self.clone(), ); @@ -637,7 +633,6 @@ impl Router { transport_id, Arc::clone(&self.inner.executor), self.inner.channel.clone(), - self.inner.payload_channel.clone(), data, webrtc_transport_options.app_data, self.clone(), @@ -703,7 +698,6 @@ impl Router { transport_id, Arc::clone(&self.inner.executor), self.inner.channel.clone(), - self.inner.payload_channel.clone(), data, pipe_transport_options.app_data, self.clone(), @@ -765,7 +759,6 @@ impl Router { transport_id, Arc::clone(&self.inner.executor), self.inner.channel.clone(), - self.inner.payload_channel.clone(), data, plain_transport_options.app_data, self.clone(), diff --git a/rust/src/router/consumer.rs b/rust/src/router/consumer.rs index 7cc9e6b223..fc45857d80 100644 --- a/rust/src/router/consumer.rs +++ b/rust/src/router/consumer.rs @@ -12,7 +12,7 @@ use crate::rtp_parameters::{MediaKind, MimeType, RtpCapabilities, RtpParameters} use crate::scalability_modes::ScalabilityMode; use crate::transport::Transport; use crate::uuid_based_wrapper_type; -use crate::worker::{Channel, PayloadChannel, RequestError, SubscriptionHandler}; +use crate::worker::{Channel, RequestError, SubscriptionHandler}; use async_executor::Executor; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; @@ -341,17 +341,13 @@ enum Notification { ProducerClose, ProducerPause, ProducerResume, + // TODO. + // Rtp, Score(ConsumerScore), LayersChange(Option), Trace(ConsumerTraceEventData), } -#[derive(Debug, Deserialize)] -#[serde(tag = "event", rename_all = "lowercase", content = "data")] -enum PayloadNotification { - Rtp, -} - #[derive(Default)] #[allow(clippy::type_complexity)] struct Handlers { @@ -468,7 +464,6 @@ impl Consumer { paused: bool, executor: Arc>, channel: Channel, - payload_channel: &PayloadChannel, producer_paused: bool, score: ConsumerScore, preferred_layers: Option, @@ -541,6 +536,14 @@ impl Consumer { handlers.resume.call_simple(); } } + /* + * TODO. + Notification::Rtp => { + handlers.rtp.call(|callback| { + callback(notification); + }); + } + */ Notification::Score(consumer_score) => { *score.lock() = consumer_score.clone(); handlers.score.call_simple(&consumer_score); @@ -560,25 +563,6 @@ impl Consumer { }) }; - let payload_subscription_handler = { - let handlers = Arc::clone(&handlers); - - payload_channel.subscribe_to_notifications(id.into(), move |message, payload| { - match serde_json::from_slice::(message) { - Ok(notification) => match notification { - PayloadNotification::Rtp => { - handlers.rtp.call(|callback| { - callback(payload); - }); - } - }, - Err(error) => { - error!("Failed to parse payload notification: {}", error); - } - } - }) - }; - let on_transport_close_handler = transport.on_close({ let inner_weak = Arc::clone(&inner_weak); @@ -609,10 +593,7 @@ impl Consumer { transport, weak_producer: producer.downgrade(), closed, - _subscription_handlers: Mutex::new(vec![ - subscription_handler, - payload_subscription_handler, - ]), + _subscription_handlers: Mutex::new(vec![subscription_handler]), _on_transport_close_handler: Mutex::new(on_transport_close_handler), }); diff --git a/rust/src/router/data_consumer.rs b/rust/src/router/data_consumer.rs index 5477e31400..73d8f0da8e 100644 --- a/rust/src/router/data_consumer.rs +++ b/rust/src/router/data_consumer.rs @@ -11,13 +11,14 @@ use crate::messages::{ use crate::sctp_parameters::SctpStreamParameters; use crate::transport::Transport; use crate::uuid_based_wrapper_type; -use crate::worker::{Channel, PayloadChannel, RequestError, SubscriptionHandler}; +use crate::worker::{Channel, RequestError, SubscriptionHandler}; use async_executor::Executor; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; -use std::borrow::Cow; +// TODO. +// use std::borrow::Cow; use std::fmt; use std::fmt::Debug; use std::sync::atomic::{AtomicBool, Ordering}; @@ -168,18 +169,14 @@ pub enum DataConsumerType { enum Notification { DataProducerClose, SctpSendBufferFull, + // TODO. + // Message { ppid: u32 }, #[serde(rename_all = "camelCase")] BufferedAmountLow { buffered_amount: u32, }, } -#[derive(Debug, Deserialize)] -#[serde(tag = "event", rename_all = "lowercase", content = "data")] -enum PayloadNotification { - Message { ppid: u32 }, -} - #[derive(Default)] #[allow(clippy::type_complexity)] struct Handlers { @@ -201,7 +198,6 @@ struct Inner { direct: bool, executor: Arc>, channel: Channel, - payload_channel: PayloadChannel, handlers: Arc, app_data: AppData, transport: Arc, @@ -345,7 +341,6 @@ impl DataConsumer { data_producer: DataProducer, executor: Arc>, channel: Channel, - payload_channel: PayloadChannel, app_data: AppData, transport: Arc, direct: bool, @@ -386,30 +381,13 @@ impl DataConsumer { Notification::SctpSendBufferFull => { handlers.sctp_send_buffer_full.call_simple(); } - Notification::BufferedAmountLow { buffered_amount } => { - handlers.buffered_amount_low.call(|callback| { - callback(buffered_amount); - }); - } - }, - Err(error) => { - error!("Failed to parse notification: {}", error); - } - } - }) - }; - - let payload_subscription_handler = { - let handlers = Arc::clone(&handlers); - - payload_channel.subscribe_to_notifications(id.into(), move |message, payload| { - match serde_json::from_slice::(message) { - Ok(notification) => match notification { - PayloadNotification::Message { ppid } => { - match WebRtcMessage::new(ppid, Cow::from(payload)) { + /* + * TODO. + Notification::Message { ppid } => { + match WebRtcMessage::new(ppid, Cow::from(_notification)) { Ok(message) => { handlers.message.call(|callback| { - callback(&message); + callback(&_notification); }); } Err(ppid) => { @@ -417,9 +395,15 @@ impl DataConsumer { } } } + */ + Notification::BufferedAmountLow { buffered_amount } => { + handlers.buffered_amount_low.call(|callback| { + callback(buffered_amount); + }); + } }, Err(error) => { - error!("Failed to parse payload notification: {}", error); + error!("Failed to parse notification: {}", error); } } }) @@ -446,16 +430,12 @@ impl DataConsumer { direct, executor, channel, - payload_channel, handlers, app_data, transport, weak_data_producer: data_producer.downgrade(), closed, - _subscription_handlers: Mutex::new(vec![ - subscription_handler, - payload_subscription_handler, - ]), + _subscription_handlers: Mutex::new(vec![subscription_handler]), _on_transport_close_handler: Mutex::new(on_transport_close_handler), }); @@ -667,18 +647,15 @@ impl DataConsumer { } } +// TODO: used because 'payload' is not being used yet. impl DirectDataConsumer { /// Sends direct messages from the Rust process. pub async fn send(&self, message: WebRtcMessage<'_>) -> Result<(), RequestError> { - let (ppid, payload) = message.into_ppid_and_payload(); + let (ppid, _payload) = message.into_ppid_and_payload(); self.inner - .payload_channel - .request( - self.inner.id, - DataConsumerSendRequest { ppid }, - payload.into_owned(), - ) + .channel + .request(self.inner.id, DataConsumerSendRequest { ppid }) .await } } diff --git a/rust/src/router/data_producer.rs b/rust/src/router/data_producer.rs index 64e9f2ad55..8a5daa0398 100644 --- a/rust/src/router/data_producer.rs +++ b/rust/src/router/data_producer.rs @@ -9,7 +9,7 @@ use crate::messages::{ use crate::sctp_parameters::SctpStreamParameters; use crate::transport::Transport; use crate::uuid_based_wrapper_type; -use crate::worker::{Channel, NotificationError, PayloadChannel, RequestError}; +use crate::worker::{Channel, NotificationError, RequestError}; use async_executor::Executor; use event_listener_primitives::{BagOnce, HandlerId}; use log::{debug, error}; @@ -137,7 +137,6 @@ struct Inner { direct: bool, executor: Arc>, channel: Channel, - payload_channel: PayloadChannel, handlers: Arc, app_data: AppData, transport: Arc, @@ -269,7 +268,6 @@ impl DataProducer { protocol: String, executor: Arc>, channel: Channel, - payload_channel: PayloadChannel, app_data: AppData, transport: Arc, direct: bool, @@ -299,7 +297,6 @@ impl DataProducer { direct, executor, channel, - payload_channel, handlers, app_data, transport, @@ -431,12 +428,12 @@ impl DataProducer { impl DirectDataProducer { /// Sends direct messages from the Rust to the worker. pub fn send(&self, message: WebRtcMessage<'_>) -> Result<(), NotificationError> { - let (ppid, payload) = message.into_ppid_and_payload(); + let (ppid, _payload) = message.into_ppid_and_payload(); - self.inner.payload_channel.notify( + self.inner.channel.notify( self.inner.id, DataProducerSendNotification { ppid }, - payload.into_owned(), + // payload.into_owned(), ) } } diff --git a/rust/src/router/direct_transport.rs b/rust/src/router/direct_transport.rs index 4658bb0564..87272f8e18 100644 --- a/rust/src/router/direct_transport.rs +++ b/rust/src/router/direct_transport.rs @@ -15,9 +15,7 @@ use crate::transport::{ RtpListener, SctpListener, Transport, TransportGeneric, TransportId, TransportTraceEventData, TransportTraceEventType, }; -use crate::worker::{ - Channel, NotificationError, PayloadChannel, RequestError, SubscriptionHandler, -}; +use crate::worker::{Channel, NotificationError, RequestError, SubscriptionHandler}; use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::{Bag, BagOnce, HandlerId}; @@ -126,12 +124,8 @@ struct Handlers { #[serde(tag = "event", rename_all = "lowercase", content = "data")] enum Notification { Trace(TransportTraceEventData), -} - -#[derive(Debug, Deserialize)] -#[serde(tag = "event", rename_all = "lowercase", content = "data")] -enum PayloadNotification { - Rtcp, + // TODO. + // Rtcp, } struct Inner { @@ -141,7 +135,6 @@ struct Inner { cname_for_producers: Mutex>, executor: Arc>, channel: Channel, - payload_channel: PayloadChannel, handlers: Arc, app_data: AppData, // Make sure router is not dropped until this transport is not dropped @@ -401,10 +394,6 @@ impl TransportImpl for DirectTransport { &self.inner.channel } - fn payload_channel(&self) -> &PayloadChannel { - &self.inner.payload_channel - } - fn executor(&self) -> &Arc> { &self.inner.executor } @@ -427,7 +416,6 @@ impl DirectTransport { id: TransportId, executor: Arc>, channel: Channel, - payload_channel: PayloadChannel, app_data: AppData, router: Router, ) -> Self { @@ -443,7 +431,14 @@ impl DirectTransport { Ok(notification) => match notification { Notification::Trace(trace_event_data) => { handlers.trace.call_simple(&trace_event_data); - } + } /* + * TODO. + Notification::Rtcp => { + handlers.rtcp.call(|callback| { + callback(notification); + }); + } + */ }, Err(error) => { error!("Failed to parse notification: {}", error); @@ -452,25 +447,6 @@ impl DirectTransport { }) }; - let payload_subscription_handler = { - let handlers = Arc::clone(&handlers); - - payload_channel.subscribe_to_notifications(id.into(), move |message, payload| { - match serde_json::from_slice::(message) { - Ok(notification) => match notification { - PayloadNotification::Rtcp => { - handlers.rtcp.call(|callback| { - callback(payload); - }); - } - }, - Err(error) => { - error!("Failed to parse payload notification: {}", error); - } - } - }) - }; - let next_mid_for_consumers = AtomicUsize::default(); let used_sctp_stream_ids = Mutex::new(IntMap::default()); let cname_for_producers = Mutex::new(None); @@ -493,15 +469,11 @@ impl DirectTransport { cname_for_producers, executor, channel, - payload_channel, handlers, app_data, router, closed: AtomicBool::new(false), - _subscription_handlers: Mutex::new(vec![ - subscription_handler, - payload_subscription_handler, - ]), + _subscription_handlers: Mutex::new(vec![subscription_handler]), _on_router_close_handler: Mutex::new(on_router_close_handler), }); @@ -513,10 +485,10 @@ impl DirectTransport { /// Send a RTCP packet from the Rust process. /// /// * `rtcp_packet` - Bytes containing a valid RTCP packet (can be a compound packet). - pub fn send_rtcp(&self, rtcp_packet: Vec) -> Result<(), NotificationError> { + pub fn send_rtcp(&self, _rtcp_packet: Vec) -> Result<(), NotificationError> { self.inner - .payload_channel - .notify(self.id(), TransportSendRtcpNotification {}, rtcp_packet) + .channel + .notify(self.id(), TransportSendRtcpNotification {}) } /// Callback is called when the direct transport receives a RTCP packet from its router. diff --git a/rust/src/router/pipe_transport.rs b/rust/src/router/pipe_transport.rs index 187811d494..cb064463bc 100644 --- a/rust/src/router/pipe_transport.rs +++ b/rust/src/router/pipe_transport.rs @@ -16,7 +16,7 @@ use crate::transport::{ RtpListener, SctpListener, Transport, TransportGeneric, TransportId, TransportTraceEventData, TransportTraceEventType, }; -use crate::worker::{Channel, PayloadChannel, RequestError, SubscriptionHandler}; +use crate::worker::{Channel, RequestError, SubscriptionHandler}; use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::{Bag, BagOnce, HandlerId}; @@ -188,7 +188,6 @@ struct Inner { cname_for_producers: Mutex>, executor: Arc>, channel: Channel, - payload_channel: PayloadChannel, handlers: Arc, data: Arc, app_data: AppData, @@ -437,10 +436,6 @@ impl TransportImpl for PipeTransport { &self.inner.channel } - fn payload_channel(&self) -> &PayloadChannel { - &self.inner.payload_channel - } - fn executor(&self) -> &Arc> { &self.inner.executor } @@ -463,7 +458,6 @@ impl PipeTransport { id: TransportId, executor: Arc>, channel: Channel, - payload_channel: PayloadChannel, data: PipeTransportData, app_data: AppData, router: Router, @@ -528,7 +522,6 @@ impl PipeTransport { cname_for_producers, executor, channel, - payload_channel, handlers, data, app_data, diff --git a/rust/src/router/plain_transport.rs b/rust/src/router/plain_transport.rs index ee15cb195d..c806751d50 100644 --- a/rust/src/router/plain_transport.rs +++ b/rust/src/router/plain_transport.rs @@ -16,7 +16,7 @@ use crate::transport::{ RtpListener, SctpListener, Transport, TransportGeneric, TransportId, TransportTraceEventData, TransportTraceEventType, }; -use crate::worker::{Channel, PayloadChannel, RequestError, SubscriptionHandler}; +use crate::worker::{Channel, RequestError, SubscriptionHandler}; use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::{Bag, BagOnce, HandlerId}; @@ -225,7 +225,6 @@ struct Inner { cname_for_producers: Mutex>, executor: Arc>, channel: Channel, - payload_channel: PayloadChannel, handlers: Arc, data: Arc, app_data: AppData, @@ -467,10 +466,6 @@ impl TransportImpl for PlainTransport { &self.inner.channel } - fn payload_channel(&self) -> &PayloadChannel { - &self.inner.payload_channel - } - fn executor(&self) -> &Arc> { &self.inner.executor } @@ -493,7 +488,6 @@ impl PlainTransport { id: TransportId, executor: Arc>, channel: Channel, - payload_channel: PayloadChannel, data: PlainTransportData, app_data: AppData, router: Router, @@ -568,7 +562,6 @@ impl PlainTransport { cname_for_producers, executor, channel, - payload_channel, handlers, data, app_data, diff --git a/rust/src/router/producer.rs b/rust/src/router/producer.rs index 17549fd822..3ee856b797 100644 --- a/rust/src/router/producer.rs +++ b/rust/src/router/producer.rs @@ -11,9 +11,7 @@ pub use crate::ortc::RtpMapping; use crate::rtp_parameters::{MediaKind, MimeType, RtpParameters}; use crate::transport::Transport; use crate::uuid_based_wrapper_type; -use crate::worker::{ - Channel, NotificationError, PayloadChannel, RequestError, SubscriptionHandler, -}; +use crate::worker::{Channel, NotificationError, RequestError, SubscriptionHandler}; use async_executor::Executor; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use hash_hasher::HashedMap; @@ -299,7 +297,6 @@ struct Inner { score: Arc>>, executor: Arc>, channel: Channel, - payload_channel: PayloadChannel, handlers: Arc, app_data: AppData, transport: Arc, @@ -441,7 +438,6 @@ impl Producer { paused: bool, executor: Arc>, channel: Channel, - payload_channel: PayloadChannel, app_data: AppData, transport: Arc, direct: bool, @@ -503,7 +499,6 @@ impl Producer { score, executor, channel, - payload_channel, handlers, app_data, transport, @@ -745,10 +740,10 @@ impl Producer { impl DirectProducer { /// Sends a RTP packet from the Rust process. - pub fn send(&self, rtp_packet: Vec) -> Result<(), NotificationError> { + pub fn send(&self, _rtp_packet: Vec) -> Result<(), NotificationError> { self.inner - .payload_channel - .notify(self.inner.id, ProducerSendNotification {}, rtp_packet) + .channel + .notify(self.inner.id, ProducerSendNotification {}) } } diff --git a/rust/src/router/transport.rs b/rust/src/router/transport.rs index 5e7eca730b..d15771596e 100644 --- a/rust/src/router/transport.rs +++ b/rust/src/router/transport.rs @@ -15,7 +15,7 @@ use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::Router; use crate::rtp_parameters::{MediaKind, RtpEncodingParameters}; use crate::sctp_parameters::SctpStreamParameters; -use crate::worker::{Channel, PayloadChannel, RequestError}; +use crate::worker::{Channel, RequestError}; use crate::{ortc, uuid_based_wrapper_type}; use async_executor::Executor; use async_trait::async_trait; @@ -333,8 +333,6 @@ pub enum ConsumeDataError { pub(super) trait TransportImpl: TransportGeneric { fn channel(&self) -> &Channel; - fn payload_channel(&self) -> &PayloadChannel; - fn executor(&self) -> &Arc>; fn next_mid_for_consumers(&self) -> &AtomicUsize; @@ -493,7 +491,6 @@ pub(super) trait TransportImpl: TransportGeneric { paused, Arc::clone(self.executor()), self.channel().clone(), - self.payload_channel().clone(), app_data, Arc::new(self.clone()), transport_type == TransportType::Direct, @@ -597,7 +594,6 @@ pub(super) trait TransportImpl: TransportGeneric { response.paused, Arc::clone(self.executor()), self.channel().clone(), - self.payload_channel(), response.producer_paused, response.score, response.preferred_layers, @@ -668,7 +664,6 @@ pub(super) trait TransportImpl: TransportGeneric { response.protocol, Arc::clone(self.executor()), self.channel().clone(), - self.payload_channel().clone(), app_data, Arc::new(self.clone()), transport_type == TransportType::Direct, @@ -764,7 +759,6 @@ pub(super) trait TransportImpl: TransportGeneric { data_producer, Arc::clone(self.executor()), self.channel().clone(), - self.payload_channel().clone(), app_data, Arc::new(self.clone()), transport_type == TransportType::Direct, diff --git a/rust/src/router/webrtc_transport.rs b/rust/src/router/webrtc_transport.rs index 53a1ac08ca..c2604ff519 100644 --- a/rust/src/router/webrtc_transport.rs +++ b/rust/src/router/webrtc_transport.rs @@ -22,7 +22,7 @@ use crate::transport::{ TransportTraceEventType, }; use crate::webrtc_server::WebRtcServer; -use crate::worker::{Channel, PayloadChannel, RequestError, SubscriptionHandler}; +use crate::worker::{Channel, RequestError, SubscriptionHandler}; use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::{Bag, BagOnce, HandlerId}; @@ -312,7 +312,6 @@ struct Inner { cname_for_producers: Mutex>, executor: Arc>, channel: Channel, - payload_channel: PayloadChannel, handlers: Arc, data: Arc, app_data: AppData, @@ -565,10 +564,6 @@ impl TransportImpl for WebRtcTransport { &self.inner.channel } - fn payload_channel(&self) -> &PayloadChannel { - &self.inner.payload_channel - } - fn executor(&self) -> &Arc> { &self.inner.executor } @@ -592,7 +587,6 @@ impl WebRtcTransport { id: TransportId, executor: Arc>, channel: Channel, - payload_channel: PayloadChannel, data: WebRtcTransportData, app_data: AppData, router: Router, @@ -697,7 +691,6 @@ impl WebRtcTransport { cname_for_producers, executor, channel, - payload_channel, handlers, data, app_data, diff --git a/rust/src/worker.rs b/rust/src/worker.rs index 431b2a9222..2cbf4cad1c 100644 --- a/rust/src/worker.rs +++ b/rust/src/worker.rs @@ -3,14 +3,11 @@ mod channel; mod common; -mod payload_channel; mod utils; use crate::data_structures::AppData; -use crate::messages::{ - WorkerCloseRequest, WorkerCreateRouterRequest, WorkerCreateWebRtcServerRequest, - WorkerDumpRequest, WorkerUpdateSettingsRequest, -}; +use crate::fbs; +use crate::messages::{WorkerCreateWebRtcServerRequest, WorkerDumpRequest}; pub use crate::ortc::RtpCapabilitiesError; use crate::router::{Router, RouterId, RouterOptions}; use crate::webrtc_server::{WebRtcServer, WebRtcServerId, WebRtcServerOptions}; @@ -19,13 +16,13 @@ pub use crate::worker::utils::ExitError; use crate::worker_manager::WorkerManager; use crate::{ortc, uuid_based_wrapper_type}; use async_executor::Executor; -pub(crate) use channel::Channel; +pub(crate) use channel::{Channel, NotificationError}; pub(crate) use common::{SubscriptionHandler, SubscriptionTarget}; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use futures_lite::FutureExt; use log::{debug, error, warn}; use parking_lot::Mutex; -pub(crate) use payload_channel::{NotificationError, PayloadChannel}; +use planus::Builder; use serde::{Deserialize, Serialize}; use std::ops::RangeInclusive; use std::path::PathBuf; @@ -272,8 +269,7 @@ pub struct WorkerUpdateSettings { #[doc(hidden)] pub struct ChannelMessageHandlers { pub channel_request_handlers: Vec, - pub payload_channel_request_handlers: Vec, - pub payload_channel_notification_handlers: Vec, + pub channel_notification_handlers: Vec, } #[derive(Debug, Clone, Deserialize, Serialize)] @@ -320,7 +316,6 @@ struct Handlers { struct Inner { id: WorkerId, channel: Channel, - payload_channel: PayloadChannel, executor: Arc>, handlers: Handlers, app_data: AppData, @@ -406,7 +401,6 @@ impl Inner { let (mut status_sender, status_receiver) = async_oneshot::oneshot(); let WorkerRunResult { channel, - payload_channel, buffer_worker_messages_guard, } = utils::run_worker_with_channels( id, @@ -424,7 +418,6 @@ impl Inner { let mut inner = Self { id, channel, - payload_channel, executor, handlers, app_data, @@ -489,21 +482,20 @@ impl Inner { let (sender, receiver) = async_oneshot::oneshot(); let id = self.id; let sender = Mutex::new(Some(sender)); - let _handler = self.channel.subscribe_to_notifications( - std::process::id().into(), + let _handler = self.channel.subscribe_to_fbs_notifications( + SubscriptionTarget::String(std::process::id().to_string()), move |notification| { - let result = match serde_json::from_slice(notification) { - Ok(Notification::Running) => { + let result = match notification.event().unwrap() { + fbs::notification::Event::WorkerRunning => { debug!("worker thread running [id:{}]", id); Ok(()) } - Err(error) => Err(io::Error::new( + _ => Err(io::Error::new( io::ErrorKind::Other, - format!( - "unexpected first notification from worker [id:{id}]: {notification:?}; error = {error}" - ), + format!("unexpected first notification from worker [id:{id}]"), )), }; + let _ = sender .lock() .take() @@ -522,7 +514,6 @@ impl Inner { fn setup_message_handling(&mut self) { let channel_receiver = self.channel.get_internal_message_receiver(); - let payload_channel_receiver = self.payload_channel.get_internal_message_receiver(); let id = self.id; let closed = Arc::clone(&self.closed); self.executor @@ -546,20 +537,6 @@ impl Inner { } }) .detach(); - - self.executor - .spawn(async move { - while let Ok(message) = payload_channel_receiver.recv().await { - match message { - payload_channel::InternalMessage::UnexpectedData(data) => error!( - "worker[id:{}] unexpected payload channel data: {}", - id, - String::from_utf8_lossy(&data) - ), - } - } - }) - .detach(); } fn close(&self) { @@ -567,15 +544,17 @@ impl Inner { if !already_closed { let channel = self.channel.clone(); - let payload_channel = self.payload_channel.clone(); + + let builder = Builder::new(); self.executor .spawn(async move { - let _ = channel.request("", WorkerCloseRequest {}).await; + let _ = channel + .request_fbs(builder, "", fbs::request::Method::WorkerClose, None) + .await; // Drop channels in here after response from worker drop(channel); - drop(payload_channel); }) .detach(); @@ -648,10 +627,29 @@ impl Worker { pub async fn update_settings(&self, data: WorkerUpdateSettings) -> Result<(), RequestError> { debug!("update_settings()"); - self.inner + let mut builder = Builder::new(); + let settings = fbs::worker::UpdateSettingsRequest::create( + &mut builder, + data.log_level.unwrap_or_default().as_str(), + data.log_tags + .map(|tags| tags.iter().map(|tag| tag.as_str()).collect::>()), + ); + let body = fbs::request::Body::create_update_settings_request(&mut builder, settings); + + match self + .inner .channel - .request("", WorkerUpdateSettingsRequest { data }) + .request_fbs( + builder, + "", + fbs::request::Method::WorkerUpdateSettings, + Some(body), + ) .await + { + Ok(_) => Ok(()), + Err(error) => Err(error), + } } /// Create a WebRtcServer. @@ -661,7 +659,7 @@ impl Worker { &self, webrtc_server_options: WebRtcServerOptions, ) -> Result { - debug!("create_router()"); + debug!("create_webrtc_server()"); let WebRtcServerOptions { listen_infos, @@ -724,9 +722,18 @@ impl Worker { let _buffer_guard = self.inner.channel.buffer_messages_for(router_id.into()); + let mut builder = Builder::new(); + let data = fbs::worker::CreateRouterRequest::create(&mut builder, router_id.to_string()); + let body = fbs::request::Body::create_create_router_request(&mut builder, data); + self.inner .channel - .request("", WorkerCreateRouterRequest { router_id }) + .request_fbs( + builder, + "", + fbs::request::Method::WorkerCreateRouter, + Some(body), + ) .await .map_err(CreateRouterError::Request)?; @@ -734,7 +741,6 @@ impl Worker { router_id, Arc::clone(&self.inner.executor), self.inner.channel.clone(), - self.inner.payload_channel.clone(), rtp_capabilities, app_data, self.clone(), diff --git a/rust/src/worker/channel.rs b/rust/src/worker/channel.rs index 7219903074..7ccee35b08 100644 --- a/rust/src/worker/channel.rs +++ b/rust/src/worker/channel.rs @@ -1,5 +1,8 @@ -use crate::messages::{Request, WorkerCloseRequest}; -use crate::worker::common::{EventHandlers, SubscriptionTarget, WeakEventHandlers}; +use crate::fbs::{message, notification, request, response}; +use crate::messages::{Notification, Request, WorkerCloseRequest}; +use crate::worker::common::{ + EventHandlers, FBSEventHandlers, FBSWeakEventHandlers, SubscriptionTarget, WeakEventHandlers, +}; use crate::worker::utils; use crate::worker::utils::{PreparedChannelRead, PreparedChannelWrite}; use crate::worker::{RequestError, SubscriptionHandler}; @@ -9,6 +12,7 @@ use log::{debug, error, trace, warn}; use lru::LruCache; use mediasoup_sys::UvAsyncT; use parking_lot::Mutex; +use planus::{Builder, ReadAsRoot, UnionOffset}; use serde::Deserialize; use serde_json::Value; use std::any::TypeId; @@ -17,6 +21,7 @@ use std::fmt::{Debug, Display}; use std::num::NonZeroUsize; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Weak}; +use thiserror::Error; #[derive(Debug, Deserialize)] #[serde(untagged)] @@ -38,11 +43,21 @@ pub(super) enum InternalMessage { Unexpected(Vec), } +#[derive(Debug, Error, Eq, PartialEq)] +pub enum NotificationError { + #[error("Channel already closed")] + ChannelClosed, +} + #[allow(clippy::type_complexity)] pub(crate) struct BufferMessagesGuard { target_id: SubscriptionTarget, buffered_notifications_for: Arc>>>>, + fbs_buffered_notifications_for: Arc>>>>, event_handlers_weak: WeakEventHandlers>, + fbs_event_handlers_weak: FBSWeakEventHandlers< + Arc) + Send + Sync + 'static>, + >, } impl Drop for BufferMessagesGuard { @@ -55,54 +70,54 @@ impl Drop for BufferMessagesGuard { } } } + + let mut fbs_buffered_notifications_for = self.fbs_buffered_notifications_for.lock(); + if let Some(notifications) = fbs_buffered_notifications_for.remove(&self.target_id) { + if let Some(event_handlers) = self.fbs_event_handlers_weak.upgrade() { + for notification in notifications { + let notification = + notification::NotificationRef::read_as_root(¬ification).unwrap(); + event_handlers.call_callbacks_with_single_value(&self.target_id, notification); + } + } + } } } -#[derive(Debug, Deserialize)] -#[serde(untagged)] -enum ChannelReceiveMessage { - #[serde(rename_all = "camelCase")] - Notification { - target_id: SubscriptionTarget, - }, - ResponseSuccess { - id: u32, - // The following field is present, unused, but needed for differentiating successful - // response from error case - #[allow(dead_code)] - accepted: bool, - data: Option, - }, - ResponseError { - id: u32, - // The following field is present, but unused - // error: Value, - reason: String, - }, +#[derive(Debug)] +enum ChannelReceiveMessage<'a> { + Notification(notification::NotificationRef<'a>), + Response(response::ResponseRef<'a>), Event(InternalMessage), } -fn deserialize_message(bytes: &[u8]) -> ChannelReceiveMessage { - match bytes[0] { - // JSON message - b'{' => serde_json::from_slice(bytes).unwrap(), - // Debug log - b'D' => ChannelReceiveMessage::Event(InternalMessage::Debug( - String::from_utf8(Vec::from(&bytes[1..])).unwrap(), - )), - // Warn log - b'W' => ChannelReceiveMessage::Event(InternalMessage::Warn( - String::from_utf8(Vec::from(&bytes[1..])).unwrap(), - )), - // Error log - b'E' => ChannelReceiveMessage::Event(InternalMessage::Error( - String::from_utf8(Vec::from(&bytes[1..])).unwrap(), - )), - // Dump log - b'X' => ChannelReceiveMessage::Event(InternalMessage::Dump( - String::from_utf8(Vec::from(&bytes[1..])).unwrap(), - )), - // Unknown +fn deserialize_message(bytes: &[u8]) -> ChannelReceiveMessage<'_> { + let message_ref = message::MessageRef::read_as_root(&bytes[4..]).unwrap(); + + match message_ref.data().unwrap() { + message::BodyRef::Log(data) => match data.data().unwrap().chars().next() { + // Debug log + Some('D') => ChannelReceiveMessage::Event(InternalMessage::Debug( + String::from_utf8(Vec::from(&data.data().unwrap().as_bytes()[1..])).unwrap(), + )), + // Warn log + Some('W') => ChannelReceiveMessage::Event(InternalMessage::Warn( + String::from_utf8(Vec::from(&data.data().unwrap().as_bytes()[1..])).unwrap(), + )), + // Error log + Some('E') => ChannelReceiveMessage::Event(InternalMessage::Error( + String::from_utf8(Vec::from(&data.data().unwrap().as_bytes()[1..])).unwrap(), + )), + // Dump log + Some('X') => ChannelReceiveMessage::Event(InternalMessage::Dump( + String::from_utf8(Vec::from(&data.data().unwrap().as_bytes()[1..])).unwrap(), + )), + // This should never happen. + _ => ChannelReceiveMessage::Event(InternalMessage::Unexpected(Vec::from(bytes))), + }, + message::BodyRef::Notification(data) => ChannelReceiveMessage::Notification(data), + message::BodyRef::Response(data) => ChannelReceiveMessage::Response(data), + _ => ChannelReceiveMessage::Event(InternalMessage::Unexpected(Vec::from(bytes))), } } @@ -112,6 +127,7 @@ struct ResponseError { } type ResponseResult = Result, ResponseError>; +type FBSResponseResult = Result, ResponseError>; struct RequestDropGuard<'a> { id: u32, @@ -132,6 +148,10 @@ impl<'a> Drop for RequestDropGuard<'a> { if let Some(requests_container) = self.channel.inner.requests_container_weak.upgrade() { requests_container.lock().handlers.remove(&self.id); } + // Remove request handler from the container + if let Some(requests_container) = self.channel.inner.fbs_requests_container_weak.upgrade() { + requests_container.lock().handlers.remove(&self.id); + } } } @@ -147,9 +167,35 @@ struct RequestsContainer { handlers: HashedMap>>, } +#[derive(Default)] +struct FBSRequestsContainer { + next_id: u32, + handlers: HashedMap>, +} + +/* TODO: Remove. +impl Drop for RequestsContainer { + fn drop(&mut self) { + panic!(); + } +} +*/ +/* +struct OutgoingMessageRequest { + message: Vec, + payload: Vec, +} + +enum OutgoingMessage { + Request(Arc>), + Notification { message: Vec, payload: Vec }, +} +*/ + struct OutgoingMessageBuffer { handle: Option, messages: VecDeque>>>, + // messages: VecDeque, } #[allow(clippy::type_complexity)] @@ -157,8 +203,13 @@ struct Inner { outgoing_message_buffer: Arc>, internal_message_receiver: async_channel::Receiver, requests_container_weak: Weak>, + fbs_requests_container_weak: Weak>, buffered_notifications_for: Arc>>>>, + fbs_buffered_notifications_for: Arc>>>>, event_handlers_weak: WeakEventHandlers>, + fbs_event_handlers_weak: FBSWeakEventHandlers< + Arc) + Send + Sync + 'static>, + >, worker_closed: Arc, closed: AtomicBool, } @@ -184,10 +235,16 @@ impl Channel { })); let requests_container = Arc::>::default(); let requests_container_weak = Arc::downgrade(&requests_container); + let fbs_requests_container = Arc::>::default(); + let fbs_requests_container_weak = Arc::downgrade(&fbs_requests_container); let buffered_notifications_for = Arc::>>>>::default(); + let fbs_buffered_notifications_for = + Arc::>>>>::default(); let event_handlers = EventHandlers::new(); + let fbs_event_handlers = FBSEventHandlers::new(); let event_handlers_weak = event_handlers.downgrade(); + let fbs_event_handlers_weak = fbs_event_handlers.downgrade(); let prepared_channel_read = utils::prepare_channel_read_fn({ let outgoing_message_buffer = Arc::clone(&outgoing_message_buffer); @@ -213,6 +270,7 @@ impl Channel { let prepared_channel_write = utils::prepare_channel_write_fn({ let buffered_notifications_for = Arc::clone(&buffered_notifications_for); + let fbs_buffered_notifications_for = Arc::clone(&fbs_buffered_notifications_for); // This this contain cache of targets that are known to not have buffering, so // that we can avoid Mutex locking overhead for them let mut non_buffered_notifications = LruCache::::new( @@ -223,7 +281,11 @@ impl Channel { trace!("received raw message: {}", String::from_utf8_lossy(message)); match deserialize_message(message) { - ChannelReceiveMessage::Notification { target_id } => { + ChannelReceiveMessage::Notification(notification) => { + let target_id: SubscriptionTarget = SubscriptionTarget::String( + notification.handler_id().unwrap().unwrap().to_string(), + ); + if !non_buffered_notifications.contains(&target_id) { let mut buffer_notifications_for = buffered_notifications_for.lock(); // Check if we need to buffer notifications for this @@ -232,31 +294,54 @@ impl Channel { list.push(Vec::from(message)); return; } + let mut fbs_buffer_notifications_for = + fbs_buffered_notifications_for.lock(); + // Check if we need to buffer notifications for this + // target_id + if let Some(list) = fbs_buffer_notifications_for.get_mut(&target_id) { + list.push(Vec::from(message)); + return; + } // Remember we don't need to buffer these - non_buffered_notifications.put(target_id, ()); + non_buffered_notifications.put(target_id.clone(), ()); } - event_handlers.call_callbacks_with_single_value(&target_id, message); + fbs_event_handlers + .call_callbacks_with_single_value(&target_id, notification); } - ChannelReceiveMessage::ResponseSuccess { id, data, .. } => { - let sender = requests_container.lock().handlers.remove(&id); + ChannelReceiveMessage::Response(response) => { + let sender = fbs_requests_container + .lock() + .handlers + .remove(&response.id().unwrap()); if let Some(mut sender) = sender { - let _ = sender.send(Ok(data)); + // Request did not succeed. + if let Ok(Some(error)) = response.error() { + let _ = sender.send(Err(ResponseError { + reason: error.to_string(), + })); + } + // Request succeeded. + else { + match response.body().expect("failed accessing response body") { + // Response has body. + Some(body_ref) => { + let _ = sender.send(Ok(Some( + body_ref + .try_into() + .expect("failed to retrieve response body"), + ))); + } + // Response does not have body. + None => { + let _ = sender.send(Ok(None)); + } + } + } } else { warn!( "received success response does not match any sent request [id:{}]", - id, - ); - } - } - ChannelReceiveMessage::ResponseError { id, reason } => { - let sender = requests_container.lock().handlers.remove(&id); - if let Some(mut sender) = sender { - let _ = sender.send(Err(ResponseError { reason })); - } else { - warn!( - "received error response does not match any sent request [id:{}]", - id, + response.id().unwrap(), ); } } @@ -271,8 +356,11 @@ impl Channel { outgoing_message_buffer, internal_message_receiver, requests_container_weak, + fbs_requests_container_weak, buffered_notifications_for, + fbs_buffered_notifications_for, event_handlers_weak, + fbs_event_handlers_weak, worker_closed, closed: AtomicBool::new(false), }); @@ -292,15 +380,23 @@ impl Channel { /// being created. This allows to avoid missing notifications due to race conditions. pub(crate) fn buffer_messages_for(&self, target_id: SubscriptionTarget) -> BufferMessagesGuard { let buffered_notifications_for = Arc::clone(&self.inner.buffered_notifications_for); + let fbs_buffered_notifications_for = Arc::clone(&self.inner.fbs_buffered_notifications_for); let event_handlers_weak = self.inner.event_handlers_weak.clone(); + let fbs_event_handlers_weak = self.inner.fbs_event_handlers_weak.clone(); buffered_notifications_for .lock() - .entry(target_id) + .entry(target_id.clone()) + .or_default(); + fbs_buffered_notifications_for + .lock() + .entry(target_id.clone()) .or_default(); BufferMessagesGuard { target_id, buffered_notifications_for, + fbs_buffered_notifications_for, event_handlers_weak, + fbs_event_handlers_weak, } } @@ -433,6 +529,155 @@ impl Channel { } } + pub(crate) async fn request_fbs( + &self, + mut builder: Builder, + handler_id: HandlerId, + method: request::Method, + body: Option>, + ) -> Result, RequestError> + where + HandlerId: Display, + { + let id; + let (result_sender, result_receiver) = async_oneshot::oneshot(); + + { + let requests_container = match self.inner.fbs_requests_container_weak.upgrade() { + Some(requests_container_lock) => requests_container_lock, + None => { + return Err(RequestError::ChannelClosed); + } + }; + let mut requests_container_lock = requests_container.lock(); + + id = requests_container_lock.next_id; + + requests_container_lock.next_id = requests_container_lock.next_id.wrapping_add(1); + requests_container_lock.handlers.insert(id, result_sender); + } + + debug!("request() [method:{:?}, id:{}]", method, id); + + let request = + request::Request::create(&mut builder, id, method, handler_id.to_string(), body); + + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + let data = builder.finish(message, None).to_vec(); + + let buffer = Arc::new(AtomicTake::new(data)); + + { + let mut outgoing_message_buffer = self.inner.outgoing_message_buffer.lock(); + outgoing_message_buffer + .messages + .push_back(Arc::clone(&buffer)); + if let Some(handle) = outgoing_message_buffer.handle { + if self.inner.worker_closed.load(Ordering::Acquire) { + // Forbid all requests after worker closing except one worker closing request + if method != request::Method::WorkerClose { + return Err(RequestError::ChannelClosed); + } + } + unsafe { + // Notify worker that there is something to read + let ret = mediasoup_sys::uv_async_send(handle); + if ret != 0 { + error!("uv_async_send call failed with code {}", ret); + + return Err(RequestError::ChannelClosed); + } + } + } + } + + // Drop guard to make sure to drop pending request when future is cancelled + let request_drop_guard = RequestDropGuard { + id, + message: buffer, + channel: self, + removed: false, + }; + + let response_result_fut = result_receiver.await; + + request_drop_guard.remove(); + + let response_result = match response_result_fut { + Ok(response_result) => response_result, + Err(_closed) => Err(ResponseError { + reason: String::from("ChannelClosed"), + }), + }; + + match response_result { + Ok(data) => { + debug!("request succeeded [method:{:?}, id:{}]", method, id); + + Ok(data) + } + Err(ResponseError { reason }) => { + debug!( + "request failed [method:{:?}, id:{}]: {}", + method, id, reason + ); + if reason.contains("not found") { + Err(RequestError::ChannelClosed) + } else { + Err(RequestError::Response { reason }) + } + } + } + } + + pub(crate) fn notify( + &self, + handler_id: HandlerId, + notification: N, + // payload: Vec, + ) -> Result<(), NotificationError> + where + N: Notification, + HandlerId: Display, + { + debug!("notify() [event:{}]", notification.as_event()); + + // TODO: Todo pre-allocate fixed size string sufficient for most cases by default + // TODO: Refactor to avoid extra allocation during JSON serialization if possible + let message = Arc::new(AtomicTake::new( + format!( + "n:{}:{handler_id}:{}", + notification.as_event(), + serde_json::to_string(¬ification).unwrap() + ) + .into_bytes(), + )); + + { + let mut outgoing_message_buffer = self.inner.outgoing_message_buffer.lock(); + outgoing_message_buffer + .messages + .push_back(Arc::clone(&message)); + // .push_back(OutgoingMessage::Notification { message, payload }); + if let Some(handle) = outgoing_message_buffer.handle { + if self.inner.worker_closed.load(Ordering::Acquire) { + return Err(NotificationError::ChannelClosed); + } + unsafe { + // Notify worker that there is something to read + let ret = mediasoup_sys::uv_async_send(handle); + if ret != 0 { + error!("uv_async_send call failed with code {}", ret); + return Err(NotificationError::ChannelClosed); + } + } + } + } + + Ok(()) + } pub(crate) fn subscribe_to_notifications( &self, target_id: SubscriptionTarget, @@ -446,4 +691,17 @@ impl Channel { .upgrade() .map(|event_handlers| event_handlers.add(target_id, Arc::new(callback))) } + pub(crate) fn subscribe_to_fbs_notifications( + &self, + target_id: SubscriptionTarget, + callback: F, + ) -> Option + where + F: Fn(notification::NotificationRef<'_>) + Send + Sync + 'static, + { + self.inner + .fbs_event_handlers_weak + .upgrade() + .map(|fbs_event_handlers| fbs_event_handlers.add(target_id, Arc::new(callback))) + } } diff --git a/rust/src/worker/common.rs b/rust/src/worker/common.rs index 6616b48c17..4af1b551e3 100644 --- a/rust/src/worker/common.rs +++ b/rust/src/worker/common.rs @@ -1,3 +1,4 @@ +use crate::fbs::notification; use hash_hasher::HashedMap; use nohash_hasher::IntMap; use parking_lot::Mutex; @@ -24,6 +25,11 @@ pub(super) struct EventHandlers { handlers: Arc>>>, } +#[derive(Clone)] +pub(super) struct FBSEventHandlers { + handlers: Arc>>>, +} + impl EventHandlers { pub(super) fn new() -> Self { let handlers = Arc::>>>::default(); @@ -35,7 +41,7 @@ impl EventHandlers { { let mut event_handlers = self.handlers.lock(); let list = event_handlers - .entry(target_id) + .entry(target_id.clone()) .or_insert_with(EventHandlersList::default); index = list.index; list.index += 1; @@ -79,6 +85,61 @@ impl EventHandlers { } } +impl FBSEventHandlers { + pub(super) fn new() -> Self { + let handlers = Arc::>>>::default(); + Self { handlers } + } + + pub(super) fn add(&self, target_id: SubscriptionTarget, callback: F) -> SubscriptionHandler { + let index; + { + let mut event_handlers = self.handlers.lock(); + let list = event_handlers + .entry(target_id.clone()) + .or_insert_with(EventHandlersList::default); + index = list.index; + list.index += 1; + list.callbacks.insert(index, callback); + drop(event_handlers); + } + + SubscriptionHandler::new({ + let event_handlers_weak = Arc::downgrade(&self.handlers); + + Box::new(move || { + if let Some(event_handlers) = event_handlers_weak.upgrade() { + // We store removed handler here in order to drop after `event_handlers` lock is + // released, otherwise handler will be dropped on removal from callbacks + // immediately and if it happens to hold another entity that held subscription + // handler, we may arrive here again trying to acquire lock that we didn't + // release yet. By dropping callback only when lock is released we avoid + // deadlocking. + let removed_handler; + { + let mut handlers = event_handlers.lock(); + let is_empty = { + let list = handlers.get_mut(&target_id).unwrap(); + removed_handler = list.callbacks.remove(&index); + list.callbacks.is_empty() + }; + if is_empty { + handlers.remove(&target_id); + } + } + drop(removed_handler); + } + }) + }) + } + + pub(super) fn downgrade(&self) -> FBSWeakEventHandlers { + FBSWeakEventHandlers { + handlers: Arc::downgrade(&self.handlers), + } + } +} + impl EventHandlers> { pub(super) fn call_callbacks_with_single_value( &self, @@ -94,17 +155,16 @@ impl EventHandlers> { } } -impl EventHandlers> { - pub(super) fn call_callbacks_with_two_values( +impl FBSEventHandlers) + Send + Sync + 'static>> { + pub(super) fn call_callbacks_with_single_value( &self, target_id: &SubscriptionTarget, - value1: &V1, - value2: &V2, + value: notification::NotificationRef<'_>, ) { let handlers = self.handlers.lock(); if let Some(list) = handlers.get(target_id) { for callback in list.callbacks.values() { - callback(value1, value2); + callback(value); } } } @@ -123,23 +183,24 @@ impl WeakEventHandlers { } } -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Deserialize)] -#[serde(untagged)] -pub(crate) enum SubscriptionTarget { - Uuid(Uuid), - Number(u64), +#[derive(Clone)] +pub(super) struct FBSWeakEventHandlers { + handlers: Weak>>>, } -impl From for SubscriptionTarget { - fn from(number: u32) -> Self { - Self::Number(u64::from(number)) +impl FBSWeakEventHandlers { + pub(super) fn upgrade(&self) -> Option> { + self.handlers + .upgrade() + .map(|handlers| FBSEventHandlers { handlers }) } } -impl From for SubscriptionTarget { - fn from(number: u64) -> Self { - Self::Number(number) - } +#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize)] +#[serde(untagged)] +pub(crate) enum SubscriptionTarget { + Uuid(Uuid), + String(String), } /// Subscription handler, will remove corresponding subscription when dropped diff --git a/rust/src/worker/payload_channel.rs b/rust/src/worker/payload_channel.rs deleted file mode 100644 index c4a7ed3172..0000000000 --- a/rust/src/worker/payload_channel.rs +++ /dev/null @@ -1,398 +0,0 @@ -use crate::messages::{Notification, Request}; -use crate::worker::common::{EventHandlers, SubscriptionTarget, WeakEventHandlers}; -use crate::worker::utils::{PreparedPayloadChannelRead, PreparedPayloadChannelWrite}; -use crate::worker::{utils, RequestError, SubscriptionHandler}; -use atomic_take::AtomicTake; -use log::{debug, error, trace, warn}; -use mediasoup_sys::UvAsyncT; -use nohash_hasher::IntMap; -use parking_lot::Mutex; -use serde::Deserialize; -use serde_json::Value; -use std::collections::VecDeque; -use std::fmt::{Debug, Display}; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{Arc, Weak}; -use thiserror::Error; - -#[derive(Debug)] -pub(super) enum InternalMessage { - /// Unknown data - UnexpectedData(Vec), -} - -#[derive(Debug, Deserialize)] -#[serde(untagged)] -enum PayloadChannelReceiveMessage { - #[serde(rename_all = "camelCase")] - Notification { target_id: SubscriptionTarget }, - ResponseSuccess { - id: u32, - // The following field is present, unused, but needed for differentiating successful - // response from error case - #[allow(dead_code)] - accepted: bool, - data: Option, - }, - ResponseError { - id: u32, - // The following field is present, but unused - // error: Value, - reason: String, - }, - /// Unknown data - #[serde(skip)] - Internal(InternalMessage), -} - -fn deserialize_message(bytes: &[u8]) -> PayloadChannelReceiveMessage { - match serde_json::from_slice(bytes) { - Ok(message) => message, - Err(error) => { - warn!("Failed to deserialize message: {}", error); - - PayloadChannelReceiveMessage::Internal(InternalMessage::UnexpectedData(Vec::from( - bytes, - ))) - } - } -} - -struct ResponseError { - reason: String, -} - -type ResponseResult = Result, ResponseError>; - -struct RequestDropGuard<'a> { - id: u32, - message_with_payload: Arc>, - channel: &'a PayloadChannel, - removed: bool, -} - -impl<'a> Drop for RequestDropGuard<'a> { - fn drop(&mut self) { - if self.removed { - return; - } - - // Drop pending message from memory - self.message_with_payload.take(); - // Remove request handler from the container - if let Some(requests_container) = self.channel.inner.requests_container_weak.upgrade() { - requests_container.lock().handlers.remove(&self.id); - } - } -} - -impl<'a> RequestDropGuard<'a> { - fn remove(mut self) { - self.removed = true; - } -} - -#[derive(Default)] -struct RequestsContainer { - next_id: u32, - handlers: IntMap>>, -} - -struct OutgoingMessageRequest { - message: Vec, - payload: Vec, -} - -enum OutgoingMessage { - Request(Arc>), - Notification { message: Vec, payload: Vec }, -} - -struct OutgoingMessageBuffer { - handle: Option, - messages: VecDeque, -} - -#[derive(Debug, Error, Eq, PartialEq)] -pub enum NotificationError { - #[error("Channel already closed")] - ChannelClosed, -} - -struct Inner { - outgoing_message_buffer: Arc>, - internal_message_receiver: async_channel::Receiver, - requests_container_weak: Weak>, - #[allow(clippy::type_complexity)] - event_handlers_weak: WeakEventHandlers>, - worker_closed: Arc, -} - -impl Drop for Inner { - fn drop(&mut self) { - self.internal_message_receiver.close(); - } -} - -#[derive(Clone)] -pub(crate) struct PayloadChannel { - inner: Arc, -} - -impl PayloadChannel { - pub(super) fn new( - worker_closed: Arc, - ) -> ( - Self, - PreparedPayloadChannelRead, - PreparedPayloadChannelWrite, - ) { - let outgoing_message_buffer = Arc::new(Mutex::new(OutgoingMessageBuffer { - handle: None, - messages: VecDeque::with_capacity(10), - })); - let requests_container = Arc::>::default(); - let requests_container_weak = Arc::downgrade(&requests_container); - let event_handlers = EventHandlers::new(); - let event_handlers_weak = event_handlers.downgrade(); - - let prepared_payload_channel_read = utils::prepare_payload_channel_read_fn({ - let outgoing_message_buffer = Arc::clone(&outgoing_message_buffer); - - move |handle| { - let mut outgoing_message_buffer = outgoing_message_buffer.lock(); - if outgoing_message_buffer.handle.is_none() { - outgoing_message_buffer.handle.replace(handle); - } - - while let Some(outgoing_message) = outgoing_message_buffer.messages.pop_front() { - match outgoing_message { - OutgoingMessage::Request(maybe_message) => { - // Request might have already been cancelled - if let Some(OutgoingMessageRequest { message, payload }) = - maybe_message.take() - { - return Some((message, payload)); - } - } - OutgoingMessage::Notification { message, payload } => { - return Some((message, payload)); - } - } - } - - None - } - }); - - let (internal_message_sender, internal_message_receiver) = async_channel::bounded(1); - - let prepared_payload_channel_write = - utils::prepare_payload_channel_write_fn(move |message, payload| { - trace!("received raw message: {}", String::from_utf8_lossy(message)); - - match deserialize_message(message) { - PayloadChannelReceiveMessage::Notification { target_id } => { - trace!("received notification payload of {} bytes", payload.len()); - - event_handlers.call_callbacks_with_two_values(&target_id, message, payload); - } - PayloadChannelReceiveMessage::ResponseSuccess { id, data, .. } => { - let sender = requests_container.lock().handlers.remove(&id); - if let Some(mut sender) = sender { - let _ = sender.send(Ok(data)); - } else { - warn!( - "received success response does not match any sent request [id:{}]", - id, - ); - } - } - PayloadChannelReceiveMessage::ResponseError { id, reason } => { - let sender = requests_container.lock().handlers.remove(&id); - if let Some(mut sender) = sender { - let _ = sender.send(Err(ResponseError { reason })); - } else { - warn!( - "received error response does not match any sent request [id:{}]", - id, - ); - } - } - PayloadChannelReceiveMessage::Internal(internal_message) => { - let _ = internal_message_sender.try_send(internal_message); - } - } - }); - - let inner = Arc::new(Inner { - outgoing_message_buffer, - internal_message_receiver, - requests_container_weak, - event_handlers_weak, - worker_closed, - }); - - ( - Self { inner }, - prepared_payload_channel_read, - prepared_payload_channel_write, - ) - } - - pub(super) fn get_internal_message_receiver(&self) -> async_channel::Receiver { - self.inner.internal_message_receiver.clone() - } - - pub(crate) async fn request( - &self, - handler_id: HandlerId, - request: R, - payload: Vec, - ) -> Result - where - R: Request, - HandlerId: Display, - { - let method = request.as_method(); - - let id; - let (result_sender, result_receiver) = async_oneshot::oneshot(); - - { - let requests_container_lock = self - .inner - .requests_container_weak - .upgrade() - .ok_or(RequestError::ChannelClosed)?; - let mut requests_container = requests_container_lock.lock(); - - id = requests_container.next_id; - - requests_container.next_id = requests_container.next_id.wrapping_add(1); - requests_container.handlers.insert(id, result_sender); - } - - debug!("request() [method:{}, id:{}]: {:?}", method, id, request); - - // TODO: Todo pre-allocate fixed size string sufficient for most cases by default - // TODO: Refactor to avoid extra allocation during JSON serialization if possible - let message = format!( - "r:{id}:{}:{handler_id}:{}", - request.as_method(), - serde_json::to_string(&request).unwrap() - ) - .into_bytes(); - - let message_with_payload = - Arc::new(AtomicTake::new(OutgoingMessageRequest { message, payload })); - - { - let mut outgoing_message_buffer = self.inner.outgoing_message_buffer.lock(); - outgoing_message_buffer - .messages - .push_back(OutgoingMessage::Request(Arc::clone(&message_with_payload))); - if let Some(handle) = outgoing_message_buffer.handle { - if self.inner.worker_closed.load(Ordering::Acquire) { - return Err(RequestError::ChannelClosed); - } - unsafe { - // Notify worker that there is something to read - let ret = mediasoup_sys::uv_async_send(handle); - if ret != 0 { - error!("uv_async_send call failed with code {}", ret); - return Err(RequestError::ChannelClosed); - } - } - } - } - - // Drop guard to make sure to drop pending request when future is cancelled - let request_drop_guard = RequestDropGuard { - id, - message_with_payload, - channel: self, - removed: false, - }; - - let response_result_fut = result_receiver.await; - - request_drop_guard.remove(); - - match response_result_fut.map_err(|_| RequestError::ChannelClosed {})? { - Ok(data) => { - debug!("request succeeded [method:{}, id:{}]", method, id); - - // Default will work for `()` response - serde_json::from_value(data.unwrap_or_default()).map_err(|error| { - RequestError::FailedToParse { - error: error.to_string(), - } - }) - } - Err(ResponseError { reason }) => { - debug!("request failed [method:{}, id:{}]: {}", method, id, reason); - - Err(RequestError::Response { reason }) - } - } - } - - pub(crate) fn notify( - &self, - handler_id: HandlerId, - notification: N, - payload: Vec, - ) -> Result<(), NotificationError> - where - N: Notification, - HandlerId: Display, - { - debug!("notify() [event:{}]", notification.as_event()); - - // TODO: Todo pre-allocate fixed size string sufficient for most cases by default - // TODO: Refactor to avoid extra allocation during JSON serialization if possible - let message = format!( - "n:{}:{handler_id}:{}", - notification.as_event(), - serde_json::to_string(¬ification).unwrap() - ) - .into_bytes(); - - { - let mut outgoing_message_buffer = self.inner.outgoing_message_buffer.lock(); - outgoing_message_buffer - .messages - .push_back(OutgoingMessage::Notification { message, payload }); - if let Some(handle) = outgoing_message_buffer.handle { - if self.inner.worker_closed.load(Ordering::Acquire) { - return Err(NotificationError::ChannelClosed); - } - unsafe { - // Notify worker that there is something to read - let ret = mediasoup_sys::uv_async_send(handle); - if ret != 0 { - error!("uv_async_send call failed with code {}", ret); - return Err(NotificationError::ChannelClosed); - } - } - } - } - - Ok(()) - } - - pub(crate) fn subscribe_to_notifications( - &self, - target_id: SubscriptionTarget, - callback: F, - ) -> Option - where - F: Fn(&[u8], &[u8]) + Send + Sync + 'static, - { - self.inner - .event_handlers_weak - .upgrade() - .map(|event_handlers| event_handlers.add(target_id, Arc::new(callback))) - } -} diff --git a/rust/src/worker/utils.rs b/rust/src/worker/utils.rs index 0c9735737c..3fa01ace77 100644 --- a/rust/src/worker/utils.rs +++ b/rust/src/worker/utils.rs @@ -2,15 +2,9 @@ mod channel_read_fn; mod channel_write_fn; use crate::worker::channel::BufferMessagesGuard; -use crate::worker::{Channel, PayloadChannel, WorkerId}; -pub(super) use channel_read_fn::{ - prepare_channel_read_fn, prepare_payload_channel_read_fn, PreparedChannelRead, - PreparedPayloadChannelRead, -}; -pub(super) use channel_write_fn::{ - prepare_channel_write_fn, prepare_payload_channel_write_fn, PreparedChannelWrite, - PreparedPayloadChannelWrite, -}; +use crate::worker::{Channel, WorkerId}; +pub(super) use channel_read_fn::{prepare_channel_read_fn, PreparedChannelRead}; +pub(super) use channel_write_fn::{prepare_channel_write_fn, PreparedChannelWrite}; use std::ffi::CString; use std::os::raw::{c_char, c_int}; use std::sync::atomic::AtomicBool; @@ -39,7 +33,6 @@ pub enum ExitError { pub(super) struct WorkerRunResult { pub(super) channel: Channel, - pub(super) payload_channel: PayloadChannel, pub(super) buffer_worker_messages_guard: BufferMessagesGuard, } @@ -55,9 +48,9 @@ where { let (channel, prepared_channel_read, prepared_channel_write) = Channel::new(Arc::clone(&worker_closed)); - let (payload_channel, prepared_payload_channel_read, prepared_payload_channel_write) = - PayloadChannel::new(worker_closed); - let buffer_worker_messages_guard = channel.buffer_messages_for(std::process::id().into()); + let buffer_worker_messages_guard = channel.buffer_messages_for( + super::common::SubscriptionTarget::String(std::process::id().to_string()), + ); std::thread::Builder::new() .name(format!("mediasoup-worker-{id}")) @@ -81,16 +74,6 @@ where prepared_channel_read.deconstruct(); let (channel_write_fn, channel_write_ctx, _channel_read_callback) = prepared_channel_write.deconstruct(); - let ( - payload_channel_read_fn, - payload_channel_read_ctx, - _payload_channel_write_callback, - ) = prepared_payload_channel_read.deconstruct(); - let ( - payload_channel_write_fn, - payload_channel_write_ctx, - _payload_channel_read_callback, - ) = prepared_payload_channel_write.deconstruct(); mediasoup_sys::mediasoup_worker_run( argc, @@ -104,10 +87,6 @@ where channel_read_ctx, channel_write_fn, channel_write_ctx, - payload_channel_read_fn, - payload_channel_read_ctx, - payload_channel_write_fn, - payload_channel_write_ctx, ) }; @@ -122,7 +101,6 @@ where WorkerRunResult { channel, - payload_channel, buffer_worker_messages_guard, } } diff --git a/rust/src/worker/utils/channel_read_fn.rs b/rust/src/worker/utils/channel_read_fn.rs index 902f87ef66..57cf3b0bf8 100644 --- a/rust/src/worker/utils/channel_read_fn.rs +++ b/rust/src/worker/utils/channel_read_fn.rs @@ -1,7 +1,5 @@ -pub(super) use mediasoup_sys::{ - ChannelReadCtx, ChannelReadFn, PayloadChannelReadCtx, PayloadChannelReadFn, -}; -use mediasoup_sys::{ChannelReadFreeFn, PayloadChannelReadFreeFn, UvAsyncT}; +pub(super) use mediasoup_sys::{ChannelReadCtx, ChannelReadFn}; +use mediasoup_sys::{ChannelReadFreeFn, UvAsyncT}; use std::mem; use std::os::raw::c_void; @@ -76,90 +74,3 @@ where write_callback: ChannelReadCallback(read_callback), } } - -#[allow(clippy::type_complexity)] -pub(super) struct PayloadChannelReadCallback( - Box Option<(Vec, Vec)>) + Send + 'static>, -); - -pub(crate) struct PreparedPayloadChannelRead { - payload_channel_read_fn: PayloadChannelReadFn, - payload_channel_read_ctx: PayloadChannelReadCtx, - write_callback: PayloadChannelReadCallback, -} - -impl PreparedPayloadChannelRead { - /// SAFETY: - /// 1) `PayloadChannelReadCallback` returned must be dropped AFTER last usage of returned - /// function and context pointers - /// 2) `PayloadChannelReadCtx` should not be called from multiple threads concurrently - pub(super) unsafe fn deconstruct( - self, - ) -> ( - PayloadChannelReadFn, - PayloadChannelReadCtx, - PayloadChannelReadCallback, - ) { - let Self { - payload_channel_read_fn, - payload_channel_read_ctx, - write_callback, - } = self; - ( - payload_channel_read_fn, - payload_channel_read_ctx, - write_callback, - ) - } -} - -/// Given callback function, prepares a pair of channel read function and context, which can be -/// provided to of C++ worker and worker will effectively call the callback whenever it wants to -/// read something from Rust (so it is reading from C++ point of view and writing from Rust). -pub(crate) fn prepare_payload_channel_read_fn(read_callback: F) -> PreparedPayloadChannelRead -where - F: (FnMut(UvAsyncT) -> Option<(Vec, Vec)>) + Send + 'static, -{ - unsafe extern "C" fn wrapper( - message: *mut *mut u8, - message_len: *mut u32, - message_capacity: *mut usize, - payload: *mut *mut u8, - payload_len: *mut u32, - payload_capacity: *mut usize, - handle: UvAsyncT, - PayloadChannelReadCtx(ctx): PayloadChannelReadCtx, - ) -> PayloadChannelReadFreeFn - where - F: (FnMut(UvAsyncT) -> Option<(Vec, Vec)>) + Send + 'static, - { - // Call Rust and try to get a new message (if there is any) - let (mut new_message, mut new_payload) = (*(ctx as *mut F))(handle)?; - - // Set pointers, give out control over memory to C++ - *message = new_message.as_mut_ptr(); - *message_len = new_message.len() as u32; - *message_capacity = new_message.capacity(); - *payload = new_payload.as_mut_ptr(); - *payload_len = new_payload.len() as u32; - *payload_capacity = new_payload.capacity(); - - // Forget about vectors in Rust - mem::forget(new_message); - mem::forget(new_payload); - - // Function pointer that C++ can use to free vectors later - Some(free_vec) - } - - // Move to heap to make sure it doesn't change address later on - let read_callback = Box::new(read_callback); - - PreparedPayloadChannelRead { - payload_channel_read_fn: wrapper::, - payload_channel_read_ctx: PayloadChannelReadCtx( - read_callback.as_ref() as *const F as *const c_void - ), - write_callback: PayloadChannelReadCallback(read_callback), - } -} diff --git a/rust/src/worker/utils/channel_write_fn.rs b/rust/src/worker/utils/channel_write_fn.rs index 968dafb79c..c9e72077c9 100644 --- a/rust/src/worker/utils/channel_write_fn.rs +++ b/rust/src/worker/utils/channel_write_fn.rs @@ -1,6 +1,4 @@ -pub(super) use mediasoup_sys::{ - ChannelWriteCtx, ChannelWriteFn, PayloadChannelWriteCtx, PayloadChannelWriteFn, -}; +pub(super) use mediasoup_sys::{ChannelWriteCtx, ChannelWriteFn}; use std::os::raw::c_void; use std::slice; @@ -59,72 +57,3 @@ where read_callback: ChannelReadCallback(read_callback), } } - -#[allow(clippy::type_complexity)] -pub(super) struct PayloadChannelReadCallback(Box); - -pub(crate) struct PreparedPayloadChannelWrite { - channel_write_fn: PayloadChannelWriteFn, - channel_write_ctx: PayloadChannelWriteCtx, - read_callback: PayloadChannelReadCallback, -} - -unsafe impl Send for PreparedPayloadChannelWrite {} - -impl PreparedPayloadChannelWrite { - /// SAFETY: - /// 1) `PayloadChannelReadCallback` returned must be dropped AFTER last usage of returned - /// function and context pointers - /// 2) `PayloadChannelWriteCtx` should not be called from multiple threads concurrently - pub(super) unsafe fn deconstruct( - self, - ) -> ( - PayloadChannelWriteFn, - PayloadChannelWriteCtx, - PayloadChannelReadCallback, - ) { - let Self { - channel_write_fn, - channel_write_ctx, - read_callback, - } = self; - (channel_write_fn, channel_write_ctx, read_callback) - } -} - -/// Given callback function, prepares a pair of channel write function and context, which can be -/// provided to of C++ worker and worker will effectively call the callback whenever it needs to -/// send something to Rust (so it is writing from C++ point of view and reading from Rust). -pub(crate) fn prepare_payload_channel_write_fn(read_callback: F) -> PreparedPayloadChannelWrite -where - F: FnMut(&[u8], &[u8]) + Send + 'static, -{ - unsafe extern "C" fn wrapper( - message: *const u8, - message_len: u32, - payload: *const u8, - payload_len: u32, - PayloadChannelWriteCtx(ctx): PayloadChannelWriteCtx, - ) where - F: FnMut(&[u8], &[u8]) + Send + 'static, - { - let message = slice::from_raw_parts(message, message_len as usize); - let payload = if payload_len == 0 { - &[] - } else { - slice::from_raw_parts(payload, payload_len as usize) - }; - (*(ctx as *mut F))(message, payload); - } - - // Move to heap to make sure it doesn't change address later on - let read_callback = Box::new(read_callback); - - PreparedPayloadChannelWrite { - channel_write_fn: wrapper::, - channel_write_ctx: PayloadChannelWriteCtx( - read_callback.as_ref() as *const F as *const c_void - ), - read_callback: PayloadChannelReadCallback(read_callback), - } -} diff --git a/rust/tests/integration/router.rs b/rust/tests/integration/router.rs index 66889e2f5b..56d056d5a9 100644 --- a/rust/tests/integration/router.rs +++ b/rust/tests/integration/router.rs @@ -111,8 +111,7 @@ fn create_router_succeeds() { worker_dump.channel_message_handlers, ChannelMessageHandlers { channel_request_handlers: vec![router.id().into()], - payload_channel_request_handlers: vec![], - payload_channel_notification_handlers: vec![] + channel_notification_handlers: vec![] } ); diff --git a/rust/tests/integration/webrtc_server.rs b/rust/tests/integration/webrtc_server.rs index b4600cd09f..a4f572ffa0 100644 --- a/rust/tests/integration/webrtc_server.rs +++ b/rust/tests/integration/webrtc_server.rs @@ -101,8 +101,7 @@ fn create_webrtc_server_succeeds() { worker_dump.channel_message_handlers, ChannelMessageHandlers { channel_request_handlers: vec![webrtc_server.id().into()], - payload_channel_request_handlers: vec![], - payload_channel_notification_handlers: vec![] + channel_notification_handlers: vec![] } ); diff --git a/rust/tests/integration/worker.rs b/rust/tests/integration/worker.rs index 1ae513b746..ad0a3d7d9a 100644 --- a/rust/tests/integration/worker.rs +++ b/rust/tests/integration/worker.rs @@ -150,8 +150,7 @@ fn dump_succeeds() { dump.channel_message_handlers, ChannelMessageHandlers { channel_request_handlers: vec![], - payload_channel_request_handlers: vec![], - payload_channel_notification_handlers: vec![] + channel_notification_handlers: vec![] } ); }); diff --git a/worker/.clang-format b/worker/.clang-format index 00181a08c8..8e9955b0d2 100644 --- a/worker/.clang-format +++ b/worker/.clang-format @@ -49,7 +49,7 @@ FixNamespaceComments: true IncludeCategories: - Regex: '"common.hpp"' Priority: 1 - - Regex: '^"(Channel|PayloadChannel|RTC|Utils|handles)/' + - Regex: '^"(Channel|PayloadChannel|FBS|RTC|Utils|handles)/' Priority: 3 - Regex: '"*"' Priority: 2 diff --git a/worker/Makefile b/worker/Makefile index 3e8fc4eac7..4862f4266f 100644 --- a/worker/Makefile +++ b/worker/Makefile @@ -21,6 +21,8 @@ INSTALL_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) BUILD_DIR ?= $(INSTALL_DIR)/build MESON ?= $(PIP_DIR)/bin/meson MESON_VERSION ?= 0.61.5 +FLATC ?= $(BUILD_DIR)/subprojects/flatbuffers-23.3.3/flatc +FLATC_OUT_DIR ?= ./include/FBS # `MESON_ARGS` can be used to provide extra configuration parameters to Meson, # such as adding defines or changing optimization options. For instance, use # `MESON_ARGS="-Dms_log_trace=true -Dms_log_file_line=true" npm i` to compile @@ -77,6 +79,7 @@ endif update-wrap-file \ mediasoup-worker \ libmediasoup-worker \ + flatc \ xcode \ lint \ format \ @@ -194,16 +197,29 @@ clean-all: clean-subprojects update-wrap-file: meson-ninja $(MESON) subprojects update --reset $(SUBPROJECT) -mediasoup-worker: setup +mediasoup-worker: setup flatc ifeq ($(MEDIASOUP_WORKER_BIN),) $(MESON) compile -C $(BUILD_DIR) -j $(CORES) mediasoup-worker $(MESON) install -C $(BUILD_DIR) --no-rebuild --tags mediasoup-worker endif -libmediasoup-worker: setup +libmediasoup-worker: setup flatc $(MESON) compile -C $(BUILD_DIR) -j $(CORES) libmediasoup-worker $(MESON) install -C $(BUILD_DIR) --no-rebuild --tags libmediasoup-worker +flatc: + $(MESON) compile -C $(BUILD_DIR) flatc + [ -d $(FLATC_OUT_DIR) ] || \ + $(FLATC) --cpp --cpp-field-case-style lower --reflect-names --scoped-enums \ + -o $(FLATC_OUT_DIR) ./fbs/* + +flatc-clean: + $(RM) -rf $(FLATC_OUT_DIR) + +flatc-force: flatc-clean flatc + +flatc-all: setup flatc + xcode: setup $(MESON) setup --buildtype debug --backend xcode $(MEDIASOUP_OUT_DIR)/xcode diff --git a/worker/deps/libwebrtc/meson.build b/worker/deps/libwebrtc/meson.build index 7d2c54e219..5e91710aa5 100644 --- a/worker/deps/libwebrtc/meson.build +++ b/worker/deps/libwebrtc/meson.build @@ -51,7 +51,6 @@ abseil_cpp_proj = subproject( 'warning_level=0', ], ) - local_include_directories = declare_dependency( include_directories: include_directories('libwebrtc') ) @@ -64,7 +63,7 @@ libwebrtc = library( openssl_proj.get_variable('openssl_dep'), abseil_cpp_proj.get_variable('absl_strings_dep'), abseil_cpp_proj.get_variable('absl_types_dep'), - nlohmann_json_proj.get_variable('nlohmann_json_dep'), + flatbuffers_proj.get_variable('flatbuffers_dep'), libuv_proj.get_variable('libuv_dep'), ], include_directories: libwebrtc_include_directories, diff --git a/worker/fbs/activeSpeakerObserver.fbs b/worker/fbs/activeSpeakerObserver.fbs new file mode 100644 index 0000000000..02c592eb41 --- /dev/null +++ b/worker/fbs/activeSpeakerObserver.fbs @@ -0,0 +1,11 @@ +namespace FBS.ActiveSpeakerObserver; + +table ActiveSpeakerObserverOptions { + interval:uint16; +} + +// Notifications from Worker. + +table DominantSpeakerNotification { + producer_id:string (required); +} diff --git a/worker/fbs/audioLevelObserver.fbs b/worker/fbs/audioLevelObserver.fbs new file mode 100644 index 0000000000..391e7225a3 --- /dev/null +++ b/worker/fbs/audioLevelObserver.fbs @@ -0,0 +1,18 @@ +namespace FBS.AudioLevelObserver; + +table AudioLevelObserverOptions { + max_entries:uint16; + threshold:int8; + interval:uint16; +} + +// Notifications from Worker. + +table Volume { + producer_id:string (required); + volume:int8; +} + +table VolumesNotification { + volumes:[Volume] (required); +} diff --git a/worker/fbs/common.fbs b/worker/fbs/common.fbs new file mode 100644 index 0000000000..f068118f45 --- /dev/null +++ b/worker/fbs/common.fbs @@ -0,0 +1,28 @@ + +namespace FBS.Common; + +table StringString { + key:string (required); + value:string (required); +} + +table StringUint8 { + key:string (required); + value:uint8; +} + +table Uint16String { + key:uint16; + value:string (required); +} + +table Uint32String { + key:uint32; + value:string (required); +} + +table StringStringArray { + key:string (required); + values:[string]; +} + diff --git a/worker/fbs/consumer.fbs b/worker/fbs/consumer.fbs new file mode 100644 index 0000000000..673269e848 --- /dev/null +++ b/worker/fbs/consumer.fbs @@ -0,0 +1,144 @@ +include "rtpParameters.fbs"; +include "rtpStream.fbs"; + +namespace FBS.Consumer; + +table ConsumerLayers { + spatial_layer:int16; + temporal_layer:int16 = null; +} + +table ConsumerScore { + score:uint8; + producer_score:uint8; + producer_scores:[uint8]; +} + +table SetPreferredLayersRequest { + preferred_layers:ConsumerLayers (required); +} + +table SetPreferredLayersResponse { + preferred_layers:ConsumerLayers; +} + +table SetPriorityRequest { + priority:uint8; +} + +table SetPriorityResponse { + priority:uint8; +} + +table EnableTraceEventRequest { + events:[string] (required); +} + +union DumpData { + SimpleConsumerDump, + SimulcastConsumerDump, + SvcConsumerDump, + PipeConsumerDump, +} + +table DumpResponse { + data: DumpData; + type:FBS.RtpParameters.Type; +} + +table BaseConsumerDump { + id:string (required); + producer_id:string (required); + kind:FBS.RtpParameters.MediaKind; + rtp_parameters:FBS.RtpParameters.RtpParameters (required); + consumable_rtp_encodings:[FBS.RtpParameters.RtpEncodingParameters]; + supported_codec_payload_types:[uint8]; + trace_event_types:[string] (required); + paused:bool = false; + producer_paused:bool = false; + priority:uint8; +} + +table SimpleConsumerDump { + base:BaseConsumerDump (required); + rtp_stream:FBS.RtpStream.Dump (required); +} + +table SimulcastConsumerDump { + base:BaseConsumerDump (required); + rtp_stream:FBS.RtpStream.Dump (required); + preferred_spatial_layer:int16; + target_spatial_layer:int16; + current_spatial_layer:int16; + preferred_temporal_layer:int16; + target_temporal_layer:int16; + current_temporal_layer:int16; +} + +table SvcConsumerDump { + base:BaseConsumerDump (required); + rtp_stream:FBS.RtpStream.Dump (required); + preferred_spatial_layer:int16; + target_spatial_layer:int16; + current_spatial_layer:int16; + preferred_temporal_layer:int16; + target_temporal_layer:int16; + current_temporal_layer:int16; +} + +table PipeConsumerDump { + base:BaseConsumerDump (required); + rtp_streams:[FBS.RtpStream.Dump] (required); +} + +table GetStatsResponse { + stats:[FBS.RtpStream.Stats]; +} + +// Notifications from Worker. + +table LayersChangeNotification { + layers:ConsumerLayers; +} + +table RtpNotification { + data:[ubyte] (required); +} + +table ScoreNotification { + score:ConsumerScore (required); +} + +enum TraceType: uint8 { KEYFRAME = 0, FIR, NACK, PLI, RTP, } +// NOTE (windows): IN|OUT are macros defined in windef.h. +enum TraceDirection: uint8 { DIRECTION_IN = 0, DIRECTION_OUT } + +union TraceInfo { + KeyFrameTraceInfo, + FirTraceInfo, + PliTraceInfo, + RtpTraceInfo, +} + +table KeyFrameTraceInfo { + is_rtx:bool; +} + +table FirTraceInfo { + ssrc:uint32; +} + +table PliTraceInfo { + ssrc:uint32; +} + +table RtpTraceInfo { + is_rtx:bool; +} + +table TraceNotification { + type: TraceType; + timestamp: uint64; + direction: TraceDirection; + info: TraceInfo; +} diff --git a/worker/fbs/dataConsumer.fbs b/worker/fbs/dataConsumer.fbs new file mode 100644 index 0000000000..bd8a376303 --- /dev/null +++ b/worker/fbs/dataConsumer.fbs @@ -0,0 +1,59 @@ +include "common.fbs"; +include "sctpParameters.fbs"; + +namespace FBS.DataConsumer; + +table GetBufferedAmountResponse { + buffered_amount:uint32; +} + +table SetBufferedAmountLowThresholdRequest { + threshold:uint32; +} + +table DumpResponse { + id:string (required); + data_producer_id:string (required); + type:string (required); + sctp_stream_parameters: FBS.SctpParameters.SctpStreamParameters; + label:string (required); + protocol:string (required); +} + +table GetStatsResponse { + timestamp:uint64; + label:string (required); + protocol:string (required); + messages_sent:uint64; + bytes_sent:uint64; + buffered_amount:uint32; +} + +table String { + value:string (required); +} + +table Binary { + value:[uint8] (required); +} + +union Data { + String, + Binary +} + +table SendRequest { + ppid:uint8; + data:Data (required); +} + +// Notifications from Worker. + +table BufferedAmountLowNotification { + buffered_amount:uint32; +} + +table MessageNotification { + ppid:uint32; + data:[ubyte] (required); +} diff --git a/worker/fbs/dataProducer.fbs b/worker/fbs/dataProducer.fbs new file mode 100644 index 0000000000..0d05717010 --- /dev/null +++ b/worker/fbs/dataProducer.fbs @@ -0,0 +1,38 @@ +include "sctpParameters.fbs"; + +namespace FBS.DataProducer; + +table DumpResponse { + id:string (required); + type:string (required); + sctp_stream_parameters: FBS.SctpParameters.SctpStreamParameters; + label:string (required); + protocol:string (required); +} + +table GetStatsResponse { + timestamp:uint64; + label:string (required); + protocol:string (required); + messages_received:uint64; + bytes_received:uint64; + buffered_amount:uint32; +} + +table String { + value:string (required); +} + +table Binary { + value:[uint8] (required); +} + +union Data { + String, + Binary +} + +table SendNotification { + ppid:uint8; + data:Data (required); +} diff --git a/worker/fbs/directTransport.fbs b/worker/fbs/directTransport.fbs new file mode 100644 index 0000000000..3ea467cebd --- /dev/null +++ b/worker/fbs/directTransport.fbs @@ -0,0 +1,21 @@ +include "transport.fbs"; + +namespace FBS.DirectTransport; + +table DirectTransportOptions { + base:FBS.Transport.Options (required); +} + +table DumpResponse { + base:FBS.Transport.Dump (required); +} + +table GetStatsResponse { + base:FBS.Transport.Stats (required); +} + +// Notifications from Worker. + +table RtcpNotification { + data:[ubyte] (required); +} diff --git a/worker/fbs/log.fbs b/worker/fbs/log.fbs new file mode 100644 index 0000000000..2558db8eee --- /dev/null +++ b/worker/fbs/log.fbs @@ -0,0 +1,6 @@ + +namespace FBS.Log; + +table Log { + data:string (required); +} diff --git a/worker/fbs/message.fbs b/worker/fbs/message.fbs new file mode 100644 index 0000000000..80fca0c762 --- /dev/null +++ b/worker/fbs/message.fbs @@ -0,0 +1,27 @@ +include "log.fbs"; +include "notification.fbs"; +include "request.fbs"; +include "response.fbs"; + +namespace FBS.Message; + +enum Type : uint8 { + REQUEST = 0, + RESPONSE, + NOTIFICATION, + LOG, +} + +union Body { + FBS.Request.Request, + FBS.Response.Response, + FBS.Notification.Notification, + FBS.Log.Log, +} + +table Message { + type:Type; + data:Body (required); +} + +root_type Message; diff --git a/worker/fbs/notification.fbs b/worker/fbs/notification.fbs new file mode 100644 index 0000000000..378fa3bc9c --- /dev/null +++ b/worker/fbs/notification.fbs @@ -0,0 +1,78 @@ +include "transport.fbs"; +include "webRtcTransport.fbs"; +include "plainTransport.fbs"; +include "directTransport.fbs"; +include "producer.fbs"; +include "dataProducer.fbs"; +include "dataConsumer.fbs"; +include "activeSpeakerObserver.fbs"; +include "audioLevelObserver.fbs"; + +namespace FBS.Notification; + +enum Event: uint8 { + // Notifications to worker. + TRANSPORT_SEND_RTCP = 0, + PRODUCER_SEND, + DATA_PRODUCER_SEND, + // Notifications from worker. + WORKER_RUNNING, + TRANSPORT_SCTP_STATE_CHANGE, + TRANSPORT_TRACE, + WEBRTCTRANSPORT_ICE_SELECTED_TUPLE_CHANGE, + WEBRTCTRANSPORT_ICE_STATE_CHANGE, + WEBRTCTRANSPORT_DTLS_STATE_CHANGE, + PLAINTRANSPORT_TUPLE, + PLAINTRANSPORT_RTCP_TUPLE, + DIRECTTRANSPORT_RTCP, + PRODUCER_SCORE, + PRODUCER_TRACE, + PRODUCER_VIDEO_ORIENTATION_CHANGE, + CONSUMER_PRODUCER_PAUSE, + CONSUMER_PRODUCER_RESUME, + CONSUMER_PRODUCER_CLOSE, + CONSUMER_LAYERS_CHANGE, + CONSUMER_RTP, + CONSUMER_SCORE, + CONSUMER_TRACE, + DATACONSUMER_BUFFERED_AMOUNT_LOW, + DATACONSUMER_SCTP_SENDBUFFER_FULL, + DATACONSUMER_DATAPRODUCER_CLOSE, + DATACONSUMER_MESSAGE, + ACTIVESPEAKEROBSERVER_DOMINANT_SPEAKER, + AUDIOLEVELOBSERVER_SILENCE, + AUDIOLEVELOBSERVER_VOLUMES, +} + +union Body { + // Notifications to worker. + FBS.Transport.SendRtcpNotification, + FBS.Transport.SctpStateChangeNotification, + FBS.Producer.SendNotification, + FBS.DataProducer.SendNotification, + // Notifications from worker. + FBS.Transport.TraceNotification, + FBS.WebRtcTransport.IceSelectedTupleChangeNotification, + FBS.WebRtcTransport.IceStateChangeNotification, + FBS.WebRtcTransport.DtlsStateChangeNotification, + FBS.PlainTransport.TupleNotification, + FBS.PlainTransport.RtcpTupleNotification, + FBS.DirectTransport.RtcpNotification, + FBS.Producer.ScoreNotification, + FBS.Producer.TraceNotification, + FBS.Producer.VideoOrientationChangeNotification, + FBS.Consumer.LayersChangeNotification, + FBS.Consumer.RtpNotification, + FBS.Consumer.ScoreNotification, + FBS.Consumer.TraceNotification, + FBS.DataConsumer.MessageNotification, + FBS.DataConsumer.BufferedAmountLowNotification, + FBS.ActiveSpeakerObserver.DominantSpeakerNotification, + FBS.AudioLevelObserver.VolumesNotification, +} + +table Notification { + handler_id:string; + event:Event; + body:Body; +} diff --git a/worker/fbs/pipeTransport.fbs b/worker/fbs/pipeTransport.fbs new file mode 100644 index 0000000000..d80e7204d5 --- /dev/null +++ b/worker/fbs/pipeTransport.fbs @@ -0,0 +1,33 @@ +include "transport.fbs"; + +namespace FBS.PipeTransport; + +table PipeTransportOptions { + base:FBS.Transport.Options (required); + listen_ip:FBS.Transport.ListenIp (required); + port:uint16; + enable_rtx:bool; + enable_srtp:bool; +} + +table ConnectRequest { + ip:string (required); + port:uint16 = null; + srtp_parameters:FBS.Transport.SrtpParameters; +} + +table ConnectResponse { + tuple:FBS.Transport.Tuple; +} + +table DumpResponse { + base:FBS.Transport.Dump (required); + tuple:FBS.Transport.Tuple (required); + rtx:bool; + srtp_parameters:FBS.Transport.SrtpParameters; +} + +table GetStatsResponse { + base:FBS.Transport.Stats (required); + tuple:FBS.Transport.Tuple (required); +} diff --git a/worker/fbs/plainTransport.fbs b/worker/fbs/plainTransport.fbs new file mode 100644 index 0000000000..152523b254 --- /dev/null +++ b/worker/fbs/plainTransport.fbs @@ -0,0 +1,54 @@ +include "transport.fbs"; +include "sctpParameters.fbs"; + +namespace FBS.PlainTransport; + +table PlainTransportOptions { + base:FBS.Transport.Options; + listen_ip:FBS.Transport.ListenIp (required); + port:uint16; + rtcp_mux:bool; + comedia:bool; + enable_srtp:bool; + srtp_crypto_suite:string; +} + +table ConnectRequest { + ip:string; + port:uint16 = null; + rtcp_port:uint16 = null; + srtp_parameters:FBS.Transport.SrtpParameters; +} + +table ConnectResponse { + tuple:FBS.Transport.Tuple (required); + rtcp_tuple:FBS.Transport.Tuple; + srtp_parameters:FBS.Transport.SrtpParameters; +} + +table DumpResponse { + base:FBS.Transport.Dump (required); + rtcp_mux:bool; + comedia:bool; + tuple:FBS.Transport.Tuple; + rtcp_tuple:FBS.Transport.Tuple; + srtp_parameters:FBS.Transport.SrtpParameters; +} + +table GetStatsResponse { + base:FBS.Transport.Stats (required); + rtcp_mux:bool; + comedia:bool; + tuple:FBS.Transport.Tuple (required); + rtcp_tuple:FBS.Transport.Tuple; +} + +// Notifications from Worker. + +table TupleNotification { + tuple:FBS.Transport.Tuple (required); +} + +table RtcpTupleNotification { + tuple:FBS.Transport.Tuple (required); +} diff --git a/worker/fbs/producer.fbs b/worker/fbs/producer.fbs new file mode 100644 index 0000000000..64d7d81ee2 --- /dev/null +++ b/worker/fbs/producer.fbs @@ -0,0 +1,79 @@ +include "rtpParameters.fbs"; +include "rtpStream.fbs"; + +namespace FBS.Producer; + +table EnableTraceEventRequest { + events:[string] (required); +} + +table DumpResponse { + id:string (required); + kind:FBS.RtpParameters.MediaKind; + type:string (required); + rtp_parameters:FBS.RtpParameters.RtpParameters (required); + rtp_mapping:FBS.RtpParameters.RtpMapping (required); + rtp_streams:[FBS.RtpStream.Dump]; + trace_event_types:[string] (required); + paused:bool = false; +} + +table GetStatsResponse { + stats:[FBS.RtpStream.Stats]; +} + +table SendNotification { + data:[uint8] (required); +} + +// Notifications from Worker. + +table Score { + ssrc:uint32; + rid:string; + score:uint8; +} + +table ScoreNotification { + scores:[Score]; +} + +table VideoOrientationChangeNotification { + camera:bool; + flip:bool; + rotation:uint16; +} + +enum TraceType: uint8 { KEYFRAME = 0, FIR, NACK, PLI, RTP, } +// NOTE (windows): IN|OUT are macros defined in windef.h. +enum TraceDirection: uint8 { DIRECTION_IN = 0, DIRECTION_OUT } + +union TraceInfo { + KeyFrameTraceInfo, + FirTraceInfo, + PliTraceInfo, + RtpTraceInfo, +} + +table KeyFrameTraceInfo { + is_rtx:bool; +} + +table FirTraceInfo { + ssrc:uint32; +} + +table PliTraceInfo { + ssrc:uint32; +} + +table RtpTraceInfo { + is_rtx:bool; +} + +table TraceNotification { + type: TraceType; + timestamp: uint64; + direction: TraceDirection; + info: TraceInfo; +} diff --git a/worker/fbs/request.fbs b/worker/fbs/request.fbs new file mode 100644 index 0000000000..58374d3e11 --- /dev/null +++ b/worker/fbs/request.fbs @@ -0,0 +1,122 @@ +include "worker.fbs"; +include "router.fbs"; +include "transport.fbs"; +include "producer.fbs"; +include "consumer.fbs"; +include "dataConsumer.fbs"; +include "rtpObserver.fbs"; + +namespace FBS.Request; + +enum Method: uint8 { + WORKER_CLOSE = 0, + WORKER_DUMP, + WORKER_GET_RESOURCE_USAGE, + WORKER_UPDATE_SETTINGS, + WORKER_CREATE_WEBRTC_SERVER, + WORKER_CREATE_ROUTER, + WORKER_WEBRTC_SERVER_CLOSE, + WORKER_CLOSE_ROUTER, + WEBRTC_SERVER_DUMP, + ROUTER_DUMP, + ROUTER_CREATE_WEBRTC_TRANSPORT, + ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER, + ROUTER_CREATE_PLAIN_TRANSPORT, + ROUTER_CREATE_PIPE_TRANSPORT, + ROUTER_CREATE_DIRECT_TRANSPORT, + ROUTER_CLOSE_TRANSPORT, + ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER, + ROUTER_CREATE_AUDIO_LEVEL_OBSERVER, + ROUTER_CLOSE_RTP_OBSERVER, + TRANSPORT_DUMP, + TRANSPORT_GET_STATS, + TRANSPORT_CONNECT, + TRANSPORT_SET_MAX_INCOMING_BITRATE, + TRANSPORT_SET_MAX_OUTGOING_BITRATE, + TRANSPORT_SET_MIN_OUTGOING_BITRATE, + TRANSPORT_RESTART_ICE, + TRANSPORT_PRODUCE, + TRANSPORT_PRODUCE_DATA, + TRANSPORT_CONSUME, + TRANSPORT_CONSUME_DATA, + TRANSPORT_ENABLE_TRACE_EVENT, + TRANSPORT_CLOSE_PRODUCER, + TRANSPORT_CLOSE_CONSUMER, + TRANSPORT_CLOSE_DATA_PRODUCER, + TRANSPORT_CLOSE_DATA_CONSUMER, + PLAIN_TRANSPORT_CONNECT, + PIPE_TRANSPORT_CONNECT, + WEBRTC_TRANSPORT_CONNECT, + PRODUCER_DUMP, + PRODUCER_GET_STATS, + PRODUCER_PAUSE, + PRODUCER_RESUME, + PRODUCER_ENABLE_TRACE_EVENT, + CONSUMER_DUMP, + CONSUMER_GET_STATS, + CONSUMER_PAUSE, + CONSUMER_RESUME, + CONSUMER_SET_PREFERRED_LAYERS, + CONSUMER_SET_PRIORITY, + CONSUMER_REQUEST_KEY_FRAME, + CONSUMER_ENABLE_TRACE_EVENT, + DATA_PRODUCER_DUMP, + DATA_PRODUCER_GET_STATS, + DATA_CONSUMER_DUMP, + DATA_CONSUMER_GET_STATS, + DATA_CONSUMER_GET_BUFFERED_AMOUNT, + DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, + DATA_CONSUMER_SEND, + RTP_OBSERVER_PAUSE, + RTP_OBSERVER_RESUME, + RTP_OBSERVER_ADD_PRODUCER, + RTP_OBSERVER_REMOVE_PRODUCER, +} + +union Body { + FBS.Worker.UpdateSettingsRequest, + FBS.Worker.CreateWebRtcServerRequest, + FBS.Worker.CloseWebRtcServerRequest, + FBS.Worker.CreateRouterRequest, + FBS.Worker.CloseRouterRequest, + FBS.Router.CreateWebRtcTransportRequest, + FBS.Router.CreatePlainTransportRequest, + FBS.Router.CreatePipeTransportRequest, + FBS.Router.CreateDirectTransportRequest, + FBS.Router.CreateActiveSpeakerObserverRequest, + FBS.Router.CreateAudioLevelObserverRequest, + FBS.Router.CloseTransportRequest, + FBS.Router.CloseRtpObserverRequest, + FBS.Transport.SetMaxIncomingBitrateRequest, + FBS.Transport.SetMaxOutgoingBitrateRequest, + FBS.Transport.SetMinOutgoingBitrateRequest, + FBS.Transport.ProduceRequest, + FBS.Transport.ConsumeRequest, + FBS.Transport.ProduceDataRequest, + FBS.Transport.ConsumeDataRequest, + FBS.Transport.EnableTraceEventRequest, + FBS.Transport.CloseProducerRequest, + FBS.Transport.CloseConsumerRequest, + FBS.Transport.CloseDataProducerRequest, + FBS.Transport.CloseDataConsumerRequest, + FBS.PlainTransport.ConnectRequest, + FBS.PipeTransport.ConnectRequest, + FBS.WebRtcTransport.ConnectRequest, + FBS.Producer.EnableTraceEventRequest, + FBS.Consumer.SetPreferredLayersRequest, + FBS.Consumer.SetPriorityRequest, + FBS.Consumer.EnableTraceEventRequest, + FBS.DataConsumer.SetBufferedAmountLowThresholdRequest, + FBS.DataConsumer.SendRequest, + FBS.RtpObserver.AddProducerRequest, + FBS.RtpObserver.RemoveProducerRequest, +} + +table Request { + id:uint32; + method:Method; + handler_id:string; + body:Body; +} + +root_type Request; diff --git a/worker/fbs/response.fbs b/worker/fbs/response.fbs new file mode 100644 index 0000000000..bd94fbe2db --- /dev/null +++ b/worker/fbs/response.fbs @@ -0,0 +1,50 @@ +include "worker.fbs"; +include "router.fbs"; +include "webRtcServer.fbs"; +include "transport.fbs"; +include "producer.fbs"; +include "consumer.fbs"; +include "dataProducer.fbs"; +include "dataConsumer.fbs"; + +namespace FBS.Response; + +union Body { + FBS_Worker_DumpResponse: FBS.Worker.DumpResponse, + FBS_Worker_ResourceUsageResponse: FBS.Worker.ResourceUsageResponse, + FBS_WebRtcServer_DumpResponse: FBS.WebRtcServer.DumpResponse, + FBS_Router_DumpResponse: FBS.Router.DumpResponse, + FBS_Transport_ProduceResponse: FBS.Transport.ProduceResponse, + FBS_Transport_ConsumeResponse: FBS.Transport.ConsumeResponse, + FBS_Transport_RestartIceResponse: FBS.Transport.RestartIceResponse, + FBS_PlainTransport_ConnectResponse: FBS.PlainTransport.ConnectResponse, + FBS_PlainTransport_DumpResponse: FBS.PlainTransport.DumpResponse, + FBS_PlainTransport_GetStatsResponse: FBS.PlainTransport.GetStatsResponse, + FBS_PipeTransport_ConnectResponse: FBS.PipeTransport.ConnectResponse, + FBS_PipeTransport_DumpResponse: FBS.PipeTransport.DumpResponse, + FBS_PipeTransport_GetStatsResponse: FBS.PipeTransport.GetStatsResponse, + FBS_DirectTransport_DumpResponse: FBS.DirectTransport.DumpResponse, + FBS_DirectTransport_GetStatsResponse: FBS.DirectTransport.GetStatsResponse, + FBS_WebRtcTransport_ConnectResponse: FBS.WebRtcTransport.ConnectResponse, + FBS_WebRtcTransport_DumpResponse: FBS.WebRtcTransport.DumpResponse, + FBS_WebRtcTransport_GetStatsResponse: FBS.WebRtcTransport.GetStatsResponse, + FBS_Producer_DumpResponse: FBS.Producer.DumpResponse, + FBS_Producer_GetStatsResponse: FBS.Producer.GetStatsResponse, + FBS_Consumer_DumpResponse: FBS.Consumer.DumpResponse, + FBS_Consumer_GetStatsResponse: FBS.Consumer.GetStatsResponse, + FBS_Consumer_SetPreferredLayersResponse: FBS.Consumer.SetPreferredLayersResponse, + FBS_Consumer_SetPriorityResponse: FBS.Consumer.SetPriorityResponse, + FBS_DataProducer_DumpResponse: FBS.DataProducer.DumpResponse, + FBS_DataProducer_GetStatsResponse: FBS.DataProducer.GetStatsResponse, + FBS_DataConsumer_GetBufferedAmountResponse: FBS.DataConsumer.GetBufferedAmountResponse, + FBS_DataConsumer_DumpResponse: FBS.DataConsumer.DumpResponse, + FBS_DataConsumer_GetStatsResponse: FBS.DataConsumer.GetStatsResponse, +} + +table Response { + id:uint32; + accepted:bool; + body:Body; + error:string; + reason:string; +} diff --git a/worker/fbs/router.fbs b/worker/fbs/router.fbs new file mode 100644 index 0000000000..ec204dddef --- /dev/null +++ b/worker/fbs/router.fbs @@ -0,0 +1,59 @@ +include "common.fbs"; +include "activeSpeakerObserver.fbs"; +include "audioLevelObserver.fbs"; +include "transport.fbs"; +include "pipeTransport.fbs"; +include "plainTransport.fbs"; +include "webRtcTransport.fbs"; +include "directTransport.fbs"; + +namespace FBS.Router; + +table DumpResponse { + id:string (required); + transport_ids:[string]; + rtp_observer_ids:[string]; + map_producer_id_consumer_ids:[FBS.Common.StringStringArray]; + map_consumer_id_producer_id:[FBS.Common.StringString]; + map_producer_id_observer_ids:[FBS.Common.StringStringArray]; + map_data_producer_id_data_consumer_ids:[FBS.Common.StringStringArray]; + map_data_consumer_id_data_producer_id:[FBS.Common.StringString]; +} + +table CreatePipeTransportRequest { + transport_id:string (required); + options:FBS.PipeTransport.PipeTransportOptions (required); +} + +table CreatePlainTransportRequest { + transport_id:string (required); + options:FBS.PlainTransport.PlainTransportOptions (required); +} + +table CreateWebRtcTransportRequest { + transport_id:string (required); + options:FBS.WebRtcTransport.WebRtcTransportOptions (required); +} + +table CreateDirectTransportRequest { + transport_id:string (required); + options:FBS.DirectTransport.DirectTransportOptions (required); +} + +table CreateAudioLevelObserverRequest { + rtp_observer_id:string (required); + options:FBS.AudioLevelObserver.AudioLevelObserverOptions (required); +} + +table CreateActiveSpeakerObserverRequest { + active_speaker_observer_id:string (required); + options:FBS.ActiveSpeakerObserver.ActiveSpeakerObserverOptions (required); +} + +table CloseTransportRequest { + transport_id:string (required); +} + +table CloseRtpObserverRequest { + rtp_observer_id:string (required); +} diff --git a/worker/fbs/rtpObserver.fbs b/worker/fbs/rtpObserver.fbs new file mode 100644 index 0000000000..b3f754f670 --- /dev/null +++ b/worker/fbs/rtpObserver.fbs @@ -0,0 +1,10 @@ + +namespace FBS.RtpObserver; + +table AddProducerRequest { + producer_id:string (required); +} + +table RemoveProducerRequest { + producer_id:string (required); +} diff --git a/worker/fbs/rtpParameters.fbs b/worker/fbs/rtpParameters.fbs new file mode 100644 index 0000000000..d9c624e7c5 --- /dev/null +++ b/worker/fbs/rtpParameters.fbs @@ -0,0 +1,104 @@ + +namespace FBS.RtpParameters; + +enum MediaKind : uint8 { ALL = 0, AUDIO, VIDEO } +enum Type: uint8 { NONE = 0, SIMPLE, SIMULCAST, SVC, PIPE } + +// Boolean is a uint8/byte type. +table Boolean { + value:uint8; +} + +table Integer { + value:int32; +} + +table IntegerArray { + value:[int32]; +} + +table Double { + value:double; +} + +table String { + value:string; +} + +union Value { + Boolean, + Integer, + Double, + String, + IntegerArray, +} + +table Parameter { + name: string (required); + value: Value; +} + +table RtcpFeedback { + type:string (required); + parameter:string; +} + +table RtpCodecParameters { + mime_type:string (required); + payload_type:uint8; + clock_rate:uint32; + channels:uint8 = null; + parameters:[Parameter]; + rtcp_feedback:[RtcpFeedback]; +} + +table RtpHeaderExtensionParameters { + uri:string (required); + id:uint8; + encrypt:bool = false; + parameters:[Parameter]; +} + +table Rtx { + ssrc:uint32; +} + +table RtpEncodingParameters { + ssrc:uint32 = null; + rid:string; + codec_payload_type:uint8 = null; + rtx:Rtx; + dtx:bool = false; + scalability_mode:string; + max_bitrate:uint32 = null; +} + +table RtcpParameters { + cname:string; + reduced_size:bool = true; +} + +table RtpParameters { + mid:string; + codecs:[RtpCodecParameters] (required); + header_extensions:[RtpHeaderExtensionParameters]; + encodings:[RtpEncodingParameters]; + rtcp:RtcpParameters; +} + +table CodecMapping { + payload_type:uint8; + mapped_payload_type:uint8; +} + +table EncodingMapping { + rid:string; + ssrc:uint32 = null; + scalability_mode:string; + mapped_ssrc:uint32; +} + +table RtpMapping { + codecs:[CodecMapping] (required); + encodings:[EncodingMapping] (required); +} diff --git a/worker/fbs/rtpStream.fbs b/worker/fbs/rtpStream.fbs new file mode 100644 index 0000000000..f12187ca5c --- /dev/null +++ b/worker/fbs/rtpStream.fbs @@ -0,0 +1,81 @@ +include "rtpParameters.fbs"; +include "rtxStream.fbs"; + +namespace FBS.RtpStream; + +table Params { + encoding_idx:uint32; + ssrc:uint32; + payload_type:uint8; + mime_type:string (required); + clock_rate: uint32; + rid:string; + cname:string (required); + rtx_ssrc:uint32 = null; + rtx_payload_type:uint8 = null; + use_nack:bool; + use_pli:bool; + use_fir:bool; + use_in_band_fec:bool; + use_dtx:bool; + spatial_layers:uint8; + temporal_layers:uint8; +} + +table Dump { + params:Params (required); + score:uint8; + rtx_stream:FBS.RtxStream.RtxDump; +} + +table BitrateByLayer { + layer:string (required); + bitrate:uint64; +} + +union StatsData { + BaseStats, + RecvStats, + SendStats, +} + +table Stats { + data:StatsData; +} + +table BaseStats { + timestamp:uint64; + ssrc:uint32; + kind:FBS.RtpParameters.MediaKind; + mime_type:string (required); + packets_lost:uint64; + fraction_lost:uint64; + packets_discarded:uint64; + packets_retransmitted:uint64; + packets_repaired:uint64; + nack_count:uint64; + nack_packet_count:uint64; + pli_count:uint64; + fir_count:uint64; + score:uint8; + rid:string; + rtx_ssrc:uint32 = null; + rtx_packets_discarded:uint64; + round_trip_time:float; +} + +table RecvStats { + base:Stats (required); + jitter:uint32; + packet_count:uint64; + byte_count:uint64; + bitrate:uint64; + bitrate_by_layer:[BitrateByLayer]; +} + +table SendStats { + base:Stats (required); + packet_count:uint64; + byte_count:uint64; + bitrate:uint64; +} diff --git a/worker/fbs/rtxStream.fbs b/worker/fbs/rtxStream.fbs new file mode 100644 index 0000000000..9e96efc568 --- /dev/null +++ b/worker/fbs/rtxStream.fbs @@ -0,0 +1,16 @@ + +namespace FBS.RtxStream; + +table Params { + ssrc:uint32; + payload_type:uint8; + mime_type:string (required); + clock_rate: uint32; + rrid:string; + cname:string (required); +} + +// NOTE: Naming this Dump collides in TS generation for Producer.DumpResponse. +table RtxDump { + params:Params (required); +} diff --git a/worker/fbs/sctpAssociation.fbs b/worker/fbs/sctpAssociation.fbs new file mode 100644 index 0000000000..ef5e0b17d6 --- /dev/null +++ b/worker/fbs/sctpAssociation.fbs @@ -0,0 +1,11 @@ + +namespace FBS.SctpAssociation; + +enum SctpState: uint8 { + NEW = 0, + CONNECTING, + CONNECTED, + FAILED, + CLOSED, +} + diff --git a/worker/fbs/sctpParameters.fbs b/worker/fbs/sctpParameters.fbs new file mode 100644 index 0000000000..ffbd8b7181 --- /dev/null +++ b/worker/fbs/sctpParameters.fbs @@ -0,0 +1,25 @@ + +namespace FBS.SctpParameters; + +table NumSctpStreams { + os:uint32 = 1024; + mis:uint32 = 1024; +} + +table SctpParameters { + // Port is always 5000. + port:uint16=5000; + os:uint16; + mis:uint16; + max_message_size:uint32; + send_buffer_size:uint32; + sctp_buffered_amount:uint32; + is_data_channel:bool; +} + +table SctpStreamParameters { + stream_id:uint16; + ordered:bool = null; + max_packet_life_time:uint16 = null; + max_retransmits:uint16 = null; +} diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs new file mode 100644 index 0000000000..c961a3f604 --- /dev/null +++ b/worker/fbs/transport.fbs @@ -0,0 +1,220 @@ +include "common.fbs"; +include "consumer.fbs"; +include "rtpParameters.fbs"; +include "sctpAssociation.fbs"; +include "sctpParameters.fbs"; + +namespace FBS.Transport; + +enum Protocol: uint8 { UDP = 1, TCP } + +table ListenIp { + ip:string (required); + announced_ip:string; +} + +table RestartIceResponse { + username_fragment:string (required); + password:string (required); + ice_lite:bool; +} + +table ConsumeRequest { + consumer_id:string (required); + producer_id:string (required); + kind:FBS.RtpParameters.MediaKind; + rtp_parameters:FBS.RtpParameters.RtpParameters (required); + type:FBS.RtpParameters.Type; + consumable_rtp_encodings:[FBS.RtpParameters.RtpEncodingParameters] (required); + paused:bool = false; + preferred_layers:FBS.Consumer.ConsumerLayers; + ignore_dtx:bool = false; +} + +table ConsumeResponse { + paused:bool; + producer_paused:bool; + score:FBS.Consumer.ConsumerScore; + preferred_layers:FBS.Consumer.ConsumerLayers; +} + +table ProduceRequest { + producer_id:string (required); + kind:FBS.RtpParameters.MediaKind; + rtp_parameters:FBS.RtpParameters.RtpParameters (required); + rtp_mapping:FBS.RtpParameters.RtpMapping (required); + key_frame_request_delay:uint16; + paused:bool = false; +} + +table ProduceResponse { + type:FBS.RtpParameters.Type; +} + +table ProduceDataRequest { + data_producer_id:string (required); + type:string (required); + sctp_stream_parameters:FBS.SctpParameters.SctpStreamParameters; + label:string; + protocol:string; +} + +table ConsumeDataRequest { + data_consumer_id:string (required); + data_producer_id:string (required); + type:string (required); + sctp_stream_parameters:FBS.SctpParameters.SctpStreamParameters; + label:string; + protocol:string; +} + +table Tuple { + local_ip:string (required); + local_port:uint16; + remote_ip:string (required); + remote_port:uint16; + protocol:string (required); +} + +table SrtpParameters { + crypto_suite:string (required); + key_base64:string (required); +} + +table RtpListener { + ssrc_table:[FBS.Common.Uint32String] (required); + mid_table:[FBS.Common.StringString] (required); + rid_table:[FBS.Common.StringString] (required); +} + +table SctpListener { + stream_id_table:[FBS.Common.Uint16String] (required); +} + +table Dump { + id:string (required); + direct:bool=false; + producer_ids:[string] (required); + consumer_ids:[string] (required); + map_ssrc_consumer_id:[FBS.Common.Uint32String] (required); + map_rtx_ssrc_consumer_id:[FBS.Common.Uint32String] (required); + data_producer_ids:[string] (required); + data_consumer_ids:[string] (required); + recv_rtp_header_extensions:[FBS.Common.StringUint8] (required); + rtp_listener:RtpListener (required); + max_message_size:uint32; + sctp_parameters:FBS.SctpParameters.SctpParameters; + sctp_state:string; + sctp_listener: SctpListener; + trace_event_types:[string] (required); +} + +table Options { + direct:bool = false; + max_message_size:uint32; + initial_available_outgoing_bitrate:uint32; + enable_sctp:bool = false; + num_sctp_streams:FBS.SctpParameters.NumSctpStreams; + max_sctp_message_size:uint32; + sctp_send_buffer_size:uint32; + is_data_channel:bool = false; +} + +table Stats { + transport_id:string (required); + timestamp:uint64; + sctp_state:string; + bytes_received:uint64; + recv_bitrate:uint64; + bytes_sent:uint64; + send_bitrate:uint64; + rtp_bytes_received:uint64; + rtp_recv_bitrate:uint64; + rtp_bytes_sent:uint64; + rtp_send_bitrate:uint64; + rtx_bytes_received:uint64; + rtx_recv_bitrate:uint64; + rtx_bytes_sent:uint64; + rtx_send_bitrate:uint64; + probation_bytes_sent:uint64; + probation_send_bitrate:uint64; + available_outgoing_bitrate:uint64; + available_incoming_bitrate:uint64; + max_incoming_bitrate:uint64; + max_outgoing_bitrate:uint64; + min_outgoing_bitrate:uint64; + rtp_packet_loss_received:uint64; + rtp_packet_loss_sent:uint64; +} + +table SetMaxIncomingBitrateRequest { + max_incoming_bitrate:uint32; +} + +table SetMaxOutgoingBitrateRequest { + max_outgoing_bitrate:uint32; +} + +table SetMinOutgoingBitrateRequest { + min_outgoing_bitrate:uint32; +} + +table EnableTraceEventRequest { + events:[string] (required); +} + +table CloseProducerRequest { + producer_id:string (required); +} + +table CloseConsumerRequest { + consumer_id:string (required); +} + +table CloseDataProducerRequest { + data_producer_id:string (required); +} + +table CloseDataConsumerRequest { + data_consumer_id:string (required); +} + +// Notifications to Worker. + +table SendRtcpNotification { + data:[uint8] (required); +} + +// Notifications from Worker. + +table SctpStateChangeNotification { + sctp_state:FBS.SctpAssociation.SctpState; +} + +enum TraceType: uint8 { PROBATION = 0, BWE } +// NOTE (windows): IN|OUT are macros defined in windef.h. +enum TraceDirection: uint8 { DIRECTION_IN = 0, DIRECTION_OUT } + +union TraceInfo { + BweTraceInfo, +} + +enum BweType: uint8 { TRANSPORT_CC = 0, REMB } + +table BweTraceInfo { + desired_bitrate:uint32; + effective_desired_bitrate:uint32; + min_bitrate:uint32; + max_bitrate:uint32; + start_bitrate:uint32; + max_padding_bitrate:uint32; + available_bitrate:uint32; + bwe_type:BweType; +} + +table TraceNotification { + type: TraceType; + timestamp: uint64; + direction: TraceDirection; + info: TraceInfo; +} diff --git a/worker/fbs/webRtcServer.fbs b/worker/fbs/webRtcServer.fbs new file mode 100644 index 0000000000..087f744088 --- /dev/null +++ b/worker/fbs/webRtcServer.fbs @@ -0,0 +1,34 @@ +include "transport.fbs"; + +namespace FBS.WebRtcServer; + +table ListenInfo { + protocol:FBS.Transport.Protocol=UDP; + ip:string (required); + announced_ip:string; + port:uint16 = 0; +} + +table IpPort { + ip:string (required); + port:uint16; +} + +table IceUserNameFragment { + local_ice_username_fragment:string (required); + web_rtc_transport_id:string (required); +} + +table TupleHash { + local_ice_username_fragment:uint64; + web_rtc_transport_id:string (required); +} + +table DumpResponse { + id:string (required); + udp_sockets:[IpPort]; + tcp_servers:[IpPort]; + web_rtc_transport_ids:[string]; + local_ice_username_fragments:[IceUserNameFragment]; + tuple_hashes:[TupleHash]; +} diff --git a/worker/fbs/webRtcTransport.fbs b/worker/fbs/webRtcTransport.fbs new file mode 100644 index 0000000000..2fcaa930fc --- /dev/null +++ b/worker/fbs/webRtcTransport.fbs @@ -0,0 +1,98 @@ +include "transport.fbs"; +include "sctpParameters.fbs"; + +namespace FBS.WebRtcTransport; + +table ListenIndividual { + listen_ips:[FBS.Transport.ListenIp] (required); + port:uint16; +} + +table ListenServer { + web_rtc_server_id:string (required); +} + +union Listen { + ListenIndividual, + ListenServer, +} + +table WebRtcTransportOptions { + base:FBS.Transport.Options (required); + listen:Listen (required); + enable_udp:bool = true; + enable_tcp:bool = false; + prefer_udp:bool = false; + prefer_tcp:bool = false; +} + +table Fingerprint { + algorithm:string (required); + value:string (required); +} + +table DtlsParameters { + fingerprints:[Fingerprint] (required); + role:string; +} + +table IceParameters { + username_fragment:string (required); + password:string (required); + ice_lite:bool = true; +} + +table IceCandidate { + foundation:string (required); + priority:uint32; + ip:string (required); + protocol:string (required); + port:uint16; + type:string; + tcp_type:string; +} + +table ConnectRequest { + dtls_parameters:DtlsParameters (required); +} + +table ConnectResponse { + dtls_local_role:string (required); +} + +table DumpResponse { + base:FBS.Transport.Dump (required); + ice_role:string (required); + ice_parameters:IceParameters (required); + ice_candidates:[IceCandidate] (required); + ice_state:string (required); + ice_selected_tuple:FBS.Transport.Tuple; + dtls_parameters:DtlsParameters (required); + dtls_state:string (required); +} + +table GetStatsResponse { + base:FBS.Transport.Stats (required); + ice_role:string (required); + ice_state:string (required); + ice_selected_tuple:FBS.Transport.Tuple; + dtls_state:string (required); +} + +// Notifications from Worker. + +table IceSelectedTupleChangeNotification { + tuple:FBS.Transport.Tuple (required); +} + +enum IceState: uint8 { NEW = 0, CONNECTED, COMPLETED, DISCONNECTED, CLOSED } +enum DtlsState: uint8 { NEW = 0, CONNECTING, CONNECTED, FAILED, CLOSED } + +table IceStateChangeNotification { + ice_state:IceState; +} + +table DtlsStateChangeNotification { + dtls_state:DtlsState; + remote_cert:string; +} diff --git a/worker/fbs/worker.fbs b/worker/fbs/worker.fbs new file mode 100644 index 0000000000..26b97b1437 --- /dev/null +++ b/worker/fbs/worker.fbs @@ -0,0 +1,56 @@ +include "webRtcServer.fbs"; + +namespace FBS.Worker; + +table ChannelMessageHandlers { + channel_request_handlers:[string]; + channel_notification_handlers:[string]; +} + +table DumpResponse { + pid:uint32; + web_rtc_server_ids:[string]; + router_ids:[string]; + channel_message_handlers:ChannelMessageHandlers; +} + +table ResourceUsageResponse { + ru_utime:uint64; + ru_stime:uint64; + ru_maxrss:uint64; + ru_ixrss:uint64; + ru_idrss:uint64; + ru_isrss:uint64; + ru_minflt:uint64; + ru_majflt:uint64; + ru_nswap:uint64; + ru_inblock:uint64; + ru_oublock:uint64; + ru_msgsnd:uint64; + ru_msgrcv:uint64; + ru_nsignals:uint64; + ru_nvcsw:uint64; + ru_nivcsw:uint64; +} + +table UpdateSettingsRequest { + log_level:string; + log_tags:[string]; +} + +table CreateWebRtcServerRequest { + web_rtc_server_id:string (required); + listen_infos:[FBS.WebRtcServer.ListenInfo]; +} + +table CloseWebRtcServerRequest { + web_rtc_server_id:string (required); +} + +table CreateRouterRequest { + router_id:string (required); +} + +table CloseRouterRequest { + router_id:string (required); +} diff --git a/worker/include/Channel/ChannelNotification.hpp b/worker/include/Channel/ChannelNotification.hpp new file mode 100644 index 0000000000..05fdf7d290 --- /dev/null +++ b/worker/include/Channel/ChannelNotification.hpp @@ -0,0 +1,33 @@ +#ifndef MS_CHANNEL_NOTIFICATION_HPP +#define MS_CHANNEL_NOTIFICATION_HPP + +#include "common.hpp" +#include "FBS/notification_generated.h" +#include +#include + +namespace Channel +{ + class ChannelNotification + { + public: + using Event = FBS::Notification::Event; + + private: + static absl::flat_hash_map event2String; + + public: + explicit ChannelNotification(const FBS::Notification::Notification* notification); + ~ChannelNotification() = default; + + public: + // Passed by argument. + Event event; + // Others. + const char* eventCStr; + std::string handlerId; + const FBS::Notification::Notification* data{ nullptr }; + }; +} // namespace Channel + +#endif diff --git a/worker/include/Channel/ChannelNotifier.hpp b/worker/include/Channel/ChannelNotifier.hpp index 5f3eabf5be..c918b077a3 100644 --- a/worker/include/Channel/ChannelNotifier.hpp +++ b/worker/include/Channel/ChannelNotifier.hpp @@ -3,11 +3,8 @@ #include "common.hpp" #include "Channel/ChannelSocket.hpp" -#include #include -using json = nlohmann::json; - namespace Channel { class ChannelNotifier @@ -16,14 +13,56 @@ namespace Channel explicit ChannelNotifier(Channel::ChannelSocket* channel); public: - void Emit(uint64_t targetId, const char* event); - void Emit(const std::string& targetId, const char* event); - void Emit(const std::string& targetId, const char* event, json& data); - void Emit(const std::string& targetId, const char* event, const std::string& data); + flatbuffers::FlatBufferBuilder& GetBufferBuilder() + { + return this->bufferBuilder; + } + + template + void Emit( + const std::string& targetId, + FBS::Notification::Event event, + FBS::Notification::Body type, + flatbuffers::Offset& body) + { + auto& builder = ChannelNotifier::bufferBuilder; + auto notification = FBS::Notification::CreateNotificationDirect( + builder, targetId.c_str(), event, type, body.Union()); + + auto message = FBS::Message::CreateMessage( + builder, + FBS::Message::Type::NOTIFICATION, + FBS::Message::Body::FBS_Notification_Notification, + notification.Union()); + + builder.FinishSizePrefixed(message); + this->channel->Send(builder.GetBufferPointer(), builder.GetSize()); + builder.Reset(); + } + + void Emit(const std::string& targetId, FBS::Notification::Event event) + { + auto& builder = ChannelNotifier::bufferBuilder; + auto notification = + FBS::Notification::CreateNotificationDirect(builder, targetId.c_str(), event); + + auto message = FBS::Message::CreateMessage( + builder, + FBS::Message::Type::NOTIFICATION, + FBS::Message::Body::FBS_Notification_Notification, + notification.Union()); + + builder.FinishSizePrefixed(message); + this->channel->Send(builder.GetBufferPointer(), builder.GetSize()); + builder.Reset(); + } + void Emit(const FBS::Notification::Notification& notification); private: // Passed by argument. Channel::ChannelSocket* channel{ nullptr }; + // Others. + flatbuffers::FlatBufferBuilder bufferBuilder{}; }; } // namespace Channel diff --git a/worker/include/Channel/ChannelRequest.hpp b/worker/include/Channel/ChannelRequest.hpp index 7381c94d7e..c26d20690c 100644 --- a/worker/include/Channel/ChannelRequest.hpp +++ b/worker/include/Channel/ChannelRequest.hpp @@ -2,12 +2,13 @@ #define MS_CHANNEL_REQUEST_HPP #include "common.hpp" +#include "FBS/message_generated.h" +#include "FBS/request_generated.h" +#include "FBS/response_generated.h" #include -#include +#include #include -using json = nlohmann::json; - namespace Channel { // Avoid cyclic #include problem by declaring classes instead of including @@ -17,89 +18,57 @@ namespace Channel class ChannelRequest { public: - enum class MethodId - { - WORKER_CLOSE = 1, - WORKER_DUMP, - WORKER_GET_RESOURCE_USAGE, - WORKER_UPDATE_SETTINGS, - WORKER_CREATE_WEBRTC_SERVER, - WORKER_CREATE_ROUTER, - WORKER_WEBRTC_SERVER_CLOSE, - WEBRTC_SERVER_DUMP, - WORKER_CLOSE_ROUTER, - ROUTER_DUMP, - ROUTER_CREATE_WEBRTC_TRANSPORT, - ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER, - ROUTER_CREATE_PLAIN_TRANSPORT, - ROUTER_CREATE_PIPE_TRANSPORT, - ROUTER_CREATE_DIRECT_TRANSPORT, - ROUTER_CLOSE_TRANSPORT, - ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER, - ROUTER_CREATE_AUDIO_LEVEL_OBSERVER, - ROUTER_CLOSE_RTP_OBSERVER, - TRANSPORT_DUMP, - TRANSPORT_GET_STATS, - TRANSPORT_CONNECT, - TRANSPORT_SET_MAX_INCOMING_BITRATE, - TRANSPORT_SET_MAX_OUTGOING_BITRATE, - TRANSPORT_SET_MIN_OUTGOING_BITRATE, - TRANSPORT_RESTART_ICE, - TRANSPORT_PRODUCE, - TRANSPORT_CONSUME, - TRANSPORT_PRODUCE_DATA, - TRANSPORT_CONSUME_DATA, - TRANSPORT_ENABLE_TRACE_EVENT, - TRANSPORT_CLOSE_PRODUCER, - PRODUCER_DUMP, - PRODUCER_GET_STATS, - PRODUCER_PAUSE, - PRODUCER_RESUME, - PRODUCER_ENABLE_TRACE_EVENT, - TRANSPORT_CLOSE_CONSUMER, - CONSUMER_DUMP, - CONSUMER_GET_STATS, - CONSUMER_PAUSE, - CONSUMER_RESUME, - CONSUMER_SET_PREFERRED_LAYERS, - CONSUMER_SET_PRIORITY, - CONSUMER_REQUEST_KEY_FRAME, - CONSUMER_ENABLE_TRACE_EVENT, - TRANSPORT_CLOSE_DATA_PRODUCER, - DATA_PRODUCER_DUMP, - DATA_PRODUCER_GET_STATS, - TRANSPORT_CLOSE_DATA_CONSUMER, - DATA_CONSUMER_DUMP, - DATA_CONSUMER_GET_STATS, - DATA_CONSUMER_GET_BUFFERED_AMOUNT, - DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, - RTP_OBSERVER_PAUSE, - RTP_OBSERVER_RESUME, - RTP_OBSERVER_ADD_PRODUCER, - RTP_OBSERVER_REMOVE_PRODUCER - }; + using Method = FBS::Request::Method; - private: - static absl::flat_hash_map string2MethodId; + public: + static absl::flat_hash_map method2String; public: - ChannelRequest(Channel::ChannelSocket* channel, const char* msg, size_t msgLen); - virtual ~ChannelRequest(); + ChannelRequest(Channel::ChannelSocket* channel, const FBS::Request::Request* request); + ~ChannelRequest() = default; + flatbuffers::FlatBufferBuilder& GetBufferBuilder() + { + return this->bufferBuilder; + } void Accept(); - void Accept(json& data); + template + void Accept(FBS::Response::Body type, flatbuffers::Offset& body) + { + assert(!this->replied); + + this->replied = true; + + auto& builder = this->bufferBuilder; + auto response = FBS::Response::CreateResponse(builder, this->id, true, type, body.Union()); + + auto message = FBS::Message::CreateMessage( + builder, + FBS::Message::Type::RESPONSE, + FBS::Message::Body::FBS_Response_Response, + response.Union()); + + builder.FinishSizePrefixed(message); + this->Send(builder.GetBufferPointer(), builder.GetSize()); + builder.Reset(); + } void Error(const char* reason = nullptr); void TypeError(const char* reason = nullptr); + private: + void Send(uint8_t* buffer, size_t size); + void SendResponse(const flatbuffers::Offset& response); + public: // Passed by argument. Channel::ChannelSocket* channel{ nullptr }; + const FBS::Request::Request* data{ nullptr }; + // Others. + flatbuffers::FlatBufferBuilder bufferBuilder{}; uint32_t id{ 0u }; - std::string method; - MethodId methodId; + Method method; + const char* methodCStr; std::string handlerId; - json data; - // Others. bool replied{ false }; }; } // namespace Channel diff --git a/worker/include/Channel/ChannelSocket.hpp b/worker/include/Channel/ChannelSocket.hpp index fdc98b8e7e..58dc41a176 100644 --- a/worker/include/Channel/ChannelSocket.hpp +++ b/worker/include/Channel/ChannelSocket.hpp @@ -2,13 +2,11 @@ #define MS_CHANNEL_SOCKET_HPP #include "common.hpp" +#include "Channel/ChannelNotification.hpp" #include "Channel/ChannelRequest.hpp" #include "handles/UnixStreamSocket.hpp" -#include #include -using json = nlohmann::json; - namespace Channel { class ConsumerSocket : public ::UnixStreamSocket @@ -65,7 +63,16 @@ namespace Channel virtual void HandleRequest(Channel::ChannelRequest* request) = 0; }; - class Listener : public RequestHandler + class NotificationHandler + { + public: + virtual ~NotificationHandler() = default; + + public: + virtual void HandleNotification(Channel::ChannelNotification* notification) = 0; + }; + + class Listener : public RequestHandler, public NotificationHandler { public: virtual ~Listener() = default; @@ -86,8 +93,7 @@ namespace Channel public: void Close(); void SetListener(Listener* listener); - void Send(json& jsonMessage); - void Send(const std::string& message); + void Send(const uint8_t* message, uint32_t messageLen); void SendLog(const char* message, uint32_t messageLen); bool CallbackRead(); @@ -111,7 +117,7 @@ namespace Channel ChannelWriteFn channelWriteFn{ nullptr }; ChannelWriteCtx channelWriteCtx{ nullptr }; uv_async_t* uvReadHandle{ nullptr }; - uint8_t* writeBuffer{ nullptr }; + flatbuffers::FlatBufferBuilder bufferBuilder{}; }; } // namespace Channel diff --git a/worker/include/ChannelMessageRegistrator.hpp b/worker/include/ChannelMessageRegistrator.hpp index f01300a658..f27e708ff1 100644 --- a/worker/include/ChannelMessageRegistrator.hpp +++ b/worker/include/ChannelMessageRegistrator.hpp @@ -3,9 +3,7 @@ #include "common.hpp" #include "Channel/ChannelSocket.hpp" -#include "PayloadChannel/PayloadChannelSocket.hpp" #include -#include #include class ChannelMessageRegistrator @@ -15,25 +13,19 @@ class ChannelMessageRegistrator ~ChannelMessageRegistrator(); public: - void FillJson(json& jsonObject); + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder); void RegisterHandler( const std::string& id, Channel::ChannelSocket::RequestHandler* channelRequestHandler, - PayloadChannel::PayloadChannelSocket::RequestHandler* payloadChannelRequestHandler, - PayloadChannel::PayloadChannelSocket::NotificationHandler* payloadChannelNotificationHandler); + Channel::ChannelSocket::NotificationHandler* channelNotificationHandler); void UnregisterHandler(const std::string& id); Channel::ChannelSocket::RequestHandler* GetChannelRequestHandler(const std::string& id); - PayloadChannel::PayloadChannelSocket::RequestHandler* GetPayloadChannelRequestHandler( - const std::string& id); - PayloadChannel::PayloadChannelSocket::NotificationHandler* GetPayloadChannelNotificationHandler( - const std::string& id); + Channel::ChannelSocket::NotificationHandler* GetChannelNotificationHandler(const std::string& id); private: absl::flat_hash_map mapChannelRequestHandlers; - absl::flat_hash_map - mapPayloadChannelRequestHandlers; - absl::flat_hash_map - mapPayloadChannelNotificationHandlers; + absl::flat_hash_map mapChannelNotificationHandlers; }; #endif diff --git a/worker/include/PayloadChannel/PayloadChannelNotification.hpp b/worker/include/PayloadChannel/PayloadChannelNotification.hpp deleted file mode 100644 index 5f4f3c2f86..0000000000 --- a/worker/include/PayloadChannel/PayloadChannelNotification.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef MS_PAYLOAD_CHANNEL_NOTIFICATION_HPP -#define MS_PAYLOAD_CHANNEL_NOTIFICATION_HPP - -#include "common.hpp" -#include -#include - -namespace PayloadChannel -{ - class PayloadChannelNotification - { - public: - enum class EventId - { - TRANSPORT_SEND_RTCP = 1, - PRODUCER_SEND, - DATA_PRODUCER_SEND - }; - - public: - static bool IsNotification(const char* msg, size_t msgLen); - - private: - static absl::flat_hash_map string2EventId; - - public: - PayloadChannelNotification(const char* msg, size_t msgLen); - virtual ~PayloadChannelNotification(); - - public: - void SetPayload(const uint8_t* payload, size_t payloadLen); - - public: - // Passed by argument. - std::string event; - EventId eventId; - std::string handlerId; - std::string data; - const uint8_t* payload{ nullptr }; - size_t payloadLen{ 0u }; - }; -} // namespace PayloadChannel - -#endif diff --git a/worker/include/PayloadChannel/PayloadChannelNotifier.hpp b/worker/include/PayloadChannel/PayloadChannelNotifier.hpp deleted file mode 100644 index c7df84a484..0000000000 --- a/worker/include/PayloadChannel/PayloadChannelNotifier.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef MS_PAYLOAD_CHANNEL_NOTIFIER_HPP -#define MS_PAYLOAD_CHANNEL_NOTIFIER_HPP - -#include "common.hpp" -#include "PayloadChannel/PayloadChannelSocket.hpp" -#include -#include - -using json = nlohmann::json; - -namespace PayloadChannel -{ - class PayloadChannelNotifier - { - public: - explicit PayloadChannelNotifier(PayloadChannel::PayloadChannelSocket* payloadChannel); - - public: - void Emit(const std::string& targetId, const char* event, const uint8_t* payload, size_t payloadLen); - void Emit( - const std::string& targetId, - const char* event, - json& data, - const uint8_t* payload, - size_t payloadLen); - void Emit( - const std::string& targetId, - const char* event, - const std::string& data, - const uint8_t* payload, - size_t payloadLen); - - private: - // Passed by argument. - PayloadChannel::PayloadChannelSocket* payloadChannel{ nullptr }; - }; -} // namespace PayloadChannel - -#endif diff --git a/worker/include/PayloadChannel/PayloadChannelRequest.hpp b/worker/include/PayloadChannel/PayloadChannelRequest.hpp deleted file mode 100644 index 0ae60fec3b..0000000000 --- a/worker/include/PayloadChannel/PayloadChannelRequest.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef MS_PAYLOAD_CHANNEL_REQUEST_HPP -#define MS_PAYLOAD_CHANNEL_REQUEST_HPP - -#include "common.hpp" -#include -#include -#include - -using json = nlohmann::json; - -namespace PayloadChannel -{ - // Avoid cyclic #include problem by declaring classes instead of including - // the corresponding header files. - class PayloadChannelSocket; - - class PayloadChannelRequest - { - public: - enum class MethodId - { - DATA_CONSUMER_SEND - }; - - public: - static bool IsRequest(const char* msg, size_t msgLen); - - private: - static absl::flat_hash_map string2MethodId; - - public: - PayloadChannelRequest(PayloadChannel::PayloadChannelSocket* channel, char* msg, size_t msgLen); - virtual ~PayloadChannelRequest(); - - public: - void Accept(); - void Accept(json& data); - void Error(const char* reason = nullptr); - void TypeError(const char* reason = nullptr); - void SetPayload(const uint8_t* payload, size_t payloadLen); - - public: - // Passed by argument. - PayloadChannel::PayloadChannelSocket* channel{ nullptr }; - uint32_t id{ 0u }; - std::string method; - MethodId methodId; - std::string handlerId; - std::string data; - const uint8_t* payload{ nullptr }; - size_t payloadLen{ 0u }; - // Others. - bool replied{ false }; - }; -} // namespace PayloadChannel - -#endif diff --git a/worker/include/PayloadChannel/PayloadChannelSocket.hpp b/worker/include/PayloadChannel/PayloadChannelSocket.hpp deleted file mode 100644 index 4191706246..0000000000 --- a/worker/include/PayloadChannel/PayloadChannelSocket.hpp +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef MS_PAYLOAD_CHANNEL_SOCKET_HPP -#define MS_PAYLOAD_CHANNEL_SOCKET_HPP - -#include "common.hpp" -#include "PayloadChannel/PayloadChannelNotification.hpp" -#include "PayloadChannel/PayloadChannelRequest.hpp" -#include "handles/UnixStreamSocket.hpp" -#include -#include - -using json = nlohmann::json; - -namespace PayloadChannel -{ - class ConsumerSocket : public ::UnixStreamSocket - { - public: - class Listener - { - public: - virtual ~Listener() = default; - - public: - virtual void OnConsumerSocketMessage(ConsumerSocket* consumerSocket, char* msg, size_t msgLen) = 0; - virtual void OnConsumerSocketClosed(ConsumerSocket* consumerSocket) = 0; - }; - - public: - ConsumerSocket(int fd, size_t bufferSize, Listener* listener); - ~ConsumerSocket(); - - /* Pure virtual methods inherited from ::UnixStreamSocket. */ - public: - void UserOnUnixStreamRead() override; - void UserOnUnixStreamSocketClosed() override; - - private: - // Passed by argument. - Listener* listener{ nullptr }; - }; - - class ProducerSocket : public ::UnixStreamSocket - { - public: - ProducerSocket(int fd, size_t bufferSize); - - /* Pure virtual methods inherited from ::UnixStreamSocket. */ - public: - void UserOnUnixStreamRead() override - { - } - void UserOnUnixStreamSocketClosed() override - { - } - }; - - class PayloadChannelSocket : public ConsumerSocket::Listener - { - public: - class RequestHandler - { - public: - virtual ~RequestHandler() = default; - - public: - virtual void HandleRequest(PayloadChannel::PayloadChannelRequest* request) = 0; - }; - - class NotificationHandler - { - public: - virtual ~NotificationHandler() = default; - - public: - virtual void HandleNotification(PayloadChannel::PayloadChannelNotification* notification) = 0; - }; - - class Listener : public RequestHandler, public NotificationHandler - { - public: - virtual ~Listener() = default; - - public: - virtual void OnPayloadChannelClosed(PayloadChannel::PayloadChannelSocket* payloadChannel) = 0; - }; - - public: - explicit PayloadChannelSocket(int consumerFd, int producerFd); - explicit PayloadChannelSocket( - PayloadChannelReadFn payloadChannelReadFn, - PayloadChannelReadCtx payloadChannelReadCtx, - PayloadChannelWriteFn payloadChannelWriteFn, - PayloadChannelWriteCtx payloadChannelWriteCtx); - virtual ~PayloadChannelSocket(); - - public: - void Close(); - void SetListener(Listener* listener); - void Send(json& jsonMessage, const uint8_t* payload, size_t payloadLen); - void Send(const std::string& message, const uint8_t* payload, size_t payloadLen); - void Send(json& jsonMessage); - void Send(const std::string& message); - bool CallbackRead(); - - private: - void SendImpl(const uint8_t* message, uint32_t messageLen); - void SendImpl( - const uint8_t* message, uint32_t messageLen, const uint8_t* payload, uint32_t payloadLen); - - /* Pure virtual methods inherited from ConsumerSocket::Listener. */ - public: - void OnConsumerSocketMessage(ConsumerSocket* consumerSocket, char* msg, size_t msgLen) override; - void OnConsumerSocketClosed(ConsumerSocket* consumerSocket) override; - - private: - // Passed by argument. - Listener* listener{ nullptr }; - // Others. - bool closed{ false }; - ConsumerSocket* consumerSocket{ nullptr }; - ProducerSocket* producerSocket{ nullptr }; - PayloadChannelReadFn payloadChannelReadFn{ nullptr }; - PayloadChannelReadCtx payloadChannelReadCtx{ nullptr }; - PayloadChannelWriteFn payloadChannelWriteFn{ nullptr }; - PayloadChannelWriteCtx payloadChannelWriteCtx{ nullptr }; - PayloadChannel::PayloadChannelNotification* ongoingNotification{ nullptr }; - PayloadChannel::PayloadChannelRequest* ongoingRequest{ nullptr }; - uv_async_t* uvReadHandle{ nullptr }; - uint8_t* writeBuffer{ nullptr }; - }; -} // namespace PayloadChannel - -#endif diff --git a/worker/include/RTC/ActiveSpeakerObserver.hpp b/worker/include/RTC/ActiveSpeakerObserver.hpp index cf4be62223..586820fdae 100644 --- a/worker/include/RTC/ActiveSpeakerObserver.hpp +++ b/worker/include/RTC/ActiveSpeakerObserver.hpp @@ -5,7 +5,6 @@ #include "RTC/Shared.hpp" #include "handles/Timer.hpp" #include -#include #include #include @@ -71,7 +70,10 @@ namespace RTC public: ActiveSpeakerObserver( - RTC::Shared* shared, const std::string& id, RTC::RtpObserver::Listener* listener, json& data); + RTC::Shared* shared, + const std::string& id, + RTC::RtpObserver::Listener* listener, + const FBS::ActiveSpeakerObserver::ActiveSpeakerObserverOptions* options); ~ActiveSpeakerObserver() override; public: diff --git a/worker/include/RTC/AudioLevelObserver.hpp b/worker/include/RTC/AudioLevelObserver.hpp index c0007e7301..54cec18f0f 100644 --- a/worker/include/RTC/AudioLevelObserver.hpp +++ b/worker/include/RTC/AudioLevelObserver.hpp @@ -5,9 +5,6 @@ #include "RTC/Shared.hpp" #include "handles/Timer.hpp" #include -#include - -using json = nlohmann::json; namespace RTC { @@ -22,7 +19,10 @@ namespace RTC public: AudioLevelObserver( - RTC::Shared* shared, const std::string& id, RTC::RtpObserver::Listener* listener, json& data); + RTC::Shared* shared, + const std::string& id, + RTC::RtpObserver::Listener* listener, + const FBS::AudioLevelObserver::AudioLevelObserverOptions* options); ~AudioLevelObserver() override; public: diff --git a/worker/include/RTC/Consumer.hpp b/worker/include/RTC/Consumer.hpp index 016a5ed085..5802777632 100644 --- a/worker/include/RTC/Consumer.hpp +++ b/worker/include/RTC/Consumer.hpp @@ -4,6 +4,7 @@ #include "common.hpp" #include "Channel/ChannelRequest.hpp" #include "Channel/ChannelSocket.hpp" +#include "FBS/consumer_generated.h" #include "RTC/RTCP/CompoundPacket.hpp" #include "RTC/RTCP/FeedbackPs.hpp" #include "RTC/RTCP/FeedbackPsFir.hpp" @@ -17,12 +18,9 @@ #include "RTC/RtpStreamSend.hpp" #include "RTC/Shared.hpp" #include -#include #include #include -using json = nlohmann::json; - namespace RTC { class Consumer : public Channel::ChannelSocket::RequestHandler @@ -65,14 +63,20 @@ namespace RTC const std::string& id, const std::string& producerId, RTC::Consumer::Listener* listener, - json& data, + const FBS::Transport::ConsumeRequest* data, RTC::RtpParameters::Type type); virtual ~Consumer(); public: - virtual void FillJson(json& jsonObject) const; - virtual void FillJsonStats(json& jsonArray) const = 0; - virtual void FillJsonScore(json& jsonObject) const = 0; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; + virtual flatbuffers::Offset FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) = 0; + virtual flatbuffers::Offset FillBufferScore( + flatbuffers::FlatBufferBuilder& builder) const + { + return 0; + }; RTC::Media::Kind GetKind() const { return this->kind; @@ -166,6 +170,7 @@ namespace RTC void EmitTraceEventPliType(uint32_t ssrc) const; void EmitTraceEventFirType(uint32_t ssrc) const; void EmitTraceEventNackType() const; + void EmitTraceEvent(flatbuffers::Offset& notification) const; private: virtual void UserOnTransportConnected() = 0; diff --git a/worker/include/RTC/DataConsumer.hpp b/worker/include/RTC/DataConsumer.hpp index 46d1f15629..d888e3c3c9 100644 --- a/worker/include/RTC/DataConsumer.hpp +++ b/worker/include/RTC/DataConsumer.hpp @@ -4,11 +4,8 @@ #include "common.hpp" #include "Channel/ChannelRequest.hpp" #include "Channel/ChannelSocket.hpp" -#include "PayloadChannel/PayloadChannelRequest.hpp" -#include "PayloadChannel/PayloadChannelSocket.hpp" #include "RTC/SctpDictionaries.hpp" #include "RTC/Shared.hpp" -#include #include namespace RTC @@ -17,8 +14,7 @@ namespace RTC // (this is to avoid circular dependencies). class SctpAssociation; - class DataConsumer : public Channel::ChannelSocket::RequestHandler, - public PayloadChannel::PayloadChannelSocket::RequestHandler + class DataConsumer : public Channel::ChannelSocket::RequestHandler { protected: using onQueuedCallback = const std::function; @@ -53,13 +49,15 @@ namespace RTC const std::string& dataProducerId, RTC::SctpAssociation* sctpAssociation, RTC::DataConsumer::Listener* listener, - json& data, + const FBS::Transport::ConsumeDataRequest* data, size_t maxMessageSize); virtual ~DataConsumer(); public: - void FillJson(json& jsonObject) const; - void FillJsonStats(json& jsonArray) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; + flatbuffers::Offset FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) const; Type GetType() const { return this->type; @@ -91,10 +89,6 @@ namespace RTC public: void HandleRequest(Channel::ChannelRequest* request) override; - /* Methods inherited from PayloadChannel::PayloadChannelSocket::RequestHandler. */ - public: - void HandleRequest(PayloadChannel::PayloadChannelRequest* request) override; - public: // Passed by argument. const std::string id; diff --git a/worker/include/RTC/DataProducer.hpp b/worker/include/RTC/DataProducer.hpp index 952cc0df9f..6ebe066ba1 100644 --- a/worker/include/RTC/DataProducer.hpp +++ b/worker/include/RTC/DataProducer.hpp @@ -4,17 +4,15 @@ #include "common.hpp" #include "Channel/ChannelRequest.hpp" #include "Channel/ChannelSocket.hpp" -#include "PayloadChannel/PayloadChannelSocket.hpp" #include "RTC/RTCP/Packet.hpp" #include "RTC/SctpDictionaries.hpp" #include "RTC/Shared.hpp" -#include #include namespace RTC { class DataProducer : public Channel::ChannelSocket::RequestHandler, - public PayloadChannel::PayloadChannelSocket::NotificationHandler + public Channel::ChannelSocket::NotificationHandler { public: class Listener @@ -41,12 +39,14 @@ namespace RTC const std::string& id, size_t maxMessageSize, RTC::DataProducer::Listener* listener, - json& data); + const FBS::Transport::ProduceDataRequest* data); virtual ~DataProducer(); public: - void FillJson(json& jsonObject) const; - void FillJsonStats(json& jsonArray) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; + flatbuffers::Offset FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) const; Type GetType() const { return this->type; @@ -61,9 +61,9 @@ namespace RTC public: void HandleRequest(Channel::ChannelRequest* request) override; - /* Methods inherited from PayloadChannel::PayloadChannelSocket::NotificationHandler. */ + /* Methods inherited from Channel::ChannelSocket::NotificationHandler. */ public: - void HandleNotification(PayloadChannel::PayloadChannelNotification* notification) override; + void HandleNotification(Channel::ChannelNotification* notification) override; public: // Passed by argument. diff --git a/worker/include/RTC/DirectTransport.hpp b/worker/include/RTC/DirectTransport.hpp index 046ac8d0ce..9b687c6086 100644 --- a/worker/include/RTC/DirectTransport.hpp +++ b/worker/include/RTC/DirectTransport.hpp @@ -10,12 +10,17 @@ namespace RTC { public: DirectTransport( - RTC::Shared* shared, const std::string& id, RTC::Transport::Listener* listener, json& data); + RTC::Shared* shared, + const std::string& id, + RTC::Transport::Listener* listener, + const FBS::DirectTransport::DirectTransportOptions* options); ~DirectTransport() override; public: - void FillJson(json& jsonObject) const override; - void FillJsonStats(json& jsonArray) override; + flatbuffers::Offset FillBufferStats( + flatbuffers::FlatBufferBuilder& builder); + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; private: bool IsConnected() const override; @@ -39,9 +44,9 @@ namespace RTC public: void HandleRequest(Channel::ChannelRequest* request) override; - /* Methods inherited from PayloadChannel::PayloadChannelSocket::NotificationHandler. */ + /* Methods inherited from Channel::ChannelSocket::NotificationHandler. */ public: - void HandleNotification(PayloadChannel::PayloadChannelNotification* notification) override; + void HandleNotification(Channel::ChannelNotification* notification) override; }; } // namespace RTC diff --git a/worker/include/RTC/IceCandidate.hpp b/worker/include/RTC/IceCandidate.hpp index 7b684365a0..448dc390b9 100644 --- a/worker/include/RTC/IceCandidate.hpp +++ b/worker/include/RTC/IceCandidate.hpp @@ -2,13 +2,12 @@ #define MS_RTC_ICE_CANDIDATE_HPP #include "common.hpp" +#include "FBS/webRtcTransport_generated.h" #include "RTC/TcpServer.hpp" #include "RTC/UdpSocket.hpp" -#include +#include #include -using json = nlohmann::json; - namespace RTC { class IceCandidate @@ -59,7 +58,8 @@ namespace RTC { } - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; private: // Others. diff --git a/worker/include/RTC/Parameters.hpp b/worker/include/RTC/Parameters.hpp index eb7cd8f188..c0ac24b049 100644 --- a/worker/include/RTC/Parameters.hpp +++ b/worker/include/RTC/Parameters.hpp @@ -2,13 +2,11 @@ #define MS_RTC_PARAMETERS_HPP #include "common.hpp" +#include "FBS/rtpParameters_generated.h" #include -#include #include #include -using json = nlohmann::json; - namespace RTC { class Parameters @@ -62,8 +60,9 @@ namespace RTC }; public: - void FillJson(json& jsonObject) const; - void Set(json& data); + std::vector> FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; + void Set(const flatbuffers::Vector>* data); bool HasBoolean(const std::string& key) const; bool HasInteger(const std::string& key) const; bool HasPositiveInteger(const std::string& key) const; diff --git a/worker/include/RTC/PipeConsumer.hpp b/worker/include/RTC/PipeConsumer.hpp index 3de9030ee4..6d998124a5 100644 --- a/worker/include/RTC/PipeConsumer.hpp +++ b/worker/include/RTC/PipeConsumer.hpp @@ -16,13 +16,16 @@ namespace RTC const std::string& id, const std::string& producerId, RTC::Consumer::Listener* listener, - json& data); + const FBS::Transport::ConsumeRequest* data); ~PipeConsumer() override; public: - void FillJson(json& jsonObject) const override; - void FillJsonStats(json& jsonArray) const override; - void FillJsonScore(json& jsonObject) const override; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; + flatbuffers::Offset FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) override; + flatbuffers::Offset FillBufferScore( + flatbuffers::FlatBufferBuilder& builder) const override; void ProducerRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) override; void ProducerNewRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) override; void ProducerRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override; diff --git a/worker/include/RTC/PipeTransport.hpp b/worker/include/RTC/PipeTransport.hpp index 2f0b9c39eb..f8560f714f 100644 --- a/worker/include/RTC/PipeTransport.hpp +++ b/worker/include/RTC/PipeTransport.hpp @@ -1,6 +1,7 @@ #ifndef MS_RTC_PIPE_TRANSPORT_HPP #define MS_RTC_PIPE_TRANSPORT_HPP +#include "FBS/pipeTransport_generated.h" #include "RTC/Shared.hpp" #include "RTC/SrtpSession.hpp" #include "RTC/Transport.hpp" @@ -25,20 +26,25 @@ namespace RTC public: PipeTransport( - RTC::Shared* shared, const std::string& id, RTC::Transport::Listener* listener, json& data); + RTC::Shared* shared, + const std::string& id, + RTC::Transport::Listener* listener, + const FBS::PipeTransport::PipeTransportOptions* options); ~PipeTransport() override; public: - void FillJson(json& jsonObject) const override; - void FillJsonStats(json& jsonArray) override; + flatbuffers::Offset FillBufferStats( + flatbuffers::FlatBufferBuilder& builder); + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; /* Methods inherited from Channel::ChannelSocket::RequestHandler. */ public: void HandleRequest(Channel::ChannelRequest* request) override; - /* Methods inherited from PayloadChannel::PayloadChannelSocket::NotificationHandler. */ + /* Methods inherited from Channel::ChannelSocket::NotificationHandler. */ public: - void HandleNotification(PayloadChannel::PayloadChannelNotification* notification) override; + void HandleNotification(Channel::ChannelNotification* notification) override; private: bool IsConnected() const override; diff --git a/worker/include/RTC/PlainTransport.hpp b/worker/include/RTC/PlainTransport.hpp index 2df62205d1..f16efdea68 100644 --- a/worker/include/RTC/PlainTransport.hpp +++ b/worker/include/RTC/PlainTransport.hpp @@ -1,6 +1,7 @@ #ifndef MS_RTC_PLAIN_TRANSPORT_HPP #define MS_RTC_PLAIN_TRANSPORT_HPP +#include "FBS/plainTransport_generated.h" #include "RTC/Shared.hpp" #include "RTC/SrtpSession.hpp" #include "RTC/Transport.hpp" @@ -25,20 +26,22 @@ namespace RTC public: PlainTransport( - RTC::Shared* shared, const std::string& id, RTC::Transport::Listener* listener, json& data); + RTC::Shared* shared, + const std::string& id, + RTC::Transport::Listener* listener, + const FBS::PlainTransport::PlainTransportOptions* options); ~PlainTransport() override; public: - void FillJson(json& jsonObject) const override; - void FillJsonStats(json& jsonArray) override; + flatbuffers::Offset FillBufferStats( + flatbuffers::FlatBufferBuilder& builder); + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; /* Methods inherited from Channel::ChannelSocket::RequestHandler. */ public: void HandleRequest(Channel::ChannelRequest* request) override; - - /* Methods inherited from PayloadChannel::PayloadChannelSocket::NotificationHandler. */ - public: - void HandleNotification(PayloadChannel::PayloadChannelNotification* notification) override; + void HandleNotification(Channel::ChannelNotification* notification) override; private: bool IsConnected() const override; @@ -63,6 +66,8 @@ namespace RTC void OnRtpDataReceived(RTC::TransportTuple* tuple, const uint8_t* data, size_t len); void OnRtcpDataReceived(RTC::TransportTuple* tuple, const uint8_t* data, size_t len); void OnSctpDataReceived(RTC::TransportTuple* tuple, const uint8_t* data, size_t len); + void EmitTuple() const; + void EmitRtcpTuple() const; /* Pure virtual methods inherited from RTC::UdpSocket::Listener. */ public: diff --git a/worker/include/RTC/PortManager.hpp b/worker/include/RTC/PortManager.hpp index ca925ef46f..4300548385 100644 --- a/worker/include/RTC/PortManager.hpp +++ b/worker/include/RTC/PortManager.hpp @@ -5,7 +5,6 @@ #include "Settings.hpp" #include #include -#include #include #include @@ -45,7 +44,6 @@ namespace RTC { return Unbind(Transport::TCP, ip, port); } - static void FillJson(json& jsonObject); private: static uv_handle_t* Bind(Transport transport, std::string& ip); diff --git a/worker/include/RTC/Producer.hpp b/worker/include/RTC/Producer.hpp index 9fb4306586..228f97e433 100644 --- a/worker/include/RTC/Producer.hpp +++ b/worker/include/RTC/Producer.hpp @@ -4,7 +4,6 @@ #include "common.hpp" #include "Channel/ChannelRequest.hpp" #include "Channel/ChannelSocket.hpp" -#include "PayloadChannel/PayloadChannelSocket.hpp" #include "RTC/KeyFrameRequestManager.hpp" #include "RTC/RTCP/CompoundPacket.hpp" #include "RTC/RTCP/Packet.hpp" @@ -15,18 +14,15 @@ #include "RTC/RtpPacket.hpp" #include "RTC/RtpStreamRecv.hpp" #include "RTC/Shared.hpp" -#include #include #include -using json = nlohmann::json; - namespace RTC { class Producer : public RTC::RtpStreamRecv::Listener, public RTC::KeyFrameRequestManager::Listener, public Channel::ChannelSocket::RequestHandler, - public PayloadChannel::PayloadChannelSocket::NotificationHandler + public Channel::ChannelSocket::NotificationHandler { public: class Listener @@ -93,12 +89,18 @@ namespace RTC }; public: - Producer(RTC::Shared* shared, const std::string& id, RTC::Producer::Listener* listener, json& data); + Producer( + RTC::Shared* shared, + const std::string& id, + RTC::Producer::Listener* listener, + const FBS::Transport::ProduceRequest* data); virtual ~Producer(); public: - void FillJson(json& jsonObject) const; - void FillJsonStats(json& jsonArray) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; + flatbuffers::Offset FillBufferStats( + flatbuffers::FlatBufferBuilder& builder); RTC::Media::Kind GetKind() const { return this->kind; @@ -137,9 +139,9 @@ namespace RTC public: void HandleRequest(Channel::ChannelRequest* request) override; - /* Methods inherited from PayloadChannel::PayloadChannelSocket::NotificationHandler. */ + /* Methods inherited from Channel::ChannelSocket::NotificationHandler. */ public: - void HandleNotification(PayloadChannel::PayloadChannelNotification* notification) override; + void HandleNotification(Channel::ChannelNotification* notification) override; private: RTC::RtpStreamRecv* GetRtpStream(RTC::RtpPacket* packet); @@ -155,6 +157,7 @@ namespace RTC void EmitTraceEventPliType(uint32_t ssrc) const; void EmitTraceEventFirType(uint32_t ssrc) const; void EmitTraceEventNackType() const; + void EmitTraceEvent(flatbuffers::Offset& notification) const; /* Pure virtual methods inherited from RTC::RtpStreamRecv::Listener. */ public: diff --git a/worker/include/RTC/Router.hpp b/worker/include/RTC/Router.hpp index 6aa38d072c..1715b2a0b0 100644 --- a/worker/include/RTC/Router.hpp +++ b/worker/include/RTC/Router.hpp @@ -2,9 +2,8 @@ #define MS_RTC_ROUTER_HPP #include "common.hpp" +#include "Channel/ChannelNotification.hpp" #include "Channel/ChannelRequest.hpp" -#include "PayloadChannel/PayloadChannelNotification.hpp" -#include "PayloadChannel/PayloadChannelRequest.hpp" #include "RTC/Consumer.hpp" #include "RTC/DataConsumer.hpp" #include "RTC/DataProducer.hpp" @@ -16,12 +15,9 @@ #include "RTC/Transport.hpp" #include "RTC/WebRtcServer.hpp" #include -#include #include #include -using json = nlohmann::json; - namespace RTC { class Router : public RTC::Transport::Listener, @@ -44,17 +40,18 @@ namespace RTC virtual ~Router(); public: - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; /* Methods inherited from Channel::ChannelSocket::RequestHandler. */ public: void HandleRequest(Channel::ChannelRequest* request) override; private: - void SetNewTransportIdFromData(json& data, std::string& transportId) const; - RTC::Transport* GetTransportFromData(json& data) const; - void SetNewRtpObserverIdFromData(json& data, std::string& rtpObserverId) const; - RTC::RtpObserver* GetRtpObserverFromData(json& data) const; + RTC::Transport* GetTransportById(const std::string& transportId) const; + RTC::RtpObserver* GetRtpObserverById(const std::string& rtpObserverId) const; + void CheckNoTransport(const std::string& transportId) const; + void CheckNoRtpObserver(const std::string& rtpObserverId) const; /* Pure virtual methods inherited from RTC::Transport::Listener. */ public: @@ -83,7 +80,7 @@ namespace RTC uint32_t mappedSsrc, uint8_t& worstRemoteFractionLost) override; void OnTransportNewConsumer( - RTC::Transport* transport, RTC::Consumer* consumer, std::string& producerId) override; + RTC::Transport* transport, RTC::Consumer* consumer, const std::string& producerId) override; void OnTransportConsumerClosed(RTC::Transport* transport, RTC::Consumer* consumer) override; void OnTransportConsumerProducerClosed(RTC::Transport* transport, RTC::Consumer* consumer) override; void OnTransportConsumerKeyFrameRequested( diff --git a/worker/include/RTC/RtpDictionaries.hpp b/worker/include/RTC/RtpDictionaries.hpp index 7cf12f2afa..735db78a08 100644 --- a/worker/include/RTC/RtpDictionaries.hpp +++ b/worker/include/RTC/RtpDictionaries.hpp @@ -2,14 +2,12 @@ #define MS_RTC_RTP_DICTIONARIES_HPP #include "common.hpp" +#include "FBS/rtpParameters_generated.h" #include "RTC/Parameters.hpp" #include -#include #include #include -using json = nlohmann::json; - namespace RTC { class Media @@ -155,9 +153,10 @@ namespace RTC { public: RtcpFeedback() = default; - explicit RtcpFeedback(json& data); + explicit RtcpFeedback(const FBS::RtpParameters::RtcpFeedback* data); - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; public: std::string type; @@ -168,9 +167,10 @@ namespace RTC { public: RtpCodecParameters() = default; - explicit RtpCodecParameters(json& data); + explicit RtpCodecParameters(const FBS::RtpParameters::RtpCodecParameters* data); - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; private: void CheckCodec(); @@ -188,9 +188,9 @@ namespace RTC { public: RtpRtxParameters() = default; - explicit RtpRtxParameters(json& data); + explicit RtpRtxParameters(const FBS::RtpParameters::Rtx* data); - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer(flatbuffers::FlatBufferBuilder& builder) const; public: uint32_t ssrc{ 0u }; @@ -200,9 +200,10 @@ namespace RTC { public: RtpEncodingParameters() = default; - explicit RtpEncodingParameters(json& data); + explicit RtpEncodingParameters(const FBS::RtpParameters::RtpEncodingParameters* data); - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; public: uint32_t ssrc{ 0u }; @@ -224,9 +225,11 @@ namespace RTC { public: RtpHeaderExtensionParameters() = default; - explicit RtpHeaderExtensionParameters(json& data); + explicit RtpHeaderExtensionParameters( + const FBS::RtpParameters::RtpHeaderExtensionParameters* const data); - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; public: std::string uri; @@ -240,13 +243,13 @@ namespace RTC { public: RtcpParameters() = default; - explicit RtcpParameters(json& data); + explicit RtcpParameters(const FBS::RtpParameters::RtcpParameters* data); - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; public: std::string cname; - uint32_t ssrc{ 0u }; bool reducedSize{ true }; }; @@ -274,9 +277,10 @@ namespace RTC public: RtpParameters() = default; - explicit RtpParameters(json& data); + explicit RtpParameters(const FBS::RtpParameters::RtpParameters* data); - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; const RTC::RtpCodecParameters* GetCodecForEncoding(RtpEncodingParameters& encoding) const; const RTC::RtpCodecParameters* GetRtxCodecForEncoding(RtpEncodingParameters& encoding) const; diff --git a/worker/include/RTC/RtpListener.hpp b/worker/include/RTC/RtpListener.hpp index b6f6d65d37..0591c4ba4f 100644 --- a/worker/include/RTC/RtpListener.hpp +++ b/worker/include/RTC/RtpListener.hpp @@ -4,18 +4,16 @@ #include "common.hpp" #include "RTC/Producer.hpp" #include "RTC/RtpPacket.hpp" -#include #include #include -using json = nlohmann::json; - namespace RTC { class RtpListener { public: - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; void AddProducer(RTC::Producer* producer); void RemoveProducer(RTC::Producer* producer); RTC::Producer* GetProducer(const RTC::RtpPacket* packet); diff --git a/worker/include/RTC/RtpObserver.hpp b/worker/include/RTC/RtpObserver.hpp index 00c8010456..4c78a5f847 100644 --- a/worker/include/RTC/RtpObserver.hpp +++ b/worker/include/RTC/RtpObserver.hpp @@ -50,9 +50,6 @@ namespace RTC virtual void Paused() = 0; virtual void Resumed() = 0; - private: - std::string GetProducerIdFromData(json& data) const; - public: // Passed by argument. const std::string id; diff --git a/worker/include/RTC/RtpPacket.hpp b/worker/include/RTC/RtpPacket.hpp index a585a3babc..f851bab3d5 100644 --- a/worker/include/RTC/RtpPacket.hpp +++ b/worker/include/RTC/RtpPacket.hpp @@ -7,12 +7,9 @@ #include "RTC/RtcLogger.hpp" #include #include -#include #include #include -using json = nlohmann::json; - namespace RTC { // Max MTU size. @@ -148,8 +145,6 @@ namespace RTC void Dump() const; - void FillJson(json& jsonObject) const; - const uint8_t* GetData() const { return (const uint8_t*)this->header; diff --git a/worker/include/RTC/RtpStream.hpp b/worker/include/RTC/RtpStream.hpp index 9a0ca8daa6..9fd3be1b03 100644 --- a/worker/include/RTC/RtpStream.hpp +++ b/worker/include/RTC/RtpStream.hpp @@ -3,6 +3,7 @@ #include "common.hpp" #include "DepLibUV.hpp" +#include "FBS/rtpStream_generated.h" #include "RTC/RTCP/FeedbackPsFir.hpp" #include "RTC/RTCP/FeedbackPsPli.hpp" #include "RTC/RTCP/FeedbackRtpNack.hpp" @@ -15,12 +16,9 @@ #include "RTC/RtpDictionaries.hpp" #include "RTC/RtpPacket.hpp" #include "RTC/RtxStream.hpp" -#include #include #include -using json = nlohmann::json; - namespace RTC { class RtpStream @@ -38,7 +36,8 @@ namespace RTC public: struct Params { - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; size_t encodingIdx{ 0u }; uint32_t ssrc{ 0u }; @@ -62,8 +61,9 @@ namespace RTC RtpStream(RTC::RtpStream::Listener* listener, RTC::RtpStream::Params& params, uint8_t initialScore); virtual ~RtpStream(); - void FillJson(json& jsonObject) const; - virtual void FillJsonStats(json& jsonObject); + flatbuffers::Offset FillBuffer(flatbuffers::FlatBufferBuilder& builder) const; + virtual flatbuffers::Offset FillBufferStats( + flatbuffers::FlatBufferBuilder& builder); uint32_t GetEncodingIdx() const { return this->params.encodingIdx; diff --git a/worker/include/RTC/RtpStreamRecv.hpp b/worker/include/RTC/RtpStreamRecv.hpp index afe7c0c83c..a4d538ed59 100644 --- a/worker/include/RTC/RtpStreamRecv.hpp +++ b/worker/include/RTC/RtpStreamRecv.hpp @@ -49,7 +49,8 @@ namespace RTC bool useRtpInactivityCheck); ~RtpStreamRecv(); - void FillJsonStats(json& jsonObject) override; + flatbuffers::Offset FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) override; bool ReceivePacket(RTC::RtpPacket* packet); bool ReceiveRtxPacket(RTC::RtpPacket* packet); RTC::RTCP::ReceiverReport* GetRtcpReceiverReport(); diff --git a/worker/include/RTC/RtpStreamSend.hpp b/worker/include/RTC/RtpStreamSend.hpp index 9c59c897dd..f98d399aca 100644 --- a/worker/include/RTC/RtpStreamSend.hpp +++ b/worker/include/RTC/RtpStreamSend.hpp @@ -28,7 +28,8 @@ namespace RTC RTC::RtpStreamSend::Listener* listener, RTC::RtpStream::Params& params, std::string& mid); ~RtpStreamSend() override; - void FillJsonStats(json& jsonObject) override; + flatbuffers::Offset FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) override; void SetRtx(uint8_t payloadType, uint32_t ssrc) override; bool ReceivePacket(RTC::RtpPacket* packet, std::shared_ptr& sharedPacket); void ReceiveNack(RTC::RTCP::FeedbackRtpNackPacket* nackPacket); diff --git a/worker/include/RTC/RtxStream.hpp b/worker/include/RTC/RtxStream.hpp index 216c3ba201..c0d862b063 100644 --- a/worker/include/RTC/RtxStream.hpp +++ b/worker/include/RTC/RtxStream.hpp @@ -3,16 +3,14 @@ #include "common.hpp" #include "DepLibUV.hpp" +#include "FBS/rtxStream_generated.h" #include "RTC/RTCP/Packet.hpp" #include "RTC/RTCP/ReceiverReport.hpp" #include "RTC/RTCP/SenderReport.hpp" #include "RTC/RtpDictionaries.hpp" #include "RTC/RtpPacket.hpp" -#include #include -using json = nlohmann::json; - namespace RTC { class RtxStream @@ -20,7 +18,8 @@ namespace RTC public: struct Params { - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; uint32_t ssrc{ 0 }; uint8_t payloadType{ 0 }; @@ -34,7 +33,7 @@ namespace RTC explicit RtxStream(RTC::RtxStream::Params& params); virtual ~RtxStream(); - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer(flatbuffers::FlatBufferBuilder& builder) const; uint32_t GetSsrc() const { return this->params.ssrc; diff --git a/worker/include/RTC/SctpAssociation.hpp b/worker/include/RTC/SctpAssociation.hpp index 6b6626f04d..0b52a05ebe 100644 --- a/worker/include/RTC/SctpAssociation.hpp +++ b/worker/include/RTC/SctpAssociation.hpp @@ -6,9 +6,6 @@ #include "RTC/DataConsumer.hpp" #include "RTC/DataProducer.hpp" #include -#include - -using json = nlohmann::json; namespace RTC { @@ -81,7 +78,8 @@ namespace RTC ~SctpAssociation(); public: - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; void TransportConnected(); SctpState GetState() const { diff --git a/worker/include/RTC/SctpDictionaries.hpp b/worker/include/RTC/SctpDictionaries.hpp index 9ceebb03a8..162d26b830 100644 --- a/worker/include/RTC/SctpDictionaries.hpp +++ b/worker/include/RTC/SctpDictionaries.hpp @@ -2,10 +2,7 @@ #define MS_RTC_SCTP_DICTIONARIES_HPP #include "common.hpp" -#include -#include - -using json = nlohmann::json; +#include namespace RTC { @@ -13,9 +10,10 @@ namespace RTC { public: SctpStreamParameters() = default; - explicit SctpStreamParameters(json& data); + explicit SctpStreamParameters(const FBS::SctpParameters::SctpStreamParameters* data); - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; public: uint16_t streamId{ 0u }; diff --git a/worker/include/RTC/SctpListener.hpp b/worker/include/RTC/SctpListener.hpp index 4988805e65..504d7d978a 100644 --- a/worker/include/RTC/SctpListener.hpp +++ b/worker/include/RTC/SctpListener.hpp @@ -3,17 +3,15 @@ #include "common.hpp" #include "RTC/DataProducer.hpp" -#include #include -using json = nlohmann::json; - namespace RTC { class SctpListener { public: - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; void AddDataProducer(RTC::DataProducer* dataProducer); void RemoveDataProducer(RTC::DataProducer* dataProducer); RTC::DataProducer* GetDataProducer(uint16_t streamId); diff --git a/worker/include/RTC/Shared.hpp b/worker/include/RTC/Shared.hpp index 90e07f058a..2a71781283 100644 --- a/worker/include/RTC/Shared.hpp +++ b/worker/include/RTC/Shared.hpp @@ -3,7 +3,6 @@ #include "ChannelMessageRegistrator.hpp" #include "Channel/ChannelNotifier.hpp" -#include "PayloadChannel/PayloadChannelNotifier.hpp" namespace RTC { @@ -12,14 +11,12 @@ namespace RTC public: explicit Shared( ChannelMessageRegistrator* channelMessageRegistrator, - Channel::ChannelNotifier* channelNotifier, - PayloadChannel::PayloadChannelNotifier* payloadChannelNotifier); + Channel::ChannelNotifier* channelNotifier); ~Shared(); public: ChannelMessageRegistrator* channelMessageRegistrator{ nullptr }; Channel::ChannelNotifier* channelNotifier{ nullptr }; - PayloadChannel::PayloadChannelNotifier* payloadChannelNotifier{ nullptr }; }; } // namespace RTC diff --git a/worker/include/RTC/SimpleConsumer.hpp b/worker/include/RTC/SimpleConsumer.hpp index 7932d13e2f..c4fa974633 100644 --- a/worker/include/RTC/SimpleConsumer.hpp +++ b/worker/include/RTC/SimpleConsumer.hpp @@ -1,6 +1,7 @@ #ifndef MS_RTC_SIMPLE_CONSUMER_HPP #define MS_RTC_SIMPLE_CONSUMER_HPP +#include "FBS/transport_generated.h" #include "RTC/Consumer.hpp" #include "RTC/RtpStreamSend.hpp" #include "RTC/SeqManager.hpp" @@ -16,13 +17,16 @@ namespace RTC const std::string& id, const std::string& producerId, RTC::Consumer::Listener* listener, - json& data); + const FBS::Transport::ConsumeRequest* data); ~SimpleConsumer() override; public: - void FillJson(json& jsonObject) const override; - void FillJsonStats(json& jsonArray) const override; - void FillJsonScore(json& jsonObject) const override; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; + flatbuffers::Offset FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) override; + flatbuffers::Offset FillBufferScore( + flatbuffers::FlatBufferBuilder& builder) const override; bool IsActive() const override { // clang-format off diff --git a/worker/include/RTC/SimulcastConsumer.hpp b/worker/include/RTC/SimulcastConsumer.hpp index c08dd83af2..f337d418ba 100644 --- a/worker/include/RTC/SimulcastConsumer.hpp +++ b/worker/include/RTC/SimulcastConsumer.hpp @@ -1,6 +1,7 @@ #ifndef MS_RTC_SIMULCAST_CONSUMER_HPP #define MS_RTC_SIMULCAST_CONSUMER_HPP +#include "FBS/consumer_generated.h" #include "RTC/Codecs/PayloadDescriptorHandler.hpp" #include "RTC/Consumer.hpp" #include "RTC/RtpStreamSend.hpp" @@ -17,13 +18,16 @@ namespace RTC const std::string& id, const std::string& producerId, RTC::Consumer::Listener* listener, - json& data); + const FBS::Transport::ConsumeRequest* data); ~SimulcastConsumer() override; public: - void FillJson(json& jsonObject) const override; - void FillJsonStats(json& jsonArray) const override; - void FillJsonScore(json& jsonObject) const override; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; + flatbuffers::Offset FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) override; + flatbuffers::Offset FillBufferScore( + flatbuffers::FlatBufferBuilder& builder) const override; RTC::Consumer::Layers GetPreferredLayers() const override { RTC::Consumer::Layers layers; diff --git a/worker/include/RTC/SvcConsumer.hpp b/worker/include/RTC/SvcConsumer.hpp index 949a86ef65..7a3150428b 100644 --- a/worker/include/RTC/SvcConsumer.hpp +++ b/worker/include/RTC/SvcConsumer.hpp @@ -18,13 +18,16 @@ namespace RTC const std::string& id, const std::string& producerId, RTC::Consumer::Listener* listener, - json& data); + const FBS::Transport::ConsumeRequest* data); ~SvcConsumer() override; public: - void FillJson(json& jsonObject) const override; - void FillJsonStats(json& jsonArray) const override; - void FillJsonScore(json& jsonObject) const override; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; + flatbuffers::Offset FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) override; + flatbuffers::Offset FillBufferScore( + flatbuffers::FlatBufferBuilder& builder) const override; RTC::Consumer::Layers GetPreferredLayers() const override { RTC::Consumer::Layers layers; diff --git a/worker/include/RTC/Transport.hpp b/worker/include/RTC/Transport.hpp index 87e5e81909..0890f2fbde 100644 --- a/worker/include/RTC/Transport.hpp +++ b/worker/include/RTC/Transport.hpp @@ -4,10 +4,10 @@ #include "common.hpp" #include "DepLibUV.hpp" +#include "Channel/ChannelNotification.hpp" #include "Channel/ChannelRequest.hpp" #include "Channel/ChannelSocket.hpp" -#include "PayloadChannel/PayloadChannelNotification.hpp" -#include "PayloadChannel/PayloadChannelRequest.hpp" +#include "FBS/transport_generated.h" #include "RTC/Consumer.hpp" #include "RTC/DataConsumer.hpp" #include "RTC/DataProducer.hpp" @@ -29,11 +29,8 @@ #include "RTC/TransportCongestionControlServer.hpp" #include "handles/Timer.hpp" #include -#include #include -using json = nlohmann::json; - namespace RTC { class Transport : public RTC::Producer::Listener, @@ -44,8 +41,7 @@ namespace RTC public RTC::TransportCongestionControlClient::Listener, public RTC::TransportCongestionControlServer::Listener, public Channel::ChannelSocket::RequestHandler, - public PayloadChannel::PayloadChannelSocket::RequestHandler, - public PayloadChannel::PayloadChannelSocket::NotificationHandler, + public Channel::ChannelSocket::NotificationHandler, #ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR public RTC::SenderBandwidthEstimator::Listener, #endif @@ -87,7 +83,7 @@ namespace RTC uint32_t mappedSsrc, uint8_t& worstRemoteFractionLost) = 0; virtual void OnTransportNewConsumer( - RTC::Transport* transport, RTC::Consumer* consumer, std::string& producerId) = 0; + RTC::Transport* transport, RTC::Consumer* consumer, const std::string& producerId) = 0; virtual void OnTransportConsumerClosed(RTC::Transport* transport, RTC::Consumer* consumer) = 0; virtual void OnTransportConsumerProducerClosed( RTC::Transport* transport, RTC::Consumer* consumer) = 0; @@ -120,27 +116,27 @@ namespace RTC }; public: - Transport(RTC::Shared* shared, const std::string& id, Listener* listener, json& data); + Transport( + RTC::Shared* shared, + const std::string& id, + RTC::Transport::Listener* listener, + const FBS::Transport::Options* options); virtual ~Transport(); public: void CloseProducersAndConsumers(); void ListenServerClosed(); // Subclasses must also invoke the parent Close(). - virtual void FillJson(json& jsonObject) const; - virtual void FillJsonStats(json& jsonArray); + flatbuffers::Offset FillBufferStats(flatbuffers::FlatBufferBuilder& builder); + flatbuffers::Offset FillBuffer(flatbuffers::FlatBufferBuilder& builder) const; /* Methods inherited from Channel::ChannelSocket::RequestHandler. */ public: void HandleRequest(Channel::ChannelRequest* request) override; - /* Methods inherited from PayloadChannel::PayloadChannelSocket::RequestHandler. */ - public: - void HandleRequest(PayloadChannel::PayloadChannelRequest* request) override; - - /* Methods inherited from PayloadChannel::PayloadChannelSocket::NotificationHandler. */ + /* Methods inherited from Channel::ChannelSocket::NotificationHandler. */ public: - void HandleNotification(PayloadChannel::PayloadChannelNotification* notification) override; + void HandleNotification(Channel::ChannelNotification* notification) override; protected: // Must be called from the subclass. @@ -157,16 +153,12 @@ namespace RTC void ReceiveRtpPacket(RTC::RtpPacket* packet); void ReceiveRtcpPacket(RTC::RTCP::Packet* packet); void ReceiveSctpData(const uint8_t* data, size_t len); - void SetNewProducerIdFromData(json& data, std::string& producerId) const; - RTC::Producer* GetProducerFromData(json& data) const; - void SetNewConsumerIdFromData(json& data, std::string& consumerId) const; - RTC::Consumer* GetConsumerFromData(json& data) const; + RTC::Producer* GetProducerById(const std::string& producerId) const; + RTC::Consumer* GetConsumerById(const std::string& consumerId) const; RTC::Consumer* GetConsumerByMediaSsrc(uint32_t ssrc) const; RTC::Consumer* GetConsumerByRtxSsrc(uint32_t ssrc) const; - void SetNewDataProducerIdFromData(json& data, std::string& dataProducerId) const; - RTC::DataProducer* GetDataProducerFromData(json& data) const; - void SetNewDataConsumerIdFromData(json& data, std::string& dataConsumerId) const; - RTC::DataConsumer* GetDataConsumerFromData(json& data) const; + RTC::DataProducer* GetDataProducerById(const std::string& dataProducerId) const; + RTC::DataConsumer* GetDataConsumerById(const std::string& dataConsumerId) const; private: virtual bool IsConnected() const = 0; @@ -189,6 +181,9 @@ namespace RTC void ComputeOutgoingDesiredBitrate(bool forceBitrate = false); void EmitTraceEventProbationType(RTC::RtpPacket* packet) const; void EmitTraceEventBweType(RTC::TransportCongestionControlClient::Bitrates& bitrates) const; + void CheckNoProducer(const std::string& producerId) const; + void CheckNoDataProducer(const std::string& dataProducerId) const; + void CheckNoDataConsumer(const std::string& dataConsumerId) const; /* Pure virtual methods inherited from RTC::Producer::Listener. */ public: @@ -313,7 +308,7 @@ namespace RTC std::shared_ptr senderBwe{ nullptr }; #endif // Others. - bool direct{ false }; // Whether this Transport allows PayloadChannel comm. + bool direct{ false }; // Whether this Transport allows direct communication. bool destroying{ false }; struct RTC::RtpHeaderExtensionIds recvRtpHeaderExtensionIds; RTC::RtpListener rtpListener; diff --git a/worker/include/RTC/TransportTuple.hpp b/worker/include/RTC/TransportTuple.hpp index 535d221a68..3fc01bca78 100644 --- a/worker/include/RTC/TransportTuple.hpp +++ b/worker/include/RTC/TransportTuple.hpp @@ -3,13 +3,12 @@ #include "common.hpp" #include "Utils.hpp" +#include "FBS/transport_generated.h" #include "RTC/TcpConnection.hpp" #include "RTC/UdpSocket.hpp" -#include +#include #include -using json = nlohmann::json; - namespace RTC { class TransportTuple @@ -63,7 +62,7 @@ namespace RTC return this->tcpConnection->IsClosed(); } - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer(flatbuffers::FlatBufferBuilder& builder) const; void Dump() const; diff --git a/worker/include/RTC/WebRtcServer.hpp b/worker/include/RTC/WebRtcServer.hpp index f0197b2d3a..c48dd44830 100644 --- a/worker/include/RTC/WebRtcServer.hpp +++ b/worker/include/RTC/WebRtcServer.hpp @@ -12,7 +12,7 @@ #include "RTC/WebRtcTransport.hpp" #include #include -#include +#include #include #include @@ -24,15 +24,6 @@ namespace RTC public RTC::WebRtcTransport::WebRtcTransportListener, public Channel::ChannelSocket::RequestHandler { - private: - struct ListenInfo - { - RTC::TransportTuple::Protocol protocol; - std::string ip; - std::string announcedIp; - uint16_t port; - }; - private: struct UdpSocketOrTcpServer { @@ -48,11 +39,15 @@ namespace RTC }; public: - WebRtcServer(RTC::Shared* shared, const std::string& id, json& data); + WebRtcServer( + RTC::Shared* shared, + const std::string& id, + const flatbuffers::Vector>* listenInfos); ~WebRtcServer(); public: - void FillJson(json& jsonObject) const; + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; std::vector GetIceCandidates( bool enableUdp, bool enableTcp, bool preferUdp, bool preferTcp); diff --git a/worker/include/RTC/WebRtcTransport.hpp b/worker/include/RTC/WebRtcTransport.hpp index 2eae6d856a..a1d90e3572 100644 --- a/worker/include/RTC/WebRtcTransport.hpp +++ b/worker/include/RTC/WebRtcTransport.hpp @@ -51,19 +51,24 @@ namespace RTC public: WebRtcTransport( - RTC::Shared* shared, const std::string& id, RTC::Transport::Listener* listener, json& data); + RTC::Shared* shared, + const std::string& id, + RTC::Transport::Listener* listener, + const FBS::WebRtcTransport::WebRtcTransportOptions* options); WebRtcTransport( RTC::Shared* shared, const std::string& id, RTC::Transport::Listener* listener, WebRtcTransportListener* webRtcTransportListener, std::vector& iceCandidates, - json& data); + const FBS::WebRtcTransport::WebRtcTransportOptions* options); ~WebRtcTransport() override; public: - void FillJson(json& jsonObject) const override; - void FillJsonStats(json& jsonArray) override; + flatbuffers::Offset FillBufferStats( + flatbuffers::FlatBufferBuilder& builder); + flatbuffers::Offset FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const; void ProcessStunPacketFromWebRtcServer(RTC::TransportTuple* tuple, RTC::StunPacket* packet); void ProcessNonStunPacketFromWebRtcServer( RTC::TransportTuple* tuple, const uint8_t* data, size_t len); @@ -73,9 +78,9 @@ namespace RTC public: void HandleRequest(Channel::ChannelRequest* request) override; - /* Methods inherited from PayloadChannel::PayloadChannelSocket::NotificationHandler. */ + /* Methods inherited from Channel::ChannelSocket::NotificationHandler. */ public: - void HandleNotification(PayloadChannel::PayloadChannelNotification* notification) override; + void HandleNotification(Channel::ChannelNotification* notification) override; private: bool IsConnected() const override; diff --git a/worker/include/Utils.hpp b/worker/include/Utils.hpp index d41ecb6551..8965f9812f 100644 --- a/worker/include/Utils.hpp +++ b/worker/include/Utils.hpp @@ -5,7 +5,6 @@ #include #include #include // std::memcmp(), std::memcpy() -#include #include #include #ifdef _WIN32 @@ -15,8 +14,6 @@ #define __builtin_popcount __popcnt #endif -using json = nlohmann::json; - namespace Utils { class IP @@ -291,8 +288,6 @@ namespace Utils static uint8_t* Base64Decode(const uint8_t* data, size_t len, size_t& outLen); static uint8_t* Base64Decode(const std::string& str, size_t& outLen); - - static std::vector Split(const std::string& str, char separator, size_t limit = 0); }; class Time @@ -355,26 +350,6 @@ namespace Utils return static_cast(((ms << 18) + 500) / 1000) & 0x00FFFFFF; } }; - - class Json - { - public: - static bool IsPositiveInteger(const json& value) - { - if (value.is_number_unsigned()) - { - return true; - } - else if (value.is_number_integer()) - { - return value.get() >= 0; - } - else - { - return false; - } - } - }; } // namespace Utils #endif diff --git a/worker/include/Worker.hpp b/worker/include/Worker.hpp index 48d993bf7a..76579fcfed 100644 --- a/worker/include/Worker.hpp +++ b/worker/include/Worker.hpp @@ -4,57 +4,43 @@ #include "common.hpp" #include "Channel/ChannelRequest.hpp" #include "Channel/ChannelSocket.hpp" -#include "PayloadChannel/PayloadChannelNotification.hpp" -#include "PayloadChannel/PayloadChannelRequest.hpp" -#include "PayloadChannel/PayloadChannelSocket.hpp" +#include "FBS/worker_generated.h" #include "RTC/Router.hpp" #include "RTC/Shared.hpp" #include "RTC/WebRtcServer.hpp" #include "handles/SignalsHandler.hpp" #include -#include +#include #include -using json = nlohmann::json; - class Worker : public Channel::ChannelSocket::Listener, - public PayloadChannel::PayloadChannelSocket::Listener, public SignalsHandler::Listener, public RTC::Router::Listener { public: - explicit Worker(Channel::ChannelSocket* channel, PayloadChannel::PayloadChannelSocket* payloadChannel); + explicit Worker(Channel::ChannelSocket* channel); ~Worker(); private: void Close(); - void FillJson(json& jsonObject) const; - void FillJsonResourceUsage(json& jsonObject) const; - void SetNewWebRtcServerIdFromData(json& data, std::string& webRtcServerId) const; - RTC::WebRtcServer* GetWebRtcServerFromData(json& data) const; - void SetNewRouterIdFromData(json& data, std::string& routerId) const; - RTC::Router* GetRouterFromData(json& data) const; + flatbuffers::Offset FillBuffer(flatbuffers::FlatBufferBuilder& builder) const; + flatbuffers::Offset FillBufferResourceUsage( + flatbuffers::FlatBufferBuilder& builder) const; + void SetNewRouterId(std::string& routerId) const; + RTC::WebRtcServer* GetWebRtcServer(const std::string& webRtcServerId) const; + RTC::Router* GetRouter(const std::string& routerId) const; + void CheckNoWebRtcServer(const std::string& webRtcServerId) const; + void CheckNoRouter(const std::string& webRtcServerId) const; /* Methods inherited from Channel::ChannelSocket::RequestHandler. */ public: void HandleRequest(Channel::ChannelRequest* request) override; + void HandleNotification(Channel::ChannelNotification* notification) override; /* Methods inherited from Channel::ChannelSocket::Listener. */ public: void OnChannelClosed(Channel::ChannelSocket* channel) override; - /* Methods inherited from PayloadChannel::PayloadChannelSocket::RequestHandler. */ -public: - void HandleRequest(PayloadChannel::PayloadChannelRequest* request) override; - - /* Methods inherited from PayloadChannel::PayloadChannelSocket::NotificationHandler. */ -public: - void HandleNotification(PayloadChannel::PayloadChannelNotification* notification) override; - - /* Methods inherited from PayloadChannel::PayloadChannelSocket::Listener. */ -public: - void OnPayloadChannelClosed(PayloadChannel::PayloadChannelSocket* payloadChannel) override; - /* Methods inherited from SignalsHandler::Listener. */ public: void OnSignal(SignalsHandler* signalsHandler, int signum) override; @@ -66,7 +52,6 @@ class Worker : public Channel::ChannelSocket::Listener, private: // Passed by argument. Channel::ChannelSocket* channel{ nullptr }; - PayloadChannel::PayloadChannelSocket* payloadChannel{ nullptr }; // Allocated by this. SignalsHandler* signalsHandler{ nullptr }; RTC::Shared* shared{ nullptr }; diff --git a/worker/include/common.hpp b/worker/include/common.hpp index f019dd411c..5b1ba0dedd 100644 --- a/worker/include/common.hpp +++ b/worker/include/common.hpp @@ -41,28 +41,4 @@ using ChannelWriteCtx = void*; using ChannelWriteFn = void (*)(const uint8_t* /* message */, uint32_t /* messageLen */, ChannelWriteCtx /* ctx */); -using PayloadChannelReadCtx = void*; -using PayloadChannelReadFreeFn = void (*)(uint8_t*, uint32_t, size_t); -// Returns `PayloadChannelReadFree` on successful read that must be used to free -// `message` and `payload`. -using PayloadChannelReadFn = PayloadChannelReadFreeFn (*)( - uint8_t** /* message */, - uint32_t* /* messageLen */, - size_t* /* messageCtx */, - uint8_t** /* payload */, - uint32_t* /* payloadLen */, - size_t* /* payloadCapacity */, - // This is `uv_async_t` handle that can be called later with `uv_async_send()` - // when there is more data to read. - const void* /* handle */, - PayloadChannelReadCtx /* ctx */); - -using PayloadChannelWriteCtx = void*; -using PayloadChannelWriteFn = void (*)( - const uint8_t* /* message */, - uint32_t /* messageLen */, - const uint8_t* /* payload */, - uint32_t /* payloadLen */, - ChannelWriteCtx /* ctx */); - #endif diff --git a/worker/include/lib.hpp b/worker/include/lib.hpp index 36d86d2d74..513e354b7d 100644 --- a/worker/include/lib.hpp +++ b/worker/include/lib.hpp @@ -11,8 +11,4 @@ extern "C" int mediasoup_worker_run( ChannelReadFn channelReadFn, ChannelReadCtx channelReadCtx, ChannelWriteFn channelWriteFn, - ChannelWriteCtx channelWriteCtx, - PayloadChannelReadFn payloadChannelReadFn, - PayloadChannelReadCtx payloadChannelReadCtx, - PayloadChannelWriteFn payloadChannelWriteFn, - PayloadChannelWriteCtx payloadChannelWriteCtx); + ChannelWriteCtx channelWriteCtx); diff --git a/worker/meson.build b/worker/meson.build index 4be31c0c0b..b14f373bdb 100644 --- a/worker/meson.build +++ b/worker/meson.build @@ -68,11 +68,8 @@ common_sources = [ 'src/handles/UnixStreamSocket.cpp', 'src/Channel/ChannelNotifier.cpp', 'src/Channel/ChannelRequest.cpp', + 'src/Channel/ChannelNotification.cpp', 'src/Channel/ChannelSocket.cpp', - 'src/PayloadChannel/PayloadChannelNotification.cpp', - 'src/PayloadChannel/PayloadChannelNotifier.cpp', - 'src/PayloadChannel/PayloadChannelRequest.cpp', - 'src/PayloadChannel/PayloadChannelSocket.cpp', 'src/RTC/ActiveSpeakerObserver.cpp', 'src/RTC/AudioLevelObserver.cpp', 'src/RTC/Consumer.cpp', @@ -175,12 +172,6 @@ openssl_proj = subproject( 'warning_level=0', ], ) -nlohmann_json_proj = subproject( - 'nlohmann_json', - default_options: [ - 'warning_level=0', - ], -) libuv_proj = subproject( 'libuv', default_options: [ @@ -217,16 +208,22 @@ catch2_proj = subproject( 'warning_level=0', ], ) +flatbuffers_proj = subproject( + 'flatbuffers', + default_options: [ + 'warning_level=0', + ], +) libwebrtc_include_directories = include_directories('include') subdir('deps/libwebrtc') dependencies = [ abseil_cpp_proj.get_variable('absl_container_dep'), openssl_proj.get_variable('openssl_dep'), - nlohmann_json_proj.get_variable('nlohmann_json_dep'), libuv_proj.get_variable('libuv_dep'), libsrtp2_proj.get_variable('libsrtp2_dep'), usrsctp_proj.get_variable('usrsctp_dep'), + flatbuffers_proj.get_variable('flatbuffers_dep'), libwebrtc_dep, ] @@ -237,6 +234,7 @@ link_whole = [ libuv_proj.get_variable('libuv'), libsrtp2_proj.get_variable('libsrtp2'), usrsctp_proj.get_variable('usrsctp'), + flatbuffers_proj.get_variable('flatbuffers_lib'), libwebrtc, ] @@ -290,8 +288,6 @@ mediasoup_worker_test = executable( ], sources: common_sources + [ 'test/src/tests.cpp', - 'test/src/PayloadChannel/TestPayloadChannelNotification.cpp', - 'test/src/PayloadChannel/TestPayloadChannelRequest.cpp', 'test/src/RTC/TestKeyFrameRequestManager.cpp', 'test/src/RTC/TestNackGenerator.cpp', 'test/src/RTC/TestRateCalculator.cpp', @@ -330,7 +326,6 @@ mediasoup_worker_test = executable( 'test/src/RTC/RTCP/TestXr.cpp', 'test/src/Utils/TestBits.cpp', 'test/src/Utils/TestIP.cpp', - 'test/src/Utils/TestJson.cpp', 'test/src/Utils/TestString.cpp', 'test/src/Utils/TestTime.cpp', ], diff --git a/worker/src/Channel/ChannelNotification.cpp b/worker/src/Channel/ChannelNotification.cpp new file mode 100644 index 0000000000..fd2b1809de --- /dev/null +++ b/worker/src/Channel/ChannelNotification.cpp @@ -0,0 +1,41 @@ +#define MS_CLASS "Channel::ChannelNotification" +// #define MS_LOG_DEV_LEVEL 3 + +#include "Channel/ChannelNotification.hpp" +#include "Logger.hpp" +#include "MediaSoupErrors.hpp" + +namespace Channel +{ + /* Class variables. */ + + // clang-format off + absl::flat_hash_map ChannelNotification::event2String = + { + { FBS::Notification::Event::TRANSPORT_SEND_RTCP, "transport.sendRtcp" }, + { FBS::Notification::Event::PRODUCER_SEND, "producer.send" }, + { FBS::Notification::Event::DATA_PRODUCER_SEND, "dataProducer.send" }, + }; + // clang-format on + + /* Instance methods. */ + + ChannelNotification::ChannelNotification(const FBS::Notification::Notification* notification) + { + MS_TRACE(); + + this->data = notification; + this->event = notification->event(); + + auto eventCStrIt = ChannelNotification::event2String.find(this->event); + + if (eventCStrIt == ChannelNotification::event2String.end()) + MS_THROW_ERROR("unknown event '%" PRIu8 "'", this->event); + + this->eventCStr = eventCStrIt->second; + + // Handler ID is optional. + if (flatbuffers::IsFieldPresent(this->data, FBS::Notification::Notification::VT_HANDLERID)) + this->handlerId = this->data->handlerId()->str(); + } +} // namespace Channel diff --git a/worker/src/Channel/ChannelNotifier.cpp b/worker/src/Channel/ChannelNotifier.cpp index 8ef6b23b2a..78a354940b 100644 --- a/worker/src/Channel/ChannelNotifier.cpp +++ b/worker/src/Channel/ChannelNotifier.cpp @@ -10,57 +10,4 @@ namespace Channel { MS_TRACE(); } - - void ChannelNotifier::Emit(uint64_t targetId, const char* event) - { - MS_TRACE(); - - json jsonNotification = json::object(); - - jsonNotification["targetId"] = targetId; - jsonNotification["event"] = event; - - this->channel->Send(jsonNotification); - } - - void ChannelNotifier::Emit(const std::string& targetId, const char* event) - { - MS_TRACE(); - - json jsonNotification = json::object(); - - jsonNotification["targetId"] = targetId; - jsonNotification["event"] = event; - - this->channel->Send(jsonNotification); - } - - void ChannelNotifier::Emit(const std::string& targetId, const char* event, json& data) - { - MS_TRACE(); - - json jsonNotification = json::object(); - - jsonNotification["targetId"] = targetId; - jsonNotification["event"] = event; - jsonNotification["data"] = data; - - this->channel->Send(jsonNotification); - } - - void ChannelNotifier::Emit(const std::string& targetId, const char* event, const std::string& data) - { - MS_TRACE(); - - std::string notification("{\"targetId\":\""); - - notification.append(targetId); - notification.append("\",\"event\":\""); - notification.append(event); - notification.append("\",\"data\":"); - notification.append(data); - notification.append("}"); - - this->channel->Send(notification); - } } // namespace Channel diff --git a/worker/src/Channel/ChannelRequest.cpp b/worker/src/Channel/ChannelRequest.cpp index d107b39329..6b19ffffba 100644 --- a/worker/src/Channel/ChannelRequest.cpp +++ b/worker/src/Channel/ChannelRequest.cpp @@ -4,140 +4,107 @@ #include "Channel/ChannelRequest.hpp" #include "Logger.hpp" #include "MediaSoupErrors.hpp" -#include "Utils.hpp" namespace Channel { /* Class variables. */ // clang-format off - absl::flat_hash_map ChannelRequest::string2MethodId = + absl::flat_hash_map ChannelRequest::method2String = { - { "worker.close", ChannelRequest::MethodId::WORKER_CLOSE }, - { "worker.dump", ChannelRequest::MethodId::WORKER_DUMP }, - { "worker.getResourceUsage", ChannelRequest::MethodId::WORKER_GET_RESOURCE_USAGE }, - { "worker.updateSettings", ChannelRequest::MethodId::WORKER_UPDATE_SETTINGS }, - { "worker.createWebRtcServer", ChannelRequest::MethodId::WORKER_CREATE_WEBRTC_SERVER }, - { "worker.createRouter", ChannelRequest::MethodId::WORKER_CREATE_ROUTER }, - { "worker.closeWebRtcServer", ChannelRequest::MethodId::WORKER_WEBRTC_SERVER_CLOSE }, - { "webRtcServer.dump", ChannelRequest::MethodId::WEBRTC_SERVER_DUMP }, - { "worker.closeRouter", ChannelRequest::MethodId::WORKER_CLOSE_ROUTER }, - { "router.dump", ChannelRequest::MethodId::ROUTER_DUMP }, - { "router.createWebRtcTransport", ChannelRequest::MethodId::ROUTER_CREATE_WEBRTC_TRANSPORT }, - { "router.createWebRtcTransportWithServer", ChannelRequest::MethodId::ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER }, - { "router.createPlainTransport", ChannelRequest::MethodId::ROUTER_CREATE_PLAIN_TRANSPORT }, - { "router.createPipeTransport", ChannelRequest::MethodId::ROUTER_CREATE_PIPE_TRANSPORT }, - { "router.createDirectTransport", ChannelRequest::MethodId::ROUTER_CREATE_DIRECT_TRANSPORT }, - { "router.closeTransport", ChannelRequest::MethodId::ROUTER_CLOSE_TRANSPORT }, - { "router.createActiveSpeakerObserver", ChannelRequest::MethodId::ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER }, - { "router.createAudioLevelObserver", ChannelRequest::MethodId::ROUTER_CREATE_AUDIO_LEVEL_OBSERVER }, - { "router.closeRtpObserver", ChannelRequest::MethodId::ROUTER_CLOSE_RTP_OBSERVER }, - { "transport.dump", ChannelRequest::MethodId::TRANSPORT_DUMP }, - { "transport.getStats", ChannelRequest::MethodId::TRANSPORT_GET_STATS }, - { "transport.connect", ChannelRequest::MethodId::TRANSPORT_CONNECT }, - { "transport.setMaxIncomingBitrate", ChannelRequest::MethodId::TRANSPORT_SET_MAX_INCOMING_BITRATE }, - { "transport.setMaxOutgoingBitrate", ChannelRequest::MethodId::TRANSPORT_SET_MAX_OUTGOING_BITRATE }, - { "transport.setMinOutgoingBitrate", ChannelRequest::MethodId::TRANSPORT_SET_MIN_OUTGOING_BITRATE }, - { "transport.restartIce", ChannelRequest::MethodId::TRANSPORT_RESTART_ICE }, - { "transport.produce", ChannelRequest::MethodId::TRANSPORT_PRODUCE }, - { "transport.consume", ChannelRequest::MethodId::TRANSPORT_CONSUME }, - { "transport.produceData", ChannelRequest::MethodId::TRANSPORT_PRODUCE_DATA }, - { "transport.consumeData", ChannelRequest::MethodId::TRANSPORT_CONSUME_DATA }, - { "transport.enableTraceEvent", ChannelRequest::MethodId::TRANSPORT_ENABLE_TRACE_EVENT }, - { "transport.closeProducer", ChannelRequest::MethodId::TRANSPORT_CLOSE_PRODUCER }, - { "transport.closeConsumer", ChannelRequest::MethodId::TRANSPORT_CLOSE_CONSUMER }, - { "transport.closeDataProducer", ChannelRequest::MethodId::TRANSPORT_CLOSE_DATA_PRODUCER }, - { "transport.closeDataConsumer", ChannelRequest::MethodId::TRANSPORT_CLOSE_DATA_CONSUMER }, - { "producer.dump", ChannelRequest::MethodId::PRODUCER_DUMP }, - { "producer.getStats", ChannelRequest::MethodId::PRODUCER_GET_STATS }, - { "producer.pause", ChannelRequest::MethodId::PRODUCER_PAUSE }, - { "producer.resume" , ChannelRequest::MethodId::PRODUCER_RESUME }, - { "producer.enableTraceEvent", ChannelRequest::MethodId::PRODUCER_ENABLE_TRACE_EVENT }, - { "consumer.dump", ChannelRequest::MethodId::CONSUMER_DUMP }, - { "consumer.getStats", ChannelRequest::MethodId::CONSUMER_GET_STATS }, - { "consumer.pause", ChannelRequest::MethodId::CONSUMER_PAUSE }, - { "consumer.resume", ChannelRequest::MethodId::CONSUMER_RESUME }, - { "consumer.setPreferredLayers", ChannelRequest::MethodId::CONSUMER_SET_PREFERRED_LAYERS }, - { "consumer.setPriority", ChannelRequest::MethodId::CONSUMER_SET_PRIORITY }, - { "consumer.requestKeyFrame", ChannelRequest::MethodId::CONSUMER_REQUEST_KEY_FRAME }, - { "consumer.enableTraceEvent", ChannelRequest::MethodId::CONSUMER_ENABLE_TRACE_EVENT }, - { "dataProducer.dump", ChannelRequest::MethodId::DATA_PRODUCER_DUMP }, - { "dataProducer.getStats", ChannelRequest::MethodId::DATA_PRODUCER_GET_STATS }, - { "dataConsumer.dump", ChannelRequest::MethodId::DATA_CONSUMER_DUMP }, - { "dataConsumer.getStats", ChannelRequest::MethodId::DATA_CONSUMER_GET_STATS }, - { "dataConsumer.getBufferedAmount", ChannelRequest::MethodId::DATA_CONSUMER_GET_BUFFERED_AMOUNT }, - { "dataConsumer.setBufferedAmountLowThreshold", ChannelRequest::MethodId::DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD }, - { "rtpObserver.pause", ChannelRequest::MethodId::RTP_OBSERVER_PAUSE }, - { "rtpObserver.resume", ChannelRequest::MethodId::RTP_OBSERVER_RESUME }, - { "rtpObserver.addProducer", ChannelRequest::MethodId::RTP_OBSERVER_ADD_PRODUCER }, - { "rtpObserver.removeProducer", ChannelRequest::MethodId::RTP_OBSERVER_REMOVE_PRODUCER } + { FBS::Request::Method::WORKER_CLOSE, "worker.close" }, + { FBS::Request::Method::WORKER_DUMP, "worker.dump" }, + { FBS::Request::Method::WORKER_GET_RESOURCE_USAGE, "worker.getResourceUsage" }, + { FBS::Request::Method::WORKER_UPDATE_SETTINGS, "worker.updateSettings" }, + { FBS::Request::Method::WORKER_CREATE_WEBRTC_SERVER, "worker.createWebRtcServer" }, + { FBS::Request::Method::WORKER_CREATE_ROUTER, "worker.createRouter" }, + { FBS::Request::Method::WORKER_WEBRTC_SERVER_CLOSE, "worker.closeWebRtcServer" }, + { FBS::Request::Method::WORKER_CLOSE_ROUTER, "worker.closeRouter" }, + { FBS::Request::Method::WEBRTC_SERVER_DUMP, "webRtcServer.dump" }, + { FBS::Request::Method::ROUTER_DUMP, "router.dump" }, + { FBS::Request::Method::ROUTER_CREATE_WEBRTC_TRANSPORT, "router.createWebRtcTransport" }, + { FBS::Request::Method::ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER, "router.createWebRtcTransportWithServer" }, + { FBS::Request::Method::ROUTER_CREATE_PLAIN_TRANSPORT, "router.createPlainTransport" }, + { FBS::Request::Method::ROUTER_CREATE_PIPE_TRANSPORT, "router.createPipeTransport" }, + { FBS::Request::Method::ROUTER_CREATE_DIRECT_TRANSPORT, "router.createDirectTransport" }, + { FBS::Request::Method::ROUTER_CLOSE_TRANSPORT, "router.closeTransport" }, + { FBS::Request::Method::ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER, "router.createActiveSpeakerObserver" }, + { FBS::Request::Method::ROUTER_CREATE_AUDIO_LEVEL_OBSERVER, "router.createAudioLevelObserver" }, + { FBS::Request::Method::ROUTER_CLOSE_RTP_OBSERVER, "router.closeRtpObserver" }, + { FBS::Request::Method::TRANSPORT_DUMP, "transport.dump" }, + { FBS::Request::Method::TRANSPORT_GET_STATS, "transport.getStats" }, + { FBS::Request::Method::TRANSPORT_CONNECT, "transport.connect" }, + { FBS::Request::Method::TRANSPORT_SET_MAX_INCOMING_BITRATE, "transport.setMaxIncomingBitrate" }, + { FBS::Request::Method::TRANSPORT_SET_MAX_OUTGOING_BITRATE, "transport.setMaxOutgoingBitrate" }, + { FBS::Request::Method::TRANSPORT_SET_MIN_OUTGOING_BITRATE, "transport.setMinOutgoingBitrate" }, + { FBS::Request::Method::TRANSPORT_RESTART_ICE, "transport.restartIce" }, + { FBS::Request::Method::TRANSPORT_PRODUCE, "transport.produce" }, + { FBS::Request::Method::TRANSPORT_PRODUCE_DATA, "transport.produceData" }, + { FBS::Request::Method::TRANSPORT_CONSUME, "transport.consume" }, + { FBS::Request::Method::TRANSPORT_CONSUME_DATA, "transport.consumeData" }, + { FBS::Request::Method::TRANSPORT_ENABLE_TRACE_EVENT, "transport.enableTraceEvent" }, + { FBS::Request::Method::TRANSPORT_CLOSE_PRODUCER, "transport.closeProducer" }, + { FBS::Request::Method::TRANSPORT_CLOSE_CONSUMER, "transport.closeConsumer" }, + { FBS::Request::Method::TRANSPORT_CLOSE_DATA_PRODUCER, "transport.closeDataProducer" }, + { FBS::Request::Method::TRANSPORT_CLOSE_DATA_CONSUMER, "transport.closeDataConsumer" }, + { FBS::Request::Method::PLAIN_TRANSPORT_CONNECT, "plainTransport.connect" }, + { FBS::Request::Method::PIPE_TRANSPORT_CONNECT, "pipeTransport.connect" }, + { FBS::Request::Method::WEBRTC_TRANSPORT_CONNECT, "webRtcTransport.connect" }, + { FBS::Request::Method::PRODUCER_DUMP, "producer.dump" }, + { FBS::Request::Method::PRODUCER_GET_STATS, "producer.getStats" }, + { FBS::Request::Method::PRODUCER_PAUSE, "producer.pause" }, + { FBS::Request::Method::PRODUCER_RESUME, "producer.resume" }, + { FBS::Request::Method::PRODUCER_ENABLE_TRACE_EVENT, "producer.enableTraceEvent" }, + { FBS::Request::Method::CONSUMER_DUMP, "consumer.dump" }, + { FBS::Request::Method::CONSUMER_GET_STATS, "consumer.getStats" }, + { FBS::Request::Method::CONSUMER_PAUSE, "consumer.pause" }, + { FBS::Request::Method::CONSUMER_RESUME, "consumer.resume" }, + { FBS::Request::Method::CONSUMER_SET_PREFERRED_LAYERS, "consumer.setPreferredLayers" }, + { FBS::Request::Method::CONSUMER_SET_PRIORITY, "consumer.setPriority" }, + { FBS::Request::Method::CONSUMER_REQUEST_KEY_FRAME, "consumer.requestKeyFrame" }, + { FBS::Request::Method::CONSUMER_ENABLE_TRACE_EVENT, "consumer.enableTraceEvent" }, + { FBS::Request::Method::DATA_PRODUCER_DUMP, "dataProducer.dump" }, + { FBS::Request::Method::DATA_PRODUCER_GET_STATS, "dataProducer.getStats" }, + { FBS::Request::Method::DATA_CONSUMER_DUMP, "dataConsumer.dump" }, + { FBS::Request::Method::DATA_CONSUMER_GET_STATS, "dataConsumer.getStats" }, + { FBS::Request::Method::DATA_CONSUMER_GET_BUFFERED_AMOUNT, "dataConsumer.getBufferedAmount" }, + { FBS::Request::Method::DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, "dataConsumer.setBufferedAmountLowThreshold" }, + { FBS::Request::Method::DATA_CONSUMER_SEND, "dataConsumer.send" }, + { FBS::Request::Method::RTP_OBSERVER_PAUSE, "rtpObserver.pause" }, + { FBS::Request::Method::RTP_OBSERVER_RESUME, "rtpObserver.resume" }, + { FBS::Request::Method::RTP_OBSERVER_ADD_PRODUCER, "rtpObserver.addProducer" }, + { FBS::Request::Method::RTP_OBSERVER_REMOVE_PRODUCER, "rtpObserver.removeProducer" }, }; // clang-format on /* Instance methods. */ /** - * msg contains "id:method:handlerId:data" where: - * - id: The ID of the request. - * - handlerId: The ID of the target entity - * - data: JSON object. + * msg contains the request flatbuffer. */ - ChannelRequest::ChannelRequest(Channel::ChannelSocket* channel, const char* msg, size_t msgLen) + ChannelRequest::ChannelRequest(Channel::ChannelSocket* channel, const FBS::Request::Request* request) : channel(channel) { MS_TRACE(); - auto info = Utils::String::Split(std::string(msg, msgLen), ':', 3); + this->data = request; + this->id = request->id(); + this->method = request->method(); - if (info.size() < 2) - MS_THROW_ERROR("too few arguments"); + auto methodCStrIt = ChannelRequest::method2String.find(this->method); - this->id = std::stoul(info[0]); - this->method = info[1]; - - auto methodIdIt = ChannelRequest::string2MethodId.find(this->method); - - if (methodIdIt == ChannelRequest::string2MethodId.end()) + if (methodCStrIt == ChannelRequest::method2String.end()) { Error("unknown method"); - MS_THROW_ERROR("unknown method '%s'", this->method.c_str()); - } - - this->methodId = methodIdIt->second; - - if (info.size() > 2) - { - auto& handlerId = info[2]; - - if (handlerId != "undefined") - this->handlerId = handlerId; + MS_THROW_ERROR("unknown method '%" PRIu8 "'", this->method); } - if (info.size() > 3) - { - auto& data = info[3]; - - if (data != "undefined") - { - try - { - this->data = json::parse(data); - - if (!this->data.is_object()) - this->data = json::object(); - } - catch (const json::parse_error& error) - { - MS_THROW_TYPE_ERROR("JSON parsing error: %s", error.what()); - } - } - } - } + this->methodCStr = methodCStrIt->second; - ChannelRequest::~ChannelRequest() - { - MS_TRACE(); + // Handler ID is optional. + if (flatbuffers::IsFieldPresent(this->data, FBS::Request::Request::VT_HANDLERID)) + this->handlerId = this->data->handlerId()->str(); } void ChannelRequest::Accept() @@ -148,31 +115,11 @@ namespace Channel this->replied = true; - std::string response("{\"id\":"); + auto& builder = this->bufferBuilder; + auto response = + FBS::Response::CreateResponse(builder, this->id, true, FBS::Response::Body::NONE, 0); - response.append(std::to_string(this->id)); - response.append(",\"accepted\":true}"); - - this->channel->Send(response); - } - - void ChannelRequest::Accept(json& data) - { - MS_TRACE(); - - MS_ASSERT(!this->replied, "request already replied"); - - this->replied = true; - - json jsonResponse = json::object(); - - jsonResponse["id"] = this->id; - jsonResponse["accepted"] = true; - - if (data.is_structured()) - jsonResponse["data"] = data; - - this->channel->Send(jsonResponse); + this->SendResponse(response); } void ChannelRequest::Error(const char* reason) @@ -183,15 +130,11 @@ namespace Channel this->replied = true; - json jsonResponse = json::object(); - - jsonResponse["id"] = this->id; - jsonResponse["error"] = "Error"; + auto& builder = this->bufferBuilder; + auto response = FBS::Response::CreateResponseDirect( + builder, this->id, false /*accepted*/, FBS::Response::Body::NONE, 0, "Error" /*Error*/, reason); - if (reason != nullptr) - jsonResponse["reason"] = reason; - - this->channel->Send(jsonResponse); + this->SendResponse(response); } void ChannelRequest::TypeError(const char* reason) @@ -202,14 +145,29 @@ namespace Channel this->replied = true; - json jsonResponse = json::object(); + auto& builder = this->bufferBuilder; + auto response = FBS::Response::CreateResponseDirect( + builder, this->id, false /*accepted*/, FBS::Response::Body::NONE, 0, "TypeError" /*Error*/, reason); - jsonResponse["id"] = this->id; - jsonResponse["error"] = "TypeError"; + this->SendResponse(response); + } - if (reason != nullptr) - jsonResponse["reason"] = reason; + void ChannelRequest::Send(uint8_t* buffer, size_t size) + { + this->channel->Send(buffer, size); + } - this->channel->Send(jsonResponse); + void ChannelRequest::SendResponse(const flatbuffers::Offset& response) + { + auto& builder = this->bufferBuilder; + auto message = FBS::Message::CreateMessage( + builder, + FBS::Message::Type::RESPONSE, + FBS::Message::Body::FBS_Response_Response, + response.Union()); + + builder.FinishSizePrefixed(message); + this->Send(builder.GetBufferPointer(), builder.GetSize()); + builder.Reset(); } } // namespace Channel diff --git a/worker/src/Channel/ChannelSocket.cpp b/worker/src/Channel/ChannelSocket.cpp index 22bc0a4b69..08261a1e5b 100644 --- a/worker/src/Channel/ChannelSocket.cpp +++ b/worker/src/Channel/ChannelSocket.cpp @@ -5,7 +5,6 @@ #include "DepLibUV.hpp" #include "Logger.hpp" #include "MediaSoupErrors.hpp" -#include // std::ceil() #include // std::memcpy(), std::memmove() namespace Channel @@ -33,8 +32,7 @@ namespace Channel ChannelSocket::ChannelSocket(int consumerFd, int producerFd) : consumerSocket(new ConsumerSocket(consumerFd, MessageMaxLen, this)), - producerSocket(new ProducerSocket(producerFd, MessageMaxLen)), - writeBuffer(static_cast(std::malloc(MessageMaxLen))) + producerSocket(new ProducerSocket(producerFd, MessageMaxLen)) { MS_TRACE_STD(); } @@ -80,8 +78,6 @@ namespace Channel { MS_TRACE_STD(); - std::free(this->writeBuffer); - if (!this->closed) Close(); @@ -121,45 +117,24 @@ namespace Channel this->listener = listener; } - void ChannelSocket::Send(json& jsonMessage) + void ChannelSocket::Send(const uint8_t* message, uint32_t messageLen) { MS_TRACE_STD(); if (this->closed) return; - std::string message = jsonMessage.dump(); - - if (message.length() > PayloadMaxLen) - { - MS_ERROR_STD("message too big"); - - return; - } - - SendImpl( - reinterpret_cast(message.c_str()), static_cast(message.length())); - } - - void ChannelSocket::Send(const std::string& message) - { - MS_TRACE_STD(); - - if (this->closed) - return; - - if (message.length() > PayloadMaxLen) + if (messageLen > PayloadMaxLen) { MS_ERROR_STD("message too big"); return; } - SendImpl( - reinterpret_cast(message.c_str()), static_cast(message.length())); + SendImpl(reinterpret_cast(message), messageLen); } - void ChannelSocket::SendLog(const char* message, uint32_t messageLen) + void ChannelSocket::SendLog(const char* msg, uint32_t messageLen) { MS_TRACE_STD(); @@ -173,7 +148,13 @@ namespace Channel return; } - SendImpl(reinterpret_cast(message), messageLen); + auto log = FBS::Log::CreateLogDirect(this->bufferBuilder, msg); + auto message = FBS::Message::CreateMessage( + this->bufferBuilder, FBS::Message::Type::LOG, FBS::Message::Body::FBS_Log_Log, log.Union()); + + this->bufferBuilder.FinishSizePrefixed(message); + this->Send(this->bufferBuilder.GetBufferPointer(), this->bufferBuilder.GetSize()); + this->bufferBuilder.Reset(); } bool ChannelSocket::CallbackRead() @@ -183,28 +164,34 @@ namespace Channel if (this->closed) return false; - uint8_t* message{ nullptr }; - uint32_t messageLen; - size_t messageCtx; + uint8_t* msg{ nullptr }; + uint32_t msgLen; + size_t msgCtx; // Try to read next message using `channelReadFn`, message, its length and context will be // stored in provided arguments. - auto free = this->channelReadFn( - &message, &messageLen, &messageCtx, this->uvReadHandle, this->channelReadCtx); + auto free = this->channelReadFn(&msg, &msgLen, &msgCtx, this->uvReadHandle, this->channelReadCtx); // Non-null free function pointer means message was successfully read above and will need to be // freed later. if (free) { - try - { - char* charMessage{ reinterpret_cast(message) }; + const auto* message = FBS::Message::GetMessage(msg); - auto* request = new Channel::ChannelRequest(this, charMessage, messageLen); + // TMP: For debugging. + auto s = flatbuffers::FlatBufferToString( + reinterpret_cast(msg), FBS::Message::MessageTypeTable()); + MS_ERROR("%s", s.c_str()); + + if (message->type() == FBS::Message::Type::REQUEST) + { + ChannelRequest* request; - // Notify the listener. try { + request = new ChannelRequest(this, message->data_as()); + + // Notify the listener. this->listener->HandleRequest(request); } catch (const MediaSoupTypeError& error) @@ -216,20 +203,33 @@ namespace Channel request->Error(error.what()); } - // Delete the Request. delete request; } - catch (const json::parse_error& error) + else if (message->type() == FBS::Message::Type::NOTIFICATION) { - MS_ERROR_STD("message parsing error: %s", error.what()); + ChannelNotification* notification; + + try + { + notification = new ChannelNotification(message->data_as()); + + // Notify the listener. + this->listener->HandleNotification(notification); + } + catch (const MediaSoupError& error) + { + MS_ERROR("notification failed: %s", error.what()); + } + + delete notification; } - catch (const MediaSoupError& error) + else { - MS_ERROR_STD("discarding wrong Channel request: %s", error.what()); + MS_ERROR("discarding wrong Channel data"); } // Message needs to be freed using stored function pointer. - free(message, messageLen, messageCtx); + free(msg, msgLen, msgCtx); } // Return `true` if something was processed. @@ -247,30 +247,30 @@ namespace Channel } else { - std::memcpy(this->writeBuffer, &payloadLen, sizeof(uint32_t)); - - if (payloadLen != 0) - { - std::memcpy(this->writeBuffer + sizeof(uint32_t), payload, payloadLen); - } - - size_t len = sizeof(uint32_t) + payloadLen; - - this->producerSocket->Write(this->writeBuffer, len); + this->producerSocket->Write(payload, payloadLen); } } void ChannelSocket::OnConsumerSocketMessage(ConsumerSocket* /*consumerSocket*/, char* msg, size_t msgLen) { - MS_TRACE_STD(); + MS_TRACE(); + + auto* message = FBS::Message::GetMessage(msg); - try + // TMP: For debugging. + // auto s = flatbuffers::FlatBufferToString( + // reinterpret_cast(msg), FBS::Message::MessageTypeTable()); + // MS_ERROR("%s", s.c_str()); + + if (message->type() == FBS::Message::Type::REQUEST) { - auto* request = new Channel::ChannelRequest(this, msg, msgLen); + ChannelRequest* request; - // Notify the listener. try { + request = new ChannelRequest(this, message->data_as()); + + // Notify the listener. this->listener->HandleRequest(request); } catch (const MediaSoupTypeError& error) @@ -282,16 +282,29 @@ namespace Channel request->Error(error.what()); } - // Delete the Request. delete request; } - catch (const json::parse_error& error) + else if (message->type() == FBS::Message::Type::NOTIFICATION) { - MS_ERROR_STD("JSON parsing error: %s", error.what()); + ChannelNotification* notification; + + try + { + notification = new ChannelNotification(message->data_as()); + + // Notify the listener. + this->listener->HandleNotification(notification); + } + catch (const MediaSoupError& error) + { + MS_ERROR("notification failed: %s", error.what()); + } + + delete notification; } - catch (const MediaSoupError& error) + else { - MS_ERROR_STD("discarding wrong Channel request: %s", error.what()); + MS_ERROR("discarding wrong Channel data"); } } diff --git a/worker/src/ChannelMessageRegistrator.cpp b/worker/src/ChannelMessageRegistrator.cpp index 4f5c9bbe50..647994d35c 100644 --- a/worker/src/ChannelMessageRegistrator.cpp +++ b/worker/src/ChannelMessageRegistrator.cpp @@ -15,54 +15,38 @@ ChannelMessageRegistrator::~ChannelMessageRegistrator() MS_TRACE(); this->mapChannelRequestHandlers.clear(); - this->mapPayloadChannelRequestHandlers.clear(); - this->mapPayloadChannelNotificationHandlers.clear(); + this->mapChannelNotificationHandlers.clear(); } -void ChannelMessageRegistrator::FillJson(json& jsonObject) +flatbuffers::Offset ChannelMessageRegistrator::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) { - MS_TRACE(); - - // Add channelRequestHandlers. - jsonObject["channelRequestHandlers"] = json::array(); - auto jsonChannelRequestHandlersIt = jsonObject.find("channelRequestHandlers"); - + // Add channelRequestHandlerIds. + std::vector> channelRequestHandlerIds; for (const auto& kv : this->mapChannelRequestHandlers) { const auto& handlerId = kv.first; - jsonChannelRequestHandlersIt->emplace_back(handlerId); + channelRequestHandlerIds.push_back(builder.CreateString(handlerId)); } - // Add payloadChannelRequestHandlers. - jsonObject["payloadChannelRequestHandlers"] = json::array(); - auto jsonPayloadChannelRequestHandlersIt = jsonObject.find("payloadChannelRequestHandlers"); - - for (const auto& kv : this->mapPayloadChannelRequestHandlers) + // Add channelNotificationHandlerIds. + std::vector> channelNotificationHandlerIds; + for (const auto& kv : this->mapChannelNotificationHandlers) { const auto& handlerId = kv.first; - jsonPayloadChannelRequestHandlersIt->emplace_back(handlerId); + channelNotificationHandlerIds.push_back(builder.CreateString(handlerId)); } - // Add payloadChannelNotificationHandlers. - jsonObject["payloadChannelNotificationHandlers"] = json::array(); - auto jsonPayloadChannelNotificationHandlersIt = - jsonObject.find("payloadChannelNotificationHandlers"); - - for (const auto& kv : this->mapPayloadChannelNotificationHandlers) - { - const auto& handlerId = kv.first; - - jsonPayloadChannelNotificationHandlersIt->emplace_back(handlerId); - } + return FBS::Worker::CreateChannelMessageHandlersDirect( + builder, &channelRequestHandlerIds, &channelNotificationHandlerIds); } void ChannelMessageRegistrator::RegisterHandler( const std::string& id, Channel::ChannelSocket::RequestHandler* channelRequestHandler, - PayloadChannel::PayloadChannelSocket::RequestHandler* payloadChannelRequestHandler, - PayloadChannel::PayloadChannelSocket::NotificationHandler* payloadChannelNotificationHandler) + Channel::ChannelSocket::NotificationHandler* channelNotificationHandler) { MS_TRACE(); @@ -76,41 +60,19 @@ void ChannelMessageRegistrator::RegisterHandler( this->mapChannelRequestHandlers[id] = channelRequestHandler; } - if (payloadChannelRequestHandler != nullptr) - { - if (this->mapPayloadChannelRequestHandlers.find(id) != this->mapPayloadChannelRequestHandlers.end()) - { - if (channelRequestHandler != nullptr) - { - this->mapChannelRequestHandlers.erase(id); - } - - MS_THROW_ERROR("PayloadChannel request handler with ID %s already exists", id.c_str()); - } - - this->mapPayloadChannelRequestHandlers[id] = payloadChannelRequestHandler; - } - - if (payloadChannelNotificationHandler != nullptr) + if (channelNotificationHandler != nullptr) { - if ( - this->mapPayloadChannelNotificationHandlers.find(id) != - this->mapPayloadChannelNotificationHandlers.end()) + if (this->mapChannelNotificationHandlers.find(id) != this->mapChannelNotificationHandlers.end()) { if (channelRequestHandler != nullptr) { this->mapChannelRequestHandlers.erase(id); } - if (payloadChannelRequestHandler != nullptr) - { - this->mapPayloadChannelRequestHandlers.erase(id); - } - - MS_THROW_ERROR("PayloadChannel notification handler with ID %s already exists", id.c_str()); + MS_THROW_ERROR("Channel notification handler with ID %s already exists", id.c_str()); } - this->mapPayloadChannelNotificationHandlers[id] = payloadChannelNotificationHandler; + this->mapChannelNotificationHandlers[id] = channelNotificationHandler; } } @@ -119,8 +81,7 @@ void ChannelMessageRegistrator::UnregisterHandler(const std::string& id) MS_TRACE(); this->mapChannelRequestHandlers.erase(id); - this->mapPayloadChannelRequestHandlers.erase(id); - this->mapPayloadChannelNotificationHandlers.erase(id); + this->mapChannelNotificationHandlers.erase(id); } Channel::ChannelSocket::RequestHandler* ChannelMessageRegistrator::GetChannelRequestHandler( @@ -140,31 +101,14 @@ Channel::ChannelSocket::RequestHandler* ChannelMessageRegistrator::GetChannelReq } } -PayloadChannel::PayloadChannelSocket::RequestHandler* ChannelMessageRegistrator::GetPayloadChannelRequestHandler( +Channel::ChannelSocket::NotificationHandler* ChannelMessageRegistrator::GetChannelNotificationHandler( const std::string& id) { MS_TRACE(); - auto it = this->mapPayloadChannelRequestHandlers.find(id); - - if (it != this->mapPayloadChannelRequestHandlers.end()) - { - return it->second; - } - else - { - return nullptr; - } -} - -PayloadChannel::PayloadChannelSocket::NotificationHandler* ChannelMessageRegistrator:: - GetPayloadChannelNotificationHandler(const std::string& id) -{ - MS_TRACE(); - - auto it = this->mapPayloadChannelNotificationHandlers.find(id); + auto it = this->mapChannelNotificationHandlers.find(id); - if (it != this->mapPayloadChannelNotificationHandlers.end()) + if (it != this->mapChannelNotificationHandlers.end()) { return it->second; } diff --git a/worker/src/PayloadChannel/PayloadChannelNotification.cpp b/worker/src/PayloadChannel/PayloadChannelNotification.cpp deleted file mode 100644 index 8805323d6d..0000000000 --- a/worker/src/PayloadChannel/PayloadChannelNotification.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#define MS_CLASS "PayloadChannel::PayloadChannelNotification" -// #define MS_LOG_DEV_LEVEL 3 - -#include "PayloadChannel/PayloadChannelNotification.hpp" -#include "Logger.hpp" -#include "MediaSoupErrors.hpp" -#include "Utils.hpp" - -namespace PayloadChannel -{ - /* Class variables. */ - - // clang-format off - absl::flat_hash_map PayloadChannelNotification::string2EventId = - { - { "transport.sendRtcp", PayloadChannelNotification::EventId::TRANSPORT_SEND_RTCP }, - { "producer.send", PayloadChannelNotification::EventId::PRODUCER_SEND }, - { "dataProducer.send", PayloadChannelNotification::EventId::DATA_PRODUCER_SEND } - }; - // clang-format on - - /* Class methods. */ - - bool PayloadChannelNotification::IsNotification(const char* msg, size_t msgLen) - { - MS_TRACE(); - - return (msgLen > 2 && msg[0] == 'n' && msg[1] == ':'); - } - - /* Instance methods. */ - - PayloadChannelNotification::PayloadChannelNotification(const char* msg, size_t msgLen) - { - MS_TRACE(); - - auto info = Utils::String::Split(std::string(msg, msgLen), ':'); - - if (info.size() < 1) - MS_THROW_ERROR("too few arguments"); - - this->event = info[0]; - - auto eventIdIt = PayloadChannelNotification::string2EventId.find(this->event); - - if (eventIdIt == PayloadChannelNotification::string2EventId.end()) - MS_THROW_ERROR("unknown event '%s'", this->event.c_str()); - - this->eventId = eventIdIt->second; - - if (info.size() > 1) - { - auto& handlerId = info[1]; - - if (handlerId != "undefined") - this->handlerId = handlerId; - } - - if (info.size() > 2) - { - auto& data = info[2]; - - if (data != "undefined") - this->data = data; - } - } - - PayloadChannelNotification::~PayloadChannelNotification() - { - MS_TRACE(); - } - - void PayloadChannelNotification::SetPayload(const uint8_t* payload, size_t payloadLen) - { - MS_TRACE(); - - this->payload = payload; - this->payloadLen = payloadLen; - } -} // namespace PayloadChannel diff --git a/worker/src/PayloadChannel/PayloadChannelNotifier.cpp b/worker/src/PayloadChannel/PayloadChannelNotifier.cpp deleted file mode 100644 index 57090ff80d..0000000000 --- a/worker/src/PayloadChannel/PayloadChannelNotifier.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#define MS_CLASS "PayloadChannel::Notifier" -// #define MS_LOG_DEV_LEVEL 3 - -#include "PayloadChannel/PayloadChannelNotifier.hpp" -#include "Logger.hpp" - -namespace PayloadChannel -{ - PayloadChannelNotifier::PayloadChannelNotifier(PayloadChannel::PayloadChannelSocket* payloadChannel) - : payloadChannel(payloadChannel) - { - MS_TRACE(); - } - - void PayloadChannelNotifier::Emit( - const std::string& targetId, const char* event, const uint8_t* payload, size_t payloadLen) - { - MS_TRACE(); - - std::string notification("{\"targetId\":\""); - - notification.append(targetId); - notification.append("\",\"event\":\""); - notification.append(event); - notification.append("\"}"); - - this->payloadChannel->Send(notification, payload, payloadLen); - } - - void PayloadChannelNotifier::Emit( - const std::string& targetId, const char* event, json& data, const uint8_t* payload, size_t payloadLen) - { - MS_TRACE(); - - json jsonNotification = json::object(); - - jsonNotification["targetId"] = targetId; - jsonNotification["event"] = event; - jsonNotification["data"] = data; - - this->payloadChannel->Send(jsonNotification, payload, payloadLen); - } -} // namespace PayloadChannel diff --git a/worker/src/PayloadChannel/PayloadChannelRequest.cpp b/worker/src/PayloadChannel/PayloadChannelRequest.cpp deleted file mode 100644 index 9e074695d2..0000000000 --- a/worker/src/PayloadChannel/PayloadChannelRequest.cpp +++ /dev/null @@ -1,165 +0,0 @@ -#define MS_CLASS "PayloadChannel::PayloadChannelRequest" -// #define MS_LOG_DEV_LEVEL 3 - -#include "PayloadChannel/PayloadChannelRequest.hpp" -#include "Logger.hpp" -#include "MediaSoupErrors.hpp" -#include "Utils.hpp" -#include "PayloadChannel/PayloadChannelSocket.hpp" - -namespace PayloadChannel -{ - /* Class variables. */ - - // clang-format off - absl::flat_hash_map PayloadChannelRequest::string2MethodId = - { - { "dataConsumer.send", PayloadChannelRequest::MethodId::DATA_CONSUMER_SEND }, - }; - // clang-format on - - /* Class methods. */ - - bool PayloadChannelRequest::IsRequest(const char* msg, size_t msgLen) - { - MS_TRACE(); - - return (msgLen > 2 && msg[0] == 'r' && msg[1] == ':'); - } - - /* Instance methods. */ - - /** - * msg contains "id:method:handlerId:data" where: - * - id: The ID of the request. - * - handlerId: The ID of the target entity - * - data: JSON object. - */ - PayloadChannelRequest::PayloadChannelRequest( - PayloadChannel::PayloadChannelSocket* channel, char* msg, size_t msgLen) - : channel(channel) - { - MS_TRACE(); - - auto info = Utils::String::Split(std::string(msg, msgLen), ':', 3); - - if (info.size() < 2) - MS_THROW_ERROR("too few arguments"); - - this->id = std::stoul(info[0]); - this->method = info[1]; - - auto methodIdIt = PayloadChannelRequest::string2MethodId.find(this->method); - - if (methodIdIt == PayloadChannelRequest::string2MethodId.end()) - { - Error("unknown method"); - - MS_THROW_ERROR("unknown method '%s'", this->method.c_str()); - } - - this->methodId = methodIdIt->second; - - if (info.size() > 2) - { - auto& handlerId = info[2]; - - if (handlerId != "undefined") - this->handlerId = handlerId; - } - - if (info.size() > 3) - { - auto& data = info[3]; - - if (data != "undefined") - this->data = data; - } - } - - PayloadChannelRequest::~PayloadChannelRequest() - { - MS_TRACE(); - } - - void PayloadChannelRequest::Accept() - { - MS_TRACE(); - - MS_ASSERT(!this->replied, "request already replied"); - - this->replied = true; - - std::string response("{\"id\":"); - - response.append(std::to_string(this->id)); - response.append(",\"accepted\":true}"); - - this->channel->Send(response); - } - - void PayloadChannelRequest::Accept(json& data) - { - MS_TRACE(); - - MS_ASSERT(!this->replied, "request already replied"); - - this->replied = true; - - json jsonResponse = json::object(); - - jsonResponse["id"] = this->id; - jsonResponse["accepted"] = true; - - if (data.is_structured()) - jsonResponse["data"] = data; - - this->channel->Send(jsonResponse); - } - - void PayloadChannelRequest::Error(const char* reason) - { - MS_TRACE(); - - MS_ASSERT(!this->replied, "request already replied"); - - this->replied = true; - - json jsonResponse = json::object(); - - jsonResponse["id"] = this->id; - jsonResponse["error"] = "Error"; - - if (reason != nullptr) - jsonResponse["reason"] = reason; - - this->channel->Send(jsonResponse); - } - - void PayloadChannelRequest::TypeError(const char* reason) - { - MS_TRACE(); - - MS_ASSERT(!this->replied, "request already replied"); - - this->replied = true; - - json jsonResponse = json::object(); - - jsonResponse["id"] = this->id; - jsonResponse["error"] = "TypeError"; - - if (reason != nullptr) - jsonResponse["reason"] = reason; - - this->channel->Send(jsonResponse); - } - - void PayloadChannelRequest::SetPayload(const uint8_t* payload, size_t payloadLen) - { - MS_TRACE(); - - this->payload = payload; - this->payloadLen = payloadLen; - } -} // namespace PayloadChannel diff --git a/worker/src/PayloadChannel/PayloadChannelSocket.cpp b/worker/src/PayloadChannel/PayloadChannelSocket.cpp deleted file mode 100644 index 52ba754f06..0000000000 --- a/worker/src/PayloadChannel/PayloadChannelSocket.cpp +++ /dev/null @@ -1,538 +0,0 @@ -#define MS_CLASS "PayloadChannel::PayloadChannelSocket" -// #define MS_LOG_DEV_LEVEL 3 - -#include "PayloadChannel/PayloadChannelSocket.hpp" -#include "DepLibUV.hpp" -#include "Logger.hpp" -#include "MediaSoupErrors.hpp" -#include "PayloadChannel/PayloadChannelRequest.hpp" -#include // std::ceil() -#include // std::memcpy(), std::memmove() - -namespace PayloadChannel -{ - // Binary length for a 4194304 bytes payload. - static constexpr size_t MessageMaxLen{ 4194308 }; - static constexpr size_t PayloadMaxLen{ 4194304 }; - - /* Static methods for UV callbacks. */ - - inline static void onAsync(uv_handle_t* handle) - { - while (static_cast(handle->data)->CallbackRead()) - { - // Read while there are new messages. - } - } - - inline static void onClose(uv_handle_t* handle) - { - delete handle; - } - - /* Instance methods. */ - - PayloadChannelSocket::PayloadChannelSocket(int consumerFd, int producerFd) - : consumerSocket(new ConsumerSocket(consumerFd, MessageMaxLen, this)), - producerSocket(new ProducerSocket(producerFd, MessageMaxLen)), - writeBuffer(static_cast(std::malloc(MessageMaxLen))) - { - MS_TRACE(); - } - - PayloadChannelSocket::PayloadChannelSocket( - PayloadChannelReadFn payloadChannelReadFn, - PayloadChannelReadCtx payloadChannelReadCtx, - PayloadChannelWriteFn payloadChannelWriteFn, - PayloadChannelWriteCtx payloadChannelWriteCtx) - : payloadChannelReadFn(payloadChannelReadFn), payloadChannelReadCtx(payloadChannelReadCtx), - payloadChannelWriteFn(payloadChannelWriteFn), payloadChannelWriteCtx(payloadChannelWriteCtx) - { - MS_TRACE(); - - int err; - - this->uvReadHandle = new uv_async_t; - this->uvReadHandle->data = static_cast(this); - - err = - uv_async_init(DepLibUV::GetLoop(), this->uvReadHandle, reinterpret_cast(onAsync)); - - if (err != 0) - { - delete this->uvReadHandle; - this->uvReadHandle = nullptr; - - MS_THROW_ERROR("uv_async_init() failed: %s", uv_strerror(err)); - } - - err = uv_async_send(this->uvReadHandle); - - if (err != 0) - { - delete this->uvReadHandle; - this->uvReadHandle = nullptr; - - MS_THROW_ERROR("uv_async_send() failed: %s", uv_strerror(err)); - } - } - - PayloadChannelSocket::~PayloadChannelSocket() - { - MS_TRACE(); - - std::free(this->writeBuffer); - delete this->ongoingNotification; - - if (!this->closed) - Close(); - - delete this->consumerSocket; - delete this->producerSocket; - } - - void PayloadChannelSocket::Close() - { - MS_TRACE_STD(); - - if (this->closed) - return; - - this->closed = true; - - if (this->uvReadHandle) - { - uv_close(reinterpret_cast(this->uvReadHandle), static_cast(onClose)); - } - - if (this->consumerSocket) - { - this->consumerSocket->Close(); - } - - if (this->producerSocket) - { - this->producerSocket->Close(); - } - } - - void PayloadChannelSocket::SetListener(Listener* listener) - { - MS_TRACE(); - - this->listener = listener; - } - - void PayloadChannelSocket::Send(json& jsonMessage, const uint8_t* payload, size_t payloadLen) - { - MS_TRACE(); - - if (this->closed) - return; - - std::string message = jsonMessage.dump(); - - this->Send(message, payload, payloadLen); - } - - void PayloadChannelSocket::Send(const std::string& message, const uint8_t* payload, size_t payloadLen) - { - MS_TRACE(); - - if (this->closed) - return; - - if (message.length() > PayloadMaxLen) - { - MS_ERROR("message too big"); - - return; - } - else if (payloadLen > PayloadMaxLen) - { - MS_ERROR("payload too big"); - - return; - } - - SendImpl( - reinterpret_cast(message.c_str()), - static_cast(message.length()), - payload, - static_cast(payloadLen)); - } - - void PayloadChannelSocket::Send(json& jsonMessage) - { - MS_TRACE_STD(); - - if (this->closed) - return; - - std::string message = jsonMessage.dump(); - - if (message.length() > PayloadMaxLen) - { - MS_ERROR_STD("message too big"); - - return; - } - - SendImpl( - reinterpret_cast(message.c_str()), static_cast(message.length())); - } - - void PayloadChannelSocket::Send(const std::string& message) - { - MS_TRACE(); - - if (this->closed) - return; - - if (message.length() > PayloadMaxLen) - { - MS_ERROR("message too big"); - - return; - } - - SendImpl( - reinterpret_cast(message.c_str()), static_cast(message.length())); - } - - bool PayloadChannelSocket::CallbackRead() - { - MS_TRACE(); - - if (this->closed) - return false; - - uint8_t* message{ nullptr }; - uint32_t messageLen; - size_t messageCtx; - - uint8_t* payload{ nullptr }; - uint32_t payloadLen; - size_t payloadCapacity; - - // Try to read next message and payload using `payloadChannelReadFn`, message and payload, - // alongside their lengths and contexts will be stored in provided arguments. - auto free = this->payloadChannelReadFn( - &message, - &messageLen, - &messageCtx, - &payload, - &payloadLen, - &payloadCapacity, - this->uvReadHandle, - this->payloadChannelReadCtx); - - // Non-null free function pointer means message was successfully read above and will need to be - // freed later. - if (free) - { - try - { - char* charMessage{ reinterpret_cast(message) }; - - if (PayloadChannelRequest::IsRequest(charMessage, messageLen)) - { - try - { - auto* request = - new PayloadChannel::PayloadChannelRequest(this, charMessage + 2, messageLen - 2); - request->SetPayload(payload, payloadLen); - - // Notify the listener. - try - { - this->listener->HandleRequest(request); - } - catch (const MediaSoupTypeError& error) - { - request->TypeError(error.what()); - } - catch (const MediaSoupError& error) - { - request->Error(error.what()); - } - - // Delete the Request. - delete request; - } - catch (const json::parse_error& error) - { - MS_ERROR_STD("message parsing error: %s", error.what()); - } - catch (const MediaSoupError& error) - { - MS_ERROR("discarding wrong PayloadChannel request: %s", error.what()); - } - } - - else if (PayloadChannelNotification::IsNotification(charMessage, messageLen)) - { - try - { - auto* notification = - new PayloadChannel::PayloadChannelNotification(charMessage + 2, messageLen - 2); - notification->SetPayload(payload, payloadLen); - - // Notify the listener. - try - { - this->listener->HandleNotification(notification); - } - catch (const MediaSoupError& error) - { - MS_ERROR("notification failed: %s", error.what()); - } - - // Delete the Notification. - delete notification; - } - catch (const json::parse_error& error) - { - MS_ERROR_STD("message parsing error: %s", error.what()); - } - catch (const MediaSoupError& error) - { - MS_ERROR("discarding wrong PayloadChannel notification: %s", error.what()); - } - } - - else - { - MS_ERROR("discarding wrong PayloadChannel data"); - } - } - catch (const json::parse_error& error) - { - MS_ERROR("JSON parsing error: %s", error.what()); - } - catch (const MediaSoupError& error) - { - MS_ERROR("discarding wrong Channel request: %s", error.what()); - } - - // Message and payload need to be freed using stored function pointer. - free(message, messageLen, messageCtx); - free(payload, payloadLen, payloadCapacity); - } - - // Return `true` if something was processed. - return free != nullptr; - } - - inline void PayloadChannelSocket::SendImpl(const uint8_t* message, uint32_t messageLen) - { - MS_TRACE(); - - // Write using function call if provided. - if (this->payloadChannelWriteFn) - { - this->payloadChannelWriteFn(message, messageLen, nullptr, 0, this->payloadChannelWriteCtx); - } - else - { - std::memcpy(this->writeBuffer, &messageLen, sizeof(uint32_t)); - - if (messageLen != 0) - { - std::memcpy(this->writeBuffer + sizeof(uint32_t), message, messageLen); - } - - size_t len = sizeof(uint32_t) + messageLen; - - this->producerSocket->Write(this->writeBuffer, len); - } - } - - inline void PayloadChannelSocket::SendImpl( - const uint8_t* message, uint32_t messageLen, const uint8_t* payload, uint32_t payloadLen) - { - MS_TRACE(); - - // Write using function call if provided. - if (this->payloadChannelWriteFn) - { - this->payloadChannelWriteFn( - message, messageLen, payload, payloadLen, this->payloadChannelWriteCtx); - } - else - { - SendImpl(message, messageLen); - SendImpl(payload, payloadLen); - } - } - - void PayloadChannelSocket::OnConsumerSocketMessage( - ConsumerSocket* /*consumerSocket*/, char* msg, size_t msgLen) - { - MS_TRACE(); - - if (!this->ongoingNotification && !this->ongoingRequest) - { - if (PayloadChannelRequest::IsRequest(msg, msgLen)) - { - try - { - this->ongoingRequest = new PayloadChannel::PayloadChannelRequest(this, msg + 2, msgLen - 2); - } - catch (const json::parse_error& error) - { - MS_ERROR_STD("msg parsing error: %s", error.what()); - } - catch (const MediaSoupError& error) - { - MS_ERROR("discarding wrong PayloadChannel request: %s", error.what()); - } - } - else if (PayloadChannelNotification::IsNotification(msg, msgLen)) - { - try - { - this->ongoingNotification = - new PayloadChannel::PayloadChannelNotification(msg + 2, msgLen - 2); - } - catch (const json::parse_error& error) - { - MS_ERROR_STD("msg parsing error: %s", error.what()); - } - catch (const MediaSoupError& error) - { - MS_ERROR("discarding wrong PayloadChannel notification: %s", error.what()); - } - } - else - { - MS_ERROR("discarding wrong PayloadChannel data"); - } - } - else if (this->ongoingNotification) - { - this->ongoingNotification->SetPayload(reinterpret_cast(msg), msgLen); - - // Notify the listener. - try - { - this->listener->HandleNotification(this->ongoingNotification); - } - catch (const MediaSoupError& error) - { - MS_ERROR("notification failed: %s", error.what()); - } - - // Delete the Notification. - delete this->ongoingNotification; - this->ongoingNotification = nullptr; - } - else if (this->ongoingRequest) - { - this->ongoingRequest->SetPayload(reinterpret_cast(msg), msgLen); - - // Notify the listener. - try - { - this->listener->HandleRequest(this->ongoingRequest); - } - catch (const MediaSoupTypeError& error) - { - this->ongoingRequest->TypeError(error.what()); - } - catch (const MediaSoupError& error) - { - this->ongoingRequest->Error(error.what()); - } - - // Delete the Request. - delete this->ongoingRequest; - this->ongoingRequest = nullptr; - } - } - - void PayloadChannelSocket::OnConsumerSocketClosed(ConsumerSocket* /*consumerSocket*/) - { - MS_TRACE(); - - this->listener->OnPayloadChannelClosed(this); - } - - /* Instance methods. */ - - ConsumerSocket::ConsumerSocket(int fd, size_t bufferSize, Listener* listener) - : ::UnixStreamSocket(fd, bufferSize, ::UnixStreamSocket::Role::CONSUMER), listener(listener) - { - MS_TRACE(); - } - - ConsumerSocket::~ConsumerSocket() - { - MS_TRACE(); - } - - void ConsumerSocket::UserOnUnixStreamRead() - { - MS_TRACE(); - - size_t msgStart{ 0 }; - - // Be ready to parse more than a single message in a single chunk. - while (true) - { - if (IsClosed()) - return; - - size_t readLen = this->bufferDataLen - msgStart; - - if (readLen < sizeof(uint32_t)) - { - // Incomplete data. - break; - } - - uint32_t msgLen; - // Read message length. - std::memcpy(&msgLen, this->buffer + msgStart, sizeof(uint32_t)); - - if (readLen < sizeof(uint32_t) + static_cast(msgLen)) - { - // Incomplete data. - break; - } - - this->listener->OnConsumerSocketMessage( - this, - reinterpret_cast(this->buffer + msgStart + sizeof(uint32_t)), - static_cast(msgLen)); - - msgStart += sizeof(uint32_t) + static_cast(msgLen); - } - - if (msgStart != 0) - { - this->bufferDataLen = this->bufferDataLen - msgStart; - - if (this->bufferDataLen != 0) - { - std::memmove(this->buffer, this->buffer + msgStart, this->bufferDataLen); - } - } - } - - void ConsumerSocket::UserOnUnixStreamSocketClosed() - { - MS_TRACE(); - - // Notify the listener. - this->listener->OnConsumerSocketClosed(this); - } - - /* Instance methods. */ - - ProducerSocket::ProducerSocket(int fd, size_t bufferSize) - : ::UnixStreamSocket(fd, bufferSize, ::UnixStreamSocket::Role::PRODUCER) - { - MS_TRACE(); - } -} // namespace PayloadChannel diff --git a/worker/src/RTC/ActiveSpeakerObserver.cpp b/worker/src/RTC/ActiveSpeakerObserver.cpp index e86bdfcdb1..7375c7be9c 100644 --- a/worker/src/RTC/ActiveSpeakerObserver.cpp +++ b/worker/src/RTC/ActiveSpeakerObserver.cpp @@ -95,19 +95,15 @@ namespace RTC } ActiveSpeakerObserver::ActiveSpeakerObserver( - RTC::Shared* shared, const std::string& id, RTC::RtpObserver::Listener* listener, json& data) + RTC::Shared* shared, + const std::string& id, + RTC::RtpObserver::Listener* listener, + const FBS::ActiveSpeakerObserver::ActiveSpeakerObserverOptions* options) : RTC::RtpObserver(shared, id, listener) { MS_TRACE(); - auto jsonIntervalIt = data.find("interval"); - - if (jsonIntervalIt == data.end() || !jsonIntervalIt->is_number()) - { - MS_THROW_TYPE_ERROR("missing interval"); - } - - this->interval = jsonIntervalIt->get(); + this->interval = options->interval(); if (this->interval < 100) this->interval = 100; @@ -122,8 +118,7 @@ namespace RTC this->shared->channelMessageRegistrator->RegisterHandler( this->id, /*channelRequestHandler*/ this, - /*payloadChannelRequestHandler*/ nullptr, - /*payloadChannelNotificationHandler*/ nullptr); + /*channelNotificationHandler*/ nullptr); } ActiveSpeakerObserver::~ActiveSpeakerObserver() @@ -275,10 +270,14 @@ namespace RTC if (!this->mapProducerSpeakers.empty() && CalculateActiveSpeaker()) { - json data = json::object(); - data["producerId"] = this->dominantId; - - this->shared->channelNotifier->Emit(this->id, "dominantspeaker", data); + auto notification = FBS::ActiveSpeakerObserver::CreateDominantSpeakerNotificationDirect( + this->shared->channelNotifier->GetBufferBuilder(), this->dominantId.c_str()); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::ACTIVESPEAKEROBSERVER_DOMINANT_SPEAKER, + FBS::Notification::Body::FBS_ActiveSpeakerObserver_DominantSpeakerNotification, + notification); } } @@ -324,7 +323,7 @@ namespace RTC { auto* producerSpeaker = kv.second; auto* speaker = producerSpeaker->speaker; - auto& id = producerSpeaker->producer->id; + const auto& id = producerSpeaker->producer->id; if (id == this->dominantId || speaker->paused) { @@ -370,7 +369,7 @@ namespace RTC { auto* producerSpeaker = kv.second; auto* speaker = producerSpeaker->speaker; - auto& id = producerSpeaker->producer->id; + const auto& id = producerSpeaker->producer->id; uint64_t idle = now - speaker->lastLevelChangeTime; if (SpeakerIdleTimeout < idle && (this->dominantId.empty() || id != this->dominantId)) diff --git a/worker/src/RTC/AudioLevelObserver.cpp b/worker/src/RTC/AudioLevelObserver.cpp index 4339e49d16..1de513774e 100644 --- a/worker/src/RTC/AudioLevelObserver.cpp +++ b/worker/src/RTC/AudioLevelObserver.cpp @@ -14,45 +14,21 @@ namespace RTC /* Instance methods. */ AudioLevelObserver::AudioLevelObserver( - RTC::Shared* shared, const std::string& id, RTC::RtpObserver::Listener* listener, json& data) + RTC::Shared* shared, + const std::string& id, + RTC::RtpObserver::Listener* listener, + const FBS::AudioLevelObserver::AudioLevelObserverOptions* options) : RTC::RtpObserver(shared, id, listener) { MS_TRACE(); - auto jsonMaxEntriesIt = data.find("maxEntries"); + this->maxEntries = options->maxEntries(); + this->threshold = options->threshold(); + this->interval = options->interval(); - // clang-format off - if ( - jsonMaxEntriesIt == data.end() || - !Utils::Json::IsPositiveInteger(*jsonMaxEntriesIt) - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("missing maxEntries"); - } - - this->maxEntries = jsonMaxEntriesIt->get(); - - if (this->maxEntries < 1) - MS_THROW_TYPE_ERROR("invalid maxEntries value %" PRIu16, this->maxEntries); - - auto jsonThresholdIt = data.find("threshold"); - - if (jsonThresholdIt == data.end() || !jsonThresholdIt->is_number()) - MS_THROW_TYPE_ERROR("missing threshold"); - - this->threshold = jsonThresholdIt->get(); - - if (this->threshold < -127 || this->threshold > 0) + if (this->threshold > 0) MS_THROW_TYPE_ERROR("invalid threshold value %" PRIi8, this->threshold); - auto jsonIntervalIt = data.find("interval"); - - if (jsonIntervalIt == data.end() || !jsonIntervalIt->is_number()) - MS_THROW_TYPE_ERROR("missing interval"); - - this->interval = jsonIntervalIt->get(); - if (this->interval < 250) this->interval = 250; else if (this->interval > 5000) @@ -66,8 +42,7 @@ namespace RTC this->shared->channelMessageRegistrator->RegisterHandler( this->id, /*channelRequestHandler*/ this, - /*payloadChannelRequestHandler*/ nullptr, - /*payloadChannelNotificationHandler*/ nullptr); + /*channelNotificationHandler*/ nullptr); } AudioLevelObserver::~AudioLevelObserver() @@ -141,7 +116,8 @@ namespace RTC { this->silence = true; - this->shared->channelNotifier->Emit(this->id, "silence"); + this->shared->channelNotifier->Emit( + this->id, FBS::Notification::Event::AUDIOLEVELOBSERVER_SILENCE); } } @@ -184,25 +160,31 @@ namespace RTC this->silence = false; uint16_t idx{ 0 }; - auto rit = mapDBovsProducer.crbegin(); - json data = json::array(); + auto rit = mapDBovsProducer.crbegin(); + + std::vector> volumes; for (; idx < this->maxEntries && rit != mapDBovsProducer.crend(); ++idx, ++rit) { - data.emplace_back(json::value_t::object); - - auto& jsonEntry = data[idx]; - - jsonEntry["producerId"] = rit->second->id; - jsonEntry["volume"] = rit->first; + volumes.emplace_back(FBS::AudioLevelObserver::CreateVolumeDirect( + this->shared->channelNotifier->GetBufferBuilder(), rit->second->id.c_str(), rit->first)); } - this->shared->channelNotifier->Emit(this->id, "volumes", data); + auto notification = FBS::AudioLevelObserver::CreateVolumesNotificationDirect( + this->shared->channelNotifier->GetBufferBuilder(), &volumes); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::AUDIOLEVELOBSERVER_VOLUMES, + FBS::Notification::Body::FBS_AudioLevelObserver_VolumesNotification, + notification); } else if (!this->silence) { this->silence = true; - this->shared->channelNotifier->Emit(this->id, "silence"); + + this->shared->channelNotifier->Emit( + this->id, FBS::Notification::Event::AUDIOLEVELOBSERVER_SILENCE); } } diff --git a/worker/src/RTC/Consumer.cpp b/worker/src/RTC/Consumer.cpp index 0d1cc9dd9a..97d56b0cc1 100644 --- a/worker/src/RTC/Consumer.cpp +++ b/worker/src/RTC/Consumer.cpp @@ -17,30 +17,16 @@ namespace RTC const std::string& id, const std::string& producerId, Listener* listener, - json& data, + const FBS::Transport::ConsumeRequest* data, RTC::RtpParameters::Type type) : id(id), producerId(producerId), shared(shared), listener(listener), type(type) { MS_TRACE(); - auto jsonKindIt = data.find("kind"); - - if (jsonKindIt == data.end() || !jsonKindIt->is_string()) - MS_THROW_TYPE_ERROR("missing kind"); - - // This may throw. - this->kind = RTC::Media::GetKind(jsonKindIt->get()); - - if (this->kind == RTC::Media::Kind::ALL) - MS_THROW_TYPE_ERROR("invalid empty kind"); - - auto jsonRtpParametersIt = data.find("rtpParameters"); - - if (jsonRtpParametersIt == data.end() || !jsonRtpParametersIt->is_object()) - MS_THROW_TYPE_ERROR("missing rtpParameters"); + this->kind = RTC::Media::Kind(data->kind()); // This may throw. - this->rtpParameters = RTC::RtpParameters(*jsonRtpParametersIt); + this->rtpParameters = RTC::RtpParameters(data->rtpParameters()); if (this->rtpParameters.encodings.empty()) MS_THROW_TYPE_ERROR("empty rtpParameters.encodings"); @@ -54,19 +40,14 @@ namespace RTC MS_THROW_TYPE_ERROR("invalid encoding in rtpParameters (missing rtx.ssrc)"); } - auto jsonConsumableRtpEncodingsIt = data.find("consumableRtpEncodings"); - - if (jsonConsumableRtpEncodingsIt == data.end() || !jsonConsumableRtpEncodingsIt->is_array()) - MS_THROW_TYPE_ERROR("missing consumableRtpEncodings"); - - if (jsonConsumableRtpEncodingsIt->empty()) + if (data->consumableRtpEncodings()->size() == 0) MS_THROW_TYPE_ERROR("empty consumableRtpEncodings"); - this->consumableRtpEncodings.reserve(jsonConsumableRtpEncodingsIt->size()); + this->consumableRtpEncodings.reserve(data->consumableRtpEncodings()->size()); - for (size_t i{ 0 }; i < jsonConsumableRtpEncodingsIt->size(); ++i) + for (size_t i{ 0 }; i < data->consumableRtpEncodings()->size(); ++i) { - auto& entry = (*jsonConsumableRtpEncodingsIt)[i]; + const auto* entry = data->consumableRtpEncodings()->Get(i); // This may throw due the constructor of RTC::RtpEncodingParameters. this->consumableRtpEncodings.emplace_back(entry); @@ -121,10 +102,8 @@ namespace RTC } } - auto jsonPausedIt = data.find("paused"); - - if (jsonPausedIt != data.end() && jsonPausedIt->is_boolean()) - this->paused = jsonPausedIt->get(); + // paused is set to false by default. + this->paused = data->paused(); // Fill supported codec payload types. for (auto& codec : this->rtpParameters.codecs) @@ -158,113 +137,77 @@ namespace RTC MS_TRACE(); } - void Consumer::FillJson(json& jsonObject) const + flatbuffers::Offset Consumer::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Add id. - jsonObject["id"] = this->id; - - // Add producerId. - jsonObject["producerId"] = this->producerId; - - // Add kind. - jsonObject["kind"] = RTC::Media::GetString(this->kind); - // Add rtpParameters. - this->rtpParameters.FillJson(jsonObject["rtpParameters"]); - - // Add type. - jsonObject["type"] = RTC::RtpParameters::GetTypeString(this->type); + auto rtpParameters = this->rtpParameters.FillBuffer(builder); // Add consumableRtpEncodings. - jsonObject["consumableRtpEncodings"] = json::array(); - auto jsonConsumableRtpEncodingsIt = jsonObject.find("consumableRtpEncodings"); + std::vector> consumableRtpEncodings; + consumableRtpEncodings.reserve(this->consumableRtpEncodings.size()); - for (size_t i{ 0 }; i < this->consumableRtpEncodings.size(); ++i) + for (const auto& encoding : this->consumableRtpEncodings) { - jsonConsumableRtpEncodingsIt->emplace_back(json::value_t::object); - - auto& jsonEntry = (*jsonConsumableRtpEncodingsIt)[i]; - const auto& encoding = this->consumableRtpEncodings[i]; - - encoding.FillJson(jsonEntry); + consumableRtpEncodings.emplace_back(encoding.FillBuffer(builder)); } // Add supportedCodecPayloadTypes. - jsonObject["supportedCodecPayloadTypes"] = json::array(); + std::vector supportedCodecPayloadTypes; for (auto i = 0; i < 128; ++i) { if (this->supportedCodecPayloadTypes[i]) - jsonObject["supportedCodecPayloadTypes"].push_back(i); + supportedCodecPayloadTypes.push_back(i); } - // Add paused. - jsonObject["paused"] = this->paused; - - // Add producerPaused. - jsonObject["producerPaused"] = this->producerPaused; - - // Add priority. - jsonObject["priority"] = this->priority; - // Add traceEventTypes. - std::vector traceEventTypes; - std::ostringstream traceEventTypesStream; + std::vector> traceEventTypes; if (this->traceEventTypes.rtp) - traceEventTypes.emplace_back("rtp"); + traceEventTypes.emplace_back(builder.CreateString("rtp")); if (this->traceEventTypes.keyframe) - traceEventTypes.emplace_back("keyframe"); + traceEventTypes.emplace_back(builder.CreateString("keyframe")); if (this->traceEventTypes.nack) - traceEventTypes.emplace_back("nack"); + traceEventTypes.emplace_back(builder.CreateString("nack")); if (this->traceEventTypes.pli) - traceEventTypes.emplace_back("pli"); + traceEventTypes.emplace_back(builder.CreateString("pli")); if (this->traceEventTypes.fir) - traceEventTypes.emplace_back("fir"); - - if (!traceEventTypes.empty()) - { - std::copy( - traceEventTypes.begin(), - traceEventTypes.end() - 1, - std::ostream_iterator(traceEventTypesStream, ",")); - traceEventTypesStream << traceEventTypes.back(); - } - - jsonObject["traceEventTypes"] = traceEventTypesStream.str(); + traceEventTypes.emplace_back(builder.CreateString("fir")); + + return FBS::Consumer::CreateBaseConsumerDumpDirect( + builder, + this->id.c_str(), + this->producerId.c_str(), + this->kind == RTC::Media::Kind::AUDIO ? FBS::RtpParameters::MediaKind::AUDIO + : FBS::RtpParameters::MediaKind::VIDEO, + rtpParameters, + &consumableRtpEncodings, + &supportedCodecPayloadTypes, + &traceEventTypes, + this->paused, + this->producerPaused, + this->priority); } void Consumer::HandleRequest(Channel::ChannelRequest* request) { MS_TRACE(); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::CONSUMER_DUMP: + case Channel::ChannelRequest::Method::CONSUMER_GET_STATS: { - json data = json::object(); - - FillJson(data); + auto responseOffset = FillBufferStats(request->GetBufferBuilder()); - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_Consumer_GetStatsResponse, responseOffset); break; } - case Channel::ChannelRequest::MethodId::CONSUMER_GET_STATS: - { - json data = json::array(); - - FillJsonStats(data); - - request->Accept(data); - - break; - } - - case Channel::ChannelRequest::MethodId::CONSUMER_PAUSE: + case Channel::ChannelRequest::Method::CONSUMER_PAUSE: { if (this->paused) { @@ -287,7 +230,7 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::CONSUMER_RESUME: + case Channel::ChannelRequest::Method::CONSUMER_RESUME: { if (!this->paused) { @@ -308,46 +251,33 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::CONSUMER_SET_PRIORITY: + case Channel::ChannelRequest::Method::CONSUMER_SET_PRIORITY: { - auto jsonPriorityIt = request->data.find("priority"); + const auto* body = request->data->body_as(); - if (jsonPriorityIt == request->data.end() || !jsonPriorityIt->is_number()) - MS_THROW_TYPE_ERROR("wrong priority (not a number)"); - - auto priority = jsonPriorityIt->get(); - - if (priority < 1u) + if (body->priority() < 1u) MS_THROW_TYPE_ERROR("wrong priority (must be higher than 0)"); - this->priority = priority; - - json data = json::object(); + this->priority = body->priority(); - data["priority"] = this->priority; + auto responseOffset = + FBS::Consumer::CreateSetPriorityResponse(request->GetBufferBuilder(), this->priority); - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_Consumer_SetPriorityResponse, responseOffset); break; } - case Channel::ChannelRequest::MethodId::CONSUMER_ENABLE_TRACE_EVENT: + case Channel::ChannelRequest::Method::CONSUMER_ENABLE_TRACE_EVENT: { - auto jsonTypesIt = request->data.find("types"); - - // Disable all if no entries. - if (jsonTypesIt == request->data.end() || !jsonTypesIt->is_array()) - MS_THROW_TYPE_ERROR("wrong types (not an array)"); + const auto* body = request->data->body_as(); // Reset traceEventTypes. struct TraceEventTypes newTraceEventTypes; - for (const auto& type : *jsonTypesIt) + for (const auto& type : *body->events()) { - if (!type.is_string()) - MS_THROW_TYPE_ERROR("wrong type (not a string)"); - - const std::string typeStr = type.get(); + const auto typeStr = type->str(); if (typeStr == "rtp") newTraceEventTypes.rtp = true; @@ -370,7 +300,7 @@ namespace RTC default: { - MS_THROW_ERROR("unknown method '%s'", request->method.c_str()); + MS_THROW_ERROR("unknown method '%s'", request->methodCStr); } } } @@ -419,7 +349,7 @@ namespace RTC if (wasActive) UserOnPaused(); - this->shared->channelNotifier->Emit(this->id, "producerpause"); + this->shared->channelNotifier->Emit(this->id, FBS::Notification::Event::CONSUMER_PRODUCER_PAUSE); } void Consumer::ProducerResumed() @@ -436,7 +366,7 @@ namespace RTC if (IsActive()) UserOnResumed(); - this->shared->channelNotifier->Emit(this->id, "producerresume"); + this->shared->channelNotifier->Emit(this->id, FBS::Notification::Event::CONSUMER_PRODUCER_RESUME); } void Consumer::ProducerRtpStreamScores(const std::vector* scores) @@ -457,7 +387,7 @@ namespace RTC MS_DEBUG_DEV("Producer closed [consumerId:%s]", this->id.c_str()); - this->shared->channelNotifier->Emit(this->id, "producerclose"); + this->shared->channelNotifier->Emit(this->id, FBS::Notification::Event::CONSUMER_PRODUCER_CLOSE); this->listener->OnConsumerProducerClosed(this); } @@ -468,33 +398,33 @@ namespace RTC if (this->traceEventTypes.keyframe && packet->IsKeyFrame()) { - json data = json::object(); - - data["type"] = "keyframe"; - data["timestamp"] = DepLibUV::GetTimeMs(); - data["direction"] = "out"; - - packet->FillJson(data["info"]); - - if (isRtx) - data["info"]["isRtx"] = true; - - this->shared->channelNotifier->Emit(this->id, "trace", data); + auto traceInfo = FBS::Consumer::CreateKeyFrameTraceInfo( + this->shared->channelNotifier->GetBufferBuilder(), isRtx); + + auto notification = FBS::Consumer::CreateTraceNotification( + this->shared->channelNotifier->GetBufferBuilder(), + FBS::Consumer::TraceType::KEYFRAME, + DepLibUV::GetTimeMs(), + FBS::Consumer::TraceDirection::DIRECTION_OUT, + FBS::Consumer::TraceInfo::KeyFrameTraceInfo, + traceInfo.Union()); + + EmitTraceEvent(notification); } else if (this->traceEventTypes.rtp) { - json data = json::object(); - - data["type"] = "rtp"; - data["timestamp"] = DepLibUV::GetTimeMs(); - data["direction"] = "out"; - - packet->FillJson(data["info"]); - - if (isRtx) - data["info"]["isRtx"] = true; - - this->shared->channelNotifier->Emit(this->id, "trace", data); + auto traceInfo = + FBS::Consumer::CreateRtpTraceInfo(this->shared->channelNotifier->GetBufferBuilder(), isRtx); + + auto notification = FBS::Consumer::CreateTraceNotification( + this->shared->channelNotifier->GetBufferBuilder(), + FBS::Consumer::TraceType::RTP, + DepLibUV::GetTimeMs(), + FBS::Consumer::TraceDirection::DIRECTION_OUT, + FBS::Consumer::TraceInfo::RtpTraceInfo, + traceInfo.Union()); + + EmitTraceEvent(notification); } } @@ -505,14 +435,18 @@ namespace RTC if (!this->traceEventTypes.pli) return; - json data = json::object(); + auto traceInfo = + FBS::Consumer::CreatePliTraceInfo(this->shared->channelNotifier->GetBufferBuilder(), ssrc); - data["type"] = "pli"; - data["timestamp"] = DepLibUV::GetTimeMs(); - data["direction"] = "in"; - data["info"]["ssrc"] = ssrc; + auto notification = FBS::Consumer::CreateTraceNotification( + this->shared->channelNotifier->GetBufferBuilder(), + FBS::Consumer::TraceType::PLI, + DepLibUV::GetTimeMs(), + FBS::Consumer::TraceDirection::DIRECTION_IN, + FBS::Consumer::TraceInfo::PliTraceInfo, + traceInfo.Union()); - this->shared->channelNotifier->Emit(this->id, "trace", data); + EmitTraceEvent(notification); } void Consumer::EmitTraceEventFirType(uint32_t ssrc) const @@ -522,14 +456,18 @@ namespace RTC if (!this->traceEventTypes.fir) return; - json data = json::object(); + auto traceInfo = + FBS::Consumer::CreateFirTraceInfo(this->shared->channelNotifier->GetBufferBuilder(), ssrc); - data["type"] = "fir"; - data["timestamp"] = DepLibUV::GetTimeMs(); - data["direction"] = "in"; - data["info"]["ssrc"] = ssrc; + auto notification = FBS::Consumer::CreateTraceNotification( + this->shared->channelNotifier->GetBufferBuilder(), + FBS::Consumer::TraceType::FIR, + DepLibUV::GetTimeMs(), + FBS::Consumer::TraceDirection::DIRECTION_IN, + FBS::Consumer::TraceInfo::FirTraceInfo, + traceInfo.Union()); - this->shared->channelNotifier->Emit(this->id, "trace", data); + EmitTraceEvent(notification); } void Consumer::EmitTraceEventNackType() const @@ -539,13 +477,23 @@ namespace RTC if (!this->traceEventTypes.nack) return; - json data = json::object(); + auto notification = FBS::Consumer::CreateTraceNotification( + this->shared->channelNotifier->GetBufferBuilder(), + FBS::Consumer::TraceType::NACK, + DepLibUV::GetTimeMs(), + FBS::Consumer::TraceDirection::DIRECTION_IN); + + EmitTraceEvent(notification); + } - data["type"] = "nack"; - data["timestamp"] = DepLibUV::GetTimeMs(); - data["direction"] = "in"; - data["info"] = json::object(); + void Consumer::EmitTraceEvent(flatbuffers::Offset& notification) const + { + MS_TRACE(); - this->shared->channelNotifier->Emit(this->id, "trace", data); + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::CONSUMER_TRACE, + FBS::Notification::Body::FBS_Consumer_TraceNotification, + notification); } } // namespace RTC diff --git a/worker/src/RTC/DataConsumer.cpp b/worker/src/RTC/DataConsumer.cpp index 9add8cab3b..c3a0bdf9b1 100644 --- a/worker/src/RTC/DataConsumer.cpp +++ b/worker/src/RTC/DataConsumer.cpp @@ -19,22 +19,14 @@ namespace RTC const std::string& dataProducerId, RTC::SctpAssociation* sctpAssociation, RTC::DataConsumer::Listener* listener, - json& data, + const FBS::Transport::ConsumeDataRequest* data, size_t maxMessageSize) : id(id), dataProducerId(dataProducerId), shared(shared), sctpAssociation(sctpAssociation), listener(listener), maxMessageSize(maxMessageSize) { MS_TRACE(); - auto jsonTypeIt = data.find("type"); - auto jsonSctpStreamParametersIt = data.find("sctpStreamParameters"); - auto jsonLabelIt = data.find("label"); - auto jsonProtocolIt = data.find("protocol"); - - if (jsonTypeIt == data.end() || !jsonTypeIt->is_string()) - MS_THROW_TYPE_ERROR("missing type"); - - this->typeString = jsonTypeIt->get(); + this->typeString = data->type()->str(); if (this->typeString == "sctp") this->type = DataConsumer::Type::SCTP; @@ -45,32 +37,27 @@ namespace RTC if (this->type == DataConsumer::Type::SCTP) { - // clang-format off - if ( - jsonSctpStreamParametersIt == data.end() || - !jsonSctpStreamParametersIt->is_object() - ) - // clang-format on + if (!flatbuffers::IsFieldPresent( + data, FBS::Transport::ConsumeDataRequest::VT_SCTPSTREAMPARAMETERS)) { MS_THROW_TYPE_ERROR("missing sctpStreamParameters"); } // This may throw. - this->sctpStreamParameters = RTC::SctpStreamParameters(*jsonSctpStreamParametersIt); + this->sctpStreamParameters = RTC::SctpStreamParameters(data->sctpStreamParameters()); } - if (jsonLabelIt != data.end() && jsonLabelIt->is_string()) - this->label = jsonLabelIt->get(); + if (flatbuffers::IsFieldPresent(data, FBS::Transport::ConsumeDataRequest::VT_LABEL)) + this->label = data->label()->str(); - if (jsonProtocolIt != data.end() && jsonProtocolIt->is_string()) - this->protocol = jsonProtocolIt->get(); + if (flatbuffers::IsFieldPresent(data, FBS::Transport::ConsumeDataRequest::VT_PROTOCOL)) + this->protocol = data->protocol()->str(); // NOTE: This may throw. this->shared->channelMessageRegistrator->RegisterHandler( this->id, /*channelRequestHandler*/ this, - /*payloadChannelRequestHandler*/ this, - /*payloadChannelNotificationHandler*/ nullptr); + /*channelNotificationHandler*/ nullptr); } DataConsumer::~DataConsumer() @@ -80,93 +67,75 @@ namespace RTC this->shared->channelMessageRegistrator->UnregisterHandler(this->id); } - void DataConsumer::FillJson(json& jsonObject) const + flatbuffers::Offset DataConsumer::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Add id. - jsonObject["id"] = this->id; - - // Add type. - jsonObject["type"] = this->typeString; - - // Add dataProducerId. - jsonObject["dataProducerId"] = this->dataProducerId; + flatbuffers::Offset sctpStreamParametersOffset; // Add sctpStreamParameters. if (this->type == DataConsumer::Type::SCTP) { - this->sctpStreamParameters.FillJson(jsonObject["sctpStreamParameters"]); + sctpStreamParametersOffset = this->sctpStreamParameters.FillBuffer(builder); } - // Add label. - jsonObject["label"] = this->label; - - // Add protocol. - jsonObject["protocol"] = this->protocol; - - // Add bufferedAmountLowThreshold. - jsonObject["bufferedAmountLowThreshold"] = this->bufferedAmountLowThreshold; + return FBS::DataConsumer::CreateDumpResponseDirect( + builder, + this->id.c_str(), + this->dataProducerId.c_str(), + this->typeString.c_str(), + sctpStreamParametersOffset, + this->label.c_str(), + this->protocol.c_str()); } - void DataConsumer::FillJsonStats(json& jsonArray) const + flatbuffers::Offset DataConsumer::FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - jsonArray.emplace_back(json::value_t::object); - auto& jsonObject = jsonArray[0]; - - // Add type. - jsonObject["type"] = "data-consumer"; - - // Add timestamp. - jsonObject["timestamp"] = DepLibUV::GetTimeMs(); - - // Add label. - jsonObject["label"] = this->label; - - // Add protocol. - jsonObject["protocol"] = this->protocol; - - // Add messagesSent. - jsonObject["messagesSent"] = this->messagesSent; - - // Add bytesSent. - jsonObject["bytesSent"] = this->bytesSent; - - // Add bufferedAmount. - jsonObject["bufferedAmount"] = this->bufferedAmount; + return FBS::DataConsumer::CreateGetStatsResponseDirect( + builder, + // timestamp. + DepLibUV::GetTimeMs(), + // label. + this->label.c_str(), + // protocol. + this->protocol.c_str(), + // messagesSent. + this->messagesSent, + // bytesSent. + this->bytesSent, + // bufferedAmount. + this->bufferedAmount); } void DataConsumer::HandleRequest(Channel::ChannelRequest* request) { MS_TRACE(); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::DATA_CONSUMER_DUMP: + case Channel::ChannelRequest::Method::DATA_CONSUMER_DUMP: { - json data = json::object(); - - FillJson(data); + auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_DataConsumer_DumpResponse, dumpOffset); break; } - case Channel::ChannelRequest::MethodId::DATA_CONSUMER_GET_STATS: + case Channel::ChannelRequest::Method::DATA_CONSUMER_GET_STATS: { - json data = json::array(); - - FillJsonStats(data); + auto responseOffset = FillBufferStats(request->GetBufferBuilder()); - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_DataConsumer_GetStatsResponse, responseOffset); break; } - case Channel::ChannelRequest::MethodId::DATA_CONSUMER_GET_BUFFERED_AMOUNT: + case Channel::ChannelRequest::Method::DATA_CONSUMER_GET_BUFFERED_AMOUNT: { if (this->GetType() != RTC::DataConsumer::Type::SCTP) { @@ -179,28 +148,26 @@ namespace RTC } // Create status response. - json data = json::object(); + auto responseOffset = FBS::DataConsumer::CreateGetBufferedAmountResponse( + request->GetBufferBuilder(), this->sctpAssociation->GetSctpBufferedAmount()); - data["bufferedAmount"] = this->sctpAssociation->GetSctpBufferedAmount(); - - request->Accept(data); + request->Accept( + FBS::Response::Body::FBS_DataConsumer_GetBufferedAmountResponse, responseOffset); break; } - case Channel::ChannelRequest::MethodId::DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD: + case Channel::ChannelRequest::Method::DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD: { if (this->GetType() != DataConsumer::Type::SCTP) { MS_THROW_TYPE_ERROR("invalid DataConsumer type"); } - auto jsonThresholdIt = request->data.find("threshold"); - - if (jsonThresholdIt == request->data.end() || !jsonThresholdIt->is_number_unsigned()) - MS_THROW_TYPE_ERROR("wrong bufferedAmountThreshold (not an unsigned number)"); + const auto* body = + request->data->body_as(); - this->bufferedAmountLowThreshold = jsonThresholdIt->get(); + this->bufferedAmountLowThreshold = body->threshold(); request->Accept(); @@ -223,20 +190,7 @@ namespace RTC break; } - default: - { - MS_THROW_ERROR("unknown method '%s'", request->method.c_str()); - } - } - } - - void DataConsumer::HandleRequest(PayloadChannel::PayloadChannelRequest* request) - { - MS_TRACE(); - - switch (request->methodId) - { - case PayloadChannel::PayloadChannelRequest::MethodId::DATA_CONSUMER_SEND: + case Channel::ChannelRequest::Method::DATA_CONSUMER_SEND: { if (this->GetType() != RTC::DataConsumer::Type::SCTP) { @@ -248,29 +202,29 @@ namespace RTC MS_THROW_ERROR("no SCTP association present"); } - int ppid; + const auto* body = request->data->body_as(); + const uint8_t* data{ nullptr }; + size_t len{ 0 }; - // This may throw. - // NOTE: If this throws we have to catch the error and throw a MediaSoupError - // intead, otherwise the process would crash. - try + if (body->data_type() == FBS::DataConsumer::Data::String) { - ppid = std::stoi(request->data); + data = body->data_as_String()->value()->Data(); + len = body->data_as_String()->value()->size(); } - catch (const std::exception& error) + else { - MS_THROW_TYPE_ERROR("invalid PPID value: %s", error.what()); + data = body->data_as_Binary()->value()->Data(); + len = body->data_as_Binary()->value()->size(); } - const auto* msg = request->payload; - auto len = request->payloadLen; + const int ppid = body->ppid(); if (len > this->maxMessageSize) { MS_THROW_TYPE_ERROR( "given message exceeds maxMessageSize value [maxMessageSize:%zu, len:%zu]", - len, - this->maxMessageSize); + this->maxMessageSize, + len); } const auto* cb = new onQueuedCallback( @@ -279,18 +233,17 @@ namespace RTC if (queued) request->Accept(); else - request->Error( - sctpSendBufferFull == true ? "sctpsendbufferfull" : "message send failed"); + request->Error(sctpSendBufferFull ? "sctpsendbufferfull" : "message send failed"); }); - SendMessage(ppid, msg, len, cb); + SendMessage(ppid, data, len, cb); break; } default: { - MS_THROW_ERROR("unknown method '%s'", request->method.c_str()); + MS_THROW_ERROR("unknown method '%s'", request->methodCStr); } } } @@ -349,12 +302,14 @@ namespace RTC this->forceTriggerBufferedAmountLow = false; // Notify the Node DataConsumer. - std::string data(R"({"bufferedAmount":)"); - - data.append(std::to_string(this->bufferedAmount)); - data.append("}"); - - this->shared->channelNotifier->Emit(this->id, "bufferedamountlow", data); + auto bufferedAmountLowOffset = FBS::DataConsumer::CreateBufferedAmountLowNotification( + this->shared->channelNotifier->GetBufferBuilder(), this->bufferedAmount); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::DATACONSUMER_BUFFERED_AMOUNT_LOW, + FBS::Notification::Body::FBS_DataConsumer_BufferedAmountLowNotification, + bufferedAmountLowOffset); } } @@ -362,7 +317,8 @@ namespace RTC { MS_TRACE(); - this->shared->channelNotifier->Emit(this->id, "sctpsendbufferfull"); + this->shared->channelNotifier->Emit( + this->id, FBS::Notification::Event::DATACONSUMER_SCTP_SENDBUFFER_FULL); } // The caller (Router) is supposed to proceed with the deletion of this DataConsumer @@ -375,7 +331,8 @@ namespace RTC MS_DEBUG_DEV("DataProducer closed [dataConsumerId:%s]", this->id.c_str()); - this->shared->channelNotifier->Emit(this->id, "dataproducerclose"); + this->shared->channelNotifier->Emit( + this->id, FBS::Notification::Event::DATACONSUMER_DATAPRODUCER_CLOSE); this->listener->OnDataConsumerDataProducerClosed(this); } diff --git a/worker/src/RTC/DataProducer.cpp b/worker/src/RTC/DataProducer.cpp index f0888c83ae..3fffe1cc6e 100644 --- a/worker/src/RTC/DataProducer.cpp +++ b/worker/src/RTC/DataProducer.cpp @@ -17,20 +17,12 @@ namespace RTC const std::string& id, size_t maxMessageSize, RTC::DataProducer::Listener* listener, - json& data) + const FBS::Transport::ProduceDataRequest* data) : id(id), shared(shared), maxMessageSize(maxMessageSize), listener(listener) { MS_TRACE(); - auto jsonTypeIt = data.find("type"); - auto jsonSctpStreamParametersIt = data.find("sctpStreamParameters"); - auto jsonLabelIt = data.find("label"); - auto jsonProtocolIt = data.find("protocol"); - - if (jsonTypeIt == data.end() || !jsonTypeIt->is_string()) - MS_THROW_TYPE_ERROR("missing type"); - - this->typeString = jsonTypeIt->get(); + this->typeString = data->type()->str(); if (this->typeString == "sctp") this->type = DataProducer::Type::SCTP; @@ -41,32 +33,27 @@ namespace RTC if (this->type == DataProducer::Type::SCTP) { - // clang-format off - if ( - jsonSctpStreamParametersIt == data.end() || - !jsonSctpStreamParametersIt->is_object() - ) - // clang-format on + if (!flatbuffers::IsFieldPresent( + data, FBS::Transport::ProduceDataRequest::VT_SCTPSTREAMPARAMETERS)) { MS_THROW_TYPE_ERROR("missing sctpStreamParameters"); } // This may throw. - this->sctpStreamParameters = RTC::SctpStreamParameters(*jsonSctpStreamParametersIt); + this->sctpStreamParameters = RTC::SctpStreamParameters(data->sctpStreamParameters()); } - if (jsonLabelIt != data.end() && jsonLabelIt->is_string()) - this->label = jsonLabelIt->get(); + if (flatbuffers::IsFieldPresent(data, FBS::Transport::ProduceDataRequest::VT_LABEL)) + this->label = data->label()->str(); - if (jsonProtocolIt != data.end() && jsonProtocolIt->is_string()) - this->protocol = jsonProtocolIt->get(); + if (flatbuffers::IsFieldPresent(data, FBS::Transport::ProduceDataRequest::VT_PROTOCOL)) + this->protocol = data->protocol()->str(); // NOTE: This may throw. this->shared->channelMessageRegistrator->RegisterHandler( this->id, /*channelRequestHandler*/ this, - /*payloadChannelRequestHandler*/ nullptr, - /*payloadChannelNotificationHandler*/ this); + /*channelNotificationHandler*/ this); } DataProducer::~DataProducer() @@ -76,124 +63,110 @@ namespace RTC this->shared->channelMessageRegistrator->UnregisterHandler(this->id); } - void DataProducer::FillJson(json& jsonObject) const + flatbuffers::Offset DataProducer::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Add id. - jsonObject["id"] = this->id; - - // Add type. - jsonObject["type"] = this->typeString; + flatbuffers::Offset sctpStreamParametersOffset; // Add sctpStreamParameters. if (this->type == DataProducer::Type::SCTP) { - this->sctpStreamParameters.FillJson(jsonObject["sctpStreamParameters"]); + sctpStreamParametersOffset = this->sctpStreamParameters.FillBuffer(builder); } - // Add label. - jsonObject["label"] = this->label; - - // Add protocol. - jsonObject["protocol"] = this->protocol; + return FBS::DataProducer::CreateDumpResponseDirect( + builder, + this->id.c_str(), + this->typeString.c_str(), + sctpStreamParametersOffset, + this->label.c_str(), + this->protocol.c_str()); } - void DataProducer::FillJsonStats(json& jsonArray) const + flatbuffers::Offset DataProducer::FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - jsonArray.emplace_back(json::value_t::object); - auto& jsonObject = jsonArray[0]; - - // Add type. - jsonObject["type"] = "data-producer"; - - // Add timestamp. - jsonObject["timestamp"] = DepLibUV::GetTimeMs(); - - // Add label. - jsonObject["label"] = this->label; - - // Add protocol. - jsonObject["protocol"] = this->protocol; - - // Add messagesReceived. - jsonObject["messagesReceived"] = this->messagesReceived; - - // Add bytesReceived. - jsonObject["bytesReceived"] = this->bytesReceived; + return FBS::DataProducer::CreateGetStatsResponseDirect( + builder, + // timestamp. + DepLibUV::GetTimeMs(), + // label. + this->label.c_str(), + // protocol. + this->protocol.c_str(), + // messagesReceived. + this->messagesReceived, + // bytesReceived. + this->bytesReceived); } void DataProducer::HandleRequest(Channel::ChannelRequest* request) { MS_TRACE(); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::DATA_PRODUCER_DUMP: + case Channel::ChannelRequest::Method::DATA_PRODUCER_DUMP: { - json data = json::object(); + auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - FillJson(data); - - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_DataProducer_DumpResponse, dumpOffset); break; } - case Channel::ChannelRequest::MethodId::DATA_PRODUCER_GET_STATS: + case Channel::ChannelRequest::Method::DATA_PRODUCER_GET_STATS: { - json data = json::array(); - - FillJsonStats(data); + auto responseOffset = FillBufferStats(request->GetBufferBuilder()); - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_DataProducer_GetStatsResponse, responseOffset); break; } default: { - MS_THROW_ERROR("unknown method '%s'", request->method.c_str()); + MS_THROW_ERROR("unknown method '%s'", request->methodCStr); } } } - void DataProducer::HandleNotification(PayloadChannel::PayloadChannelNotification* notification) + void DataProducer::HandleNotification(Channel::ChannelNotification* notification) { MS_TRACE(); - switch (notification->eventId) + switch (notification->event) { - case PayloadChannel::PayloadChannelNotification::EventId::DATA_PRODUCER_SEND: + case Channel::ChannelNotification::Event::DATA_PRODUCER_SEND: { - int ppid; + const auto* body = notification->data->body_as(); + const uint8_t* data{ nullptr }; + size_t len{ 0 }; - // This may throw. - // NOTE: If this throws we have to catch the error and throw a MediaSoupError - // intead, otherwise the process would crash. - try + if (body->data_type() == FBS::DataProducer::Data::String) { - ppid = std::stoi(notification->data); + data = body->data_as_String()->value()->Data(); + len = body->data_as_String()->value()->size(); } - catch (const std::exception& error) + else { - MS_THROW_TYPE_ERROR("invalid PPID value: %s", error.what()); + data = body->data_as_Binary()->value()->Data(); + len = body->data_as_Binary()->value()->size(); } - const auto* msg = notification->payload; - auto len = notification->payloadLen; - if (len > this->maxMessageSize) { MS_THROW_TYPE_ERROR( "given message exceeds maxMessageSize value [maxMessageSize:%zu, len:%zu]", - len, - this->maxMessageSize); + this->maxMessageSize, + len); } - this->ReceiveMessage(ppid, msg, len); + this->ReceiveMessage(body->ppid(), data, len); // Increase receive transmission. this->listener->OnDataProducerReceiveData(this, len); @@ -203,7 +176,7 @@ namespace RTC default: { - MS_ERROR("unknown event '%s'", notification->event.c_str()); + MS_ERROR("unknown event '%s'", notification->eventCStr); } } } diff --git a/worker/src/RTC/DirectTransport.cpp b/worker/src/RTC/DirectTransport.cpp index fe28591730..f4822d74e2 100644 --- a/worker/src/RTC/DirectTransport.cpp +++ b/worker/src/RTC/DirectTransport.cpp @@ -11,8 +11,11 @@ namespace RTC // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) DirectTransport::DirectTransport( - RTC::Shared* shared, const std::string& id, RTC::Transport::Listener* listener, json& data) - : RTC::Transport::Transport(shared, id, listener, data) + RTC::Shared* shared, + const std::string& id, + RTC::Transport::Listener* listener, + const FBS::DirectTransport::DirectTransportOptions* options) + : RTC::Transport::Transport(shared, id, listener, options->base()) { MS_TRACE(); @@ -20,8 +23,7 @@ namespace RTC this->shared->channelMessageRegistrator->RegisterHandler( this->id, /*channelRequestHandler*/ this, - /*payloadChannelRequestHandler*/ this, - /*payloadChannelNotificationHandler*/ this); + /*channelNotificationHandler*/ this); } DirectTransport::~DirectTransport() @@ -31,57 +33,80 @@ namespace RTC this->shared->channelMessageRegistrator->UnregisterHandler(this->id); } - void DirectTransport::FillJson(json& jsonObject) const + flatbuffers::Offset DirectTransport::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { - MS_TRACE(); + // Add base transport dump. + auto base = Transport::FillBuffer(builder); - // Call the parent method. - RTC::Transport::FillJson(jsonObject); + return FBS::DirectTransport::CreateDumpResponse(builder, base); } - void DirectTransport::FillJsonStats(json& jsonArray) + flatbuffers::Offset DirectTransport::FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) { MS_TRACE(); - // Call the parent method. - RTC::Transport::FillJsonStats(jsonArray); - - auto& jsonObject = jsonArray[0]; + // Base Transport stats. + auto base = Transport::FillBufferStats(builder); - // Add type. - jsonObject["type"] = "direct-transport"; + return FBS::DirectTransport::CreateGetStatsResponse(builder, base); } void DirectTransport::HandleRequest(Channel::ChannelRequest* request) { MS_TRACE(); - // Pass it to the parent class. - RTC::Transport::HandleRequest(request); + switch (request->method) + { + case Channel::ChannelRequest::Method::TRANSPORT_GET_STATS: + { + auto responseOffset = FillBufferStats(request->GetBufferBuilder()); + + request->Accept(FBS::Response::Body::FBS_DirectTransport_GetStatsResponse, responseOffset); + + break; + } + + case Channel::ChannelRequest::Method::TRANSPORT_DUMP: + { + auto dumpOffset = FillBuffer(request->GetBufferBuilder()); + + request->Accept(FBS::Response::Body::FBS_PipeTransport_DumpResponse, dumpOffset); + + break; + } + + default: + { + // Pass it to the parent class. + RTC::Transport::HandleRequest(request); + } + } } - void DirectTransport::HandleNotification(PayloadChannel::PayloadChannelNotification* notification) + void DirectTransport::HandleNotification(Channel::ChannelNotification* notification) { MS_TRACE(); - switch (notification->eventId) + switch (notification->event) { - case PayloadChannel::PayloadChannelNotification::EventId::TRANSPORT_SEND_RTCP: + case Channel::ChannelNotification::Event::TRANSPORT_SEND_RTCP: { - const auto* data = notification->payload; - auto len = notification->payloadLen; + const auto* body = notification->data->body_as(); + auto len = body->data()->size(); // Increase receive transmission. RTC::Transport::DataReceived(len); if (len > RTC::MtuSize + 100) { - MS_WARN_TAG(rtp, "given RTCP packet exceeds maximum size [len:%zu]", len); + MS_WARN_TAG(rtp, "given RTCP packet exceeds maximum size [len:%i]", len); return; } - RTC::RTCP::Packet* packet = RTC::RTCP::Packet::Parse(data, len); + RTC::RTCP::Packet* packet = RTC::RTCP::Packet::Parse(body->data()->data(), len); if (!packet) { @@ -121,11 +146,17 @@ namespace RTC return; } - const uint8_t* data = packet->GetData(); - const size_t len = packet->GetSize(); + const auto data = this->shared->channelNotifier->GetBufferBuilder().CreateVector( + packet->GetData(), packet->GetSize()); - // Notify the Node DirectTransport. - this->shared->payloadChannelNotifier->Emit(consumer->id, "rtp", data, len); + auto notification = + FBS::Consumer::CreateRtpNotification(this->shared->channelNotifier->GetBufferBuilder(), data); + + this->shared->channelNotifier->Emit( + consumer->id, + FBS::Notification::Event::CONSUMER_RTP, + FBS::Notification::Body::FBS_Consumer_RtpNotification, + notification); if (cb) { @@ -134,21 +165,28 @@ namespace RTC } // Increase send transmission. - RTC::Transport::DataSent(len); + RTC::Transport::DataSent(packet->GetSize()); } void DirectTransport::SendRtcpPacket(RTC::RTCP::Packet* packet) { MS_TRACE(); - const uint8_t* data = packet->GetData(); - const size_t len = packet->GetSize(); - // Notify the Node DirectTransport. - this->shared->payloadChannelNotifier->Emit(this->id, "rtcp", data, len); + const auto data = this->shared->channelNotifier->GetBufferBuilder().CreateVector( + packet->GetData(), packet->GetSize()); + + auto notification = FBS::DirectTransport::CreateRtcpNotification( + this->shared->channelNotifier->GetBufferBuilder(), data); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::DIRECTTRANSPORT_RTCP, + FBS::Notification::Body::FBS_DirectTransport_RtcpNotification, + notification); // Increase send transmission. - RTC::Transport::DataSent(len); + RTC::Transport::DataSent(packet->GetSize()); } void DirectTransport::SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet) @@ -157,14 +195,17 @@ namespace RTC packet->Serialize(RTC::RTCP::Buffer); - const uint8_t* data = packet->GetData(); - const size_t len = packet->GetSize(); + const auto data = this->shared->channelNotifier->GetBufferBuilder().CreateVector( + packet->GetData(), packet->GetSize()); - // Notify the Node DirectTransport. - this->shared->payloadChannelNotifier->Emit(this->id, "rtcp", data, len); + auto notification = FBS::DirectTransport::CreateRtcpNotification( + this->shared->channelNotifier->GetBufferBuilder(), data); - // Increase send transmission. - RTC::Transport::DataSent(len); + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::DIRECTTRANSPORT_RTCP, + FBS::Notification::Body::FBS_DirectTransport_RtcpNotification, + notification); } void DirectTransport::SendMessage( @@ -173,11 +214,16 @@ namespace RTC MS_TRACE(); // Notify the Node DirectTransport. - json data = json::object(); + auto data = this->shared->channelNotifier->GetBufferBuilder().CreateVector(msg, len); - data["ppid"] = ppid; + auto notification = FBS::DataConsumer::CreateMessageNotification( + this->shared->channelNotifier->GetBufferBuilder(), ppid, data); - this->shared->payloadChannelNotifier->Emit(dataConsumer->id, "message", data, msg, len); + this->shared->channelNotifier->Emit( + dataConsumer->id, + FBS::Notification::Event::DATACONSUMER_MESSAGE, + FBS::Notification::Body::FBS_DataConsumer_MessageNotification, + notification); // Increase send transmission. RTC::Transport::DataSent(len); diff --git a/worker/src/RTC/IceCandidate.cpp b/worker/src/RTC/IceCandidate.cpp index 4d756c3a64..67af1a18e4 100644 --- a/worker/src/RTC/IceCandidate.cpp +++ b/worker/src/RTC/IceCandidate.cpp @@ -8,51 +8,60 @@ namespace RTC { /* Instance methods. */ - void IceCandidate::FillJson(json& jsonObject) const + flatbuffers::Offset IceCandidate::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Add foundation. - jsonObject["foundation"] = this->foundation; + std::string protocol; - // Add priority. - jsonObject["priority"] = this->priority; - - // Add ip. - jsonObject["ip"] = this->ip; - - // Add protocol. switch (this->protocol) { case Protocol::UDP: - jsonObject["protocol"] = "udp"; + protocol = "udp"; break; case Protocol::TCP: - jsonObject["protocol"] = "tcp"; + protocol = "tcp"; break; } - // Add port. - jsonObject["port"] = this->port; + std::string type; - // Add type. switch (this->type) { case CandidateType::HOST: - jsonObject["type"] = "host"; + type = "host"; break; } - // Add tcpType. + std::string tcpType; + if (this->protocol == Protocol::TCP) { switch (this->tcpType) { case TcpCandidateType::PASSIVE: - jsonObject["tcpType"] = "passive"; + tcpType = "passive"; break; } } + + return FBS::WebRtcTransport::CreateIceCandidateDirect( + builder, + // foundation. + this->foundation.c_str(), + // priority. + this->priority, + // ip. + this->ip.c_str(), + // protocol. + protocol.c_str(), + // port. + this->port, + // type. + type.c_str(), + // tcpType. + tcpType.c_str()); } } // namespace RTC diff --git a/worker/src/RTC/PipeConsumer.cpp b/worker/src/RTC/PipeConsumer.cpp index f4f1d767ef..64dc90ad73 100644 --- a/worker/src/RTC/PipeConsumer.cpp +++ b/worker/src/RTC/PipeConsumer.cpp @@ -16,7 +16,7 @@ namespace RTC const std::string& id, const std::string& producerId, RTC::Consumer::Listener* listener, - json& data) + const FBS::Transport::ConsumeRequest* data) : RTC::Consumer::Consumer(shared, id, producerId, listener, data, RTC::RtpParameters::Type::PIPE) { MS_TRACE(); @@ -37,8 +37,7 @@ namespace RTC this->shared->channelMessageRegistrator->RegisterHandler( this->id, /*channelRequestHandler*/ this, - /*payloadChannelRequestHandler*/ nullptr, - /*payloadChannelNotificationHandler*/ nullptr); + /*channelNotificationHandler*/ nullptr); } PipeConsumer::~PipeConsumer() @@ -56,61 +55,76 @@ namespace RTC this->mapSsrcRtpStream.clear(); } - void PipeConsumer::FillJson(json& jsonObject) const + flatbuffers::Offset PipeConsumer::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); // Call the parent method. - RTC::Consumer::FillJson(jsonObject); + auto base = RTC::Consumer::FillBuffer(builder); // Add rtpStreams. - jsonObject["rtpStreams"] = json::array(); - auto jsonRtpStreamsIt = jsonObject.find("rtpStreams"); + std::vector> rtpStreams; + rtpStreams.reserve(this->rtpStreams.size()); - for (auto* rtpStream : this->rtpStreams) + for (const auto* rtpStream : this->rtpStreams) { - jsonRtpStreamsIt->emplace_back(json::value_t::object); + rtpStreams.emplace_back(rtpStream->FillBuffer(builder)); + } - auto& jsonEntry = (*jsonRtpStreamsIt)[jsonRtpStreamsIt->size() - 1]; + auto pipeConsumerDump = FBS::Consumer::CreatePipeConsumerDumpDirect(builder, base, &rtpStreams); - rtpStream->FillJson(jsonEntry); - } + return FBS::Consumer::CreateDumpResponse( + builder, + FBS::Consumer::DumpData::PipeConsumerDump, + pipeConsumerDump.Union(), + FBS::RtpParameters::Type(this->type)); } - void PipeConsumer::FillJsonStats(json& jsonArray) const + flatbuffers::Offset PipeConsumer::FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) { MS_TRACE(); + std::vector> rtpStreams; + rtpStreams.reserve(this->rtpStreams.size()); + // Add stats of our send streams. for (auto* rtpStream : this->rtpStreams) { - jsonArray.emplace_back(json::value_t::object); - - auto& jsonEntry = jsonArray[jsonArray.size() - 1]; - - rtpStream->FillJsonStats(jsonEntry); + rtpStreams.emplace_back(rtpStream->FillBufferStats(builder)); } + + return FBS::Consumer::CreateGetStatsResponseDirect(builder, &rtpStreams); } - void PipeConsumer::FillJsonScore(json& jsonObject) const + flatbuffers::Offset PipeConsumer::FillBufferScore( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); MS_ASSERT(this->producerRtpStreamScores, "producerRtpStreamScores not set"); // NOTE: Hardcoded values in PipeTransport. - jsonObject["score"] = 10; - jsonObject["producerScore"] = 10; - jsonObject["producerScores"] = *this->producerRtpStreamScores; + return FBS::Consumer::CreateConsumerScoreDirect(builder, 10, 10, this->producerRtpStreamScores); } void PipeConsumer::HandleRequest(Channel::ChannelRequest* request) { MS_TRACE(); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::CONSUMER_REQUEST_KEY_FRAME: + case Channel::ChannelRequest::Method::CONSUMER_DUMP: + { + auto dumpOffset = FillBuffer(request->GetBufferBuilder()); + + request->Accept(FBS::Response::Body::FBS_Consumer_DumpResponse, dumpOffset); + + break; + } + + case Channel::ChannelRequest::Method::CONSUMER_REQUEST_KEY_FRAME: { if (IsActive()) RequestKeyFrame(); @@ -120,7 +134,7 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::CONSUMER_SET_PREFERRED_LAYERS: + case Channel::ChannelRequest::Method::CONSUMER_SET_PREFERRED_LAYERS: { // Do nothing. diff --git a/worker/src/RTC/PipeTransport.cpp b/worker/src/RTC/PipeTransport.cpp index 39bc2a0ead..2895d099f9 100644 --- a/worker/src/RTC/PipeTransport.cpp +++ b/worker/src/RTC/PipeTransport.cpp @@ -23,65 +23,25 @@ namespace RTC // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) PipeTransport::PipeTransport( - RTC::Shared* shared, const std::string& id, RTC::Transport::Listener* listener, json& data) - : RTC::Transport::Transport(shared, id, listener, data) + RTC::Shared* shared, + const std::string& id, + RTC::Transport::Listener* listener, + const FBS::PipeTransport::PipeTransportOptions* options) + : RTC::Transport::Transport(shared, id, listener, options->base()) { MS_TRACE(); - auto jsonListenIpIt = data.find("listenIp"); - - if (jsonListenIpIt == data.end()) - MS_THROW_TYPE_ERROR("missing listenIp"); - else if (!jsonListenIpIt->is_object()) - MS_THROW_TYPE_ERROR("wrong listenIp (not an object)"); - - auto jsonIpIt = jsonListenIpIt->find("ip"); - - if (jsonIpIt == jsonListenIpIt->end()) - MS_THROW_TYPE_ERROR("missing listenIp.ip"); - else if (!jsonIpIt->is_string()) - MS_THROW_TYPE_ERROR("wrong listenIp.ip (not an string)"); - - this->listenIp.ip.assign(jsonIpIt->get()); + this->listenIp.ip.assign(options->listenIp()->ip()->str()); // This may throw. Utils::IP::NormalizeIp(this->listenIp.ip); - auto jsonAnnouncedIpIt = jsonListenIpIt->find("announcedIp"); + if (flatbuffers::IsFieldPresent(options->listenIp(), FBS::Transport::ListenIp::VT_ANNOUNCEDIP)) + this->listenIp.announcedIp.assign(options->listenIp()->announcedIp()->str()); - if (jsonAnnouncedIpIt != jsonListenIpIt->end()) - { - if (!jsonAnnouncedIpIt->is_string()) - MS_THROW_TYPE_ERROR("wrong listenIp.announcedIp (not an string"); - - this->listenIp.announcedIp.assign(jsonAnnouncedIpIt->get()); - } + this->rtx = options->enableRtx(); - uint16_t port{ 0 }; - auto jsonPortIt = data.find("port"); - - if (jsonPortIt != data.end()) - { - if (!(jsonPortIt->is_number() && Utils::Json::IsPositiveInteger(*jsonPortIt))) - MS_THROW_TYPE_ERROR("wrong port (not a positive number)"); - - port = jsonPortIt->get(); - } - - auto jsonEnableRtxIt = data.find("enableRtx"); - - if (jsonEnableRtxIt != data.end() && jsonEnableRtxIt->is_boolean()) - this->rtx = jsonEnableRtxIt->get(); - - auto jsonEnableSrtpIt = data.find("enableSrtp"); - - // clang-format off - if ( - jsonEnableSrtpIt != data.end() && - jsonEnableSrtpIt->is_boolean() && - jsonEnableSrtpIt->get() - ) - // clang-format on + if (options->enableSrtp()) { this->srtpKey = Utils::Crypto::GetRandomString(PipeTransport::srtpMasterLength); this->srtpKeyBase64 = Utils::String::Base64Encode(this->srtpKey); @@ -90,8 +50,8 @@ namespace RTC try { // This may throw. - if (port != 0) - this->udpSocket = new RTC::UdpSocket(this, this->listenIp.ip, port); + if (options->port() != 0) + this->udpSocket = new RTC::UdpSocket(this, this->listenIp.ip, options->port()); else this->udpSocket = new RTC::UdpSocket(this, this->listenIp.ip); @@ -99,8 +59,7 @@ namespace RTC this->shared->channelMessageRegistrator->RegisterHandler( this->id, /*channelRequestHandler*/ this, - /*payloadChannelRequestHandler*/ this, - /*payloadChannelNotificationHandler*/ this); + /*channelNotificationHandler*/ this); } catch (const MediaSoupError& error) { @@ -132,85 +91,112 @@ namespace RTC this->srtpRecvSession = nullptr; } - void PipeTransport::FillJson(json& jsonObject) const + flatbuffers::Offset PipeTransport::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Call the parent method. - RTC::Transport::FillJson(jsonObject); - // Add tuple. + flatbuffers::Offset tuple; + if (this->tuple) { - this->tuple->FillJson(jsonObject["tuple"]); + tuple = this->tuple->FillBuffer(builder); } else { - jsonObject["tuple"] = json::object(); - auto jsonTupleIt = jsonObject.find("tuple"); + std::string localIp; if (this->listenIp.announcedIp.empty()) - (*jsonTupleIt)["localIp"] = this->udpSocket->GetLocalIp(); + localIp = this->udpSocket->GetLocalIp(); else - (*jsonTupleIt)["localIp"] = this->listenIp.announcedIp; + localIp = this->listenIp.announcedIp; - (*jsonTupleIt)["localPort"] = this->udpSocket->GetLocalPort(); - (*jsonTupleIt)["protocol"] = "udp"; + tuple = FBS::Transport::CreateTupleDirect( + builder, localIp.c_str(), this->udpSocket->GetLocalPort(), "", 0, "udp"); } - // Add rtx. - jsonObject["rtx"] = this->rtx; - // Add srtpParameters. + flatbuffers::Offset srtpParameters; + if (HasSrtp()) { - jsonObject["srtpParameters"] = json::object(); - auto jsonSrtpParametersIt = jsonObject.find("srtpParameters"); - - (*jsonSrtpParametersIt)["cryptoSuite"] = PipeTransport::srtpCryptoSuiteString; - (*jsonSrtpParametersIt)["keyBase64"] = this->srtpKeyBase64; + srtpParameters = FBS::Transport::CreateSrtpParametersDirect( + builder, PipeTransport::srtpCryptoSuiteString.c_str(), this->srtpKeyBase64.c_str()); } + + // Add base transport dump. + auto base = Transport::FillBuffer(builder); + + return FBS::PipeTransport::CreateDumpResponse(builder, base, tuple, this->rtx, srtpParameters); } - void PipeTransport::FillJsonStats(json& jsonArray) + flatbuffers::Offset PipeTransport::FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) { MS_TRACE(); - // Call the parent method. - RTC::Transport::FillJsonStats(jsonArray); - - auto& jsonObject = jsonArray[0]; - - // Add type. - jsonObject["type"] = "pipe-transport"; + // Add tuple. + flatbuffers::Offset tuple; if (this->tuple) { - this->tuple->FillJson(jsonObject["tuple"]); + tuple = this->tuple->FillBuffer(builder); } else { - // Add tuple. - jsonObject["tuple"] = json::object(); - auto jsonTupleIt = jsonObject.find("tuple"); + std::string localIp; if (this->listenIp.announcedIp.empty()) - (*jsonTupleIt)["localIp"] = this->udpSocket->GetLocalIp(); + localIp = this->udpSocket->GetLocalIp(); else - (*jsonTupleIt)["localIp"] = this->listenIp.announcedIp; - - (*jsonTupleIt)["localPort"] = this->udpSocket->GetLocalPort(); - (*jsonTupleIt)["protocol"] = "udp"; + localIp = this->listenIp.announcedIp; + + tuple = FBS::Transport::CreateTupleDirect( + builder, + // localIp. + localIp.c_str(), + // localPort, + this->udpSocket->GetLocalPort(), + // remoteIp. + nullptr, + // remotePort. + 0, + // protocol. + "udp"); } + + // Base Transport stats. + auto base = Transport::FillBufferStats(builder); + + return FBS::PipeTransport::CreateGetStatsResponse(builder, base, tuple); } void PipeTransport::HandleRequest(Channel::ChannelRequest* request) { MS_TRACE(); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::TRANSPORT_CONNECT: + case Channel::ChannelRequest::Method::TRANSPORT_GET_STATS: + { + auto responseOffset = FillBufferStats(request->GetBufferBuilder()); + + request->Accept(FBS::Response::Body::FBS_PipeTransport_GetStatsResponse, responseOffset); + + break; + } + + case Channel::ChannelRequest::Method::TRANSPORT_DUMP: + { + auto dumpOffset = FillBuffer(request->GetBufferBuilder()); + + request->Accept(FBS::Response::Body::FBS_PipeTransport_DumpResponse, dumpOffset); + + break; + } + + case Channel::ChannelRequest::Method::PIPE_TRANSPORT_CONNECT: { // Ensure this method is not called twice. if (this->tuple) @@ -222,56 +208,32 @@ namespace RTC uint16_t port{ 0u }; std::string srtpKeyBase64; - auto jsonSrtpParametersIt = request->data.find("srtpParameters"); + const auto* body = request->data->body_as(); + + auto srtpParametersPresent = + flatbuffers::IsFieldPresent(body, FBS::PipeTransport::ConnectRequest::VT_SRTPPARAMETERS); - if (!HasSrtp() && jsonSrtpParametersIt != request->data.end()) + if (!HasSrtp() && srtpParametersPresent) { MS_THROW_TYPE_ERROR("invalid srtpParameters (SRTP not enabled)"); } else if (HasSrtp()) { - // clang-format off - if ( - jsonSrtpParametersIt == request->data.end() || - !jsonSrtpParametersIt->is_object() - ) - // clang-format on + if (!srtpParametersPresent) { MS_THROW_TYPE_ERROR("missing srtpParameters (SRTP enabled)"); } - auto jsonCryptoSuiteIt = jsonSrtpParametersIt->find("cryptoSuite"); - - // clang-format off - if ( - jsonCryptoSuiteIt == jsonSrtpParametersIt->end() || - !jsonCryptoSuiteIt->is_string() - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("missing srtpParameters.cryptoSuite)"); - } + const auto* srtpParameters = body->srtpParameters(); // NOTE: We just use AEAD_AES_256_GCM as SRTP crypto suite in // PipeTransport. - if (jsonCryptoSuiteIt->get() != PipeTransport::srtpCryptoSuiteString) + if (srtpParameters->cryptoSuite()->str() != PipeTransport::srtpCryptoSuiteString) { MS_THROW_TYPE_ERROR("invalid/unsupported srtpParameters.cryptoSuite"); } - auto jsonKeyBase64It = jsonSrtpParametersIt->find("keyBase64"); - - // clang-format off - if ( - jsonKeyBase64It == jsonSrtpParametersIt->end() || - !jsonKeyBase64It->is_string() - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("missing srtpParameters.keyBase64)"); - } - - srtpKeyBase64 = jsonKeyBase64It->get(); + srtpKeyBase64 = srtpParameters->keyBase64()->str(); size_t outLen; // This may throw. @@ -322,29 +284,20 @@ namespace RTC delete[] srtpRemoteKey; } - auto jsonIpIt = request->data.find("ip"); - - if (jsonIpIt == request->data.end() || !jsonIpIt->is_string()) + if (!flatbuffers::IsFieldPresent(body, FBS::PipeTransport::ConnectRequest::VT_IP)) MS_THROW_TYPE_ERROR("missing ip"); - ip = jsonIpIt->get(); + ip = body->ip()->str(); // This may throw. Utils::IP::NormalizeIp(ip); - auto jsonPortIt = request->data.find("port"); - - // clang-format off - if ( - jsonPortIt == request->data.end() || - !Utils::Json::IsPositiveInteger(*jsonPortIt) - ) - // clang-format on + if (!body->port().has_value()) { MS_THROW_TYPE_ERROR("missing port"); } - port = jsonPortIt->get(); + port = body->port().value(); int err; @@ -403,12 +356,12 @@ namespace RTC throw; } - // Tell the caller about the selected local DTLS role. - json data = json::object(); + auto tupleOffset = this->tuple->FillBuffer(request->GetBufferBuilder()); - this->tuple->FillJson(data["tuple"]); + auto responseOffset = + FBS::PipeTransport::CreateConnectResponse(request->GetBufferBuilder(), tupleOffset); - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_PipeTransport_ConnectResponse, responseOffset); // Assume we are connected (there is no much more we can do to know it) // and tell the parent class. @@ -425,7 +378,7 @@ namespace RTC } } - void PipeTransport::HandleNotification(PayloadChannel::PayloadChannelNotification* notification) + void PipeTransport::HandleNotification(Channel::ChannelNotification* notification) { MS_TRACE(); diff --git a/worker/src/RTC/PlainTransport.cpp b/worker/src/RTC/PlainTransport.cpp index a90ecdd8dc..95e931ede9 100644 --- a/worker/src/RTC/PlainTransport.cpp +++ b/worker/src/RTC/PlainTransport.cpp @@ -44,90 +44,34 @@ namespace RTC /* Instance methods. */ - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) - PlainTransport::PlainTransport(RTC::Shared* shared, const std::string& id, RTC::Transport::Listener* listener, json& data) - : RTC::Transport::Transport(shared, id, listener, data) + PlainTransport::PlainTransport( + RTC::Shared* shared, + const std::string& id, + RTC::Transport::Listener* listener, + const FBS::PlainTransport::PlainTransportOptions* options) + : RTC::Transport::Transport(shared, id, listener, options->base()) { MS_TRACE(); - auto jsonListenIpIt = data.find("listenIp"); - - if (jsonListenIpIt == data.end()) - MS_THROW_TYPE_ERROR("missing listenIp"); - else if (!jsonListenIpIt->is_object()) - MS_THROW_TYPE_ERROR("wrong listenIp (not an object)"); - - auto jsonIpIt = jsonListenIpIt->find("ip"); - - if (jsonIpIt == jsonListenIpIt->end()) - MS_THROW_TYPE_ERROR("missing listenIp.ip"); - else if (!jsonIpIt->is_string()) - MS_THROW_TYPE_ERROR("wrong listenIp.ip (not an string)"); - - this->listenIp.ip.assign(jsonIpIt->get()); + this->listenIp.ip.assign(options->listenIp()->ip()->str()); // This may throw. Utils::IP::NormalizeIp(this->listenIp.ip); - auto jsonAnnouncedIpIt = jsonListenIpIt->find("announcedIp"); - - if (jsonAnnouncedIpIt != jsonListenIpIt->end()) - { - if (!jsonAnnouncedIpIt->is_string()) - MS_THROW_TYPE_ERROR("wrong listenIp.announcedIp (not an string"); - - this->listenIp.announcedIp.assign(jsonAnnouncedIpIt->get()); - } - - uint16_t port{ 0 }; - auto jsonPortIt = data.find("port"); - - if (jsonPortIt != data.end()) - { - if (!(jsonPortIt->is_number() && Utils::Json::IsPositiveInteger(*jsonPortIt))) - MS_THROW_TYPE_ERROR("wrong port (not a positive number)"); - - port = jsonPortIt->get(); - } - - auto jsonRtcpMuxIt = data.find("rtcpMux"); - - if (jsonRtcpMuxIt != data.end()) - { - if (!jsonRtcpMuxIt->is_boolean()) - MS_THROW_TYPE_ERROR("wrong rtcpMux (not a boolean)"); - - this->rtcpMux = jsonRtcpMuxIt->get(); - } - - auto jsonComediaIt = data.find("comedia"); - - if (jsonComediaIt != data.end()) - { - if (!jsonComediaIt->is_boolean()) - MS_THROW_TYPE_ERROR("wrong comedia (not a boolean)"); - - this->comedia = jsonComediaIt->get(); - } + if (flatbuffers::IsFieldPresent(options->listenIp(), FBS::Transport::ListenIp::VT_ANNOUNCEDIP)) + this->listenIp.announcedIp.assign(options->listenIp()->announcedIp()->str()); - auto jsonEnableSrtpIt = data.find("enableSrtp"); + this->rtcpMux = options->rtcpMux(); + this->comedia = options->comedia(); - // clang-format off - if ( - jsonEnableSrtpIt != data.end() && - jsonEnableSrtpIt->is_boolean() && - jsonEnableSrtpIt->get() - ) - // clang-format on + if (options->enableSrtp()) { - auto jsonSrtpCryptoSuiteIt = data.find("srtpCryptoSuite"); - - if (jsonSrtpCryptoSuiteIt == data.end() || !jsonSrtpCryptoSuiteIt->is_string()) + if (!flatbuffers::IsFieldPresent( + options, FBS::PlainTransport::PlainTransportOptions::VT_SRTPCRYPTOSUITE)) MS_THROW_TYPE_ERROR("missing srtpCryptoSuite)"); // Ensure it's a crypto suite supported by us. - auto it = - PlainTransport::string2SrtpCryptoSuite.find(jsonSrtpCryptoSuiteIt->get()); + auto it = PlainTransport::string2SrtpCryptoSuite.find(options->srtpCryptoSuite()->str()); if (it == PlainTransport::string2SrtpCryptoSuite.end()) MS_THROW_TYPE_ERROR("invalid/unsupported srtpCryptoSuite"); @@ -172,8 +116,8 @@ namespace RTC try { // This may throw. - if (port != 0) - this->udpSocket = new RTC::UdpSocket(this, this->listenIp.ip, port); + if (options->port() != 0) + this->udpSocket = new RTC::UdpSocket(this, this->listenIp.ip, options->port()); else this->udpSocket = new RTC::UdpSocket(this, this->listenIp.ip); @@ -187,8 +131,7 @@ namespace RTC this->shared->channelMessageRegistrator->RegisterHandler( this->id, /*channelRequestHandler*/ this, - /*payloadChannelRequestHandler*/ this, - /*payloadChannelNotificationHandler*/ this); + /*channelNotificationHandler*/ this); } catch (const MediaSoupError& error) { @@ -227,122 +170,151 @@ namespace RTC this->srtpRecvSession = nullptr; } - void PlainTransport::FillJson(json& jsonObject) const + flatbuffers::Offset PlainTransport::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Call the parent method. - RTC::Transport::FillJson(jsonObject); - - // Add rtcpMux. - jsonObject["rtcpMux"] = this->rtcpMux; - - // Add comedia. - jsonObject["comedia"] = this->comedia; - // Add tuple. + flatbuffers::Offset tuple; + if (this->tuple) { - this->tuple->FillJson(jsonObject["tuple"]); + tuple = this->tuple->FillBuffer(builder); } else { - jsonObject["tuple"] = json::object(); - auto jsonTupleIt = jsonObject.find("tuple"); + std::string localIp; if (this->listenIp.announcedIp.empty()) - (*jsonTupleIt)["localIp"] = this->udpSocket->GetLocalIp(); + localIp = this->udpSocket->GetLocalIp(); else - (*jsonTupleIt)["localIp"] = this->listenIp.announcedIp; + localIp = this->listenIp.announcedIp; - (*jsonTupleIt)["localPort"] = this->udpSocket->GetLocalPort(); - (*jsonTupleIt)["protocol"] = "udp"; + tuple = FBS::Transport::CreateTupleDirect( + builder, localIp.c_str(), this->udpSocket->GetLocalPort(), "", 0, "udp"); } // Add rtcpTuple. + flatbuffers::Offset rtcpTuple; + if (!this->rtcpMux) { if (this->rtcpTuple) { - this->rtcpTuple->FillJson(jsonObject["rtcpTuple"]); + rtcpTuple = this->rtcpTuple->FillBuffer(builder); } else { - jsonObject["rtcpTuple"] = json::object(); - auto jsonRtcpTupleIt = jsonObject.find("rtcpTuple"); + std::string localIp; if (this->listenIp.announcedIp.empty()) - (*jsonRtcpTupleIt)["localIp"] = this->rtcpUdpSocket->GetLocalIp(); + localIp = this->rtcpUdpSocket->GetLocalIp(); else - (*jsonRtcpTupleIt)["localIp"] = this->listenIp.announcedIp; + localIp = this->listenIp.announcedIp; - (*jsonRtcpTupleIt)["localPort"] = this->rtcpUdpSocket->GetLocalPort(); - (*jsonRtcpTupleIt)["protocol"] = "udp"; + rtcpTuple = FBS::Transport::CreateTupleDirect( + builder, localIp.c_str(), this->rtcpUdpSocket->GetLocalPort(), "", 0, "udp"); } } // Add srtpParameters. + flatbuffers::Offset srtpParameters; + if (HasSrtp()) { - jsonObject["srtpParameters"] = json::object(); - auto jsonSrtpParametersIt = jsonObject.find("srtpParameters"); - - (*jsonSrtpParametersIt)["cryptoSuite"] = - PlainTransport::srtpCryptoSuite2String[this->srtpCryptoSuite]; - (*jsonSrtpParametersIt)["keyBase64"] = this->srtpKeyBase64; + srtpParameters = FBS::Transport::CreateSrtpParametersDirect( + builder, + PlainTransport::srtpCryptoSuite2String[this->srtpCryptoSuite].c_str(), + this->srtpKeyBase64.c_str()); } + + // Add base transport dump. + auto base = Transport::FillBuffer(builder); + + return FBS::PlainTransport::CreateDumpResponse( + builder, base, this->rtcpMux, this->comedia, tuple, rtcpTuple, srtpParameters); } - void PlainTransport::FillJsonStats(json& jsonArray) + flatbuffers::Offset PlainTransport::FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) { MS_TRACE(); - // Call the parent method. - RTC::Transport::FillJsonStats(jsonArray); - - auto& jsonObject = jsonArray[0]; - - // Add type. - jsonObject["type"] = "plain-rtp-transport"; - - // Add rtcpMux. - jsonObject["rtcpMux"] = this->rtcpMux; - - // Add comedia. - jsonObject["comedia"] = this->comedia; + // Add tuple. + flatbuffers::Offset tuple; if (this->tuple) { - // Add tuple. - this->tuple->FillJson(jsonObject["tuple"]); + tuple = this->tuple->FillBuffer(builder); } else { - // Add tuple. - jsonObject["tuple"] = json::object(); - auto jsonTupleIt = jsonObject.find("tuple"); + std::string localIp; if (this->listenIp.announcedIp.empty()) - (*jsonTupleIt)["localIp"] = this->udpSocket->GetLocalIp(); + localIp = this->udpSocket->GetLocalIp(); else - (*jsonTupleIt)["localIp"] = this->listenIp.announcedIp; - - (*jsonTupleIt)["localPort"] = this->udpSocket->GetLocalPort(); - (*jsonTupleIt)["protocol"] = "udp"; + localIp = this->listenIp.announcedIp; + + tuple = FBS::Transport::CreateTupleDirect( + builder, + // localIp. + localIp.c_str(), + // localPort, + this->udpSocket->GetLocalPort(), + // remoteIp. + nullptr, + // remotePort. + 0, + // protocol. + "udp" + ); } // Add rtcpTuple. + flatbuffers::Offset rtcpTuple; + if (!this->rtcpMux && this->rtcpTuple) - this->rtcpTuple->FillJson(jsonObject["rtcpTuple"]); + rtcpTuple = this->rtcpTuple->FillBuffer(builder); + + // Base Transport stats. + auto base = Transport::FillBufferStats(builder); + + return FBS::PlainTransport::CreateGetStatsResponse( + builder, + base, + this->rtcpMux, + this->comedia, + tuple, + rtcpTuple); } void PlainTransport::HandleRequest(Channel::ChannelRequest* request) { MS_TRACE(); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::TRANSPORT_CONNECT: + case Channel::ChannelRequest::Method::TRANSPORT_DUMP: + { + auto dumpOffset = FillBuffer(request->GetBufferBuilder()); + + request->Accept(FBS::Response::Body::FBS_PlainTransport_DumpResponse, dumpOffset); + + break; + } + + case Channel::ChannelRequest::Method::TRANSPORT_GET_STATS: + { + auto responseOffset = FillBufferStats(request->GetBufferBuilder()); + + request->Accept(FBS::Response::Body::FBS_PlainTransport_GetStatsResponse, responseOffset); + + break; + } + + case Channel::ChannelRequest::Method::PLAIN_TRANSPORT_CONNECT: { // Ensure this method is not called twice. if (this->connectCalled) @@ -355,39 +327,26 @@ namespace RTC uint16_t rtcpPort{ 0u }; std::string srtpKeyBase64; - auto jsonSrtpParametersIt = request->data.find("srtpParameters"); + const auto *body = request->data->body_as(); + + auto srtpParametersPresent = flatbuffers::IsFieldPresent( + body, FBS::PlainTransport::ConnectRequest::VT_SRTPPARAMETERS); - if (!HasSrtp() && jsonSrtpParametersIt != request->data.end()) + if (!HasSrtp() && srtpParametersPresent) { MS_THROW_TYPE_ERROR("invalid srtpParameters (SRTP not enabled)"); } else if (HasSrtp()) { - // clang-format off - if ( - jsonSrtpParametersIt == request->data.end() || - !jsonSrtpParametersIt->is_object() - ) - // clang-format on + if (!srtpParametersPresent) { MS_THROW_TYPE_ERROR("missing srtpParameters (SRTP enabled)"); } - auto jsonCryptoSuiteIt = jsonSrtpParametersIt->find("cryptoSuite"); - - // clang-format off - if ( - jsonCryptoSuiteIt == jsonSrtpParametersIt->end() || - !jsonCryptoSuiteIt->is_string() - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("missing srtpParameters.cryptoSuite)"); - } - + const auto *srtpParameters = body->srtpParameters(); // Ensure it's a crypto suite supported by us. auto it = - PlainTransport::string2SrtpCryptoSuite.find(jsonCryptoSuiteIt->get()); + PlainTransport::string2SrtpCryptoSuite.find(srtpParameters->cryptoSuite()->str()); if (it == PlainTransport::string2SrtpCryptoSuite.end()) MS_THROW_TYPE_ERROR("invalid/unsupported srtpParameters.cryptoSuite"); @@ -433,19 +392,7 @@ namespace RTC this->srtpKeyBase64 = Utils::String::Base64Encode(this->srtpKey); } - auto jsonKeyBase64It = jsonSrtpParametersIt->find("keyBase64"); - - // clang-format off - if ( - jsonKeyBase64It == jsonSrtpParametersIt->end() || - !jsonKeyBase64It->is_string() - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("missing srtpParameters.keyBase64)"); - } - - srtpKeyBase64 = jsonKeyBase64It->get(); + srtpKeyBase64 = srtpParameters->keyBase64()->str(); size_t outLen; // This may throw. @@ -498,43 +445,27 @@ namespace RTC if (!this->comedia) { - auto jsonIpIt = request->data.find("ip"); - - if (jsonIpIt == request->data.end() || !jsonIpIt->is_string()) + if (!flatbuffers::IsFieldPresent(body, FBS::PlainTransport::ConnectRequest::VT_IP)) MS_THROW_TYPE_ERROR("missing ip"); - ip = jsonIpIt->get(); + ip = body->ip()->str(); // This may throw. Utils::IP::NormalizeIp(ip); - auto jsonPortIt = request->data.find("port"); - - // clang-format off - if ( - jsonPortIt == request->data.end() || - !Utils::Json::IsPositiveInteger(*jsonPortIt) - ) - // clang-format on + if (!body->port().has_value()) { MS_THROW_TYPE_ERROR("missing port"); } - port = jsonPortIt->get(); + port = body->port().value(); - auto jsonRtcpPortIt = request->data.find("rtcpPort"); - - // clang-format off - if ( - jsonRtcpPortIt != request->data.end() && - Utils::Json::IsPositiveInteger(*jsonRtcpPortIt) - ) - // clang-format on + if (body->rtcpPort().has_value()) { if (this->rtcpMux) MS_THROW_TYPE_ERROR("cannot set rtcpPort with rtcpMux enabled"); - rtcpPort = jsonRtcpPortIt->get(); + rtcpPort = body->rtcpPort().value(); } else { @@ -651,25 +582,30 @@ namespace RTC this->connectCalled = true; // Tell the caller about the selected local DTLS role. - json data = json::object(); + flatbuffers::Offset tupleOffset; + flatbuffers::Offset rtcpTupleOffset; + flatbuffers::Offset srtpParametersOffset; if (this->tuple) - this->tuple->FillJson(data["tuple"]); + tupleOffset = this->tuple->FillBuffer(request->GetBufferBuilder()); if (!this->rtcpMux && this->rtcpTuple) - this->rtcpTuple->FillJson(data["rtcpTuple"]); + rtcpTupleOffset = this->rtcpTuple->FillBuffer(request->GetBufferBuilder()); if (HasSrtp()) { - data["srtpParameters"] = json::object(); - auto jsonSrtpParametersIt = data.find("srtpParameters"); - - (*jsonSrtpParametersIt)["cryptoSuite"] = - PlainTransport::srtpCryptoSuite2String[this->srtpCryptoSuite]; - (*jsonSrtpParametersIt)["keyBase64"] = this->srtpKeyBase64; + srtpParametersOffset = FBS::Transport::CreateSrtpParametersDirect( + request->GetBufferBuilder(), + PlainTransport::srtpCryptoSuite2String[this->srtpCryptoSuite].c_str(), + this->srtpKeyBase64.c_str() + ); } - request->Accept(data); + auto responseOffset = + FBS::PlainTransport::CreateConnectResponse( + request->GetBufferBuilder(), tupleOffset, rtcpTupleOffset, srtpParametersOffset); + + request->Accept(FBS::Response::Body::FBS_PlainTransport_ConnectResponse, responseOffset); // Assume we are connected (there is no much more we can do to know it) // and tell the parent class. @@ -686,7 +622,7 @@ namespace RTC } } - void PlainTransport::HandleNotification(PayloadChannel::PayloadChannelNotification* notification) + void PlainTransport::HandleNotification(Channel::ChannelNotification* notification) { MS_TRACE(); @@ -937,11 +873,7 @@ namespace RTC if (!wasConnected) { // Notify the Node PlainTransport. - json data = json::object(); - - this->tuple->FillJson(data["tuple"]); - - this->shared->channelNotifier->Emit(this->id, "tuple", data); + EmitTuple(); RTC::Transport::Connected(); } @@ -1004,11 +936,7 @@ namespace RTC if (!wasConnected) { // Notify the Node PlainTransport. - json data = json::object(); - - this->tuple->FillJson(data["tuple"]); - - this->shared->channelNotifier->Emit(this->id, "tuple", data); + EmitTuple(); RTC::Transport::Connected(); } @@ -1032,11 +960,7 @@ namespace RTC this->rtcpTuple->SetLocalAnnouncedIp(this->listenIp.announcedIp); // Notify the Node PlainTransport. - json data = json::object(); - - this->rtcpTuple->FillJson(data["rtcpTuple"]); - - this->shared->channelNotifier->Emit(this->id, "rtcptuple", data); + EmitRtcpTuple(); } // If RTCP-mux verify that the packet's tuple matches our RTP tuple. else if (this->rtcpMux && !this->tuple->Compare(tuple)) @@ -1094,11 +1018,7 @@ namespace RTC if (!wasConnected) { // Notify the Node PlainTransport. - json data = json::object(); - - this->tuple->FillJson(data["tuple"]); - - this->shared->channelNotifier->Emit(this->id, "tuple", data); + EmitTuple(); RTC::Transport::Connected(); } @@ -1116,6 +1036,34 @@ namespace RTC RTC::Transport::ReceiveSctpData(data, len); } + inline void PlainTransport::EmitTuple() const + { + auto tuple = this->tuple->FillBuffer(this->shared->channelNotifier->GetBufferBuilder()); + auto notification = FBS::PlainTransport::CreateTupleNotification( + this->shared->channelNotifier->GetBufferBuilder(), + tuple); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::PLAINTRANSPORT_TUPLE, + FBS::Notification::Body::FBS_PlainTransport_TupleNotification, + notification); + } + + inline void PlainTransport::EmitRtcpTuple() const + { + auto rtcpTuple = this->rtcpTuple->FillBuffer(this->shared->channelNotifier->GetBufferBuilder()); + auto notification = FBS::PlainTransport::CreateRtcpTupleNotification( + this->shared->channelNotifier->GetBufferBuilder(), + rtcpTuple); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::PLAINTRANSPORT_RTCP_TUPLE, + FBS::Notification::Body::FBS_PlainTransport_RtcpTupleNotification, + notification); + } + inline void PlainTransport::OnUdpSocketPacketReceived( RTC::UdpSocket* socket, const uint8_t* data, size_t len, const struct sockaddr* remoteAddr) { diff --git a/worker/src/RTC/PortManager.cpp b/worker/src/RTC/PortManager.cpp index 5269fced06..2b634edf5e 100644 --- a/worker/src/RTC/PortManager.cpp +++ b/worker/src/RTC/PortManager.cpp @@ -608,55 +608,4 @@ namespace RTC return emptyPorts; } - - void PortManager::FillJson(json& jsonObject) - { - MS_TRACE(); - - // Add udp. - jsonObject["udp"] = json::object(); - auto jsonUdpIt = jsonObject.find("udp"); - - for (auto& kv : PortManager::mapUdpIpPorts) - { - const auto& ip = kv.first; - auto& ports = kv.second; - - (*jsonUdpIt)[ip] = json::array(); - auto jsonIpIt = jsonUdpIt->find(ip); - - for (size_t i{ 0 }; i < ports.size(); ++i) - { - if (!ports[i]) - continue; - - auto port = static_cast(i + Settings::configuration.rtcMinPort); - - jsonIpIt->push_back(port); - } - } - - // Add tcp. - jsonObject["tcp"] = json::object(); - auto jsonTcpIt = jsonObject.find("tcp"); - - for (auto& kv : PortManager::mapTcpIpPorts) - { - const auto& ip = kv.first; - auto& ports = kv.second; - - (*jsonTcpIt)[ip] = json::array(); - auto jsonIpIt = jsonTcpIt->find(ip); - - for (size_t i{ 0 }; i < ports.size(); ++i) - { - if (!ports[i]) - continue; - - auto port = static_cast(i + Settings::configuration.rtcMinPort); - - jsonIpIt->emplace_back(port); - } - } - } } // namespace RTC diff --git a/worker/src/RTC/Producer.cpp b/worker/src/RTC/Producer.cpp index 1c0e674a8d..b0113e87ec 100644 --- a/worker/src/RTC/Producer.cpp +++ b/worker/src/RTC/Producer.cpp @@ -28,35 +28,24 @@ namespace RTC /* Instance methods. */ Producer::Producer( - RTC::Shared* shared, const std::string& id, RTC::Producer::Listener* listener, json& data) + RTC::Shared* shared, + const std::string& id, + RTC::Producer::Listener* listener, + const FBS::Transport::ProduceRequest* data) : id(id), shared(shared), listener(listener) { MS_TRACE(); - auto jsonKindIt = data.find("kind"); - - if (jsonKindIt == data.end() || !jsonKindIt->is_string()) - { - MS_THROW_TYPE_ERROR("missing kind"); - } - // This may throw. - this->kind = RTC::Media::GetKind(jsonKindIt->get()); + this->kind = RTC::Media::Kind(data->kind()); if (this->kind == RTC::Media::Kind::ALL) { MS_THROW_TYPE_ERROR("invalid empty kind"); } - auto jsonRtpParametersIt = data.find("rtpParameters"); - - if (jsonRtpParametersIt == data.end() || !jsonRtpParametersIt->is_object()) - { - MS_THROW_TYPE_ERROR("missing rtpParameters"); - } - // This may throw. - this->rtpParameters = RTC::RtpParameters(*jsonRtpParametersIt); + this->rtpParameters = RTC::RtpParameters(data->rtpParameters()); // Evaluate type. this->type = RTC::RtpParameters::GetType(this->rtpParameters); @@ -77,102 +66,34 @@ namespace RTC RTC::RtpParameters::GetTypeString(this->type).c_str()); } - auto jsonRtpMappingIt = data.find("rtpMapping"); - - if (jsonRtpMappingIt == data.end() || !jsonRtpMappingIt->is_object()) - { - MS_THROW_TYPE_ERROR("missing rtpMapping"); - } - - auto jsonCodecsIt = jsonRtpMappingIt->find("codecs"); - - if (jsonCodecsIt == jsonRtpMappingIt->end() || !jsonCodecsIt->is_array()) - { - MS_THROW_TYPE_ERROR("missing rtpMapping.codecs"); - } - - for (auto& codec : *jsonCodecsIt) + for (const auto& codec : *data->rtpMapping()->codecs()) { - if (!codec.is_object()) - { - MS_THROW_TYPE_ERROR("wrong entry in rtpMapping.codecs (not an object)"); - } - - auto jsonPayloadTypeIt = codec.find("payloadType"); - - // clang-format off - if ( - jsonPayloadTypeIt == codec.end() || - !Utils::Json::IsPositiveInteger(*jsonPayloadTypeIt) - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("wrong entry in rtpMapping.codecs (missing payloadType)"); - } - - auto jsonMappedPayloadTypeIt = codec.find("mappedPayloadType"); - - // clang-format off - if ( - jsonMappedPayloadTypeIt == codec.end() || - !Utils::Json::IsPositiveInteger(*jsonMappedPayloadTypeIt) - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("wrong entry in rtpMapping.codecs (missing mappedPayloadType)"); - } - - this->rtpMapping.codecs[jsonPayloadTypeIt->get()] = - jsonMappedPayloadTypeIt->get(); + this->rtpMapping.codecs[codec->payloadType()] = codec->mappedPayloadType(); } - auto jsonEncodingsIt = jsonRtpMappingIt->find("encodings"); + const auto* encodings = data->rtpMapping()->encodings(); - if (jsonEncodingsIt == jsonRtpMappingIt->end() || !jsonEncodingsIt->is_array()) - { - MS_THROW_TYPE_ERROR("missing rtpMapping.encodings"); - } + this->rtpMapping.encodings.reserve(encodings->size()); - this->rtpMapping.encodings.reserve(jsonEncodingsIt->size()); - - for (auto& encoding : *jsonEncodingsIt) + for (const auto& encoding : *encodings) { - if (!encoding.is_object()) - { - MS_THROW_TYPE_ERROR("wrong entry in rtpMapping.encodings"); - } - this->rtpMapping.encodings.emplace_back(); auto& encodingMapping = this->rtpMapping.encodings.back(); // ssrc is optional. - auto jsonSsrcIt = encoding.find("ssrc"); - - // clang-format off - if ( - jsonSsrcIt != encoding.end() && - Utils::Json::IsPositiveInteger(*jsonSsrcIt) - ) - // clang-format on + if (encoding->ssrc().has_value()) { - encodingMapping.ssrc = jsonSsrcIt->get(); + encodingMapping.ssrc = encoding->ssrc().value(); } // rid is optional. - auto jsonRidIt = encoding.find("rid"); - - if (jsonRidIt != encoding.end() && jsonRidIt->is_string()) - { - encodingMapping.rid = jsonRidIt->get(); - } - // However ssrc or rid must be present (if more than 1 encoding). // clang-format off if ( - jsonEncodingsIt->size() > 1 && - jsonSsrcIt == encoding.end() && - jsonRidIt == encoding.end() + encodings->size() > 1 && + !encoding->ssrc().has_value() && + !flatbuffers::IsFieldPresent(encoding, FBS::RtpParameters::EncodingMapping::VT_RID) ) // clang-format on { @@ -183,9 +104,9 @@ namespace RTC // clang-format off if ( this->rtpParameters.mid.empty() && - jsonEncodingsIt->size() == 1 && - jsonSsrcIt == encoding.end() && - jsonRidIt == encoding.end() + encodings->size() == 1 && + !encoding->ssrc().has_value() && + !flatbuffers::IsFieldPresent(encoding, FBS::RtpParameters::EncodingMapping::VT_RID) ) // clang-format on { @@ -194,27 +115,15 @@ namespace RTC } // mappedSsrc is mandatory. - auto jsonMappedSsrcIt = encoding.find("mappedSsrc"); - - // clang-format off - if ( - jsonMappedSsrcIt == encoding.end() || - !Utils::Json::IsPositiveInteger(*jsonMappedSsrcIt) - ) - // clang-format on + if (!encoding->mappedSsrc()) { MS_THROW_TYPE_ERROR("wrong entry in rtpMapping.encodings (missing mappedSsrc)"); } - encodingMapping.mappedSsrc = jsonMappedSsrcIt->get(); + encodingMapping.mappedSsrc = encoding->mappedSsrc(); } - auto jsonPausedIt = data.find("paused"); - - if (jsonPausedIt != data.end() && jsonPausedIt->is_boolean()) - { - this->paused = jsonPausedIt->get(); - } + this->paused = data->paused(); // The number of encodings in rtpParameters must match the number of encodings // in rtpMapping. @@ -298,18 +207,7 @@ namespace RTC // Create a KeyFrameRequestManager. if (this->kind == RTC::Media::Kind::VIDEO) { - auto jsonKeyFrameRequestDelayIt = data.find("keyFrameRequestDelay"); - uint32_t keyFrameRequestDelay = 0u; - - // clang-format off - if ( - jsonKeyFrameRequestDelayIt != data.end() && - jsonKeyFrameRequestDelayIt->is_number_integer() - ) - // clang-format on - { - keyFrameRequestDelay = jsonKeyFrameRequestDelayIt->get(); - } + auto keyFrameRequestDelay = data->keyFrameRequestDelay(); this->keyFrameRequestManager = new RTC::KeyFrameRequestManager(this, keyFrameRequestDelay); } @@ -318,8 +216,7 @@ namespace RTC this->shared->channelMessageRegistrator->RegisterHandler( this->id, /*channelRequestHandler*/ this, - /*payloadChannelRequestHandler*/ nullptr, - /*payloadChannelNotificationHandler*/ this); + /*channelNotificationHandler*/ this); } Producer::~Producer() @@ -347,165 +244,121 @@ namespace RTC delete this->keyFrameRequestManager; } - void Producer::FillJson(json& jsonObject) const + flatbuffers::Offset Producer::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Add id. - jsonObject["id"] = this->id; - - // Add kind. - jsonObject["kind"] = RTC::Media::GetString(this->kind); - // Add rtpParameters. - this->rtpParameters.FillJson(jsonObject["rtpParameters"]); - - // Add type. - jsonObject["type"] = RTC::RtpParameters::GetTypeString(this->type); - - // Add rtpMapping. - jsonObject["rtpMapping"] = json::object(); - auto jsonRtpMappingIt = jsonObject.find("rtpMapping"); + auto rtpParameters = this->rtpParameters.FillBuffer(builder); // Add rtpMapping.codecs. - { - (*jsonRtpMappingIt)["codecs"] = json::array(); - auto jsonCodecsIt = jsonRtpMappingIt->find("codecs"); - size_t idx{ 0 }; + std::vector> codecs; - for (const auto& kv : this->rtpMapping.codecs) - { - jsonCodecsIt->emplace_back(json::value_t::object); - - auto& jsonEntry = (*jsonCodecsIt)[idx]; - auto payloadType = kv.first; - auto mappedPayloadType = kv.second; - - jsonEntry["payloadType"] = payloadType; - jsonEntry["mappedPayloadType"] = mappedPayloadType; - - ++idx; - } + for (const auto& kv : this->rtpMapping.codecs) + { + codecs.emplace_back(FBS::RtpParameters::CreateCodecMapping(builder, kv.first, kv.second)); } // Add rtpMapping.encodings. - { - (*jsonRtpMappingIt)["encodings"] = json::array(); - auto jsonEncodingsIt = jsonRtpMappingIt->find("encodings"); + std::vector> encodings; + encodings.reserve(this->rtpMapping.encodings.size()); - for (size_t i{ 0 }; i < this->rtpMapping.encodings.size(); ++i) - { - jsonEncodingsIt->emplace_back(json::value_t::object); - - auto& jsonEntry = (*jsonEncodingsIt)[i]; - const auto& encodingMapping = this->rtpMapping.encodings[i]; - - if (!encodingMapping.rid.empty()) - jsonEntry["rid"] = encodingMapping.rid; - else - jsonEntry["rid"] = nullptr; - - if (encodingMapping.ssrc != 0u) - jsonEntry["ssrc"] = encodingMapping.ssrc; - else - jsonEntry["ssrc"] = nullptr; - - jsonEntry["mappedSsrc"] = encodingMapping.mappedSsrc; - } + for (const auto& encodingMapping : this->rtpMapping.encodings) + { + encodings.emplace_back(FBS::RtpParameters::CreateEncodingMappingDirect( + builder, + encodingMapping.rid.c_str(), + encodingMapping.ssrc != 0u ? flatbuffers::Optional(encodingMapping.ssrc) + : flatbuffers::nullopt, + nullptr, /* capability mode. NOTE: Present in NODE*/ + encodingMapping.mappedSsrc)); } + // Build rtpMapping. + auto rtpMapping = FBS::RtpParameters::CreateRtpMappingDirect(builder, &codecs, &encodings); + // Add rtpStreams. - jsonObject["rtpStreams"] = json::array(); - auto jsonRtpStreamsIt = jsonObject.find("rtpStreams"); + std::vector> rtpStreams; - for (auto* rtpStream : this->rtpStreamByEncodingIdx) + for (const auto* rtpStream : this->rtpStreamByEncodingIdx) { if (!rtpStream) continue; - jsonRtpStreamsIt->emplace_back(json::value_t::object); - - auto& jsonEntry = (*jsonRtpStreamsIt)[jsonRtpStreamsIt->size() - 1]; - - rtpStream->FillJson(jsonEntry); + rtpStreams.emplace_back(rtpStream->FillBuffer(builder)); } - // Add paused. - jsonObject["paused"] = this->paused; - // Add traceEventTypes. - std::vector traceEventTypes; - std::ostringstream traceEventTypesStream; + std::vector> traceEventTypes; if (this->traceEventTypes.rtp) - traceEventTypes.emplace_back("rtp"); + traceEventTypes.emplace_back(builder.CreateString("rtp")); if (this->traceEventTypes.keyframe) - traceEventTypes.emplace_back("keyframe"); + traceEventTypes.emplace_back(builder.CreateString("keyframe")); if (this->traceEventTypes.nack) - traceEventTypes.emplace_back("nack"); + traceEventTypes.emplace_back(builder.CreateString("nack")); if (this->traceEventTypes.pli) - traceEventTypes.emplace_back("pli"); + traceEventTypes.emplace_back(builder.CreateString("pli")); if (this->traceEventTypes.fir) - traceEventTypes.emplace_back("fir"); - - if (!traceEventTypes.empty()) - { - std::copy( - traceEventTypes.begin(), - traceEventTypes.end() - 1, - std::ostream_iterator(traceEventTypesStream, ",")); - traceEventTypesStream << traceEventTypes.back(); - } - - jsonObject["traceEventTypes"] = traceEventTypesStream.str(); + traceEventTypes.emplace_back(builder.CreateString("fir")); + + return FBS::Producer::CreateDumpResponseDirect( + builder, + this->id.c_str(), + this->kind == RTC::Media::Kind::AUDIO ? FBS::RtpParameters::MediaKind::AUDIO + : FBS::RtpParameters::MediaKind::VIDEO, + RTC::RtpParameters::GetTypeString(this->type).c_str(), + rtpParameters, + rtpMapping, + &rtpStreams, + &traceEventTypes, + this->paused); } - void Producer::FillJsonStats(json& jsonArray) const + flatbuffers::Offset Producer::FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) { MS_TRACE(); + std::vector> rtpStreams; + for (auto* rtpStream : this->rtpStreamByEncodingIdx) { if (!rtpStream) continue; - jsonArray.emplace_back(json::value_t::object); - - auto& jsonEntry = jsonArray[jsonArray.size() - 1]; - - rtpStream->FillJsonStats(jsonEntry); + rtpStreams.emplace_back(rtpStream->FillBufferStats(builder)); } + + return FBS::Producer::CreateGetStatsResponseDirect(builder, &rtpStreams); } void Producer::HandleRequest(Channel::ChannelRequest* request) { MS_TRACE(); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::PRODUCER_DUMP: + case Channel::ChannelRequest::Method::PRODUCER_DUMP: { - json data = json::object(); + auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - FillJson(data); - - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_Producer_DumpResponse, dumpOffset); break; } - case Channel::ChannelRequest::MethodId::PRODUCER_GET_STATS: + case Channel::ChannelRequest::Method::PRODUCER_GET_STATS: { - json data = json::array(); - - FillJsonStats(data); + auto responseOffset = FillBufferStats(request->GetBufferBuilder()); - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_Producer_GetStatsResponse, responseOffset); break; } - case Channel::ChannelRequest::MethodId::PRODUCER_PAUSE: + case Channel::ChannelRequest::Method::PRODUCER_PAUSE: { if (this->paused) { @@ -533,7 +386,7 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::PRODUCER_RESUME: + case Channel::ChannelRequest::Method::PRODUCER_RESUME: { if (!this->paused) { @@ -574,23 +427,16 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::PRODUCER_ENABLE_TRACE_EVENT: + case Channel::ChannelRequest::Method::PRODUCER_ENABLE_TRACE_EVENT: { - auto jsonTypesIt = request->data.find("types"); - - // Disable all if no entries. - if (jsonTypesIt == request->data.end() || !jsonTypesIt->is_array()) - MS_THROW_TYPE_ERROR("wrong types (not an array)"); + const auto* body = request->data->body_as(); // Reset traceEventTypes. struct TraceEventTypes newTraceEventTypes; - for (const auto& type : *jsonTypesIt) + for (const auto& type : *body->events()) { - if (!type.is_string()) - MS_THROW_TYPE_ERROR("wrong type (not a string)"); - - const std::string typeStr = type.get(); + const auto typeStr = type->str(); if (typeStr == "rtp") newTraceEventTypes.rtp = true; @@ -613,28 +459,28 @@ namespace RTC default: { - MS_THROW_ERROR("unknown method '%s'", request->method.c_str()); + MS_THROW_ERROR("unknown method '%s'", request->methodCStr); } } } - void Producer::HandleNotification(PayloadChannel::PayloadChannelNotification* notification) + void Producer::HandleNotification(Channel::ChannelNotification* notification) { MS_TRACE(); - switch (notification->eventId) + switch (notification->event) { - case PayloadChannel::PayloadChannelNotification::EventId::PRODUCER_SEND: + case Channel::ChannelNotification::Event::PRODUCER_SEND: { - const auto* data = notification->payload; - auto len = notification->payloadLen; + const auto* body = notification->data->body_as(); + auto len = body->data()->size(); // Increase receive transmission. this->listener->OnProducerReceiveData(this, len); if (len > RTC::MtuSize + 100) { - MS_WARN_TAG(rtp, "given RTP packet exceeds maximum size [len:%zu]", len); + MS_WARN_TAG(rtp, "given RTP packet exceeds maximum size [len:%i]", len); break; } @@ -644,7 +490,7 @@ namespace RTC Producer::buffer = new uint8_t[RTC::MtuSize + 100]; // Copy the received packet into this buffer so it can be expanded later. - std::memcpy(Producer::buffer, data, static_cast(len)); + std::memcpy(Producer::buffer, body->data()->data(), static_cast(len)); RTC::RtpPacket* packet = RTC::RtpPacket::Parse(Producer::buffer, len); @@ -663,7 +509,7 @@ namespace RTC default: { - MS_ERROR("unknown event '%s'", notification->event.c_str()); + MS_ERROR("unknown event '%s'", notification->eventCStr); } } } @@ -1503,13 +1349,17 @@ namespace RTC this->videoOrientation.flip = flip; this->videoOrientation.rotation = rotation; - json data = json::object(); - - data["camera"] = this->videoOrientation.camera; - data["flip"] = this->videoOrientation.flip; - data["rotation"] = this->videoOrientation.rotation; - - this->shared->channelNotifier->Emit(this->id, "videoorientationchange", data); + auto notification = FBS::Producer::CreateVideoOrientationChangeNotification( + this->shared->channelNotifier->GetBufferBuilder(), + this->videoOrientation.camera, + this->videoOrientation.flip, + this->videoOrientation.rotation); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::PRODUCER_VIDEO_ORIENTATION_CHANGE, + FBS::Notification::Body::FBS_Producer_VideoOrientationChangeNotification, + notification); } } } @@ -1519,27 +1369,28 @@ namespace RTC { MS_TRACE(); - json data = json::array(); + std::vector> scores; - for (auto* rtpStream : this->rtpStreamByEncodingIdx) + for (const auto* rtpStream : this->rtpStreamByEncodingIdx) { if (!rtpStream) continue; - data.emplace_back(json::value_t::object); - - auto& jsonEntry = data[data.size() - 1]; - - jsonEntry["encodingIdx"] = rtpStream->GetEncodingIdx(); - jsonEntry["ssrc"] = rtpStream->GetSsrc(); - - if (!rtpStream->GetRid().empty()) - jsonEntry["rid"] = rtpStream->GetRid(); - - jsonEntry["score"] = rtpStream->GetScore(); + scores.emplace_back(FBS::Producer::CreateScoreDirect( + this->shared->channelNotifier->GetBufferBuilder(), + rtpStream->GetSsrc(), + !rtpStream->GetRid().empty() ? rtpStream->GetRid().c_str() : nullptr, + rtpStream->GetScore())); } - this->shared->channelNotifier->Emit(this->id, "score", data); + auto notification = FBS::Producer::CreateScoreNotificationDirect( + this->shared->channelNotifier->GetBufferBuilder(), &scores); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::PRODUCER_SCORE, + FBS::Notification::Body::FBS_Producer_ScoreNotification, + notification); } inline void Producer::EmitTraceEventRtpAndKeyFrameTypes(RTC::RtpPacket* packet, bool isRtx) const @@ -1548,33 +1399,33 @@ namespace RTC if (this->traceEventTypes.keyframe && packet->IsKeyFrame()) { - json data = json::object(); - - data["type"] = "keyframe"; - data["timestamp"] = DepLibUV::GetTimeMs(); - data["direction"] = "in"; - - packet->FillJson(data["info"]); - - if (isRtx) - data["info"]["isRtx"] = true; - - this->shared->channelNotifier->Emit(this->id, "trace", data); + auto traceInfo = FBS::Producer::CreateKeyFrameTraceInfo( + this->shared->channelNotifier->GetBufferBuilder(), isRtx); + + auto notification = FBS::Producer::CreateTraceNotification( + this->shared->channelNotifier->GetBufferBuilder(), + FBS::Producer::TraceType::KEYFRAME, + DepLibUV::GetTimeMs(), + FBS::Producer::TraceDirection::DIRECTION_IN, + FBS::Producer::TraceInfo::KeyFrameTraceInfo, + traceInfo.Union()); + + EmitTraceEvent(notification); } else if (this->traceEventTypes.rtp) { - json data = json::object(); - - data["type"] = "rtp"; - data["timestamp"] = DepLibUV::GetTimeMs(); - data["direction"] = "in"; - - packet->FillJson(data["info"]); - - if (isRtx) - data["info"]["isRtx"] = true; - - this->shared->channelNotifier->Emit(this->id, "trace", data); + auto traceInfo = + FBS::Producer::CreateRtpTraceInfo(this->shared->channelNotifier->GetBufferBuilder(), isRtx); + + auto notification = FBS::Producer::CreateTraceNotification( + this->shared->channelNotifier->GetBufferBuilder(), + FBS::Producer::TraceType::RTP, + DepLibUV::GetTimeMs(), + FBS::Producer::TraceDirection::DIRECTION_IN, + FBS::Producer::TraceInfo::RtpTraceInfo, + traceInfo.Union()); + + EmitTraceEvent(notification); } } @@ -1585,14 +1436,18 @@ namespace RTC if (!this->traceEventTypes.pli) return; - json data = json::object(); + auto traceInfo = + FBS::Producer::CreatePliTraceInfo(this->shared->channelNotifier->GetBufferBuilder(), ssrc); - data["type"] = "pli"; - data["timestamp"] = DepLibUV::GetTimeMs(); - data["direction"] = "out"; - data["info"]["ssrc"] = ssrc; + auto notification = FBS::Producer::CreateTraceNotification( + this->shared->channelNotifier->GetBufferBuilder(), + FBS::Producer::TraceType::PLI, + DepLibUV::GetTimeMs(), + FBS::Producer::TraceDirection::DIRECTION_OUT, + FBS::Producer::TraceInfo::PliTraceInfo, + traceInfo.Union()); - this->shared->channelNotifier->Emit(this->id, "trace", data); + EmitTraceEvent(notification); } inline void Producer::EmitTraceEventFirType(uint32_t ssrc) const @@ -1602,14 +1457,18 @@ namespace RTC if (!this->traceEventTypes.fir) return; - json data = json::object(); + auto traceInfo = + FBS::Producer::CreateFirTraceInfo(this->shared->channelNotifier->GetBufferBuilder(), ssrc); - data["type"] = "fir"; - data["timestamp"] = DepLibUV::GetTimeMs(); - data["direction"] = "out"; - data["info"]["ssrc"] = ssrc; + auto notification = FBS::Producer::CreateTraceNotification( + this->shared->channelNotifier->GetBufferBuilder(), + FBS::Producer::TraceType::FIR, + DepLibUV::GetTimeMs(), + FBS::Producer::TraceDirection::DIRECTION_OUT, + FBS::Producer::TraceInfo::FirTraceInfo, + traceInfo.Union()); - this->shared->channelNotifier->Emit(this->id, "trace", data); + EmitTraceEvent(notification); } inline void Producer::EmitTraceEventNackType() const @@ -1619,14 +1478,25 @@ namespace RTC if (!this->traceEventTypes.nack) return; - json data = json::object(); + auto notification = FBS::Producer::CreateTraceNotification( + this->shared->channelNotifier->GetBufferBuilder(), + FBS::Producer::TraceType::NACK, + DepLibUV::GetTimeMs(), + FBS::Producer::TraceDirection::DIRECTION_OUT); - data["type"] = "nack"; - data["timestamp"] = DepLibUV::GetTimeMs(); - data["direction"] = "out"; - data["info"] = json::object(); + EmitTraceEvent(notification); + } - this->shared->channelNotifier->Emit(this->id, "trace", data); + inline void Producer::EmitTraceEvent( + flatbuffers::Offset& notification) const + { + MS_TRACE(); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::PRODUCER_TRACE, + FBS::Notification::Body::FBS_Producer_TraceNotification, + notification); } inline void Producer::OnRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) diff --git a/worker/src/RTC/Router.cpp b/worker/src/RTC/Router.cpp index b56dc1c345..92b7bfacde 100644 --- a/worker/src/RTC/Router.cpp +++ b/worker/src/RTC/Router.cpp @@ -25,8 +25,7 @@ namespace RTC this->shared->channelMessageRegistrator->RegisterHandler( this->id, /*channelRequestHandler*/ this, - /*payloadChannelRequestHandler*/ nullptr, - /*payloadChannelNotificationHandler*/ nullptr); + /*ChannelNotificationHandler*/ nullptr); } Router::~Router() @@ -63,227 +62,198 @@ namespace RTC this->mapDataProducers.clear(); } - void Router::FillJson(json& jsonObject) const + flatbuffers::Offset Router::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Add id. - jsonObject["id"] = this->id; - // Add transportIds. - jsonObject["transportIds"] = json::array(); - auto jsonTransportIdsIt = jsonObject.find("transportIds"); + std::vector> transportIds; + transportIds.reserve(this->mapTransports.size()); for (const auto& kv : this->mapTransports) { const auto& transportId = kv.first; - jsonTransportIdsIt->emplace_back(transportId); + transportIds.push_back(builder.CreateString(transportId)); } // Add rtpObserverIds. - jsonObject["rtpObserverIds"] = json::array(); - auto jsonRtpObserverIdsIt = jsonObject.find("rtpObserverIds"); + std::vector> rtpObserverIds; + rtpObserverIds.reserve(this->mapRtpObservers.size()); for (const auto& kv : this->mapRtpObservers) { const auto& rtpObserverId = kv.first; - jsonRtpObserverIdsIt->emplace_back(rtpObserverId); + rtpObserverIds.push_back(builder.CreateString(rtpObserverId)); } // Add mapProducerIdConsumerIds. - jsonObject["mapProducerIdConsumerIds"] = json::object(); - auto jsonMapProducerConsumersIt = jsonObject.find("mapProducerIdConsumerIds"); + std::vector> mapProducerIdConsumerIds; + mapProducerIdConsumerIds.reserve(this->mapProducerConsumers.size()); for (const auto& kv : this->mapProducerConsumers) { auto* producer = kv.first; const auto& consumers = kv.second; - (*jsonMapProducerConsumersIt)[producer->id] = json::array(); - auto jsonProducerIdIt = jsonMapProducerConsumersIt->find(producer->id); + std::vector> consumerIds; + consumerIds.reserve(consumers.size()); for (auto* consumer : consumers) { - jsonProducerIdIt->emplace_back(consumer->id); + consumerIds.emplace_back(builder.CreateString(consumer->id)); } + + mapProducerIdConsumerIds.emplace_back( + FBS::Common::CreateStringStringArrayDirect(builder, producer->id.c_str(), &consumerIds)); } // Add mapConsumerIdProducerId. - jsonObject["mapConsumerIdProducerId"] = json::object(); - auto jsonMapConsumerProducerIt = jsonObject.find("mapConsumerIdProducerId"); + std::vector> mapConsumerIdProducerId; + mapConsumerIdProducerId.reserve(this->mapConsumerProducer.size()); for (const auto& kv : this->mapConsumerProducer) { auto* consumer = kv.first; auto* producer = kv.second; - (*jsonMapConsumerProducerIt)[consumer->id] = producer->id; + mapConsumerIdProducerId.emplace_back( + FBS::Common::CreateStringStringDirect(builder, consumer->id.c_str(), producer->id.c_str())); } // Add mapProducerIdObserverIds. - jsonObject["mapProducerIdObserverIds"] = json::object(); - auto jsonMapProducerRtpObserversIt = jsonObject.find("mapProducerIdObserverIds"); + std::vector> mapProducerIdObserverIds; + mapProducerIdObserverIds.reserve(this->mapProducerRtpObservers.size()); for (const auto& kv : this->mapProducerRtpObservers) { auto* producer = kv.first; const auto& rtpObservers = kv.second; - (*jsonMapProducerRtpObserversIt)[producer->id] = json::array(); - auto jsonProducerIdIt = jsonMapProducerRtpObserversIt->find(producer->id); + std::vector> observerIds; + observerIds.reserve(rtpObservers.size()); for (auto* rtpObserver : rtpObservers) { - jsonProducerIdIt->emplace_back(rtpObserver->id); + observerIds.emplace_back(builder.CreateString(rtpObserver->id)); } + + mapProducerIdObserverIds.emplace_back( + FBS::Common::CreateStringStringArrayDirect(builder, producer->id.c_str(), &observerIds)); } // Add mapDataProducerIdDataConsumerIds. - jsonObject["mapDataProducerIdDataConsumerIds"] = json::object(); - auto jsonMapDataProducerDataConsumersIt = jsonObject.find("mapDataProducerIdDataConsumerIds"); + std::vector> mapDataProducerIdDataConsumerIds; + mapDataProducerIdDataConsumerIds.reserve(this->mapDataProducerDataConsumers.size()); for (const auto& kv : this->mapDataProducerDataConsumers) { auto* dataProducer = kv.first; const auto& dataConsumers = kv.second; - (*jsonMapDataProducerDataConsumersIt)[dataProducer->id] = json::array(); - auto jsonDataProducerIdIt = jsonMapDataProducerDataConsumersIt->find(dataProducer->id); + std::vector> dataConsumerIds; + dataConsumerIds.reserve(dataConsumers.size()); for (auto* dataConsumer : dataConsumers) { - jsonDataProducerIdIt->emplace_back(dataConsumer->id); + dataConsumerIds.emplace_back(builder.CreateString(dataConsumer->id)); } + + mapDataProducerIdDataConsumerIds.emplace_back(FBS::Common::CreateStringStringArrayDirect( + builder, dataProducer->id.c_str(), &dataConsumerIds)); } // Add mapDataConsumerIdDataProducerId. - jsonObject["mapDataConsumerIdDataProducerId"] = json::object(); - auto jsonMapDataConsumerDataProducerIt = jsonObject.find("mapDataConsumerIdDataProducerId"); + std::vector> mapDataConsumerIdDataProducerId; + mapDataConsumerIdDataProducerId.reserve(this->mapDataConsumerDataProducer.size()); for (const auto& kv : this->mapDataConsumerDataProducer) { auto* dataConsumer = kv.first; auto* dataProducer = kv.second; - (*jsonMapDataConsumerDataProducerIt)[dataConsumer->id] = dataProducer->id; + mapDataConsumerIdDataProducerId.emplace_back(FBS::Common::CreateStringStringDirect( + builder, dataConsumer->id.c_str(), dataProducer->id.c_str())); } + + return FBS::Router::CreateDumpResponseDirect( + builder, + this->id.c_str(), + &transportIds, + &rtpObserverIds, + &mapProducerIdConsumerIds, + &mapConsumerIdProducerId, + &mapProducerIdObserverIds, + &mapDataProducerIdDataConsumerIds, + &mapDataConsumerIdDataProducerId); } void Router::HandleRequest(Channel::ChannelRequest* request) { MS_TRACE(); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::ROUTER_DUMP: + case Channel::ChannelRequest::Method::ROUTER_DUMP: { - json data = json::object(); + auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - FillJson(data); - - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_Router_DumpResponse, dumpOffset); break; } - case Channel::ChannelRequest::MethodId::ROUTER_CREATE_WEBRTC_TRANSPORT: + case Channel::ChannelRequest::Method::ROUTER_CREATE_WEBRTC_TRANSPORT: { - std::string transportId; + const auto* body = request->data->body_as(); + + auto transportId = body->transportId()->str(); // This may throw. - SetNewTransportIdFromData(request->data, transportId); + CheckNoTransport(transportId); // This may throw. auto* webRtcTransport = - new RTC::WebRtcTransport(this->shared, transportId, this, request->data); + new RTC::WebRtcTransport(this->shared, transportId, this, body->options()); // Insert into the map. this->mapTransports[transportId] = webRtcTransport; MS_DEBUG_DEV("WebRtcTransport created [transportId:%s]", transportId.c_str()); - json data = json::object(); - - webRtcTransport->FillJson(data); + auto dumpOffset = webRtcTransport->FillBuffer(request->GetBufferBuilder()); - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_WebRtcTransport_DumpResponse, dumpOffset); break; } - case Channel::ChannelRequest::MethodId::ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER: + case Channel::ChannelRequest::Method::ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER: { - std::string transportId; + const auto* body = request->data->body_as(); + auto transportId = body->transportId()->str(); // This may throw. - SetNewTransportIdFromData(request->data, transportId); + CheckNoTransport(transportId); - auto jsonWebRtcServerIdIt = request->data.find("webRtcServerId"); + const auto* options = body->options(); + const auto* listenInfo = options->listen_as(); - if (jsonWebRtcServerIdIt == request->data.end() || !jsonWebRtcServerIdIt->is_string()) - { - MS_THROW_TYPE_ERROR("missing webRtcServerId"); - } - - std::string webRtcServerId = jsonWebRtcServerIdIt->get(); + auto webRtcServerId = listenInfo->webRtcServerId()->str(); auto* webRtcServer = this->listener->OnRouterNeedWebRtcServer(this, webRtcServerId); if (!webRtcServer) MS_THROW_ERROR("wrong webRtcServerId (no associated WebRtcServer found)"); - bool enableUdp{ true }; - auto jsonEnableUdpIt = request->data.find("enableUdp"); - - if (jsonEnableUdpIt != request->data.end()) - { - if (!jsonEnableUdpIt->is_boolean()) - MS_THROW_TYPE_ERROR("wrong enableUdp (not a boolean)"); - - enableUdp = jsonEnableUdpIt->get(); - } - - bool enableTcp{ false }; - auto jsonEnableTcpIt = request->data.find("enableTcp"); - - if (jsonEnableTcpIt != request->data.end()) - { - if (!jsonEnableTcpIt->is_boolean()) - MS_THROW_TYPE_ERROR("wrong enableTcp (not a boolean)"); - - enableTcp = jsonEnableTcpIt->get(); - } - - bool preferUdp{ false }; - auto jsonPreferUdpIt = request->data.find("preferUdp"); - - if (jsonPreferUdpIt != request->data.end()) - { - if (!jsonPreferUdpIt->is_boolean()) - MS_THROW_TYPE_ERROR("wrong preferUdp (not a boolean)"); - - preferUdp = jsonPreferUdpIt->get(); - } - - bool preferTcp{ false }; - auto jsonPreferTcpIt = request->data.find("preferTcp"); - - if (jsonPreferTcpIt != request->data.end()) - { - if (!jsonPreferTcpIt->is_boolean()) - MS_THROW_TYPE_ERROR("wrong preferTcp (not a boolean)"); - - preferTcp = jsonPreferTcpIt->get(); - } - - auto iceCandidates = - webRtcServer->GetIceCandidates(enableUdp, enableTcp, preferUdp, preferTcp); + auto iceCandidates = webRtcServer->GetIceCandidates( + options->enableUdp(), options->enableTcp(), options->preferUdp(), options->preferTcp()); // This may throw. auto* webRtcTransport = new RTC::WebRtcTransport( - this->shared, transportId, this, webRtcServer, iceCandidates, request->data); + this->shared, transportId, this, webRtcServer, iceCandidates, options); // Insert into the map. this->mapTransports[transportId] = webRtcTransport; @@ -291,95 +261,92 @@ namespace RTC MS_DEBUG_DEV( "WebRtcTransport with WebRtcServer created [transportId:%s]", transportId.c_str()); - json data = json::object(); + auto dumpOffset = webRtcTransport->FillBuffer(request->GetBufferBuilder()); - webRtcTransport->FillJson(data); - - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_WebRtcTransport_DumpResponse, dumpOffset); break; } - case Channel::ChannelRequest::MethodId::ROUTER_CREATE_PLAIN_TRANSPORT: + case Channel::ChannelRequest::Method::ROUTER_CREATE_PLAIN_TRANSPORT: { - std::string transportId; + const auto* body = request->data->body_as(); + auto transportId = body->transportId()->str(); - // This may throw - SetNewTransportIdFromData(request->data, transportId); + // This may throw. + CheckNoTransport(transportId); auto* plainTransport = - new RTC::PlainTransport(this->shared, transportId, this, request->data); + new RTC::PlainTransport(this->shared, transportId, this, body->options()); // Insert into the map. this->mapTransports[transportId] = plainTransport; MS_DEBUG_DEV("PlainTransport created [transportId:%s]", transportId.c_str()); - json data = json::object(); + auto dumpOffset = plainTransport->FillBuffer(request->GetBufferBuilder()); - plainTransport->FillJson(data); - - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_PlainTransport_DumpResponse, dumpOffset); break; } - case Channel::ChannelRequest::MethodId::ROUTER_CREATE_PIPE_TRANSPORT: + case Channel::ChannelRequest::Method::ROUTER_CREATE_PIPE_TRANSPORT: { - std::string transportId; + const auto* body = request->data->body_as(); + auto transportId = body->transportId()->str(); - // This may throw - SetNewTransportIdFromData(request->data, transportId); + // This may throw. + CheckNoTransport(transportId); - auto* pipeTransport = new RTC::PipeTransport(this->shared, transportId, this, request->data); + auto* pipeTransport = + new RTC::PipeTransport(this->shared, transportId, this, body->options()); // Insert into the map. this->mapTransports[transportId] = pipeTransport; MS_DEBUG_DEV("PipeTransport created [transportId:%s]", transportId.c_str()); - json data = json::object(); + auto dumpOffset = pipeTransport->FillBuffer(request->GetBufferBuilder()); - pipeTransport->FillJson(data); - - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_PipeTransport_DumpResponse, dumpOffset); break; } - case Channel::ChannelRequest::MethodId::ROUTER_CREATE_DIRECT_TRANSPORT: + case Channel::ChannelRequest::Method::ROUTER_CREATE_DIRECT_TRANSPORT: { - std::string transportId; + const auto* body = request->data->body_as(); + auto transportId = body->transportId()->str(); - // This may throw - SetNewTransportIdFromData(request->data, transportId); + // This may throw. + CheckNoTransport(transportId); auto* directTransport = - new RTC::DirectTransport(this->shared, transportId, this, request->data); + new RTC::DirectTransport(this->shared, transportId, this, body->options()); // Insert into the map. this->mapTransports[transportId] = directTransport; MS_DEBUG_DEV("DirectTransport created [transportId:%s]", transportId.c_str()); - json data = json::object(); + auto dumpOffset = directTransport->FillBuffer(request->GetBufferBuilder()); - directTransport->FillJson(data); - - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_DirectTransport_DumpResponse, dumpOffset); break; } - case Channel::ChannelRequest::MethodId::ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER: + case Channel::ChannelRequest::Method::ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER: { - std::string rtpObserverId; + const auto* body = request->data->body_as(); + auto rtpObserverId = body->activeSpeakerObserverId()->str(); // This may throw. - SetNewRtpObserverIdFromData(request->data, rtpObserverId); + CheckNoRtpObserver(rtpObserverId); auto* activeSpeakerObserver = - new RTC::ActiveSpeakerObserver(this->shared, rtpObserverId, this, request->data); + new RTC::ActiveSpeakerObserver(this->shared, rtpObserverId, this, body->options()); // Insert into the map. this->mapRtpObservers[rtpObserverId] = activeSpeakerObserver; @@ -391,15 +358,16 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::ROUTER_CREATE_AUDIO_LEVEL_OBSERVER: + case Channel::ChannelRequest::Method::ROUTER_CREATE_AUDIO_LEVEL_OBSERVER: { - std::string rtpObserverId; + const auto* body = request->data->body_as(); + auto rtpObserverId = body->rtpObserverId()->str(); - // This may throw - SetNewRtpObserverIdFromData(request->data, rtpObserverId); + // This may throw. + CheckNoRtpObserver(rtpObserverId); auto* audioLevelObserver = - new RTC::AudioLevelObserver(this->shared, rtpObserverId, this, request->data); + new RTC::AudioLevelObserver(this->shared, rtpObserverId, this, body->options()); // Insert into the map. this->mapRtpObservers[rtpObserverId] = audioLevelObserver; @@ -411,10 +379,13 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::ROUTER_CLOSE_TRANSPORT: + case Channel::ChannelRequest::Method::ROUTER_CLOSE_TRANSPORT: { + const auto* body = request->data->body_as(); + auto transportId = body->transportId()->str(); + // This may throw. - RTC::Transport* transport = GetTransportFromData(request->data); + RTC::Transport* transport = GetTransportById(transportId); // Tell the Transport to close all its Producers and Consumers so it will // notify us about their closures. @@ -433,10 +404,13 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::ROUTER_CLOSE_RTP_OBSERVER: + case Channel::ChannelRequest::Method::ROUTER_CLOSE_RTP_OBSERVER: { + const auto* body = request->data->body_as(); + auto rtpObserverId = body->rtpObserverId()->str(); + // This may throw. - RTC::RtpObserver* rtpObserver = GetRtpObserverFromData(request->data); + RTC::RtpObserver* rtpObserver = GetRtpObserverById(rtpObserverId); // Remove it from the map. this->mapRtpObservers.erase(rtpObserver->id); @@ -461,89 +435,45 @@ namespace RTC default: { - MS_THROW_ERROR("unknown method '%s'", request->method.c_str()); + MS_THROW_ERROR("unknown method '%s'", Channel::ChannelRequest::method2String[request->method]); } } } - void Router::SetNewTransportIdFromData(json& data, std::string& transportId) const + void Router::CheckNoTransport(const std::string& transportId) const { - MS_TRACE(); - - auto jsonTransportIdIt = data.find("transportId"); - - if (jsonTransportIdIt == data.end() || !jsonTransportIdIt->is_string()) - { - MS_THROW_TYPE_ERROR("missing transportId"); - } - - transportId.assign(jsonTransportIdIt->get()); - if (this->mapTransports.find(transportId) != this->mapTransports.end()) - { - MS_THROW_ERROR("a Transport with same transportId already exists"); - } + MS_THROW_ERROR("a Transport with same id already exists"); } - RTC::Transport* Router::GetTransportFromData(json& data) const + void Router::CheckNoRtpObserver(const std::string& rtpObserverId) const { - MS_TRACE(); - - auto jsonTransportIdIt = data.find("transportId"); - - if (jsonTransportIdIt == data.end() || !jsonTransportIdIt->is_string()) - { - MS_THROW_TYPE_ERROR("missing transportId"); - } - - auto it = this->mapTransports.find(jsonTransportIdIt->get()); - - if (it == this->mapTransports.end()) - MS_THROW_ERROR("Transport not found"); - - RTC::Transport* transport = it->second; - - return transport; + if (this->mapRtpObservers.find(rtpObserverId) != this->mapRtpObservers.end()) + MS_THROW_ERROR("an RtpObserver with same id already exists"); } - void Router::SetNewRtpObserverIdFromData(json& data, std::string& rtpObserverId) const + RTC::Transport* Router::GetTransportById(const std::string& transportId) const { MS_TRACE(); - auto jsonRtpObserverIdIt = data.find("rtpObserverId"); - - if (jsonRtpObserverIdIt == data.end() || !jsonRtpObserverIdIt->is_string()) - { - MS_THROW_TYPE_ERROR("missing rtpObserverId"); - } + auto it = this->mapTransports.find(transportId); - rtpObserverId.assign(jsonRtpObserverIdIt->get()); + if (this->mapTransports.find(transportId) == this->mapTransports.end()) + MS_THROW_ERROR("Transport not found"); - if (this->mapRtpObservers.find(rtpObserverId) != this->mapRtpObservers.end()) - { - MS_THROW_ERROR("an RtpObserver with same rtpObserverId already exists"); - } + return it->second; } - RTC::RtpObserver* Router::GetRtpObserverFromData(json& data) const + RTC::RtpObserver* Router::GetRtpObserverById(const std::string& rtpObserverId) const { MS_TRACE(); - auto jsonRtpObserverIdIt = data.find("rtpObserverId"); + auto it = this->mapRtpObservers.find(rtpObserverId); - if (jsonRtpObserverIdIt == data.end() || !jsonRtpObserverIdIt->is_string()) - { - MS_THROW_TYPE_ERROR("missing rtpObserverId"); - } - - auto it = this->mapRtpObservers.find(jsonRtpObserverIdIt->get()); - - if (it == this->mapRtpObservers.end()) + if (this->mapRtpObservers.find(rtpObserverId) == this->mapRtpObservers.end()) MS_THROW_ERROR("RtpObserver not found"); - RTC::RtpObserver* rtpObserver = it->second; - - return rtpObserver; + return it->second; } inline void Router::OnTransportNewProducer(RTC::Transport* /*transport*/, RTC::Producer* producer) @@ -759,7 +689,7 @@ namespace RTC } inline void Router::OnTransportNewConsumer( - RTC::Transport* /*transport*/, RTC::Consumer* consumer, std::string& producerId) + RTC::Transport* /*transport*/, RTC::Consumer* consumer, const std::string& producerId) { MS_TRACE(); diff --git a/worker/src/RTC/RtpDictionaries/Parameters.cpp b/worker/src/RTC/RtpDictionaries/Parameters.cpp index c51b8c9b9f..ab3ee0b776 100644 --- a/worker/src/RTC/RtpDictionaries/Parameters.cpp +++ b/worker/src/RTC/RtpDictionaries/Parameters.cpp @@ -8,104 +8,121 @@ namespace RTC { /* Instance methods. */ - void Parameters::FillJson(json& jsonObject) const + std::vector> Parameters::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Force it to be an object even if no key/values are added below. - jsonObject = json::object(); + std::vector> parameters; - for (auto& kv : this->mapKeyValues) + for (const auto& kv : this->mapKeyValues) { - auto& key = kv.first; - auto& value = kv.second; + const auto& key = kv.first; + const auto& value = kv.second; + + flatbuffers::Offset parameter; switch (value.type) { case Value::Type::BOOLEAN: - jsonObject[key] = value.booleanValue; + { + auto valueOffset = FBS::RtpParameters::CreateBoolean(builder, value.booleanValue); + + parameter = FBS::RtpParameters::CreateParameterDirect( + builder, key.c_str(), FBS::RtpParameters::Value::Boolean, valueOffset.Union()); + break; + } case Value::Type::INTEGER: - jsonObject[key] = value.integerValue; + { + auto valueOffset = FBS::RtpParameters::CreateInteger(builder, value.integerValue); + + parameters.emplace_back(FBS::RtpParameters::CreateParameterDirect( + builder, key.c_str(), FBS::RtpParameters::Value::Integer, valueOffset.Union())); + break; + } case Value::Type::DOUBLE: - jsonObject[key] = value.doubleValue; + { + auto valueOffset = FBS::RtpParameters::CreateDouble(builder, value.doubleValue); + + parameters.emplace_back(FBS::RtpParameters::CreateParameterDirect( + builder, key.c_str(), FBS::RtpParameters::Value::Double, valueOffset.Union())); + break; + } case Value::Type::STRING: - jsonObject[key] = value.stringValue; + { + auto valueOffset = + FBS::RtpParameters::CreateStringDirect(builder, value.stringValue.c_str()); + + parameters.emplace_back(FBS::RtpParameters::CreateParameterDirect( + builder, key.c_str(), FBS::RtpParameters::Value::String, valueOffset.Union())); + break; + } case Value::Type::ARRAY_OF_INTEGERS: - jsonObject[key] = value.arrayOfIntegers; + { + auto valueOffset = + FBS::RtpParameters::CreateIntegerArrayDirect(builder, &value.arrayOfIntegers); + + parameters.emplace_back(FBS::RtpParameters::CreateParameterDirect( + builder, key.c_str(), FBS::RtpParameters::Value::IntegerArray, valueOffset.Union())); + break; + } } } + + return parameters; } - void Parameters::Set(json& data) + void Parameters::Set(const flatbuffers::Vector>* data) { MS_TRACE(); - MS_ASSERT(data.is_object(), "data is not an object"); - - for (json::iterator it = data.begin(); it != data.end(); ++it) + for (const auto* parameter : *data) { - const std::string& key = it.key(); - auto& value = it.value(); + const auto key = parameter->name()->str(); - switch (value.type()) + switch (parameter->value_type()) { - case json::value_t::boolean: + case FBS::RtpParameters::Value::Boolean: { - this->mapKeyValues.emplace(key, Value(value.get())); + this->mapKeyValues.emplace( + key, Value((parameter->value_as_Boolean()->value() == 0) ? false : true)); break; } - case json::value_t::number_integer: - case json::value_t::number_unsigned: + case FBS::RtpParameters::Value::Integer: { - this->mapKeyValues.emplace(key, Value(value.get())); + this->mapKeyValues.emplace(key, Value(parameter->value_as_Integer()->value())); break; } - case json::value_t::number_float: + case FBS::RtpParameters::Value::Double: { - this->mapKeyValues.emplace(key, Value(value.get())); + this->mapKeyValues.emplace(key, Value(parameter->value_as_Double()->value())); break; } - case json::value_t::string: + case FBS::RtpParameters::Value::String: { - this->mapKeyValues.emplace(key, Value(value.get())); + this->mapKeyValues.emplace(key, Value(parameter->value_as_String()->value()->str())); break; } - case json::value_t::array: + case FBS::RtpParameters::Value::IntegerArray: { - std::vector arrayOfIntegers; - bool isValid = true; - - for (auto& entry : value) - { - if (!entry.is_number_integer()) - { - isValid = false; - - break; - } - - arrayOfIntegers.emplace_back(entry.get()); - } - - if (!arrayOfIntegers.empty() && isValid) - this->mapKeyValues.emplace(key, Value(arrayOfIntegers)); + this->mapKeyValues.emplace(key, Value(parameter->value_as_IntegerArray()->value())); break; } @@ -124,7 +141,7 @@ namespace RTC if (it == this->mapKeyValues.end()) return false; - auto& value = it->second; + const auto& value = it->second; return value.type == Value::Type::BOOLEAN; } @@ -138,7 +155,7 @@ namespace RTC if (it == this->mapKeyValues.end()) return false; - auto& value = it->second; + const auto& value = it->second; return value.type == Value::Type::INTEGER; } @@ -152,7 +169,7 @@ namespace RTC if (it == this->mapKeyValues.end()) return false; - auto& value = it->second; + const auto& value = it->second; return value.type == Value::Type::INTEGER && value.integerValue >= 0; } @@ -166,7 +183,7 @@ namespace RTC if (it == this->mapKeyValues.end()) return false; - auto& value = it->second; + const auto& value = it->second; return value.type == Value::Type::DOUBLE; } @@ -180,7 +197,7 @@ namespace RTC if (it == this->mapKeyValues.end()) return false; - auto& value = it->second; + const auto& value = it->second; return value.type == Value::Type::STRING; } @@ -194,7 +211,7 @@ namespace RTC if (it == this->mapKeyValues.end()) return false; - auto& value = it->second; + const auto& value = it->second; return value.type == Value::Type::ARRAY_OF_INTEGERS; } @@ -208,8 +225,8 @@ namespace RTC if (it == this->mapKeyValues.end()) return false; - auto& value = it->second; - auto& array = value.arrayOfIntegers; + const auto& value = it->second; + const auto& array = value.arrayOfIntegers; return std::find(array.begin(), array.end(), integer) != array.end(); } @@ -222,7 +239,7 @@ namespace RTC MS_ASSERT(it != this->mapKeyValues.end(), "key does not exist [key:%s]", key.c_str()); - auto& value = it->second; + const auto& value = it->second; return value.booleanValue; } @@ -235,7 +252,7 @@ namespace RTC MS_ASSERT(it != this->mapKeyValues.end(), "key does not exist [key:%s]", key.c_str()); - auto& value = it->second; + const auto& value = it->second; return value.integerValue; } @@ -248,7 +265,7 @@ namespace RTC MS_ASSERT(it != this->mapKeyValues.end(), "key does not exist [key:%s]", key.c_str()); - auto& value = it->second; + const auto& value = it->second; return value.doubleValue; } @@ -261,7 +278,7 @@ namespace RTC MS_ASSERT(it != this->mapKeyValues.end(), "key does not exist [key:%s]", key.c_str()); - auto& value = it->second; + const auto& value = it->second; return value.stringValue; } @@ -274,7 +291,7 @@ namespace RTC MS_ASSERT(it != this->mapKeyValues.end(), "key does not exist [key:%s]", key.c_str()); - auto& value = it->second; + const auto& value = it->second; return value.arrayOfIntegers; } diff --git a/worker/src/RTC/RtpDictionaries/RtcpFeedback.cpp b/worker/src/RTC/RtpDictionaries/RtcpFeedback.cpp index 4c0f90f054..40a27c5614 100644 --- a/worker/src/RTC/RtpDictionaries/RtcpFeedback.cpp +++ b/worker/src/RTC/RtpDictionaries/RtcpFeedback.cpp @@ -9,36 +9,23 @@ namespace RTC { /* Instance methods. */ - RtcpFeedback::RtcpFeedback(json& data) + RtcpFeedback::RtcpFeedback(const FBS::RtpParameters::RtcpFeedback* data) { MS_TRACE(); - if (!data.is_object()) - MS_THROW_TYPE_ERROR("data is not an object"); - - auto jsonTypeIt = data.find("type"); - auto jsonParameterIt = data.find("parameter"); - - // type is mandatory. - if (jsonTypeIt == data.end() || !jsonTypeIt->is_string()) - MS_THROW_TYPE_ERROR("missing type"); - - this->type = jsonTypeIt->get(); + this->type = data->type()->str(); // parameter is optional. - if (jsonParameterIt != data.end() && jsonParameterIt->is_string()) - this->parameter = jsonParameterIt->get(); + if (flatbuffers::IsFieldPresent(data, FBS::RtpParameters::RtcpFeedback::VT_PARAMETER)) + this->parameter = data->parameter()->str(); } - void RtcpFeedback::FillJson(json& jsonObject) const + flatbuffers::Offset RtcpFeedback::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Add type. - jsonObject["type"] = this->type; - - // Add parameter (optional). - if (this->parameter.length() > 0) - jsonObject["parameter"] = this->parameter; + return FBS::RtpParameters::CreateRtcpFeedbackDirect( + builder, this->type.c_str(), this->parameter.length() > 0 ? this->parameter.c_str() : nullptr); } } // namespace RTC diff --git a/worker/src/RTC/RtpDictionaries/RtcpParameters.cpp b/worker/src/RTC/RtpDictionaries/RtcpParameters.cpp index fe77eeebd1..c98713a9f9 100644 --- a/worker/src/RTC/RtpDictionaries/RtcpParameters.cpp +++ b/worker/src/RTC/RtpDictionaries/RtcpParameters.cpp @@ -10,50 +10,24 @@ namespace RTC { /* Instance methods. */ - RtcpParameters::RtcpParameters(json& data) + RtcpParameters::RtcpParameters(const FBS::RtpParameters::RtcpParameters* data) { MS_TRACE(); - if (!data.is_object()) - MS_THROW_TYPE_ERROR("data is not an object"); - - auto jsonCnameIt = data.find("cname"); - auto jsonSsrcIt = data.find("ssrc"); - auto jsonRedicedSizeIt = data.find("reducedSize"); - // cname is optional. - if (jsonCnameIt != data.end() && jsonCnameIt->is_string()) - this->cname = jsonCnameIt->get(); - - // ssrc is optional. - // clang-format off - if ( - jsonSsrcIt != data.end() && - Utils::Json::IsPositiveInteger(*jsonSsrcIt) - ) - // clang-format on - { - this->ssrc = jsonSsrcIt->get(); - } + if (flatbuffers::IsFieldPresent(data, FBS::RtpParameters::RtcpParameters::VT_CNAME)) + this->cname = data->cname()->str(); - // reducedSize is optional. - if (jsonRedicedSizeIt != data.end() && jsonRedicedSizeIt->is_boolean()) - this->reducedSize = jsonRedicedSizeIt->get(); + // reducedSize is optional, default value is true. + this->reducedSize = data->reducedSize(); } - void RtcpParameters::FillJson(json& jsonObject) const + flatbuffers::Offset RtcpParameters::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Add cname. - if (!this->cname.empty()) - jsonObject["cname"] = this->cname; - - // Add ssrc. - if (this->ssrc != 0u) - jsonObject["ssrc"] = this->ssrc; - - // Add reducedSize. - jsonObject["reducedSize"] = this->reducedSize; + return FBS::RtpParameters::CreateRtcpParametersDirect( + builder, this->cname.c_str(), this->reducedSize); } } // namespace RTC diff --git a/worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp b/worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp index caab4b63ce..92655338ef 100644 --- a/worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp +++ b/worker/src/RTC/RtpDictionaries/RtpCodecParameters.cpp @@ -10,77 +10,37 @@ namespace RTC { /* Instance methods. */ - RtpCodecParameters::RtpCodecParameters(json& data) + RtpCodecParameters::RtpCodecParameters(const FBS::RtpParameters::RtpCodecParameters* data) { MS_TRACE(); - if (!data.is_object()) - MS_THROW_TYPE_ERROR("data is not an object"); - - auto jsonMimeTypeIt = data.find("mimeType"); - auto jsonPayloadTypeIt = data.find("payloadType"); - auto jsonClockRateIt = data.find("clockRate"); - auto jsonChannelsIt = data.find("channels"); - auto jsonParametersIt = data.find("parameters"); - auto jsonRtcpFeedbackIt = data.find("rtcpFeedback"); - - // mimeType is mandatory. - if (jsonMimeTypeIt == data.end() || !jsonMimeTypeIt->is_string()) - MS_THROW_TYPE_ERROR("missing mimeType"); - // Set MIME field. // This may throw. - this->mimeType.SetMimeType(jsonMimeTypeIt->get()); - - // payloadType is mandatory. - // clang-format off - if ( - jsonPayloadTypeIt == data.end() || - !Utils::Json::IsPositiveInteger(*jsonPayloadTypeIt) - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("missing payloadType"); - } - - this->payloadType = jsonPayloadTypeIt->get(); + this->mimeType.SetMimeType(data->mimeType()->str()); - // clockRate is mandatory. - // clang-format off - if ( - jsonClockRateIt == data.end() || - !Utils::Json::IsPositiveInteger(*jsonClockRateIt) - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("missing clockRate"); - } + // payloadType. + this->payloadType = data->payloadType(); - this->clockRate = jsonClockRateIt->get(); + // clockRate. + this->clockRate = data->clockRate(); // channels is optional. - // clang-format off - if ( - jsonChannelsIt != data.end() && - Utils::Json::IsPositiveInteger(*jsonChannelsIt) - ) - // clang-format on + if (data->channels().has_value()) { - this->channels = jsonChannelsIt->get(); + this->channels = data->channels().value(); } // parameters is optional. - if (jsonParametersIt != data.end() && jsonParametersIt->is_object()) - this->parameters.Set(*jsonParametersIt); + if (flatbuffers::IsFieldPresent(data, FBS::RtpParameters::RtpCodecParameters::VT_PARAMETERS)) + this->parameters.Set(data->parameters()); // rtcpFeedback is optional. - if (jsonRtcpFeedbackIt != data.end() && jsonRtcpFeedbackIt->is_array()) + if (flatbuffers::IsFieldPresent(data, FBS::RtpParameters::RtpCodecParameters::VT_RTCPFEEDBACK)) { - this->rtcpFeedback.reserve(jsonRtcpFeedbackIt->size()); + this->rtcpFeedback.reserve(data->rtcpFeedback()->size()); - for (auto& entry : *jsonRtcpFeedbackIt) + for (const auto* entry : *data->rtcpFeedback()) { - // This may throw due the constructor of RTC::RtcpFeedback. this->rtcpFeedback.emplace_back(entry); } } @@ -89,39 +49,29 @@ namespace RTC CheckCodec(); } - void RtpCodecParameters::FillJson(json& jsonObject) const + flatbuffers::Offset RtpCodecParameters::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Add mimeType. - jsonObject["mimeType"] = this->mimeType.ToString(); + auto parameters = this->parameters.FillBuffer(builder); - // Add payloadType. - jsonObject["payloadType"] = this->payloadType; + std::vector> rtcpFeedback; + rtcpFeedback.reserve(this->rtcpFeedback.size()); - // Add clockRate. - jsonObject["clockRate"] = this->clockRate; - - // Add channels. - if (this->channels > 1) - jsonObject["channels"] = this->channels; - - // Add parameters. - this->parameters.FillJson(jsonObject["parameters"]); - - // Add rtcpFeedback. - jsonObject["rtcpFeedback"] = json::array(); - auto jsonRtcpFeedbackIt = jsonObject.find("rtcpFeedback"); - - for (size_t i{ 0 }; i < this->rtcpFeedback.size(); ++i) + for (const auto& fb : this->rtcpFeedback) { - jsonRtcpFeedbackIt->emplace_back(json::value_t::object); - - auto& jsonEntry = (*jsonRtcpFeedbackIt)[i]; - auto& fb = this->rtcpFeedback[i]; - - fb.FillJson(jsonEntry); + rtcpFeedback.emplace_back(fb.FillBuffer(builder)); } + + return FBS::RtpParameters::CreateRtpCodecParametersDirect( + builder, + this->mimeType.ToString().c_str(), + this->payloadType, + this->clockRate, + this->channels > 1 ? flatbuffers::Optional(this->channels) : flatbuffers::nullopt, + ¶meters, + &rtcpFeedback); } inline void RtpCodecParameters::CheckCodec() diff --git a/worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp b/worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp index 6c745802bd..a9326752be 100644 --- a/worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp +++ b/worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp @@ -12,80 +12,44 @@ namespace RTC { /* Instance methods. */ - RtpEncodingParameters::RtpEncodingParameters(json& data) + RtpEncodingParameters::RtpEncodingParameters(const FBS::RtpParameters::RtpEncodingParameters* data) { MS_TRACE(); - if (!data.is_object()) - MS_THROW_TYPE_ERROR("data is not an object"); - - auto jsonSsrcIt = data.find("ssrc"); - auto jsonRidIt = data.find("rid"); - auto jsonCodecPayloadTypeIt = data.find("codecPayloadType"); - auto jsonRtxIt = data.find("rtx"); - auto jsonMaxBitrateIt = data.find("maxBitrate"); - auto jsonMaxFramerateIt = data.find("maxFramerate"); - auto jsonDtxIt = data.find("dtx"); - auto jsonScalabilityModeIt = data.find("scalabilityMode"); - // ssrc is optional. - // clang-format off - if ( - jsonSsrcIt != data.end() && - Utils::Json::IsPositiveInteger(*jsonSsrcIt) - ) - // clang-format on - { - this->ssrc = jsonSsrcIt->get(); - } + if (data->ssrc().has_value()) + this->ssrc = data->ssrc().value(); // rid is optional. - if (jsonRidIt != data.end() && jsonRidIt->is_string()) - this->rid = jsonRidIt->get(); + if (flatbuffers::IsFieldPresent(data, FBS::RtpParameters::RtpEncodingParameters::VT_RID)) + this->rid = data->rid()->str(); // codecPayloadType is optional. - // clang-format off - if ( - jsonCodecPayloadTypeIt != data.end() && - Utils::Json::IsPositiveInteger(*jsonCodecPayloadTypeIt) - ) - // clang-format on + if (data->codecPayloadType().has_value()) { - this->codecPayloadType = jsonCodecPayloadTypeIt->get(); + this->codecPayloadType = data->codecPayloadType().value(); this->hasCodecPayloadType = true; } // rtx is optional. - // This may throw. - if (jsonRtxIt != data.end() && jsonRtxIt->is_object()) + if (flatbuffers::IsFieldPresent(data, FBS::RtpParameters::RtpEncodingParameters::VT_RTX)) { - this->rtx = RtpRtxParameters(*jsonRtxIt); + this->rtx = RtpRtxParameters(data->rtx()); this->hasRtx = true; } // maxBitrate is optional. - // clang-format off - if ( - jsonMaxBitrateIt != data.end() && - Utils::Json::IsPositiveInteger(*jsonMaxBitrateIt) - ) - // clang-format on - { - this->maxBitrate = jsonMaxBitrateIt->get(); - } - - // maxFramerate is optional. - if (jsonMaxFramerateIt != data.end() && jsonMaxFramerateIt->is_number()) - this->maxFramerate = jsonMaxFramerateIt->get(); + if (data->maxBitrate().has_value()) + this->maxBitrate = data->maxBitrate().value(); - // dtx is optional. - if (jsonDtxIt != data.end() && jsonDtxIt->is_boolean()) - this->dtx = jsonDtxIt->get(); + // dtx is optional, default is false. + this->dtx = data->dtx(); // scalabilityMode is optional. - if (jsonScalabilityModeIt != data.end() && jsonScalabilityModeIt->is_string()) + if (flatbuffers::IsFieldPresent( + data, FBS::RtpParameters::RtpEncodingParameters::VT_SCALABILITYMODE)) { - std::string scalabilityMode = jsonScalabilityModeIt->get(); + const std::string scalabilityMode = data->scalabilityMode()->str(); static const std::regex ScalabilityModeRegex( "^[LS]([1-9]\\d{0,1})T([1-9]\\d{0,1})(_KEY)?.*", std::regex_constants::ECMAScript); @@ -112,48 +76,19 @@ namespace RTC } } - void RtpEncodingParameters::FillJson(json& jsonObject) const + flatbuffers::Offset RtpEncodingParameters::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Force it to be an object even if no key/values are added below. - jsonObject = json::object(); - - // Add ssrc. - if (this->ssrc != 0u) - jsonObject["ssrc"] = this->ssrc; - - // Add rid. - if (!this->rid.empty()) - jsonObject["rid"] = this->rid; - - // Add codecPayloadType. - if (this->hasCodecPayloadType) - jsonObject["codecPayloadType"] = this->codecPayloadType; - - // Add rtx. - if (this->hasRtx) - this->rtx.FillJson(jsonObject["rtx"]); - - // Add maxBitrate. - if (this->maxBitrate != 0u) - jsonObject["maxBitrate"] = this->maxBitrate; - - // Add maxFramerate. - if (this->maxFramerate > 0) - jsonObject["maxFramerate"] = this->maxFramerate; - - // Add dtx. - if (this->dtx) - jsonObject["dtx"] = this->dtx; - - // Add scalabilityMode. - if (!this->scalabilityMode.empty()) - { - jsonObject["scalabilityMode"] = this->scalabilityMode; - jsonObject["spatialLayers"] = this->spatialLayers; - jsonObject["temporalLayers"] = this->temporalLayers; - jsonObject["ksvc"] = this->ksvc; - } + return FBS::RtpParameters::CreateRtpEncodingParametersDirect( + builder, + this->ssrc != 0u ? flatbuffers::Optional(this->ssrc) : flatbuffers::nullopt, + this->rid.size() > 0 ? this->rid.c_str() : nullptr, + this->hasCodecPayloadType ? flatbuffers::Optional(this->codecPayloadType) + : flatbuffers::nullopt, + this->hasRtx ? this->rtx.FillBuffer(builder) : 0u, + this->dtx, + this->scalabilityMode.size() > 0 ? this->scalabilityMode.c_str() : nullptr); } } // namespace RTC diff --git a/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionParameters.cpp b/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionParameters.cpp index bb762881bc..9eadc74475 100644 --- a/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionParameters.cpp +++ b/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionParameters.cpp @@ -10,23 +10,13 @@ namespace RTC { /* Instance methods. */ - RtpHeaderExtensionParameters::RtpHeaderExtensionParameters(json& data) + RtpHeaderExtensionParameters::RtpHeaderExtensionParameters( + const FBS::RtpParameters::RtpHeaderExtensionParameters* const data) { MS_TRACE(); - if (!data.is_object()) - MS_THROW_TYPE_ERROR("data is not an object"); - - auto jsonUriIt = data.find("uri"); - auto jsonIdIt = data.find("id"); - auto jsonEncryptIt = data.find("encrypt"); - auto jsonParametersIt = data.find("parameters"); - // uri is mandatory. - if (jsonUriIt == data.end() || !jsonUriIt->is_string()) - MS_THROW_TYPE_ERROR("missing uri"); - - this->uri = jsonUriIt->get(); + this->uri = data->uri()->str(); if (this->uri.empty()) MS_THROW_TYPE_ERROR("empty uri"); @@ -34,39 +24,31 @@ namespace RTC // Get the type. this->type = RTC::RtpHeaderExtensionUri::GetType(this->uri); - // id is mandatory. - if (jsonIdIt == data.end() || !Utils::Json::IsPositiveInteger(*jsonIdIt)) - MS_THROW_TYPE_ERROR("missing id"); - - this->id = jsonIdIt->get(); + this->id = data->id(); // Don't allow id 0. if (this->id == 0u) MS_THROW_TYPE_ERROR("invalid id 0"); - // encrypt is optional. - if (jsonEncryptIt != data.end() && jsonEncryptIt->is_boolean()) - this->encrypt = jsonEncryptIt->get(); + // encrypt is false by default. + this->encrypt = data->encrypt(); // parameters is optional. - if (jsonParametersIt != data.end() && jsonParametersIt->is_object()) - this->parameters.Set(*jsonParametersIt); + if (flatbuffers::IsFieldPresent( + data, FBS::RtpParameters::RtpHeaderExtensionParameters::VT_PARAMETERS)) + { + this->parameters.Set(data->parameters()); + } } - void RtpHeaderExtensionParameters::FillJson(json& jsonObject) const + flatbuffers::Offset RtpHeaderExtensionParameters::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Add uri. - jsonObject["uri"] = this->uri; - - // Add id. - jsonObject["id"] = this->id; - - // Add encrypt. - jsonObject["encrypt"] = this->encrypt; + auto parameters = this->parameters.FillBuffer(builder); - // Add parameters. - this->parameters.FillJson(jsonObject["parameters"]); + return FBS::RtpParameters::CreateRtpHeaderExtensionParametersDirect( + builder, this->uri.c_str(), this->id, this->encrypt, ¶meters); } } // namespace RTC diff --git a/worker/src/RTC/RtpDictionaries/RtpParameters.cpp b/worker/src/RTC/RtpDictionaries/RtpParameters.cpp index 2a0010affa..a11567e89d 100644 --- a/worker/src/RTC/RtpDictionaries/RtpParameters.cpp +++ b/worker/src/RTC/RtpDictionaries/RtpParameters.cpp @@ -38,7 +38,7 @@ namespace RTC if (rtpParameters.encodings.size() == 1) { - auto& encoding = rtpParameters.encodings[0]; + const auto& encoding = rtpParameters.encodings[0]; const auto* mediaCodec = rtpParameters.GetCodecForEncoding(const_cast(encoding)); @@ -104,35 +104,22 @@ namespace RTC /* Instance methods. */ - RtpParameters::RtpParameters(json& data) + RtpParameters::RtpParameters(const FBS::RtpParameters::RtpParameters* data) { MS_TRACE(); - if (!data.is_object()) - MS_THROW_TYPE_ERROR("data is not an object"); - - auto jsonMidIt = data.find("mid"); - auto jsonCodecsIt = data.find("codecs"); - auto jsonEncodingsIt = data.find("encodings"); - auto jsonHeaderExtensionsIt = data.find("headerExtensions"); - auto jsonRtcpIt = data.find("rtcp"); - // mid is optional. - if (jsonMidIt != data.end() && jsonMidIt->is_string()) + if (data->mid()) { - this->mid = jsonMidIt->get(); + this->mid = data->mid()->str(); if (this->mid.empty()) MS_THROW_TYPE_ERROR("empty mid"); } - // codecs is mandatory. - if (jsonCodecsIt == data.end() || !jsonCodecsIt->is_array()) - MS_THROW_TYPE_ERROR("missing codecs"); + this->codecs.reserve(data->codecs()->size()); - this->codecs.reserve(jsonCodecsIt->size()); - - for (auto& entry : *jsonCodecsIt) + for (const auto* entry : *data->codecs()) { // This may throw due the constructor of RTC::RtpCodecParameters. this->codecs.emplace_back(entry); @@ -142,12 +129,12 @@ namespace RTC MS_THROW_TYPE_ERROR("empty codecs"); // encodings is mandatory. - if (jsonEncodingsIt == data.end() || !jsonEncodingsIt->is_array()) + if (!flatbuffers::IsFieldPresent(data, FBS::RtpParameters::RtpParameters::VT_ENCODINGS)) MS_THROW_TYPE_ERROR("missing encodings"); - this->encodings.reserve(jsonEncodingsIt->size()); + this->encodings.reserve(data->encodings()->size()); - for (auto& entry : *jsonEncodingsIt) + for (const auto* entry : *data->encodings()) { // This may throw due the constructor of RTC::RtpEncodingParameters. this->encodings.emplace_back(entry); @@ -157,11 +144,11 @@ namespace RTC MS_THROW_TYPE_ERROR("empty encodings"); // headerExtensions is optional. - if (jsonHeaderExtensionsIt != data.end() && jsonHeaderExtensionsIt->is_array()) + if (flatbuffers::IsFieldPresent(data, FBS::RtpParameters::RtpParameters::VT_HEADEREXTENSIONS)) { - this->headerExtensions.reserve(jsonHeaderExtensionsIt->size()); + this->headerExtensions.reserve(data->headerExtensions()->size()); - for (auto& entry : *jsonHeaderExtensionsIt) + for (const auto* entry : *data->headerExtensions()) { // This may throw due the constructor of RTC::RtpHeaderExtensionParameters. this->headerExtensions.emplace_back(entry); @@ -169,10 +156,10 @@ namespace RTC } // rtcp is optional. - if (jsonRtcpIt != data.end() && jsonRtcpIt->is_object()) + if (flatbuffers::IsFieldPresent(data, FBS::RtpParameters::RtpParameters::VT_RTCP)) { // This may throw. - this->rtcp = RTC::RtcpParameters(*jsonRtcpIt); + this->rtcp = RTC::RtcpParameters(data->rtcp()); this->hasRtcp = true; } @@ -181,61 +168,46 @@ namespace RTC ValidateEncodings(); } - void RtpParameters::FillJson(json& jsonObject) const + flatbuffers::Offset RtpParameters::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Add mid. - if (!this->mid.empty()) - jsonObject["mid"] = this->mid; - // Add codecs. - jsonObject["codecs"] = json::array(); - auto jsonCodecsIt = jsonObject.find("codecs"); + std::vector> codecs; + codecs.reserve(this->codecs.size()); - for (size_t i{ 0 }; i < this->codecs.size(); ++i) + for (const auto& codec : this->codecs) { - jsonCodecsIt->emplace_back(json::value_t::object); - - auto& jsonEntry = (*jsonCodecsIt)[i]; - auto& codec = this->codecs[i]; - - codec.FillJson(jsonEntry); + codecs.emplace_back(codec.FillBuffer(builder)); } // Add encodings. - jsonObject["encodings"] = json::array(); - auto jsonEncodingsIt = jsonObject.find("encodings"); + std::vector> encodings; + encodings.reserve(this->encodings.size()); - for (size_t i{ 0 }; i < this->encodings.size(); ++i) + for (const auto& encoding : this->encodings) { - jsonEncodingsIt->emplace_back(json::value_t::object); - - auto& jsonEntry = (*jsonEncodingsIt)[i]; - auto& encoding = this->encodings[i]; - - encoding.FillJson(jsonEntry); + encodings.emplace_back(encoding.FillBuffer(builder)); } // Add headerExtensions. - jsonObject["headerExtensions"] = json::array(); - auto jsonHeaderExtensionsIt = jsonObject.find("headerExtensions"); + std::vector> headerExtensions; + headerExtensions.reserve(this->headerExtensions.size()); - for (size_t i{ 0 }; i < this->headerExtensions.size(); ++i) + for (const auto& headerExtension : this->headerExtensions) { - jsonHeaderExtensionsIt->emplace_back(json::value_t::object); - - auto& jsonEntry = (*jsonHeaderExtensionsIt)[i]; - auto& headerExtension = this->headerExtensions[i]; - - headerExtension.FillJson(jsonEntry); + headerExtensions.emplace_back(headerExtension.FillBuffer(builder)); } // Add rtcp. + flatbuffers::Offset rtcp; + if (this->hasRtcp) - this->rtcp.FillJson(jsonObject["rtcp"]); - else - jsonObject["rtcp"] = json::object(); + rtcp = this->rtcp.FillBuffer(builder); + + return FBS::RtpParameters::CreateRtpParametersDirect( + builder, mid.c_str(), &codecs, &headerExtensions, &encodings, rtcp); } const RTC::RtpCodecParameters* RtpParameters::GetCodecForEncoding(RtpEncodingParameters& encoding) const @@ -247,7 +219,7 @@ namespace RTC for (; it != this->codecs.end(); ++it) { - auto& codec = *it; + const auto& codec = *it; if (codec.payloadType == payloadType) return std::addressof(codec); diff --git a/worker/src/RTC/RtpDictionaries/RtpRtxParameters.cpp b/worker/src/RTC/RtpDictionaries/RtpRtxParameters.cpp index eaf8726395..41272388b1 100644 --- a/worker/src/RTC/RtpDictionaries/RtpRtxParameters.cpp +++ b/worker/src/RTC/RtpDictionaries/RtpRtxParameters.cpp @@ -10,36 +10,18 @@ namespace RTC { /* Instance methods. */ - RtpRtxParameters::RtpRtxParameters(json& data) + RtpRtxParameters::RtpRtxParameters(const FBS::RtpParameters::Rtx* data) { MS_TRACE(); - if (!data.is_object()) - MS_THROW_TYPE_ERROR("data is not an object"); - - auto jsonSsrcIt = data.find("ssrc"); - - // ssrc is optional. - // clang-format off - if ( - jsonSsrcIt != data.end() && - Utils::Json::IsPositiveInteger(*jsonSsrcIt) - ) - // clang-format on - { - this->ssrc = jsonSsrcIt->get(); - } + this->ssrc = data->ssrc(); } - void RtpRtxParameters::FillJson(json& jsonObject) const + flatbuffers::Offset RtpRtxParameters::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Force it to be an object even if no key/values are added below. - jsonObject = json::object(); - - // Add ssrc (optional). - if (this->ssrc != 0u) - jsonObject["ssrc"] = this->ssrc; + return FBS::RtpParameters::CreateRtx(builder, this->ssrc); } } // namespace RTC diff --git a/worker/src/RTC/RtpListener.cpp b/worker/src/RTC/RtpListener.cpp index 5c21c60cf9..e8a4e43e24 100644 --- a/worker/src/RTC/RtpListener.cpp +++ b/worker/src/RTC/RtpListener.cpp @@ -10,44 +10,48 @@ namespace RTC { /* Instance methods. */ - void RtpListener::FillJson(json& jsonObject) const + flatbuffers::Offset RtpListener::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - jsonObject["ssrcTable"] = json::object(); - jsonObject["midTable"] = json::object(); - jsonObject["ridTable"] = json::object(); - - auto jsonSsrcTableIt = jsonObject.find("ssrcTable"); - auto jsonMidTableIt = jsonObject.find("midTable"); - auto jsonRidTableIt = jsonObject.find("ridTable"); - // Add ssrcTable. + std::vector> ssrcTable; + for (const auto& kv : this->ssrcTable) { auto ssrc = kv.first; auto* producer = kv.second; - (*jsonSsrcTableIt)[std::to_string(ssrc)] = producer->id; + ssrcTable.emplace_back( + FBS::Common::CreateUint32StringDirect(builder, ssrc, producer->id.c_str())); } // Add midTable. + std::vector> midTable; + for (const auto& kv : this->midTable) { const auto& mid = kv.first; auto* producer = kv.second; - (*jsonMidTableIt)[mid] = producer->id; + midTable.emplace_back( + FBS::Common::CreateStringStringDirect(builder, mid.c_str(), producer->id.c_str())); } // Add ridTable. + std::vector> ridTable; + for (const auto& kv : this->ridTable) { const auto& rid = kv.first; auto* producer = kv.second; - (*jsonRidTableIt)[rid] = producer->id; + ridTable.emplace_back( + FBS::Common::CreateStringStringDirect(builder, rid.c_str(), producer->id.c_str())); } + + return FBS::Transport::CreateRtpListenerDirect(builder, &ssrcTable, &midTable, &ridTable); } void RtpListener::AddProducer(RTC::Producer* producer) diff --git a/worker/src/RTC/RtpObserver.cpp b/worker/src/RTC/RtpObserver.cpp index e57dfe542b..b7db32ce1a 100644 --- a/worker/src/RTC/RtpObserver.cpp +++ b/worker/src/RTC/RtpObserver.cpp @@ -24,9 +24,9 @@ namespace RTC { MS_TRACE(); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::RTP_OBSERVER_PAUSE: + case Channel::ChannelRequest::Method::RTP_OBSERVER_PAUSE: { this->Pause(); @@ -35,7 +35,7 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::RTP_OBSERVER_RESUME: + case Channel::ChannelRequest::Method::RTP_OBSERVER_RESUME: { this->Resume(); @@ -44,10 +44,11 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::RTP_OBSERVER_ADD_PRODUCER: + case Channel::ChannelRequest::Method::RTP_OBSERVER_ADD_PRODUCER: { - // This may throw. - auto producerId = GetProducerIdFromData(request->data); + const auto* body = request->data->body_as(); + auto producerId = body->producerId()->str(); + RTC::Producer* producer = this->listener->RtpObserverGetProducer(this, producerId); this->AddProducer(producer); @@ -59,10 +60,11 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::RTP_OBSERVER_REMOVE_PRODUCER: + case Channel::ChannelRequest::Method::RTP_OBSERVER_REMOVE_PRODUCER: { - // This may throw. - auto producerId = GetProducerIdFromData(request->data); + const auto* body = request->data->body_as(); + auto producerId = body->producerId()->str(); + RTC::Producer* producer = this->listener->RtpObserverGetProducer(this, producerId); this->RemoveProducer(producer); @@ -77,7 +79,7 @@ namespace RTC default: { - MS_THROW_ERROR("unknown method '%s'", request->method.c_str()); + MS_THROW_ERROR("unknown method '%s'", request->methodCStr); } } } @@ -105,16 +107,4 @@ namespace RTC Resumed(); } - - std::string RtpObserver::GetProducerIdFromData(json& data) const - { - MS_TRACE(); - - auto jsonRouterIdIt = data.find("producerId"); - - if (jsonRouterIdIt == data.end() || !jsonRouterIdIt->is_string()) - MS_THROW_ERROR("missing data.producerId"); - - return jsonRouterIdIt->get(); - } } // namespace RTC diff --git a/worker/src/RTC/RtpPacket.cpp b/worker/src/RTC/RtpPacket.cpp index 368115abed..64a2b5a55d 100644 --- a/worker/src/RTC/RtpPacket.cpp +++ b/worker/src/RTC/RtpPacket.cpp @@ -317,65 +317,6 @@ namespace RTC MS_DUMP(""); } - void RtpPacket::FillJson(json& jsonObject) const - { - MS_TRACE(); - - // Add payloadType. - jsonObject["payloadType"] = GetPayloadType(); - - // Add sequenceNumber. - jsonObject["sequenceNumber"] = GetSequenceNumber(); - - // Add timestamp. - jsonObject["timestamp"] = GetTimestamp(); - - // Add marker. - jsonObject["marker"] = HasMarker(); - - // Add ssrc. - jsonObject["ssrc"] = GetSsrc(); - - // Add isKeyFrame. - jsonObject["isKeyFrame"] = IsKeyFrame(); - - // Add size. - jsonObject["size"] = GetSize(); - - // Add payloadSize. - jsonObject["payloadSize"] = GetPayloadLength(); - - // Add spatialLayer. - jsonObject["spatialLayer"] = GetSpatialLayer(); - - // Add temporalLayer. - jsonObject["temporalLayer"] = GetTemporalLayer(); - - // Add mid. - std::string mid; - - if (this->midExtensionId != 0u && ReadMid(mid)) - jsonObject["mid"] = mid; - - // Add rid. - std::string rid; - - if (this->ridExtensionId != 0u && ReadRid(rid)) - jsonObject["rid"] = rid; - - // Add rrid. - std::string rrid; - - if (this->rridExtensionId != 0u && ReadRid(rrid)) - jsonObject["rrid"] = rrid; - - // Add wideSequenceNumber. - uint16_t wideSequenceNumber; - - if (this->transportWideCc01ExtensionId != 0u && ReadTransportWideCc01(wideSequenceNumber)) - jsonObject["wideSequenceNumber"] = wideSequenceNumber; - } - void RtpPacket::SetExtensions(uint8_t type, const std::vector& extensions) { MS_ASSERT(type == 1u || type == 2u, "type must be 1 or 2"); diff --git a/worker/src/RTC/RtpStream.cpp b/worker/src/RTC/RtpStream.cpp index 85b6850b81..35bf431d79 100644 --- a/worker/src/RTC/RtpStream.cpp +++ b/worker/src/RTC/RtpStream.cpp @@ -31,53 +31,54 @@ namespace RTC this->rtxStream = nullptr; } - void RtpStream::FillJson(json& jsonObject) const + flatbuffers::Offset RtpStream::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); // Add params. - this->params.FillJson(jsonObject["params"]); - - // Add score. - jsonObject["score"] = this->score; + auto params = this->params.FillBuffer(builder); // Add rtxStream. + flatbuffers::Offset rtxStream; + if (HasRtx()) - this->rtxStream->FillJson(jsonObject["rtxStream"]); + rtxStream = this->rtxStream->FillBuffer(builder); + + return FBS::RtpStream::CreateDump(builder, params, this->score, rtxStream); } - void RtpStream::FillJsonStats(json& jsonObject) + flatbuffers::Offset RtpStream::FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) { MS_TRACE(); const uint64_t nowMs = DepLibUV::GetTimeMs(); - jsonObject["timestamp"] = nowMs; - jsonObject["ssrc"] = this->params.ssrc; - jsonObject["kind"] = RtpCodecMimeType::type2String[this->params.mimeType.type]; - jsonObject["mimeType"] = this->params.mimeType.ToString(); - jsonObject["packetsLost"] = this->packetsLost; - jsonObject["fractionLost"] = this->fractionLost; - jsonObject["packetsDiscarded"] = this->packetsDiscarded; - jsonObject["packetsRetransmitted"] = this->packetsRetransmitted; - jsonObject["packetsRepaired"] = this->packetsRepaired; - jsonObject["nackCount"] = this->nackCount; - jsonObject["nackPacketCount"] = this->nackPacketCount; - jsonObject["pliCount"] = this->pliCount; - jsonObject["firCount"] = this->firCount; - jsonObject["score"] = this->score; - - if (!this->params.rid.empty()) - jsonObject["rid"] = this->params.rid; - - if (this->params.rtxSsrc) - jsonObject["rtxSsrc"] = this->params.rtxSsrc; - - if (this->rtxStream) - jsonObject["rtxPacketsDiscarded"] = this->rtxStream->GetPacketsDiscarded(); - - if (this->hasRtt) - jsonObject["roundTripTime"] = this->rtt; + auto baseStats = FBS::RtpStream::CreateBaseStatsDirect( + builder, + nowMs, + this->params.ssrc, + FBS::RtpParameters::MediaKind(this->params.mimeType.type), + this->params.mimeType.ToString().c_str(), + this->packetsLost, + this->fractionLost, + this->packetsDiscarded, + this->packetsRetransmitted, + this->packetsRepaired, + this->nackCount, + this->nackPacketCount, + this->pliCount, + this->firCount, + this->score, + !this->params.rid.empty() ? this->params.rid.c_str() : nullptr, + this->params.rtxSsrc ? flatbuffers::Optional(this->params.rtxSsrc) + : flatbuffers::nullopt, + this->rtxStream ? this->rtxStream->GetPacketsDiscarded() : 0, + this->hasRtt ? this->rtt : 0); + + return FBS::RtpStream::CreateStats( + builder, FBS::RtpStream::StatsData::BaseStats, baseStats.Union()); } void RtpStream::SetRtx(uint8_t payloadType, uint32_t ssrc) @@ -338,33 +339,28 @@ namespace RTC this->badSeq = RtpSeqMod + 1; // So seq == badSeq is false. } - void RtpStream::Params::FillJson(json& jsonObject) const + flatbuffers::Offset RtpStream::Params::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - jsonObject["encodingIdx"] = this->encodingIdx; - jsonObject["ssrc"] = this->ssrc; - jsonObject["payloadType"] = this->payloadType; - jsonObject["mimeType"] = this->mimeType.ToString(); - jsonObject["clockRate"] = this->clockRate; - - if (!this->rid.empty()) - jsonObject["rid"] = this->rid; - - jsonObject["cname"] = this->cname; - - if (this->rtxSsrc != 0) - { - jsonObject["rtxSsrc"] = this->rtxSsrc; - jsonObject["rtxPayloadType"] = this->rtxPayloadType; - } - - jsonObject["useNack"] = this->useNack; - jsonObject["usePli"] = this->usePli; - jsonObject["useFir"] = this->useFir; - jsonObject["useInBandFec"] = this->useInBandFec; - jsonObject["useDtx"] = this->useDtx; - jsonObject["spatialLayers"] = this->spatialLayers; - jsonObject["temporalLayers"] = this->temporalLayers; + return FBS::RtpStream::CreateParamsDirect( + builder, + this->encodingIdx, + this->ssrc, + this->payloadType, + this->mimeType.ToString().c_str(), + this->clockRate, + this->rid.c_str(), + this->cname.c_str(), + this->rtxSsrc != 0 ? flatbuffers::Optional(this->rtxSsrc) : flatbuffers::nullopt, + this->rtxSsrc != 0 ? flatbuffers::Optional(this->rtxPayloadType) : flatbuffers::nullopt, + this->useNack, + this->usePli, + this->useFir, + this->useInBandFec, + this->useDtx, + this->spatialLayers, + this->temporalLayers); } } // namespace RTC diff --git a/worker/src/RTC/RtpStreamRecv.cpp b/worker/src/RTC/RtpStreamRecv.cpp index abee7f293b..a9a09ebd5e 100644 --- a/worker/src/RTC/RtpStreamRecv.cpp +++ b/worker/src/RTC/RtpStreamRecv.cpp @@ -158,9 +158,9 @@ namespace RTC size_t packetCount{ 0u }; - for (auto& spatialLayerCounter : this->spatialLayerCounters) + for (const auto& spatialLayerCounter : this->spatialLayerCounters) { - for (auto& temporalLayerCounter : spatialLayerCounter) + for (const auto& temporalLayerCounter : spatialLayerCounter) { packetCount += temporalLayerCounter.GetPacketCount(); } @@ -227,34 +227,41 @@ namespace RTC this->inactivityCheckPeriodicTimer = nullptr; } - void RtpStreamRecv::FillJsonStats(json& jsonObject) + flatbuffers::Offset RtpStreamRecv::FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) { MS_TRACE(); const uint64_t nowMs = DepLibUV::GetTimeMs(); - RTC::RtpStream::FillJsonStats(jsonObject); + auto baseStats = RTC::RtpStream::FillBufferStats(builder); - jsonObject["type"] = "inbound-rtp"; - jsonObject["jitter"] = this->jitter; - jsonObject["packetCount"] = this->transmissionCounter.GetPacketCount(); - jsonObject["byteCount"] = this->transmissionCounter.GetBytes(); - jsonObject["bitrate"] = this->transmissionCounter.GetBitrate(nowMs); + std::vector> bitrateByLayer; if (GetSpatialLayers() > 1 || GetTemporalLayers() > 1) { - jsonObject["bitrateByLayer"] = json::object(); - auto jsonBitrateByLayerIt = jsonObject.find("bitrateByLayer"); - for (uint8_t sIdx = 0; sIdx < GetSpatialLayers(); ++sIdx) { for (uint8_t tIdx = 0; tIdx < GetTemporalLayers(); ++tIdx) { - (*jsonBitrateByLayerIt)[std::to_string(sIdx) + "." + std::to_string(tIdx)] = - GetBitrate(nowMs, sIdx, tIdx); + auto layer = std::to_string(sIdx) + "." + std::to_string(tIdx); + + bitrateByLayer.emplace_back(FBS::RtpStream::CreateBitrateByLayerDirect( + builder, layer.c_str(), GetBitrate(nowMs, sIdx, tIdx))); } } } + + auto stats = FBS::RtpStream::CreateRecvStatsDirect( + builder, + baseStats, + this->jitter, + this->transmissionCounter.GetPacketCount(), + this->transmissionCounter.GetBytes(), + this->transmissionCounter.GetBitrate(nowMs), + &bitrateByLayer); + + return FBS::RtpStream::CreateStats(builder, FBS::RtpStream::StatsData::RecvStats, stats.Union()); } bool RtpStreamRecv::ReceivePacket(RTC::RtpPacket* packet) diff --git a/worker/src/RTC/RtpStreamSend.cpp b/worker/src/RTC/RtpStreamSend.cpp index b8949a37ff..74d3a67a70 100644 --- a/worker/src/RTC/RtpStreamSend.cpp +++ b/worker/src/RTC/RtpStreamSend.cpp @@ -72,18 +72,22 @@ namespace RTC this->retransmissionBuffer = nullptr; } - void RtpStreamSend::FillJsonStats(json& jsonObject) + flatbuffers::Offset RtpStreamSend::FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) { MS_TRACE(); const uint64_t nowMs = DepLibUV::GetTimeMs(); - RTC::RtpStream::FillJsonStats(jsonObject); + auto baseStats = RTC::RtpStream::FillBufferStats(builder); + auto stats = FBS::RtpStream::CreateSendStats( + builder, + baseStats, + this->transmissionCounter.GetPacketCount(), + this->transmissionCounter.GetBytes(), + this->transmissionCounter.GetBitrate(nowMs)); - jsonObject["type"] = "outbound-rtp"; - jsonObject["packetCount"] = this->transmissionCounter.GetPacketCount(); - jsonObject["byteCount"] = this->transmissionCounter.GetBytes(); - jsonObject["bitrate"] = this->transmissionCounter.GetBitrate(nowMs); + return FBS::RtpStream::CreateStats(builder, FBS::RtpStream::StatsData::SendStats, stats.Union()); } void RtpStreamSend::SetRtx(uint8_t payloadType, uint32_t ssrc) diff --git a/worker/src/RTC/RtxStream.cpp b/worker/src/RTC/RtxStream.cpp index 44b5c3bc12..6f900906f4 100644 --- a/worker/src/RTC/RtxStream.cpp +++ b/worker/src/RTC/RtxStream.cpp @@ -28,12 +28,15 @@ namespace RTC MS_TRACE(); } - void RtxStream::FillJson(json& jsonObject) const + flatbuffers::Offset RtxStream::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); // Add params. - this->params.FillJson(jsonObject["params"]); + auto params = this->params.FillBuffer(builder); + + return FBS::RtxStream::CreateRtxDump(builder, params); } bool RtxStream::ReceivePacket(RTC::RtpPacket* packet) @@ -231,18 +234,18 @@ namespace RTC this->badSeq = RtpSeqMod + 1; // So seq == badSeq is false. } - void RtxStream::Params::FillJson(json& jsonObject) const + flatbuffers::Offset RtxStream::Params::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - jsonObject["ssrc"] = this->ssrc; - jsonObject["payloadType"] = this->payloadType; - jsonObject["mimeType"] = this->mimeType.ToString(); - jsonObject["clockRate"] = this->clockRate; - - if (!this->rrid.empty()) - jsonObject["rrid"] = this->rrid; - - jsonObject["cname"] = this->cname; + return FBS::RtxStream::CreateParamsDirect( + builder, + this->ssrc, + this->payloadType, + this->mimeType.ToString().c_str(), + this->clockRate, + this->rrid.c_str(), + this->cname.c_str()); } } // namespace RTC diff --git a/worker/src/RTC/SctpAssociation.cpp b/worker/src/RTC/SctpAssociation.cpp index 8a5b6c2df6..89f9bf525f 100644 --- a/worker/src/RTC/SctpAssociation.cpp +++ b/worker/src/RTC/SctpAssociation.cpp @@ -341,30 +341,27 @@ namespace RTC } } - void SctpAssociation::FillJson(json& jsonObject) const + flatbuffers::Offset SctpAssociation::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Add port (always 5000). - jsonObject["port"] = 5000; - - // Add OS. - jsonObject["OS"] = this->os; - - // Add MIS. - jsonObject["MIS"] = this->mis; - - // Add maxMessageSize. - jsonObject["maxMessageSize"] = this->maxSctpMessageSize; - - // Add sendBufferSize. - jsonObject["sendBufferSize"] = this->sctpSendBufferSize; - - // Add sctpBufferedAmountLowThreshold. - jsonObject["sctpBufferedAmount"] = this->sctpBufferedAmount; - - // Add isDataChannel. - jsonObject["isDataChannel"] = this->isDataChannel; + return FBS::SctpParameters::CreateSctpParameters( + builder, + // Add port (always 5000). + 5000, + // Add OS. + this->os, + // Add MIS. + this->mis, + // Add maxMessageSize. + this->maxSctpMessageSize, + // Add sendBufferSize. + this->sctpSendBufferSize, + // Add sctpBufferedAmountLowThreshold. + this->sctpBufferedAmount, + // Add isDataChannel. + this->isDataChannel); } void SctpAssociation::ProcessSctpData(const uint8_t* data, size_t len) diff --git a/worker/src/RTC/SctpDictionaries/SctpStreamParameters.cpp b/worker/src/RTC/SctpDictionaries/SctpStreamParameters.cpp index 5a6e4156c5..1634783876 100644 --- a/worker/src/RTC/SctpDictionaries/SctpStreamParameters.cpp +++ b/worker/src/RTC/SctpDictionaries/SctpStreamParameters.cpp @@ -10,23 +10,11 @@ namespace RTC { /* Instance methods. */ - SctpStreamParameters::SctpStreamParameters(json& data) + SctpStreamParameters::SctpStreamParameters(const FBS::SctpParameters::SctpStreamParameters* data) { MS_TRACE(); - if (!data.is_object()) - MS_THROW_TYPE_ERROR("data is not an object"); - - auto jsonStreamIdIt = data.find("streamId"); - auto jsonOrderedIdIt = data.find("ordered"); - auto jsonMaxPacketLifeTimeIt = data.find("maxPacketLifeTime"); - auto jsonMaxRetransmitsIt = data.find("maxRetransmits"); - - // streamId is mandatory. - if (jsonStreamIdIt == data.end() || !Utils::Json::IsPositiveInteger(*jsonStreamIdIt)) - MS_THROW_TYPE_ERROR("missing streamId"); - - this->streamId = jsonStreamIdIt->get(); + this->streamId = data->streamId(); if (this->streamId > 65534) MS_THROW_TYPE_ERROR("streamId must not be greater than 65534"); @@ -34,32 +22,22 @@ namespace RTC // ordered is optional. bool orderedGiven = false; - if (jsonOrderedIdIt != data.end() && jsonOrderedIdIt->is_boolean()) + if (data->ordered().has_value()) { orderedGiven = true; - this->ordered = jsonOrderedIdIt->get(); + this->ordered = data->ordered().value(); } // maxPacketLifeTime is optional. - // clang-format off - if ( - jsonMaxPacketLifeTimeIt != data.end() && - Utils::Json::IsPositiveInteger(*jsonMaxPacketLifeTimeIt) - ) - // clang-format on + if (data->maxPacketLifeTime().has_value()) { - this->maxPacketLifeTime = jsonMaxPacketLifeTimeIt->get(); + this->maxPacketLifeTime = data->maxPacketLifeTime().value(); } // maxRetransmits is optional. - // clang-format off - if ( - jsonMaxRetransmitsIt != data.end() && - Utils::Json::IsPositiveInteger(*jsonMaxRetransmitsIt) - ) - // clang-format on + if (data->maxRetransmits().has_value()) { - this->maxRetransmits = jsonMaxRetransmitsIt->get(); + this->maxRetransmits = data->maxRetransmits().value(); } if (this->maxPacketLifeTime && this->maxRetransmits) @@ -81,22 +59,18 @@ namespace RTC } } - void SctpStreamParameters::FillJson(json& jsonObject) const + flatbuffers::Offset SctpStreamParameters::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Add streamId. - jsonObject["streamId"] = this->streamId; - - // Add ordered. - jsonObject["ordered"] = this->ordered; - - // Add maxPacketLifeTime. - if (this->maxPacketLifeTime) - jsonObject["maxPacketLifeTime"] = this->maxPacketLifeTime; - - // Add maxRetransmits. - if (this->maxRetransmits) - jsonObject["maxRetransmits"] = this->maxRetransmits; + return FBS::SctpParameters::CreateSctpStreamParameters( + builder, + this->streamId, + this->ordered, + this->maxPacketLifeTime ? flatbuffers::Optional(this->maxPacketLifeTime) + : flatbuffers::nullopt, + this->maxRetransmits ? flatbuffers::Optional(this->maxRetransmits) + : flatbuffers::nullopt); } } // namespace RTC diff --git a/worker/src/RTC/SctpListener.cpp b/worker/src/RTC/SctpListener.cpp index 64300c6c0a..3daf7aa76f 100644 --- a/worker/src/RTC/SctpListener.cpp +++ b/worker/src/RTC/SctpListener.cpp @@ -10,22 +10,24 @@ namespace RTC { /* Instance methods. */ - void SctpListener::FillJson(json& jsonObject) const + flatbuffers::Offset SctpListener::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - jsonObject["streamIdTable"] = json::object(); - - auto jsonStreamIdTableIt = jsonObject.find("streamIdTable"); - // Add streamIdTable. + std::vector> streamIdTable; + for (const auto& kv : this->streamIdTable) { auto streamId = kv.first; auto* dataProducer = kv.second; - (*jsonStreamIdTableIt)[std::to_string(streamId)] = dataProducer->id; + streamIdTable.emplace_back( + FBS::Common::CreateUint16StringDirect(builder, streamId, dataProducer->id.c_str())); } + + return FBS::Transport::CreateSctpListenerDirect(builder, &streamIdTable); } void SctpListener::AddDataProducer(RTC::DataProducer* dataProducer) diff --git a/worker/src/RTC/Shared.cpp b/worker/src/RTC/Shared.cpp index e984862df0..037eca59c8 100644 --- a/worker/src/RTC/Shared.cpp +++ b/worker/src/RTC/Shared.cpp @@ -7,11 +7,8 @@ namespace RTC { Shared::Shared( - ChannelMessageRegistrator* channelMessageRegistrator, - Channel::ChannelNotifier* channelNotifier, - PayloadChannel::PayloadChannelNotifier* payloadChannelNotifier) - : channelMessageRegistrator(channelMessageRegistrator), channelNotifier(channelNotifier), - payloadChannelNotifier(payloadChannelNotifier) + ChannelMessageRegistrator* channelMessageRegistrator, Channel::ChannelNotifier* channelNotifier) + : channelMessageRegistrator(channelMessageRegistrator), channelNotifier(channelNotifier) { MS_TRACE(); } @@ -22,6 +19,5 @@ namespace RTC delete this->channelMessageRegistrator; delete this->channelNotifier; - delete this->payloadChannelNotifier; } } // namespace RTC diff --git a/worker/src/RTC/SimpleConsumer.cpp b/worker/src/RTC/SimpleConsumer.cpp index 01da96fb0e..5407142c66 100644 --- a/worker/src/RTC/SimpleConsumer.cpp +++ b/worker/src/RTC/SimpleConsumer.cpp @@ -16,7 +16,7 @@ namespace RTC const std::string& id, const std::string& producerId, RTC::Consumer::Listener* listener, - json& data) + const FBS::Transport::ConsumeRequest* data) : RTC::Consumer::Consumer(shared, id, producerId, listener, data, RTC::RtpParameters::Type::SIMPLE) { MS_TRACE(); @@ -44,22 +44,15 @@ namespace RTC this->encodingContext.reset( RTC::Codecs::Tools::GetEncodingContext(mediaCodec->mimeType, params)); - auto jsonIgnoreDtx = data.find("ignoreDtx"); - - if (jsonIgnoreDtx != data.end() && jsonIgnoreDtx->is_boolean()) - { - auto ignoreDtx = jsonIgnoreDtx->get(); - - this->encodingContext->SetIgnoreDtx(ignoreDtx); - } + // ignoreDtx is set to false by default. + this->encodingContext->SetIgnoreDtx(data->ignoreDtx()); } // NOTE: This may throw. this->shared->channelMessageRegistrator->RegisterHandler( this->id, /*channelRequestHandler*/ this, - /*payloadChannelRequestHandler*/ nullptr, - /*payloadChannelNotificationHandler*/ nullptr); + /*channelNotificationHandler*/ nullptr); } SimpleConsumer::~SimpleConsumer() @@ -71,56 +64,76 @@ namespace RTC delete this->rtpStream; } - void SimpleConsumer::FillJson(json& jsonObject) const + flatbuffers::Offset SimpleConsumer::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); // Call the parent method. - RTC::Consumer::FillJson(jsonObject); - + auto base = RTC::Consumer::FillBuffer(builder); // Add rtpStream. - this->rtpStream->FillJson(jsonObject["rtpStream"]); + auto rtpStream = this->rtpStream->FillBuffer(builder); + + auto simpleConsumerDump = FBS::Consumer::CreateSimpleConsumerDump(builder, base, rtpStream); + + return FBS::Consumer::CreateDumpResponse( + builder, + FBS::Consumer::DumpData::SimpleConsumerDump, + simpleConsumerDump.Union(), + FBS::RtpParameters::Type(this->type)); } - void SimpleConsumer::FillJsonStats(json& jsonArray) const + flatbuffers::Offset SimpleConsumer::FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) { MS_TRACE(); + std::vector> rtpStreams; + // Add stats of our send stream. - jsonArray.emplace_back(json::value_t::object); - this->rtpStream->FillJsonStats(jsonArray[0]); + rtpStreams.emplace_back(this->rtpStream->FillBufferStats(builder)); // Add stats of our recv stream. if (this->producerRtpStream) { - jsonArray.emplace_back(json::value_t::object); - this->producerRtpStream->FillJsonStats(jsonArray[1]); + rtpStreams.emplace_back(this->producerRtpStream->FillBufferStats(builder)); } + + return FBS::Consumer::CreateGetStatsResponseDirect(builder, &rtpStreams); } - void SimpleConsumer::FillJsonScore(json& jsonObject) const + flatbuffers::Offset SimpleConsumer::FillBufferScore( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); MS_ASSERT(this->producerRtpStreamScores, "producerRtpStreamScores not set"); - jsonObject["score"] = this->rtpStream->GetScore(); + uint8_t producerScore{ 0 }; if (this->producerRtpStream) - jsonObject["producerScore"] = this->producerRtpStream->GetScore(); - else - jsonObject["producerScore"] = 0; + producerScore = this->producerRtpStream->GetScore(); - jsonObject["producerScores"] = *this->producerRtpStreamScores; + return FBS::Consumer::CreateConsumerScoreDirect( + builder, this->rtpStream->GetScore(), producerScore, this->producerRtpStreamScores); } void SimpleConsumer::HandleRequest(Channel::ChannelRequest* request) { MS_TRACE(); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::CONSUMER_REQUEST_KEY_FRAME: + case Channel::ChannelRequest::Method::CONSUMER_DUMP: + { + auto dumpOffset = FillBuffer(request->GetBufferBuilder()); + + request->Accept(FBS::Response::Body::FBS_Consumer_DumpResponse, dumpOffset); + + break; + } + + case Channel::ChannelRequest::Method::CONSUMER_REQUEST_KEY_FRAME: { if (IsActive()) RequestKeyFrame(); @@ -130,7 +143,7 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::CONSUMER_SET_PREFERRED_LAYERS: + case Channel::ChannelRequest::Method::CONSUMER_SET_PREFERRED_LAYERS: { // Do nothing. @@ -636,11 +649,16 @@ namespace RTC { MS_TRACE(); - json data = json::object(); + auto scoreOffset = FillBufferScore(this->shared->channelNotifier->GetBufferBuilder()); - FillJsonScore(data); + auto notificationOffset = FBS::Consumer::CreateScoreNotification( + this->shared->channelNotifier->GetBufferBuilder(), scoreOffset); - this->shared->channelNotifier->Emit(this->id, "score", data); + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::CONSUMER_SCORE, + FBS::Notification::Body::FBS_Consumer_ScoreNotification, + notificationOffset); } inline void SimpleConsumer::OnRtpStreamScore( diff --git a/worker/src/RTC/SimulcastConsumer.cpp b/worker/src/RTC/SimulcastConsumer.cpp index 44076dca1f..3527f3c0ff 100644 --- a/worker/src/RTC/SimulcastConsumer.cpp +++ b/worker/src/RTC/SimulcastConsumer.cpp @@ -24,7 +24,7 @@ namespace RTC const std::string& id, const std::string& producerId, RTC::Consumer::Listener* listener, - json& data) + const FBS::Transport::ConsumeRequest* data) : RTC::Consumer::Consumer( shared, id, producerId, listener, data, RTC::RtpParameters::Type::SIMULCAST) { @@ -43,8 +43,6 @@ namespace RTC MS_THROW_TYPE_ERROR("encoding.spatialLayers does not match number of consumableRtpEncodings"); } - auto jsonPreferredLayersIt = data.find("preferredLayers"); - // Fill mapMappedSsrcSpatialLayer. for (size_t idx{ 0u }; idx < this->consumableRtpEncodings.size(); ++idx) { @@ -54,34 +52,18 @@ namespace RTC } // Set preferredLayers (if given). - if (jsonPreferredLayersIt != data.end() && jsonPreferredLayersIt->is_object()) + if (flatbuffers::IsFieldPresent(data, FBS::Transport::ConsumeRequest::VT_PREFERREDLAYERS)) { - auto jsonSpatialLayerIt = jsonPreferredLayersIt->find("spatialLayer"); - auto jsonTemporalLayerIt = jsonPreferredLayersIt->find("temporalLayer"); - - // clang-format off - if ( - jsonSpatialLayerIt == jsonPreferredLayersIt->end() || - !Utils::Json::IsPositiveInteger(*jsonSpatialLayerIt) - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("missing preferredLayers.spatialLayer"); - } + const auto* preferredLayers = data->preferredLayers(); - this->preferredSpatialLayer = jsonSpatialLayerIt->get(); + this->preferredSpatialLayer = preferredLayers->spatialLayer(); if (this->preferredSpatialLayer > encoding.spatialLayers - 1) this->preferredSpatialLayer = encoding.spatialLayers - 1; - // clang-format off - if ( - jsonTemporalLayerIt != jsonPreferredLayersIt->end() && - Utils::Json::IsPositiveInteger(*jsonTemporalLayerIt) - ) - // clang-format on + if (preferredLayers->temporalLayer().has_value()) { - this->preferredTemporalLayer = jsonTemporalLayerIt->get(); + this->preferredTemporalLayer = preferredLayers->temporalLayer().value(); if (this->preferredTemporalLayer > encoding.temporalLayers - 1) this->preferredTemporalLayer = encoding.temporalLayers - 1; @@ -129,8 +111,7 @@ namespace RTC this->shared->channelMessageRegistrator->RegisterHandler( this->id, /*channelRequestHandler*/ this, - /*payloadChannelRequestHandler*/ nullptr, - /*payloadChannelNotificationHandler*/ nullptr); + /*channelRequestHandler*/ nullptr); } SimulcastConsumer::~SimulcastConsumer() @@ -142,54 +123,57 @@ namespace RTC delete this->rtpStream; } - void SimulcastConsumer::FillJson(json& jsonObject) const + flatbuffers::Offset SimulcastConsumer::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); // Call the parent method. - RTC::Consumer::FillJson(jsonObject); - + auto base = RTC::Consumer::FillBuffer(builder); // Add rtpStream. - this->rtpStream->FillJson(jsonObject["rtpStream"]); - - // Add preferredSpatialLayer. - jsonObject["preferredSpatialLayer"] = this->preferredSpatialLayer; - - // Add targetSpatialLayer. - jsonObject["targetSpatialLayer"] = this->targetSpatialLayer; + auto rtpStream = this->rtpStream->FillBuffer(builder); - // Add currentSpatialLayer. - jsonObject["currentSpatialLayer"] = this->currentSpatialLayer; - - // Add preferredTemporalLayer. - jsonObject["preferredTemporalLayer"] = this->preferredTemporalLayer; - - // Add targetTemporalLayer. - jsonObject["targetTemporalLayer"] = this->targetTemporalLayer; + auto simulcastConsumerDump = FBS::Consumer::CreateSimulcastConsumerDump( + builder, + base, + rtpStream, + this->preferredSpatialLayer, + this->targetSpatialLayer, + this->currentSpatialLayer, + this->preferredTemporalLayer, + this->targetTemporalLayer, + this->encodingContext->GetCurrentTemporalLayer()); - // Add currentTemporalLayer. - jsonObject["currentTemporalLayer"] = this->encodingContext->GetCurrentTemporalLayer(); + return FBS::Consumer::CreateDumpResponse( + builder, + FBS::Consumer::DumpData::SimulcastConsumerDump, + simulcastConsumerDump.Union(), + FBS::RtpParameters::Type(this->type)); } - void SimulcastConsumer::FillJsonStats(json& jsonArray) const + flatbuffers::Offset SimulcastConsumer::FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) { MS_TRACE(); + std::vector> rtpStreams; + // Add stats of our send stream. - jsonArray.emplace_back(json::value_t::object); - this->rtpStream->FillJsonStats(jsonArray[0]); + rtpStreams.emplace_back(this->rtpStream->FillBufferStats(builder)); - // Add stats of our recv stream. auto* producerCurrentRtpStream = GetProducerCurrentRtpStream(); + // Add stats of our recv stream. if (producerCurrentRtpStream) { - jsonArray.emplace_back(json::value_t::object); - producerCurrentRtpStream->FillJsonStats(jsonArray[1]); + rtpStreams.emplace_back(producerCurrentRtpStream->FillBufferStats(builder)); } + + return FBS::Consumer::CreateGetStatsResponseDirect(builder, &rtpStreams); } - void SimulcastConsumer::FillJsonScore(json& jsonObject) const + flatbuffers::Offset SimulcastConsumer::FillBufferScore( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); @@ -197,23 +181,33 @@ namespace RTC auto* producerCurrentRtpStream = GetProducerCurrentRtpStream(); - jsonObject["score"] = this->rtpStream->GetScore(); + uint8_t producerScore{ 0 }; if (producerCurrentRtpStream) - jsonObject["producerScore"] = producerCurrentRtpStream->GetScore(); + producerScore = producerCurrentRtpStream->GetScore(); else - jsonObject["producerScore"] = 0; + producerScore = 0; - jsonObject["producerScores"] = *this->producerRtpStreamScores; + return FBS::Consumer::CreateConsumerScoreDirect( + builder, this->rtpStream->GetScore(), producerScore, this->producerRtpStreamScores); } void SimulcastConsumer::HandleRequest(Channel::ChannelRequest* request) { MS_TRACE(); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::CONSUMER_REQUEST_KEY_FRAME: + case Channel::ChannelRequest::Method::CONSUMER_DUMP: + { + auto dumpOffset = FillBuffer(request->GetBufferBuilder()); + + request->Accept(FBS::Response::Body::FBS_Consumer_DumpResponse, dumpOffset); + + break; + } + + case Channel::ChannelRequest::Method::CONSUMER_REQUEST_KEY_FRAME: { if (IsActive()) RequestKeyFrames(); @@ -223,39 +217,24 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::CONSUMER_SET_PREFERRED_LAYERS: + case Channel::ChannelRequest::Method::CONSUMER_SET_PREFERRED_LAYERS: { auto previousPreferredSpatialLayer = this->preferredSpatialLayer; auto previousPreferredTemporalLayer = this->preferredTemporalLayer; - auto jsonSpatialLayerIt = request->data.find("spatialLayer"); - auto jsonTemporalLayerIt = request->data.find("temporalLayer"); + const auto* body = request->data->body_as(); + const auto* preferredLayers = body->preferredLayers(); // Spatial layer. - // clang-format off - if ( - jsonSpatialLayerIt == request->data.end() || - !Utils::Json::IsPositiveInteger(*jsonSpatialLayerIt) - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("missing spatialLayer"); - } - - this->preferredSpatialLayer = jsonSpatialLayerIt->get(); + this->preferredSpatialLayer = preferredLayers->spatialLayer(); if (this->preferredSpatialLayer > this->rtpStream->GetSpatialLayers() - 1) this->preferredSpatialLayer = this->rtpStream->GetSpatialLayers() - 1; // preferredTemporaLayer is optional. - // clang-format off - if ( - jsonTemporalLayerIt != request->data.end() && - Utils::Json::IsPositiveInteger(*jsonTemporalLayerIt) - ) - // clang-format on + if (preferredLayers->temporalLayer().has_value()) { - this->preferredTemporalLayer = jsonTemporalLayerIt->get(); + this->preferredTemporalLayer = preferredLayers->temporalLayer().value(); if (this->preferredTemporalLayer > this->rtpStream->GetTemporalLayers() - 1) this->preferredTemporalLayer = this->rtpStream->GetTemporalLayers() - 1; @@ -271,12 +250,13 @@ namespace RTC this->preferredTemporalLayer, this->id.c_str()); - json data = json::object(); - - data["spatialLayer"] = this->preferredSpatialLayer; - data["temporalLayer"] = this->preferredTemporalLayer; + const flatbuffers::Optional preferredTemporalLayer{ this->preferredTemporalLayer }; + auto preferredLayersOffset = FBS::Consumer::CreateConsumerLayers( + request->GetBufferBuilder(), this->preferredSpatialLayer, preferredTemporalLayer); + auto responseOffset = FBS::Consumer::CreateSetPreferredLayersResponse( + request->GetBufferBuilder(), preferredLayersOffset); - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_Consumer_SetPreferredLayersResponse, responseOffset); // clang-format off if ( @@ -1501,11 +1481,16 @@ namespace RTC { MS_TRACE(); - json data = json::object(); + auto scoreOffset = FillBufferScore(this->shared->channelNotifier->GetBufferBuilder()); - FillJsonScore(data); + auto notificationOffset = FBS::Consumer::CreateScoreNotification( + this->shared->channelNotifier->GetBufferBuilder(), scoreOffset); - this->shared->channelNotifier->Emit(this->id, "score", data); + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::CONSUMER_SCORE, + FBS::Notification::Body::FBS_Consumer_ScoreNotification, + notificationOffset); } inline void SimulcastConsumer::EmitLayersChange() const @@ -1518,19 +1503,24 @@ namespace RTC this->encodingContext->GetCurrentTemporalLayer(), this->id.c_str()); - json data = json::object(); + flatbuffers::Offset layersOffset; if (this->currentSpatialLayer >= 0) { - data["spatialLayer"] = this->currentSpatialLayer; - data["temporalLayer"] = this->encodingContext->GetCurrentTemporalLayer(); - } - else - { - data = nullptr; + layersOffset = FBS::Consumer::CreateConsumerLayers( + this->shared->channelNotifier->GetBufferBuilder(), + this->currentSpatialLayer, + this->encodingContext->GetCurrentTemporalLayer()); } - this->shared->channelNotifier->Emit(this->id, "layerschange", data); + auto notificationOffset = FBS::Consumer::CreateLayersChangeNotification( + this->shared->channelNotifier->GetBufferBuilder(), layersOffset); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::CONSUMER_LAYERS_CHANGE, + FBS::Notification::Body::FBS_Consumer_LayersChangeNotification, + notificationOffset); } inline RTC::RtpStream* SimulcastConsumer::GetProducerCurrentRtpStream() const diff --git a/worker/src/RTC/SvcConsumer.cpp b/worker/src/RTC/SvcConsumer.cpp index d2b6af9566..af791de3e5 100644 --- a/worker/src/RTC/SvcConsumer.cpp +++ b/worker/src/RTC/SvcConsumer.cpp @@ -22,7 +22,7 @@ namespace RTC const std::string& id, const std::string& producerId, RTC::Consumer::Listener* listener, - json& data) + const FBS::Transport::ConsumeRequest* data) : RTC::Consumer::Consumer(shared, id, producerId, listener, data, RTC::RtpParameters::Type::SVC) { MS_TRACE(); @@ -37,38 +37,17 @@ namespace RTC if (encoding.spatialLayers < 2u && encoding.temporalLayers < 2u) MS_THROW_TYPE_ERROR("invalid number of layers"); - auto jsonPreferredLayersIt = data.find("preferredLayers"); - // Set preferredLayers (if given). - if (jsonPreferredLayersIt != data.end() && jsonPreferredLayersIt->is_object()) + if (flatbuffers::IsFieldPresent(data, FBS::Transport::ConsumeRequest::VT_PREFERREDLAYERS)) { - auto jsonSpatialLayerIt = jsonPreferredLayersIt->find("spatialLayer"); - auto jsonTemporalLayerIt = jsonPreferredLayersIt->find("temporalLayer"); - - // clang-format off - if ( - jsonSpatialLayerIt == jsonPreferredLayersIt->end() || - !Utils::Json::IsPositiveInteger(*jsonSpatialLayerIt) - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("missing preferredLayers.spatialLayer"); - } - - this->preferredSpatialLayer = jsonSpatialLayerIt->get(); + this->preferredSpatialLayer = data->preferredLayers()->spatialLayer(); if (this->preferredSpatialLayer > encoding.spatialLayers - 1) this->preferredSpatialLayer = encoding.spatialLayers - 1; - // clang-format off - if ( - jsonTemporalLayerIt != jsonPreferredLayersIt->end() && - Utils::Json::IsPositiveInteger(*jsonTemporalLayerIt) - ) - // clang-format on + if (flatbuffers::IsFieldPresent( + data->preferredLayers(), FBS::Consumer::ConsumerLayers::VT_TEMPORALLAYER)) { - this->preferredTemporalLayer = jsonTemporalLayerIt->get(); - if (this->preferredTemporalLayer > encoding.temporalLayers - 1) this->preferredTemporalLayer = encoding.temporalLayers - 1; } @@ -110,8 +89,7 @@ namespace RTC this->shared->channelMessageRegistrator->RegisterHandler( this->id, /*channelRequestHandler*/ this, - /*payloadChannelRequestHandler*/ nullptr, - /*payloadChannelNotificationHandler*/ nullptr); + /*channelNotificationHandler*/ nullptr); } SvcConsumer::~SvcConsumer() @@ -123,74 +101,87 @@ namespace RTC delete this->rtpStream; } - void SvcConsumer::FillJson(json& jsonObject) const + flatbuffers::Offset SvcConsumer::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); // Call the parent method. - RTC::Consumer::FillJson(jsonObject); - + auto base = RTC::Consumer::FillBuffer(builder); // Add rtpStream. - this->rtpStream->FillJson(jsonObject["rtpStream"]); - - // Add preferredSpatialLayer. - jsonObject["preferredSpatialLayer"] = this->preferredSpatialLayer; - - // Add targetSpatialLayer. - jsonObject["targetSpatialLayer"] = this->encodingContext->GetTargetSpatialLayer(); - - // Add currentSpatialLayer. - jsonObject["currentSpatialLayer"] = this->encodingContext->GetCurrentSpatialLayer(); - - // Add preferredTemporalLayer. - jsonObject["preferredTemporalLayer"] = this->preferredTemporalLayer; - - // Add targetTemporalLayer. - jsonObject["targetTemporalLayer"] = this->encodingContext->GetTargetTemporalLayer(); - - // Add currentTemporalLayer. - jsonObject["currentTemporalLayer"] = this->encodingContext->GetCurrentTemporalLayer(); + auto rtpStream = this->rtpStream->FillBuffer(builder); + + auto svcConsumerDump = FBS::Consumer::CreateSvcConsumerDump( + builder, + base, + rtpStream, + this->preferredSpatialLayer, + this->encodingContext->GetTargetSpatialLayer(), + this->encodingContext->GetCurrentSpatialLayer(), + this->preferredTemporalLayer, + this->encodingContext->GetTargetTemporalLayer(), + this->encodingContext->GetCurrentTemporalLayer()); + + return FBS::Consumer::CreateDumpResponse( + builder, + FBS::Consumer::DumpData::SvcConsumerDump, + svcConsumerDump.Union(), + FBS::RtpParameters::Type(this->type)); } - void SvcConsumer::FillJsonStats(json& jsonArray) const + flatbuffers::Offset SvcConsumer::FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) { MS_TRACE(); + std::vector> rtpStreams; + // Add stats of our send stream. - jsonArray.emplace_back(json::value_t::object); - this->rtpStream->FillJsonStats(jsonArray[0]); + rtpStreams.emplace_back(this->rtpStream->FillBufferStats(builder)); // Add stats of our recv stream. if (this->producerRtpStream) { - jsonArray.emplace_back(json::value_t::object); - this->producerRtpStream->FillJsonStats(jsonArray[1]); + rtpStreams.emplace_back(producerRtpStream->FillBufferStats(builder)); } + + return FBS::Consumer::CreateGetStatsResponseDirect(builder, &rtpStreams); } - void SvcConsumer::FillJsonScore(json& jsonObject) const + flatbuffers::Offset SvcConsumer::FillBufferScore( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); MS_ASSERT(this->producerRtpStreamScores, "producerRtpStreamScores not set"); - jsonObject["score"] = this->rtpStream->GetScore(); + uint8_t producerScore{ 0 }; if (this->producerRtpStream) - jsonObject["producerScore"] = this->producerRtpStream->GetScore(); + producerScore = this->producerRtpStream->GetScore(); else - jsonObject["producerScore"] = 0; + producerScore = 0; - jsonObject["producerScores"] = *this->producerRtpStreamScores; + return FBS::Consumer::CreateConsumerScoreDirect( + builder, this->rtpStream->GetScore(), producerScore, this->producerRtpStreamScores); } void SvcConsumer::HandleRequest(Channel::ChannelRequest* request) { MS_TRACE(); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::CONSUMER_REQUEST_KEY_FRAME: + case Channel::ChannelRequest::Method::CONSUMER_DUMP: + { + auto dumpOffset = FillBuffer(request->GetBufferBuilder()); + + request->Accept(FBS::Response::Body::FBS_Consumer_DumpResponse, dumpOffset); + + break; + } + + case Channel::ChannelRequest::Method::CONSUMER_REQUEST_KEY_FRAME: { if (IsActive()) RequestKeyFrame(); @@ -200,39 +191,24 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::CONSUMER_SET_PREFERRED_LAYERS: + case Channel::ChannelRequest::Method::CONSUMER_SET_PREFERRED_LAYERS: { auto previousPreferredSpatialLayer = this->preferredSpatialLayer; auto previousPreferredTemporalLayer = this->preferredTemporalLayer; - auto jsonSpatialLayerIt = request->data.find("spatialLayer"); - auto jsonTemporalLayerIt = request->data.find("temporalLayer"); + const auto* body = request->data->body_as(); + const auto* preferredLayers = body->preferredLayers(); // Spatial layer. - // clang-format off - if ( - jsonSpatialLayerIt == request->data.end() || - !Utils::Json::IsPositiveInteger(*jsonSpatialLayerIt) - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("missing spatialLayer"); - } - - this->preferredSpatialLayer = jsonSpatialLayerIt->get(); + this->preferredSpatialLayer = preferredLayers->spatialLayer(); if (this->preferredSpatialLayer > this->rtpStream->GetSpatialLayers() - 1) this->preferredSpatialLayer = this->rtpStream->GetSpatialLayers() - 1; // preferredTemporaLayer is optional. - // clang-format off - if ( - jsonTemporalLayerIt != request->data.end() && - Utils::Json::IsPositiveInteger(*jsonTemporalLayerIt) - ) - // clang-format on + if (preferredLayers->temporalLayer().has_value()) { - this->preferredTemporalLayer = jsonTemporalLayerIt->get(); + this->preferredTemporalLayer = preferredLayers->temporalLayer().value(); if (this->preferredTemporalLayer > this->rtpStream->GetTemporalLayers() - 1) this->preferredTemporalLayer = this->rtpStream->GetTemporalLayers() - 1; @@ -248,12 +224,13 @@ namespace RTC this->preferredTemporalLayer, this->id.c_str()); - json data = json::object(); - - data["spatialLayer"] = this->preferredSpatialLayer; - data["temporalLayer"] = this->preferredTemporalLayer; + const flatbuffers::Optional preferredTemporalLayer{ this->preferredTemporalLayer }; + auto preferredLayersOffset = FBS::Consumer::CreateConsumerLayers( + request->GetBufferBuilder(), this->preferredSpatialLayer, preferredTemporalLayer); + auto responseOffset = FBS::Consumer::CreateSetPreferredLayersResponse( + request->GetBufferBuilder(), preferredLayersOffset); - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_Consumer_SetPreferredLayersResponse, responseOffset); // clang-format off if ( @@ -1139,11 +1116,16 @@ namespace RTC { MS_TRACE(); - json data = json::object(); + auto scoreOffset = FillBufferScore(this->shared->channelNotifier->GetBufferBuilder()); - FillJsonScore(data); + auto notificationOffset = FBS::Consumer::CreateScoreNotification( + this->shared->channelNotifier->GetBufferBuilder(), scoreOffset); - this->shared->channelNotifier->Emit(this->id, "score", data); + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::CONSUMER_SCORE, + FBS::Notification::Body::FBS_Consumer_ScoreNotification, + notificationOffset); } inline void SvcConsumer::EmitLayersChange() const @@ -1156,19 +1138,24 @@ namespace RTC this->encodingContext->GetCurrentTemporalLayer(), this->id.c_str()); - json data = json::object(); + flatbuffers::Offset layersOffset; if (this->encodingContext->GetCurrentSpatialLayer() >= 0) { - data["spatialLayer"] = this->encodingContext->GetCurrentSpatialLayer(); - data["temporalLayer"] = this->encodingContext->GetCurrentTemporalLayer(); - } - else - { - data = nullptr; + layersOffset = FBS::Consumer::CreateConsumerLayers( + this->shared->channelNotifier->GetBufferBuilder(), + this->encodingContext->GetCurrentSpatialLayer(), + this->encodingContext->GetCurrentTemporalLayer()); } - this->shared->channelNotifier->Emit(this->id, "layerschange", data); + auto notificationOffset = FBS::Consumer::CreateLayersChangeNotification( + this->shared->channelNotifier->GetBufferBuilder(), layersOffset); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::CONSUMER_LAYERS_CHANGE, + FBS::Notification::Body::FBS_Consumer_LayersChangeNotification, + notificationOffset); } inline void SvcConsumer::OnRtpStreamScore( diff --git a/worker/src/RTC/Transport.cpp b/worker/src/RTC/Transport.cpp index 65e0b57c73..5c14bfba63 100644 --- a/worker/src/RTC/Transport.cpp +++ b/worker/src/RTC/Transport.cpp @@ -5,6 +5,7 @@ #include "Logger.hpp" #include "MediaSoupErrors.hpp" #include "Utils.hpp" +#include "FBS/transport_generated.h" #include "RTC/BweType.hpp" #include "RTC/PipeConsumer.hpp" #include "RTC/RTCP/FeedbackPs.hpp" @@ -30,148 +31,70 @@ namespace RTC /* Instance methods. */ - Transport::Transport(RTC::Shared* shared, const std::string& id, Listener* listener, json& data) + Transport::Transport( + RTC::Shared* shared, + const std::string& id, + RTC::Transport::Listener* listener, + const FBS::Transport::Options* options) : id(id), shared(shared), listener(listener), recvRtxTransmission(1000u), sendRtxTransmission(1000u), sendProbationTransmission(100u) { MS_TRACE(); - auto jsonDirectIt = data.find("direct"); - - // clang-format off - if ( - jsonDirectIt != data.end() && - jsonDirectIt->is_boolean() && - jsonDirectIt->get() - ) - // clang-format on + if (options->direct()) { - this->direct = true; - - auto jsonMaxMessageSizeIt = data.find("maxMessageSize"); - - // maxMessageSize is mandatory for direct Transports. - // clang-format off - if ( - jsonMaxMessageSizeIt == data.end() || - !Utils::Json::IsPositiveInteger(*jsonMaxMessageSizeIt) - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("wrong maxMessageSize (not a number)"); - } - - this->maxMessageSize = jsonMaxMessageSizeIt->get(); + this->direct = true; + this->maxMessageSize = options->maxMessageSize(); } - auto jsonInitialAvailableOutgoingBitrateIt = data.find("initialAvailableOutgoingBitrate"); + this->initialAvailableOutgoingBitrate = options->initialAvailableOutgoingBitrate(); - if (jsonInitialAvailableOutgoingBitrateIt != data.end()) - { - if (!Utils::Json::IsPositiveInteger(*jsonInitialAvailableOutgoingBitrateIt)) - { - MS_THROW_TYPE_ERROR("wrong initialAvailableOutgoingBitrate (not a number)"); - } - - this->initialAvailableOutgoingBitrate = jsonInitialAvailableOutgoingBitrateIt->get(); - } - - auto jsonEnableSctpIt = data.find("enableSctp"); - - // clang-format off - if ( - jsonEnableSctpIt != data.end() && - jsonEnableSctpIt->is_boolean() && - jsonEnableSctpIt->get() - ) - // clang-format on + if (options->enableSctp()) { if (this->direct) { MS_THROW_TYPE_ERROR("cannot enable SCTP in a direct Transport"); } - auto jsonNumSctpStreamsIt = data.find("numSctpStreams"); - auto jsonMaxSctpMessageSizeIt = data.find("maxSctpMessageSize"); - auto jsonSctpSendBufferSizeIt = data.find("sctpSendBufferSize"); - auto jsonIsDataChannelIt = data.find("isDataChannel"); - // numSctpStreams is mandatory. - // clang-format off - if ( - jsonNumSctpStreamsIt == data.end() || - !jsonNumSctpStreamsIt->is_object() - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("wrong numSctpStreams (not an object)"); - } - - auto jsonOSIt = jsonNumSctpStreamsIt->find("OS"); - auto jsonMISIt = jsonNumSctpStreamsIt->find("MIS"); - - // numSctpStreams.OS and numSctpStreams.MIS are mandatory. - // clang-format off - if ( - jsonOSIt == jsonNumSctpStreamsIt->end() || - !Utils::Json::IsPositiveInteger(*jsonOSIt) || - jsonMISIt == jsonNumSctpStreamsIt->end() || - !Utils::Json::IsPositiveInteger(*jsonMISIt) - ) - // clang-format on + if (!flatbuffers::IsFieldPresent(options, FBS::Transport::Options::VT_NUMSCTPSTREAMS)) { - MS_THROW_TYPE_ERROR("wrong numSctpStreams.OS and/or numSctpStreams.MIS (not a number)"); + MS_THROW_TYPE_ERROR("numSctpStreams missing"); } - auto os = jsonOSIt->get(); - auto mis = jsonMISIt->get(); - // maxSctpMessageSize is mandatory. - // clang-format off - if ( - jsonMaxSctpMessageSizeIt == data.end() || - !Utils::Json::IsPositiveInteger(*jsonMaxSctpMessageSizeIt) - ) - // clang-format on + if (!flatbuffers::IsFieldPresent(options, FBS::Transport::Options::VT_MAXSCTPMESSAGESIZE)) { - MS_THROW_TYPE_ERROR("wrong maxSctpMessageSize (not a number)"); + MS_THROW_TYPE_ERROR("maxSctpMessageSize missing"); } - this->maxMessageSize = jsonMaxSctpMessageSizeIt->get(); + this->maxMessageSize = options->maxSctpMessageSize(); size_t sctpSendBufferSize; // sctpSendBufferSize is optional. - if (jsonSctpSendBufferSizeIt != data.end()) + if (flatbuffers::IsFieldPresent(options, FBS::Transport::Options::VT_SCTPSENDBUFFERSIZE)) { - if (!Utils::Json::IsPositiveInteger(*jsonSctpSendBufferSizeIt)) - { - MS_THROW_TYPE_ERROR("wrong sctpSendBufferSize (not a number)"); - } - - sctpSendBufferSize = jsonSctpSendBufferSizeIt->get(); - - if (sctpSendBufferSize > MaxSctpSendBufferSize) + if (options->sctpSendBufferSize() > MaxSctpSendBufferSize) { MS_THROW_TYPE_ERROR("wrong sctpSendBufferSize (maximum value exceeded)"); } + + sctpSendBufferSize = options->sctpSendBufferSize(); } else { sctpSendBufferSize = DefaultSctpSendBufferSize; } - // isDataChannel is optional. - bool isDataChannel{ false }; - - if (jsonIsDataChannelIt != data.end() && jsonIsDataChannelIt->is_boolean()) - { - isDataChannel = jsonIsDataChannelIt->get(); - } - // This may throw. this->sctpAssociation = new RTC::SctpAssociation( - this, os, mis, this->maxMessageSize, sctpSendBufferSize, isDataChannel); + this, + options->numSctpStreams()->os(), + options->numSctpStreams()->mis(), + this->maxMessageSize, + sctpSendBufferSize, + options->isDataChannel()); } // Create the RTCP timer. @@ -303,189 +226,184 @@ namespace RTC this->listener->OnTransportListenServerClosed(this); } - void Transport::FillJson(json& jsonObject) const + flatbuffers::Offset Transport::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Add id. - jsonObject["id"] = this->id; - - // Add direct. - jsonObject["direct"] = this->direct; - // Add producerIds. - jsonObject["producerIds"] = json::array(); - auto jsonProducerIdsIt = jsonObject.find("producerIds"); + std::vector> producerIds; for (const auto& kv : this->mapProducers) { const auto& producerId = kv.first; - jsonProducerIdsIt->emplace_back(producerId); + producerIds.emplace_back(builder.CreateString(producerId)); } // Add consumerIds. - jsonObject["consumerIds"] = json::array(); - auto jsonConsumerIdsIt = jsonObject.find("consumerIds"); + std::vector> consumerIds; for (const auto& kv : this->mapConsumers) { const auto& consumerId = kv.first; - jsonConsumerIdsIt->emplace_back(consumerId); + consumerIds.emplace_back(builder.CreateString(consumerId)); } // Add mapSsrcConsumerId. - jsonObject["mapSsrcConsumerId"] = json::object(); - auto jsonMapSsrcConsumerId = jsonObject.find("mapSsrcConsumerId"); + std::vector> mapSsrcConsumerId; for (const auto& kv : this->mapSsrcConsumer) { auto ssrc = kv.first; auto* consumer = kv.second; - (*jsonMapSsrcConsumerId)[std::to_string(ssrc)] = consumer->id; + mapSsrcConsumerId.emplace_back( + FBS::Common::CreateUint32StringDirect(builder, ssrc, consumer->id.c_str())); } // Add mapRtxSsrcConsumerId. - jsonObject["mapRtxSsrcConsumerId"] = json::object(); - auto jsonMapRtxSsrcConsumerId = jsonObject.find("mapRtxSsrcConsumerId"); + std::vector> mapRtxSsrcConsumerId; for (const auto& kv : this->mapRtxSsrcConsumer) { auto ssrc = kv.first; auto* consumer = kv.second; - (*jsonMapRtxSsrcConsumerId)[std::to_string(ssrc)] = consumer->id; + mapRtxSsrcConsumerId.emplace_back( + FBS::Common::CreateUint32StringDirect(builder, ssrc, consumer->id.c_str())); } // Add dataProducerIds. - jsonObject["dataProducerIds"] = json::array(); - auto jsonDataProducerIdsIt = jsonObject.find("dataProducerIds"); + std::vector> dataProducerIds; for (const auto& kv : this->mapDataProducers) { const auto& dataProducerId = kv.first; - jsonDataProducerIdsIt->emplace_back(dataProducerId); + dataProducerIds.emplace_back(builder.CreateString(dataProducerId)); } // Add dataConsumerIds. - jsonObject["dataConsumerIds"] = json::array(); - auto jsonDataConsumerIdsIt = jsonObject.find("dataConsumerIds"); + std::vector> dataConsumerIds; for (const auto& kv : this->mapDataConsumers) { const auto& dataConsumerId = kv.first; - jsonDataConsumerIdsIt->emplace_back(dataConsumerId); + dataConsumerIds.emplace_back(builder.CreateString(dataConsumerId)); } // Add headerExtensionIds. - jsonObject["recvRtpHeaderExtensions"] = json::object(); - auto jsonRtpHeaderExtensionsIt = jsonObject.find("recvRtpHeaderExtensions"); + std::vector> recvRtpHeaderExtensions; if (this->recvRtpHeaderExtensionIds.mid != 0u) { - (*jsonRtpHeaderExtensionsIt)["mid"] = this->recvRtpHeaderExtensionIds.mid; + recvRtpHeaderExtensions.emplace_back( + FBS::Common::CreateStringUint8Direct(builder, "mid", this->recvRtpHeaderExtensionIds.mid)); } if (this->recvRtpHeaderExtensionIds.rid != 0u) { - (*jsonRtpHeaderExtensionsIt)["rid"] = this->recvRtpHeaderExtensionIds.rid; + recvRtpHeaderExtensions.emplace_back( + FBS::Common::CreateStringUint8Direct(builder, "rid", this->recvRtpHeaderExtensionIds.rid)); } if (this->recvRtpHeaderExtensionIds.rrid != 0u) { - (*jsonRtpHeaderExtensionsIt)["rrid"] = this->recvRtpHeaderExtensionIds.rrid; + recvRtpHeaderExtensions.emplace_back(FBS::Common::CreateStringUint8Direct( + builder, "rrid", this->recvRtpHeaderExtensionIds.rrid)); } if (this->recvRtpHeaderExtensionIds.absSendTime != 0u) { - (*jsonRtpHeaderExtensionsIt)["absSendTime"] = this->recvRtpHeaderExtensionIds.absSendTime; + recvRtpHeaderExtensions.emplace_back(FBS::Common::CreateStringUint8Direct( + builder, "absSendTime", this->recvRtpHeaderExtensionIds.absSendTime)); } if (this->recvRtpHeaderExtensionIds.transportWideCc01 != 0u) { - (*jsonRtpHeaderExtensionsIt)["transportWideCc01"] = - this->recvRtpHeaderExtensionIds.transportWideCc01; + recvRtpHeaderExtensions.emplace_back(FBS::Common::CreateStringUint8Direct( + builder, "transportWideCc01", this->recvRtpHeaderExtensionIds.transportWideCc01)); } - // Add rtpListener. - this->rtpListener.FillJson(jsonObject["rtpListener"]); + auto rtpListenerOffset = this->rtpListener.FillBuffer(builder); - // Add maxMessageSize. - jsonObject["maxMessageSize"] = this->maxMessageSize; + // Add sctpParameters. + flatbuffers::Offset sctpParameters; + // Add sctpState. + std::string sctpState; + // Add sctpListener. + flatbuffers::Offset sctpListener; if (this->sctpAssociation) { // Add sctpParameters. - this->sctpAssociation->FillJson(jsonObject["sctpParameters"]); + sctpParameters = this->sctpAssociation->FillBuffer(builder); - // Add sctpState. switch (this->sctpAssociation->GetState()) { case RTC::SctpAssociation::SctpState::NEW: - jsonObject["sctpState"] = "new"; + sctpState = "new"; break; case RTC::SctpAssociation::SctpState::CONNECTING: - jsonObject["sctpState"] = "connecting"; + sctpState = "connecting"; break; case RTC::SctpAssociation::SctpState::CONNECTED: - jsonObject["sctpState"] = "connected"; + sctpState = "connected"; break; case RTC::SctpAssociation::SctpState::FAILED: - jsonObject["sctpState"] = "failed"; + sctpState = "failed"; break; case RTC::SctpAssociation::SctpState::CLOSED: - jsonObject["sctpState"] = "closed"; + sctpState = "closed"; break; } - // Add sctpListener. - this->sctpListener.FillJson(jsonObject["sctpListener"]); + sctpListener = this->sctpListener.FillBuffer(builder); } // Add traceEventTypes. - std::vector traceEventTypes; - std::ostringstream traceEventTypesStream; + std::vector> traceEventTypes; if (this->traceEventTypes.probation) { - traceEventTypes.emplace_back("probation"); + traceEventTypes.emplace_back(builder.CreateString("probation")); } - if (this->traceEventTypes.bwe) { - traceEventTypes.emplace_back("bwe"); - } - - if (!traceEventTypes.empty()) - { - std::copy( - traceEventTypes.begin(), - traceEventTypes.end() - 1, - std::ostream_iterator(traceEventTypesStream, ",")); - traceEventTypesStream << traceEventTypes.back(); - } - - jsonObject["traceEventTypes"] = traceEventTypesStream.str(); + traceEventTypes.emplace_back(builder.CreateString("bwe")); + } + + return FBS::Transport::CreateDumpDirect( + builder, + this->id.c_str(), + this->direct, + &producerIds, + &consumerIds, + &mapSsrcConsumerId, + &mapRtxSsrcConsumerId, + &dataProducerIds, + &dataConsumerIds, + &recvRtpHeaderExtensions, + rtpListenerOffset, + this->maxMessageSize, + sctpParameters, + sctpState.c_str(), + sctpListener, + &traceEventTypes); } - void Transport::FillJsonStats(json& jsonArray) + flatbuffers::Offset Transport::FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) { MS_TRACE(); auto nowMs = DepLibUV::GetTimeMs(); - jsonArray.emplace_back(json::value_t::object); - auto& jsonObject = jsonArray[0]; - - // Add transportId. - jsonObject["transportId"] = this->id; - - // Add timestamp. - jsonObject["timestamp"] = nowMs; + // Add sctpState. + std::string sctpState; if (this->sctpAssociation) { @@ -493,139 +411,86 @@ namespace RTC switch (this->sctpAssociation->GetState()) { case RTC::SctpAssociation::SctpState::NEW: - jsonObject["sctpState"] = "new"; + sctpState = "new"; break; case RTC::SctpAssociation::SctpState::CONNECTING: - jsonObject["sctpState"] = "connecting"; + sctpState = "connecting"; break; case RTC::SctpAssociation::SctpState::CONNECTED: - jsonObject["sctpState"] = "connected"; + sctpState = "connected"; break; case RTC::SctpAssociation::SctpState::FAILED: - jsonObject["sctpState"] = "failed"; + sctpState = "failed"; break; case RTC::SctpAssociation::SctpState::CLOSED: - jsonObject["sctpState"] = "closed"; + sctpState = "closed"; break; } } - // Add bytesReceived. - jsonObject["bytesReceived"] = this->recvTransmission.GetBytes(); - - // Add recvBitrate. - jsonObject["recvBitrate"] = this->recvTransmission.GetRate(nowMs); - - // Add bytesSent. - jsonObject["bytesSent"] = this->sendTransmission.GetBytes(); - - // Add sendBitrate. - jsonObject["sendBitrate"] = this->sendTransmission.GetRate(nowMs); - - // Add rtpBytesReceived. - jsonObject["rtpBytesReceived"] = this->recvRtpTransmission.GetBytes(); - - // Add rtpRecvBitrate. - jsonObject["rtpRecvBitrate"] = this->recvRtpTransmission.GetBitrate(nowMs); - - // Add rtpBytesSent. - jsonObject["rtpBytesSent"] = this->sendRtpTransmission.GetBytes(); - - // Add rtpSendBitrate. - jsonObject["rtpSendBitrate"] = this->sendRtpTransmission.GetBitrate(nowMs); - - // Add rtxBytesReceived. - jsonObject["rtxBytesReceived"] = this->recvRtxTransmission.GetBytes(); - - // Add rtxRecvBitrate. - jsonObject["rtxRecvBitrate"] = this->recvRtxTransmission.GetBitrate(nowMs); - - // Add rtxBytesSent. - jsonObject["rtxBytesSent"] = this->sendRtxTransmission.GetBytes(); - - // Add rtxSendBitrate. - jsonObject["rtxSendBitrate"] = this->sendRtxTransmission.GetBitrate(nowMs); - - // Add probationBytesSent. - jsonObject["probationBytesSent"] = this->sendProbationTransmission.GetBytes(); - - // Add probationSendBitrate. - jsonObject["probationSendBitrate"] = this->sendProbationTransmission.GetBitrate(nowMs); - - // Add availableOutgoingBitrate. - if (this->tccClient) - { - jsonObject["availableOutgoingBitrate"] = this->tccClient->GetAvailableBitrate(); - } - - // Add availableIncomingBitrate. - if (this->tccServer && this->tccServer->GetAvailableBitrate() != 0u) - { - jsonObject["availableIncomingBitrate"] = this->tccServer->GetAvailableBitrate(); - } - - // Add maxIncomingBitrate. - if (this->maxIncomingBitrate != 0u) - { - jsonObject["maxIncomingBitrate"] = this->maxIncomingBitrate; - } - - // Add packetLossReceived. - if (this->tccServer) - { - jsonObject["rtpPacketLossReceived"] = this->tccServer->GetPacketLoss(); - } - - // Add packetLossSent. - if (this->tccClient) - { - jsonObject["rtpPacketLossSent"] = this->tccClient->GetPacketLoss(); - } + return FBS::Transport::CreateStatsDirect( + builder, + // transportId. + this->id.c_str(), + // timestamp. + nowMs, + // sctpState. + sctpState.c_str(), + // bytesReceived. + this->recvTransmission.GetBytes(), + // recvBitrate. + this->recvTransmission.GetRate(nowMs), + // bytesSent. + this->sendTransmission.GetBytes(), + // sendBitrate. + this->sendTransmission.GetRate(nowMs), + // rtpBytesReceived. + this->recvRtpTransmission.GetBytes(), + // rtpRecvBitrate. + this->recvRtpTransmission.GetBitrate(nowMs), + // rtpBytesSent. + this->sendRtpTransmission.GetBytes(), + // rtpSendBitrate. + this->sendRtpTransmission.GetBitrate(nowMs), + // rtxBytesReceived. + this->recvRtxTransmission.GetBytes(), + // rtxRecvBitrate. + this->recvRtxTransmission.GetBitrate(nowMs), + // rtxBytesSent. + this->sendRtxTransmission.GetBytes(), + // rtxSendBitrate. + this->sendRtxTransmission.GetBitrate(nowMs), + // probationBytesSent. + this->sendProbationTransmission.GetBytes(), + // probationSendBitrate. + this->sendProbationTransmission.GetBitrate(nowMs), + // availableOutgoingBitrate. + this->tccClient ? this->tccClient->GetAvailableBitrate() : 0u, + // availableIncomingBitrate. + this->tccServer ? this->tccServer->GetAvailableBitrate() : 0u, + // maxIncomingBitrate. + this->maxIncomingBitrate, + // maxOutgoingBitrate. + this->maxOutgoingBitrate, + // minOutgoingBitrate. + this->minOutgoingBitrate, + // packetLossReceived. + this->tccServer ? this->tccServer->GetPacketLoss() : 0u, + // packetLossSent. + this->tccClient ? this->tccClient->GetPacketLoss() : 0u); } void Transport::HandleRequest(Channel::ChannelRequest* request) { MS_TRACE(); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::TRANSPORT_DUMP: + case Channel::ChannelRequest::Method::TRANSPORT_SET_MAX_INCOMING_BITRATE: { - json data = json::object(); - - FillJson(data); - - request->Accept(data); + const auto* body = request->data->body_as(); - break; - } - - case Channel::ChannelRequest::MethodId::TRANSPORT_GET_STATS: - { - json data = json::array(); - - FillJsonStats(data); - - request->Accept(data); - - break; - } - - case Channel::ChannelRequest::MethodId::TRANSPORT_SET_MAX_INCOMING_BITRATE: - { - auto jsonBitrateIt = request->data.find("bitrate"); - - // clang-format off - if ( - jsonBitrateIt == request->data.end() || - !Utils::Json::IsPositiveInteger(*jsonBitrateIt) - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("missing bitrate"); - } - - this->maxIncomingBitrate = jsonBitrateIt->get(); + this->maxIncomingBitrate = body->maxIncomingBitrate(); MS_DEBUG_TAG(bwe, "maximum incoming bitrate set to %" PRIu32, this->maxIncomingBitrate); @@ -639,21 +504,10 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::TRANSPORT_SET_MAX_OUTGOING_BITRATE: + case Channel::ChannelRequest::Method::TRANSPORT_SET_MAX_OUTGOING_BITRATE: { - auto jsonBitrateIt = request->data.find("bitrate"); - - // clang-format off - if ( - jsonBitrateIt == request->data.end() || - !Utils::Json::IsPositiveInteger(*jsonBitrateIt) - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("missing bitrate"); - } - - const uint32_t bitrate = jsonBitrateIt->get(); + const auto* body = request->data->body_as(); + const uint32_t bitrate = body->maxOutgoingBitrate(); if (bitrate > 0u && bitrate < RTC::TransportCongestionControlMinOutgoingBitrate) { @@ -689,21 +543,10 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::TRANSPORT_SET_MIN_OUTGOING_BITRATE: + case Channel::ChannelRequest::Method::TRANSPORT_SET_MIN_OUTGOING_BITRATE: { - auto jsonBitrateIt = request->data.find("bitrate"); - - // clang-format off - if ( - jsonBitrateIt == request->data.end() || - !Utils::Json::IsPositiveInteger(*jsonBitrateIt) - ) - // clang-format on - { - MS_THROW_TYPE_ERROR("missing bitrate"); - } - - const uint32_t bitrate = jsonBitrateIt->get(); + const auto* body = request->data->body_as(); + const uint32_t bitrate = body->minOutgoingBitrate(); if (bitrate > 0u && bitrate < RTC::TransportCongestionControlMinOutgoingBitrate) { @@ -739,15 +582,18 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::TRANSPORT_PRODUCE: + case Channel::ChannelRequest::Method::TRANSPORT_PRODUCE: { - std::string producerId; + const auto* body = request->data->body_as(); + auto producerId = body->producerId()->str(); - // This may throw. - SetNewProducerIdFromData(request->data, producerId); + if (this->mapProducers.find(producerId) != this->mapProducers.end()) + { + MS_THROW_ERROR("a Producer with same producerId already exists"); + } // This may throw. - auto* producer = new RTC::Producer(this->shared, producerId, this, request->data); + auto* producer = new RTC::Producer(this->shared, producerId, this, body); // Insert the Producer into the RtpListener. // This may throw. If so, delete the Producer and throw. @@ -815,11 +661,10 @@ namespace RTC } // Create status response. - json data = json::object(); - - data["type"] = RTC::RtpParameters::GetTypeString(producer->GetType()); + auto responseOffset = FBS::Transport::CreateProduceResponse( + request->GetBufferBuilder(), FBS::RtpParameters::Type(producer->GetType())); - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_Transport_ProduceResponse, responseOffset); // Check if TransportCongestionControlServer or REMB server must be // created. @@ -901,31 +746,18 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::TRANSPORT_CONSUME: + case Channel::ChannelRequest::Method::TRANSPORT_CONSUME: { - auto jsonProducerIdIt = request->data.find("producerId"); - - if (jsonProducerIdIt == request->data.end() || !jsonProducerIdIt->is_string()) - { - MS_THROW_TYPE_ERROR("missing producerId"); - } - - std::string producerId = jsonProducerIdIt->get(); - std::string consumerId; - - // This may throw. - SetNewConsumerIdFromData(request->data, consumerId); + const auto* body = request->data->body_as(); + const std::string producerId = body->producerId()->str(); + const std::string consumerId = body->consumerId()->str(); - // Get type. - auto jsonTypeIt = request->data.find("type"); - - if (jsonTypeIt == request->data.end() || !jsonTypeIt->is_string()) + if (this->mapConsumers.find(consumerId) != this->mapConsumers.end()) { - MS_THROW_TYPE_ERROR("missing type"); + MS_THROW_ERROR("a Consumer with same consumerId already exists"); } - // This may throw. - auto type = RTC::RtpParameters::GetType(jsonTypeIt->get()); + auto type = RTC::RtpParameters::Type(body->type()); RTC::Consumer* consumer{ nullptr }; @@ -941,8 +773,7 @@ namespace RTC case RTC::RtpParameters::Type::SIMPLE: { // This may throw. - consumer = - new RTC::SimpleConsumer(this->shared, consumerId, producerId, this, request->data); + consumer = new RTC::SimpleConsumer(this->shared, consumerId, producerId, this, body); break; } @@ -950,8 +781,7 @@ namespace RTC case RTC::RtpParameters::Type::SIMULCAST: { // This may throw. - consumer = - new RTC::SimulcastConsumer(this->shared, consumerId, producerId, this, request->data); + consumer = new RTC::SimulcastConsumer(this->shared, consumerId, producerId, this, body); break; } @@ -959,8 +789,7 @@ namespace RTC case RTC::RtpParameters::Type::SVC: { // This may throw. - consumer = - new RTC::SvcConsumer(this->shared, consumerId, producerId, this, request->data); + consumer = new RTC::SvcConsumer(this->shared, consumerId, producerId, this, body); break; } @@ -968,8 +797,7 @@ namespace RTC case RTC::RtpParameters::Type::PIPE: { // This may throw. - consumer = - new RTC::PipeConsumer(this->shared, consumerId, producerId, this, request->data); + consumer = new RTC::PipeConsumer(this->shared, consumerId, producerId, this, body); break; } @@ -1004,23 +832,25 @@ namespace RTC MS_DEBUG_DEV( "Consumer created [consumerId:%s, producerId:%s]", consumerId.c_str(), producerId.c_str()); - // Create status response. - json data = json::object(); - - data["paused"] = consumer->IsPaused(); - data["producerPaused"] = consumer->IsProducerPaused(); - - consumer->FillJsonScore(data["score"]); - + flatbuffers::Offset preferredLayersOffset; auto preferredLayers = consumer->GetPreferredLayers(); if (preferredLayers.spatial > -1 && preferredLayers.temporal > -1) { - data["preferredLayers"]["spatialLayer"] = preferredLayers.spatial; - data["preferredLayers"]["temporalLayer"] = preferredLayers.temporal; + const flatbuffers::Optional preferredTemporalLayer{ preferredLayers.temporal }; + preferredLayersOffset = FBS::Consumer::CreateConsumerLayers( + request->GetBufferBuilder(), preferredLayers.spatial, preferredTemporalLayer); } - request->Accept(data); + auto scoreOffset = consumer->FillBufferScore(request->GetBufferBuilder()); + auto responseOffset = FBS::Transport::CreateConsumeResponse( + request->GetBufferBuilder(), + consumer->IsPaused(), + consumer->IsProducerPaused(), + scoreOffset, + preferredLayersOffset); + + request->Accept(FBS::Response::Body::FBS_Transport_ConsumeResponse, responseOffset); // Check if Transport Congestion Control client must be created. const auto& rtpHeaderExtensionIds = consumer->GetRtpHeaderExtensionIds(); @@ -1038,19 +868,19 @@ namespace RTC // - there is "transport-cc" in codecs RTCP feedback. // // clang-format off - if ( - consumer->GetKind() == RTC::Media::Kind::VIDEO && - rtpHeaderExtensionIds.transportWideCc01 != 0u && - std::any_of( - codecs.begin(), codecs.end(), [](const RTC::RtpCodecParameters& codec) - { - return std::any_of( - codec.rtcpFeedback.begin(), codec.rtcpFeedback.end(), [](const RTC::RtcpFeedback& fb) + if ( + consumer->GetKind() == RTC::Media::Kind::VIDEO && + rtpHeaderExtensionIds.transportWideCc01 != 0u && + std::any_of( + codecs.begin(), codecs.end(), [](const RTC::RtpCodecParameters& codec) { - return fb.type == "transport-cc"; - }); - }) - ) + return std::any_of( + codec.rtcpFeedback.begin(), codec.rtcpFeedback.end(), [](const RTC::RtcpFeedback& fb) + { + return fb.type == "transport-cc"; + }); + }) + ) // clang-format on { MS_DEBUG_TAG(bwe, "enabling TransportCongestionControlClient with transport-cc"); @@ -1064,19 +894,19 @@ namespace RTC // - there is "remb" in codecs RTCP feedback. // // clang-format off - else if ( - consumer->GetKind() == RTC::Media::Kind::VIDEO && - rtpHeaderExtensionIds.absSendTime != 0u && - std::any_of( - codecs.begin(), codecs.end(), [](const RTC::RtpCodecParameters& codec) - { - return std::any_of( - codec.rtcpFeedback.begin(), codec.rtcpFeedback.end(), [](const RTC::RtcpFeedback& fb) + else if ( + consumer->GetKind() == RTC::Media::Kind::VIDEO && + rtpHeaderExtensionIds.absSendTime != 0u && + std::any_of( + codecs.begin(), codecs.end(), [](const RTC::RtpCodecParameters& codec) { - return fb.type == "goog-remb"; - }); - }) - ) + return std::any_of( + codec.rtcpFeedback.begin(), codec.rtcpFeedback.end(), [](const RTC::RtcpFeedback& fb) + { + return fb.type == "goog-remb"; + }); + }) + ) // clang-format on { MS_DEBUG_TAG(bwe, "enabling TransportCongestionControlClient with REMB"); @@ -1124,20 +954,20 @@ namespace RTC // - there is "transport-cc" in codecs RTCP feedback. // // clang-format off - if ( - !this->senderBwe && - consumer->GetKind() == RTC::Media::Kind::VIDEO && - rtpHeaderExtensionIds.transportWideCc01 != 0u && - std::any_of( - codecs.begin(), codecs.end(), [](const RTC::RtpCodecParameters& codec) - { - return std::any_of( - codec.rtcpFeedback.begin(), codec.rtcpFeedback.end(), [](const RTC::RtcpFeedback& fb) + if ( + !this->senderBwe && + consumer->GetKind() == RTC::Media::Kind::VIDEO && + rtpHeaderExtensionIds.transportWideCc01 != 0u && + std::any_of( + codecs.begin(), codecs.end(), [](const RTC::RtpCodecParameters& codec) { - return fb.type == "transport-cc"; - }); - }) - ) + return std::any_of( + codec.rtcpFeedback.begin(), codec.rtcpFeedback.end(), [](const RTC::RtcpFeedback& fb) + { + return fb.type == "transport-cc"; + }); + }) + ) // clang-format on { MS_DEBUG_TAG(bwe, "enabling SenderBandwidthEstimator"); @@ -1175,7 +1005,7 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::TRANSPORT_PRODUCE_DATA: + case Channel::ChannelRequest::Method::TRANSPORT_PRODUCE_DATA: { // Early check. The Transport must support SCTP or be direct. if (!this->sctpAssociation && !this->direct) @@ -1183,14 +1013,16 @@ namespace RTC MS_THROW_ERROR("SCTP not enabled and not a direct Transport"); } - std::string dataProducerId; + const auto* body = request->data->body_as(); + + auto dataProducerId = body->dataProducerId()->str(); // This may throw. - SetNewDataProducerIdFromData(request->data, dataProducerId); + CheckNoDataProducer(dataProducerId); // This may throw. - auto* dataProducer = new RTC::DataProducer( - this->shared, dataProducerId, this->maxMessageSize, this, request->data); + auto* dataProducer = + new RTC::DataProducer(this->shared, dataProducerId, this->maxMessageSize, this, body); // Verify the type of the DataProducer. switch (dataProducer->GetType()) @@ -1263,16 +1095,14 @@ namespace RTC MS_DEBUG_DEV("DataProducer created [dataProducerId:%s]", dataProducerId.c_str()); - json data = json::object(); - - dataProducer->FillJson(data); + auto dumpOffset = dataProducer->FillBuffer(request->GetBufferBuilder()); - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_DataProducer_DumpResponse, dumpOffset); break; } - case Channel::ChannelRequest::MethodId::TRANSPORT_CONSUME_DATA: + case Channel::ChannelRequest::Method::TRANSPORT_CONSUME_DATA: { // Early check. The Transport must support SCTP or be direct. if (!this->sctpAssociation && !this->direct) @@ -1280,18 +1110,13 @@ namespace RTC MS_THROW_ERROR("SCTP not enabled and not a direct Transport"); } - auto jsonDataProducerIdIt = request->data.find("dataProducerId"); + const auto* body = request->data->body_as(); - if (jsonDataProducerIdIt == request->data.end() || !jsonDataProducerIdIt->is_string()) - { - MS_THROW_ERROR("missing dataProducerId"); - } - - std::string dataProducerId = jsonDataProducerIdIt->get(); - std::string dataConsumerId; + auto dataProducerId = body->dataProducerId()->str(); + auto dataConsumerId = body->dataConsumerId()->str(); // This may throw. - SetNewDataConsumerIdFromData(request->data, dataConsumerId); + CheckNoDataConsumer(dataConsumerId); // This may throw. auto* dataConsumer = new RTC::DataConsumer( @@ -1300,7 +1125,7 @@ namespace RTC dataProducerId, this->sctpAssociation, this, - request->data, + body, this->maxMessageSize); // Verify the type of the DataConsumer. @@ -1356,11 +1181,9 @@ namespace RTC dataConsumerId.c_str(), dataProducerId.c_str()); - json data = json::object(); - - dataConsumer->FillJson(data); + auto dumpOffset = dataConsumer->FillBuffer(request->GetBufferBuilder()); - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_DataConsumer_DumpResponse, dumpOffset); if (IsConnected()) { @@ -1381,33 +1204,22 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::TRANSPORT_ENABLE_TRACE_EVENT: + case Channel::ChannelRequest::Method::TRANSPORT_ENABLE_TRACE_EVENT: { - auto jsonTypesIt = request->data.find("types"); - - // Disable all if no entries. - if (jsonTypesIt == request->data.end() || !jsonTypesIt->is_array()) - { - MS_THROW_TYPE_ERROR("wrong types (not an array)"); - } + const auto* body = request->data->body_as(); // Reset traceEventTypes. struct TraceEventTypes newTraceEventTypes; - for (const auto& type : *jsonTypesIt) + for (const auto& type : *body->events()) { - if (!type.is_string()) - { - MS_THROW_TYPE_ERROR("wrong type (not a string)"); - } - - const std::string typeStr = type.get(); + const auto typeStr = type->str(); if (typeStr == "probation") { newTraceEventTypes.probation = true; } - if (typeStr == "bwe") + else if (typeStr == "bwe") { newTraceEventTypes.bwe = true; } @@ -1420,10 +1232,12 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::TRANSPORT_CLOSE_PRODUCER: + case Channel::ChannelRequest::Method::TRANSPORT_CLOSE_PRODUCER: { + const auto* body = request->data->body_as(); + // This may throw. - RTC::Producer* producer = GetProducerFromData(request->data); + RTC::Producer* producer = GetProducerById(body->producerId()->str()); // Remove it from the RtpListener. this->rtpListener.RemoveProducer(producer); @@ -1457,10 +1271,12 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::TRANSPORT_CLOSE_CONSUMER: + case Channel::ChannelRequest::Method::TRANSPORT_CLOSE_CONSUMER: { + const auto* body = request->data->body_as(); + // This may throw. - RTC::Consumer* consumer = GetConsumerFromData(request->data); + RTC::Consumer* consumer = GetConsumerById(body->consumerId()->str()); // Remove it from the maps. this->mapConsumers.erase(consumer->id); @@ -1501,10 +1317,12 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::TRANSPORT_CLOSE_DATA_PRODUCER: + case Channel::ChannelRequest::Method::TRANSPORT_CLOSE_DATA_PRODUCER: { + const auto* body = request->data->body_as(); + // This may throw. - RTC::DataProducer* dataProducer = GetDataProducerFromData(request->data); + RTC::DataProducer* dataProducer = GetDataProducerById(body->dataProducerId()->str()); if (dataProducer->GetType() == RTC::DataProducer::Type::SCTP) { @@ -1534,10 +1352,12 @@ namespace RTC break; } - case Channel::ChannelRequest::MethodId::TRANSPORT_CLOSE_DATA_CONSUMER: + case Channel::ChannelRequest::Method::TRANSPORT_CLOSE_DATA_CONSUMER: { + const auto* body = request->data->body_as(); + // This may throw. - RTC::DataConsumer* dataConsumer = GetDataConsumerFromData(request->data); + RTC::DataConsumer* dataConsumer = GetDataConsumerById(body->dataConsumerId()->str()); // Remove it from the maps. this->mapDataConsumers.erase(dataConsumer->id); @@ -1563,33 +1383,30 @@ namespace RTC default: { - MS_THROW_ERROR("unknown method '%s'", request->method.c_str()); + MS_THROW_ERROR("unknown method '%s'", request->methodCStr); } } - } - void Transport::HandleRequest(PayloadChannel::PayloadChannelRequest* request) - { - MS_TRACE(); + return; - switch (request->methodId) + switch (request->method) { default: { - MS_THROW_ERROR("unknown method '%s'", request->method.c_str()); + MS_ERROR("unknown method"); } } } - void Transport::HandleNotification(PayloadChannel::PayloadChannelNotification* notification) + void Transport::HandleNotification(Channel::ChannelNotification* notification) { MS_TRACE(); - switch (notification->eventId) + switch (notification->event) { default: { - MS_ERROR("unknown event '%s'", notification->event.c_str()); + MS_ERROR("unknown event '%s'", notification->eventCStr); } } } @@ -1789,88 +1606,50 @@ namespace RTC this->sctpAssociation->ProcessSctpData(data, len); } - void Transport::SetNewProducerIdFromData(json& data, std::string& producerId) const + void Transport::CheckNoDataProducer(const std::string& dataProducerId) const { - MS_TRACE(); - - auto jsonProducerIdIt = data.find("producerId"); - - if (jsonProducerIdIt == data.end() || !jsonProducerIdIt->is_string()) - { - MS_THROW_TYPE_ERROR("missing producerId"); - } - - producerId.assign(jsonProducerIdIt->get()); - - if (this->mapProducers.find(producerId) != this->mapProducers.end()) + if (this->mapDataProducers.find(dataProducerId) != this->mapDataProducers.end()) { - MS_THROW_ERROR("a Producer with same producerId already exists"); + MS_THROW_ERROR("a DataProducer with same dataProducerId already exists"); } } - RTC::Producer* Transport::GetProducerFromData(json& data) const + void Transport::CheckNoDataConsumer(const std::string& dataConsumerId) const { MS_TRACE(); - auto jsonProducerIdIt = data.find("producerId"); - - if (jsonProducerIdIt == data.end() || !jsonProducerIdIt->is_string()) - { - MS_THROW_TYPE_ERROR("missing producerId"); - } - - auto it = this->mapProducers.find(jsonProducerIdIt->get()); - - if (it == this->mapProducers.end()) + if (this->mapDataConsumers.find(dataConsumerId) != this->mapDataConsumers.end()) { - MS_THROW_ERROR("Producer not found"); + MS_THROW_ERROR("a DataConsumer with same dataConsumerId already exists"); } - - RTC::Producer* producer = it->second; - - return producer; } - void Transport::SetNewConsumerIdFromData(json& data, std::string& consumerId) const + RTC::Producer* Transport::GetProducerById(const std::string& producerId) const { MS_TRACE(); - auto jsonConsumerIdIt = data.find("consumerId"); + auto it = this->mapProducers.find(producerId); - if (jsonConsumerIdIt == data.end() || !jsonConsumerIdIt->is_string()) + if (it == this->mapProducers.end()) { - MS_THROW_TYPE_ERROR("missing consumerId"); + MS_THROW_ERROR("Producer not found"); } - consumerId.assign(jsonConsumerIdIt->get()); - - if (this->mapConsumers.find(consumerId) != this->mapConsumers.end()) - { - MS_THROW_ERROR("a Consumer with same consumerId already exists"); - } + return it->second; } - RTC::Consumer* Transport::GetConsumerFromData(json& data) const + RTC::Consumer* Transport::GetConsumerById(const std::string& consumerId) const { MS_TRACE(); - auto jsonConsumerIdIt = data.find("consumerId"); - - if (jsonConsumerIdIt == data.end() || !jsonConsumerIdIt->is_string()) - { - MS_THROW_TYPE_ERROR("missing consumerId"); - } - - auto it = this->mapConsumers.find(jsonConsumerIdIt->get()); + auto it = this->mapConsumers.find(consumerId); if (it == this->mapConsumers.end()) { MS_THROW_ERROR("Consumer not found"); } - RTC::Consumer* consumer = it->second; - - return consumer; + return it->second; } inline RTC::Consumer* Transport::GetConsumerByMediaSsrc(uint32_t ssrc) const @@ -1905,88 +1684,32 @@ namespace RTC return consumer; } - void Transport::SetNewDataProducerIdFromData(json& data, std::string& dataProducerId) const + RTC::DataProducer* Transport::GetDataProducerById(const std::string& dataProducerId) const { MS_TRACE(); - auto jsonDataProducerIdIt = data.find("dataProducerId"); - - if (jsonDataProducerIdIt == data.end() || !jsonDataProducerIdIt->is_string()) - { - MS_THROW_TYPE_ERROR("missing dataProducerId"); - } - - dataProducerId.assign(jsonDataProducerIdIt->get()); - - if (this->mapDataProducers.find(dataProducerId) != this->mapDataProducers.end()) - { - MS_THROW_ERROR("a DataProducer with same dataProducerId already exists"); - } - } - - RTC::DataProducer* Transport::GetDataProducerFromData(json& data) const - { - MS_TRACE(); - - auto jsonDataProducerIdIt = data.find("dataProducerId"); - - if (jsonDataProducerIdIt == data.end() || !jsonDataProducerIdIt->is_string()) - { - MS_THROW_TYPE_ERROR("missing dataProducerId"); - } - - auto it = this->mapDataProducers.find(jsonDataProducerIdIt->get()); + auto it = this->mapDataProducers.find(dataProducerId); if (it == this->mapDataProducers.end()) { MS_THROW_ERROR("DataProducer not found"); } - RTC::DataProducer* dataProducer = it->second; - - return dataProducer; - } - - void Transport::SetNewDataConsumerIdFromData(json& data, std::string& dataConsumerId) const - { - MS_TRACE(); - - auto jsonDataConsumerIdIt = data.find("dataConsumerId"); - - if (jsonDataConsumerIdIt == data.end() || !jsonDataConsumerIdIt->is_string()) - { - MS_THROW_TYPE_ERROR("missing dataConsumerId"); - } - - dataConsumerId.assign(jsonDataConsumerIdIt->get()); - - if (this->mapDataConsumers.find(dataConsumerId) != this->mapDataConsumers.end()) - { - MS_THROW_ERROR("a DataConsumer with same dataConsumerId already exists"); - } + return it->second; } - RTC::DataConsumer* Transport::GetDataConsumerFromData(json& data) const + RTC::DataConsumer* Transport::GetDataConsumerById(const std::string& dataConsumerId) const { MS_TRACE(); - auto jsonDataConsumerIdIt = data.find("dataConsumerId"); - - if (jsonDataConsumerIdIt == data.end() || !jsonDataConsumerIdIt->is_string()) - { - MS_THROW_TYPE_ERROR("missing dataConsumerId"); - } - - auto it = this->mapDataConsumers.find(jsonDataConsumerIdIt->get()); + auto it = this->mapDataConsumers.find(dataConsumerId); if (it == this->mapDataConsumers.end()) { MS_THROW_ERROR("DataConsumer not found"); } - RTC::DataConsumer* dataConsumer = it->second; - - return dataConsumer; + return it->second; } void Transport::HandleRtcpPacket(RTC::RTCP::Packet* packet) @@ -2555,15 +2278,17 @@ namespace RTC return; } - json data = json::object(); - - data["type"] = "probation"; - data["timestamp"] = DepLibUV::GetTimeMs(); - data["direction"] = "out"; + auto notification = FBS::Transport::CreateTraceNotification( + this->shared->channelNotifier->GetBufferBuilder(), + FBS::Transport::TraceType::PROBATION, + DepLibUV::GetTimeMs(), + FBS::Transport::TraceDirection::DIRECTION_OUT); - packet->FillJson(data["info"]); - - this->shared->channelNotifier->Emit(this->id, "trace", data); + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::TRANSPORT_TRACE, + FBS::Notification::Body::FBS_Transport_TraceNotification, + notification); } inline void Transport::EmitTraceEventBweType( @@ -2576,30 +2301,32 @@ namespace RTC return; } - json data = json::object(); - - data["type"] = "bwe"; - data["timestamp"] = DepLibUV::GetTimeMs(); - data["direction"] = "out"; - data["info"]["desiredBitrate"] = bitrates.desiredBitrate; - data["info"]["effectiveDesiredBitrate"] = bitrates.effectiveDesiredBitrate; - data["info"]["minBitrate"] = bitrates.minBitrate; - data["info"]["maxBitrate"] = bitrates.maxBitrate; - data["info"]["startBitrate"] = bitrates.startBitrate; - data["info"]["maxPaddingBitrate"] = bitrates.maxPaddingBitrate; - data["info"]["availableBitrate"] = bitrates.availableBitrate; - - switch (this->tccClient->GetBweType()) - { - case RTC::BweType::TRANSPORT_CC: - data["info"]["type"] = "transport-cc"; - break; - case RTC::BweType::REMB: - data["info"]["type"] = "remb"; - break; - } - - this->shared->channelNotifier->Emit(this->id, "trace", data); + auto traceInfo = FBS::Transport::CreateBweTraceInfo( + this->shared->channelNotifier->GetBufferBuilder(), + bitrates.desiredBitrate, + bitrates.effectiveDesiredBitrate, + bitrates.minBitrate, + bitrates.maxBitrate, + bitrates.startBitrate, + bitrates.maxPaddingBitrate, + bitrates.availableBitrate, + this->tccClient->GetBweType() == RTC::BweType::TRANSPORT_CC + ? FBS::Transport::BweType::TRANSPORT_CC + : FBS::Transport::BweType::REMB); + + auto notification = FBS::Transport::CreateTraceNotification( + this->shared->channelNotifier->GetBufferBuilder(), + FBS::Transport::TraceType::BWE, + DepLibUV::GetTimeMs(), + FBS::Transport::TraceDirection::DIRECTION_OUT, + FBS::Transport::TraceInfo::BweTraceInfo, + traceInfo.Union()); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::TRANSPORT_TRACE, + FBS::Notification::Body::FBS_Transport_TraceNotification, + notification); } inline void Transport::OnProducerPaused(RTC::Producer* producer) @@ -2962,11 +2689,14 @@ namespace RTC MS_TRACE(); // Notify the Node Transport. - json data = json::object(); - - data["sctpState"] = "connecting"; - - this->shared->channelNotifier->Emit(this->id, "sctpstatechange", data); + auto sctpStateChangeOffset = FBS::Transport::CreateSctpStateChangeNotification( + this->shared->channelNotifier->GetBufferBuilder(), FBS::SctpAssociation::SctpState::CONNECTING); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::TRANSPORT_SCTP_STATE_CHANGE, + FBS::Notification::Body::FBS_Transport_SctpStateChangeNotification, + sctpStateChangeOffset); } inline void Transport::OnSctpAssociationConnected(RTC::SctpAssociation* /*sctpAssociation*/) @@ -2985,11 +2715,14 @@ namespace RTC } // Notify the Node Transport. - json data = json::object(); - - data["sctpState"] = "connected"; - - this->shared->channelNotifier->Emit(this->id, "sctpstatechange", data); + auto sctpStateChangeOffset = FBS::Transport::CreateSctpStateChangeNotification( + this->shared->channelNotifier->GetBufferBuilder(), FBS::SctpAssociation::SctpState::CONNECTED); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::TRANSPORT_SCTP_STATE_CHANGE, + FBS::Notification::Body::FBS_Transport_SctpStateChangeNotification, + sctpStateChangeOffset); } inline void Transport::OnSctpAssociationFailed(RTC::SctpAssociation* /*sctpAssociation*/) @@ -3008,11 +2741,14 @@ namespace RTC } // Notify the Node Transport. - json data = json::object(); - - data["sctpState"] = "failed"; - - this->shared->channelNotifier->Emit(this->id, "sctpstatechange", data); + auto sctpStateChangeOffset = FBS::Transport::CreateSctpStateChangeNotification( + this->shared->channelNotifier->GetBufferBuilder(), FBS::SctpAssociation::SctpState::FAILED); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::TRANSPORT_SCTP_STATE_CHANGE, + FBS::Notification::Body::FBS_Transport_SctpStateChangeNotification, + sctpStateChangeOffset); } inline void Transport::OnSctpAssociationClosed(RTC::SctpAssociation* /*sctpAssociation*/) @@ -3031,11 +2767,14 @@ namespace RTC } // Notify the Node Transport. - json data = json::object(); - - data["sctpState"] = "closed"; - - this->shared->channelNotifier->Emit(this->id, "sctpstatechange", data); + auto sctpStateChangeOffset = FBS::Transport::CreateSctpStateChangeNotification( + this->shared->channelNotifier->GetBufferBuilder(), FBS::SctpAssociation::SctpState::CLOSED); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::TRANSPORT_SCTP_STATE_CHANGE, + FBS::Notification::Body::FBS_Transport_SctpStateChangeNotification, + sctpStateChangeOffset); } inline void Transport::OnSctpAssociationSendData( diff --git a/worker/src/RTC/TransportTuple.cpp b/worker/src/RTC/TransportTuple.cpp index ab8dce24b2..4150b2f7e0 100644 --- a/worker/src/RTC/TransportTuple.cpp +++ b/worker/src/RTC/TransportTuple.cpp @@ -9,44 +9,40 @@ namespace RTC { /* Instance methods. */ - void TransportTuple::FillJson(json& jsonObject) const + flatbuffers::Offset TransportTuple::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); int family; - std::string ip; - uint16_t port; - - Utils::IP::GetAddressInfo(GetLocalAddress(), family, ip, port); + std::string localIp; + uint16_t localPort; - // Add localIp. - if (this->localAnnouncedIp.empty()) - jsonObject["localIp"] = ip; - else - jsonObject["localIp"] = this->localAnnouncedIp; + Utils::IP::GetAddressInfo(GetLocalAddress(), family, localIp, localPort); - // Add localPort. - jsonObject["localPort"] = port; + localIp = this->localAnnouncedIp.empty() ? localIp : this->localAnnouncedIp; - Utils::IP::GetAddressInfo(GetRemoteAddress(), family, ip, port); + std::string remoteIp; + uint16_t remotePort; - // Add remoteIp. - jsonObject["remoteIp"] = ip; + Utils::IP::GetAddressInfo(GetRemoteAddress(), family, remoteIp, remotePort); - // Add remotePort. - jsonObject["remotePort"] = port; + std::string protocol; // Add protocol. switch (GetProtocol()) { case Protocol::UDP: - jsonObject["protocol"] = "udp"; + protocol = "udp"; break; case Protocol::TCP: - jsonObject["protocol"] = "tcp"; + protocol = "tcp"; break; } + + return FBS::Transport::CreateTupleDirect( + builder, localIp.c_str(), localPort, remoteIp.c_str(), remotePort, protocol.c_str()); } void TransportTuple::Dump() const diff --git a/worker/src/RTC/WebRtcServer.cpp b/worker/src/RTC/WebRtcServer.cpp index fab070a96c..8e3cf849e2 100644 --- a/worker/src/RTC/WebRtcServer.cpp +++ b/worker/src/RTC/WebRtcServer.cpp @@ -27,113 +27,58 @@ namespace RTC /* Instance methods. */ - WebRtcServer::WebRtcServer(RTC::Shared* shared, const std::string& id, json& data) + WebRtcServer::WebRtcServer( + RTC::Shared* shared, + const std::string& id, + const flatbuffers::Vector>* listenInfos) : id(id), shared(shared) { MS_TRACE(); - auto jsonListenInfosIt = data.find("listenInfos"); - - if (jsonListenInfosIt == data.end()) - MS_THROW_TYPE_ERROR("missing listenInfos"); - else if (!jsonListenInfosIt->is_array()) - MS_THROW_TYPE_ERROR("wrong listenInfos (not an array)"); - else if (jsonListenInfosIt->empty()) + if (listenInfos->size() == 0) MS_THROW_TYPE_ERROR("wrong listenInfos (empty array)"); - else if (jsonListenInfosIt->size() > 8) + else if (listenInfos->size() > 8) MS_THROW_TYPE_ERROR("wrong listenInfos (too many entries)"); - std::vector listenInfos(jsonListenInfosIt->size()); - - for (size_t i{ 0 }; i < jsonListenInfosIt->size(); ++i) + try { - auto& jsonListenInfo = (*jsonListenInfosIt)[i]; - auto& listenInfo = listenInfos[i]; - - if (!jsonListenInfo.is_object()) - MS_THROW_TYPE_ERROR("wrong listenInfo (not an object)"); - - auto jsonProtocolIt = jsonListenInfo.find("protocol"); - - if (jsonProtocolIt == jsonListenInfo.end()) - MS_THROW_TYPE_ERROR("missing listenInfo.protocol"); - else if (!jsonProtocolIt->is_string()) - MS_THROW_TYPE_ERROR("wrong listenInfo.protocol (not an string"); - - std::string protocolStr = jsonProtocolIt->get(); - - Utils::String::ToLowerCase(protocolStr); - - if (protocolStr == "udp") - listenInfo.protocol = RTC::TransportTuple::Protocol::UDP; - else if (protocolStr == "tcp") - listenInfo.protocol = RTC::TransportTuple::Protocol::TCP; - else - MS_THROW_TYPE_ERROR("invalid listenInfo.protocol (must be 'udp' or 'tcp'"); - - auto jsonIpIt = jsonListenInfo.find("ip"); - - if (jsonIpIt == jsonListenInfo.end()) - MS_THROW_TYPE_ERROR("missing listenInfo.ip"); - else if (!jsonIpIt->is_string()) - MS_THROW_TYPE_ERROR("wrong listenInfo.ip (not an string"); - - listenInfo.ip.assign(jsonIpIt->get()); - - // This may throw. - Utils::IP::NormalizeIp(listenInfo.ip); - - auto jsonAnnouncedIpIt = jsonListenInfo.find("announcedIp"); - - if (jsonAnnouncedIpIt != jsonListenInfo.end()) + for (const auto* listenInfo : *listenInfos) { - if (!jsonAnnouncedIpIt->is_string()) - MS_THROW_TYPE_ERROR("wrong listenInfo.announcedIp (not an string)"); + auto ip = listenInfo->ip()->str(); - listenInfo.announcedIp.assign(jsonAnnouncedIpIt->get()); - } + // This may throw. + Utils::IP::NormalizeIp(ip); - uint16_t port{ 0 }; - auto jsonPortIt = jsonListenInfo.find("port"); + std::string announcedIp; - if (jsonPortIt != jsonListenInfo.end()) - { - if (!(jsonPortIt->is_number() && Utils::Json::IsPositiveInteger(*jsonPortIt))) - MS_THROW_TYPE_ERROR("wrong port (not a positive number)"); - - port = jsonPortIt->get(); - } - - listenInfo.port = port; - } + if (flatbuffers::IsFieldPresent(listenInfo, FBS::WebRtcServer::ListenInfo::VT_ANNOUNCEDIP)) + { + announcedIp = listenInfo->announcedIp()->str(); + } - try - { - for (auto& listenInfo : listenInfos) - { - if (listenInfo.protocol == RTC::TransportTuple::Protocol::UDP) + if (listenInfo->protocol() == FBS::Transport::Protocol::UDP) { // This may throw. RTC::UdpSocket* udpSocket; - if (listenInfo.port != 0) - udpSocket = new RTC::UdpSocket(this, listenInfo.ip, listenInfo.port); + if (listenInfo->port() != 0) + udpSocket = new RTC::UdpSocket(this, ip, listenInfo->port()); else - udpSocket = new RTC::UdpSocket(this, listenInfo.ip); + udpSocket = new RTC::UdpSocket(this, ip); - this->udpSocketOrTcpServers.emplace_back(udpSocket, nullptr, listenInfo.announcedIp); + this->udpSocketOrTcpServers.emplace_back(udpSocket, nullptr, announcedIp); } - else if (listenInfo.protocol == RTC::TransportTuple::Protocol::TCP) + else if (listenInfo->protocol() == FBS::Transport::Protocol::TCP) { // This may throw. RTC::TcpServer* tcpServer; - if (listenInfo.port != 0) - tcpServer = new RTC::TcpServer(this, this, listenInfo.ip, listenInfo.port); + if (listenInfo->port() != 0) + tcpServer = new RTC::TcpServer(this, this, ip, listenInfo->port()); else - tcpServer = new RTC::TcpServer(this, this, listenInfo.ip); + tcpServer = new RTC::TcpServer(this, this, ip); - this->udpSocketOrTcpServers.emplace_back(nullptr, tcpServer, listenInfo.announcedIp); + this->udpSocketOrTcpServers.emplace_back(nullptr, tcpServer, announcedIp); } } @@ -141,8 +86,7 @@ namespace RTC this->shared->channelMessageRegistrator->RegisterHandler( this->id, /*channelRequestHandler*/ this, - /*payloadChannelRequestHandler*/ nullptr, - /*payloadChannelNotificationHandler*/ nullptr); + /*channelNotificationHandler*/ nullptr); } catch (const MediaSoupError& error) { @@ -185,120 +129,89 @@ namespace RTC this->webRtcTransports.clear(); } - void WebRtcServer::FillJson(json& jsonObject) const + flatbuffers::Offset WebRtcServer::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Add id. - jsonObject["id"] = this->id; - // Add udpSockets and tcpServers. - jsonObject["udpSockets"] = json::array(); - auto jsonUdpSocketsIt = jsonObject.find("udpSockets"); - jsonObject["tcpServers"] = json::array(); - auto jsonTcpServersIt = jsonObject.find("tcpServers"); - - size_t udpSocketIdx{ 0 }; - size_t tcpServerIdx{ 0 }; + std::vector> udpSockets; + std::vector> tcpServers; - for (auto& item : this->udpSocketOrTcpServers) + for (const auto& item : this->udpSocketOrTcpServers) { if (item.udpSocket) { - jsonUdpSocketsIt->emplace_back(json::value_t::object); - - auto& jsonEntry = (*jsonUdpSocketsIt)[udpSocketIdx]; - - jsonEntry["ip"] = item.udpSocket->GetLocalIp(); - jsonEntry["port"] = item.udpSocket->GetLocalPort(); - - ++udpSocketIdx; + udpSockets.emplace_back(FBS::WebRtcServer::CreateIpPortDirect( + builder, item.udpSocket->GetLocalIp().c_str(), item.udpSocket->GetLocalPort())); } else if (item.tcpServer) { - jsonTcpServersIt->emplace_back(json::value_t::object); - - auto& jsonEntry = (*jsonTcpServersIt)[tcpServerIdx]; - - jsonEntry["ip"] = item.tcpServer->GetLocalIp(); - jsonEntry["port"] = item.tcpServer->GetLocalPort(); - - ++tcpServerIdx; + tcpServers.emplace_back(FBS::WebRtcServer::CreateIpPortDirect( + builder, item.tcpServer->GetLocalIp().c_str(), item.tcpServer->GetLocalPort())); } } // Add webRtcTransportIds. - jsonObject["webRtcTransportIds"] = json::array(); - auto jsonWebRtcTransportIdsIt = jsonObject.find("webRtcTransportIds"); + std::vector> webRtcTransportIds; for (auto* webRtcTransport : this->webRtcTransports) { - jsonWebRtcTransportIdsIt->emplace_back(webRtcTransport->id); + webRtcTransportIds.emplace_back(builder.CreateString(webRtcTransport->id)); } - size_t idx; - // Add localIceUsernameFragments. - jsonObject["localIceUsernameFragments"] = json::array(); - auto jsonLocalIceUsernamesIt = jsonObject.find("localIceUsernameFragments"); + std::vector> localIceUsernameFragments; - idx = 0; - for (auto& kv : this->mapLocalIceUsernameFragmentWebRtcTransport) + for (const auto& kv : this->mapLocalIceUsernameFragmentWebRtcTransport) { const auto& localIceUsernameFragment = kv.first; const auto* webRtcTransport = kv.second; - jsonLocalIceUsernamesIt->emplace_back(json::value_t::object); - - auto& jsonEntry = (*jsonLocalIceUsernamesIt)[idx]; - - jsonEntry["localIceUsernameFragment"] = localIceUsernameFragment; - jsonEntry["webRtcTransportId"] = webRtcTransport->id; - - ++idx; + localIceUsernameFragments.emplace_back(FBS::WebRtcServer::CreateIceUserNameFragmentDirect( + builder, localIceUsernameFragment.c_str(), webRtcTransport->id.c_str())); } // Add tupleHashes. - jsonObject["tupleHashes"] = json::array(); - auto jsonTupleHashesIt = jsonObject.find("tupleHashes"); + std::vector> tupleHashes; - idx = 0; - for (auto& kv : this->mapTupleWebRtcTransport) + for (const auto& kv : this->mapTupleWebRtcTransport) { const auto& tupleHash = kv.first; const auto* webRtcTransport = kv.second; - jsonTupleHashesIt->emplace_back(json::value_t::object); - - auto& jsonEntry = (*jsonTupleHashesIt)[idx]; - - jsonEntry["tupleHash"] = tupleHash; - jsonEntry["webRtcTransportId"] = webRtcTransport->id; - - ++idx; + tupleHashes.emplace_back( + FBS::WebRtcServer::CreateTupleHashDirect(builder, tupleHash, webRtcTransport->id.c_str())); } + + return FBS::WebRtcServer::CreateDumpResponseDirect( + builder, + this->id.c_str(), + &udpSockets, + &tcpServers, + &webRtcTransportIds, + &localIceUsernameFragments, + &tupleHashes); } void WebRtcServer::HandleRequest(Channel::ChannelRequest* request) { MS_TRACE(); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::WEBRTC_SERVER_DUMP: + case Channel::ChannelRequest::Method::WEBRTC_SERVER_DUMP: { - json data = json::object(); - - FillJson(data); + auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_WebRtcServer_DumpResponse, dumpOffset); break; } default: { - MS_THROW_ERROR("unknown method '%s'", request->method.c_str()); + MS_THROW_ERROR("unknown method '%s'", request->methodCStr); } } } diff --git a/worker/src/RTC/WebRtcTransport.cpp b/worker/src/RTC/WebRtcTransport.cpp index 4ec9065d50..5bc1a5c435 100644 --- a/worker/src/RTC/WebRtcTransport.cpp +++ b/worker/src/RTC/WebRtcTransport.cpp @@ -5,6 +5,7 @@ #include "Logger.hpp" #include "MediaSoupErrors.hpp" #include "Utils.hpp" +#include "FBS/webRtcTransport_generated.h" #include // std::pow() namespace RTC @@ -28,169 +29,91 @@ namespace RTC /* Instance methods. */ WebRtcTransport::WebRtcTransport( - RTC::Shared* shared, const std::string& id, RTC::Transport::Listener* listener, json& data) - : RTC::Transport::Transport(shared, id, listener, data) + RTC::Shared* shared, + const std::string& id, + RTC::Transport::Listener* listener, + const FBS::WebRtcTransport::WebRtcTransportOptions* options) + : RTC::Transport::Transport(shared, id, listener, options->base()) { MS_TRACE(); - bool enableUdp{ true }; - auto jsonEnableUdpIt = data.find("enableUdp"); - - if (jsonEnableUdpIt != data.end()) - { - if (!jsonEnableUdpIt->is_boolean()) - MS_THROW_TYPE_ERROR("wrong enableUdp (not a boolean)"); - - enableUdp = jsonEnableUdpIt->get(); - } - - bool enableTcp{ false }; - auto jsonEnableTcpIt = data.find("enableTcp"); - - if (jsonEnableTcpIt != data.end()) - { - if (!jsonEnableTcpIt->is_boolean()) - MS_THROW_TYPE_ERROR("wrong enableTcp (not a boolean)"); - - enableTcp = jsonEnableTcpIt->get(); - } - - bool preferUdp{ false }; - auto jsonPreferUdpIt = data.find("preferUdp"); - - if (jsonPreferUdpIt != data.end()) - { - if (!jsonPreferUdpIt->is_boolean()) - MS_THROW_TYPE_ERROR("wrong preferUdp (not a boolean)"); - - preferUdp = jsonPreferUdpIt->get(); - } - - bool preferTcp{ false }; - auto jsonPreferTcpIt = data.find("preferTcp"); - - if (jsonPreferTcpIt != data.end()) - { - if (!jsonPreferTcpIt->is_boolean()) - MS_THROW_TYPE_ERROR("wrong preferTcp (not a boolean)"); - - preferTcp = jsonPreferTcpIt->get(); - } - - auto jsonListenIpsIt = data.find("listenIps"); - - if (jsonListenIpsIt == data.end()) - MS_THROW_TYPE_ERROR("missing listenIps"); - else if (!jsonListenIpsIt->is_array()) - MS_THROW_TYPE_ERROR("wrong listenIps (not an array)"); - else if (jsonListenIpsIt->empty()) - MS_THROW_TYPE_ERROR("wrong listenIps (empty array)"); - else if (jsonListenIpsIt->size() > 8) - MS_THROW_TYPE_ERROR("wrong listenIps (too many IPs)"); - - std::vector listenIps(jsonListenIpsIt->size()); - - for (size_t i{ 0 }; i < jsonListenIpsIt->size(); ++i) - { - auto& jsonListenIp = (*jsonListenIpsIt)[i]; - auto& listenIp = listenIps[i]; - - if (!jsonListenIp.is_object()) - MS_THROW_TYPE_ERROR("wrong listenIp (not an object)"); - - auto jsonIpIt = jsonListenIp.find("ip"); - - if (jsonIpIt == jsonListenIp.end()) - MS_THROW_TYPE_ERROR("missing listenIp.ip"); - else if (!jsonIpIt->is_string()) - MS_THROW_TYPE_ERROR("wrong listenIp.ip (not an string"); - - listenIp.ip.assign(jsonIpIt->get()); - - // This may throw. - Utils::IP::NormalizeIp(listenIp.ip); - - auto jsonAnnouncedIpIt = jsonListenIp.find("announcedIp"); - - if (jsonAnnouncedIpIt != jsonListenIp.end()) - { - if (!jsonAnnouncedIpIt->is_string()) - MS_THROW_TYPE_ERROR("wrong listenIp.announcedIp (not an string)"); - - listenIp.announcedIp.assign(jsonAnnouncedIpIt->get()); - } - } - - uint16_t port{ 0 }; - auto jsonPortIt = data.find("port"); - - if (jsonPortIt != data.end()) - { - if (!(jsonPortIt->is_number() && Utils::Json::IsPositiveInteger(*jsonPortIt))) - MS_THROW_TYPE_ERROR("wrong port (not a positive number)"); - - port = jsonPortIt->get(); - } + const auto* listenInfo = options->listen_as(); + const auto* listenIps = listenInfo->listenIps(); try { uint16_t iceLocalPreferenceDecrement{ 0 }; - if (enableUdp && enableTcp) - this->iceCandidates.reserve(2 * jsonListenIpsIt->size()); + if (options->enableUdp() && options->enableTcp()) + this->iceCandidates.reserve(2 * listenIps->size()); else - this->iceCandidates.reserve(jsonListenIpsIt->size()); + this->iceCandidates.reserve(listenIps->size()); - for (auto& listenIp : listenIps) + for (const auto* listenIp : *listenIps) { - if (enableUdp) + auto ip = listenIp->ip()->str(); + + // This may throw. + Utils::IP::NormalizeIp(ip); + + if (options->enableUdp()) { uint16_t iceLocalPreference = IceCandidateDefaultLocalPriority - iceLocalPreferenceDecrement; - if (preferUdp) + if (options->preferUdp()) iceLocalPreference += 1000; uint32_t icePriority = generateIceCandidatePriority(iceLocalPreference); // This may throw. RTC::UdpSocket* udpSocket; - if (port != 0) - udpSocket = new RTC::UdpSocket(this, listenIp.ip, port); + if (listenInfo->port() != 0) + udpSocket = new RTC::UdpSocket(this, ip, listenInfo->port()); else - udpSocket = new RTC::UdpSocket(this, listenIp.ip); + udpSocket = new RTC::UdpSocket(this, ip); + + std::string announcedIp; - this->udpSockets[udpSocket] = listenIp.announcedIp; + if (flatbuffers::IsFieldPresent(listenIp, FBS::Transport::ListenIp::VT_ANNOUNCEDIP)) + announcedIp = listenIp->announcedIp()->str(); - if (listenIp.announcedIp.empty()) + this->udpSockets[udpSocket] = announcedIp; + + if (announcedIp.size() == 0) this->iceCandidates.emplace_back(udpSocket, icePriority); else - this->iceCandidates.emplace_back(udpSocket, icePriority, listenIp.announcedIp); + this->iceCandidates.emplace_back(udpSocket, icePriority, announcedIp); } - if (enableTcp) + if (options->enableTcp()) { uint16_t iceLocalPreference = IceCandidateDefaultLocalPriority - iceLocalPreferenceDecrement; - if (preferTcp) + if (options->preferTcp()) iceLocalPreference += 1000; - uint32_t icePriority = generateIceCandidatePriority(iceLocalPreference); + const uint32_t icePriority = generateIceCandidatePriority(iceLocalPreference); // This may throw. RTC::TcpServer* tcpServer; - if (port != 0) - tcpServer = new RTC::TcpServer(this, this, listenIp.ip, port); + if (listenInfo->port() != 0) + tcpServer = new RTC::TcpServer(this, this, ip, listenInfo->port()); else - tcpServer = new RTC::TcpServer(this, this, listenIp.ip); + tcpServer = new RTC::TcpServer(this, this, ip); - this->tcpServers[tcpServer] = listenIp.announcedIp; + std::string announcedIp; - if (listenIp.announcedIp.empty()) + if (flatbuffers::IsFieldPresent(listenIp, FBS::Transport::ListenIp::VT_ANNOUNCEDIP)) + announcedIp = listenIp->announcedIp()->str(); + + this->tcpServers[tcpServer] = announcedIp; + + if (announcedIp.size() == 0) this->iceCandidates.emplace_back(tcpServer, icePriority); else - this->iceCandidates.emplace_back(tcpServer, icePriority, listenIp.announcedIp); + this->iceCandidates.emplace_back(tcpServer, icePriority, announcedIp); } // Decrement initial ICE local preference for next IP. @@ -208,8 +131,7 @@ namespace RTC this->shared->channelMessageRegistrator->RegisterHandler( this->id, /*channelRequestHandler*/ this, - /*payloadChannelRequestHandler*/ this, - /*payloadChannelNotificationHandler*/ this); + /*channelNotificationHandler*/ this); } catch (const MediaSoupError& error) { @@ -252,8 +174,8 @@ namespace RTC RTC::Transport::Listener* listener, WebRtcTransportListener* webRtcTransportListener, std::vector& iceCandidates, - json& data) - : RTC::Transport::Transport(shared, id, listener, data), + const FBS::WebRtcTransport::WebRtcTransportOptions* options) + : RTC::Transport::Transport(shared, id, listener, options->base()), webRtcTransportListener(webRtcTransportListener), iceCandidates(iceCandidates) { MS_TRACE(); @@ -277,8 +199,7 @@ namespace RTC this->shared->channelMessageRegistrator->RegisterHandler( this->id, /*channelRequestHandler*/ this, - /*payloadChannelRequestHandler*/ this, - /*payloadChannelNotificationHandler*/ this); + /*channelNotificationHandler*/ this); } catch (const MediaSoupError& error) { @@ -339,250 +260,249 @@ namespace RTC this->webRtcTransportListener->OnWebRtcTransportClosed(this); } - void WebRtcTransport::FillJson(json& jsonObject) const + flatbuffers::Offset WebRtcTransport::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); - // Call the parent method. - RTC::Transport::FillJson(jsonObject); - - // Add iceRole (we are always "controlled"). - jsonObject["iceRole"] = "controlled"; - // Add iceParameters. - jsonObject["iceParameters"] = json::object(); - auto jsonIceParametersIt = jsonObject.find("iceParameters"); - - (*jsonIceParametersIt)["usernameFragment"] = this->iceServer->GetUsernameFragment(); - (*jsonIceParametersIt)["password"] = this->iceServer->GetPassword(); - (*jsonIceParametersIt)["iceLite"] = true; + auto iceParameters = FBS::WebRtcTransport::CreateIceParametersDirect( + builder, + this->iceServer->GetUsernameFragment().c_str(), + this->iceServer->GetPassword().c_str(), + true); - // Add iceCandidates. - jsonObject["iceCandidates"] = json::array(); - auto jsonIceCandidatesIt = jsonObject.find("iceCandidates"); + std::vector> iceCandidates; + iceCandidates.reserve(this->iceCandidates.size()); - for (size_t i{ 0 }; i < this->iceCandidates.size(); ++i) + for (const auto& iceCandidate : this->iceCandidates) { - jsonIceCandidatesIt->emplace_back(json::value_t::object); - - auto& jsonEntry = (*jsonIceCandidatesIt)[i]; - const auto& iceCandidate = this->iceCandidates[i]; - - iceCandidate.FillJson(jsonEntry); + iceCandidates.emplace_back(iceCandidate.FillBuffer(builder)); } // Add iceState. + std::string iceState; + switch (this->iceServer->GetState()) { case RTC::IceServer::IceState::NEW: - jsonObject["iceState"] = "new"; + iceState = "new"; break; case RTC::IceServer::IceState::CONNECTED: - jsonObject["iceState"] = "connected"; + iceState = "connected"; break; case RTC::IceServer::IceState::COMPLETED: - jsonObject["iceState"] = "completed"; + iceState = "completed"; break; case RTC::IceServer::IceState::DISCONNECTED: - jsonObject["iceState"] = "disconnected"; + iceState = "disconnected"; break; } // Add iceSelectedTuple. - if (this->iceServer->GetSelectedTuple()) - this->iceServer->GetSelectedTuple()->FillJson(jsonObject["iceSelectedTuple"]); + flatbuffers::Offset iceSelectedTuple; - // Add dtlsParameters. - jsonObject["dtlsParameters"] = json::object(); - auto jsonDtlsParametersIt = jsonObject.find("dtlsParameters"); + if (this->iceServer->GetSelectedTuple()) + iceSelectedTuple = this->iceServer->GetSelectedTuple()->FillBuffer(builder); // Add dtlsParameters.fingerprints. - (*jsonDtlsParametersIt)["fingerprints"] = json::array(); - auto jsonDtlsParametersFingerprintsIt = jsonDtlsParametersIt->find("fingerprints"); - auto& fingerprints = this->dtlsTransport->GetLocalFingerprints(); + std::vector> fingerprints; - for (size_t i{ 0 }; i < fingerprints.size(); ++i) + for (const auto& fingerprint : this->dtlsTransport->GetLocalFingerprints()) { - jsonDtlsParametersFingerprintsIt->emplace_back(json::value_t::object); - - auto& jsonEntry = (*jsonDtlsParametersFingerprintsIt)[i]; - auto& fingerprint = fingerprints[i]; + auto& algorithm = RTC::DtlsTransport::GetFingerprintAlgorithmString(fingerprint.algorithm); + const auto& value = fingerprint.value; - jsonEntry["algorithm"] = - RTC::DtlsTransport::GetFingerprintAlgorithmString(fingerprint.algorithm); - jsonEntry["value"] = fingerprint.value; + fingerprints.emplace_back( + FBS::WebRtcTransport::CreateFingerprintDirect(builder, algorithm.c_str(), value.c_str())); } // Add dtlsParameters.role. + std::string dtlsRole; + switch (this->dtlsRole) { case RTC::DtlsTransport::Role::NONE: - (*jsonDtlsParametersIt)["role"] = "none"; + dtlsRole = "none"; break; case RTC::DtlsTransport::Role::AUTO: - (*jsonDtlsParametersIt)["role"] = "auto"; + dtlsRole = "auto"; break; case RTC::DtlsTransport::Role::CLIENT: - (*jsonDtlsParametersIt)["role"] = "client"; + dtlsRole = "client"; break; case RTC::DtlsTransport::Role::SERVER: - (*jsonDtlsParametersIt)["role"] = "server"; + dtlsRole = "server"; break; } // Add dtlsState. + std::string dtlsState; + switch (this->dtlsTransport->GetState()) { case RTC::DtlsTransport::DtlsState::NEW: - jsonObject["dtlsState"] = "new"; + dtlsState = "new"; break; case RTC::DtlsTransport::DtlsState::CONNECTING: - jsonObject["dtlsState"] = "connecting"; + dtlsState = "connecting"; break; case RTC::DtlsTransport::DtlsState::CONNECTED: - jsonObject["dtlsState"] = "connected"; + dtlsState = "connected"; break; case RTC::DtlsTransport::DtlsState::FAILED: - jsonObject["dtlsState"] = "failed"; + dtlsState = "failed"; break; case RTC::DtlsTransport::DtlsState::CLOSED: - jsonObject["dtlsState"] = "closed"; + dtlsState = "closed"; break; } + + // Add base transport dump. + auto base = Transport::FillBuffer(builder); + // Add dtlsParameters. + auto dtlsParameters = + FBS::WebRtcTransport::CreateDtlsParametersDirect(builder, &fingerprints, dtlsRole.c_str()); + + return FBS::WebRtcTransport::CreateDumpResponseDirect( + builder, + base, + // iceRole (we are always "controlled"). + "controlled", + iceParameters, + &iceCandidates, + iceState.c_str(), + iceSelectedTuple, + dtlsParameters, + dtlsState.c_str()); } - void WebRtcTransport::FillJsonStats(json& jsonArray) + flatbuffers::Offset WebRtcTransport::FillBufferStats( + flatbuffers::FlatBufferBuilder& builder) { MS_TRACE(); - // Call the parent method. - RTC::Transport::FillJsonStats(jsonArray); - - auto& jsonObject = jsonArray[0]; - - // Add type. - jsonObject["type"] = "webrtc-transport"; - - // Add iceRole (we are always "controlled"). - jsonObject["iceRole"] = "controlled"; - // Add iceState. + std::string iceState; + switch (this->iceServer->GetState()) { case RTC::IceServer::IceState::NEW: - jsonObject["iceState"] = "new"; + iceState = "new"; break; case RTC::IceServer::IceState::CONNECTED: - jsonObject["iceState"] = "connected"; + iceState = "connected"; break; case RTC::IceServer::IceState::COMPLETED: - jsonObject["iceState"] = "completed"; + iceState = "completed"; break; case RTC::IceServer::IceState::DISCONNECTED: - jsonObject["iceState"] = "disconnected"; + iceState = "disconnected"; break; } + // Add iceSelectedTuple. + flatbuffers::Offset iceSelectedTuple; + if (this->iceServer->GetSelectedTuple()) - { - // Add iceSelectedTuple. - this->iceServer->GetSelectedTuple()->FillJson(jsonObject["iceSelectedTuple"]); - } + iceSelectedTuple = this->iceServer->GetSelectedTuple()->FillBuffer(builder); + + std::string dtlsState; // Add dtlsState. switch (this->dtlsTransport->GetState()) { case RTC::DtlsTransport::DtlsState::NEW: - jsonObject["dtlsState"] = "new"; + dtlsState = "new"; break; case RTC::DtlsTransport::DtlsState::CONNECTING: - jsonObject["dtlsState"] = "connecting"; + dtlsState = "connecting"; break; case RTC::DtlsTransport::DtlsState::CONNECTED: - jsonObject["dtlsState"] = "connected"; + dtlsState = "connected"; break; case RTC::DtlsTransport::DtlsState::FAILED: - jsonObject["dtlsState"] = "failed"; + dtlsState = "failed"; break; case RTC::DtlsTransport::DtlsState::CLOSED: - jsonObject["dtlsState"] = "closed"; + dtlsState = "closed"; break; } + + // Base Transport stats. + auto base = Transport::FillBufferStats(builder); + + return FBS::WebRtcTransport::CreateGetStatsResponseDirect( + builder, + base, + // iceRole (we are always "controlled"). + "controlled", + iceState.c_str(), + iceSelectedTuple, + dtlsState.c_str()); } void WebRtcTransport::HandleRequest(Channel::ChannelRequest* request) { MS_TRACE(); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::TRANSPORT_CONNECT: + case Channel::ChannelRequest::Method::TRANSPORT_GET_STATS: + { + auto responseOffset = FillBufferStats(request->GetBufferBuilder()); + + request->Accept(FBS::Response::Body::FBS_WebRtcTransport_GetStatsResponse, responseOffset); + + break; + } + + case Channel::ChannelRequest::Method::TRANSPORT_DUMP: + { + auto dumpOffset = FillBuffer(request->GetBufferBuilder()); + + request->Accept(FBS::Response::Body::FBS_WebRtcTransport_DumpResponse, dumpOffset); + + break; + } + + case Channel::ChannelRequest::Method::WEBRTC_TRANSPORT_CONNECT: { // Ensure this method is not called twice. if (this->connectCalled) MS_THROW_ERROR("connect() already called"); + const auto* body = request->data->body_as(); + const auto* dtlsParameters = body->dtlsParameters(); + RTC::DtlsTransport::Fingerprint dtlsRemoteFingerprint; RTC::DtlsTransport::Role dtlsRemoteRole; - auto jsonDtlsParametersIt = request->data.find("dtlsParameters"); - - if (jsonDtlsParametersIt == request->data.end() || !jsonDtlsParametersIt->is_object()) - MS_THROW_TYPE_ERROR("missing dtlsParameters"); - - auto jsonFingerprintsIt = jsonDtlsParametersIt->find("fingerprints"); - - if (jsonFingerprintsIt == jsonDtlsParametersIt->end() || !jsonFingerprintsIt->is_array()) - { - MS_THROW_TYPE_ERROR("missing dtlsParameters.fingerprints"); - } - else if (jsonFingerprintsIt->empty()) + if (dtlsParameters->fingerprints()->size() == 0) { MS_THROW_TYPE_ERROR("empty dtlsParameters.fingerprints array"); } // NOTE: Just take the first fingerprint. - for (auto& jsonFingerprint : *jsonFingerprintsIt) + for (const auto& fingerprint : *dtlsParameters->fingerprints()) { - if (!jsonFingerprint.is_object()) - MS_THROW_TYPE_ERROR("wrong entry in dtlsParameters.fingerprints (not an object)"); - - auto jsonAlgorithmIt = jsonFingerprint.find("algorithm"); - - if (jsonAlgorithmIt == jsonFingerprint.end()) - MS_THROW_TYPE_ERROR("missing fingerprint.algorithm"); - else if (!jsonAlgorithmIt->is_string()) - MS_THROW_TYPE_ERROR("wrong fingerprint.algorithm (not a string)"); - dtlsRemoteFingerprint.algorithm = - RTC::DtlsTransport::GetFingerprintAlgorithm(jsonAlgorithmIt->get()); + RTC::DtlsTransport::GetFingerprintAlgorithm(fingerprint->algorithm()->str()); if (dtlsRemoteFingerprint.algorithm == RTC::DtlsTransport::FingerprintAlgorithm::NONE) { MS_THROW_TYPE_ERROR("invalid fingerprint.algorithm value"); } - auto jsonValueIt = jsonFingerprint.find("value"); - - if (jsonValueIt == jsonFingerprint.end()) - MS_THROW_TYPE_ERROR("missing fingerprint.value"); - else if (!jsonValueIt->is_string()) - MS_THROW_TYPE_ERROR("wrong fingerprint.value (not a string)"); - - dtlsRemoteFingerprint.value = jsonValueIt->get(); + dtlsRemoteFingerprint.value = fingerprint->value()->str(); // Just use the first fingerprint. break; } - auto jsonRoleIt = jsonDtlsParametersIt->find("role"); - - if (jsonRoleIt != jsonDtlsParametersIt->end()) + if (flatbuffers::IsFieldPresent(dtlsParameters, FBS::WebRtcTransport::DtlsParameters::VT_ROLE)) { - if (!jsonRoleIt->is_string()) - MS_THROW_TYPE_ERROR("wrong dtlsParameters.role (not a string)"); - - dtlsRemoteRole = RTC::DtlsTransport::StringToRole(jsonRoleIt->get()); + dtlsRemoteRole = RTC::DtlsTransport::StringToRole(dtlsParameters->role()->str()); if (dtlsRemoteRole == RTC::DtlsTransport::Role::NONE) MS_THROW_TYPE_ERROR("invalid dtlsParameters.role value"); @@ -625,28 +545,31 @@ namespace RTC } // Tell the caller about the selected local DTLS role. - json data = json::object(); + std::string dtlsLocalRole; switch (this->dtlsRole) { case RTC::DtlsTransport::Role::CLIENT: - data["dtlsLocalRole"] = "client"; + dtlsLocalRole = "client"; break; case RTC::DtlsTransport::Role::SERVER: - data["dtlsLocalRole"] = "server"; + dtlsLocalRole = "server"; break; default: MS_ABORT("invalid local DTLS role"); } - request->Accept(data); + auto responseOffset = FBS::WebRtcTransport::CreateConnectResponseDirect( + request->GetBufferBuilder(), dtlsLocalRole.c_str()); + + request->Accept(FBS::Response::Body::FBS_WebRtcTransport_ConnectResponse, responseOffset); break; } - case Channel::ChannelRequest::MethodId::TRANSPORT_RESTART_ICE: + case Channel::ChannelRequest::Method::TRANSPORT_RESTART_ICE: { const std::string usernameFragment = Utils::Crypto::GetRandomString(32); const std::string password = Utils::Crypto::GetRandomString(32); @@ -657,16 +580,14 @@ namespace RTC "WebRtcTransport ICE usernameFragment and password changed [id:%s]", this->id.c_str()); // Reply with the updated ICE local parameters. - json data = json::object(); - - data["iceParameters"] = json::object(); - auto jsonIceParametersIt = data.find("iceParameters"); + auto responseOffset = FBS::Transport::CreateRestartIceResponseDirect( + request->GetBufferBuilder(), + this->iceServer->GetUsernameFragment().c_str(), + this->iceServer->GetPassword().c_str(), + true /* iceLite */ + ); - (*jsonIceParametersIt)["usernameFragment"] = this->iceServer->GetUsernameFragment(); - (*jsonIceParametersIt)["password"] = this->iceServer->GetPassword(); - (*jsonIceParametersIt)["iceLite"] = true; - - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_Transport_RestartIceResponse, responseOffset); break; } @@ -679,7 +600,7 @@ namespace RTC } } - void WebRtcTransport::HandleNotification(PayloadChannel::PayloadChannelNotification* notification) + void WebRtcTransport::HandleNotification(Channel::ChannelNotification* notification) { MS_TRACE(); @@ -1300,11 +1221,17 @@ namespace RTC MS_DEBUG_TAG(ice, "ICE selected tuple"); // Notify the Node WebRtcTransport. - json data = json::object(); + auto tuple = this->iceServer->GetSelectedTuple()->FillBuffer( + this->shared->channelNotifier->GetBufferBuilder()); - this->iceServer->GetSelectedTuple()->FillJson(data["iceSelectedTuple"]); + auto notification = FBS::WebRtcTransport::CreateIceSelectedTupleChangeNotification( + this->shared->channelNotifier->GetBufferBuilder(), tuple); - this->shared->channelNotifier->Emit(this->id, "iceselectedtuplechange", data); + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::WEBRTCTRANSPORT_ICE_SELECTED_TUPLE_CHANGE, + FBS::Notification::Body::FBS_WebRtcTransport_IceSelectedTupleChangeNotification, + notification); } inline void WebRtcTransport::OnIceServerConnected(const RTC::IceServer* /*iceServer*/) @@ -1314,11 +1241,14 @@ namespace RTC MS_DEBUG_TAG(ice, "ICE connected"); // Notify the Node WebRtcTransport. - json data = json::object(); - - data["iceState"] = "connected"; + auto iceStateChangeOffset = FBS::WebRtcTransport::CreateIceStateChangeNotification( + this->shared->channelNotifier->GetBufferBuilder(), FBS::WebRtcTransport::IceState::CONNECTED); - this->shared->channelNotifier->Emit(this->id, "icestatechange", data); + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::WEBRTCTRANSPORT_ICE_STATE_CHANGE, + FBS::Notification::Body::FBS_WebRtcTransport_IceStateChangeNotification, + iceStateChangeOffset); // If ready, run the DTLS handler. MayRunDtlsTransport(); @@ -1337,11 +1267,14 @@ namespace RTC MS_DEBUG_TAG(ice, "ICE completed"); // Notify the Node WebRtcTransport. - json data = json::object(); + auto iceStateChangeOffset = FBS::WebRtcTransport::CreateIceStateChangeNotification( + this->shared->channelNotifier->GetBufferBuilder(), FBS::WebRtcTransport::IceState::COMPLETED); - data["iceState"] = "completed"; - - this->shared->channelNotifier->Emit(this->id, "icestatechange", data); + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::WEBRTCTRANSPORT_ICE_STATE_CHANGE, + FBS::Notification::Body::FBS_WebRtcTransport_IceStateChangeNotification, + iceStateChangeOffset); // If ready, run the DTLS handler. MayRunDtlsTransport(); @@ -1360,11 +1293,15 @@ namespace RTC MS_DEBUG_TAG(ice, "ICE disconnected"); // Notify the Node WebRtcTransport. - json data = json::object(); - - data["iceState"] = "disconnected"; + auto iceStateChangeOffset = FBS::WebRtcTransport::CreateIceStateChangeNotification( + this->shared->channelNotifier->GetBufferBuilder(), + FBS::WebRtcTransport::IceState::DISCONNECTED); - this->shared->channelNotifier->Emit(this->id, "icestatechange", data); + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::WEBRTCTRANSPORT_ICE_STATE_CHANGE, + FBS::Notification::Body::FBS_WebRtcTransport_IceStateChangeNotification, + iceStateChangeOffset); // If DTLS was already connected, notify the parent class. if (this->dtlsTransport->GetState() == RTC::DtlsTransport::DtlsState::CONNECTED) @@ -1380,11 +1317,14 @@ namespace RTC MS_DEBUG_TAG(dtls, "DTLS connecting"); // Notify the Node WebRtcTransport. - json data = json::object(); - - data["dtlsState"] = "connecting"; - - this->shared->channelNotifier->Emit(this->id, "dtlsstatechange", data); + auto dtlsStateChangeOffset = FBS::WebRtcTransport::CreateDtlsStateChangeNotification( + this->shared->channelNotifier->GetBufferBuilder(), FBS::WebRtcTransport::DtlsState::CONNECTING); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::WEBRTCTRANSPORT_DTLS_STATE_CHANGE, + FBS::Notification::Body::FBS_WebRtcTransport_DtlsStateChangeNotification, + dtlsStateChangeOffset); } inline void WebRtcTransport::OnDtlsTransportConnected( @@ -1423,12 +1363,16 @@ namespace RTC RTC::SrtpSession::Type::INBOUND, srtpCryptoSuite, srtpRemoteKey, srtpRemoteKeyLen); // Notify the Node WebRtcTransport. - json data = json::object(); - - data["dtlsState"] = "connected"; - data["dtlsRemoteCert"] = remoteCert; + auto dtlsStateChangeOffset = FBS::WebRtcTransport::CreateDtlsStateChangeNotificationDirect( + this->shared->channelNotifier->GetBufferBuilder(), + FBS::WebRtcTransport::DtlsState::CONNECTED, + remoteCert.c_str()); - this->shared->channelNotifier->Emit(this->id, "dtlsstatechange", data); + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::WEBRTCTRANSPORT_DTLS_STATE_CHANGE, + FBS::Notification::Body::FBS_WebRtcTransport_DtlsStateChangeNotification, + dtlsStateChangeOffset); // Tell the parent class. RTC::Transport::Connected(); @@ -1449,11 +1393,14 @@ namespace RTC MS_WARN_TAG(dtls, "DTLS failed"); // Notify the Node WebRtcTransport. - json data = json::object(); - - data["dtlsState"] = "failed"; - - this->shared->channelNotifier->Emit(this->id, "dtlsstatechange", data); + auto dtlsStateChangeOffset = FBS::WebRtcTransport::CreateDtlsStateChangeNotification( + this->shared->channelNotifier->GetBufferBuilder(), FBS::WebRtcTransport::DtlsState::FAILED); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::WEBRTCTRANSPORT_DTLS_STATE_CHANGE, + FBS::Notification::Body::FBS_WebRtcTransport_DtlsStateChangeNotification, + dtlsStateChangeOffset); } inline void WebRtcTransport::OnDtlsTransportClosed(const RTC::DtlsTransport* /*dtlsTransport*/) @@ -1463,11 +1410,14 @@ namespace RTC MS_WARN_TAG(dtls, "DTLS remotely closed"); // Notify the Node WebRtcTransport. - json data = json::object(); - - data["dtlsState"] = "closed"; - - this->shared->channelNotifier->Emit(this->id, "dtlsstatechange", data); + auto dtlsStateChangeOffset = FBS::WebRtcTransport::CreateDtlsStateChangeNotification( + this->shared->channelNotifier->GetBufferBuilder(), FBS::WebRtcTransport::DtlsState::CLOSED); + + this->shared->channelNotifier->Emit( + this->id, + FBS::Notification::Event::WEBRTCTRANSPORT_DTLS_STATE_CHANGE, + FBS::Notification::Body::FBS_WebRtcTransport_DtlsStateChangeNotification, + dtlsStateChangeOffset); // Tell the parent class. RTC::Transport::Disconnected(); diff --git a/worker/src/Settings.cpp b/worker/src/Settings.cpp index 786064d42d..c890b7361c 100644 --- a/worker/src/Settings.cpp +++ b/worker/src/Settings.cpp @@ -5,10 +5,10 @@ #include "Logger.hpp" #include "MediaSoupErrors.hpp" #include "Utils.hpp" -#include // isprint() +#include // isprint() +#include #include // std::ostream_iterator #include -#include #include // std::ostringstream #include extern "C" @@ -263,31 +263,28 @@ void Settings::HandleRequest(Channel::ChannelRequest* request) { MS_TRACE(); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::WORKER_UPDATE_SETTINGS: + case Channel::ChannelRequest::Method::WORKER_UPDATE_SETTINGS: { - auto jsonLogLevelIt = request->data.find("logLevel"); - auto jsonLogTagsIt = request->data.find("logTags"); + auto body = request->data->body_as(); - // Update logLevel if requested. - if (jsonLogLevelIt != request->data.end() && jsonLogLevelIt->is_string()) + if (flatbuffers::IsFieldPresent(body, FBS::Worker::UpdateSettingsRequest::VT_LOGLEVEL)) { - std::string logLevel = *jsonLogLevelIt; + auto logLevel = body->logLevel()->str(); // This may throw. Settings::SetLogLevel(logLevel); } // Update logTags if requested. - if (jsonLogTagsIt != request->data.end() && jsonLogTagsIt->is_array()) + if (flatbuffers::IsFieldPresent(body, FBS::Worker::UpdateSettingsRequest::VT_LOGTAGS)) { std::vector logTags; - for (const auto& logTag : *jsonLogTagsIt) + for (const auto& logTag : *body->logTags()) { - if (logTag.is_string()) - logTags.push_back(logTag); + logTags.push_back(logTag->str()); } Settings::SetLogTags(logTags); @@ -303,7 +300,7 @@ void Settings::HandleRequest(Channel::ChannelRequest* request) default: { - MS_THROW_ERROR("unknown method '%s'", request->method.c_str()); + MS_THROW_ERROR("unknown method '%s'", request->methodCStr); } } } diff --git a/worker/src/Utils/String.cpp b/worker/src/Utils/String.cpp index 0e5cdd2ede..04086187cb 100644 --- a/worker/src/Utils/String.cpp +++ b/worker/src/Utils/String.cpp @@ -170,43 +170,4 @@ namespace Utils return Base64Decode(data, str.size(), outLen); } - - std::vector Utils::String::Split(const std::string& str, char separator, size_t limit) - { - std::vector items; - size_t pos = 0; - - while (pos < str.length()) - { - auto found = str.find(separator, pos); - - std::string item; - if (found != std::string::npos) - { - item = str.substr(pos, found - pos); - items.push_back(item); - } - else - { - item = str.substr(pos, str.size()); - items.push_back(item); - - break; - } - - // Escape the separator character. - pos += item.length() + 1; - - // Limit reached, add the remaining buffer to the last item. - if (limit != 0 && items.size() >= limit) - { - item = str.substr(pos, str.size()); - items.push_back(item); - - break; - } - } - - return items; - } } // namespace Utils diff --git a/worker/src/Worker.cpp b/worker/src/Worker.cpp index 9914efb9c2..18d31cb267 100644 --- a/worker/src/Worker.cpp +++ b/worker/src/Worker.cpp @@ -9,29 +9,25 @@ #include "MediaSoupErrors.hpp" #include "Settings.hpp" #include "Channel/ChannelNotifier.hpp" -#include "PayloadChannel/PayloadChannelNotifier.hpp" +#include "FBS/response_generated.h" +#include "FBS/worker_generated.h" /* Instance methods. */ -Worker::Worker(::Channel::ChannelSocket* channel, PayloadChannel::PayloadChannelSocket* payloadChannel) - : channel(channel), payloadChannel(payloadChannel) +Worker::Worker(::Channel::ChannelSocket* channel) : channel(channel) { MS_TRACE(); // Set us as Channel's listener. this->channel->SetListener(this); - // Set us as PayloadChannel's listener. - this->payloadChannel->SetListener(this); - // Set the SignalHandler. this->signalsHandler = new SignalsHandler(this); // Set up the RTC::Shared singleton. this->shared = new RTC::Shared( /*channelMessageRegistrator*/ new ChannelMessageRegistrator(), - /*channelNotifier*/ new Channel::ChannelNotifier(this->channel), - /*payloadChannelNotifier*/ new PayloadChannel::PayloadChannelNotifier(this->payloadChannel)); + /*channelNotifier*/ new Channel::ChannelNotifier(this->channel)); #ifdef MS_EXECUTABLE { @@ -45,7 +41,8 @@ Worker::Worker(::Channel::ChannelSocket* channel, PayloadChannel::PayloadChannel DepUsrSCTP::CreateChecker(); // Tell the Node process that we are running. - this->shared->channelNotifier->Emit(Logger::pid, "running"); + this->shared->channelNotifier->Emit( + std::to_string(Logger::pid), FBS::Notification::Event::WORKER_RUNNING); MS_DEBUG_DEV("starting libuv loop"); DepLibUV::RunLoop(); @@ -98,48 +95,41 @@ void Worker::Close() // Close the Channel. this->channel->Close(); - - // Close the PayloadChannel. - this->payloadChannel->Close(); } -void Worker::FillJson(json& jsonObject) const +flatbuffers::Offset Worker::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const { - MS_TRACE(); - - // Add pid. - jsonObject["pid"] = Logger::pid; - // Add webRtcServerIds. - jsonObject["webRtcServerIds"] = json::array(); - auto jsonWebRtcServerIdsIt = jsonObject.find("webRtcServerIds"); + std::vector> webRtcServerIds; + webRtcServerIds.reserve(this->mapWebRtcServers.size()); for (const auto& kv : this->mapWebRtcServers) { const auto& webRtcServerId = kv.first; - jsonWebRtcServerIdsIt->emplace_back(webRtcServerId); + webRtcServerIds.push_back(builder.CreateString(webRtcServerId)); } // Add routerIds. - jsonObject["routerIds"] = json::array(); - auto jsonRouterIdsIt = jsonObject.find("routerIds"); + std::vector> routerIds; + routerIds.reserve(this->mapRouters.size()); for (const auto& kv : this->mapRouters) { const auto& routerId = kv.first; - jsonRouterIdsIt->emplace_back(routerId); + routerIds.push_back(builder.CreateString(routerId)); } - // Add channelMessageHandlers. - jsonObject["channelMessageHandlers"] = json::object(); - auto jsonChannelMessageHandlersIt = jsonObject.find("channelMessageHandlers"); + auto channelMessageHandlers = this->shared->channelMessageRegistrator->FillBuffer(builder); - this->shared->channelMessageRegistrator->FillJson(*jsonChannelMessageHandlersIt); + return FBS::Worker::CreateDumpResponseDirect( + builder, Logger::pid, &webRtcServerIds, &routerIds, channelMessageHandlers); } -void Worker::FillJsonResourceUsage(json& jsonObject) const +flatbuffers::Offset Worker::FillBufferResourceUsage( + flatbuffers::FlatBufferBuilder& builder) const { MS_TRACE(); @@ -151,123 +141,85 @@ void Worker::FillJsonResourceUsage(json& jsonObject) const if (err != 0) MS_THROW_ERROR("uv_getrusagerequest() failed: %s", uv_strerror(err)); - // Add ru_utime (uv_timeval_t, user CPU time used, converted to ms). - jsonObject["ru_utime"] = - (uvRusage.ru_utime.tv_sec * static_cast(1000)) + (uvRusage.ru_utime.tv_usec / 1000); - - // Add ru_stime (uv_timeval_t, system CPU time used, converted to ms). - jsonObject["ru_stime"] = - (uvRusage.ru_stime.tv_sec * static_cast(1000)) + (uvRusage.ru_stime.tv_usec / 1000); + return FBS::Worker::CreateResourceUsageResponse( + builder, + // Add ru_utime (uv_timeval_t, user CPU time used, converted to ms). + (uvRusage.ru_utime.tv_sec * static_cast(1000)) + (uvRusage.ru_utime.tv_usec / 1000), + // Add ru_stime (uv_timeval_t, system CPU time used, converted to ms). + (uvRusage.ru_stime.tv_sec * static_cast(1000)) + (uvRusage.ru_stime.tv_usec / 1000), + // Add ru_maxrss (uint64_t, maximum resident set size). + uvRusage.ru_maxrss, - // Add ru_maxrss (uint64_t, maximum resident set size). - jsonObject["ru_maxrss"] = uvRusage.ru_maxrss; + // Add ru_ixrss (uint64_t, integral shared memory size). + uvRusage.ru_ixrss, - // Add ru_ixrss (uint64_t, integral shared memory size). - jsonObject["ru_ixrss"] = uvRusage.ru_ixrss; + // Add ru_idrss (uint64_t, integral unshared data size). + uvRusage.ru_idrss, - // Add ru_idrss (uint64_t, integral unshared data size). - jsonObject["ru_idrss"] = uvRusage.ru_idrss; + // Add ru_isrss (uint64_t, integral unshared stack size). + uvRusage.ru_isrss, - // Add ru_isrss (uint64_t, integral unshared stack size). - jsonObject["ru_isrss"] = uvRusage.ru_isrss; + // Add ru_minflt (uint64_t, page reclaims, soft page faults). + uvRusage.ru_minflt, - // Add ru_minflt (uint64_t, page reclaims, soft page faults). - jsonObject["ru_minflt"] = uvRusage.ru_minflt; + // Add ru_majflt (uint64_t, page faults, hard page faults). + uvRusage.ru_majflt, - // Add ru_majflt (uint64_t, page faults, hard page faults). - jsonObject["ru_majflt"] = uvRusage.ru_majflt; + // Add ru_nswap (uint64_t, swaps). + uvRusage.ru_nswap, - // Add ru_nswap (uint64_t, swaps). - jsonObject["ru_nswap"] = uvRusage.ru_nswap; + // Add ru_inblock (uint64_t, block input operations). + uvRusage.ru_inblock, - // Add ru_inblock (uint64_t, block input operations). - jsonObject["ru_inblock"] = uvRusage.ru_inblock; + // Add ru_oublock (uint64_t, block output operations). + uvRusage.ru_oublock, - // Add ru_oublock (uint64_t, block output operations). - jsonObject["ru_oublock"] = uvRusage.ru_oublock; + // Add ru_msgsnd (uint64_t, IPC messages sent). + uvRusage.ru_msgsnd, - // Add ru_msgsnd (uint64_t, IPC messages sent). - jsonObject["ru_msgsnd"] = uvRusage.ru_msgsnd; + // Add ru_msgrcv (uint64_t, IPC messages received). + uvRusage.ru_msgrcv, - // Add ru_msgrcv (uint64_t, IPC messages received). - jsonObject["ru_msgrcv"] = uvRusage.ru_msgrcv; - - // Add ru_nsignals (uint64_t, signals received). - jsonObject["ru_nsignals"] = uvRusage.ru_nsignals; - - // Add ru_nvcsw (uint64_t, voluntary context switches). - jsonObject["ru_nvcsw"] = uvRusage.ru_nvcsw; - - // Add ru_nivcsw (uint64_t, involuntary context switches). - jsonObject["ru_nivcsw"] = uvRusage.ru_nivcsw; + // Add ru_nsignals (uint64_t, signals received). + uvRusage.ru_nsignals, + // Add ru_nvcsw (uint64_t, voluntary context switches). + uvRusage.ru_nvcsw, + // Add ru_nivcsw (uint64_t, involuntary context switches). + uvRusage.ru_nivcsw); } -void Worker::SetNewWebRtcServerIdFromData(json& data, std::string& webRtcServerId) const +RTC::Router* Worker::GetRouter(const std::string& routerId) const { MS_TRACE(); - auto jsonWebRtcServerIdIt = data.find("webRtcServerId"); + auto it = this->mapRouters.find(routerId); - if (jsonWebRtcServerIdIt == data.end() || !jsonWebRtcServerIdIt->is_string()) - MS_THROW_ERROR("missing webRtcServerId"); - - webRtcServerId.assign(jsonWebRtcServerIdIt->get()); + if (it == this->mapRouters.end()) + MS_THROW_ERROR("Router not found"); - if (this->mapWebRtcServers.find(webRtcServerId) != this->mapWebRtcServers.end()) - MS_THROW_ERROR("a WebRtcServer with same webRtcServerId already exists"); + return it->second; } -RTC::WebRtcServer* Worker::GetWebRtcServerFromData(json& data) const +void Worker::CheckNoWebRtcServer(const std::string& webRtcServerId) const { - MS_TRACE(); - - auto jsonWebRtcServerIdIt = data.find("webRtcServerId"); - - if (jsonWebRtcServerIdIt == data.end() || !jsonWebRtcServerIdIt->is_string()) - MS_THROW_ERROR("missing handlerId.webRtcServerId"); - - auto it = this->mapWebRtcServers.find(jsonWebRtcServerIdIt->get()); - - if (it == this->mapWebRtcServers.end()) - MS_THROW_ERROR("WebRtcServer not found"); - - RTC::WebRtcServer* webRtcServer = it->second; - - return webRtcServer; + if (this->mapWebRtcServers.find(webRtcServerId) != this->mapWebRtcServers.end()) + MS_THROW_ERROR("a WebRtcServer with same webRtcServerId already exists"); } -void Worker::SetNewRouterIdFromData(json& data, std::string& routerId) const +void Worker::CheckNoRouter(const std::string& routerId) const { - MS_TRACE(); - - auto jsonRouterIdIt = data.find("routerId"); - - if (jsonRouterIdIt == data.end() || !jsonRouterIdIt->is_string()) - MS_THROW_ERROR("missing routerId"); - - routerId.assign(jsonRouterIdIt->get()); - if (this->mapRouters.find(routerId) != this->mapRouters.end()) MS_THROW_ERROR("a Router with same routerId already exists"); } -RTC::Router* Worker::GetRouterFromData(json& data) const +RTC::WebRtcServer* Worker::GetWebRtcServer(const std::string& webRtcServerId) const { - MS_TRACE(); - - auto jsonRouterIdIt = data.find("routerId"); - - if (jsonRouterIdIt == data.end() || !jsonRouterIdIt->is_string()) - MS_THROW_ERROR("missing routerId"); - - auto it = this->mapRouters.find(jsonRouterIdIt->get()); - - if (it == this->mapRouters.end()) - MS_THROW_ERROR("Router not found"); + auto it = this->mapWebRtcServers.find(webRtcServerId); - RTC::Router* router = it->second; + if (it == this->mapWebRtcServers.end()) + MS_THROW_ERROR("WebRtcServer not found"); - return router; + return it->second; } inline void Worker::HandleRequest(Channel::ChannelRequest* request) @@ -275,11 +227,11 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) MS_TRACE(); MS_DEBUG_DEV( - "Channel request received [method:%s, id:%" PRIu32 "]", request->method.c_str(), request->id); + "Channel request received [method:%s, id:%" PRIu32 "]", request->methodCStr, request->id); - switch (request->methodId) + switch (request->method) { - case Channel::ChannelRequest::MethodId::WORKER_CLOSE: + case Channel::ChannelRequest::Method::WORKER_CLOSE: { if (this->closed) return; @@ -291,44 +243,42 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) break; } - case Channel::ChannelRequest::MethodId::WORKER_DUMP: + case Channel::ChannelRequest::Method::WORKER_DUMP: { - json data = json::object(); - - FillJson(data); + auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_Worker_DumpResponse, dumpOffset); break; } - case Channel::ChannelRequest::MethodId::WORKER_GET_RESOURCE_USAGE: + case Channel::ChannelRequest::Method::WORKER_GET_RESOURCE_USAGE: { - json data = json::object(); - - FillJsonResourceUsage(data); + auto resourceUsageOffset = FillBufferResourceUsage(request->GetBufferBuilder()); - request->Accept(data); + request->Accept(FBS::Response::Body::FBS_Worker_ResourceUsageResponse, resourceUsageOffset); break; } - case Channel::ChannelRequest::MethodId::WORKER_UPDATE_SETTINGS: + case Channel::ChannelRequest::Method::WORKER_UPDATE_SETTINGS: { Settings::HandleRequest(request); break; } - case Channel::ChannelRequest::MethodId::WORKER_CREATE_WEBRTC_SERVER: + case Channel::ChannelRequest::Method::WORKER_CREATE_WEBRTC_SERVER: { try { - std::string webRtcServerId; + auto body = request->data->body_as(); - SetNewWebRtcServerIdFromData(request->data, webRtcServerId); + std::string webRtcServerId = body->webRtcServerId()->str(); - auto* webRtcServer = new RTC::WebRtcServer(this->shared, webRtcServerId, request->data); + CheckNoWebRtcServer(webRtcServerId); + + auto* webRtcServer = new RTC::WebRtcServer(this->shared, webRtcServerId, body->listenInfos()); this->mapWebRtcServers[webRtcServerId] = webRtcServer; @@ -338,27 +288,31 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) } catch (const MediaSoupTypeError& error) { - MS_THROW_TYPE_ERROR("%s [method:%s]", error.what(), request->method.c_str()); + MS_THROW_TYPE_ERROR("%s [method:%s]", error.what(), request->methodCStr); } catch (const MediaSoupError& error) { - MS_THROW_ERROR("%s [method:%s]", error.what(), request->method.c_str()); + MS_THROW_ERROR("%s [method:%s]", error.what(), request->methodCStr); } break; } - case Channel::ChannelRequest::MethodId::WORKER_WEBRTC_SERVER_CLOSE: + case Channel::ChannelRequest::Method::WORKER_WEBRTC_SERVER_CLOSE: { RTC::WebRtcServer* webRtcServer{ nullptr }; + auto body = request->data->body_as(); + + auto webRtcServerId = body->webRtcServerId()->str(); + try { - webRtcServer = GetWebRtcServerFromData(request->data); + webRtcServer = GetWebRtcServer(webRtcServerId); } catch (const MediaSoupError& error) { - MS_THROW_ERROR("%s [method:%s]", error.what(), request->method.c_str()); + MS_THROW_ERROR("%s [method:%s]", error.what(), request->methodCStr); } // Remove it from the map and delete it. @@ -373,17 +327,19 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) break; } - case Channel::ChannelRequest::MethodId::WORKER_CREATE_ROUTER: + case Channel::ChannelRequest::Method::WORKER_CREATE_ROUTER: { - std::string routerId; + auto body = request->data->body_as(); + + auto routerId = body->routerId()->str(); try { - SetNewRouterIdFromData(request->data, routerId); + CheckNoRouter(routerId); } catch (const MediaSoupError& error) { - MS_THROW_ERROR("%s [method:%s]", error.what(), request->method.c_str()); + MS_THROW_ERROR("%s [method:%s]", error.what(), request->methodCStr); } auto* router = new RTC::Router(this->shared, routerId, this); @@ -397,17 +353,21 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) break; } - case Channel::ChannelRequest::MethodId::WORKER_CLOSE_ROUTER: + case Channel::ChannelRequest::Method::WORKER_CLOSE_ROUTER: { RTC::Router* router{ nullptr }; + auto body = request->data->body_as(); + + auto routerId = body->routerId()->str(); + try { - router = GetRouterFromData(request->data); + router = GetRouter(routerId); } catch (const MediaSoupError& error) { - MS_THROW_ERROR("%s [method:%s]", error.what(), request->method.c_str()); + MS_THROW_ERROR("%s [method:%s]", error.what(), request->methodCStr); } // Remove it from the map and delete it. @@ -439,11 +399,11 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) } catch (const MediaSoupTypeError& error) { - MS_THROW_TYPE_ERROR("%s [method:%s]", error.what(), request->method.c_str()); + MS_THROW_TYPE_ERROR("%s [method:%s]", error.what(), request->methodCStr); } catch (const MediaSoupError& error) { - MS_THROW_ERROR("%s [method:%s]", error.what(), request->method.c_str()); + MS_THROW_ERROR("%s [method:%s]", error.what(), request->methodCStr); } break; @@ -451,90 +411,44 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) } } -inline void Worker::OnChannelClosed(Channel::ChannelSocket* /*socket*/) -{ - MS_TRACE_STD(); - - // Only needed for executable, library user can close channel earlier and it is fine. -#ifdef MS_EXECUTABLE - // If the pipe is remotely closed it may mean that mediasoup Node process - // abruptly died (SIGKILL?) so we must die. - MS_ERROR_STD("channel remotely closed, closing myself"); -#endif - - Close(); -} - -inline void Worker::HandleRequest(PayloadChannel::PayloadChannelRequest* request) +inline void Worker::HandleNotification(Channel::ChannelNotification* notification) { MS_TRACE(); - MS_DEBUG_DEV( - "PayloadChannel request received [method:%s, id:%" PRIu32 "]", - request->method.c_str(), - request->id); + MS_DEBUG_DEV("Channel notification received [event:%s]", notification->eventCStr); try { auto* handler = - this->shared->channelMessageRegistrator->GetPayloadChannelRequestHandler(request->handlerId); - - if (handler == nullptr) - { - MS_THROW_ERROR( - "PayloadChannel request handler with ID %s not found", request->handlerId.c_str()); - } - - handler->HandleRequest(request); - } - catch (const MediaSoupTypeError& error) - { - MS_THROW_TYPE_ERROR("%s [method:%s]", error.what(), request->method.c_str()); - } - catch (const MediaSoupError& error) - { - MS_THROW_ERROR("%s [method:%s]", error.what(), request->method.c_str()); - } -} - -inline void Worker::HandleNotification(PayloadChannel::PayloadChannelNotification* notification) -{ - MS_TRACE(); - - MS_DEBUG_DEV("PayloadChannel notification received [event:%s]", notification->event.c_str()); - - try - { - auto* handler = this->shared->channelMessageRegistrator->GetPayloadChannelNotificationHandler( - notification->handlerId); + this->shared->channelMessageRegistrator->GetChannelNotificationHandler(notification->handlerId); if (handler == nullptr) { MS_THROW_ERROR( - "PayloadChannel notification handler with ID %s not found", notification->handlerId.c_str()); + "Channel notification handler with ID %s not found", notification->handlerId.c_str()); } handler->HandleNotification(notification); } catch (const MediaSoupTypeError& error) { - MS_THROW_TYPE_ERROR("%s [event:%s]", error.what(), notification->event.c_str()); + MS_THROW_TYPE_ERROR("%s [event:%s]", error.what(), notification->eventCStr); } catch (const MediaSoupError& error) { - MS_THROW_ERROR("%s [method:%s]", error.what(), notification->event.c_str()); + MS_THROW_ERROR("%s [method:%s]", error.what(), notification->eventCStr); } } -inline void Worker::OnPayloadChannelClosed(PayloadChannel::PayloadChannelSocket* /*payloadChannel*/) +inline void Worker::OnChannelClosed(Channel::ChannelSocket* /*socket*/) { - MS_TRACE(); + MS_TRACE_STD(); // Only needed for executable, library user can close channel earlier and it is fine. #ifdef MS_EXECUTABLE // If the pipe is remotely closed it may mean that mediasoup Node process // abruptly died (SIGKILL?) so we must die. - MS_ERROR_STD("payloadChannel remotely closed, closing myself"); + MS_ERROR_STD("channel remotely closed, closing myself"); #endif Close(); diff --git a/worker/src/lib.cpp b/worker/src/lib.cpp index 86246cf270..54e3ca9cb5 100644 --- a/worker/src/lib.cpp +++ b/worker/src/lib.cpp @@ -13,7 +13,6 @@ #include "Utils.hpp" #include "Worker.hpp" #include "Channel/ChannelSocket.hpp" -#include "PayloadChannel/PayloadChannelSocket.hpp" #include "RTC/DtlsTransport.hpp" #include "RTC/SrtpSession.hpp" #include @@ -37,11 +36,7 @@ extern "C" int mediasoup_worker_run( ChannelReadFn channelReadFn, ChannelReadCtx channelReadCtx, ChannelWriteFn channelWriteFn, - ChannelWriteCtx channelWriteCtx, - PayloadChannelReadFn payloadChannelReadFn, - PayloadChannelReadCtx payloadChannelReadCtx, - PayloadChannelWriteFn payloadChannelWriteFn, - PayloadChannelWriteCtx payloadChannelWriteCtx) + ChannelWriteCtx channelWriteCtx) { // Initialize libuv stuff (we need it for the Channel). DepLibUV::ClassInit(); @@ -51,11 +46,6 @@ extern "C" int mediasoup_worker_run( // deallocate its UV handles. std::unique_ptr channel{ nullptr }; - // PayloadChannel socket. If Worker instance runs properly, this socket is - // closed by it in its destructor. Otherwise it's closed here by also letting - // libuv deallocate its UV handles. - std::unique_ptr payloadChannel{ nullptr }; - try { if (channelReadFn) @@ -78,30 +68,6 @@ extern "C" int mediasoup_worker_run( return 1; } - try - { - if (payloadChannelReadFn) - { - payloadChannel.reset(new PayloadChannel::PayloadChannelSocket( - payloadChannelReadFn, payloadChannelReadCtx, payloadChannelWriteFn, payloadChannelWriteCtx)); - } - else - { - payloadChannel.reset( - new PayloadChannel::PayloadChannelSocket(payloadConsumeChannelFd, payloadProduceChannelFd)); - } - } - catch (const MediaSoupError& error) - { - MS_ERROR_STD("error creating the PayloadChannel: %s", error.what()); - - channel->Close(); - DepLibUV::RunLoop(); - DepLibUV::ClassDestroy(); - - return 1; - } - // Initialize the Logger. Logger::ClassInit(channel.get()); @@ -114,7 +80,6 @@ extern "C" int mediasoup_worker_run( MS_ERROR_STD("settings error: %s", error.what()); channel->Close(); - payloadChannel->Close(); DepLibUV::RunLoop(); DepLibUV::ClassDestroy(); @@ -126,7 +91,6 @@ extern "C" int mediasoup_worker_run( MS_ERROR_STD("unexpected settings error: %s", error.what()); channel->Close(); - payloadChannel->Close(); DepLibUV::RunLoop(); DepLibUV::ClassDestroy(); @@ -171,7 +135,7 @@ extern "C" int mediasoup_worker_run( #endif // Run the Worker. - Worker worker(channel.get(), payloadChannel.get()); + Worker worker(channel.get()); // Free static stuff. DepLibSRTP::ClassDestroy(); diff --git a/worker/src/lib.rs b/worker/src/lib.rs index 0e4f4e4fb7..fe8aae3d16 100644 --- a/worker/src/lib.rs +++ b/worker/src/lib.rs @@ -38,43 +38,6 @@ pub type ChannelWriteFn = unsafe extern "C" fn( unsafe impl Send for ChannelWriteCtx {} -#[repr(transparent)] -pub struct PayloadChannelReadCtx(pub *const c_void); -pub type PayloadChannelReadFreeFn = Option< - unsafe extern "C" fn( - /* message: */ *mut u8, - /* message_len: */ u32, - /* message_ctx: */ usize, - ), ->; -pub type PayloadChannelReadFn = unsafe extern "C" fn( - /* message: */ *mut *mut u8, - /* message_len: */ *mut u32, - /* message_ctx: */ *mut usize, - /* payload: */ *mut *mut u8, - /* payload_len: */ *mut u32, - /* payload_capacity: */ *mut usize, - // This is `uv_async_t` handle that can be called later with `uv_async_send()` when there is - // more data to read - /* handle */ - UvAsyncT, - /* ctx: */ PayloadChannelReadCtx, -) -> PayloadChannelReadFreeFn; - -unsafe impl Send for PayloadChannelReadCtx {} - -#[repr(transparent)] -pub struct PayloadChannelWriteCtx(pub *const c_void); -pub type PayloadChannelWriteFn = unsafe extern "C" fn( - /* message: */ *const u8, - /* message_len: */ u32, - /* payload: */ *const u8, - /* payload_len: */ u32, - /* ctx: */ PayloadChannelWriteCtx, -); - -unsafe impl Send for PayloadChannelWriteCtx {} - #[link(name = "mediasoup-worker", kind = "static")] extern "C" { /// Returns `0` on success, or an error code `< 0` on failure @@ -92,9 +55,5 @@ extern "C" { channel_read_ctx: ChannelReadCtx, channel_write_fn: ChannelWriteFn, channel_write_ctx: ChannelWriteCtx, - payload_channel_read_fn: PayloadChannelReadFn, - payload_channel_read_ctx: PayloadChannelReadCtx, - payload_channel_write_fn: PayloadChannelWriteFn, - payload_channel_write_ctx: PayloadChannelWriteCtx, ) -> c_int; } diff --git a/worker/src/main.cpp b/worker/src/main.cpp index fcf4f47872..f53b8257a7 100644 --- a/worker/src/main.cpp +++ b/worker/src/main.cpp @@ -34,10 +34,6 @@ int main(int argc, char* argv[]) nullptr, nullptr, nullptr, - nullptr, - nullptr, - nullptr, - nullptr, nullptr); switch (statusCode) diff --git a/worker/subprojects/flatbuffers.wrap b/worker/subprojects/flatbuffers.wrap new file mode 100644 index 0000000000..630611bdb1 --- /dev/null +++ b/worker/subprojects/flatbuffers.wrap @@ -0,0 +1,14 @@ +[wrap-file] +directory = flatbuffers-23.3.3 +source_url = https://github.com/google/flatbuffers/archive/v23.3.3.tar.gz +source_filename = flatbuffers-23.3.3.tar.gz +source_hash = 8aff985da30aaab37edf8e5b02fda33ed4cbdd962699a8e2af98fdef306f4e4d +patch_filename = flatbuffers_23.3.3-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/flatbuffers_23.3.3-1/get_patch +patch_hash = fa5faa75a99d1161be532a5d5db19543c15cb193d116d24827a251fc03488a14 +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/flatbuffers_23.3.3-1/flatbuffers-23.3.3.tar.gz +wrapdb_version = 23.3.3-1 + +[provide] +flatbuffers = flatbuffers_dep +program_names = flatc, flathash diff --git a/worker/subprojects/nlohmann_json.wrap b/worker/subprojects/nlohmann_json.wrap deleted file mode 100644 index 857277a676..0000000000 --- a/worker/subprojects/nlohmann_json.wrap +++ /dev/null @@ -1,10 +0,0 @@ -[wrap-file] -directory = nlohmann_json-3.10.5 -lead_directory_missing = true -source_url = https://github.com/nlohmann/json/releases/download/v3.10.5/include.zip -source_filename = nlohmann_json-3.10.5.zip -source_hash = b94997df68856753b72f0d7a3703b7d484d4745c567f3584ef97c96c25a5798e - -[provide] -nlohmann_json = nlohmann_json_dep - diff --git a/worker/test/src/RTC/TestRtpPacketH264Svc.cpp b/worker/test/src/RTC/TestRtpPacketH264Svc.cpp index 022bee4a13..970cc73284 100644 --- a/worker/test/src/RTC/TestRtpPacketH264Svc.cpp +++ b/worker/test/src/RTC/TestRtpPacketH264Svc.cpp @@ -4,6 +4,7 @@ #include "RTC/RtpPacket.hpp" #include #include // std::memset() +#include #include #include diff --git a/worker/test/src/Utils/TestJson.cpp b/worker/test/src/Utils/TestJson.cpp deleted file mode 100644 index 03ab8800e1..0000000000 --- a/worker/test/src/Utils/TestJson.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include "common.hpp" -#include "Utils.hpp" -#include -#include - -using namespace Utils; -using json = nlohmann::json; - -SCENARIO("Json::IsPositiveInteger()") -{ - json jsonValue; - int intValue; - int8_t int8Value; - int32_t int32Value; - unsigned int uintValue; - uint8_t uint8Value; - uint32_t uint32Value; - float floatValue; - json jsonArray{ json::array() }; - json jsonObject{ json::object() }; - - jsonValue = 0; - REQUIRE(Json::IsPositiveInteger(jsonValue)); - - jsonValue = 1; - REQUIRE(Json::IsPositiveInteger(jsonValue)); - - jsonValue = 0u; - REQUIRE(Json::IsPositiveInteger(jsonValue)); - - jsonValue = 1u; - REQUIRE(Json::IsPositiveInteger(jsonValue)); - - jsonValue = -1; - REQUIRE(!Json::IsPositiveInteger(jsonValue)); - - intValue = 0; - REQUIRE(Json::IsPositiveInteger(intValue)); - - intValue = 1; - REQUIRE(Json::IsPositiveInteger(intValue)); - - intValue = -1; - REQUIRE(!Json::IsPositiveInteger(intValue)); - - int8Value = 0; - REQUIRE(Json::IsPositiveInteger(int8Value)); - - int8Value = 1; - REQUIRE(Json::IsPositiveInteger(int8Value)); - - int8Value = -1; - REQUIRE(!Json::IsPositiveInteger(int8Value)); - - int32Value = 0; - REQUIRE(Json::IsPositiveInteger(int32Value)); - - int32Value = 1; - REQUIRE(Json::IsPositiveInteger(int32Value)); - - int32Value = -1; - REQUIRE(!Json::IsPositiveInteger(int32Value)); - - uintValue = 0; - REQUIRE(Json::IsPositiveInteger(uintValue)); - - uintValue = 1; - REQUIRE(Json::IsPositiveInteger(uintValue)); - - uint8Value = 0; - REQUIRE(Json::IsPositiveInteger(uint8Value)); - - uint8Value = 1; - REQUIRE(Json::IsPositiveInteger(uint8Value)); - - uint32Value = 0; - REQUIRE(Json::IsPositiveInteger(uint32Value)); - - uint32Value = 1; - REQUIRE(Json::IsPositiveInteger(uint32Value)); - - floatValue = 0; - REQUIRE(!Json::IsPositiveInteger(floatValue)); - - floatValue = 0.0; - REQUIRE(!Json::IsPositiveInteger(floatValue)); - - floatValue = 1; - REQUIRE(!Json::IsPositiveInteger(floatValue)); - - floatValue = 1.1; - REQUIRE(!Json::IsPositiveInteger(floatValue)); - - floatValue = -1; - REQUIRE(!Json::IsPositiveInteger(floatValue)); - - floatValue = -1.1; - REQUIRE(!Json::IsPositiveInteger(floatValue)); - - REQUIRE(!Json::IsPositiveInteger(jsonArray)); - REQUIRE(!Json::IsPositiveInteger(jsonObject)); - REQUIRE(!Json::IsPositiveInteger(nullptr)); - REQUIRE(!Json::IsPositiveInteger(true)); - REQUIRE(!Json::IsPositiveInteger(false)); -} diff --git a/worker/test/src/Utils/TestString.cpp b/worker/test/src/Utils/TestString.cpp index 3b4dcf016d..99fe49e751 100644 --- a/worker/test/src/Utils/TestString.cpp +++ b/worker/test/src/Utils/TestString.cpp @@ -76,40 +76,3 @@ SCENARIO("String::Base64Encode() and String::Base64Decode()") REQUIRE(outLen == sizeof(rtpPacket)); REQUIRE(std::memcmp(decodedPtr, rtpPacket, outLen) == 0); } - -SCENARIO("String::Split()", "[utils][string]") -{ - SECTION("empty string") - { - std::string foo{}; - - auto v = String::Split(foo, ','); - - REQUIRE(v.size() == 0); - } - - SECTION("character separated string with no limit") - { - std::string foo{ "a,b,c,d" }; - - auto v = String::Split(foo, ','); - - REQUIRE(v.size() == 4); - REQUIRE(v[0] == "a"); - REQUIRE(v[1] == "b"); - REQUIRE(v[2] == "c"); - REQUIRE(v[3] == "d"); - } - - SECTION("character separated string with limit") - { - std::string foo{ "a,b,c,d" }; - - auto v = String::Split(foo, ',', 2); - - REQUIRE(v.size() == 3); - REQUIRE(v[0] == "a"); - REQUIRE(v[1] == "b"); - REQUIRE(v[2] == "c,d"); - } -} From add71dc6a2332f8b4e3df139e88198c82a1738e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Wed, 17 May 2023 23:38:46 +0200 Subject: [PATCH 02/73] Update NPM flatbuffers dep --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 45ae73c1b2..1583c4e605 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "license": "ISC", "dependencies": { "debug": "^4.3.4", - "flatbuffers": "^23.3.3", + "flatbuffers": "^23.5.9", "h264-profile-level-id": "^1.0.1", "supports-color": "^9.3.1", "uuid": "^9.0.0" @@ -2842,9 +2842,9 @@ } }, "node_modules/flatbuffers": { - "version": "23.3.3", - "resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-23.3.3.tgz", - "integrity": "sha512-jmreOaAT1t55keaf+Z259Tvh8tR/Srry9K8dgCgvizhKSEr6gLGgaOJI2WFL5fkOpGOGRZwxUrlFn0GCmXUy6g==" + "version": "23.5.9", + "resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-23.5.9.tgz", + "integrity": "sha512-IZFQesZoNhn8Jb6PXPJv/J07hoC6NFr23d9vyK9BpZ7rS5ewn16ZYALePcF91bCGI61uaYfMtGJOHfOZCn6A5g==" }, "node_modules/flatted": { "version": "3.2.7", @@ -8202,9 +8202,9 @@ } }, "flatbuffers": { - "version": "23.3.3", - "resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-23.3.3.tgz", - "integrity": "sha512-jmreOaAT1t55keaf+Z259Tvh8tR/Srry9K8dgCgvizhKSEr6gLGgaOJI2WFL5fkOpGOGRZwxUrlFn0GCmXUy6g==" + "version": "23.5.9", + "resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-23.5.9.tgz", + "integrity": "sha512-IZFQesZoNhn8Jb6PXPJv/J07hoC6NFr23d9vyK9BpZ7rS5ewn16ZYALePcF91bCGI61uaYfMtGJOHfOZCn6A5g==" }, "flatted": { "version": "3.2.7", diff --git a/package.json b/package.json index dbc86671d7..d23edf09b1 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ }, "dependencies": { "debug": "^4.3.4", - "flatbuffers": "^23.3.3", + "flatbuffers": "^23.5.9", "h264-profile-level-id": "^1.0.1", "supports-color": "^9.3.1", "uuid": "^9.0.0" From 148090a3aeb06f1f9513f94997d2ed3cd36fb2a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Fri, 19 May 2023 10:23:40 +0200 Subject: [PATCH 03/73] [flatbuffers] Add ListenInfo in all transports and send/recv buffer size options (#1084) --- CHANGELOG.md | 5 + node/src/PipeTransport.ts | 20 +- node/src/PlainTransport.ts | 20 +- node/src/Router.ts | 279 +++++++++++++----- node/src/Transport.ts | 38 +++ node/src/WebRtcServer.ts | 32 +- node/src/WebRtcTransport.ts | 31 +- node/src/Worker.ts | 28 +- node/src/tests/test-PipeTransport.ts | 111 +++++-- node/src/tests/test-PlainTransport.ts | 26 +- node/src/tests/test-WebRtcServer.ts | 35 ++- node/src/tests/test-WebRtcTransport.ts | 39 ++- node/src/types.ts | 10 + node/src/utils.ts | 12 +- rust/examples/echo.rs | 13 +- rust/examples/multiopus.rs | 18 +- rust/examples/svc-simulcast.rs | 13 +- rust/examples/videoroom.rs | 6 +- rust/src/data_structures.rs | 15 +- rust/src/messages.rs | 39 +-- rust/src/prelude.rs | 8 +- rust/src/router.rs | 47 +-- rust/src/router/consumer/tests.rs | 19 +- rust/src/router/data_consumer/tests.rs | 22 +- rust/src/router/data_producer/tests.rs | 12 +- rust/src/router/pipe_transport.rs | 13 +- rust/src/router/pipe_transport/tests.rs | 19 +- rust/src/router/plain_transport.rs | 13 +- rust/src/router/plain_transport/tests.rs | 8 +- rust/src/router/producer/tests.rs | 19 +- rust/src/router/webrtc_transport.rs | 66 ++--- rust/src/router/webrtc_transport/tests.rs | 60 ++-- rust/src/webrtc_server.rs | 28 +- rust/src/webrtc_server/tests.rs | 14 +- rust/tests/integration/consumer.rs | 19 +- rust/tests/integration/data_consumer.rs | 30 +- rust/tests/integration/data_producer.rs | 18 +- rust/tests/integration/multiopus.rs | 19 +- rust/tests/integration/pipe_transport.rs | 60 +++- rust/tests/integration/plain_transport.rs | 73 ++++- rust/tests/integration/producer.rs | 19 +- rust/tests/integration/smoke.rs | 23 +- rust/tests/integration/webrtc_server.rs | 116 ++++---- rust/tests/integration/webrtc_transport.rs | 208 ++++++++----- worker/fbs/pipeTransport.fbs | 3 +- worker/fbs/plainTransport.fbs | 3 +- worker/fbs/transport.fbs | 28 +- worker/fbs/webRtcServer.fbs | 7 - worker/fbs/webRtcTransport.fbs | 7 +- worker/fbs/worker.fbs | 4 +- worker/include/Channel/ChannelSocket.hpp | 10 +- worker/include/DepUsrSCTP.hpp | 10 +- worker/include/RTC/ActiveSpeakerObserver.hpp | 10 +- worker/include/RTC/AudioLevelObserver.hpp | 10 +- worker/include/RTC/DtlsTransport.hpp | 10 +- worker/include/RTC/KeyFrameRequestManager.hpp | 18 +- worker/include/RTC/NackGenerator.hpp | 10 +- worker/include/RTC/PipeTransport.hpp | 9 +- worker/include/RTC/PlainTransport.hpp | 9 +- worker/include/RTC/RtpStreamRecv.hpp | 10 +- worker/include/RTC/TcpConnection.hpp | 8 +- worker/include/RTC/TcpServer.hpp | 10 +- worker/include/RTC/Transport.hpp | 20 +- .../RTC/TransportCongestionControlClient.hpp | 10 +- .../RTC/TransportCongestionControlServer.hpp | 10 +- worker/include/RTC/UdpSocket.hpp | 6 +- worker/include/RTC/WebRtcServer.hpp | 7 +- worker/include/RTC/WebRtcTransport.hpp | 12 +- worker/include/Worker.hpp | 10 +- .../{SignalsHandler.hpp => SignalHandle.hpp} | 12 +- ...ionHandler.hpp => TcpConnectionHandle.hpp} | 20 +- ...pServerHandler.hpp => TcpServerHandle.hpp} | 28 +- .../handles/{Timer.hpp => TimerHandle.hpp} | 16 +- ...pSocketHandler.hpp => UdpSocketHandle.hpp} | 24 +- ...mSocket.hpp => UnixStreamSocketHandle.hpp} | 20 +- worker/meson.build | 12 +- worker/src/Channel/ChannelSocket.cpp | 5 +- worker/src/DepUsrSCTP.cpp | 4 +- worker/src/RTC/ActiveSpeakerObserver.cpp | 4 +- worker/src/RTC/AudioLevelObserver.cpp | 4 +- worker/src/RTC/DtlsTransport.cpp | 4 +- worker/src/RTC/KeyFrameRequestManager.cpp | 14 +- worker/src/RTC/NackGenerator.cpp | 4 +- worker/src/RTC/PipeTransport.cpp | 84 +++++- worker/src/RTC/PlainTransport.cpp | 178 +++++++++-- worker/src/RTC/Router.cpp | 3 +- worker/src/RTC/RtpStreamRecv.cpp | 4 +- worker/src/RTC/TcpConnection.cpp | 6 +- worker/src/RTC/TcpServer.cpp | 6 +- worker/src/RTC/Transport.cpp | 4 +- .../RTC/TransportCongestionControlClient.cpp | 4 +- .../RTC/TransportCongestionControlServer.cpp | 4 +- worker/src/RTC/UdpSocket.cpp | 4 +- worker/src/RTC/WebRtcServer.cpp | 124 +++++--- worker/src/RTC/WebRtcTransport.cpp | 112 ++++--- worker/src/Worker.cpp | 14 +- .../{SignalsHandler.cpp => SignalHandle.cpp} | 24 +- ...ionHandler.cpp => TcpConnectionHandle.cpp} | 76 +++-- ...pServerHandler.cpp => TcpServerHandle.cpp} | 112 ++++++- .../handles/{Timer.cpp => TimerHandle.cpp} | 22 +- ...pSocketHandler.cpp => UdpSocketHandle.cpp} | 128 ++++++-- ...mSocket.cpp => UnixStreamSocketHandle.cpp} | 131 ++++++-- 102 files changed, 2102 insertions(+), 1083 deletions(-) rename worker/include/handles/{SignalsHandler.hpp => SignalHandle.hpp} (68%) rename worker/include/handles/{TcpConnectionHandler.hpp => TcpConnectionHandle.hpp} (85%) rename worker/include/handles/{TcpServerHandler.hpp => TcpServerHandle.hpp} (61%) rename worker/include/handles/{Timer.hpp => TimerHandle.hpp} (72%) rename worker/include/handles/{UdpSocketHandler.hpp => UdpSocketHandle.hpp} (77%) rename worker/include/handles/{UnixStreamSocket.hpp => UnixStreamSocketHandle.hpp} (70%) rename worker/src/handles/{SignalsHandler.cpp => SignalHandle.cpp} (76%) rename worker/src/handles/{TcpConnectionHandler.cpp => TcpConnectionHandle.cpp} (86%) rename worker/src/handles/{TcpServerHandler.cpp => TcpServerHandle.cpp} (58%) rename worker/src/handles/{Timer.cpp => TimerHandle.cpp} (84%) rename worker/src/handles/{UdpSocketHandler.cpp => UdpSocketHandle.cpp} (69%) rename worker/src/handles/{UnixStreamSocket.cpp => UnixStreamSocketHandle.cpp} (68%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eb2f33350..6d21204312 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog +### Next + +* Add `ListenInfo` in all transports and send/recv buffer size options ([PR #1084](https://github.com/versatica/mediasoup/pull/1084)). + + ### 3.11.26 * `Worker`: Fix NACK timer and avoid negative RTT ([PR #1082](https://github.com/versatica/mediasoup/pull/1082), thanks to o-u-p for his work in ([PR #1076](https://github.com/versatica/mediasoup/pull/1076)). diff --git a/node/src/PipeTransport.ts b/node/src/PipeTransport.ts index 129f7a3d9a..149d62c043 100644 --- a/node/src/PipeTransport.ts +++ b/node/src/PipeTransport.ts @@ -11,6 +11,7 @@ import { parseTuple, parseTransportTraceEventData, Transport, + TransportListenInfo, TransportListenIp, TransportTuple, TransportEvents, @@ -27,7 +28,7 @@ import { serializeSrtpParameters, SrtpParameters } from './SrtpParameters'; -import { AppData } from './types'; +import { AppData, Either } from './types'; import { MediaKind as FbsMediaKind } from './fbs/rtp-parameters/media-kind'; import * as FbsRtpParameters from './fbs/rtp-parameters'; import { Event, Notification } from './fbs/notification'; @@ -35,7 +36,15 @@ import * as FbsRequest from './fbs/request'; import * as FbsTransport from './fbs/transport'; import * as FbsPipeTransport from './fbs/pipe-transport'; -export type PipeTransportOptions = +type PipeTransportListenInfo = +{ + /** + * Listening info. + */ + listenInfo: TransportListenInfo; +}; + +type PipeTransportListenIp = { /** * Listening IP address. @@ -47,7 +56,12 @@ export type PipeTransportOptions * range. */ port?: number; +}; + +type PipeTransportListen = Either; +export type PipeTransportOptions = +{ /** * Create a SCTP association. Default false. */ @@ -88,7 +102,7 @@ export type PipeTransportOptions * Custom application data. */ appData?: PipeTransportAppData; -}; +} & PipeTransportListen; export type PipeTransportStat = BaseTransportStats & { diff --git a/node/src/PlainTransport.ts b/node/src/PlainTransport.ts index f006237b27..9d7629dc10 100644 --- a/node/src/PlainTransport.ts +++ b/node/src/PlainTransport.ts @@ -9,6 +9,7 @@ import { parseBaseTransportStats, parseTransportTraceEventData, Transport, + TransportListenInfo, TransportListenIp, TransportTuple, TransportEvents, @@ -23,13 +24,21 @@ import { SrtpParameters, SrtpCryptoSuite } from './SrtpParameters'; -import { AppData } from './types'; +import { AppData, Either } from './types'; import { Event, Notification } from './fbs/notification'; import * as FbsRequest from './fbs/request'; import * as FbsTransport from './fbs/transport'; import * as FbsPlainTransport from './fbs/plain-transport'; -export type PlainTransportOptions = +type PlainTransportListenInfo = +{ + /** + * Listening info. + */ + listenInfo: TransportListenInfo; +}; + +type PlainTransportListenIp = { /** * Listening IP address. @@ -41,7 +50,12 @@ export type PlainTransportOptions; +export type PlainTransportOptions = +{ /** * Use RTCP-mux (RTP and RTCP in the same port). Default true. */ @@ -93,7 +107,7 @@ export type PlainTransportOptions = @@ -44,6 +50,22 @@ export type RouterOptions = appData?: RouterAppData; }; +type PipeToRouterListenInfo = +{ + listenInfo: TransportListenInfo; +}; + +type PipeToRouterListenIp = +{ + /** + * IP used in the PipeTransport pair. Default '127.0.0.1'. + */ + listenIp?: TransportListenIp | string; +}; + +type PipeToRouterListen = + Either; + export type PipeToRouterOptions = { /** @@ -61,11 +83,6 @@ export type PipeToRouterOptions = */ router: Router; - /** - * IP used in the PipeTransport pair. Default '127.0.0.1'. - */ - listenIp?: TransportListenIp | string; - /** * Create a SCTP association. Default true. */ @@ -85,7 +102,7 @@ export type PipeToRouterOptions = * Enable SRTP. */ enableSrtp?: boolean; -}; +} & PipeToRouterListen; export type PipeToRouterResult = { @@ -384,6 +401,7 @@ export class Router async createWebRtcTransport( { webRtcServer, + listenInfos, listenIps, port, enableUdp = true, @@ -401,9 +419,13 @@ export class Router { logger.debug('createWebRtcTransport()'); - if (!webRtcServer && !Array.isArray(listenIps)) + if (!webRtcServer && !Array.isArray(listenInfos) && !Array.isArray(listenIps)) + { + throw new TypeError('missing webRtcServer, listenInfos and listenIps (one of them is mandatory)'); + } + else if (webRtcServer && listenInfos && listenIps) { - throw new TypeError('missing webRtcServer and listenIps (one of them is mandatory)'); + throw new TypeError('only one of webRtcServer, listenInfos and listenIps must be given'); } else if ( numSctpStreams && @@ -417,31 +439,58 @@ export class Router throw new TypeError('if given, appData must be an object'); } + // Convert deprecated TransportListenIps to TransportListenInfos. if (listenIps) { - if (listenIps.length === 0) - { - throw new TypeError('empty listenIps array provided'); - } - + // Normalize IP strings to TransportListenIp objects. listenIps = listenIps.map((listenIp) => { - if (typeof listenIp === 'string' && listenIp) + if (typeof listenIp === 'string') { return { ip: listenIp }; } - else if (typeof listenIp === 'object') - { - return { - ip : listenIp.ip, - announcedIp : listenIp.announcedIp || undefined - }; - } else { - throw new TypeError('wrong listenIp'); + return listenIp; } }); + + listenInfos = []; + + const orderedProtocols: TransportProtocol[] = []; + + if (enableUdp && (!enableTcp || preferUdp)) + { + orderedProtocols.push('udp'); + + if (enableTcp) + { + orderedProtocols.push('tcp'); + } + } + else if (enableTcp && (!enableUdp || (preferTcp && !preferUdp))) + { + orderedProtocols.push('tcp'); + + if (enableUdp) + { + orderedProtocols.push('udp'); + } + } + + for (const listenIp of listenIps as TransportListenIp[]) + { + for (const protocol of orderedProtocols) + { + listenInfos.push( + { + protocol : protocol, + ip : listenIp.ip, + announcedIp : listenIp.announcedIp, + port : port + }); + } + } } const transportId = uuidv4(); @@ -459,16 +508,24 @@ export class Router } else { - const fbsListenIps: FbsTransport.ListenIpT[] = []; + const fbsListenInfos: FbsTransport.ListenInfoT[] = []; - for (const listenIp of listenIps as any[]) + for (const listenInfo of listenInfos!) { - fbsListenIps.push( - new FbsTransport.ListenIpT(listenIp.ip, listenIp.announcedIp)); + fbsListenInfos.push(new FbsTransport.ListenInfoT( + listenInfo.protocol === 'udp' + ? FbsTransportProtocol.UDP + : FbsTransportProtocol.TCP, + listenInfo.ip, + listenInfo.announcedIp, + listenInfo.port, + listenInfo.sendBufferSize, + listenInfo.recvBufferSize + )); } webRtcTransportListenIndividual = - new FbsWebRtcTransport.ListenIndividualT(fbsListenIps, port); + new FbsWebRtcTransport.ListenIndividualT(fbsListenInfos); } const baseTransportOptions = new FbsTransport.OptionsT( @@ -487,11 +544,7 @@ export class Router webRtcServer ? FbsWebRtcTransport.Listen.ListenServer : FbsWebRtcTransport.Listen.ListenIndividual, - webRtcServer ? webRtcTransportListenServer : webRtcTransportListenIndividual, - enableUdp, - enableTcp, - preferUdp, - preferTcp + webRtcServer ? webRtcTransportListenServer : webRtcTransportListenIndividual ); const requestOffset = new FbsRouter.CreateWebRtcTransportRequestT( @@ -561,6 +614,7 @@ export class Router */ async createPlainTransport( { + listenInfo, listenIp, port, rtcpMux = true, @@ -577,31 +631,36 @@ export class Router { logger.debug('createPlainTransport()'); - if (!listenIp) + if (!listenInfo && !listenIp) + { + throw new TypeError('missing listenInfo and listenIp (one of them is mandatory)'); + } + else if (listenInfo && listenIp) { - throw new TypeError('missing listenIp'); + throw new TypeError('only one of listenInfo and listenIp must be given'); } else if (appData && typeof appData !== 'object') { throw new TypeError('if given, appData must be an object'); } - if (typeof listenIp === 'string' && listenIp) - { - listenIp = { ip: listenIp }; - } - else if (typeof listenIp === 'object') + // Convert deprecated TransportListenIps to TransportListenInfos. + if (listenIp) { - listenIp = + // Normalize IP string to TransportListenIp object. + if (typeof listenIp === 'string') { + listenIp = { ip: listenIp }; + } + + listenInfo = + { + protocol : 'udp', ip : listenIp.ip, - announcedIp : listenIp.announcedIp || undefined + announcedIp : listenIp.announcedIp, + port : port }; } - else - { - throw new TypeError('wrong listenIp'); - } const transportId = uuidv4(); @@ -619,26 +678,25 @@ export class Router const plainTransportOptions = new FbsPlainTransport.PlainTransportOptionsT( baseTransportOptions, - new FbsTransport.ListenIpT(listenIp.ip, listenIp.announcedIp), - port, + new FbsTransport.ListenInfoT( + listenInfo!.protocol === 'udp' + ? FbsTransportProtocol.UDP + : FbsTransportProtocol.TCP, + listenInfo!.ip, + listenInfo!.announcedIp, + listenInfo!.port, + listenInfo!.sendBufferSize, + listenInfo!.recvBufferSize + ), rtcpMux, comedia, enableSrtp, srtpCryptoSuite ); - let requestOffset; - - try - { - requestOffset = new FbsRouter.CreatePlainTransportRequestT( - transportId, plainTransportOptions - ).pack(this.#channel.bufferBuilder); - } - catch (error) - { - throw new TypeError((error as Error).message); - } + const requestOffset = new FbsRouter.CreatePlainTransportRequestT( + transportId, plainTransportOptions + ).pack(this.#channel.bufferBuilder); const response = await this.#channel.request( FbsRequest.Method.ROUTER_CREATE_PLAIN_TRANSPORT, @@ -696,6 +754,7 @@ export class Router */ async createPipeTransport( { + listenInfo, listenIp, port, enableSctp = false, @@ -710,31 +769,36 @@ export class Router { logger.debug('createPipeTransport()'); - if (!listenIp) + if (!listenInfo && !listenIp) { - throw new TypeError('missing listenIp'); + throw new TypeError('missing listenInfo and listenIp (one of them is mandatory)'); + } + else if (listenInfo && listenIp) + { + throw new TypeError('only one of listenInfo and listenIp must be given'); } else if (appData && typeof appData !== 'object') { throw new TypeError('if given, appData must be an object'); } - if (typeof listenIp === 'string' && listenIp) - { - listenIp = { ip: listenIp }; - } - else if (typeof listenIp === 'object') + // Convert deprecated TransportListenIps to TransportListenInfos. + if (listenIp) { - listenIp = + // Normalize IP string to TransportListenIp object. + if (typeof listenIp === 'string') { + listenIp = { ip: listenIp }; + } + + listenInfo = + { + protocol : 'udp', ip : listenIp.ip, - announcedIp : listenIp.announcedIp || undefined + announcedIp : listenIp.announcedIp, + port : port }; } - else - { - throw new TypeError('wrong listenIp'); - } const transportId = uuidv4(); @@ -752,8 +816,16 @@ export class Router const pipeTransportOptions = new FbsPipeTransport.PipeTransportOptionsT( baseTransportOptions, - new FbsTransport.ListenIpT(listenIp.ip, listenIp.announcedIp), - port, + new FbsTransport.ListenInfoT( + listenInfo!.protocol === 'udp' + ? FbsTransportProtocol.UDP + : FbsTransportProtocol.TCP, + listenInfo!.ip, + listenInfo!.announcedIp, + listenInfo!.port, + listenInfo!.sendBufferSize, + listenInfo!.recvBufferSize + ), enableRtx, enableSrtp ); @@ -918,7 +990,8 @@ export class Router producerId, dataProducerId, router, - listenIp = '127.0.0.1', + listenInfo, + listenIp, enableSctp = true, numSctpStreams = { OS: 1024, MIS: 1024 }, enableRtx = false, @@ -928,7 +1001,20 @@ export class Router { logger.debug('pipeToRouter()'); - if (!producerId && !dataProducerId) + if (!listenInfo && !listenIp) + { + listenInfo = + { + protocol : 'udp', + ip : '127.0.0.1' + }; + } + + if (listenInfo && listenIp) + { + throw new TypeError('only one of listenInfo and listenIp must be given'); + } + else if (!producerId && !dataProducerId) { throw new TypeError('missing producerId or dataProducerId'); } @@ -945,6 +1031,23 @@ export class Router throw new TypeError('cannot use this Router as destination'); } + // Convert deprecated TransportListenIps to TransportListenInfos. + if (listenIp) + { + // Normalize IP string to TransportListenIp object. + if (typeof listenIp === 'string') + { + listenIp = { ip: listenIp }; + } + + listenInfo = + { + protocol : 'udp', + ip : listenIp.ip, + announcedIp : listenIp.announcedIp + }; + } + let producer: Producer | undefined; let dataProducer: DataProducer | undefined; @@ -987,9 +1090,21 @@ export class Router Promise.all( [ this.createPipeTransport( - { listenIp, enableSctp, numSctpStreams, enableRtx, enableSrtp }), + { + listenInfo : listenInfo!, + enableSctp, + numSctpStreams, + enableRtx, + enableSrtp + }), router.createPipeTransport( - { listenIp, enableSctp, numSctpStreams, enableRtx, enableSrtp }) + { + listenInfo : listenInfo!, + enableSctp, + numSctpStreams, + enableRtx, + enableSrtp + }) ]) .then((pipeTransports) => { diff --git a/node/src/Transport.ts b/node/src/Transport.ts index b9575a06d8..a1ee90754f 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -47,6 +47,44 @@ import * as FbsTransport from './fbs/transport'; import * as FbsRouter from './fbs/router'; import { SctpState as FbsSctpState } from './fbs/sctp-association/sctp-state'; +export type TransportListenInfo = +{ + /** + * Network protocol. + */ + protocol: TransportProtocol; + + /** + * Listening IPv4 or IPv6. + */ + ip: string; + + /** + * Announced IPv4 or IPv6 (useful when running mediasoup behind NAT with + * private IP). + */ + announcedIp?: string; + + /** + * Listening port. + */ + port?: number; + + /** + * Send buffer size (bytes). + */ + sendBufferSize?: number; + + /** + * Recv buffer size (bytes). + */ + recvBufferSize?: number; +}; + +/** + * Use TransportListenInfo instead. + * @deprecated + */ export type TransportListenIp = { /** diff --git a/node/src/WebRtcServer.ts b/node/src/WebRtcServer.ts index 31e10f922d..71d1820028 100644 --- a/node/src/WebRtcServer.ts +++ b/node/src/WebRtcServer.ts @@ -1,7 +1,7 @@ import { Logger } from './Logger'; import { EnhancedEventEmitter } from './EnhancedEventEmitter'; import { Channel } from './Channel'; -import { TransportProtocol } from './Transport'; +import { TransportListenInfo } from './Transport'; import { WebRtcTransport } from './WebRtcTransport'; import { AppData } from './types'; import { Body as RequestBody, Method } from './fbs/request'; @@ -13,7 +13,7 @@ export type WebRtcServerOptions = /** * Listen infos. */ - listenInfos: WebRtcServerListenInfo[]; + listenInfos: TransportListenInfo[]; /** * Custom application data. @@ -21,29 +21,11 @@ export type WebRtcServerOptions = appData?: WebRtcServerAppData; }; -export type WebRtcServerListenInfo = -{ - /** - * Network protocol. - */ - protocol: TransportProtocol; - - /** - * Listening IPv4 or IPv6. - */ - ip: string; - - /** - * Announced IPv4 or IPv6 (useful when running mediasoup behind NAT with - * private IP). - */ - announcedIp?: string; - - /** - * Listening port. - */ - port?: number; -}; +/** + * @deprecated + * Use TransportListenInfo instead. + */ +export type WebRtcServerListenInfo = TransportListenInfo; export type WebRtcServerEvents = { diff --git a/node/src/WebRtcTransport.ts b/node/src/WebRtcTransport.ts index 7858161d77..d7277e832b 100644 --- a/node/src/WebRtcTransport.ts +++ b/node/src/WebRtcTransport.ts @@ -9,6 +9,7 @@ import { BaseTransportDump, BaseTransportStats, Transport, + TransportListenInfo, TransportListenIp, TransportProtocol, TransportTuple, @@ -19,8 +20,8 @@ import { } from './Transport'; import { WebRtcServer } from './WebRtcServer'; import { SctpParameters, NumSctpStreams } from './SctpParameters'; -import { AppData } from './types'; -import { Either, parseVector } from './utils'; +import { AppData, Either } from './types'; +import { parseVector } from './utils'; import { Event, Notification } from './fbs/notification'; import * as FbsRequest from './fbs/request'; import * as FbsTransport from './fbs/transport'; @@ -31,11 +32,19 @@ import { IceState as FbsIceState } from './fbs/web-rtc-transport/ice-state'; export type WebRtcTransportOptions = WebRtcTransportOptionsBase & WebRtcTransportListen; -export type WebRtcTransportListenIndividual = +type WebRtcTransportListenIndividualListenInfo = +{ + /** + * Listening info. + */ + listenInfos: TransportListenInfo[]; +}; + +type WebRtcTransportListenIndividualListenIp = { /** * Listening IP address or addresses in order of preference (first one is the - * preferred one). Mandatory unless webRtcServer is given. + * preferred one). */ listenIps: (TransportListenIp | string)[]; @@ -46,36 +55,42 @@ export type WebRtcTransportListenIndividual = port?: number; }; -export type WebRtcTransportListenServer = +type WebRtcTransportListenServer = { /** - * Instance of WebRtcServer. Mandatory unless listenIps is given. + * Instance of WebRtcServer. */ webRtcServer: WebRtcServer; }; -export type WebRtcTransportListen = - Either; +type WebRtcTransportListen = Either< + Either, + WebRtcTransportListenServer +>; export type WebRtcTransportOptionsBase = { /** * Listen in UDP. Default true. + * @deprecated */ enableUdp?: boolean; /** * Listen in TCP. Default false. + * @deprecated */ enableTcp?: boolean; /** * Prefer UDP. Default false. + * @deprecated */ preferUdp?: boolean; /** * Prefer TCP. Default false. + * @deprecated */ preferTcp?: boolean; diff --git a/node/src/Worker.ts b/node/src/Worker.ts index a7a6ebb510..3b0aa06286 100644 --- a/node/src/Worker.ts +++ b/node/src/Worker.ts @@ -12,7 +12,7 @@ import { AppData } from './types'; import { Event } from './fbs/notification'; import * as FbsRequest from './fbs/request'; import * as FbsWorker from './fbs/worker'; -import * as FbsWebRtcServer from './fbs/web-rtc-server'; +import * as FbsTransport from './fbs/transport'; import { Protocol as FbsTransportProtocol } from './fbs/transport/protocol'; export type WorkerLogLevel = 'debug' | 'warn' | 'error' | 'none'; @@ -679,31 +679,27 @@ export class Worker } // Build the request. - const fbsListenInfos: FbsWebRtcServer.ListenInfoT[] = []; + const fbsListenInfos: FbsTransport.ListenInfoT[] = []; for (const listenInfo of listenInfos) { - fbsListenInfos.push(new FbsWebRtcServer.ListenInfoT( - listenInfo.protocol === 'udp' ? FbsTransportProtocol.UDP : FbsTransportProtocol.TCP, + fbsListenInfos.push(new FbsTransport.ListenInfoT( + listenInfo.protocol === 'udp' + ? FbsTransportProtocol.UDP + : FbsTransportProtocol.TCP, listenInfo.ip, listenInfo.announcedIp, - listenInfo.port) + listenInfo.port, + listenInfo.sendBufferSize, + listenInfo.recvBufferSize) ); } const webRtcServerId = uuidv4(); - let createWebRtcServerRequestOffset; - - try - { - createWebRtcServerRequestOffset = new FbsWorker.CreateWebRtcServerRequestT( - webRtcServerId, fbsListenInfos).pack(this.#channel.bufferBuilder); - } - catch (error) - { - throw new TypeError((error as Error).message); - } + const createWebRtcServerRequestOffset = new FbsWorker.CreateWebRtcServerRequestT( + webRtcServerId, fbsListenInfos + ).pack(this.#channel.bufferBuilder); await this.#channel.request( FbsRequest.Method.WORKER_CREATE_WEBRTC_SERVER, diff --git a/node/src/tests/test-PipeTransport.ts b/node/src/tests/test-PipeTransport.ts index 17153850de..23ba30a7f2 100644 --- a/node/src/tests/test-PipeTransport.ts +++ b/node/src/tests/test-PipeTransport.ts @@ -196,8 +196,8 @@ beforeAll(async () => router2 = await worker2.createRouter({ mediaCodecs }); transport1 = await router1.createWebRtcTransport( { - listenIps : [ '127.0.0.1' ], - enableSctp : true + listenInfos : [ { protocol: 'udp', ip: '127.0.0.1' } ], + enableSctp : true }); transport2 = await router2.createWebRtcTransport( { @@ -466,27 +466,47 @@ test('router.pipeToRouter() succeeds with video', async () => expect(pipeProducer.paused).toBe(true); }, 2000); -test('router.pipeToRouter() fails if both Routers belong to the same Worker', async () => +test('router.createPipeTransport() with wrong arguments rejects with TypeError', async () => { - const router1bis = await worker1.createRouter({ mediaCodecs }); + // @ts-ignore + await expect(router1.createPipeTransport({})) + .rejects + .toThrow(TypeError); - await expect(router1.pipeToRouter( + await expect(router1.createPipeTransport({ listenIp: '123' })) + .rejects + .toThrow(TypeError); + + // TODO: Ideally this should reject with TypeError. See: + // https://github.com/versatica/mediasoup/pull/927#issuecomment-1507188359 + // @ts-ignore + await expect(router1.createPipeTransport({ listenIp: [ '127.0.0.1' ] })) + .rejects + .toThrow(Error); + + await expect(router1.createPipeTransport( { - producerId : videoProducer.id, - router : router1bis + listenInfo : { protocol: 'tcp', ip: '127.0.0.1' } })) .rejects - .toThrow(Error); + .toThrow(TypeError); - router1bis.close(); + await expect(router1.createPipeTransport( + { + listenInfo : { protocol: 'udp', ip: '127.0.0.1' }, + // @ts-ignore + appData : 'NOT-AN-OBJECT' + })) + .rejects + .toThrow(TypeError); }, 2000); test('router.createPipeTransport() with enableRtx succeeds', async () => { const pipeTransport = await router1.createPipeTransport( { - listenIp : '127.0.0.1', - enableRtx : true + listenInfo : { protocol: 'udp', ip: '127.0.0.1' }, + enableRtx : true }); const pipeConsumer = @@ -564,12 +584,41 @@ test('router.createPipeTransport() with enableRtx succeeds', async () => pipeTransport.close(); }, 2000); -test('router.createPipeTransport() with invalid srtpParameters must fail', async () => +test('pipeTransport.connect() with valid SRTP parameters succeeds', async () => +{ + const pipeTransport = await router1.createPipeTransport( + { + listenIp : '127.0.0.1', + enableSrtp : true + }); + + expect(typeof pipeTransport.srtpParameters).toBe('object'); + // The master length of AEAD_AES_256_GCM. + expect(pipeTransport.srtpParameters?.keyBase64.length).toBe(60); + + // Valid srtpParameters. + await expect(pipeTransport.connect( + { + ip : '127.0.0.2', + port : 9999, + srtpParameters : + { + cryptoSuite : 'AEAD_AES_256_GCM', + keyBase64 : 'YTdjcDBvY2JoMGY5YXNlNDc0eDJsdGgwaWRvNnJsamRrdG16aWVpZHphdHo=' + } + })) + .resolves + .toBeUndefined(); + + pipeTransport.close(); +}, 2000); + +test('pipeTransport.connect() with srtpParameters fails if enableSrtp is unset', async () => { const pipeTransport = await router1.createPipeTransport( { - listenIp : '127.0.0.1', - enableRtx : true + listenInfo : { protocol: 'udp', ip: '127.0.0.1' }, + enableRtx : true }); expect(pipeTransport.srtpParameters).toBeUndefined(); @@ -602,7 +651,7 @@ test('router.createPipeTransport() with invalid srtpParameters must fail', async pipeTransport.close(); }); -test('router.createPipeTransport() with enableSrtp succeeds', async () => +test('pipeTransport.connect() with invalid srtpParameters fails', async () => { const pipeTransport = await router1.createPipeTransport( { @@ -708,20 +757,6 @@ test('router.createPipeTransport() with enableSrtp succeeds', async () => .rejects .toThrow(TypeError); - // Valid srtpParameters. - await expect(pipeTransport.connect( - { - ip : '127.0.0.2', - port : 9999, - srtpParameters : - { - cryptoSuite : 'AEAD_AES_256_GCM', - keyBase64 : 'YTdjcDBvY2JoMGY5YXNlNDc0eDJsdGgwaWRvNnJsamRrdG16aWVpZHphdHo=' - } - })) - .resolves - .toBeUndefined(); - pipeTransport.close(); }, 2000); @@ -730,8 +765,7 @@ test('router.createPipeTransport() with fixed port succeeds', async () => const port = await pickPort({ ip: '127.0.0.1', reserveTimeout: 0 }); const pipeTransport = await router1.createPipeTransport( { - listenIp : '127.0.0.1', - port + listenInfo : { protocol: 'udp', ip: '127.0.0.1', port } }); expect(pipeTransport.tuple.localPort).toEqual(port); @@ -845,6 +879,21 @@ test('producer.close() is transmitted to pipe Consumer', async () => expect(videoConsumer.closed).toBe(true); }, 2000); +test('router.pipeToRouter() fails if both Routers belong to the same Worker', async () => +{ + const router1bis = await worker1.createRouter({ mediaCodecs }); + + await expect(router1.pipeToRouter( + { + producerId : videoProducer.id, + router : router1bis + })) + .rejects + .toThrow(Error); + + router1bis.close(); +}, 2000); + test('router.pipeToRouter() succeeds with data', async () => { let dump; diff --git a/node/src/tests/test-PlainTransport.ts b/node/src/tests/test-PlainTransport.ts index bee31c73d5..69cf391331 100644 --- a/node/src/tests/test-PlainTransport.ts +++ b/node/src/tests/test-PlainTransport.ts @@ -53,8 +53,8 @@ beforeEach(async () => { transport = await router.createPlainTransport( { - listenIp : { ip: '127.0.0.1', announcedIp: '4.4.4.4' }, - rtcpMux : false + listenInfo : { protocol: 'udp', ip: '127.0.0.1', announcedIp: '4.4.4.4' }, + rtcpMux : false }); }); @@ -73,7 +73,7 @@ test('router.createPlainTransport() succeeds', async () => // Create a separate transport here. const transport1 = await router.createPlainTransport( { - listenIp : { ip: '127.0.0.1', announcedIp: '9.9.9.1' }, + listenInfo : { protocol: 'udp', ip: '127.0.0.1', announcedIp: '9.9.9.1' }, rtcpMux : true, enableSctp : true, appData : { foo: 'bar' } @@ -121,8 +121,8 @@ test('router.createPlainTransport() succeeds', async () => const transport2 = await router.createPlainTransport( { - listenIp : '127.0.0.1', - rtcpMux : false + listenInfo : { protocol: 'udp', ip: '127.0.0.1' }, + rtcpMux : false }); expect(typeof transport2.id).toBe('string'); @@ -159,16 +159,25 @@ test('router.createPlainTransport() with wrong arguments rejects with TypeError' .rejects .toThrow(TypeError); + // TODO: Ideally this should reject with TypeError. See: + // https://github.com/versatica/mediasoup/pull/927#issuecomment-1507188359 // @ts-ignore await expect(router.createPlainTransport({ listenIp: [ '127.0.0.1' ] })) + .rejects + .toThrow(Error); + + await expect(router.createPipeTransport( + { + listenInfo : { protocol: 'tcp', ip: '127.0.0.1' } + })) .rejects .toThrow(TypeError); await expect(router.createPlainTransport( { - listenIp : '127.0.0.1', + listenInfo : { protocol: 'udp', ip: '127.0.0.1' }, // @ts-ignore - appData : 'NOT-AN-OBJECT' + appData : 'NOT-AN-OBJECT' })) .rejects .toThrow(TypeError); @@ -421,8 +430,7 @@ test('router.createPlainTransport() with fixed port succeeds', async () => const port = await pickPort({ ip: '127.0.0.1', reserveTimeout: 0 }); const plainTransport = await router.createPlainTransport( { - listenIp : '127.0.0.1', - port + listenInfo : { protocol: 'udp', ip: '127.0.0.1', port } }); expect(plainTransport.tuple.localPort).toEqual(port); diff --git a/node/src/tests/test-WebRtcServer.ts b/node/src/tests/test-WebRtcServer.ts index 137aeb0d73..b8edf82726 100644 --- a/node/src/tests/test-WebRtcServer.ts +++ b/node/src/tests/test-WebRtcServer.ts @@ -172,15 +172,19 @@ test('worker.createWebRtcServer() with wrong arguments rejects with TypeError', .rejects .toThrow(TypeError); + // TODO: Ideally this should reject with TypeError. See: + // https://github.com/versatica/mediasoup/pull/927#issuecomment-1507188359 // @ts-ignore await expect(worker.createWebRtcServer({ listenInfos: 'NOT-AN-ARRAY' })) .rejects - .toThrow(TypeError); + .toThrow(Error); + // TODO: Ideally this should reject with TypeError. See: + // https://github.com/versatica/mediasoup/pull/927#issuecomment-1507188359 // @ts-ignore await expect(worker.createWebRtcServer({ listenInfos: [ 'NOT-AN-OBJECT' ] })) .rejects - .toThrow(TypeError); + .toThrow(Error); // Empty listenInfos so should fail. await expect(worker.createWebRtcServer({ listenInfos: [] })) @@ -356,8 +360,7 @@ test('router.createWebRtcTransport() with webRtcServer succeeds and transport is const transport = await router.createWebRtcTransport( { webRtcServer, - enableTcp : false, - appData : { foo: 'bar' } + appData : { foo: 'bar' } }); await expect(router.dump()) @@ -374,12 +377,17 @@ test('router.createWebRtcTransport() with webRtcServer succeeds and transport is const iceCandidates = transport.iceCandidates; - expect(iceCandidates.length).toBe(1); + expect(iceCandidates.length).toBe(2); expect(iceCandidates[0].ip).toBe('127.0.0.1'); expect(iceCandidates[0].port).toBe(port1); expect(iceCandidates[0].protocol).toBe('udp'); expect(iceCandidates[0].type).toBe('host'); expect(iceCandidates[0].tcpType).toBeUndefined(); + expect(iceCandidates[1].ip).toBe('127.0.0.1'); + expect(iceCandidates[1].port).toBe(port2); + expect(iceCandidates[1].protocol).toBe('tcp'); + expect(iceCandidates[1].type).toBe('host'); + expect(iceCandidates[1].tcpType).toBe('passive'); expect(transport.iceState).toBe('new'); expect(transport.iceSelectedTuple).toBeUndefined(); @@ -460,9 +468,7 @@ test('router.createWebRtcTransport() with webRtcServer succeeds and webRtcServer const transport = await router.createWebRtcTransport( { webRtcServer, - enableUdp : false, - enableTcp : true, - appData : { foo: 'bar' } + appData : { foo: 'bar' } }); expect(onObserverWebRtcTransportHandled).toHaveBeenCalledTimes(1); @@ -478,12 +484,17 @@ test('router.createWebRtcTransport() with webRtcServer succeeds and webRtcServer const iceCandidates = transport.iceCandidates; - expect(iceCandidates.length).toBe(1); + expect(iceCandidates.length).toBe(2); expect(iceCandidates[0].ip).toBe('127.0.0.1'); - expect(iceCandidates[0].port).toBe(port2); - expect(iceCandidates[0].protocol).toBe('tcp'); + expect(iceCandidates[0].port).toBe(port1); + expect(iceCandidates[0].protocol).toBe('udp'); expect(iceCandidates[0].type).toBe('host'); - expect(iceCandidates[0].tcpType).toBe('passive'); + expect(iceCandidates[0].tcpType).toBeUndefined(); + expect(iceCandidates[1].ip).toBe('127.0.0.1'); + expect(iceCandidates[1].port).toBe(port2); + expect(iceCandidates[1].protocol).toBe('tcp'); + expect(iceCandidates[1].type).toBe('host'); + expect(iceCandidates[1].tcpType).toBe('passive'); expect(transport.iceState).toBe('new'); expect(transport.iceSelectedTuple).toBeUndefined(); diff --git a/node/src/tests/test-WebRtcTransport.ts b/node/src/tests/test-WebRtcTransport.ts index e5a9b4e19a..acd1651f18 100644 --- a/node/src/tests/test-WebRtcTransport.ts +++ b/node/src/tests/test-WebRtcTransport.ts @@ -56,8 +56,7 @@ beforeEach(async () => { transport = await router.createWebRtcTransport( { - listenIps : [ { ip: '127.0.0.1', announcedIp: '9.9.9.1' } ], - enableTcp : false + listenInfos : [ { protocol: 'udp', ip: '127.0.0.1', announcedIp: '9.9.9.1' } ] }); }); @@ -76,11 +75,14 @@ test('router.createWebRtcTransport() succeeds', async () => // Create a separate transport here. const transport1 = await router.createWebRtcTransport( { - listenIps : + listenInfos : [ - { ip: '127.0.0.1', announcedIp: '9.9.9.1' }, - { ip: '0.0.0.0', announcedIp: '9.9.9.2' }, - { ip: '127.0.0.1', announcedIp: undefined } + { protocol: 'udp', ip: '127.0.0.1', announcedIp: '9.9.9.1' }, + { protocol: 'tcp', ip: '127.0.0.1', announcedIp: '9.9.9.1' }, + { protocol: 'udp', ip: '0.0.0.0', announcedIp: '9.9.9.2' }, + { protocol: 'tcp', ip: '0.0.0.0', announcedIp: '9.9.9.2' }, + { protocol: 'udp', ip: '127.0.0.1', announcedIp: undefined }, + { protocol: 'tcp', ip: '127.0.0.1', announcedIp: undefined } ], enableTcp : true, preferUdp : true, @@ -137,9 +139,9 @@ test('router.createWebRtcTransport() succeeds', async () => expect(iceCandidates[5].type).toBe('host'); expect(iceCandidates[5].tcpType).toBe('passive'); expect(iceCandidates[0].priority).toBeGreaterThan(iceCandidates[1].priority); - expect(iceCandidates[2].priority).toBeGreaterThan(iceCandidates[1].priority); + expect(iceCandidates[1].priority).toBeGreaterThan(iceCandidates[2].priority); expect(iceCandidates[2].priority).toBeGreaterThan(iceCandidates[3].priority); - expect(iceCandidates[4].priority).toBeGreaterThan(iceCandidates[3].priority); + expect(iceCandidates[3].priority).toBeGreaterThan(iceCandidates[4].priority); expect(iceCandidates[4].priority).toBeGreaterThan(iceCandidates[5].priority); expect(transport1.iceState).toBe('new'); @@ -173,7 +175,9 @@ test('router.createWebRtcTransport() succeeds', async () => expect(transport1.closed).toBe(true); const anotherTransport = await router.createWebRtcTransport( - { listenIps: [ '127.0.0.1' ] }); + { + listenInfos : [ { protocol: 'udp', ip: '127.0.0.1' } ] + }); expect(typeof anotherTransport).toBe('object'); }, 2000); @@ -185,12 +189,15 @@ test('router.createWebRtcTransport() with wrong arguments rejects with TypeError .rejects .toThrow(TypeError); - await expect(router.createWebRtcTransport({ listenIps: [] })) + // TODO: Ideally this should reject with TypeError. See: + // https://github.com/versatica/mediasoup/pull/927#issuecomment-1507188359 + // @ts-ignore + await expect(router.createWebRtcTransport({ listenIps: [ 123 ] })) .rejects - .toThrow(TypeError); + .toThrow(Error); // @ts-ignore - await expect(router.createWebRtcTransport({ listenIps: [ 123 ] })) + await expect(router.createWebRtcTransport({ listenInfos: '127.0.0.1' })) .rejects .toThrow(TypeError); @@ -221,7 +228,10 @@ test('router.createWebRtcTransport() with wrong arguments rejects with TypeError test('router.createWebRtcTransport() with non bindable IP rejects with Error', async () => { - await expect(router.createWebRtcTransport({ listenIps: [ '8.8.8.8' ] })) + await expect(router.createWebRtcTransport( + { + listenInfos : [ { protocol: 'udp', ip: '8.8.8.8' } ] + })) .rejects .toThrow(Error); }, 2000); @@ -631,8 +641,7 @@ test('router.createWebRtcTransport() with fixed port succeeds', async () => const port = await pickPort({ ip: '127.0.0.1', reserveTimeout: 0 }); const webRtcTransport = await router.createWebRtcTransport( { - listenIps : [ '127.0.0.1' ], - port + listenInfos : [ { protocol: 'udp', ip: '127.0.0.1', port } ] }); expect(webRtcTransport.iceCandidates[0].port).toEqual(port); diff --git a/node/src/types.ts b/node/src/types.ts index fe72cb95fb..59198fb5d3 100644 --- a/node/src/types.ts +++ b/node/src/types.ts @@ -23,3 +23,13 @@ export type AppData = { [key: string]: unknown; }; + +type Only = +{ + [P in keyof T]: T[P]; +} & +{ + [P in keyof U]?: never; +}; + +export type Either = Only | Only; diff --git a/node/src/utils.ts b/node/src/utils.ts index c7821509a0..77da462bc3 100644 --- a/node/src/utils.ts +++ b/node/src/utils.ts @@ -18,21 +18,11 @@ export function clone(data: any): any /** * Generates a random positive integer. */ -export function generateRandomNumber() +export function generateRandomNumber(): number { return randomInt(100_000_000, 999_999_999); } -type Only = -{ - [P in keyof T]: T[P]; -} & -{ - [P in keyof U]?: never; -}; - -export type Either = Only | Only; - /** * Get the flatbuffers RtpParameters type for a given Producer. */ diff --git a/rust/examples/echo.rs b/rust/examples/echo.rs index 0a0c688b9f..fd8027d83c 100644 --- a/rust/examples/echo.rs +++ b/rust/examples/echo.rs @@ -181,10 +181,15 @@ impl EchoConnection { // We know that for echo example we'll need 2 transports, so we can create both right away. // This may not be the case for real-world applications or you may create this at a // different time and/or in different order. - let transport_options = WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - })); + let transport_options = + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, + })); let producer_transport = router .create_webrtc_transport(transport_options.clone()) .await diff --git a/rust/examples/multiopus.rs b/rust/examples/multiopus.rs index 67e784335d..341c9d8a0c 100644 --- a/rust/examples/multiopus.rs +++ b/rust/examples/multiopus.rs @@ -145,9 +145,13 @@ impl EchoConnection { // For simplicity we will create plain transport for audio producer right away let plain_transport = router .create_plain_transport({ - let mut options = PlainTransportOptions::new(ListenIp { + let mut options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); options.comedia = true; @@ -225,12 +229,16 @@ impl EchoConnection { // it right away. This may not be the case for real-world applications or you may create // this at a different time and/or in different order. let consumer_transport = router - .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - ListenIp { + .create_webrtc_transport(WebRtcTransportOptions::new( + WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, - }, - ))) + port: None, + send_buffer_size: None, + recv_buffer_size: None, + }), + )) .await .map_err(|error| format!("Failed to create consumer transport: {error}"))?; diff --git a/rust/examples/svc-simulcast.rs b/rust/examples/svc-simulcast.rs index 465bddac88..3cfd318b9b 100644 --- a/rust/examples/svc-simulcast.rs +++ b/rust/examples/svc-simulcast.rs @@ -201,10 +201,15 @@ impl SvcSimulcastConnection { // right away. // This may not be the case for real-world applications or you may create this at a // different time and/or in different order. - let transport_options = WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - })); + let transport_options = + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, + })); let producer_transport = router .create_webrtc_transport(transport_options.clone()) .await diff --git a/rust/examples/videoroom.rs b/rust/examples/videoroom.rs index 369ae4f0da..ef818d8be2 100644 --- a/rust/examples/videoroom.rs +++ b/rust/examples/videoroom.rs @@ -496,9 +496,13 @@ mod participant { // right away. This may not be the case for real-world applications or you may create // this at a different time and/or in different order. let transport_options = - WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, })); let producer_transport = room .router() diff --git a/rust/src/data_structures.rs b/rust/src/data_structures.rs index 3995f530cc..29d7939684 100644 --- a/rust/src/data_structures.rs +++ b/rust/src/data_structures.rs @@ -44,18 +44,29 @@ impl AppData { } } -/// IP to listen on. +/// Listening protocol, IP and port for [`WebRtcServer`] to listen on. /// /// # Notes on usage /// If you use "0.0.0.0" or "::" as ip value, then you need to also provide `announced_ip`. #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] -pub struct ListenIp { +pub struct ListenInfo { + /// Network protocol. + pub protocol: Protocol, /// Listening IPv4 or IPv6. pub ip: IpAddr, /// Announced IPv4 or IPv6 (useful when running mediasoup behind NAT with private IP). #[serde(skip_serializing_if = "Option::is_none")] pub announced_ip: Option, + /// Listening port. + #[serde(skip_serializing_if = "Option::is_none")] + pub port: Option, + /// Send buffer size (bytes). + #[serde(skip_serializing_if = "Option::is_none")] + pub send_buffer_size: Option, + /// Recv buffer size (bytes). + #[serde(skip_serializing_if = "Option::is_none")] + pub recv_buffer_size: Option, } /// ICE role. diff --git a/rust/src/messages.rs b/rust/src/messages.rs index e09f22b5af..ebddba9d6e 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -7,8 +7,8 @@ use crate::consumer::{ use crate::data_consumer::{DataConsumerDump, DataConsumerId, DataConsumerStat, DataConsumerType}; use crate::data_producer::{DataProducerDump, DataProducerId, DataProducerStat, DataProducerType}; use crate::data_structures::{ - DtlsParameters, DtlsRole, DtlsState, IceCandidate, IceParameters, IceRole, IceState, ListenIp, - SctpState, TransportTuple, + DtlsParameters, DtlsRole, DtlsState, IceCandidate, IceParameters, IceRole, IceState, + ListenInfo, SctpState, TransportTuple, }; use crate::direct_transport::DirectTransportOptions; use crate::ortc::RtpMapping; @@ -24,7 +24,9 @@ use crate::sctp_parameters::{NumSctpStreams, SctpParameters, SctpStreamParameter use crate::srtp_parameters::{SrtpCryptoSuite, SrtpParameters}; use crate::transport::{TransportId, TransportTraceEventType}; use crate::webrtc_server::{WebRtcServerDump, WebRtcServerId, WebRtcServerListenInfos}; -use crate::webrtc_transport::{TransportListenIps, WebRtcTransportListen, WebRtcTransportOptions}; +use crate::webrtc_transport::{ + WebRtcTransportListen, WebRtcTransportListenInfos, WebRtcTransportOptions, +}; use crate::worker::WorkerDump; use parking_lot::Mutex; use serde::de::DeserializeOwned; @@ -234,9 +236,7 @@ request_response!( enum RouterCreateWebrtcTransportListen { #[serde(rename_all = "camelCase")] Individual { - listen_ips: TransportListenIps, - #[serde(skip_serializing_if = "Option::is_none")] - port: Option, + listen_infos: WebRtcTransportListenInfos, }, Server { #[serde(rename = "webRtcServerId")] @@ -250,10 +250,6 @@ pub(crate) struct RouterCreateWebrtcTransportRequest { transport_id: TransportId, #[serde(flatten)] listen: RouterCreateWebrtcTransportListen, - enable_udp: bool, - enable_tcp: bool, - prefer_udp: bool, - prefer_tcp: bool, initial_available_outgoing_bitrate: u32, enable_sctp: bool, num_sctp_streams: NumSctpStreams, @@ -270,10 +266,9 @@ impl RouterCreateWebrtcTransportRequest { Self { transport_id, listen: match &webrtc_transport_options.listen { - WebRtcTransportListen::Individual { listen_ips, port } => { + WebRtcTransportListen::Individual { listen_infos } => { RouterCreateWebrtcTransportListen::Individual { - listen_ips: listen_ips.clone(), - port: *port, + listen_infos: listen_infos.clone(), } } WebRtcTransportListen::Server { webrtc_server } => { @@ -282,10 +277,6 @@ impl RouterCreateWebrtcTransportRequest { } } }, - enable_udp: webrtc_transport_options.enable_udp, - enable_tcp: webrtc_transport_options.enable_tcp, - prefer_udp: webrtc_transport_options.prefer_udp, - prefer_tcp: webrtc_transport_options.prefer_tcp, initial_available_outgoing_bitrate: webrtc_transport_options .initial_available_outgoing_bitrate, enable_sctp: webrtc_transport_options.enable_sctp, @@ -330,9 +321,7 @@ impl Request for RouterCreateWebrtcTransportRequest { #[serde(rename_all = "camelCase")] pub(crate) struct RouterCreatePlainTransportData { transport_id: TransportId, - listen_ip: ListenIp, - #[serde(skip_serializing_if = "Option::is_none")] - port: Option, + listen_info: ListenInfo, rtcp_mux: bool, comedia: bool, enable_sctp: bool, @@ -351,8 +340,7 @@ impl RouterCreatePlainTransportData { ) -> Self { Self { transport_id, - listen_ip: plain_transport_options.listen_ip, - port: plain_transport_options.port, + listen_info: plain_transport_options.listen_info, rtcp_mux: plain_transport_options.rtcp_mux, comedia: plain_transport_options.comedia, enable_sctp: plain_transport_options.enable_sctp, @@ -389,9 +377,7 @@ request_response!( #[serde(rename_all = "camelCase")] pub(crate) struct RouterCreatePipeTransportData { transport_id: TransportId, - listen_ip: ListenIp, - #[serde(skip_serializing_if = "Option::is_none")] - port: Option, + listen_info: ListenInfo, enable_sctp: bool, num_sctp_streams: NumSctpStreams, max_sctp_message_size: u32, @@ -408,8 +394,7 @@ impl RouterCreatePipeTransportData { ) -> Self { Self { transport_id, - listen_ip: pipe_transport_options.listen_ip, - port: pipe_transport_options.port, + listen_info: pipe_transport_options.listen_info, enable_sctp: pipe_transport_options.enable_sctp, num_sctp_streams: pipe_transport_options.num_sctp_streams, max_sctp_message_size: pipe_transport_options.max_sctp_message_size, diff --git a/rust/src/prelude.rs b/rust/src/prelude.rs index f23ce3e364..62953870e5 100644 --- a/rust/src/prelude.rs +++ b/rust/src/prelude.rs @@ -20,8 +20,7 @@ pub use crate::router::{ }; pub use crate::webrtc_server::{ - WebRtcServer, WebRtcServerId, WebRtcServerListenInfo, WebRtcServerListenInfos, - WebRtcServerOptions, + WebRtcServer, WebRtcServerId, WebRtcServerListenInfos, WebRtcServerOptions, }; pub use crate::direct_transport::{DirectTransport, DirectTransportOptions, WeakDirectTransport}; @@ -36,7 +35,8 @@ pub use crate::transport::{ TransportId, }; pub use crate::webrtc_transport::{ - TransportListenIps, WebRtcTransport, WebRtcTransportOptions, WebRtcTransportRemoteParameters, + WebRtcTransport, WebRtcTransportListenInfos, WebRtcTransportOptions, + WebRtcTransportRemoteParameters, }; pub use crate::active_speaker_observer::{ @@ -60,7 +60,7 @@ pub use crate::data_producer::{ pub use crate::producer::{Producer, ProducerId, ProducerOptions, WeakProducer}; pub use crate::data_structures::{ - AppData, DtlsParameters, IceCandidate, IceParameters, ListenIp, WebRtcMessage, + AppData, DtlsParameters, IceCandidate, IceParameters, ListenInfo, Protocol, WebRtcMessage, }; pub use crate::rtp_parameters::{ MediaKind, MimeTypeAudio, MimeTypeVideo, RtcpFeedback, RtpCapabilities, diff --git a/rust/src/router.rs b/rust/src/router.rs index bca8accb7e..0391f10744 100644 --- a/rust/src/router.rs +++ b/rust/src/router.rs @@ -28,7 +28,7 @@ use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions}; use crate::data_producer::{ DataProducer, DataProducerId, DataProducerOptions, NonClosingDataProducer, WeakDataProducer, }; -use crate::data_structures::{AppData, ListenIp}; +use crate::data_structures::{AppData, ListenInfo, Protocol}; use crate::direct_transport::{DirectTransport, DirectTransportOptions}; use crate::messages::{ RouterCloseRequest, RouterCreateActiveSpeakerObserverData, @@ -116,8 +116,8 @@ pub struct PipeToRouterOptions { pub router: Router, /// IP used in the PipeTransport pair. /// - /// Default `127.0.0.1`. - listen_ip: ListenIp, + /// Default `{ protocol: 'udp', ip: '127.0.0.1' }`. + listen_info: ListenInfo, /// Create a SCTP association. /// /// Default `true`. @@ -140,9 +140,13 @@ impl PipeToRouterOptions { pub fn new(router: Router) -> Self { Self { router, - listen_ip: ListenIp { + listen_info: ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, }, enable_sctp: true, num_sctp_streams: NumSctpStreams::default(), @@ -597,8 +601,9 @@ impl Router { /// /// # async fn f(router: Router) -> Result<(), Box> { /// let transport = router - /// .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - /// ListenIp { + /// .create_webrtc_transport(WebRtcTransportOptions::new(WebRtcTransportListenInfos::new( + /// ListenInfo { + /// protocol: Protocol::Udp, /// ip: IpAddr::V4(Ipv4Addr::LOCALHOST), /// announced_ip: Some("9.9.9.1".parse().unwrap()), /// }, @@ -662,7 +667,8 @@ impl Router { /// /// # async fn f(router: Router) -> Result<(), Box> { /// let transport = router - /// .create_pipe_transport(PipeTransportOptions::new(ListenIp { + /// .create_pipe_transport(PipeTransportOptions::new(ListenInfo { + /// protocol: Protocol::Udp, /// ip: IpAddr::V4(Ipv4Addr::LOCALHOST), /// announced_ip: Some("9.9.9.1".parse().unwrap()), /// })) @@ -723,7 +729,8 @@ impl Router { /// /// # async fn f(router: Router) -> Result<(), Box> { /// let transport = router - /// .create_plain_transport(PlainTransportOptions::new(ListenIp { + /// .create_plain_transport(PlainTransportOptions::new(ListenInfo { + /// protocol: Protocol::Udp, /// ip: IpAddr::V4(Ipv4Addr::LOCALHOST), /// announced_ip: Some("9.9.9.1".parse().unwrap()), /// })) @@ -928,8 +935,9 @@ impl Router { /// /// // Produce in router1. /// let transport1 = router1 - /// .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - /// ListenIp { + /// .create_webrtc_transport(WebRtcTransportOptions::new(WebRtcTransportListenInfos::new( + /// ListenInfo { + /// protocol: Protocol::Udp, /// ip: IpAddr::V4(Ipv4Addr::LOCALHOST), /// announced_ip: Some("9.9.9.1".parse().unwrap()), /// }, @@ -966,8 +974,9 @@ impl Router { /// /// // Consume producer1 from router2. /// let transport2 = router2 - /// .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - /// ListenIp { + /// .create_webrtc_transport(WebRtcTransportOptions::new(WebRtcTransportListenInfos::new( + /// ListenInfo { + /// protocol: Protocol::Udp, /// ip: IpAddr::V4(Ipv4Addr::LOCALHOST), /// announced_ip: Some("9.9.9.1".parse().unwrap()), /// }, @@ -1147,8 +1156,9 @@ impl Router { /// // Produce in router1. /// let transport1 = router1 /// .create_webrtc_transport({ - /// let mut options = WebRtcTransportOptions::new(TransportListenIps::new( - /// ListenIp { + /// let mut options = WebRtcTransportOptions::new(WebRtcTransportListenInfos::new( + /// ListenInfo { + /// protocol: Protocol::Udp, /// ip: IpAddr::V4(Ipv4Addr::LOCALHOST), /// announced_ip: Some("9.9.9.1".parse().unwrap()), /// }, @@ -1174,8 +1184,9 @@ impl Router { /// // Consume data_producer1 from router2. /// let transport2 = router2 /// .create_webrtc_transport({ - /// let mut options = WebRtcTransportOptions::new(TransportListenIps::new( - /// ListenIp { + /// let mut options = WebRtcTransportOptions::new(WebRtcTransportListenInfos::new( + /// ListenInfo { + /// protocol: Protocol::Udp, /// ip: IpAddr::V4(Ipv4Addr::LOCALHOST), /// announced_ip: Some("9.9.9.1".parse().unwrap()), /// }, @@ -1393,7 +1404,7 @@ impl Router { ) -> Result { let PipeToRouterOptions { router, - listen_ip, + listen_info, enable_sctp, num_sctp_streams, enable_rtx, @@ -1408,7 +1419,7 @@ impl Router { enable_rtx, enable_srtp, app_data: AppData::default(), - ..PipeTransportOptions::new(listen_ip) + ..PipeTransportOptions::new(listen_info) }; let local_pipe_transport_fut = self.create_pipe_transport(transport_options.clone()); diff --git a/rust/src/router/consumer/tests.rs b/rust/src/router/consumer/tests.rs index 62d7a69b4c..8f4fe2a74a 100644 --- a/rust/src/router/consumer/tests.rs +++ b/rust/src/router/consumer/tests.rs @@ -1,5 +1,5 @@ use crate::consumer::ConsumerOptions; -use crate::data_structures::ListenIp; +use crate::data_structures::{ListenInfo, Protocol}; use crate::producer::ProducerOptions; use crate::router::{Router, RouterOptions}; use crate::rtp_parameters::{ @@ -7,7 +7,9 @@ use crate::rtp_parameters::{ RtpCodecParametersParameters, RtpParameters, }; use crate::transport::Transport; -use crate::webrtc_transport::{TransportListenIps, WebRtcTransport, WebRtcTransportOptions}; +use crate::webrtc_transport::{ + WebRtcTransport, WebRtcTransportListenInfos, WebRtcTransportOptions, +}; use crate::worker::WorkerSettings; use crate::worker_manager::WorkerManager; use futures_lite::future; @@ -79,10 +81,15 @@ async fn init() -> (Router, WebRtcTransport, WebRtcTransport) { .await .expect("Failed to create router"); - let transport_options = WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - })); + let transport_options = + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, + })); let transport_1 = router .create_webrtc_transport(transport_options.clone()) diff --git a/rust/src/router/data_consumer/tests.rs b/rust/src/router/data_consumer/tests.rs index d12a876eb7..7ef9a80588 100644 --- a/rust/src/router/data_consumer/tests.rs +++ b/rust/src/router/data_consumer/tests.rs @@ -1,11 +1,11 @@ use crate::data_consumer::DataConsumerOptions; use crate::data_producer::{DataProducer, DataProducerOptions}; -use crate::data_structures::ListenIp; +use crate::data_structures::{ListenInfo, Protocol}; use crate::plain_transport::PlainTransportOptions; use crate::router::{Router, RouterOptions}; use crate::sctp_parameters::SctpStreamParameters; use crate::transport::Transport; -use crate::webrtc_transport::{TransportListenIps, WebRtcTransportOptions}; +use crate::webrtc_transport::{WebRtcTransportListenInfos, WebRtcTransportOptions}; use crate::worker::WorkerSettings; use crate::worker_manager::WorkerManager; use futures_lite::future; @@ -36,9 +36,13 @@ async fn init() -> (Router, DataProducer) { let transport = router .create_webrtc_transport({ let mut transport_options = - WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, })); transport_options.enable_sctp = true; @@ -65,9 +69,13 @@ fn data_producer_close_event() { let transport2 = router .create_plain_transport({ - let mut transport_options = PlainTransportOptions::new(ListenIp { + let mut transport_options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); transport_options.enable_sctp = true; @@ -114,9 +122,13 @@ fn transport_close_event() { let transport2 = router .create_plain_transport({ - let mut transport_options = PlainTransportOptions::new(ListenIp { + let mut transport_options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); transport_options.enable_sctp = true; diff --git a/rust/src/router/data_producer/tests.rs b/rust/src/router/data_producer/tests.rs index a98116529d..3bbb34db02 100644 --- a/rust/src/router/data_producer/tests.rs +++ b/rust/src/router/data_producer/tests.rs @@ -1,9 +1,11 @@ use crate::data_producer::DataProducerOptions; -use crate::data_structures::ListenIp; +use crate::data_structures::{ListenInfo, Protocol}; use crate::router::{Router, RouterOptions}; use crate::sctp_parameters::SctpStreamParameters; use crate::transport::Transport; -use crate::webrtc_transport::{TransportListenIps, WebRtcTransport, WebRtcTransportOptions}; +use crate::webrtc_transport::{ + WebRtcTransport, WebRtcTransportListenInfos, WebRtcTransportOptions, +}; use crate::worker::WorkerSettings; use crate::worker_manager::WorkerManager; use futures_lite::future; @@ -34,9 +36,13 @@ async fn init() -> (Router, WebRtcTransport) { let transport1 = router .create_webrtc_transport({ let mut transport_options = - WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, })); transport_options.enable_sctp = true; diff --git a/rust/src/router/pipe_transport.rs b/rust/src/router/pipe_transport.rs index cb064463bc..80370973be 100644 --- a/rust/src/router/pipe_transport.rs +++ b/rust/src/router/pipe_transport.rs @@ -4,7 +4,7 @@ mod tests; 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, ListenIp, SctpState, TransportTuple}; +use crate::data_structures::{AppData, ListenInfo, SctpState, TransportTuple}; use crate::messages::{PipeTransportData, TransportCloseRequest, TransportConnectPipeRequest}; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; @@ -33,10 +33,8 @@ use std::sync::{Arc, Weak}; #[derive(Debug, Clone)] #[non_exhaustive] pub struct PipeTransportOptions { - /// Listening IP address. - pub listen_ip: ListenIp, - /// Fixed port to listen on instead of selecting automatically from Worker's port range. - pub port: Option, + /// Listening info. + pub listen_info: ListenInfo, /// Create a SCTP association. /// Default false. pub enable_sctp: bool, @@ -64,10 +62,9 @@ pub struct PipeTransportOptions { impl PipeTransportOptions { /// Create Pipe transport options with given listen IP. #[must_use] - pub fn new(listen_ip: ListenIp) -> Self { + pub fn new(listen_info: ListenInfo) -> Self { Self { - listen_ip, - port: None, + listen_info, enable_sctp: false, num_sctp_streams: NumSctpStreams::default(), max_sctp_message_size: 268_435_456, diff --git a/rust/src/router/pipe_transport/tests.rs b/rust/src/router/pipe_transport/tests.rs index 67862e5bc2..54a1f22a48 100644 --- a/rust/src/router/pipe_transport/tests.rs +++ b/rust/src/router/pipe_transport/tests.rs @@ -1,7 +1,7 @@ use crate::consumer::ConsumerOptions; use crate::data_consumer::DataConsumerOptions; use crate::data_producer::DataProducerOptions; -use crate::data_structures::ListenIp; +use crate::data_structures::{ListenInfo, Protocol}; use crate::producer::ProducerOptions; use crate::router::{PipeToRouterOptions, Router, RouterOptions}; use crate::rtp_parameters::{ @@ -10,7 +10,9 @@ use crate::rtp_parameters::{ }; use crate::sctp_parameters::SctpStreamParameters; use crate::transport::Transport; -use crate::webrtc_transport::{TransportListenIps, WebRtcTransport, WebRtcTransportOptions}; +use crate::webrtc_transport::{ + WebRtcTransport, WebRtcTransportListenInfos, WebRtcTransportOptions, +}; use crate::worker::WorkerSettings; use crate::worker_manager::WorkerManager; use futures_lite::future; @@ -95,10 +97,15 @@ async fn init() -> (Router, Router, WebRtcTransport, WebRtcTransport) { .await .expect("Failed to create router"); - let mut transport_options = WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - })); + let mut transport_options = + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, + })); transport_options.enable_sctp = true; let transport_1 = router1 diff --git a/rust/src/router/plain_transport.rs b/rust/src/router/plain_transport.rs index c806751d50..0574a91c61 100644 --- a/rust/src/router/plain_transport.rs +++ b/rust/src/router/plain_transport.rs @@ -4,7 +4,7 @@ mod tests; 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, ListenIp, SctpState, TransportTuple}; +use crate::data_structures::{AppData, ListenInfo, SctpState, TransportTuple}; use crate::messages::{PlainTransportData, TransportCloseRequest, TransportConnectPlainRequest}; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; @@ -42,10 +42,8 @@ use std::sync::{Arc, Weak}; #[derive(Debug, Clone)] #[non_exhaustive] pub struct PlainTransportOptions { - /// Listening IP address. - pub listen_ip: ListenIp, - /// Fixed port to listen on instead of selecting automatically from Worker's port range. - pub port: Option, + /// Listening info. + pub listen_info: ListenInfo, /// Use RTCP-mux (RTP and RTCP in the same port). /// Default true. pub rtcp_mux: bool, @@ -78,10 +76,9 @@ pub struct PlainTransportOptions { impl PlainTransportOptions { /// Create Plain transport options with given listen IP. #[must_use] - pub fn new(listen_ip: ListenIp) -> Self { + pub fn new(listen_info: ListenInfo) -> Self { Self { - listen_ip, - port: None, + listen_info, rtcp_mux: true, comedia: false, enable_sctp: false, diff --git a/rust/src/router/plain_transport/tests.rs b/rust/src/router/plain_transport/tests.rs index 5fd65b1a40..fcff706c5f 100644 --- a/rust/src/router/plain_transport/tests.rs +++ b/rust/src/router/plain_transport/tests.rs @@ -1,4 +1,4 @@ -use crate::data_structures::ListenIp; +use crate::data_structures::{ListenInfo, Protocol}; use crate::plain_transport::PlainTransportOptions; use crate::router::{Router, RouterOptions}; use crate::transport::Transport; @@ -37,9 +37,13 @@ fn router_close_event() { let transport = router .create_plain_transport({ - let mut plain_transport_options = PlainTransportOptions::new(ListenIp { + let mut plain_transport_options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("4.4.4.4".parse().unwrap()), + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); plain_transport_options.rtcp_mux = false; diff --git a/rust/src/router/producer/tests.rs b/rust/src/router/producer/tests.rs index f5fd9d9e12..92533c3c32 100644 --- a/rust/src/router/producer/tests.rs +++ b/rust/src/router/producer/tests.rs @@ -1,4 +1,4 @@ -use crate::data_structures::ListenIp; +use crate::data_structures::{ListenInfo, Protocol}; use crate::producer::ProducerOptions; use crate::router::{Router, RouterOptions}; use crate::rtp_parameters::{ @@ -6,7 +6,9 @@ use crate::rtp_parameters::{ RtpParameters, }; use crate::transport::Transport; -use crate::webrtc_transport::{TransportListenIps, WebRtcTransport, WebRtcTransportOptions}; +use crate::webrtc_transport::{ + WebRtcTransport, WebRtcTransportListenInfos, WebRtcTransportOptions, +}; use crate::worker::WorkerSettings; use crate::worker_manager::WorkerManager; use futures_lite::future; @@ -64,10 +66,15 @@ async fn init() -> (Router, WebRtcTransport) { .await .expect("Failed to create router"); - let transport_options = WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - })); + let transport_options = + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, + })); let transport_1 = router .create_webrtc_transport(transport_options.clone()) diff --git a/rust/src/router/webrtc_transport.rs b/rust/src/router/webrtc_transport.rs index c2604ff519..54e11de3f5 100644 --- a/rust/src/router/webrtc_transport.rs +++ b/rust/src/router/webrtc_transport.rs @@ -5,7 +5,7 @@ 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, DtlsParameters, DtlsState, IceCandidate, IceParameters, IceRole, IceState, ListenIp, + AppData, DtlsParameters, DtlsState, IceCandidate, IceParameters, IceRole, IceState, ListenInfo, SctpState, TransportTuple, }; use crate::messages::{ @@ -39,25 +39,25 @@ use thiserror::Error; /// Struct that protects an invariant of having non-empty list of listen IPs #[derive(Debug, Clone, Eq, PartialEq, Serialize)] -pub struct TransportListenIps(Vec); +pub struct WebRtcTransportListenInfos(Vec); -impl TransportListenIps { +impl WebRtcTransportListenInfos { /// Create transport listen IPs with given IP populated initially. #[must_use] - pub fn new(listen_ip: ListenIp) -> Self { - Self(vec![listen_ip]) + pub fn new(listen_info: ListenInfo) -> Self { + Self(vec![listen_info]) } /// Insert another listen IP. #[must_use] - pub fn insert(mut self, listen_ip: ListenIp) -> Self { - self.0.push(listen_ip); + pub fn insert(mut self, listen_info: ListenInfo) -> Self { + self.0.push(listen_info); self } } -impl Deref for TransportListenIps { - type Target = Vec; +impl Deref for WebRtcTransportListenInfos { + type Target = Vec; fn deref(&self) -> &Self::Target { &self.0 @@ -69,14 +69,14 @@ impl Deref for TransportListenIps { #[error("Empty list of listen IPs provided, should have at least one element")] pub struct EmptyListError; -impl TryFrom> for TransportListenIps { +impl TryFrom> for WebRtcTransportListenInfos { type Error = EmptyListError; - fn try_from(listen_ips: Vec) -> Result { - if listen_ips.is_empty() { + fn try_from(listen_infos: Vec) -> Result { + if listen_infos.is_empty() { Err(EmptyListError) } else { - Ok(Self(listen_ips)) + Ok(Self(listen_infos)) } } } @@ -84,18 +84,16 @@ impl TryFrom> for TransportListenIps { /// How [`WebRtcTransport`] should listen on interfaces. /// /// # Notes on usage -/// * Do not use "0.0.0.0" into `listen_ips`. Values in `listen_ips` must be specific bindable IPs +/// * Do not use "0.0.0.0" into `listen_infos`. Values in `listen_infos` must be specific bindable IPs /// on the host. -/// * If you use "0.0.0.0" or "::" into `listen_ips`, then you need to also provide `announced_ip` -/// in the corresponding entry in `listen_ips`. +/// * If you use "0.0.0.0" or "::" into `listen_infos`, then you need to also provide `announced_ip` +/// in the corresponding entry in `listen_infos`. #[derive(Debug, Clone)] pub enum WebRtcTransportListen { - /// Listen on individual IP/port combinations specific to this transport. + /// Listen on individual protocol/IP/port combinations specific to this transport. Individual { - /// Listening IP address or addresses in order of preference (first one is the preferred one). - listen_ips: TransportListenIps, - /// Fixed port to listen on instead of selecting automatically from Worker's port range. - port: Option, + /// Listening infos in order of preference (first one is the preferred one). + listen_infos: WebRtcTransportListenInfos, }, /// Share [`WebRtcServer`] with other transports withing the same worker. Server { @@ -114,17 +112,6 @@ pub enum WebRtcTransportListen { pub struct WebRtcTransportOptions { /// How [`WebRtcTransport`] should listen on interfaces. pub listen: WebRtcTransportListen, - /// Listen in UDP. Default true. - pub enable_udp: bool, - /// Listen in TCP. - /// Default false. - pub enable_tcp: bool, - /// Prefer UDP. - /// Default false. - pub prefer_udp: bool, - /// Prefer TCP. - /// Default false. - pub prefer_tcp: bool, /// Initial available outgoing bitrate (in bps). /// Default 600000. pub initial_available_outgoing_bitrate: u32, @@ -146,16 +133,9 @@ pub struct WebRtcTransportOptions { impl WebRtcTransportOptions { /// Create [`WebRtcTransport`] options with given listen IPs. #[must_use] - pub fn new(listen_ips: TransportListenIps) -> Self { + pub fn new(listen_infos: WebRtcTransportListenInfos) -> Self { Self { - listen: WebRtcTransportListen::Individual { - listen_ips, - port: None, - }, - enable_udp: true, - enable_tcp: false, - prefer_udp: false, - prefer_tcp: false, + listen: WebRtcTransportListen::Individual { listen_infos }, initial_available_outgoing_bitrate: 600_000, enable_sctp: false, num_sctp_streams: NumSctpStreams::default(), @@ -169,10 +149,6 @@ impl WebRtcTransportOptions { pub fn new_with_server(webrtc_server: WebRtcServer) -> Self { Self { listen: WebRtcTransportListen::Server { webrtc_server }, - enable_udp: true, - enable_tcp: false, - prefer_udp: false, - prefer_tcp: false, initial_available_outgoing_bitrate: 600_000, enable_sctp: false, num_sctp_streams: NumSctpStreams::default(), diff --git a/rust/src/router/webrtc_transport/tests.rs b/rust/src/router/webrtc_transport/tests.rs index 9ddf7f66f8..7502ef38c9 100644 --- a/rust/src/router/webrtc_transport/tests.rs +++ b/rust/src/router/webrtc_transport/tests.rs @@ -1,11 +1,9 @@ -use crate::data_structures::{IceCandidateType, IceState, ListenIp, Protocol}; +use crate::data_structures::{IceCandidateType, IceState, ListenInfo, Protocol}; use crate::prelude::WebRtcTransport; use crate::router::{NewTransport, Router, RouterOptions}; use crate::transport::Transport; -use crate::webrtc_server::{ - WebRtcServerIpPort, WebRtcServerListenInfo, WebRtcServerListenInfos, WebRtcServerOptions, -}; -use crate::webrtc_transport::{TransportListenIps, WebRtcTransportOptions}; +use crate::webrtc_server::{WebRtcServerIpPort, WebRtcServerListenInfos, WebRtcServerOptions}; +use crate::webrtc_transport::{WebRtcTransportListenInfos, WebRtcTransportOptions}; use crate::worker::{Worker, WorkerSettings}; use crate::worker_manager::WorkerManager; use async_io::Timer; @@ -52,21 +50,21 @@ fn create_with_webrtc_server_succeeds() { let webrtc_server = worker .create_webrtc_server({ - let listen_infos = WebRtcServerListenInfos::new(WebRtcServerListenInfo { + let listen_infos = WebRtcServerListenInfos::new(ListenInfo { protocol: Protocol::Udp, - listen_ip: ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - }, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, port: Some(port1), + send_buffer_size: None, + recv_buffer_size: None, }); - let listen_infos = listen_infos.insert(WebRtcServerListenInfo { + let listen_infos = listen_infos.insert(ListenInfo { protocol: Protocol::Tcp, - listen_ip: ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - }, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, port: Some(port2), + send_buffer_size: None, + recv_buffer_size: None, }); WebRtcServerOptions::new(listen_infos) }) @@ -219,12 +217,16 @@ fn router_close_event() { let (_worker, router) = init().await; let transport = router - .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - ListenIp { + .create_webrtc_transport(WebRtcTransportOptions::new( + WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), - }, - ))) + port: None, + send_buffer_size: None, + recv_buffer_size: None, + }), + )) .await .expect("Failed to create WebRTC transport"); @@ -257,21 +259,21 @@ fn webrtc_server_close_event() { let webrtc_server = worker .create_webrtc_server({ - let listen_infos = WebRtcServerListenInfos::new(WebRtcServerListenInfo { + let listen_infos = WebRtcServerListenInfos::new(ListenInfo { protocol: Protocol::Udp, - listen_ip: ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - }, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, port: Some(port1), + send_buffer_size: None, + recv_buffer_size: None, }); - let listen_infos = listen_infos.insert(WebRtcServerListenInfo { + let listen_infos = listen_infos.insert(ListenInfo { protocol: Protocol::Tcp, - listen_ip: ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - }, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, port: Some(port2), + send_buffer_size: None, + recv_buffer_size: None, }); WebRtcServerOptions::new(listen_infos) }) diff --git a/rust/src/webrtc_server.rs b/rust/src/webrtc_server.rs index 7d70430e0d..e5bc7977bb 100644 --- a/rust/src/webrtc_server.rs +++ b/rust/src/webrtc_server.rs @@ -10,7 +10,7 @@ #[cfg(test)] mod tests; -use crate::data_structures::{AppData, ListenIp, Protocol}; +use crate::data_structures::{AppData, ListenInfo}; use crate::messages::{WebRtcServerCloseRequest, WebRtcServerDumpRequest}; use crate::transport::TransportId; use crate::uuid_based_wrapper_type; @@ -73,41 +73,27 @@ pub struct WebRtcServerDump { pub tuple_hashes: Vec, } -/// Listening protocol, IP and port for [`WebRtcServer`] to listen on. -#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct WebRtcServerListenInfo { - /// Network protocol. - pub protocol: Protocol, - /// Listening IP address. - #[serde(flatten)] - pub listen_ip: ListenIp, - /// Listening port. - #[serde(skip_serializing_if = "Option::is_none")] - pub port: Option, -} - /// Struct that protects an invariant of having non-empty list of listen infos. #[derive(Debug, Clone, Eq, PartialEq, Serialize)] -pub struct WebRtcServerListenInfos(Vec); +pub struct WebRtcServerListenInfos(Vec); impl WebRtcServerListenInfos { /// Create WebRTC server listen infos with given info populated initially. #[must_use] - pub fn new(listen_info: WebRtcServerListenInfo) -> Self { + pub fn new(listen_info: ListenInfo) -> Self { Self(vec![listen_info]) } /// Insert another listen info. #[must_use] - pub fn insert(mut self, listen_info: WebRtcServerListenInfo) -> Self { + pub fn insert(mut self, listen_info: ListenInfo) -> Self { self.0.push(listen_info); self } } impl Deref for WebRtcServerListenInfos { - type Target = Vec; + type Target = Vec; fn deref(&self) -> &Self::Target { &self.0 @@ -119,10 +105,10 @@ impl Deref for WebRtcServerListenInfos { #[error("Empty list of listen infos provided, should have at least one element")] pub struct EmptyListError; -impl TryFrom> for WebRtcServerListenInfos { +impl TryFrom> for WebRtcServerListenInfos { type Error = EmptyListError; - fn try_from(listen_infos: Vec) -> Result { + fn try_from(listen_infos: Vec) -> Result { if listen_infos.is_empty() { Err(EmptyListError) } else { diff --git a/rust/src/webrtc_server/tests.rs b/rust/src/webrtc_server/tests.rs index a87f17d653..a07c32c648 100644 --- a/rust/src/webrtc_server/tests.rs +++ b/rust/src/webrtc_server/tests.rs @@ -1,5 +1,5 @@ -use crate::data_structures::{ListenIp, Protocol}; -use crate::webrtc_server::{WebRtcServerListenInfo, WebRtcServerListenInfos, WebRtcServerOptions}; +use crate::data_structures::{ListenInfo, Protocol}; +use crate::webrtc_server::{WebRtcServerListenInfos, WebRtcServerOptions}; use crate::worker::{Worker, WorkerSettings}; use crate::worker_manager::WorkerManager; use futures_lite::future; @@ -33,13 +33,13 @@ fn worker_close_event() { let webrtc_server = worker .create_webrtc_server(WebRtcServerOptions::new(WebRtcServerListenInfos::new( - WebRtcServerListenInfo { + ListenInfo { protocol: Protocol::Udp, - listen_ip: ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - }, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, port: Some(port), + send_buffer_size: None, + recv_buffer_size: None, }, ))) .await diff --git a/rust/tests/integration/consumer.rs b/rust/tests/integration/consumer.rs index 385c92601f..7ebb7e9ba0 100644 --- a/rust/tests/integration/consumer.rs +++ b/rust/tests/integration/consumer.rs @@ -5,7 +5,7 @@ use hash_hasher::{HashedMap, HashedSet}; use mediasoup::consumer::{ ConsumableRtpEncoding, ConsumerLayers, ConsumerOptions, ConsumerScore, ConsumerType, }; -use mediasoup::data_structures::{AppData, ListenIp}; +use mediasoup::data_structures::{AppData, ListenInfo, Protocol}; use mediasoup::prelude::*; use mediasoup::producer::ProducerOptions; use mediasoup::router::{Router, RouterOptions}; @@ -18,7 +18,9 @@ use mediasoup::rtp_parameters::{ }; use mediasoup::scalability_modes::ScalabilityMode; use mediasoup::transport::ConsumeError; -use mediasoup::webrtc_transport::{TransportListenIps, WebRtcTransport, WebRtcTransportOptions}; +use mediasoup::webrtc_transport::{ + WebRtcTransport, WebRtcTransportListenInfos, WebRtcTransportOptions, +}; use mediasoup::worker::{Worker, WorkerSettings}; use mediasoup::worker_manager::WorkerManager; use parking_lot::Mutex; @@ -346,10 +348,15 @@ async fn init() -> ( .await .expect("Failed to create router"); - let transport_options = WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - })); + let transport_options = + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, + })); let transport_1 = router .create_webrtc_transport(transport_options.clone()) diff --git a/rust/tests/integration/data_consumer.rs b/rust/tests/integration/data_consumer.rs index 37e510720d..30b3688279 100644 --- a/rust/tests/integration/data_consumer.rs +++ b/rust/tests/integration/data_consumer.rs @@ -3,13 +3,15 @@ use futures_lite::future; use hash_hasher::{HashedMap, HashedSet}; use mediasoup::data_consumer::{DataConsumerOptions, DataConsumerType}; use mediasoup::data_producer::{DataProducer, DataProducerOptions}; -use mediasoup::data_structures::{AppData, ListenIp}; +use mediasoup::data_structures::{AppData, ListenInfo, Protocol}; use mediasoup::direct_transport::DirectTransportOptions; use mediasoup::plain_transport::PlainTransportOptions; use mediasoup::prelude::*; use mediasoup::router::{Router, RouterOptions}; use mediasoup::sctp_parameters::SctpStreamParameters; -use mediasoup::webrtc_transport::{TransportListenIps, WebRtcTransport, WebRtcTransportOptions}; +use mediasoup::webrtc_transport::{ + WebRtcTransport, WebRtcTransportListenInfos, WebRtcTransportOptions, +}; use mediasoup::worker::{Worker, WorkerSettings}; use mediasoup::worker_manager::WorkerManager; use std::env; @@ -61,9 +63,13 @@ async fn init() -> (Worker, Router, WebRtcTransport, DataProducer) { let transport = router .create_webrtc_transport({ let mut transport_options = - WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, })); transport_options.enable_sctp = true; @@ -88,9 +94,13 @@ fn consume_data_succeeds() { let transport2 = router .create_plain_transport({ - let mut transport_options = PlainTransportOptions::new(ListenIp { + let mut transport_options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); transport_options.enable_sctp = true; @@ -187,9 +197,13 @@ fn weak() { let transport2 = router .create_plain_transport({ - let mut transport_options = PlainTransportOptions::new(ListenIp { + let mut transport_options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); transport_options.enable_sctp = true; @@ -436,9 +450,13 @@ fn close_event() { let transport2 = router .create_plain_transport({ - let mut transport_options = PlainTransportOptions::new(ListenIp { + let mut transport_options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); transport_options.enable_sctp = true; diff --git a/rust/tests/integration/data_producer.rs b/rust/tests/integration/data_producer.rs index 809e95bee8..7fb83ce83f 100644 --- a/rust/tests/integration/data_producer.rs +++ b/rust/tests/integration/data_producer.rs @@ -2,13 +2,15 @@ use async_io::Timer; use futures_lite::future; use hash_hasher::{HashedMap, HashedSet}; use mediasoup::data_producer::{DataProducerOptions, DataProducerType}; -use mediasoup::data_structures::{AppData, ListenIp}; +use mediasoup::data_structures::{AppData, ListenInfo, Protocol}; use mediasoup::plain_transport::{PlainTransport, PlainTransportOptions}; use mediasoup::prelude::*; use mediasoup::router::{Router, RouterOptions}; use mediasoup::sctp_parameters::SctpStreamParameters; use mediasoup::transport::ProduceDataError; -use mediasoup::webrtc_transport::{TransportListenIps, WebRtcTransport, WebRtcTransportOptions}; +use mediasoup::webrtc_transport::{ + WebRtcTransport, WebRtcTransportListenInfos, WebRtcTransportOptions, +}; use mediasoup::worker::{RequestError, Worker, WorkerSettings}; use mediasoup::worker_manager::WorkerManager; use std::env; @@ -47,9 +49,13 @@ async fn init() -> (Worker, Router, WebRtcTransport, PlainTransport) { let transport1 = router .create_webrtc_transport({ let mut transport_options = - WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, })); transport_options.enable_sctp = true; @@ -61,9 +67,13 @@ async fn init() -> (Worker, Router, WebRtcTransport, PlainTransport) { let transport2 = router .create_plain_transport({ - let mut transport_options = PlainTransportOptions::new(ListenIp { + let mut transport_options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); transport_options.enable_sctp = true; diff --git a/rust/tests/integration/multiopus.rs b/rust/tests/integration/multiopus.rs index 16ea0ab483..650b450cd0 100644 --- a/rust/tests/integration/multiopus.rs +++ b/rust/tests/integration/multiopus.rs @@ -1,5 +1,5 @@ use futures_lite::future; -use mediasoup::data_structures::ListenIp; +use mediasoup::data_structures::{ListenInfo, Protocol}; use mediasoup::prelude::*; use mediasoup::producer::ProducerOptions; use mediasoup::router::{Router, RouterOptions}; @@ -8,7 +8,9 @@ use mediasoup::rtp_parameters::{ RtpHeaderExtension, RtpHeaderExtensionDirection, RtpHeaderExtensionParameters, RtpHeaderExtensionUri, RtpParameters, }; -use mediasoup::webrtc_transport::{TransportListenIps, WebRtcTransport, WebRtcTransportOptions}; +use mediasoup::webrtc_transport::{ + WebRtcTransport, WebRtcTransportListenInfos, WebRtcTransportOptions, +}; use mediasoup::worker::WorkerSettings; use mediasoup::worker_manager::WorkerManager; use std::env; @@ -127,10 +129,15 @@ async fn init() -> (Router, WebRtcTransport) { .await .expect("Failed to create router"); - let transport_options = WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - })); + let transport_options = + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, + })); let transport = router .create_webrtc_transport(transport_options.clone()) diff --git a/rust/tests/integration/pipe_transport.rs b/rust/tests/integration/pipe_transport.rs index c6bc626d66..242c37a483 100644 --- a/rust/tests/integration/pipe_transport.rs +++ b/rust/tests/integration/pipe_transport.rs @@ -2,7 +2,7 @@ use futures_lite::future; use mediasoup::consumer::{ConsumerOptions, ConsumerScore, ConsumerType}; use mediasoup::data_consumer::{DataConsumerOptions, DataConsumerType}; use mediasoup::data_producer::{DataProducerOptions, DataProducerType}; -use mediasoup::data_structures::{AppData, ListenIp}; +use mediasoup::data_structures::{AppData, ListenInfo, Protocol}; use mediasoup::pipe_transport::{PipeTransportOptions, PipeTransportRemoteParameters}; use mediasoup::prelude::*; use mediasoup::producer::ProducerOptions; @@ -19,7 +19,9 @@ use mediasoup::rtp_parameters::{ use mediasoup::sctp_parameters::SctpStreamParameters; use mediasoup::srtp_parameters::{SrtpCryptoSuite, SrtpParameters}; use mediasoup::transport::ProduceError; -use mediasoup::webrtc_transport::{TransportListenIps, WebRtcTransport, WebRtcTransportOptions}; +use mediasoup::webrtc_transport::{ + WebRtcTransport, WebRtcTransportListenInfos, WebRtcTransportOptions, +}; use mediasoup::worker::{RequestError, Worker, WorkerSettings}; use mediasoup::worker_manager::WorkerManager; use parking_lot::Mutex; @@ -253,10 +255,15 @@ async fn init() -> ( .await .expect("Failed to create router"); - let mut transport_options = WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - })); + let mut transport_options = + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, + })); transport_options.enable_sctp = true; let transport_1 = router1 @@ -593,9 +600,13 @@ fn weak() { let pipe_transport = router1 .create_pipe_transport({ - let mut options = PipeTransportOptions::new(ListenIp { + let mut options = PipeTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); options.enable_rtx = true; @@ -623,13 +634,14 @@ fn create_with_fixed_port_succeeds() { let pipe_transport = router1 .create_pipe_transport({ - let mut options = PipeTransportOptions::new(ListenIp { + PipeTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, - }); - options.port = Some(port); - - options + port: Some(port), + send_buffer_size: None, + recv_buffer_size: None, + }) }) .await .expect("Failed to create Pipe transport"); @@ -645,9 +657,13 @@ fn create_with_enable_rtx_succeeds() { let pipe_transport = router1 .create_pipe_transport({ - let mut options = PipeTransportOptions::new(ListenIp { + let mut options = PipeTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); options.enable_rtx = true; @@ -753,9 +769,13 @@ fn create_with_enable_srtp_succeeds() { let pipe_transport = router1 .create_pipe_transport({ - let mut options = PipeTransportOptions::new(ListenIp { + let mut options = PipeTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); options.enable_srtp = true; @@ -804,9 +824,13 @@ fn create_with_invalid_srtp_parameters_fails() { let (_worker1, _worker2, router1, _router2, _transport1, _transport2) = init().await; let pipe_transport = router1 - .create_pipe_transport(PipeTransportOptions::new(ListenIp { + .create_pipe_transport(PipeTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, })) .await .expect("Failed to create Pipe transport"); @@ -1126,9 +1150,13 @@ fn pipe_to_router_called_twice_generates_single_pair() { .expect("Failed to create router"); let mut transport_options = - WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, })); transport_options.enable_sctp = true; diff --git a/rust/tests/integration/plain_transport.rs b/rust/tests/integration/plain_transport.rs index fc4add8344..9c0be9bedc 100644 --- a/rust/tests/integration/plain_transport.rs +++ b/rust/tests/integration/plain_transport.rs @@ -1,6 +1,6 @@ use futures_lite::future; use hash_hasher::HashedSet; -use mediasoup::data_structures::{AppData, ListenIp, Protocol, SctpState, TransportTuple}; +use mediasoup::data_structures::{AppData, ListenInfo, Protocol, SctpState, TransportTuple}; use mediasoup::plain_transport::{PlainTransportOptions, PlainTransportRemoteParameters}; use mediasoup::prelude::*; use mediasoup::router::{Router, RouterOptions}; @@ -89,9 +89,13 @@ fn create_succeeds() { { let transport = router .create_plain_transport({ - let mut plain_transport_options = PlainTransportOptions::new(ListenIp { + let mut plain_transport_options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("4.4.4.4".parse().unwrap()), + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); plain_transport_options.rtcp_mux = false; @@ -123,9 +127,13 @@ fn create_succeeds() { let transport1 = router .create_plain_transport({ - let mut plain_transport_options = PlainTransportOptions::new(ListenIp { + let mut plain_transport_options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); plain_transport_options.rtcp_mux = true; plain_transport_options.enable_sctp = true; @@ -191,9 +199,13 @@ fn create_succeeds() { { let transport2 = router .create_plain_transport({ - let mut plain_transport_options = PlainTransportOptions::new(ListenIp { + let mut plain_transport_options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); plain_transport_options.rtcp_mux = false; @@ -251,13 +263,14 @@ fn create_with_fixed_port_succeeds() { let transport = router .create_plain_transport({ - let mut plain_transport_options = PlainTransportOptions::new(ListenIp { + PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("4.4.4.4".parse().unwrap()), - }); - plain_transport_options.port = Some(port); - - plain_transport_options + port: Some(port), + send_buffer_size: None, + recv_buffer_size: None, + }) }) .await .expect("Failed to create Plain transport"); @@ -273,9 +286,13 @@ fn weak() { let transport = router .create_plain_transport({ - let mut plain_transport_options = PlainTransportOptions::new(ListenIp { + let mut plain_transport_options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("4.4.4.4".parse().unwrap()), + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); plain_transport_options.rtcp_mux = false; @@ -302,9 +319,13 @@ fn create_enable_srtp_succeeds() { // Use default cryptoSuite: 'AES_CM_128_HMAC_SHA1_80'. let transport1 = router .create_plain_transport({ - let mut plain_transport_options = PlainTransportOptions::new(ListenIp { + let mut plain_transport_options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); plain_transport_options.enable_srtp = true; @@ -363,9 +384,13 @@ fn create_non_bindable_ip() { assert!(matches!( router - .create_plain_transport(PlainTransportOptions::new(ListenIp { + .create_plain_transport(PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: "8.8.8.8".parse().unwrap(), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, })) .await, Err(RequestError::Response { .. }), @@ -380,9 +405,13 @@ fn get_stats_succeeds() { let transport = router .create_plain_transport({ - let mut plain_transport_options = PlainTransportOptions::new(ListenIp { + let mut plain_transport_options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("4.4.4.4".parse().unwrap()), + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); plain_transport_options.rtcp_mux = false; @@ -436,9 +465,13 @@ fn connect_succeeds() { let transport = router .create_plain_transport({ - let mut plain_transport_options = PlainTransportOptions::new(ListenIp { + let mut plain_transport_options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("4.4.4.4".parse().unwrap()), + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); plain_transport_options.rtcp_mux = false; @@ -507,9 +540,13 @@ fn connect_wrong_arguments() { let transport = router .create_plain_transport({ - let mut plain_transport_options = PlainTransportOptions::new(ListenIp { + let mut plain_transport_options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("4.4.4.4".parse().unwrap()), + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); plain_transport_options.rtcp_mux = false; @@ -543,9 +580,13 @@ fn close_event() { let transport = router .create_plain_transport({ - let mut plain_transport_options = PlainTransportOptions::new(ListenIp { + let mut plain_transport_options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("4.4.4.4".parse().unwrap()), + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); plain_transport_options.rtcp_mux = false; diff --git a/rust/tests/integration/producer.rs b/rust/tests/integration/producer.rs index ee5023b1ef..f0055301dc 100644 --- a/rust/tests/integration/producer.rs +++ b/rust/tests/integration/producer.rs @@ -1,7 +1,7 @@ use async_io::Timer; use futures_lite::future; use hash_hasher::{HashedMap, HashedSet}; -use mediasoup::data_structures::{AppData, ListenIp}; +use mediasoup::data_structures::{AppData, ListenInfo, Protocol}; use mediasoup::prelude::*; use mediasoup::producer::{ProducerOptions, ProducerTraceEventType, ProducerType}; use mediasoup::router::{Router, RouterOptions}; @@ -12,7 +12,9 @@ use mediasoup::rtp_parameters::{ }; use mediasoup::scalability_modes::ScalabilityMode; use mediasoup::transport::ProduceError; -use mediasoup::webrtc_transport::{TransportListenIps, WebRtcTransport, WebRtcTransportOptions}; +use mediasoup::webrtc_transport::{ + WebRtcTransport, WebRtcTransportListenInfos, WebRtcTransportOptions, +}; use mediasoup::worker::{Worker, WorkerSettings}; use mediasoup::worker_manager::WorkerManager; use std::env; @@ -199,10 +201,15 @@ async fn init() -> (Worker, Router, WebRtcTransport, WebRtcTransport) { .await .expect("Failed to create router"); - let transport_options = WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - })); + let transport_options = + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, + })); let transport_1 = router .create_webrtc_transport(transport_options.clone()) diff --git a/rust/tests/integration/smoke.rs b/rust/tests/integration/smoke.rs index e6527f3671..2f1a46f658 100644 --- a/rust/tests/integration/smoke.rs +++ b/rust/tests/integration/smoke.rs @@ -4,7 +4,7 @@ use mediasoup::audio_level_observer::AudioLevelObserverOptions; use mediasoup::consumer::{ConsumerLayers, ConsumerOptions, ConsumerTraceEventType}; use mediasoup::data_consumer::DataConsumerOptions; use mediasoup::data_producer::DataProducerOptions; -use mediasoup::data_structures::ListenIp; +use mediasoup::data_structures::{ListenInfo, Protocol}; use mediasoup::direct_transport::DirectTransportOptions; use mediasoup::plain_transport::PlainTransportOptions; use mediasoup::prelude::*; @@ -17,7 +17,7 @@ use mediasoup::rtp_parameters::{ }; use mediasoup::sctp_parameters::SctpStreamParameters; use mediasoup::transport::TransportTraceEventType; -use mediasoup::webrtc_transport::{TransportListenIps, WebRtcTransportOptions}; +use mediasoup::webrtc_transport::{WebRtcTransportListenInfos, WebRtcTransportOptions}; use mediasoup::worker::{WorkerLogLevel, WorkerSettings, WorkerUpdateSettings}; use mediasoup::worker_manager::WorkerManager; use std::net::{IpAddr, Ipv4Addr}; @@ -82,10 +82,15 @@ fn smoke() { let webrtc_transport = router .create_webrtc_transport({ - let mut options = WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - })); + let mut options = + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, + })); options.enable_sctp = true; @@ -264,9 +269,13 @@ fn smoke() { let plain_transport = router .create_plain_transport({ - let mut options = PlainTransportOptions::new(ListenIp { + let mut options = PlainTransportOptions::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, }); options.enable_sctp = true; diff --git a/rust/tests/integration/webrtc_server.rs b/rust/tests/integration/webrtc_server.rs index a4f572ffa0..f02cb765be 100644 --- a/rust/tests/integration/webrtc_server.rs +++ b/rust/tests/integration/webrtc_server.rs @@ -1,9 +1,7 @@ use futures_lite::future; use hash_hasher::HashedSet; -use mediasoup::data_structures::{AppData, ListenIp, Protocol}; -use mediasoup::webrtc_server::{ - WebRtcServerIpPort, WebRtcServerListenInfo, WebRtcServerListenInfos, WebRtcServerOptions, -}; +use mediasoup::data_structures::{AppData, ListenInfo, Protocol}; +use mediasoup::webrtc_server::{WebRtcServerIpPort, WebRtcServerListenInfos, WebRtcServerOptions}; use mediasoup::worker::{ChannelMessageHandlers, CreateWebRtcServerError, Worker, WorkerSettings}; use mediasoup::worker_manager::WorkerManager; use portpicker::pick_unused_port; @@ -61,21 +59,21 @@ fn create_webrtc_server_succeeds() { let webrtc_server = worker1 .create_webrtc_server({ - let listen_infos = WebRtcServerListenInfos::new(WebRtcServerListenInfo { + let listen_infos = WebRtcServerListenInfos::new(ListenInfo { protocol: Protocol::Udp, - listen_ip: ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - }, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, port: Some(port1), + send_buffer_size: None, + recv_buffer_size: None, }); - let listen_infos = listen_infos.insert(WebRtcServerListenInfo { + let listen_infos = listen_infos.insert(ListenInfo { protocol: Protocol::Tcp, - listen_ip: ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: Some(IpAddr::V4(Ipv4Addr::new(1, 2, 3, 4))), - }, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: Some(IpAddr::V4(Ipv4Addr::new(1, 2, 3, 4))), port: Some(port2), + send_buffer_size: None, + recv_buffer_size: None, }); let mut webrtc_server_options = WebRtcServerOptions::new(listen_infos); @@ -155,21 +153,21 @@ fn create_webrtc_server_without_specifying_port_succeeds() { let webrtc_server = worker1 .create_webrtc_server({ - let listen_infos = WebRtcServerListenInfos::new(WebRtcServerListenInfo { + let listen_infos = WebRtcServerListenInfos::new(ListenInfo { protocol: Protocol::Udp, - listen_ip: ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - }, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, port: None, + send_buffer_size: None, + recv_buffer_size: None, }); - let listen_infos = listen_infos.insert(WebRtcServerListenInfo { + let listen_infos = listen_infos.insert(ListenInfo { protocol: Protocol::Tcp, - listen_ip: ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: Some(IpAddr::V4(Ipv4Addr::new(1, 2, 3, 4))), - }, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: Some(IpAddr::V4(Ipv4Addr::new(1, 2, 3, 4))), port: None, + send_buffer_size: None, + recv_buffer_size: None, }); let mut webrtc_server_options = WebRtcServerOptions::new(listen_infos); @@ -236,21 +234,21 @@ fn unavailable_infos_fails() { { let create_result = worker1 .create_webrtc_server({ - let listen_infos = WebRtcServerListenInfos::new(WebRtcServerListenInfo { + let listen_infos = WebRtcServerListenInfos::new(ListenInfo { protocol: Protocol::Udp, - listen_ip: ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - }, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, port: Some(port1), + send_buffer_size: None, + recv_buffer_size: None, }); - let listen_infos = listen_infos.insert(WebRtcServerListenInfo { + let listen_infos = listen_infos.insert(ListenInfo { protocol: Protocol::Udp, - listen_ip: ListenIp { - ip: IpAddr::V4(Ipv4Addr::new(1, 2, 3, 4)), - announced_ip: None, - }, + ip: IpAddr::V4(Ipv4Addr::new(1, 2, 3, 4)), + announced_ip: None, port: Some(port2), + send_buffer_size: None, + recv_buffer_size: None, }); WebRtcServerOptions::new(listen_infos) @@ -267,21 +265,21 @@ fn unavailable_infos_fails() { { let create_result = worker1 .create_webrtc_server({ - let listen_infos = WebRtcServerListenInfos::new(WebRtcServerListenInfo { + let listen_infos = WebRtcServerListenInfos::new(ListenInfo { protocol: Protocol::Udp, - listen_ip: ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - }, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, port: Some(port1), + send_buffer_size: None, + recv_buffer_size: None, }); - let listen_infos = listen_infos.insert(WebRtcServerListenInfo { + let listen_infos = listen_infos.insert(ListenInfo { protocol: Protocol::Udp, - listen_ip: ListenIp { - ip: IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), - announced_ip: Some(IpAddr::V4(Ipv4Addr::new(1, 2, 3, 4))), - }, + ip: IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), + announced_ip: Some(IpAddr::V4(Ipv4Addr::new(1, 2, 3, 4))), port: Some(port1), + send_buffer_size: None, + recv_buffer_size: None, }); WebRtcServerOptions::new(listen_infos) @@ -298,13 +296,13 @@ fn unavailable_infos_fails() { { let _webrtc_server = worker1 .create_webrtc_server(WebRtcServerOptions::new(WebRtcServerListenInfos::new( - WebRtcServerListenInfo { + ListenInfo { protocol: Protocol::Udp, - listen_ip: ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - }, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, port: Some(port1), + send_buffer_size: None, + recv_buffer_size: None, }, ))) .await @@ -312,13 +310,13 @@ fn unavailable_infos_fails() { let create_result = worker2 .create_webrtc_server(WebRtcServerOptions::new(WebRtcServerListenInfos::new( - WebRtcServerListenInfo { + ListenInfo { protocol: Protocol::Udp, - listen_ip: ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - }, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, port: Some(port1), + send_buffer_size: None, + recv_buffer_size: None, }, ))) .await; @@ -340,13 +338,13 @@ fn close_event() { let webrtc_server = worker1 .create_webrtc_server(WebRtcServerOptions::new(WebRtcServerListenInfos::new( - WebRtcServerListenInfo { + ListenInfo { protocol: Protocol::Udp, - listen_ip: ListenIp { - ip: IpAddr::V4(Ipv4Addr::LOCALHOST), - announced_ip: None, - }, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, port: Some(port), + send_buffer_size: None, + recv_buffer_size: None, }, ))) .await diff --git a/rust/tests/integration/webrtc_transport.rs b/rust/tests/integration/webrtc_transport.rs index f50bae6a28..ccb811cd6f 100644 --- a/rust/tests/integration/webrtc_transport.rs +++ b/rust/tests/integration/webrtc_transport.rs @@ -2,7 +2,7 @@ use futures_lite::future; use hash_hasher::HashedSet; use mediasoup::data_structures::{ AppData, DtlsFingerprint, DtlsParameters, DtlsRole, DtlsState, IceCandidateTcpType, - IceCandidateType, IceRole, IceState, ListenIp, Protocol, SctpState, + IceCandidateType, IceRole, IceState, ListenInfo, Protocol, SctpState, }; use mediasoup::prelude::*; use mediasoup::router::{Router, RouterOptions}; @@ -12,8 +12,7 @@ use mediasoup::rtp_parameters::{ use mediasoup::sctp_parameters::{NumSctpStreams, SctpParameters}; use mediasoup::transport::TransportTraceEventType; use mediasoup::webrtc_transport::{ - TransportListenIps, WebRtcTransportListen, WebRtcTransportOptions, - WebRtcTransportRemoteParameters, + WebRtcTransportListenInfos, WebRtcTransportOptions, WebRtcTransportRemoteParameters, }; use mediasoup::worker::{RequestError, Worker, WorkerSettings}; use mediasoup::worker_manager::WorkerManager; @@ -95,12 +94,16 @@ fn create_succeeds() { { let transport = router - .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - ListenIp { + .create_webrtc_transport(WebRtcTransportOptions::new( + WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), - }, - ))) + port: None, + send_buffer_size: None, + recv_buffer_size: None, + }), + )) .await .expect("Failed to create WebRTC transport"); @@ -129,25 +132,34 @@ fn create_succeeds() { .create_webrtc_transport({ let mut webrtc_transport_options = WebRtcTransportOptions::new( vec![ - ListenIp { + ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), + port: None, + send_buffer_size: None, + recv_buffer_size: None, }, - ListenIp { + ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::UNSPECIFIED), announced_ip: Some("9.9.9.2".parse().unwrap()), + port: None, + send_buffer_size: None, + recv_buffer_size: None, }, - ListenIp { + ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, }, ] .try_into() .unwrap(), ); - webrtc_transport_options.enable_tcp = true; - webrtc_transport_options.prefer_udp = true; - webrtc_transport_options.enable_sctp = true; webrtc_transport_options.num_sctp_streams = NumSctpStreams { os: 2048, mis: 2048, @@ -214,9 +226,9 @@ fn create_succeeds() { assert_eq!(ice_candidates[4].r#type, IceCandidateType::Host); assert_eq!(ice_candidates[4].tcp_type, None); assert!(ice_candidates[0].priority > ice_candidates[1].priority); - assert!(ice_candidates[2].priority > ice_candidates[1].priority); + assert!(ice_candidates[1].priority > ice_candidates[2].priority); assert!(ice_candidates[2].priority > ice_candidates[3].priority); - assert!(ice_candidates[4].priority > ice_candidates[3].priority); + assert!(ice_candidates[3].priority > ice_candidates[4].priority); assert!(ice_candidates[4].priority > ice_candidates[5].priority); } @@ -258,29 +270,23 @@ fn create_with_fixed_port_succeeds() { future::block_on(async move { let (_worker, router) = init().await; - let port1 = pick_unused_port().unwrap(); + let port = pick_unused_port().unwrap(); let transport = router .create_webrtc_transport({ - let mut options = WebRtcTransportOptions::new(TransportListenIps::new(ListenIp { + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), - })); - match &mut options.listen { - WebRtcTransportListen::Individual { port, .. } => { - port.replace(port1); - } - WebRtcTransportListen::Server { .. } => { - unreachable!(); - } - } - - options + port: Some(port), + send_buffer_size: None, + recv_buffer_size: None, + })) }) .await .expect("Failed to create WebRTC transport"); - assert_eq!(transport.ice_candidates().get(0).unwrap().port, port1); + assert_eq!(transport.ice_candidates().get(0).unwrap().port, port); }); } @@ -290,12 +296,16 @@ fn weak() { let (_worker, router) = init().await; let transport = router - .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - ListenIp { + .create_webrtc_transport(WebRtcTransportOptions::new( + WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), - }, - ))) + port: None, + send_buffer_size: None, + recv_buffer_size: None, + }), + )) .await .expect("Failed to create WebRTC transport"); @@ -316,12 +326,16 @@ fn create_non_bindable_ip() { assert!(matches!( router - .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - ListenIp { + .create_webrtc_transport(WebRtcTransportOptions::new( + WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: "8.8.8.8".parse().unwrap(), announced_ip: None, - }, - ))) + port: None, + send_buffer_size: None, + recv_buffer_size: None, + },) + )) .await, Err(RequestError::Response { .. }), )); @@ -334,12 +348,16 @@ fn get_stats_succeeds() { let (_worker, router) = init().await; let transport = router - .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - ListenIp { + .create_webrtc_transport(WebRtcTransportOptions::new( + WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), - }, - ))) + port: None, + send_buffer_size: None, + recv_buffer_size: None, + }), + )) .await .expect("Failed to create WebRTC transport"); @@ -381,12 +399,16 @@ fn connect_succeeds() { let (_worker, router) = init().await; let transport = router - .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - ListenIp { + .create_webrtc_transport(WebRtcTransportOptions::new( + WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), - }, - ))) + port: None, + send_buffer_size: None, + recv_buffer_size: None, + }), + )) .await .expect("Failed to create WebRTC transport"); @@ -426,12 +448,16 @@ fn set_max_incoming_bitrate_succeeds() { let (_worker, router) = init().await; let transport = router - .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - ListenIp { + .create_webrtc_transport(WebRtcTransportOptions::new( + WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), - }, - ))) + port: None, + send_buffer_size: None, + recv_buffer_size: None, + }), + )) .await .expect("Failed to create WebRTC transport"); @@ -454,12 +480,16 @@ fn set_max_outgoing_bitrate_succeeds() { let (_worker, router) = init().await; let transport = router - .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - ListenIp { + .create_webrtc_transport(WebRtcTransportOptions::new( + WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), - }, - ))) + port: None, + send_buffer_size: None, + recv_buffer_size: None, + }), + )) .await .expect("Failed to create WebRTC transport"); @@ -482,12 +512,16 @@ fn set_min_outgoing_bitrate_succeeds() { let (_worker, router) = init().await; let transport = router - .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - ListenIp { + .create_webrtc_transport(WebRtcTransportOptions::new( + WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), - }, - ))) + port: None, + send_buffer_size: None, + recv_buffer_size: None, + }), + )) .await .expect("Failed to create WebRTC transport"); @@ -510,12 +544,16 @@ fn set_max_outgoing_bitrate_fails_if_value_is_lower_than_current_min_limit() { let (_worker, router) = init().await; let transport = router - .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - ListenIp { + .create_webrtc_transport(WebRtcTransportOptions::new( + WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), - }, - ))) + port: None, + send_buffer_size: None, + recv_buffer_size: None, + }), + )) .await .expect("Failed to create WebRTC transport"); @@ -543,12 +581,16 @@ fn set_min_outgoing_bitrate_fails_if_value_is_higher_than_current_max_limit() { let (_worker, router) = init().await; let transport = router - .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - ListenIp { + .create_webrtc_transport(WebRtcTransportOptions::new( + WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), - }, - ))) + port: None, + send_buffer_size: None, + recv_buffer_size: None, + }), + )) .await .expect("Failed to create WebRTC transport"); @@ -576,12 +618,16 @@ fn restart_ice_succeeds() { let (_worker, router) = init().await; let transport = router - .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - ListenIp { + .create_webrtc_transport(WebRtcTransportOptions::new( + WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), - }, - ))) + port: None, + send_buffer_size: None, + recv_buffer_size: None, + }), + )) .await .expect("Failed to create WebRTC transport"); @@ -607,12 +653,16 @@ fn enable_trace_event_succeeds() { let (_worker, router) = init().await; let transport = router - .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - ListenIp { + .create_webrtc_transport(WebRtcTransportOptions::new( + WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), - }, - ))) + port: None, + send_buffer_size: None, + recv_buffer_size: None, + }), + )) .await .expect("Failed to create WebRTC transport"); @@ -669,12 +719,16 @@ fn close_event() { let (_worker, router) = init().await; let transport = router - .create_webrtc_transport(WebRtcTransportOptions::new(TransportListenIps::new( - ListenIp { + .create_webrtc_transport(WebRtcTransportOptions::new( + WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, ip: IpAddr::V4(Ipv4Addr::LOCALHOST), announced_ip: Some("9.9.9.1".parse().unwrap()), - }, - ))) + port: None, + send_buffer_size: None, + recv_buffer_size: None, + }), + )) .await .expect("Failed to create WebRTC transport"); diff --git a/worker/fbs/pipeTransport.fbs b/worker/fbs/pipeTransport.fbs index d80e7204d5..82cc56515e 100644 --- a/worker/fbs/pipeTransport.fbs +++ b/worker/fbs/pipeTransport.fbs @@ -4,8 +4,7 @@ namespace FBS.PipeTransport; table PipeTransportOptions { base:FBS.Transport.Options (required); - listen_ip:FBS.Transport.ListenIp (required); - port:uint16; + listen_info:FBS.Transport.ListenInfo (required); enable_rtx:bool; enable_srtp:bool; } diff --git a/worker/fbs/plainTransport.fbs b/worker/fbs/plainTransport.fbs index 152523b254..fbcebb985c 100644 --- a/worker/fbs/plainTransport.fbs +++ b/worker/fbs/plainTransport.fbs @@ -5,8 +5,7 @@ namespace FBS.PlainTransport; table PlainTransportOptions { base:FBS.Transport.Options; - listen_ip:FBS.Transport.ListenIp (required); - port:uint16; + listen_info:FBS.Transport.ListenInfo (required); rtcp_mux:bool; comedia:bool; enable_srtp:bool; diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs index c961a3f604..7e9b7dfca7 100644 --- a/worker/fbs/transport.fbs +++ b/worker/fbs/transport.fbs @@ -8,9 +8,13 @@ namespace FBS.Transport; enum Protocol: uint8 { UDP = 1, TCP } -table ListenIp { +table ListenInfo { + protocol:FBS.Transport.Protocol=UDP; ip:string (required); announced_ip:string; + port:uint16 = 0; + send_buffer_size:uint32 = 0; + recv_buffer_size:uint32 = 0; } table RestartIceResponse { @@ -91,6 +95,17 @@ table SctpListener { stream_id_table:[FBS.Common.Uint16String] (required); } +table Options { + direct:bool = false; + max_message_size:uint32; + initial_available_outgoing_bitrate:uint32; + enable_sctp:bool = false; + num_sctp_streams:FBS.SctpParameters.NumSctpStreams; + max_sctp_message_size:uint32; + sctp_send_buffer_size:uint32; + is_data_channel:bool = false; +} + table Dump { id:string (required); direct:bool=false; @@ -109,17 +124,6 @@ table Dump { trace_event_types:[string] (required); } -table Options { - direct:bool = false; - max_message_size:uint32; - initial_available_outgoing_bitrate:uint32; - enable_sctp:bool = false; - num_sctp_streams:FBS.SctpParameters.NumSctpStreams; - max_sctp_message_size:uint32; - sctp_send_buffer_size:uint32; - is_data_channel:bool = false; -} - table Stats { transport_id:string (required); timestamp:uint64; diff --git a/worker/fbs/webRtcServer.fbs b/worker/fbs/webRtcServer.fbs index 087f744088..7f556902f9 100644 --- a/worker/fbs/webRtcServer.fbs +++ b/worker/fbs/webRtcServer.fbs @@ -2,13 +2,6 @@ include "transport.fbs"; namespace FBS.WebRtcServer; -table ListenInfo { - protocol:FBS.Transport.Protocol=UDP; - ip:string (required); - announced_ip:string; - port:uint16 = 0; -} - table IpPort { ip:string (required); port:uint16; diff --git a/worker/fbs/webRtcTransport.fbs b/worker/fbs/webRtcTransport.fbs index 2fcaa930fc..f3551139e2 100644 --- a/worker/fbs/webRtcTransport.fbs +++ b/worker/fbs/webRtcTransport.fbs @@ -4,8 +4,7 @@ include "sctpParameters.fbs"; namespace FBS.WebRtcTransport; table ListenIndividual { - listen_ips:[FBS.Transport.ListenIp] (required); - port:uint16; + listen_infos:[FBS.Transport.ListenInfo] (required); } table ListenServer { @@ -20,10 +19,6 @@ union Listen { table WebRtcTransportOptions { base:FBS.Transport.Options (required); listen:Listen (required); - enable_udp:bool = true; - enable_tcp:bool = false; - prefer_udp:bool = false; - prefer_tcp:bool = false; } table Fingerprint { diff --git a/worker/fbs/worker.fbs b/worker/fbs/worker.fbs index 26b97b1437..326532aec9 100644 --- a/worker/fbs/worker.fbs +++ b/worker/fbs/worker.fbs @@ -1,4 +1,4 @@ -include "webRtcServer.fbs"; +include "transport.fbs"; namespace FBS.Worker; @@ -40,7 +40,7 @@ table UpdateSettingsRequest { table CreateWebRtcServerRequest { web_rtc_server_id:string (required); - listen_infos:[FBS.WebRtcServer.ListenInfo]; + listen_infos:[FBS.Transport.ListenInfo]; } table CloseWebRtcServerRequest { diff --git a/worker/include/Channel/ChannelSocket.hpp b/worker/include/Channel/ChannelSocket.hpp index 58dc41a176..188ec03abb 100644 --- a/worker/include/Channel/ChannelSocket.hpp +++ b/worker/include/Channel/ChannelSocket.hpp @@ -4,12 +4,12 @@ #include "common.hpp" #include "Channel/ChannelNotification.hpp" #include "Channel/ChannelRequest.hpp" -#include "handles/UnixStreamSocket.hpp" +#include "handles/UnixStreamSocketHandle.hpp" #include namespace Channel { - class ConsumerSocket : public ::UnixStreamSocket + class ConsumerSocket : public ::UnixStreamSocketHandle { public: class Listener @@ -26,7 +26,7 @@ namespace Channel ConsumerSocket(int fd, size_t bufferSize, Listener* listener); ~ConsumerSocket(); - /* Pure virtual methods inherited from ::UnixStreamSocket. */ + /* Pure virtual methods inherited from ::UnixStreamSocketHandle. */ public: void UserOnUnixStreamRead() override; void UserOnUnixStreamSocketClosed() override; @@ -36,12 +36,12 @@ namespace Channel Listener* listener{ nullptr }; }; - class ProducerSocket : public ::UnixStreamSocket + class ProducerSocket : public ::UnixStreamSocketHandle { public: ProducerSocket(int fd, size_t bufferSize); - /* Pure virtual methods inherited from ::UnixStreamSocket. */ + /* Pure virtual methods inherited from ::UnixStreamSocketHandle. */ public: void UserOnUnixStreamRead() override { diff --git a/worker/include/DepUsrSCTP.hpp b/worker/include/DepUsrSCTP.hpp index b7df08620b..122cb63c47 100644 --- a/worker/include/DepUsrSCTP.hpp +++ b/worker/include/DepUsrSCTP.hpp @@ -3,13 +3,13 @@ #include "common.hpp" #include "RTC/SctpAssociation.hpp" -#include "handles/Timer.hpp" +#include "handles/TimerHandle.hpp" #include class DepUsrSCTP { private: - class Checker : public Timer::Listener + class Checker : public TimerHandle::Listener { public: Checker(); @@ -19,12 +19,12 @@ class DepUsrSCTP void Start(); void Stop(); - /* Pure virtual methods inherited from Timer::Listener. */ + /* Pure virtual methods inherited from TimerHandle::Listener. */ public: - void OnTimer(Timer* timer) override; + void OnTimer(TimerHandle* timer) override; private: - Timer* timer{ nullptr }; + TimerHandle* timer{ nullptr }; uint64_t lastCalledAtMs{ 0u }; }; diff --git a/worker/include/RTC/ActiveSpeakerObserver.hpp b/worker/include/RTC/ActiveSpeakerObserver.hpp index 586820fdae..556e6c0e02 100644 --- a/worker/include/RTC/ActiveSpeakerObserver.hpp +++ b/worker/include/RTC/ActiveSpeakerObserver.hpp @@ -3,7 +3,7 @@ #include "RTC/RtpObserver.hpp" #include "RTC/Shared.hpp" -#include "handles/Timer.hpp" +#include "handles/TimerHandle.hpp" #include #include #include @@ -15,7 +15,7 @@ // https://github.com/jitsi/jitsi-utils/blob/master/src/main/java/org/jitsi/utils/dsi/DominantSpeakerIdentification.java namespace RTC { - class ActiveSpeakerObserver : public RTC::RtpObserver, public Timer::Listener + class ActiveSpeakerObserver : public RTC::RtpObserver, public TimerHandle::Listener { private: class Speaker @@ -90,14 +90,14 @@ namespace RTC bool CalculateActiveSpeaker(); void TimeoutIdleLevels(uint64_t now); - /* Pure virtual methods inherited from Timer. */ + /* Pure virtual methods inherited from TimerHandle. */ protected: - void OnTimer(Timer* timer) override; + void OnTimer(TimerHandle* timer) override; private: double relativeSpeachActivities[RelativeSpeachActivitiesLen]; std::string dominantId; - Timer* periodicTimer{ nullptr }; + TimerHandle* periodicTimer{ nullptr }; uint16_t interval{ 300u }; // Map of ProducerSpeakers indexed by Producer id. absl::flat_hash_map mapProducerSpeakers; diff --git a/worker/include/RTC/AudioLevelObserver.hpp b/worker/include/RTC/AudioLevelObserver.hpp index 54cec18f0f..49b17dcaf8 100644 --- a/worker/include/RTC/AudioLevelObserver.hpp +++ b/worker/include/RTC/AudioLevelObserver.hpp @@ -3,12 +3,12 @@ #include "RTC/RtpObserver.hpp" #include "RTC/Shared.hpp" -#include "handles/Timer.hpp" +#include "handles/TimerHandle.hpp" #include namespace RTC { - class AudioLevelObserver : public RTC::RtpObserver, public Timer::Listener + class AudioLevelObserver : public RTC::RtpObserver, public TimerHandle::Listener { private: struct DBovs @@ -38,9 +38,9 @@ namespace RTC void Update(); void ResetMapProducerDBovs(); - /* Pure virtual methods inherited from Timer. */ + /* Pure virtual methods inherited from TimerHandle. */ protected: - void OnTimer(Timer* timer) override; + void OnTimer(TimerHandle* timer) override; private: // Passed by argument. @@ -48,7 +48,7 @@ namespace RTC int8_t threshold{ -80 }; uint16_t interval{ 1000u }; // Allocated by this. - Timer* periodicTimer{ nullptr }; + TimerHandle* periodicTimer{ nullptr }; // Others. absl::flat_hash_map mapProducerDBovs; bool silence{ true }; diff --git a/worker/include/RTC/DtlsTransport.hpp b/worker/include/RTC/DtlsTransport.hpp index be0e0fdeb9..80b03802e1 100644 --- a/worker/include/RTC/DtlsTransport.hpp +++ b/worker/include/RTC/DtlsTransport.hpp @@ -3,7 +3,7 @@ #include "common.hpp" #include "RTC/SrtpSession.hpp" -#include "handles/Timer.hpp" +#include "handles/TimerHandle.hpp" #include #include #include @@ -13,7 +13,7 @@ namespace RTC { - class DtlsTransport : public Timer::Listener + class DtlsTransport : public TimerHandle::Listener { public: enum class DtlsState @@ -204,9 +204,9 @@ namespace RTC public: void OnSslInfo(int where, int ret); - /* Pure virtual methods inherited from Timer::Listener. */ + /* Pure virtual methods inherited from TimerHandle::Listener. */ public: - void OnTimer(Timer* timer) override; + void OnTimer(TimerHandle* timer) override; private: // Passed by argument. @@ -215,7 +215,7 @@ namespace RTC SSL* ssl{ nullptr }; BIO* sslBioFromNetwork{ nullptr }; // The BIO from which ssl reads. BIO* sslBioToNetwork{ nullptr }; // The BIO in which ssl writes. - Timer* timer{ nullptr }; + TimerHandle* timer{ nullptr }; // Others. DtlsState state{ DtlsState::NEW }; Role localRole{ Role::NONE }; diff --git a/worker/include/RTC/KeyFrameRequestManager.hpp b/worker/include/RTC/KeyFrameRequestManager.hpp index d3d52c6b34..e56482c2a6 100644 --- a/worker/include/RTC/KeyFrameRequestManager.hpp +++ b/worker/include/RTC/KeyFrameRequestManager.hpp @@ -1,12 +1,12 @@ #ifndef MS_KEY_FRAME_REQUEST_MANAGER_HPP #define MS_KEY_FRAME_REQUEST_MANAGER_HPP -#include "handles/Timer.hpp" +#include "handles/TimerHandle.hpp" #include namespace RTC { - class PendingKeyFrameInfo : public Timer::Listener + class PendingKeyFrameInfo : public TimerHandle::Listener { public: class Listener @@ -39,18 +39,18 @@ namespace RTC return this->timer->Restart(); } - /* Pure virtual methods inherited from Timer::Listener. */ + /* Pure virtual methods inherited from TimerHandle::Listener. */ public: - void OnTimer(Timer* timer) override; + void OnTimer(TimerHandle* timer) override; private: Listener* listener{ nullptr }; uint32_t ssrc; - Timer* timer{ nullptr }; + TimerHandle* timer{ nullptr }; bool retryOnTimeout{ true }; }; - class KeyFrameRequestDelayer : public Timer::Listener + class KeyFrameRequestDelayer : public TimerHandle::Listener { public: class Listener @@ -79,14 +79,14 @@ namespace RTC this->keyFrameRequested = flag; } - /* Pure virtual methods inherited from Timer::Listener. */ + /* Pure virtual methods inherited from TimerHandle::Listener. */ public: - void OnTimer(Timer* timer) override; + void OnTimer(TimerHandle* timer) override; private: Listener* listener{ nullptr }; uint32_t ssrc; - Timer* timer{ nullptr }; + TimerHandle* timer{ nullptr }; bool keyFrameRequested{ false }; }; diff --git a/worker/include/RTC/NackGenerator.hpp b/worker/include/RTC/NackGenerator.hpp index f7924f6bd0..3195267729 100644 --- a/worker/include/RTC/NackGenerator.hpp +++ b/worker/include/RTC/NackGenerator.hpp @@ -4,7 +4,7 @@ #include "common.hpp" #include "RTC/RtpPacket.hpp" #include "RTC/SeqManager.hpp" -#include "handles/Timer.hpp" +#include "handles/TimerHandle.hpp" #include #include #include @@ -13,7 +13,7 @@ namespace RTC { - class NackGenerator : public Timer::Listener + class NackGenerator : public TimerHandle::Listener { public: class Listener @@ -69,16 +69,16 @@ namespace RTC std::vector GetNackBatch(NackFilter filter); void MayRunTimer() const; - /* Pure virtual methods inherited from Timer::Listener. */ + /* Pure virtual methods inherited from TimerHandle::Listener. */ public: - void OnTimer(Timer* timer) override; + void OnTimer(TimerHandle* timer) override; private: // Passed by argument. Listener* listener{ nullptr }; unsigned int sendNackDelayMs{ 0u }; // Allocated by this. - Timer* timer{ nullptr }; + TimerHandle* timer{ nullptr }; // Others. absl::btree_map::SeqLowerThan> nackList; absl::btree_set::SeqLowerThan> keyFrameList; diff --git a/worker/include/RTC/PipeTransport.hpp b/worker/include/RTC/PipeTransport.hpp index f8560f714f..07ccbc10d5 100644 --- a/worker/include/RTC/PipeTransport.hpp +++ b/worker/include/RTC/PipeTransport.hpp @@ -12,13 +12,6 @@ namespace RTC { class PipeTransport : public RTC::Transport, public RTC::UdpSocket::Listener { - private: - struct ListenIp - { - std::string ip; - std::string announcedIp; - }; - private: static RTC::SrtpSession::CryptoSuite srtpCryptoSuite; static std::string srtpCryptoSuiteString; @@ -81,7 +74,7 @@ namespace RTC RTC::SrtpSession* srtpRecvSession{ nullptr }; RTC::SrtpSession* srtpSendSession{ nullptr }; // Others. - ListenIp listenIp; + ListenInfo listenInfo; struct sockaddr_storage remoteAddrStorage; bool rtx{ false }; std::string srtpKey; diff --git a/worker/include/RTC/PlainTransport.hpp b/worker/include/RTC/PlainTransport.hpp index f16efdea68..0e08d5e302 100644 --- a/worker/include/RTC/PlainTransport.hpp +++ b/worker/include/RTC/PlainTransport.hpp @@ -13,13 +13,6 @@ namespace RTC { class PlainTransport : public RTC::Transport, public RTC::UdpSocket::Listener { - private: - struct ListenIp - { - std::string ip; - std::string announcedIp; - }; - private: static absl::flat_hash_map string2SrtpCryptoSuite; static absl::flat_hash_map srtpCryptoSuite2String; @@ -83,7 +76,7 @@ namespace RTC RTC::SrtpSession* srtpRecvSession{ nullptr }; RTC::SrtpSession* srtpSendSession{ nullptr }; // Others. - ListenIp listenIp; + ListenInfo listenInfo; bool rtcpMux{ true }; bool comedia{ false }; struct sockaddr_storage remoteAddrStorage; diff --git a/worker/include/RTC/RtpStreamRecv.hpp b/worker/include/RTC/RtpStreamRecv.hpp index a4d538ed59..833d6b2109 100644 --- a/worker/include/RTC/RtpStreamRecv.hpp +++ b/worker/include/RTC/RtpStreamRecv.hpp @@ -5,14 +5,14 @@ #include "RTC/RTCP/XrDelaySinceLastRr.hpp" #include "RTC/RateCalculator.hpp" #include "RTC/RtpStream.hpp" -#include "handles/Timer.hpp" +#include "handles/TimerHandle.hpp" #include namespace RTC { class RtpStreamRecv : public RTC::RtpStream, public RTC::NackGenerator::Listener, - public Timer::Listener + public TimerHandle::Listener { public: class Listener : public RTC::RtpStream::Listener @@ -86,9 +86,9 @@ namespace RTC public: void UserOnSequenceNumberReset() override; - /* Pure virtual methods inherited from Timer. */ + /* Pure virtual methods inherited from TimerHandle. */ protected: - void OnTimer(Timer* timer) override; + void OnTimer(TimerHandle* timer) override; /* Pure virtual methods inherited from RTC::NackGenerator. */ protected: @@ -119,7 +119,7 @@ namespace RTC uint8_t firSeqNumber{ 0u }; uint32_t reportedPacketLost{ 0u }; std::unique_ptr nackGenerator; - Timer* inactivityCheckPeriodicTimer{ nullptr }; + TimerHandle* inactivityCheckPeriodicTimer{ nullptr }; bool inactive{ false }; // Valid media + valid RTX. TransmissionCounter transmissionCounter; diff --git a/worker/include/RTC/TcpConnection.hpp b/worker/include/RTC/TcpConnection.hpp index 0aa17ebb62..27d5aaa786 100644 --- a/worker/include/RTC/TcpConnection.hpp +++ b/worker/include/RTC/TcpConnection.hpp @@ -2,11 +2,11 @@ #define MS_RTC_TCP_CONNECTION_HPP #include "common.hpp" -#include "handles/TcpConnectionHandler.hpp" +#include "handles/TcpConnectionHandle.hpp" namespace RTC { - class TcpConnection : public ::TcpConnectionHandler + class TcpConnection : public ::TcpConnectionHandle { public: class Listener @@ -24,9 +24,9 @@ namespace RTC ~TcpConnection() override; public: - void Send(const uint8_t* data, size_t len, ::TcpConnectionHandler::onSendCallback* cb); + void Send(const uint8_t* data, size_t len, ::TcpConnectionHandle::onSendCallback* cb); - /* Pure virtual methods inherited from ::TcpConnectionHandler. */ + /* Pure virtual methods inherited from ::TcpConnectionHandle. */ public: void UserOnTcpConnectionRead() override; diff --git a/worker/include/RTC/TcpServer.hpp b/worker/include/RTC/TcpServer.hpp index 859785cce5..89e03ca6b8 100644 --- a/worker/include/RTC/TcpServer.hpp +++ b/worker/include/RTC/TcpServer.hpp @@ -3,13 +3,13 @@ #include "common.hpp" #include "RTC/TcpConnection.hpp" -#include "handles/TcpConnectionHandler.hpp" -#include "handles/TcpServerHandler.hpp" +#include "handles/TcpConnectionHandle.hpp" +#include "handles/TcpServerHandle.hpp" #include namespace RTC { - class TcpServer : public ::TcpServerHandler + class TcpServer : public ::TcpServerHandle { public: class Listener @@ -28,10 +28,10 @@ namespace RTC Listener* listener, RTC::TcpConnection::Listener* connListener, std::string& ip, uint16_t port); ~TcpServer() override; - /* Pure virtual methods inherited from ::TcpServerHandler. */ + /* Pure virtual methods inherited from ::TcpServerHandle. */ public: void UserOnTcpConnectionAlloc() override; - void UserOnTcpConnectionClosed(::TcpConnectionHandler* connection) override; + void UserOnTcpConnectionClosed(::TcpConnectionHandle* connection) override; private: // Passed by argument. diff --git a/worker/include/RTC/Transport.hpp b/worker/include/RTC/Transport.hpp index 0890f2fbde..957fff6f2e 100644 --- a/worker/include/RTC/Transport.hpp +++ b/worker/include/RTC/Transport.hpp @@ -27,7 +27,7 @@ #endif #include "RTC/TransportCongestionControlClient.hpp" #include "RTC/TransportCongestionControlServer.hpp" -#include "handles/Timer.hpp" +#include "handles/TimerHandle.hpp" #include #include @@ -45,7 +45,7 @@ namespace RTC #ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR public RTC::SenderBandwidthEstimator::Listener, #endif - public Timer::Listener + public TimerHandle::Listener { protected: using onSendCallback = const std::function; @@ -108,6 +108,16 @@ namespace RTC virtual void OnTransportListenServerClosed(RTC::Transport* transport) = 0; }; + public: + struct ListenInfo + { + std::string ip; + std::string announcedIp; + uint16_t port{ 0u }; + uint32_t sendBufferSize{ 0u }; + uint32_t recvBufferSize{ 0u }; + }; + private: struct TraceEventTypes { @@ -277,9 +287,9 @@ namespace RTC uint32_t previousAvailableBitrate) override; #endif - /* Pure virtual methods inherited from Timer::Listener. */ + /* Pure virtual methods inherited from TimerHandle::Listener. */ public: - void OnTimer(Timer* timer) override; + void OnTimer(TimerHandle* timer) override; public: // Passed by argument. @@ -301,7 +311,7 @@ namespace RTC absl::flat_hash_map mapDataConsumers; absl::flat_hash_map mapSsrcConsumer; absl::flat_hash_map mapRtxSsrcConsumer; - Timer* rtcpTimer{ nullptr }; + TimerHandle* rtcpTimer{ nullptr }; std::shared_ptr tccClient{ nullptr }; std::shared_ptr tccServer{ nullptr }; #ifdef ENABLE_RTC_SENDER_BANDWIDTH_ESTIMATOR diff --git a/worker/include/RTC/TransportCongestionControlClient.hpp b/worker/include/RTC/TransportCongestionControlClient.hpp index dd58ed943c..1c2fb61f6c 100644 --- a/worker/include/RTC/TransportCongestionControlClient.hpp +++ b/worker/include/RTC/TransportCongestionControlClient.hpp @@ -8,7 +8,7 @@ #include "RTC/RtpPacket.hpp" #include "RTC/RtpProbationGenerator.hpp" #include "RTC/TrendCalculator.hpp" -#include "handles/Timer.hpp" +#include "handles/TimerHandle.hpp" #include #include #include @@ -21,7 +21,7 @@ namespace RTC class TransportCongestionControlClient : public webrtc::PacketRouter, public webrtc::TargetTransferRateObserver, - public Timer::Listener + public TimerHandle::Listener { public: struct Bitrates @@ -104,9 +104,9 @@ namespace RTC void SendPacket(RTC::RtpPacket* packet, const webrtc::PacedPacketInfo& pacingInfo) override; RTC::RtpPacket* GeneratePadding(size_t size) override; - /* Pure virtual methods inherited from RTC::Timer. */ + /* Pure virtual methods inherited from RTC::TimerHandle. */ public: - void OnTimer(Timer* timer) override; + void OnTimer(TimerHandle* timer) override; private: // Passed by argument. @@ -115,7 +115,7 @@ namespace RTC webrtc::NetworkControllerFactoryInterface* controllerFactory{ nullptr }; webrtc::RtpTransportControllerSend* rtpTransportControllerSend{ nullptr }; RTC::RtpProbationGenerator* probationGenerator{ nullptr }; - Timer* processTimer{ nullptr }; + TimerHandle* processTimer{ nullptr }; // Others. RTC::BweType bweType; uint32_t initialAvailableBitrate{ 0u }; diff --git a/worker/include/RTC/TransportCongestionControlServer.hpp b/worker/include/RTC/TransportCongestionControlServer.hpp index 5747d13d03..ae1e307707 100644 --- a/worker/include/RTC/TransportCongestionControlServer.hpp +++ b/worker/include/RTC/TransportCongestionControlServer.hpp @@ -6,14 +6,14 @@ #include "RTC/RTCP/FeedbackRtpTransport.hpp" #include "RTC/RTCP/Packet.hpp" #include "RTC/RtpPacket.hpp" -#include "handles/Timer.hpp" +#include "handles/TimerHandle.hpp" #include #include namespace RTC { class TransportCongestionControlServer : public webrtc::RemoteBitrateEstimator::Listener, - public Timer::Listener + public TimerHandle::Listener { public: class Listener @@ -67,15 +67,15 @@ namespace RTC const std::vector& ssrcs, uint32_t availableBitrate) override; - /* Pure virtual methods inherited from Timer::Listener. */ + /* Pure virtual methods inherited from TimerHandle::Listener. */ public: - void OnTimer(Timer* timer) override; + void OnTimer(TimerHandle* timer) override; private: // Passed by argument. Listener* listener{ nullptr }; // Allocated by this. - Timer* transportCcFeedbackSendPeriodicTimer{ nullptr }; + TimerHandle* transportCcFeedbackSendPeriodicTimer{ nullptr }; std::unique_ptr transportCcFeedbackPacket; webrtc::RemoteBitrateEstimatorAbsSendTime* rembServer{ nullptr }; // Others. diff --git a/worker/include/RTC/UdpSocket.hpp b/worker/include/RTC/UdpSocket.hpp index 070209f734..46e90f3edd 100644 --- a/worker/include/RTC/UdpSocket.hpp +++ b/worker/include/RTC/UdpSocket.hpp @@ -2,12 +2,12 @@ #define MS_RTC_UDP_SOCKET_HPP #include "common.hpp" -#include "handles/UdpSocketHandler.hpp" +#include "handles/UdpSocketHandle.hpp" #include namespace RTC { - class UdpSocket : public ::UdpSocketHandler + class UdpSocket : public ::UdpSocketHandle { public: class Listener @@ -25,7 +25,7 @@ namespace RTC UdpSocket(Listener* listener, std::string& ip, uint16_t port); ~UdpSocket() override; - /* Pure virtual methods inherited from ::UdpSocketHandler. */ + /* Pure virtual methods inherited from ::UdpSocketHandle. */ public: void UserOnUdpDatagramReceived(const uint8_t* data, size_t len, const struct sockaddr* addr) override; diff --git a/worker/include/RTC/WebRtcServer.hpp b/worker/include/RTC/WebRtcServer.hpp index c48dd44830..d14b240b4e 100644 --- a/worker/include/RTC/WebRtcServer.hpp +++ b/worker/include/RTC/WebRtcServer.hpp @@ -42,14 +42,13 @@ namespace RTC WebRtcServer( RTC::Shared* shared, const std::string& id, - const flatbuffers::Vector>* listenInfos); + const flatbuffers::Vector>* listenInfos); ~WebRtcServer(); public: flatbuffers::Offset FillBuffer( flatbuffers::FlatBufferBuilder& builder) const; - std::vector GetIceCandidates( - bool enableUdp, bool enableTcp, bool preferUdp, bool preferTcp); + const std::vector& GetIceCandidates() const; /* Methods inherited from Channel::ChannelSocket::RequestHandler. */ public: @@ -103,6 +102,8 @@ namespace RTC absl::flat_hash_map mapLocalIceUsernameFragmentWebRtcTransport; // Map of WebRtcTransports indexed by TransportTuple.hash. absl::flat_hash_map mapTupleWebRtcTransport; + // ICE candidates. + std::vector iceCandidates; }; } // namespace RTC diff --git a/worker/include/RTC/WebRtcTransport.hpp b/worker/include/RTC/WebRtcTransport.hpp index a1d90e3572..2687c4c2d6 100644 --- a/worker/include/RTC/WebRtcTransport.hpp +++ b/worker/include/RTC/WebRtcTransport.hpp @@ -23,13 +23,6 @@ namespace RTC public RTC::IceServer::Listener, public RTC::DtlsTransport::Listener { - private: - struct ListenIp - { - std::string ip; - std::string announcedIp; - }; - public: class WebRtcTransportListener { @@ -60,7 +53,7 @@ namespace RTC const std::string& id, RTC::Transport::Listener* listener, WebRtcTransportListener* webRtcTransportListener, - std::vector& iceCandidates, + const std::vector& iceCandidates, const FBS::WebRtcTransport::WebRtcTransportOptions* options); ~WebRtcTransport() override; @@ -167,7 +160,8 @@ namespace RTC RTC::SrtpSession* srtpRecvSession{ nullptr }; RTC::SrtpSession* srtpSendSession{ nullptr }; // Others. - bool connectCalled{ false }; // Whether connect() was succesfully called. + // Whether connect() was succesfully called. + bool connectCalled{ false }; std::vector iceCandidates; RTC::DtlsTransport::Role dtlsRole{ RTC::DtlsTransport::Role::AUTO }; }; diff --git a/worker/include/Worker.hpp b/worker/include/Worker.hpp index 76579fcfed..90f75bf600 100644 --- a/worker/include/Worker.hpp +++ b/worker/include/Worker.hpp @@ -8,13 +8,13 @@ #include "RTC/Router.hpp" #include "RTC/Shared.hpp" #include "RTC/WebRtcServer.hpp" -#include "handles/SignalsHandler.hpp" +#include "handles/SignalHandle.hpp" #include #include #include class Worker : public Channel::ChannelSocket::Listener, - public SignalsHandler::Listener, + public SignalHandle::Listener, public RTC::Router::Listener { public: @@ -41,9 +41,9 @@ class Worker : public Channel::ChannelSocket::Listener, public: void OnChannelClosed(Channel::ChannelSocket* channel) override; - /* Methods inherited from SignalsHandler::Listener. */ + /* Methods inherited from SignalHandle::Listener. */ public: - void OnSignal(SignalsHandler* signalsHandler, int signum) override; + void OnSignal(SignalHandle* signalsHandler, int signum) override; /* Pure virtual methods inherited from RTC::Router::Listener. */ public: @@ -53,7 +53,7 @@ class Worker : public Channel::ChannelSocket::Listener, // Passed by argument. Channel::ChannelSocket* channel{ nullptr }; // Allocated by this. - SignalsHandler* signalsHandler{ nullptr }; + SignalHandle* signalHandle{ nullptr }; RTC::Shared* shared{ nullptr }; absl::flat_hash_map mapWebRtcServers; absl::flat_hash_map mapRouters; diff --git a/worker/include/handles/SignalsHandler.hpp b/worker/include/handles/SignalHandle.hpp similarity index 68% rename from worker/include/handles/SignalsHandler.hpp rename to worker/include/handles/SignalHandle.hpp index 7c9407b7d4..ff32054389 100644 --- a/worker/include/handles/SignalsHandler.hpp +++ b/worker/include/handles/SignalHandle.hpp @@ -1,11 +1,11 @@ -#ifndef MS_SIGNALS_HANDLER_HPP -#define MS_SIGNALS_HANDLER_HPP +#ifndef MS_SIGNAL_HANDLE_HPP +#define MS_SIGNAL_HANDLE_HPP #include #include #include -class SignalsHandler +class SignalHandle { public: class Listener @@ -14,12 +14,12 @@ class SignalsHandler virtual ~Listener() = default; public: - virtual void OnSignal(SignalsHandler* signalsHandler, int signum) = 0; + virtual void OnSignal(SignalHandle* signalsHandler, int signum) = 0; }; public: - explicit SignalsHandler(Listener* listener); - ~SignalsHandler(); + explicit SignalHandle(Listener* listener); + ~SignalHandle(); public: void Close(); diff --git a/worker/include/handles/TcpConnectionHandler.hpp b/worker/include/handles/TcpConnectionHandle.hpp similarity index 85% rename from worker/include/handles/TcpConnectionHandler.hpp rename to worker/include/handles/TcpConnectionHandle.hpp index 0b536225ba..fd5b8c291d 100644 --- a/worker/include/handles/TcpConnectionHandler.hpp +++ b/worker/include/handles/TcpConnectionHandle.hpp @@ -1,11 +1,11 @@ -#ifndef MS_TCP_CONNECTION_HPP -#define MS_TCP_CONNECTION_HPP +#ifndef MS_TCP_CONNECTION_HANDLE_HPP +#define MS_TCP_CONNECTION_HANDLE_HPP #include "common.hpp" #include #include -class TcpConnectionHandler +class TcpConnectionHandle { protected: using onSendCallback = const std::function; @@ -17,7 +17,7 @@ class TcpConnectionHandler virtual ~Listener() = default; public: - virtual void OnTcpConnectionClosed(TcpConnectionHandler* connection) = 0; + virtual void OnTcpConnectionClosed(TcpConnectionHandle* connection) = 0; }; public: @@ -40,14 +40,14 @@ class TcpConnectionHandler uv_write_t req; uint8_t* store{ nullptr }; - TcpConnectionHandler::onSendCallback* cb{ nullptr }; + TcpConnectionHandle::onSendCallback* cb{ nullptr }; }; public: - explicit TcpConnectionHandler(size_t bufferSize); - TcpConnectionHandler& operator=(const TcpConnectionHandler&) = delete; - TcpConnectionHandler(const TcpConnectionHandler&) = delete; - virtual ~TcpConnectionHandler(); + explicit TcpConnectionHandle(size_t bufferSize); + TcpConnectionHandle& operator=(const TcpConnectionHandle&) = delete; + TcpConnectionHandle(const TcpConnectionHandle&) = delete; + virtual ~TcpConnectionHandle(); public: void Close(); @@ -71,7 +71,7 @@ class TcpConnectionHandler size_t len1, const uint8_t* data2, size_t len2, - TcpConnectionHandler::onSendCallback* cb); + TcpConnectionHandle::onSendCallback* cb); void ErrorReceiving(); const struct sockaddr* GetLocalAddress() const { diff --git a/worker/include/handles/TcpServerHandler.hpp b/worker/include/handles/TcpServerHandle.hpp similarity index 61% rename from worker/include/handles/TcpServerHandler.hpp rename to worker/include/handles/TcpServerHandle.hpp index ad7b52e8aa..3d7608d88d 100644 --- a/worker/include/handles/TcpServerHandler.hpp +++ b/worker/include/handles/TcpServerHandle.hpp @@ -1,20 +1,20 @@ -#ifndef MS_TCP_SERVER_HPP -#define MS_TCP_SERVER_HPP +#ifndef MS_TCP_SERVER_HANDLE_HPP +#define MS_TCP_SERVER_HANDLE_HPP #include "common.hpp" -#include "handles/TcpConnectionHandler.hpp" +#include "handles/TcpConnectionHandle.hpp" #include #include #include -class TcpServerHandler : public TcpConnectionHandler::Listener +class TcpServerHandle : public TcpConnectionHandle::Listener { public: /** * uvHandle must be an already initialized and binded uv_tcp_t pointer. */ - TcpServerHandler(uv_tcp_t* uvHandle); - virtual ~TcpServerHandler() override; + TcpServerHandle(uv_tcp_t* uvHandle); + virtual ~TcpServerHandle() override; public: void Close(); @@ -39,25 +39,29 @@ class TcpServerHandler : public TcpConnectionHandler::Listener { return this->connections.size(); } + uint32_t GetSendBufferSize() const; + void SetSendBufferSize(uint32_t size); + uint32_t GetRecvBufferSize() const; + void SetRecvBufferSize(uint32_t size); protected: - void AcceptTcpConnection(TcpConnectionHandler* connection); + void AcceptTcpConnection(TcpConnectionHandle* connection); private: bool SetLocalAddress(); /* Pure virtual methods that must be implemented by the subclass. */ protected: - virtual void UserOnTcpConnectionAlloc() = 0; - virtual void UserOnTcpConnectionClosed(TcpConnectionHandler* connection) = 0; + virtual void UserOnTcpConnectionAlloc() = 0; + virtual void UserOnTcpConnectionClosed(TcpConnectionHandle* connection) = 0; /* Callbacks fired by UV events. */ public: void OnUvConnection(int status); - /* Methods inherited from TcpConnectionHandler::Listener. */ + /* Methods inherited from TcpConnectionHandle::Listener. */ public: - void OnTcpConnectionClosed(TcpConnectionHandler* connection) override; + void OnTcpConnectionClosed(TcpConnectionHandle* connection) override; protected: struct sockaddr_storage localAddr; @@ -68,7 +72,7 @@ class TcpServerHandler : public TcpConnectionHandler::Listener // Allocated by this (may be passed by argument). uv_tcp_t* uvHandle{ nullptr }; // Others. - absl::flat_hash_set connections; + absl::flat_hash_set connections; bool closed{ false }; }; diff --git a/worker/include/handles/Timer.hpp b/worker/include/handles/TimerHandle.hpp similarity index 72% rename from worker/include/handles/Timer.hpp rename to worker/include/handles/TimerHandle.hpp index dfb9c47ee7..09ea83b5a8 100644 --- a/worker/include/handles/Timer.hpp +++ b/worker/include/handles/TimerHandle.hpp @@ -1,10 +1,10 @@ -#ifndef MS_TIMER_HPP -#define MS_TIMER_HPP +#ifndef MS_TIMER_HANDLE_HPP +#define MS_TIMER_HANDLE_HPP #include "common.hpp" #include -class Timer +class TimerHandle { public: class Listener @@ -13,14 +13,14 @@ class Timer virtual ~Listener() = default; public: - virtual void OnTimer(Timer* timer) = 0; + virtual void OnTimer(TimerHandle* timer) = 0; }; public: - explicit Timer(Listener* listener); - Timer& operator=(const Timer&) = delete; - Timer(const Timer&) = delete; - ~Timer(); + explicit TimerHandle(Listener* listener); + TimerHandle& operator=(const TimerHandle&) = delete; + TimerHandle(const TimerHandle&) = delete; + ~TimerHandle(); public: void Close(); diff --git a/worker/include/handles/UdpSocketHandler.hpp b/worker/include/handles/UdpSocketHandle.hpp similarity index 77% rename from worker/include/handles/UdpSocketHandler.hpp rename to worker/include/handles/UdpSocketHandle.hpp index 188f23b4fa..486ed5bebf 100644 --- a/worker/include/handles/UdpSocketHandler.hpp +++ b/worker/include/handles/UdpSocketHandle.hpp @@ -1,11 +1,11 @@ -#ifndef MS_UDP_SOCKET_HPP -#define MS_UDP_SOCKET_HPP +#ifndef MS_UDP_SOCKET_HANDLE_HPP +#define MS_UDP_SOCKET_HANDLE_HPP #include "common.hpp" #include #include -class UdpSocketHandler +class UdpSocketHandle { protected: using onSendCallback = const std::function; @@ -30,17 +30,17 @@ class UdpSocketHandler uv_udp_send_t req; uint8_t* store{ nullptr }; - UdpSocketHandler::onSendCallback* cb{ nullptr }; + UdpSocketHandle::onSendCallback* cb{ nullptr }; }; public: /** * uvHandle must be an already initialized and binded uv_udp_t pointer. */ - explicit UdpSocketHandler(uv_udp_t* uvHandle); - UdpSocketHandler& operator=(const UdpSocketHandler&) = delete; - UdpSocketHandler(const UdpSocketHandler&) = delete; - virtual ~UdpSocketHandler(); + explicit UdpSocketHandle(uv_udp_t* uvHandle); + UdpSocketHandle& operator=(const UdpSocketHandle&) = delete; + UdpSocketHandle(const UdpSocketHandle&) = delete; + virtual ~UdpSocketHandle(); public: void Close(); @@ -50,7 +50,7 @@ class UdpSocketHandler } virtual void Dump() const; void Send( - const uint8_t* data, size_t len, const struct sockaddr* addr, UdpSocketHandler::onSendCallback* cb); + const uint8_t* data, size_t len, const struct sockaddr* addr, UdpSocketHandle::onSendCallback* cb); const struct sockaddr* GetLocalAddress() const { return reinterpret_cast(&this->localAddr); @@ -75,6 +75,10 @@ class UdpSocketHandler { return this->sentBytes; } + uint32_t GetSendBufferSize() const; + void SetSendBufferSize(uint32_t size); + uint32_t GetRecvBufferSize() const; + void SetRecvBufferSize(uint32_t size); private: bool SetLocalAddress(); @@ -83,7 +87,7 @@ class UdpSocketHandler public: void OnUvRecvAlloc(size_t suggestedSize, uv_buf_t* buf); void OnUvRecv(ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags); - void OnUvSend(int status, UdpSocketHandler::onSendCallback* cb); + void OnUvSend(int status, UdpSocketHandle::onSendCallback* cb); /* Pure virtual methods that must be implemented by the subclass. */ protected: diff --git a/worker/include/handles/UnixStreamSocket.hpp b/worker/include/handles/UnixStreamSocketHandle.hpp similarity index 70% rename from worker/include/handles/UnixStreamSocket.hpp rename to worker/include/handles/UnixStreamSocketHandle.hpp index 5d3f05764e..164ab02ec6 100644 --- a/worker/include/handles/UnixStreamSocket.hpp +++ b/worker/include/handles/UnixStreamSocketHandle.hpp @@ -1,11 +1,11 @@ -#ifndef MS_UNIX_STREAM_SOCKET_HPP -#define MS_UNIX_STREAM_SOCKET_HPP +#ifndef MS_UNIX_STREAM_SOCKET_HANDLE_HPP +#define MS_UNIX_STREAM_SOCKET_HANDLE_HPP #include "common.hpp" #include #include -class UnixStreamSocket +class UnixStreamSocketHandle { public: /* Struct for the data field of uv_req_t when writing data. */ @@ -35,10 +35,10 @@ class UnixStreamSocket }; public: - UnixStreamSocket(int fd, size_t bufferSize, UnixStreamSocket::Role role); - UnixStreamSocket& operator=(const UnixStreamSocket&) = delete; - UnixStreamSocket(const UnixStreamSocket&) = delete; - virtual ~UnixStreamSocket(); + UnixStreamSocketHandle(int fd, size_t bufferSize, UnixStreamSocketHandle::Role role); + UnixStreamSocketHandle& operator=(const UnixStreamSocketHandle&) = delete; + UnixStreamSocketHandle(const UnixStreamSocketHandle&) = delete; + virtual ~UnixStreamSocketHandle(); public: void Close(); @@ -47,6 +47,10 @@ class UnixStreamSocket return this->closed; } void Write(const uint8_t* data, size_t len); + uint32_t GetSendBufferSize() const; + void SetSendBufferSize(uint32_t size); + uint32_t GetRecvBufferSize() const; + void SetRecvBufferSize(uint32_t size); /* Callbacks fired by UV events. */ public: @@ -70,7 +74,7 @@ class UnixStreamSocket protected: // Passed by argument. size_t bufferSize{ 0u }; - UnixStreamSocket::Role role; + UnixStreamSocketHandle::Role role; // Allocated by this. uint8_t* buffer{ nullptr }; // Others. diff --git a/worker/meson.build b/worker/meson.build index 464ff19963..fe14262540 100644 --- a/worker/meson.build +++ b/worker/meson.build @@ -60,12 +60,12 @@ common_sources = [ 'src/Utils/File.cpp', 'src/Utils/IP.cpp', 'src/Utils/String.cpp', - 'src/handles/SignalsHandler.cpp', - 'src/handles/TcpConnectionHandler.cpp', - 'src/handles/TcpServerHandler.cpp', - 'src/handles/Timer.cpp', - 'src/handles/UdpSocketHandler.cpp', - 'src/handles/UnixStreamSocket.cpp', + 'src/handles/SignalHandle.cpp', + 'src/handles/TcpConnectionHandle.cpp', + 'src/handles/TcpServerHandle.cpp', + 'src/handles/TimerHandle.cpp', + 'src/handles/UdpSocketHandle.cpp', + 'src/handles/UnixStreamSocketHandle.cpp', 'src/Channel/ChannelNotifier.cpp', 'src/Channel/ChannelRequest.cpp', 'src/Channel/ChannelNotification.cpp', diff --git a/worker/src/Channel/ChannelSocket.cpp b/worker/src/Channel/ChannelSocket.cpp index 08261a1e5b..4b14ce6757 100644 --- a/worker/src/Channel/ChannelSocket.cpp +++ b/worker/src/Channel/ChannelSocket.cpp @@ -318,7 +318,8 @@ namespace Channel /* Instance methods. */ ConsumerSocket::ConsumerSocket(int fd, size_t bufferSize, Listener* listener) - : ::UnixStreamSocket(fd, bufferSize, ::UnixStreamSocket::Role::CONSUMER), listener(listener) + : ::UnixStreamSocketHandle(fd, bufferSize, ::UnixStreamSocketHandle::Role::CONSUMER), + listener(listener) { MS_TRACE_STD(); } @@ -388,7 +389,7 @@ namespace Channel /* Instance methods. */ ProducerSocket::ProducerSocket(int fd, size_t bufferSize) - : ::UnixStreamSocket(fd, bufferSize, ::UnixStreamSocket::Role::PRODUCER) + : ::UnixStreamSocketHandle(fd, bufferSize, ::UnixStreamSocketHandle::Role::PRODUCER) { MS_TRACE_STD(); } diff --git a/worker/src/DepUsrSCTP.cpp b/worker/src/DepUsrSCTP.cpp index 0a969de927..57b0a3cd51 100644 --- a/worker/src/DepUsrSCTP.cpp +++ b/worker/src/DepUsrSCTP.cpp @@ -200,7 +200,7 @@ DepUsrSCTP::Checker::Checker() { MS_TRACE(); - this->timer = new Timer(this); + this->timer = new TimerHandle(this); } DepUsrSCTP::Checker::~Checker() @@ -232,7 +232,7 @@ void DepUsrSCTP::Checker::Stop() this->timer->Stop(); } -void DepUsrSCTP::Checker::OnTimer(Timer* /*timer*/) +void DepUsrSCTP::Checker::OnTimer(TimerHandle* /*timer*/) { MS_TRACE(); diff --git a/worker/src/RTC/ActiveSpeakerObserver.cpp b/worker/src/RTC/ActiveSpeakerObserver.cpp index 7375c7be9c..be92f59f44 100644 --- a/worker/src/RTC/ActiveSpeakerObserver.cpp +++ b/worker/src/RTC/ActiveSpeakerObserver.cpp @@ -110,7 +110,7 @@ namespace RTC else if (this->interval > 5000) this->interval = 5000; - this->periodicTimer = new Timer(this); + this->periodicTimer = new TimerHandle(this); this->periodicTimer->Start(interval, interval); @@ -245,7 +245,7 @@ namespace RTC this->periodicTimer->Restart(); } - void ActiveSpeakerObserver::OnTimer(Timer* timer) + void ActiveSpeakerObserver::OnTimer(TimerHandle* timer) { MS_TRACE(); diff --git a/worker/src/RTC/AudioLevelObserver.cpp b/worker/src/RTC/AudioLevelObserver.cpp index 1de513774e..d59f6b289e 100644 --- a/worker/src/RTC/AudioLevelObserver.cpp +++ b/worker/src/RTC/AudioLevelObserver.cpp @@ -34,7 +34,7 @@ namespace RTC else if (this->interval > 5000) this->interval = 5000; - this->periodicTimer = new Timer(this); + this->periodicTimer = new TimerHandle(this); this->periodicTimer->Start(this->interval, this->interval); @@ -201,7 +201,7 @@ namespace RTC } } - inline void AudioLevelObserver::OnTimer(Timer* /*timer*/) + inline void AudioLevelObserver::OnTimer(TimerHandle* /*timer*/) { MS_TRACE(); diff --git a/worker/src/RTC/DtlsTransport.cpp b/worker/src/RTC/DtlsTransport.cpp index d639f64767..51413f0238 100644 --- a/worker/src/RTC/DtlsTransport.cpp +++ b/worker/src/RTC/DtlsTransport.cpp @@ -548,7 +548,7 @@ namespace RTC DTLS_set_timer_cb(this->ssl, onSslDtlsTimer); // Set the DTLS timer. - this->timer = new Timer(this); + this->timer = new TimerHandle(this); return; @@ -1409,7 +1409,7 @@ namespace RTC // receipt of a close alert does not work (the flag is set after this callback). } - inline void DtlsTransport::OnTimer(Timer* /*timer*/) + inline void DtlsTransport::OnTimer(TimerHandle* /*timer*/) { MS_TRACE(); diff --git a/worker/src/RTC/KeyFrameRequestManager.cpp b/worker/src/RTC/KeyFrameRequestManager.cpp index aae45b0f70..f3b1e7ed67 100644 --- a/worker/src/RTC/KeyFrameRequestManager.cpp +++ b/worker/src/RTC/KeyFrameRequestManager.cpp @@ -13,7 +13,7 @@ RTC::PendingKeyFrameInfo::PendingKeyFrameInfo(PendingKeyFrameInfo::Listener* lis { MS_TRACE(); - this->timer = new Timer(this); + this->timer = new TimerHandle(this); this->timer->Start(KeyFrameRetransmissionWaitTime); } @@ -25,12 +25,14 @@ RTC::PendingKeyFrameInfo::~PendingKeyFrameInfo() delete this->timer; } -inline void RTC::PendingKeyFrameInfo::OnTimer(Timer* timer) +inline void RTC::PendingKeyFrameInfo::OnTimer(TimerHandle* timer) { MS_TRACE(); if (timer == this->timer) + { this->listener->OnKeyFrameRequestTimeout(this); + } } /* KeyFrameRequestDelayer methods. */ @@ -41,7 +43,7 @@ RTC::KeyFrameRequestDelayer::KeyFrameRequestDelayer( { MS_TRACE(); - this->timer = new Timer(this); + this->timer = new TimerHandle(this); this->timer->Start(delay); } @@ -53,12 +55,14 @@ RTC::KeyFrameRequestDelayer::~KeyFrameRequestDelayer() delete this->timer; } -inline void RTC::KeyFrameRequestDelayer::OnTimer(Timer* timer) +inline void RTC::KeyFrameRequestDelayer::OnTimer(TimerHandle* timer) { MS_TRACE(); if (timer == this->timer) + { this->listener->OnKeyFrameDelayTimeout(this); + } } /* KeyFrameRequestManager methods. */ @@ -185,7 +189,9 @@ void RTC::KeyFrameRequestManager::KeyFrameReceived(uint32_t ssrc) // There is no pending key frame for the given ssrc. if (it == this->mapSsrcPendingKeyFrameInfo.end()) + { return; + } auto* pendingKeyFrameInfo = it->second; diff --git a/worker/src/RTC/NackGenerator.cpp b/worker/src/RTC/NackGenerator.cpp index 289d6dd3df..7eb168df40 100644 --- a/worker/src/RTC/NackGenerator.cpp +++ b/worker/src/RTC/NackGenerator.cpp @@ -26,7 +26,7 @@ namespace RTC MS_TRACE(); // Set the timer. - this->timer = new Timer(this); + this->timer = new TimerHandle(this); } NackGenerator::~NackGenerator() @@ -372,7 +372,7 @@ namespace RTC } } - inline void NackGenerator::OnTimer(Timer* /*timer*/) + inline void NackGenerator::OnTimer(TimerHandle* /*timer*/) { MS_TRACE(); diff --git a/worker/src/RTC/PipeTransport.cpp b/worker/src/RTC/PipeTransport.cpp index 2895d099f9..f7b10cc705 100644 --- a/worker/src/RTC/PipeTransport.cpp +++ b/worker/src/RTC/PipeTransport.cpp @@ -31,13 +31,39 @@ namespace RTC { MS_TRACE(); - this->listenIp.ip.assign(options->listenIp()->ip()->str()); + if (options->listenInfo()->protocol() != FBS::Transport::Protocol::UDP) + { + MS_THROW_TYPE_ERROR("unsupported listen protocol"); + } + + this->listenInfo.ip.assign(options->listenInfo()->ip()->str()); // This may throw. - Utils::IP::NormalizeIp(this->listenIp.ip); + Utils::IP::NormalizeIp(this->listenInfo.ip); + + if (flatbuffers::IsFieldPresent(options->listenInfo(), FBS::Transport::ListenInfo::VT_ANNOUNCEDIP)) + { + this->listenInfo.announcedIp.assign(options->listenInfo()->announcedIp()->str()); + } + + if (flatbuffers::IsFieldPresent(options->listenInfo(), FBS::Transport::ListenInfo::VT_ANNOUNCEDIP)) + { + this->listenInfo.announcedIp.assign(options->listenInfo()->announcedIp()->str()); + } - if (flatbuffers::IsFieldPresent(options->listenIp(), FBS::Transport::ListenIp::VT_ANNOUNCEDIP)) - this->listenIp.announcedIp.assign(options->listenIp()->announcedIp()->str()); + this->listenInfo.port = options->listenInfo()->port(); + + if (flatbuffers::IsFieldPresent( + options->listenInfo(), FBS::Transport::ListenInfo::VT_SENDBUFFERSIZE)) + { + this->listenInfo.sendBufferSize = options->listenInfo()->sendBufferSize(); + } + + if (flatbuffers::IsFieldPresent( + options->listenInfo(), FBS::Transport::ListenInfo::VT_RECVBUFFERSIZE)) + { + this->listenInfo.recvBufferSize = options->listenInfo()->recvBufferSize(); + } this->rtx = options->enableRtx(); @@ -50,10 +76,32 @@ namespace RTC try { // This may throw. - if (options->port() != 0) - this->udpSocket = new RTC::UdpSocket(this, this->listenIp.ip, options->port()); + if (this->listenInfo.port != 0) + { + this->udpSocket = new RTC::UdpSocket(this, this->listenInfo.ip, this->listenInfo.port); + } else - this->udpSocket = new RTC::UdpSocket(this, this->listenIp.ip); + { + this->udpSocket = new RTC::UdpSocket(this, this->listenInfo.ip); + } + + if (this->listenInfo.sendBufferSize != 0) + { + // NOTE: This may throw. + udpSocket->SetSendBufferSize(this->listenInfo.sendBufferSize); + } + + if (this->listenInfo.recvBufferSize != 0) + { + // NOTE: This may throw. + udpSocket->SetRecvBufferSize(this->listenInfo.recvBufferSize); + } + + MS_DEBUG_TAG( + info, + "UDP socket buffer sizes [send:%" PRIu32 ", recv:%" PRIu32 "]", + udpSocket->GetSendBufferSize(), + udpSocket->GetRecvBufferSize()); // NOTE: This may throw. this->shared->channelMessageRegistrator->RegisterHandler( @@ -107,10 +155,14 @@ namespace RTC { std::string localIp; - if (this->listenIp.announcedIp.empty()) + if (this->listenInfo.announcedIp.empty()) + { localIp = this->udpSocket->GetLocalIp(); + } else - localIp = this->listenIp.announcedIp; + { + localIp = this->listenInfo.announcedIp; + } tuple = FBS::Transport::CreateTupleDirect( builder, localIp.c_str(), this->udpSocket->GetLocalPort(), "", 0, "udp"); @@ -147,10 +199,14 @@ namespace RTC { std::string localIp; - if (this->listenIp.announcedIp.empty()) + if (this->listenInfo.announcedIp.empty()) + { localIp = this->udpSocket->GetLocalIp(); + } else - localIp = this->listenIp.announcedIp; + { + localIp = this->listenInfo.announcedIp; + } tuple = FBS::Transport::CreateTupleDirect( builder, @@ -339,8 +395,10 @@ namespace RTC this->tuple = new RTC::TransportTuple( this->udpSocket, reinterpret_cast(&this->remoteAddrStorage)); - if (!this->listenIp.announcedIp.empty()) - this->tuple->SetLocalAnnouncedIp(this->listenIp.announcedIp); + if (!this->listenInfo.announcedIp.empty()) + { + this->tuple->SetLocalAnnouncedIp(this->listenInfo.announcedIp); + } } catch (const MediaSoupError& error) { diff --git a/worker/src/RTC/PlainTransport.cpp b/worker/src/RTC/PlainTransport.cpp index 95e931ede9..aa2dceafb8 100644 --- a/worker/src/RTC/PlainTransport.cpp +++ b/worker/src/RTC/PlainTransport.cpp @@ -53,13 +53,32 @@ namespace RTC { MS_TRACE(); - this->listenIp.ip.assign(options->listenIp()->ip()->str()); + if (options->listenInfo()->protocol() != FBS::Transport::Protocol::UDP) + { + MS_THROW_TYPE_ERROR("unsupported listen protocol"); + } + + this->listenInfo.ip.assign(options->listenInfo()->ip()->str()); // This may throw. - Utils::IP::NormalizeIp(this->listenIp.ip); + Utils::IP::NormalizeIp(this->listenInfo.ip); - if (flatbuffers::IsFieldPresent(options->listenIp(), FBS::Transport::ListenIp::VT_ANNOUNCEDIP)) - this->listenIp.announcedIp.assign(options->listenIp()->announcedIp()->str()); + if (flatbuffers::IsFieldPresent(options->listenInfo(), FBS::Transport::ListenInfo::VT_ANNOUNCEDIP)) + { + this->listenInfo.announcedIp.assign(options->listenInfo()->announcedIp()->str()); + } + + this->listenInfo.port = options->listenInfo()->port(); + + if (flatbuffers::IsFieldPresent(options->listenInfo(), FBS::Transport::ListenInfo::VT_SENDBUFFERSIZE)) + { + this->listenInfo.sendBufferSize = options->listenInfo()->sendBufferSize(); + } + + if (flatbuffers::IsFieldPresent(options->listenInfo(), FBS::Transport::ListenInfo::VT_RECVBUFFERSIZE)) + { + this->listenInfo.recvBufferSize = options->listenInfo()->recvBufferSize(); + } this->rtcpMux = options->rtcpMux(); this->comedia = options->comedia(); @@ -68,13 +87,17 @@ namespace RTC { if (!flatbuffers::IsFieldPresent( options, FBS::PlainTransport::PlainTransportOptions::VT_SRTPCRYPTOSUITE)) - MS_THROW_TYPE_ERROR("missing srtpCryptoSuite)"); + { + MS_THROW_TYPE_ERROR("missing srtpCryptoSuite"); + } // Ensure it's a crypto suite supported by us. auto it = PlainTransport::string2SrtpCryptoSuite.find(options->srtpCryptoSuite()->str()); if (it == PlainTransport::string2SrtpCryptoSuite.end()) + { MS_THROW_TYPE_ERROR("invalid/unsupported srtpCryptoSuite"); + } // NOTE: The SRTP crypto suite may change later on connect(). this->srtpCryptoSuite = it->second; @@ -116,15 +139,43 @@ namespace RTC try { // This may throw. - if (options->port() != 0) - this->udpSocket = new RTC::UdpSocket(this, this->listenIp.ip, options->port()); + if (this->listenInfo.port != 0) + { + this->udpSocket = new RTC::UdpSocket(this, this->listenInfo.ip, this->listenInfo.port); + } else - this->udpSocket = new RTC::UdpSocket(this, this->listenIp.ip); + { + this->udpSocket = new RTC::UdpSocket(this, this->listenInfo.ip); + } + + if (this->listenInfo.sendBufferSize != 0) + { + // NOTE: This may throw. + udpSocket->SetSendBufferSize(this->listenInfo.sendBufferSize); + } + + if (this->listenInfo.recvBufferSize != 0) + { + // NOTE: This may throw. + udpSocket->SetRecvBufferSize(this->listenInfo.recvBufferSize); + } if (!this->rtcpMux) { // This may throw. - this->rtcpUdpSocket = new RTC::UdpSocket(this, this->listenIp.ip); + this->rtcpUdpSocket = new RTC::UdpSocket(this, this->listenInfo.ip); + + if (this->listenInfo.sendBufferSize != 0) + { + // NOTE: This may throw. + rtcpUdpSocket->SetSendBufferSize(this->listenInfo.sendBufferSize); + } + + if (this->listenInfo.recvBufferSize != 0) + { + // NOTE: This may throw. + rtcpUdpSocket->SetRecvBufferSize(this->listenInfo.recvBufferSize); + } } // NOTE: This may throw. @@ -186,10 +237,14 @@ namespace RTC { std::string localIp; - if (this->listenIp.announcedIp.empty()) + if (this->listenInfo.announcedIp.empty()) + { localIp = this->udpSocket->GetLocalIp(); + } else - localIp = this->listenIp.announcedIp; + { + localIp = this->listenInfo.announcedIp; + } tuple = FBS::Transport::CreateTupleDirect( builder, localIp.c_str(), this->udpSocket->GetLocalPort(), "", 0, "udp"); @@ -208,10 +263,14 @@ namespace RTC { std::string localIp; - if (this->listenIp.announcedIp.empty()) + if (this->listenInfo.announcedIp.empty()) + { localIp = this->rtcpUdpSocket->GetLocalIp(); + } else - localIp = this->listenIp.announcedIp; + { + localIp = this->listenInfo.announcedIp; + } rtcpTuple = FBS::Transport::CreateTupleDirect( builder, localIp.c_str(), this->rtcpUdpSocket->GetLocalPort(), "", 0, "udp"); @@ -252,10 +311,15 @@ namespace RTC { std::string localIp; - if (this->listenIp.announcedIp.empty()) + + if (this->listenInfo.announcedIp.empty()) + { localIp = this->udpSocket->GetLocalIp(); + } else - localIp = this->listenIp.announcedIp; + { + localIp = this->listenInfo.announcedIp; + } tuple = FBS::Transport::CreateTupleDirect( builder, @@ -276,7 +340,9 @@ namespace RTC flatbuffers::Offset rtcpTuple; if (!this->rtcpMux && this->rtcpTuple) + { rtcpTuple = this->rtcpTuple->FillBuffer(builder); + } // Base Transport stats. auto base = Transport::FillBufferStats(builder); @@ -318,7 +384,9 @@ namespace RTC { // Ensure this method is not called twice. if (this->connectCalled) + { MS_THROW_ERROR("connect() already called"); + } try { @@ -349,7 +417,9 @@ namespace RTC PlainTransport::string2SrtpCryptoSuite.find(srtpParameters->cryptoSuite()->str()); if (it == PlainTransport::string2SrtpCryptoSuite.end()) + { MS_THROW_TYPE_ERROR("invalid/unsupported srtpParameters.cryptoSuite"); + } // Update out SRTP crypto suite with the one used by the remote. auto previousSrtpCryptoSuite = this->srtpCryptoSuite; @@ -399,7 +469,9 @@ namespace RTC auto* srtpKey = Utils::String::Base64Decode(srtpKeyBase64, outLen); if (outLen != this->srtpMasterLength) + { MS_THROW_TYPE_ERROR("invalid decoded SRTP key length"); + } auto* srtpLocalKey = new uint8_t[this->srtpMasterLength]; auto* srtpRemoteKey = new uint8_t[this->srtpMasterLength]; @@ -446,7 +518,9 @@ namespace RTC if (!this->comedia) { if (!flatbuffers::IsFieldPresent(body, FBS::PlainTransport::ConnectRequest::VT_IP)) + { MS_THROW_TYPE_ERROR("missing ip"); + } ip = body->ip()->str(); @@ -463,14 +537,18 @@ namespace RTC if (body->rtcpPort().has_value()) { if (this->rtcpMux) + { MS_THROW_TYPE_ERROR("cannot set rtcpPort with rtcpMux enabled"); + } rtcpPort = body->rtcpPort().value(); } else { if (!this->rtcpMux) + { MS_THROW_TYPE_ERROR("missing rtcpPort (required with rtcpMux disabled)"); + } } int err; @@ -485,7 +563,9 @@ namespace RTC reinterpret_cast(&this->remoteAddrStorage)); if (err != 0) + { MS_THROW_ERROR("uv_ip4_addr() failed: %s", uv_strerror(err)); + } break; } @@ -498,7 +578,9 @@ namespace RTC reinterpret_cast(&this->remoteAddrStorage)); if (err != 0) + { MS_THROW_ERROR("uv_ip6_addr() failed: %s", uv_strerror(err)); + } break; } @@ -513,8 +595,10 @@ namespace RTC this->tuple = new RTC::TransportTuple( this->udpSocket, reinterpret_cast(&this->remoteAddrStorage)); - if (!this->listenIp.announcedIp.empty()) - this->tuple->SetLocalAnnouncedIp(this->listenIp.announcedIp); + if (!this->listenInfo.announcedIp.empty()) + { + this->tuple->SetLocalAnnouncedIp(this->listenInfo.announcedIp); + } if (!this->rtcpMux) { @@ -528,7 +612,9 @@ namespace RTC reinterpret_cast(&this->rtcpRemoteAddrStorage)); if (err != 0) + { MS_THROW_ERROR("uv_ip4_addr() failed: %s", uv_strerror(err)); + } break; } @@ -541,7 +627,9 @@ namespace RTC reinterpret_cast(&this->rtcpRemoteAddrStorage)); if (err != 0) + { MS_THROW_ERROR("uv_ip6_addr() failed: %s", uv_strerror(err)); + } break; } @@ -557,8 +645,10 @@ namespace RTC this->rtcpUdpSocket, reinterpret_cast(&this->rtcpRemoteAddrStorage)); - if (!this->listenIp.announcedIp.empty()) - this->rtcpTuple->SetLocalAnnouncedIp(this->listenIp.announcedIp); + if (!this->listenInfo.announcedIp.empty()) + { + this->rtcpTuple->SetLocalAnnouncedIp(this->listenInfo.announcedIp); + } } } } @@ -587,10 +677,14 @@ namespace RTC flatbuffers::Offset srtpParametersOffset; if (this->tuple) + { tupleOffset = this->tuple->FillBuffer(request->GetBufferBuilder()); + } if (!this->rtcpMux && this->rtcpTuple) + { rtcpTupleOffset = this->rtcpTuple->FillBuffer(request->GetBufferBuilder()); + } if (HasSrtp()) { @@ -688,20 +782,28 @@ namespace RTC MS_TRACE(); if (!IsConnected()) + { return; + } const uint8_t* data = packet->GetData(); auto intLen = static_cast(packet->GetSize()); if (HasSrtp() && !this->srtpSendSession->EncryptRtcp(&data, &intLen)) + { return; + } auto len = static_cast(intLen); if (this->rtcpMux) + { this->tuple->Send(data, len); + } else if (this->rtcpTuple) + { this->rtcpTuple->Send(data, len); + } // Increase send transmission. RTC::Transport::DataSent(len); @@ -712,7 +814,9 @@ namespace RTC MS_TRACE(); if (!IsConnected()) + { return; + } packet->Serialize(RTC::RTCP::Buffer); @@ -720,14 +824,20 @@ namespace RTC auto intLen = static_cast(packet->GetSize()); if (HasSrtp() && !this->srtpSendSession->EncryptRtcp(&data, &intLen)) + { return; + } auto len = static_cast(intLen); if (this->rtcpMux) + { this->tuple->Send(data, len); + } else if (this->rtcpTuple) + { this->rtcpTuple->Send(data, len); + } // Increase send transmission. RTC::Transport::DataSent(len); @@ -746,7 +856,9 @@ namespace RTC MS_TRACE(); if (!IsConnected()) + { return; + } this->tuple->Send(data, len); @@ -808,7 +920,9 @@ namespace RTC MS_TRACE(); if (HasSrtp() && !IsSrtpReady()) + { return; + } // Decrypt the SRTP packet. auto intLen = static_cast(len); @@ -866,8 +980,10 @@ namespace RTC this->tuple = new RTC::TransportTuple(tuple); - if (!this->listenIp.announcedIp.empty()) - this->tuple->SetLocalAnnouncedIp(this->listenIp.announcedIp); + if (!this->listenInfo.announcedIp.empty()) + { + this->tuple->SetLocalAnnouncedIp(this->listenInfo.announcedIp); + } // If not yet connected do it now. if (!wasConnected) @@ -902,7 +1018,9 @@ namespace RTC MS_TRACE(); if (HasSrtp() && !IsSrtpReady()) + { return; + } // Decrypt the SRTCP packet. auto intLen = static_cast(len); @@ -929,8 +1047,10 @@ namespace RTC this->tuple = new RTC::TransportTuple(tuple); - if (!this->listenIp.announcedIp.empty()) - this->tuple->SetLocalAnnouncedIp(this->listenIp.announcedIp); + if (!this->listenInfo.announcedIp.empty()) + { + this->tuple->SetLocalAnnouncedIp(this->listenInfo.announcedIp); + } // If not yet connected do it now. if (!wasConnected) @@ -956,8 +1076,10 @@ namespace RTC this->rtcpTuple = new RTC::TransportTuple(tuple); - if (!this->listenIp.announcedIp.empty()) - this->rtcpTuple->SetLocalAnnouncedIp(this->listenIp.announcedIp); + if (!this->listenInfo.announcedIp.empty()) + { + this->rtcpTuple->SetLocalAnnouncedIp(this->listenInfo.announcedIp); + } // Notify the Node PlainTransport. EmitRtcpTuple(); @@ -1011,8 +1133,10 @@ namespace RTC this->tuple = new RTC::TransportTuple(tuple); - if (!this->listenIp.announcedIp.empty()) - this->tuple->SetLocalAnnouncedIp(this->listenIp.announcedIp); + if (!this->listenInfo.announcedIp.empty()) + { + this->tuple->SetLocalAnnouncedIp(this->listenInfo.announcedIp); + } // If not yet connected do it now. if (!wasConnected) diff --git a/worker/src/RTC/Router.cpp b/worker/src/RTC/Router.cpp index 92b7bfacde..487449dc55 100644 --- a/worker/src/RTC/Router.cpp +++ b/worker/src/RTC/Router.cpp @@ -248,8 +248,7 @@ namespace RTC if (!webRtcServer) MS_THROW_ERROR("wrong webRtcServerId (no associated WebRtcServer found)"); - auto iceCandidates = webRtcServer->GetIceCandidates( - options->enableUdp(), options->enableTcp(), options->preferUdp(), options->preferTcp()); + auto& iceCandidates = webRtcServer->GetIceCandidates(); // This may throw. auto* webRtcTransport = new RTC::WebRtcTransport( diff --git a/worker/src/RTC/RtpStreamRecv.cpp b/worker/src/RTC/RtpStreamRecv.cpp index c03309c63f..a110d97e93 100644 --- a/worker/src/RTC/RtpStreamRecv.cpp +++ b/worker/src/RTC/RtpStreamRecv.cpp @@ -211,7 +211,7 @@ namespace RTC { // Run the RTP inactivity periodic timer (use a different timeout if DTX is // enabled). - this->inactivityCheckPeriodicTimer = new Timer(this); + this->inactivityCheckPeriodicTimer = new TimerHandle(this); this->inactivityCheckPeriodicTimer->Start( this->params.useDtx ? InactivityCheckIntervalWithDtx : InactivityCheckInterval); @@ -854,7 +854,7 @@ namespace RTC // Nothing to do. } - inline void RtpStreamRecv::OnTimer(Timer* timer) + inline void RtpStreamRecv::OnTimer(TimerHandle* timer) { MS_TRACE(); diff --git a/worker/src/RTC/TcpConnection.cpp b/worker/src/RTC/TcpConnection.cpp index b13cfd430c..143447367f 100644 --- a/worker/src/RTC/TcpConnection.cpp +++ b/worker/src/RTC/TcpConnection.cpp @@ -16,7 +16,7 @@ namespace RTC /* Instance methods. */ TcpConnection::TcpConnection(Listener* listener, size_t bufferSize) - : ::TcpConnectionHandler::TcpConnectionHandler(bufferSize), listener(listener) + : ::TcpConnectionHandle::TcpConnectionHandle(bufferSize), listener(listener) { MS_TRACE(); } @@ -154,7 +154,7 @@ namespace RTC } } - void TcpConnection::Send(const uint8_t* data, size_t len, ::TcpConnectionHandler::onSendCallback* cb) + void TcpConnection::Send(const uint8_t* data, size_t len, ::TcpConnectionHandle::onSendCallback* cb) { MS_TRACE(); @@ -163,6 +163,6 @@ namespace RTC uint8_t frameLen[2]; Utils::Byte::Set2Bytes(frameLen, 0, len); - ::TcpConnectionHandler::Write(frameLen, 2, data, len, cb); + ::TcpConnectionHandle::Write(frameLen, 2, data, len, cb); } } // namespace RTC diff --git a/worker/src/RTC/TcpServer.cpp b/worker/src/RTC/TcpServer.cpp index 3d502c9d69..ddd1d2da82 100644 --- a/worker/src/RTC/TcpServer.cpp +++ b/worker/src/RTC/TcpServer.cpp @@ -12,7 +12,7 @@ namespace RTC TcpServer::TcpServer(Listener* listener, RTC::TcpConnection::Listener* connListener, std::string& ip) : // This may throw. - ::TcpServerHandler::TcpServerHandler(RTC::PortManager::BindTcp(ip)), listener(listener), + ::TcpServerHandle::TcpServerHandle(RTC::PortManager::BindTcp(ip)), listener(listener), connListener(connListener) { MS_TRACE(); @@ -21,7 +21,7 @@ namespace RTC TcpServer::TcpServer( Listener* listener, RTC::TcpConnection::Listener* connListener, std::string& ip, uint16_t port) : // This may throw. - ::TcpServerHandler::TcpServerHandler(RTC::PortManager::BindTcp(ip, port)), listener(listener), + ::TcpServerHandle::TcpServerHandle(RTC::PortManager::BindTcp(ip, port)), listener(listener), connListener(connListener), fixedPort(true) { MS_TRACE(); @@ -48,7 +48,7 @@ namespace RTC AcceptTcpConnection(connection); } - void TcpServer::UserOnTcpConnectionClosed(::TcpConnectionHandler* connection) + void TcpServer::UserOnTcpConnectionClosed(::TcpConnectionHandle* connection) { MS_TRACE(); diff --git a/worker/src/RTC/Transport.cpp b/worker/src/RTC/Transport.cpp index 5c14bfba63..c6d64ca4e0 100644 --- a/worker/src/RTC/Transport.cpp +++ b/worker/src/RTC/Transport.cpp @@ -98,7 +98,7 @@ namespace RTC } // Create the RTCP timer. - this->rtcpTimer = new Timer(this); + this->rtcpTimer = new TimerHandle(this); } Transport::~Transport() @@ -2992,7 +2992,7 @@ namespace RTC } #endif - inline void Transport::OnTimer(Timer* timer) + inline void Transport::OnTimer(TimerHandle* timer) { MS_TRACE(); diff --git a/worker/src/RTC/TransportCongestionControlClient.cpp b/worker/src/RTC/TransportCongestionControlClient.cpp index 2a0d35badd..380fb34edb 100644 --- a/worker/src/RTC/TransportCongestionControlClient.cpp +++ b/worker/src/RTC/TransportCongestionControlClient.cpp @@ -73,7 +73,7 @@ namespace RTC // videos are muted or using screensharing with still images) this->rtpTransportControllerSend->EnablePeriodicAlrProbing(true); - this->processTimer = new Timer(this); + this->processTimer = new TimerHandle(this); // clang-format off this->processTimer->Start(std::min( @@ -556,7 +556,7 @@ namespace RTC return this->probationGenerator->GetNextPacket(size); } - void TransportCongestionControlClient::OnTimer(Timer* timer) + void TransportCongestionControlClient::OnTimer(TimerHandle* timer) { MS_TRACE(); diff --git a/worker/src/RTC/TransportCongestionControlServer.cpp b/worker/src/RTC/TransportCongestionControlServer.cpp index 8c7a016949..98ed26a575 100644 --- a/worker/src/RTC/TransportCongestionControlServer.cpp +++ b/worker/src/RTC/TransportCongestionControlServer.cpp @@ -38,7 +38,7 @@ namespace RTC this->transportCcFeedbackPacket->SetFeedbackPacketCount(this->transportCcFeedbackPacketCount); // Create the feedback send periodic timer. - this->transportCcFeedbackSendPeriodicTimer = new Timer(this); + this->transportCcFeedbackSendPeriodicTimer = new TimerHandle(this); break; } @@ -383,7 +383,7 @@ namespace RTC this->listener->OnTransportCongestionControlServerSendRtcpPacket(this, &packet); } - inline void TransportCongestionControlServer::OnTimer(Timer* timer) + inline void TransportCongestionControlServer::OnTimer(TimerHandle* timer) { MS_TRACE(); diff --git a/worker/src/RTC/UdpSocket.cpp b/worker/src/RTC/UdpSocket.cpp index e750131f71..6c47ab4671 100644 --- a/worker/src/RTC/UdpSocket.cpp +++ b/worker/src/RTC/UdpSocket.cpp @@ -12,14 +12,14 @@ namespace RTC UdpSocket::UdpSocket(Listener* listener, std::string& ip) : // This may throw. - ::UdpSocketHandler::UdpSocketHandler(PortManager::BindUdp(ip)), listener(listener) + ::UdpSocketHandle::UdpSocketHandle(PortManager::BindUdp(ip)), listener(listener) { MS_TRACE(); } UdpSocket::UdpSocket(Listener* listener, std::string& ip, uint16_t port) : // This may throw. - ::UdpSocketHandler::UdpSocketHandler(PortManager::BindUdp(ip, port)), listener(listener), + ::UdpSocketHandle::UdpSocketHandle(PortManager::BindUdp(ip, port)), listener(listener), fixedPort(true) { MS_TRACE(); diff --git a/worker/src/RTC/WebRtcServer.cpp b/worker/src/RTC/WebRtcServer.cpp index 8e3cf849e2..de64910a95 100644 --- a/worker/src/RTC/WebRtcServer.cpp +++ b/worker/src/RTC/WebRtcServer.cpp @@ -30,18 +30,26 @@ namespace RTC WebRtcServer::WebRtcServer( RTC::Shared* shared, const std::string& id, - const flatbuffers::Vector>* listenInfos) + const flatbuffers::Vector>* listenInfos) : id(id), shared(shared) { MS_TRACE(); if (listenInfos->size() == 0) + { MS_THROW_TYPE_ERROR("wrong listenInfos (empty array)"); + } else if (listenInfos->size() > 8) + { MS_THROW_TYPE_ERROR("wrong listenInfos (too many entries)"); + } try { + uint16_t iceLocalPreferenceDecrement{ 0u }; + + this->iceCandidates.reserve(listenInfos->size()); + for (const auto* listenInfo : *listenInfos) { auto ip = listenInfo->ip()->str(); @@ -51,22 +59,55 @@ namespace RTC std::string announcedIp; - if (flatbuffers::IsFieldPresent(listenInfo, FBS::WebRtcServer::ListenInfo::VT_ANNOUNCEDIP)) + if (flatbuffers::IsFieldPresent(listenInfo, FBS::Transport::ListenInfo::VT_ANNOUNCEDIP)) { announcedIp = listenInfo->announcedIp()->str(); } + const uint16_t iceLocalPreference = + IceCandidateDefaultLocalPriority - iceLocalPreferenceDecrement; + const uint32_t icePriority = generateIceCandidatePriority(iceLocalPreference); + if (listenInfo->protocol() == FBS::Transport::Protocol::UDP) { // This may throw. RTC::UdpSocket* udpSocket; if (listenInfo->port() != 0) + { udpSocket = new RTC::UdpSocket(this, ip, listenInfo->port()); + } else + { udpSocket = new RTC::UdpSocket(this, ip); + } this->udpSocketOrTcpServers.emplace_back(udpSocket, nullptr, announcedIp); + + if (announcedIp.size() == 0) + { + this->iceCandidates.emplace_back(udpSocket, icePriority); + } + else + { + this->iceCandidates.emplace_back(udpSocket, icePriority, announcedIp); + } + + if (listenInfo->sendBufferSize() != 0) + { + udpSocket->SetSendBufferSize(listenInfo->sendBufferSize()); + } + + if (listenInfo->recvBufferSize() != 0) + { + udpSocket->SetRecvBufferSize(listenInfo->recvBufferSize()); + } + + MS_DEBUG_TAG( + info, + "UDP socket send buffer size: %d, recv buffer size: %d", + udpSocket->GetSendBufferSize(), + udpSocket->GetRecvBufferSize()); } else if (listenInfo->protocol() == FBS::Transport::Protocol::TCP) { @@ -74,12 +115,44 @@ namespace RTC RTC::TcpServer* tcpServer; if (listenInfo->port() != 0) + { tcpServer = new RTC::TcpServer(this, this, ip, listenInfo->port()); + } else + { tcpServer = new RTC::TcpServer(this, this, ip); + } this->udpSocketOrTcpServers.emplace_back(nullptr, tcpServer, announcedIp); + + if (announcedIp.size() == 0) + { + this->iceCandidates.emplace_back(tcpServer, icePriority); + } + else + { + this->iceCandidates.emplace_back(tcpServer, icePriority, announcedIp); + } + + if (listenInfo->sendBufferSize() != 0) + { + tcpServer->SetSendBufferSize(listenInfo->sendBufferSize()); + } + + if (listenInfo->recvBufferSize() != 0) + { + tcpServer->SetRecvBufferSize(listenInfo->recvBufferSize()); + } + + MS_DEBUG_TAG( + info, + "TCP server send buffer size: %d, recv buffer size: %d", + tcpServer->GetSendBufferSize(), + tcpServer->GetRecvBufferSize()); } + + // Decrement initial ICE local preference for next IP. + iceLocalPreferenceDecrement += 100; } // NOTE: This may throw. @@ -216,50 +289,11 @@ namespace RTC } } - std::vector WebRtcServer::GetIceCandidates( - bool enableUdp, bool enableTcp, bool preferUdp, bool preferTcp) + const std::vector& WebRtcServer::GetIceCandidates() const { MS_TRACE(); - std::vector iceCandidates; - uint16_t iceLocalPreferenceDecrement{ 0 }; - - for (auto& item : this->udpSocketOrTcpServers) - { - if (item.udpSocket && enableUdp) - { - uint16_t iceLocalPreference = IceCandidateDefaultLocalPriority - iceLocalPreferenceDecrement; - - if (preferUdp) - iceLocalPreference += 1000; - - uint32_t icePriority = generateIceCandidatePriority(iceLocalPreference); - - if (item.announcedIp.empty()) - iceCandidates.emplace_back(item.udpSocket, icePriority); - else - iceCandidates.emplace_back(item.udpSocket, icePriority, item.announcedIp); - } - else if (item.tcpServer && enableTcp) - { - uint16_t iceLocalPreference = IceCandidateDefaultLocalPriority - iceLocalPreferenceDecrement; - - if (preferTcp) - iceLocalPreference += 1000; - - uint32_t icePriority = generateIceCandidatePriority(iceLocalPreference); - - if (item.announcedIp.empty()) - iceCandidates.emplace_back(item.tcpServer, icePriority); - else - iceCandidates.emplace_back(item.tcpServer, icePriority, item.announcedIp); - } - - // Decrement initial ICE local preference for next IP. - iceLocalPreferenceDecrement += 100; - } - - return iceCandidates; + return this->iceCandidates; } inline std::string WebRtcServer::GetLocalIceUsernameFragmentFromReceivedStunPacket( @@ -277,7 +311,9 @@ namespace RTC // If no colon is found just return the whole USERNAME attribute anyway. if (colonPos == std::string::npos) + { return username; + } return username.substr(0, colonPos); } @@ -464,7 +500,9 @@ namespace RTC auto it = this->mapTupleWebRtcTransport.find(tuple.hash); if (it == this->mapTupleWebRtcTransport.end()) + { return; + } auto* webRtcTransport = it->second; diff --git a/worker/src/RTC/WebRtcTransport.cpp b/worker/src/RTC/WebRtcTransport.cpp index 5bc1a5c435..a4d9cd2c00 100644 --- a/worker/src/RTC/WebRtcTransport.cpp +++ b/worker/src/RTC/WebRtcTransport.cpp @@ -37,83 +37,115 @@ namespace RTC { MS_TRACE(); - const auto* listenInfo = options->listen_as(); - const auto* listenIps = listenInfo->listenIps(); - try { - uint16_t iceLocalPreferenceDecrement{ 0 }; + const auto* listenIndividual = options->listen_as(); + const auto* listenInfos = listenIndividual->listenInfos(); + uint16_t iceLocalPreferenceDecrement{ 0u }; - if (options->enableUdp() && options->enableTcp()) - this->iceCandidates.reserve(2 * listenIps->size()); - else - this->iceCandidates.reserve(listenIps->size()); + this->iceCandidates.reserve(listenInfos->size()); - for (const auto* listenIp : *listenIps) + for (const auto* listenInfo : *listenInfos) { - auto ip = listenIp->ip()->str(); + auto ip = listenInfo->ip()->str(); // This may throw. Utils::IP::NormalizeIp(ip); - if (options->enableUdp()) - { - uint16_t iceLocalPreference = - IceCandidateDefaultLocalPriority - iceLocalPreferenceDecrement; + std::string announcedIp; - if (options->preferUdp()) - iceLocalPreference += 1000; + if (flatbuffers::IsFieldPresent(listenInfo, FBS::Transport::ListenInfo::VT_ANNOUNCEDIP)) + { + announcedIp = listenInfo->announcedIp()->str(); + } - uint32_t icePriority = generateIceCandidatePriority(iceLocalPreference); + const uint16_t iceLocalPreference = + IceCandidateDefaultLocalPriority - iceLocalPreferenceDecrement; + const uint32_t icePriority = generateIceCandidatePriority(iceLocalPreference); - // This may throw. + if (listenInfo->protocol() == FBS::Transport::Protocol::UDP) + { RTC::UdpSocket* udpSocket; + if (listenInfo->port() != 0) + { udpSocket = new RTC::UdpSocket(this, ip, listenInfo->port()); + } else + { udpSocket = new RTC::UdpSocket(this, ip); - - std::string announcedIp; - - if (flatbuffers::IsFieldPresent(listenIp, FBS::Transport::ListenIp::VT_ANNOUNCEDIP)) - announcedIp = listenIp->announcedIp()->str(); + } this->udpSockets[udpSocket] = announcedIp; if (announcedIp.size() == 0) + { this->iceCandidates.emplace_back(udpSocket, icePriority); + } else + { this->iceCandidates.emplace_back(udpSocket, icePriority, announcedIp); - } - - if (options->enableTcp()) - { - uint16_t iceLocalPreference = - IceCandidateDefaultLocalPriority - iceLocalPreferenceDecrement; + } - if (options->preferTcp()) - iceLocalPreference += 1000; + if (listenInfo->sendBufferSize() != 0) + { + // NOTE: This may throw. + udpSocket->SetSendBufferSize(listenInfo->sendBufferSize()); + } - const uint32_t icePriority = generateIceCandidatePriority(iceLocalPreference); + if (listenInfo->recvBufferSize() != 0) + { + // NOTE: This may throw. + udpSocket->SetRecvBufferSize(listenInfo->recvBufferSize()); + } - // This may throw. + MS_DEBUG_TAG( + info, + "UDP socket buffer sizes [send:%" PRIu32 ", recv:%" PRIu32 "]", + udpSocket->GetSendBufferSize(), + udpSocket->GetRecvBufferSize()); + } + else if (listenInfo->protocol() == FBS::Transport::Protocol::TCP) + { RTC::TcpServer* tcpServer; + if (listenInfo->port() != 0) + { tcpServer = new RTC::TcpServer(this, this, ip, listenInfo->port()); + } else + { tcpServer = new RTC::TcpServer(this, this, ip); - - std::string announcedIp; - - if (flatbuffers::IsFieldPresent(listenIp, FBS::Transport::ListenIp::VT_ANNOUNCEDIP)) - announcedIp = listenIp->announcedIp()->str(); + } this->tcpServers[tcpServer] = announcedIp; if (announcedIp.size() == 0) + { this->iceCandidates.emplace_back(tcpServer, icePriority); + } else + { this->iceCandidates.emplace_back(tcpServer, icePriority, announcedIp); + } + + if (listenInfo->sendBufferSize() != 0) + { + // NOTE: This may throw. + tcpServer->SetSendBufferSize(listenInfo->sendBufferSize()); + } + + if (listenInfo->recvBufferSize() != 0) + { + // NOTE: This may throw. + tcpServer->SetRecvBufferSize(listenInfo->recvBufferSize()); + } + + MS_DEBUG_TAG( + info, + "TCP sockets buffer sizes [send:%" PRIu32 ", recv:%" PRIu32 "]", + tcpServer->GetSendBufferSize(), + tcpServer->GetRecvBufferSize()); } // Decrement initial ICE local preference for next IP. @@ -173,7 +205,7 @@ namespace RTC const std::string& id, RTC::Transport::Listener* listener, WebRtcTransportListener* webRtcTransportListener, - std::vector& iceCandidates, + const std::vector& iceCandidates, const FBS::WebRtcTransport::WebRtcTransportOptions* options) : RTC::Transport::Transport(shared, id, listener, options->base()), webRtcTransportListener(webRtcTransportListener), iceCandidates(iceCandidates) @@ -211,8 +243,6 @@ namespace RTC delete this->iceServer; this->iceServer = nullptr; - this->iceCandidates.clear(); - throw; } } diff --git a/worker/src/Worker.cpp b/worker/src/Worker.cpp index 18d31cb267..b372f60061 100644 --- a/worker/src/Worker.cpp +++ b/worker/src/Worker.cpp @@ -21,8 +21,8 @@ Worker::Worker(::Channel::ChannelSocket* channel) : channel(channel) // Set us as Channel's listener. this->channel->SetListener(this); - // Set the SignalHandler. - this->signalsHandler = new SignalsHandler(this); + // Set the SignalHandle. + this->signalHandle = new SignalHandle(this); // Set up the RTC::Shared singleton. this->shared = new RTC::Shared( @@ -32,8 +32,8 @@ Worker::Worker(::Channel::ChannelSocket* channel) : channel(channel) #ifdef MS_EXECUTABLE { // Add signals to handle. - this->signalsHandler->AddSignal(SIGINT, "INT"); - this->signalsHandler->AddSignal(SIGTERM, "TERM"); + this->signalHandle->AddSignal(SIGINT, "INT"); + this->signalHandle->AddSignal(SIGTERM, "TERM"); } #endif @@ -66,8 +66,8 @@ void Worker::Close() this->closed = true; - // Delete the SignalsHandler. - delete this->signalsHandler; + // Delete the SignalHandle. + delete this->signalHandle; // Delete all Routers. for (auto& kv : this->mapRouters) @@ -454,7 +454,7 @@ inline void Worker::OnChannelClosed(Channel::ChannelSocket* /*socket*/) Close(); } -inline void Worker::OnSignal(SignalsHandler* /*signalsHandler*/, int signum) +inline void Worker::OnSignal(SignalHandle* /*signalHandle*/, int signum) { MS_TRACE(); diff --git a/worker/src/handles/SignalsHandler.cpp b/worker/src/handles/SignalHandle.cpp similarity index 76% rename from worker/src/handles/SignalsHandler.cpp rename to worker/src/handles/SignalHandle.cpp index f23240bd5b..346a4ba1f5 100644 --- a/worker/src/handles/SignalsHandler.cpp +++ b/worker/src/handles/SignalHandle.cpp @@ -1,7 +1,7 @@ -#define MS_CLASS "SignalsHandler" +#define MS_CLASS "SignalHandle" // #define MS_LOG_DEV_LEVEL 3 -#include "handles/SignalsHandler.hpp" +#include "handles/SignalHandle.hpp" #include "DepLibUV.hpp" #include "Logger.hpp" #include "MediaSoupErrors.hpp" @@ -10,7 +10,7 @@ inline static void onSignal(uv_signal_t* handle, int signum) { - static_cast(handle->data)->OnUvSignal(signum); + static_cast(handle->data)->OnUvSignal(signum); } inline static void onClose(uv_handle_t* handle) @@ -20,25 +20,29 @@ inline static void onClose(uv_handle_t* handle) /* Instance methods. */ -SignalsHandler::SignalsHandler(Listener* listener) : listener(listener) +SignalHandle::SignalHandle(Listener* listener) : listener(listener) { MS_TRACE(); } -SignalsHandler::~SignalsHandler() +SignalHandle::~SignalHandle() { MS_TRACE(); if (!this->closed) + { Close(); + } } -void SignalsHandler::Close() +void SignalHandle::Close() { MS_TRACE(); if (this->closed) + { return; + } this->closed = true; @@ -48,12 +52,14 @@ void SignalsHandler::Close() } } -void SignalsHandler::AddSignal(int signum, const std::string& name) +void SignalHandle::AddSignal(int signum, const std::string& name) { MS_TRACE(); if (this->closed) + { MS_THROW_ERROR("closed"); + } int err; auto* uvHandle = new uv_signal_t; @@ -72,13 +78,15 @@ void SignalsHandler::AddSignal(int signum, const std::string& name) err = uv_signal_start(uvHandle, static_cast(onSignal), signum); if (err != 0) + { MS_THROW_ERROR("uv_signal_start() failed for signal %s: %s", name.c_str(), uv_strerror(err)); + } // Enter the UV handle into the vector. this->uvHandles.push_back(uvHandle); } -inline void SignalsHandler::OnUvSignal(int signum) +inline void SignalHandle::OnUvSignal(int signum) { MS_TRACE(); diff --git a/worker/src/handles/TcpConnectionHandler.cpp b/worker/src/handles/TcpConnectionHandle.cpp similarity index 86% rename from worker/src/handles/TcpConnectionHandler.cpp rename to worker/src/handles/TcpConnectionHandle.cpp index 5e3fa110ed..ebcda996d2 100644 --- a/worker/src/handles/TcpConnectionHandler.cpp +++ b/worker/src/handles/TcpConnectionHandle.cpp @@ -1,7 +1,7 @@ -#define MS_CLASS "TcpConnectionHandler" +#define MS_CLASS "TcpConnectionHandle" // #define MS_LOG_DEV_LEVEL 3 -#include "handles/TcpConnectionHandler.hpp" +#include "handles/TcpConnectionHandle.hpp" #include "DepLibUV.hpp" #include "Logger.hpp" #include "MediaSoupErrors.hpp" @@ -12,29 +12,35 @@ inline static void onAlloc(uv_handle_t* handle, size_t suggestedSize, uv_buf_t* buf) { - auto* connection = static_cast(handle->data); + auto* connection = static_cast(handle->data); if (connection) + { connection->OnUvReadAlloc(suggestedSize, buf); + } } inline static void onRead(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { - auto* connection = static_cast(handle->data); + auto* connection = static_cast(handle->data); if (connection) + { connection->OnUvRead(nread, buf); + } } inline static void onWrite(uv_write_t* req, int status) { - auto* writeData = static_cast(req->data); + auto* writeData = static_cast(req->data); auto* handle = req->handle; - auto* connection = static_cast(handle->data); + auto* connection = static_cast(handle->data); auto* cb = writeData->cb; if (connection) + { connection->OnUvWrite(status, cb); + } // Delete the UvWriteData struct and the cb. delete writeData; @@ -58,7 +64,7 @@ inline static void onShutdown(uv_shutdown_t* req, int /*status*/) /* Instance methods. */ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) -TcpConnectionHandler::TcpConnectionHandler(size_t bufferSize) : bufferSize(bufferSize) +TcpConnectionHandle::TcpConnectionHandle(size_t bufferSize) : bufferSize(bufferSize) { MS_TRACE(); @@ -68,35 +74,41 @@ TcpConnectionHandler::TcpConnectionHandler(size_t bufferSize) : bufferSize(buffe // NOTE: Don't allocate the buffer here. Instead wait for the first uv_alloc_cb(). } -TcpConnectionHandler::~TcpConnectionHandler() +TcpConnectionHandle::~TcpConnectionHandle() { MS_TRACE(); if (!this->closed) + { Close(); + } delete[] this->buffer; } -void TcpConnectionHandler::Close() +void TcpConnectionHandle::Close() { MS_TRACE(); if (this->closed) + { return; + } int err; this->closed = true; - // Tell the UV handle that the TcpConnectionHandler has been closed. + // Tell the UV handle that the TcpConnectionHandle has been closed. this->uvHandle->data = nullptr; // Don't read more. err = uv_read_stop(reinterpret_cast(this->uvHandle)); if (err != 0) + { MS_ABORT("uv_read_stop() failed: %s", uv_strerror(err)); + } // If there is no error and the peer didn't close its connection side then close gracefully. if (!this->hasError && !this->isClosedByPeer) @@ -109,7 +121,9 @@ void TcpConnectionHandler::Close() req, reinterpret_cast(this->uvHandle), static_cast(onShutdown)); if (err != 0) + { MS_ABORT("uv_shutdown() failed: %s", uv_strerror(err)); + } } // Otherwise directly close the socket. else @@ -118,18 +132,18 @@ void TcpConnectionHandler::Close() } } -void TcpConnectionHandler::Dump() const +void TcpConnectionHandle::Dump() const { - MS_DUMP(""); + MS_DUMP(""); MS_DUMP(" localIp : %s", this->localIp.c_str()); MS_DUMP(" localPort : %" PRIu16, static_cast(this->localPort)); MS_DUMP(" remoteIp : %s", this->peerIp.c_str()); MS_DUMP(" remotePort : %" PRIu16, static_cast(this->peerPort)); MS_DUMP(" closed : %s", !this->closed ? "open" : "closed"); - MS_DUMP(""); + MS_DUMP(""); } -void TcpConnectionHandler::Setup( +void TcpConnectionHandle::Setup( Listener* listener, struct sockaddr_storage* localAddr, const std::string& localIp, uint16_t localPort) { MS_TRACE(); @@ -154,12 +168,14 @@ void TcpConnectionHandler::Setup( this->localPort = localPort; } -void TcpConnectionHandler::Start() +void TcpConnectionHandle::Start() { MS_TRACE(); if (this->closed) + { return; + } int err = uv_read_start( reinterpret_cast(this->uvHandle), @@ -167,19 +183,23 @@ void TcpConnectionHandler::Start() static_cast(onRead)); if (err != 0) + { MS_THROW_ERROR("uv_read_start() failed: %s", uv_strerror(err)); + } // Get the peer address. if (!SetPeerAddress()) + { MS_THROW_ERROR("error setting peer IP and port"); + } } -void TcpConnectionHandler::Write( +void TcpConnectionHandle::Write( const uint8_t* data1, size_t len1, const uint8_t* data2, size_t len2, - TcpConnectionHandler::onSendCallback* cb) + TcpConnectionHandle::onSendCallback* cb) { MS_TRACE(); @@ -283,7 +303,9 @@ void TcpConnectionHandler::Write( MS_WARN_DEV("uv_write() failed: %s", uv_strerror(err)); if (cb) + { (*cb)(false); + } // Delete the UvWriteData struct (it will delete the store and cb too). delete writeData; @@ -295,7 +317,7 @@ void TcpConnectionHandler::Write( } } -void TcpConnectionHandler::ErrorReceiving() +void TcpConnectionHandle::ErrorReceiving() { MS_TRACE(); @@ -304,7 +326,7 @@ void TcpConnectionHandler::ErrorReceiving() this->listener->OnTcpConnectionClosed(this); } -bool TcpConnectionHandler::SetPeerAddress() +bool TcpConnectionHandle::SetPeerAddress() { MS_TRACE(); @@ -328,13 +350,15 @@ bool TcpConnectionHandler::SetPeerAddress() return true; } -inline void TcpConnectionHandler::OnUvReadAlloc(size_t /*suggestedSize*/, uv_buf_t* buf) +inline void TcpConnectionHandle::OnUvReadAlloc(size_t /*suggestedSize*/, uv_buf_t* buf) { MS_TRACE(); // If this is the first call to onUvReadAlloc() then allocate the receiving buffer now. if (!this->buffer) + { this->buffer = new uint8_t[this->bufferSize]; + } // Tell UV to write after the last data byte in the buffer. buf->base = reinterpret_cast(this->buffer + this->bufferDataLen); @@ -352,12 +376,14 @@ inline void TcpConnectionHandler::OnUvReadAlloc(size_t /*suggestedSize*/, uv_buf } } -inline void TcpConnectionHandler::OnUvRead(ssize_t nread, const uv_buf_t* /*buf*/) +inline void TcpConnectionHandle::OnUvRead(ssize_t nread, const uv_buf_t* /*buf*/) { MS_TRACE(); if (nread == 0) + { return; + } // Data received. if (nread > 0) @@ -399,7 +425,7 @@ inline void TcpConnectionHandler::OnUvRead(ssize_t nread, const uv_buf_t* /*buf* } } -inline void TcpConnectionHandler::OnUvWrite(int status, TcpConnectionHandler::onSendCallback* cb) +inline void TcpConnectionHandle::OnUvWrite(int status, TcpConnectionHandle::onSendCallback* cb) { MS_TRACE(); @@ -408,17 +434,23 @@ inline void TcpConnectionHandler::OnUvWrite(int status, TcpConnectionHandler::on if (status == 0) { if (cb) + { (*cb)(true); + } } else { if (status != UV_EPIPE && status != UV_ENOTCONN) + { this->hasError = true; + } MS_WARN_DEV("write error, closing the connection: %s", uv_strerror(status)); if (cb) + { (*cb)(false); + } Close(); diff --git a/worker/src/handles/TcpServerHandler.cpp b/worker/src/handles/TcpServerHandle.cpp similarity index 58% rename from worker/src/handles/TcpServerHandler.cpp rename to worker/src/handles/TcpServerHandle.cpp index f6513603f0..8f2c35c802 100644 --- a/worker/src/handles/TcpServerHandler.cpp +++ b/worker/src/handles/TcpServerHandle.cpp @@ -1,7 +1,7 @@ -#define MS_CLASS "TcpServerHandler" +#define MS_CLASS "TcpServerHandle" // #define MS_LOG_DEV_LEVEL 3 -#include "handles/TcpServerHandler.hpp" +#include "handles/TcpServerHandle.hpp" #include "Logger.hpp" #include "MediaSoupErrors.hpp" #include "Utils.hpp" @@ -14,10 +14,12 @@ static constexpr int ListenBacklog{ 512 }; inline static void onConnection(uv_stream_t* handle, int status) { - auto* server = static_cast(handle->data); + auto* server = static_cast(handle->data); if (server) + { server->OnUvConnection(status); + } } inline static void onClose(uv_handle_t* handle) @@ -28,7 +30,7 @@ inline static void onClose(uv_handle_t* handle) /* Instance methods. */ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) -TcpServerHandler::TcpServerHandler(uv_tcp_t* uvHandle) : uvHandle(uvHandle) +TcpServerHandle::TcpServerHandle(uv_tcp_t* uvHandle) : uvHandle(uvHandle) { MS_TRACE(); @@ -57,24 +59,28 @@ TcpServerHandler::TcpServerHandler(uv_tcp_t* uvHandle) : uvHandle(uvHandle) } } -TcpServerHandler::~TcpServerHandler() +TcpServerHandle::~TcpServerHandle() { MS_TRACE(); if (!this->closed) + { Close(); + } } -void TcpServerHandler::Close() +void TcpServerHandle::Close() { MS_TRACE(); if (this->closed) + { return; + } this->closed = true; - // Tell the UV handle that the TcpServerHandler has been closed. + // Tell the UV handle that the TcpServerHandle has been closed. this->uvHandle->data = nullptr; MS_DEBUG_DEV("closing %zu active connections", this->connections.size()); @@ -87,23 +93,93 @@ void TcpServerHandler::Close() uv_close(reinterpret_cast(this->uvHandle), static_cast(onClose)); } -void TcpServerHandler::Dump() const +void TcpServerHandle::Dump() const { - MS_DUMP(""); + MS_DUMP(""); MS_DUMP( " [TCP, local:%s :%" PRIu16 ", status:%s, connections:%zu]", this->localIp.c_str(), static_cast(this->localPort), (!this->closed) ? "open" : "closed", this->connections.size()); - MS_DUMP(""); + MS_DUMP(""); +} + +uint32_t TcpServerHandle::GetSendBufferSize() const +{ + MS_TRACE(); + + int size{ 0 }; + int err = uv_send_buffer_size(reinterpret_cast(this->uvHandle), std::addressof(size)); + + if (err) + { + MS_THROW_ERROR("uv_send_buffer_size() failed: %s", uv_strerror(err)); + } + + return static_cast(size); +} + +void TcpServerHandle::SetSendBufferSize(uint32_t size) +{ + MS_TRACE(); + + auto size_int = static_cast(size); + + if (size_int <= 0) + { + MS_THROW_TYPE_ERROR("invalid size: %d", size_int); + } + + int err = + uv_send_buffer_size(reinterpret_cast(this->uvHandle), std::addressof(size_int)); + + if (err) + { + MS_THROW_ERROR("uv_send_buffer_size() failed: %s", uv_strerror(err)); + } +} + +uint32_t TcpServerHandle::GetRecvBufferSize() const +{ + MS_TRACE(); + + int size{ 0 }; + int err = uv_recv_buffer_size(reinterpret_cast(this->uvHandle), std::addressof(size)); + + if (err) + { + MS_THROW_ERROR("uv_recv_buffer_size() failed: %s", uv_strerror(err)); + } + + return static_cast(size); +} + +void TcpServerHandle::SetRecvBufferSize(uint32_t size) +{ + MS_TRACE(); + + auto size_int = static_cast(size); + + if (size_int <= 0) + { + MS_THROW_TYPE_ERROR("invalid size: %d", size_int); + } + + int err = + uv_recv_buffer_size(reinterpret_cast(this->uvHandle), std::addressof(size_int)); + + if (err) + { + MS_THROW_ERROR("uv_recv_buffer_size() failed: %s", uv_strerror(err)); + } } -void TcpServerHandler::AcceptTcpConnection(TcpConnectionHandler* connection) +void TcpServerHandle::AcceptTcpConnection(TcpConnectionHandle* connection) { MS_TRACE(); - MS_ASSERT(connection != nullptr, "TcpConnectionHandler pointer was not allocated by the user"); + MS_ASSERT(connection != nullptr, "TcpConnectionHandle pointer was not allocated by the user"); try { @@ -122,7 +198,9 @@ void TcpServerHandler::AcceptTcpConnection(TcpConnectionHandler* connection) reinterpret_cast(connection->GetUvHandle())); if (err != 0) + { MS_ABORT("uv_accept() failed: %s", uv_strerror(err)); + } // Start receiving data. try @@ -141,7 +219,7 @@ void TcpServerHandler::AcceptTcpConnection(TcpConnectionHandler* connection) this->connections.insert(connection); } -bool TcpServerHandler::SetLocalAddress() +bool TcpServerHandle::SetLocalAddress() { MS_TRACE(); @@ -166,12 +244,14 @@ bool TcpServerHandler::SetLocalAddress() return true; } -inline void TcpServerHandler::OnUvConnection(int status) +inline void TcpServerHandle::OnUvConnection(int status) { MS_TRACE(); if (this->closed) + { return; + } if (status != 0) { @@ -184,13 +264,13 @@ inline void TcpServerHandler::OnUvConnection(int status) UserOnTcpConnectionAlloc(); } -inline void TcpServerHandler::OnTcpConnectionClosed(TcpConnectionHandler* connection) +inline void TcpServerHandle::OnTcpConnectionClosed(TcpConnectionHandle* connection) { MS_TRACE(); MS_DEBUG_DEV("TCP connection closed"); - // Remove the TcpConnectionHandler from the set. + // Remove the TcpConnectionHandle from the set. this->connections.erase(connection); // Notify the subclass. diff --git a/worker/src/handles/Timer.cpp b/worker/src/handles/TimerHandle.cpp similarity index 84% rename from worker/src/handles/Timer.cpp rename to worker/src/handles/TimerHandle.cpp index ce6bad6264..bf0514a2de 100644 --- a/worker/src/handles/Timer.cpp +++ b/worker/src/handles/TimerHandle.cpp @@ -1,7 +1,7 @@ -#define MS_CLASS "Timer" +#define MS_CLASS "TimerHandle" // #define MS_LOG_DEV_LEVEL 3 -#include "handles/Timer.hpp" +#include "handles/TimerHandle.hpp" #include "DepLibUV.hpp" #include "Logger.hpp" #include "MediaSoupErrors.hpp" @@ -10,7 +10,7 @@ inline static void onTimer(uv_timer_t* handle) { - static_cast(handle->data)->OnUvTimer(); + static_cast(handle->data)->OnUvTimer(); } inline static void onClose(uv_handle_t* handle) @@ -20,7 +20,7 @@ inline static void onClose(uv_handle_t* handle) /* Instance methods. */ -Timer::Timer(Listener* listener) : listener(listener) +TimerHandle::TimerHandle(Listener* listener) : listener(listener) { MS_TRACE(); @@ -38,7 +38,7 @@ Timer::Timer(Listener* listener) : listener(listener) } } -Timer::~Timer() +TimerHandle::~TimerHandle() { MS_TRACE(); @@ -48,7 +48,7 @@ Timer::~Timer() } } -void Timer::Close() +void TimerHandle::Close() { MS_TRACE(); @@ -62,7 +62,7 @@ void Timer::Close() uv_close(reinterpret_cast(this->uvHandle), static_cast(onClose)); } -void Timer::Start(uint64_t timeout, uint64_t repeat) +void TimerHandle::Start(uint64_t timeout, uint64_t repeat) { MS_TRACE(); @@ -87,7 +87,7 @@ void Timer::Start(uint64_t timeout, uint64_t repeat) } } -void Timer::Stop() +void TimerHandle::Stop() { MS_TRACE(); @@ -104,7 +104,7 @@ void Timer::Stop() } } -void Timer::Reset() +void TimerHandle::Reset() { MS_TRACE(); @@ -132,7 +132,7 @@ void Timer::Reset() } } -void Timer::Restart() +void TimerHandle::Restart() { MS_TRACE(); @@ -155,7 +155,7 @@ void Timer::Restart() } } -inline void Timer::OnUvTimer() +inline void TimerHandle::OnUvTimer() { MS_TRACE(); diff --git a/worker/src/handles/UdpSocketHandler.cpp b/worker/src/handles/UdpSocketHandle.cpp similarity index 69% rename from worker/src/handles/UdpSocketHandler.cpp rename to worker/src/handles/UdpSocketHandle.cpp index 6cb7ef3702..e8cb2e20aa 100644 --- a/worker/src/handles/UdpSocketHandler.cpp +++ b/worker/src/handles/UdpSocketHandle.cpp @@ -1,7 +1,7 @@ -#define MS_CLASS "UdpSocketHandler" +#define MS_CLASS "UdpSocketHandle" // #define MS_LOG_DEV_LEVEL 3 -#include "handles/UdpSocketHandler.hpp" +#include "handles/UdpSocketHandle.hpp" #include "Logger.hpp" #include "MediaSoupErrors.hpp" #include "Utils.hpp" @@ -16,30 +16,36 @@ thread_local static uint8_t ReadBuffer[ReadBufferSize]; inline static void onAlloc(uv_handle_t* handle, size_t suggestedSize, uv_buf_t* buf) { - auto* socket = static_cast(handle->data); + auto* socket = static_cast(handle->data); if (socket) + { socket->OnUvRecvAlloc(suggestedSize, buf); + } } inline static void onRecv( uv_udp_t* handle, ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags) { - auto* socket = static_cast(handle->data); + auto* socket = static_cast(handle->data); if (socket) + { socket->OnUvRecv(nread, buf, addr, flags); + } } inline static void onSend(uv_udp_send_t* req, int status) { - auto* sendData = static_cast(req->data); + auto* sendData = static_cast(req->data); auto* handle = req->handle; - auto* socket = static_cast(handle->data); + auto* socket = static_cast(handle->data); auto* cb = sendData->cb; if (socket) + { socket->OnUvSend(status, cb); + } // Delete the UvSendData struct (it will delete the store and cb too). delete sendData; @@ -53,7 +59,7 @@ inline static void onClose(uv_handle_t* handle) /* Instance methods. */ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) -UdpSocketHandler::UdpSocketHandler(uv_udp_t* uvHandle) : uvHandle(uvHandle) +UdpSocketHandle::UdpSocketHandle(uv_udp_t* uvHandle) : uvHandle(uvHandle) { MS_TRACE(); @@ -80,46 +86,52 @@ UdpSocketHandler::UdpSocketHandler(uv_udp_t* uvHandle) : uvHandle(uvHandle) } } -UdpSocketHandler::~UdpSocketHandler() +UdpSocketHandle::~UdpSocketHandle() { MS_TRACE(); if (!this->closed) + { Close(); + } } -void UdpSocketHandler::Close() +void UdpSocketHandle::Close() { MS_TRACE(); if (this->closed) + { return; + } this->closed = true; - // Tell the UV handle that the UdpSocketHandler has been closed. + // Tell the UV handle that the UdpSocketHandle has been closed. this->uvHandle->data = nullptr; // Don't read more. const int err = uv_udp_recv_stop(this->uvHandle); if (err != 0) + { MS_ABORT("uv_udp_recv_stop() failed: %s", uv_strerror(err)); + } uv_close(reinterpret_cast(this->uvHandle), static_cast(onClose)); } -void UdpSocketHandler::Dump() const +void UdpSocketHandle::Dump() const { - MS_DUMP(""); + MS_DUMP(""); MS_DUMP(" localIp : %s", this->localIp.c_str()); MS_DUMP(" localPort : %" PRIu16, static_cast(this->localPort)); MS_DUMP(" closed : %s", !this->closed ? "open" : "closed"); - MS_DUMP(""); + MS_DUMP(""); } -void UdpSocketHandler::Send( - const uint8_t* data, size_t len, const struct sockaddr* addr, UdpSocketHandler::onSendCallback* cb) +void UdpSocketHandle::Send( + const uint8_t* data, size_t len, const struct sockaddr* addr, UdpSocketHandle::onSendCallback* cb) { MS_TRACE(); @@ -204,7 +216,9 @@ void UdpSocketHandler::Send( MS_WARN_DEV("uv_udp_send() failed: %s", uv_strerror(err)); if (cb) + { (*cb)(false); + } // Delete the UvSendData struct (it will delete the store and cb too). delete sendData; @@ -216,7 +230,77 @@ void UdpSocketHandler::Send( } } -bool UdpSocketHandler::SetLocalAddress() +uint32_t UdpSocketHandle::GetSendBufferSize() const +{ + MS_TRACE(); + + int size{ 0 }; + int err = uv_send_buffer_size(reinterpret_cast(this->uvHandle), std::addressof(size)); + + if (err) + { + MS_THROW_ERROR("uv_send_buffer_size() failed: %s", uv_strerror(err)); + } + + return static_cast(size); +} + +void UdpSocketHandle::SetSendBufferSize(uint32_t size) +{ + MS_TRACE(); + + auto size_int = static_cast(size); + + if (size_int <= 0) + { + MS_THROW_TYPE_ERROR("invalid size: %d", size_int); + } + + int err = + uv_send_buffer_size(reinterpret_cast(this->uvHandle), std::addressof(size_int)); + + if (err) + { + MS_THROW_ERROR("uv_send_buffer_size() failed: %s", uv_strerror(err)); + } +} + +uint32_t UdpSocketHandle::GetRecvBufferSize() const +{ + MS_TRACE(); + + int size{ 0 }; + int err = uv_recv_buffer_size(reinterpret_cast(this->uvHandle), std::addressof(size)); + + if (err) + { + MS_THROW_ERROR("uv_recv_buffer_size() failed: %s", uv_strerror(err)); + } + + return static_cast(size); +} + +void UdpSocketHandle::SetRecvBufferSize(uint32_t size) +{ + MS_TRACE(); + + auto size_int = static_cast(size); + + if (size_int <= 0) + { + MS_THROW_TYPE_ERROR("invalid size: %d", size_int); + } + + int err = + uv_recv_buffer_size(reinterpret_cast(this->uvHandle), std::addressof(size_int)); + + if (err) + { + MS_THROW_ERROR("uv_recv_buffer_size() failed: %s", uv_strerror(err)); + } +} + +bool UdpSocketHandle::SetLocalAddress() { MS_TRACE(); @@ -241,7 +325,7 @@ bool UdpSocketHandler::SetLocalAddress() return true; } -inline void UdpSocketHandler::OnUvRecvAlloc(size_t /*suggestedSize*/, uv_buf_t* buf) +inline void UdpSocketHandle::OnUvRecvAlloc(size_t /*suggestedSize*/, uv_buf_t* buf) { MS_TRACE(); @@ -251,14 +335,16 @@ inline void UdpSocketHandler::OnUvRecvAlloc(size_t /*suggestedSize*/, uv_buf_t* buf->len = ReadBufferSize; } -inline void UdpSocketHandler::OnUvRecv( +inline void UdpSocketHandle::OnUvRecv( ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags) { MS_TRACE(); // NOTE: Ignore if there is nothing to read or if it was an empty datagram. if (nread == 0) + { return; + } // Check flags. if ((flags & UV_UDP_PARTIAL) != 0u) @@ -284,7 +370,7 @@ inline void UdpSocketHandler::OnUvRecv( } } -inline void UdpSocketHandler::OnUvSend(int status, UdpSocketHandler::onSendCallback* cb) +inline void UdpSocketHandle::OnUvSend(int status, UdpSocketHandle::onSendCallback* cb) { MS_TRACE(); @@ -293,7 +379,9 @@ inline void UdpSocketHandler::OnUvSend(int status, UdpSocketHandler::onSendCallb if (status == 0) { if (cb) + { (*cb)(true); + } } else { @@ -302,6 +390,8 @@ inline void UdpSocketHandler::OnUvSend(int status, UdpSocketHandler::onSendCallb #endif if (cb) + { (*cb)(false); + } } } diff --git a/worker/src/handles/UnixStreamSocket.cpp b/worker/src/handles/UnixStreamSocketHandle.cpp similarity index 68% rename from worker/src/handles/UnixStreamSocket.cpp rename to worker/src/handles/UnixStreamSocketHandle.cpp index 8f4f5b5aca..ffa4aec0e5 100644 --- a/worker/src/handles/UnixStreamSocket.cpp +++ b/worker/src/handles/UnixStreamSocketHandle.cpp @@ -3,10 +3,10 @@ * Channel. */ -#define MS_CLASS "UnixStreamSocket" +#define MS_CLASS "UnixStreamSocketHandle" // #define MS_LOG_DEV_LEVEL 3 -#include "handles/UnixStreamSocket.hpp" +#include "handles/UnixStreamSocketHandle.hpp" #include "DepLibUV.hpp" #include "Logger.hpp" #include "MediaSoupErrors.hpp" @@ -16,29 +16,35 @@ inline static void onAlloc(uv_handle_t* handle, size_t suggestedSize, uv_buf_t* buf) { - auto* socket = static_cast(handle->data); + auto* socket = static_cast(handle->data); if (socket) + { socket->OnUvReadAlloc(suggestedSize, buf); + } } inline static void onRead(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { - auto* socket = static_cast(handle->data); + auto* socket = static_cast(handle->data); if (socket) + { socket->OnUvRead(nread, buf); + } } inline static void onWrite(uv_write_t* req, int status) { - auto* writeData = static_cast(req->data); + auto* writeData = static_cast(req->data); auto* handle = req->handle; - auto* socket = static_cast(handle->data); + auto* socket = static_cast(handle->data); - // Just notify the UnixStreamSocket when error. + // Just notify the UnixStreamSocketHandle when error. if (socket && status != 0) + { socket->OnUvWriteError(status); + } // Delete the UvWriteData struct. delete writeData; @@ -61,7 +67,8 @@ inline static void onShutdown(uv_shutdown_t* req, int /*status*/) /* Instance methods. */ -UnixStreamSocket::UnixStreamSocket(int fd, size_t bufferSize, UnixStreamSocket::Role role) +UnixStreamSocketHandle::UnixStreamSocketHandle( + int fd, size_t bufferSize, UnixStreamSocketHandle::Role role) : bufferSize(bufferSize), role(role) { MS_TRACE_STD(); @@ -90,7 +97,7 @@ UnixStreamSocket::UnixStreamSocket(int fd, size_t bufferSize, UnixStreamSocket:: MS_THROW_ERROR_STD("uv_pipe_open() failed: %s", uv_strerror(err)); } - if (this->role == UnixStreamSocket::Role::CONSUMER) + if (this->role == UnixStreamSocketHandle::Role::CONSUMER) { // Start reading. err = uv_read_start( @@ -109,41 +116,47 @@ UnixStreamSocket::UnixStreamSocket(int fd, size_t bufferSize, UnixStreamSocket:: // NOTE: Don't allocate the buffer here. Instead wait for the first uv_alloc_cb(). } -UnixStreamSocket::~UnixStreamSocket() +UnixStreamSocketHandle::~UnixStreamSocketHandle() { MS_TRACE_STD(); delete[] this->buffer; if (!this->closed) + { Close(); + } } -void UnixStreamSocket::Close() +void UnixStreamSocketHandle::Close() { MS_TRACE_STD(); if (this->closed) + { return; + } int err; this->closed = true; - // Tell the UV handle that the UnixStreamSocket has been closed. + // Tell the UV handle that the UnixStreamSocketHandle has been closed. this->uvHandle->data = nullptr; - if (this->role == UnixStreamSocket::Role::CONSUMER) + if (this->role == UnixStreamSocketHandle::Role::CONSUMER) { // Don't read more. err = uv_read_stop(reinterpret_cast(this->uvHandle)); if (err != 0) + { MS_ABORT("uv_read_stop() failed: %s", uv_strerror(err)); + } } // If there is no error and the peer didn't close its pipe side then close gracefully. - if (this->role == UnixStreamSocket::Role::PRODUCER && !this->hasError && !this->isClosedByPeer) + if (this->role == UnixStreamSocketHandle::Role::PRODUCER && !this->hasError && !this->isClosedByPeer) { // Use uv_shutdown() so pending data to be written will be sent to the peer before closing. auto* req = new uv_shutdown_t; @@ -152,7 +165,9 @@ void UnixStreamSocket::Close() req, reinterpret_cast(this->uvHandle), static_cast(onShutdown)); if (err != 0) + { MS_ABORT("uv_shutdown() failed: %s", uv_strerror(err)); + } } // Otherwise directly close the socket. else @@ -161,15 +176,19 @@ void UnixStreamSocket::Close() } } -void UnixStreamSocket::Write(const uint8_t* data, size_t len) +void UnixStreamSocketHandle::Write(const uint8_t* data, size_t len) { MS_TRACE_STD(); if (this->closed) + { return; + } if (len == 0) + { return; + } // First try uv_try_write(). In case it can not directly send all the given data // then build a uv_req_t and use uv_write(). @@ -221,13 +240,85 @@ void UnixStreamSocket::Write(const uint8_t* data, size_t len) } } -inline void UnixStreamSocket::OnUvReadAlloc(size_t /*suggestedSize*/, uv_buf_t* buf) +uint32_t UnixStreamSocketHandle::GetSendBufferSize() const +{ + MS_TRACE(); + + int size{ 0 }; + int err = uv_send_buffer_size(reinterpret_cast(this->uvHandle), std::addressof(size)); + + if (err) + { + MS_THROW_ERROR_STD("uv_send_buffer_size() failed: %s", uv_strerror(err)); + } + + return static_cast(size); +} + +void UnixStreamSocketHandle::SetSendBufferSize(uint32_t size) +{ + MS_TRACE(); + + auto size_int = static_cast(size); + + if (size_int <= 0) + { + MS_THROW_TYPE_ERROR_STD("invalid size: %d", size_int); + } + + int err = + uv_send_buffer_size(reinterpret_cast(this->uvHandle), std::addressof(size_int)); + + if (err) + { + MS_THROW_ERROR_STD("uv_send_buffer_size() failed: %s", uv_strerror(err)); + } +} + +uint32_t UnixStreamSocketHandle::GetRecvBufferSize() const +{ + MS_TRACE(); + + int size{ 0 }; + int err = uv_recv_buffer_size(reinterpret_cast(this->uvHandle), std::addressof(size)); + + if (err) + { + MS_THROW_ERROR_STD("uv_recv_buffer_size() failed: %s", uv_strerror(err)); + } + + return static_cast(size); +} + +void UnixStreamSocketHandle::SetRecvBufferSize(uint32_t size) +{ + MS_TRACE(); + + auto size_int = static_cast(size); + + if (size_int <= 0) + { + MS_THROW_TYPE_ERROR_STD("invalid size: %d", size_int); + } + + int err = + uv_recv_buffer_size(reinterpret_cast(this->uvHandle), std::addressof(size_int)); + + if (err) + { + MS_THROW_ERROR_STD("uv_recv_buffer_size() failed: %s", uv_strerror(err)); + } +} + +inline void UnixStreamSocketHandle::OnUvReadAlloc(size_t /*suggestedSize*/, uv_buf_t* buf) { MS_TRACE_STD(); // If this is the first call to onUvReadAlloc() then allocate the receiving buffer now. if (!this->buffer) + { this->buffer = new uint8_t[this->bufferSize]; + } // Tell UV to write after the last data byte in the buffer. buf->base = reinterpret_cast(this->buffer + this->bufferDataLen); @@ -245,12 +336,14 @@ inline void UnixStreamSocket::OnUvReadAlloc(size_t /*suggestedSize*/, uv_buf_t* } } -inline void UnixStreamSocket::OnUvRead(ssize_t nread, const uv_buf_t* /*buf*/) +inline void UnixStreamSocketHandle::OnUvRead(ssize_t nread, const uv_buf_t* /*buf*/) { MS_TRACE_STD(); if (nread == 0) + { return; + } // Data received. if (nread > 0) @@ -287,12 +380,14 @@ inline void UnixStreamSocket::OnUvRead(ssize_t nread, const uv_buf_t* /*buf*/) } } -inline void UnixStreamSocket::OnUvWriteError(int error) +inline void UnixStreamSocketHandle::OnUvWriteError(int error) { MS_TRACE_STD(); if (error != UV_EPIPE && error != UV_ENOTCONN) + { this->hasError = true; + } MS_ERROR_STD("write error, closing the pipe: %s", uv_strerror(error)); From 6594f0755e3905114ac5b7fc55618c2fc2c43981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Fri, 2 Jun 2023 15:37:45 +0200 Subject: [PATCH 04/73] PlainTransportOptions: add optional rtcpListenInfo (#1099) --- node/src/PlainTransport.ts | 5 ++ node/src/Router.ts | 19 ++++++ node/src/tests/test-PlainTransport.ts | 11 ++-- rust/src/router/plain_transport.rs | 3 + rust/tests/integration/plain_transport.rs | 16 ++++- worker/fbs/plainTransport.fbs | 1 + worker/include/RTC/PlainTransport.hpp | 1 + worker/src/RTC/PipeTransport.cpp | 4 +- worker/src/RTC/PlainTransport.cpp | 71 ++++++++++++++++++----- 9 files changed, 111 insertions(+), 20 deletions(-) diff --git a/node/src/PlainTransport.ts b/node/src/PlainTransport.ts index 9d7629dc10..d82b713e19 100644 --- a/node/src/PlainTransport.ts +++ b/node/src/PlainTransport.ts @@ -36,6 +36,11 @@ type PlainTransportListenInfo = * Listening info. */ listenInfo: TransportListenInfo; + + /** + * Optional listening info for RTCP. + */ + rtcpListenInfo?: TransportListenInfo; }; type PlainTransportListenIp = diff --git a/node/src/Router.ts b/node/src/Router.ts index 424e554abf..1c4712eb1f 100644 --- a/node/src/Router.ts +++ b/node/src/Router.ts @@ -615,6 +615,7 @@ export class Router async createPlainTransport( { listenInfo, + rtcpListenInfo, listenIp, port, rtcpMux = true, @@ -644,6 +645,14 @@ export class Router throw new TypeError('if given, appData must be an object'); } + // If rtcpMux is enabled, ignore rtcpListenInfo. + if (rtcpMux) + { + logger.warn('createPlainTransport() | ignoring given rtcpListenInfo since rtcpMux is enabled'); + + rtcpListenInfo = undefined; + } + // Convert deprecated TransportListenIps to TransportListenInfos. if (listenIp) { @@ -688,6 +697,16 @@ export class Router listenInfo!.sendBufferSize, listenInfo!.recvBufferSize ), + rtcpListenInfo ? new FbsTransport.ListenInfoT( + rtcpListenInfo.protocol === 'udp' + ? FbsTransportProtocol.UDP + : FbsTransportProtocol.TCP, + rtcpListenInfo.ip, + rtcpListenInfo.announcedIp, + rtcpListenInfo.port, + rtcpListenInfo.sendBufferSize, + rtcpListenInfo.recvBufferSize + ) : undefined, rtcpMux, comedia, enableSrtp, diff --git a/node/src/tests/test-PlainTransport.ts b/node/src/tests/test-PlainTransport.ts index 69cf391331..d64f93b467 100644 --- a/node/src/tests/test-PlainTransport.ts +++ b/node/src/tests/test-PlainTransport.ts @@ -119,10 +119,13 @@ test('router.createPlainTransport() succeeds', async () => expect(typeof anotherTransport).toBe('object'); + const rtpPort = await pickPort({ ip: '127.0.0.1', reserveTimeout: 0 }); + const rtcpPort = await pickPort({ ip: '127.0.0.1', reserveTimeout: 0 }); const transport2 = await router.createPlainTransport( { - listenInfo : { protocol: 'udp', ip: '127.0.0.1' }, - rtcpMux : false + listenInfo : { protocol: 'udp', ip: '127.0.0.1', port: rtpPort }, + rtcpListenInfo : { protocol: 'udp', ip: '127.0.0.1', port: rtcpPort }, + rtcpMux : false }); expect(typeof transport2.id).toBe('string'); @@ -130,11 +133,11 @@ test('router.createPlainTransport() succeeds', async () => expect(transport2.appData).toEqual({}); expect(typeof transport2.tuple).toBe('object'); expect(transport2.tuple.localIp).toBe('127.0.0.1'); - expect(typeof transport2.tuple.localPort).toBe('number'); + expect(transport2.tuple.localPort).toBe(rtpPort); expect(transport2.tuple.protocol).toBe('udp'); expect(typeof transport2.rtcpTuple).toBe('object'); expect(transport2.rtcpTuple?.localIp).toBe('127.0.0.1'); - expect(typeof transport2.rtcpTuple?.localPort).toBe('number'); + expect(transport2.rtcpTuple?.localPort).toBe(rtcpPort); expect(transport2.rtcpTuple?.protocol).toBe('udp'); expect(transport2.sctpParameters).toBeUndefined(); expect(transport2.sctpState).toBeUndefined(); diff --git a/rust/src/router/plain_transport.rs b/rust/src/router/plain_transport.rs index 0574a91c61..12ef25c8fb 100644 --- a/rust/src/router/plain_transport.rs +++ b/rust/src/router/plain_transport.rs @@ -44,6 +44,8 @@ use std::sync::{Arc, Weak}; pub struct PlainTransportOptions { /// Listening info. pub listen_info: ListenInfo, + /// Optional listening info for RTCP. + pub rtcp_listen_info: Option, /// Use RTCP-mux (RTP and RTCP in the same port). /// Default true. pub rtcp_mux: bool, @@ -79,6 +81,7 @@ impl PlainTransportOptions { pub fn new(listen_info: ListenInfo) -> Self { Self { listen_info, + rtcp_listen_info: None, rtcp_mux: true, comedia: false, enable_sctp: false, diff --git a/rust/tests/integration/plain_transport.rs b/rust/tests/integration/plain_transport.rs index 9c0be9bedc..761d102be9 100644 --- a/rust/tests/integration/plain_transport.rs +++ b/rust/tests/integration/plain_transport.rs @@ -197,6 +197,7 @@ fn create_succeeds() { } { + let rtcp_port = pick_unused_port().unwrap(); let transport2 = router .create_plain_transport({ let mut plain_transport_options = PlainTransportOptions::new(ListenInfo { @@ -209,6 +210,15 @@ fn create_succeeds() { }); plain_transport_options.rtcp_mux = false; + plain_transport_options.rtcp_listen_info = Some(ListenInfo { + protocol: Protocol::Udp, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, + port: Some(rtcp_port), + send_buffer_size: None, + recv_buffer_size: None, + }); + plain_transport_options }) .await @@ -229,10 +239,14 @@ fn create_succeeds() { } assert!(transport2.rtcp_tuple().is_some()); if let TransportTuple::LocalOnly { - local_ip, protocol, .. + local_ip, + local_port, + protocol, + .. } = transport2.rtcp_tuple().unwrap() { assert_eq!(local_ip, "127.0.0.1".parse::().unwrap()); + assert_eq!(local_port, rtcp_port); assert_eq!(protocol, Protocol::Udp); } assert_eq!(transport2.srtp_parameters(), None); diff --git a/worker/fbs/plainTransport.fbs b/worker/fbs/plainTransport.fbs index fbcebb985c..20a1baec18 100644 --- a/worker/fbs/plainTransport.fbs +++ b/worker/fbs/plainTransport.fbs @@ -6,6 +6,7 @@ namespace FBS.PlainTransport; table PlainTransportOptions { base:FBS.Transport.Options; listen_info:FBS.Transport.ListenInfo (required); + rtcp_listen_info:FBS.Transport.ListenInfo; rtcp_mux:bool; comedia:bool; enable_srtp:bool; diff --git a/worker/include/RTC/PlainTransport.hpp b/worker/include/RTC/PlainTransport.hpp index 0e08d5e302..202dcc6a21 100644 --- a/worker/include/RTC/PlainTransport.hpp +++ b/worker/include/RTC/PlainTransport.hpp @@ -77,6 +77,7 @@ namespace RTC RTC::SrtpSession* srtpSendSession{ nullptr }; // Others. ListenInfo listenInfo; + ListenInfo rtcpListenInfo; bool rtcpMux{ true }; bool comedia{ false }; struct sockaddr_storage remoteAddrStorage; diff --git a/worker/src/RTC/PipeTransport.cpp b/worker/src/RTC/PipeTransport.cpp index f7b10cc705..9b4a32672e 100644 --- a/worker/src/RTC/PipeTransport.cpp +++ b/worker/src/RTC/PipeTransport.cpp @@ -88,13 +88,13 @@ namespace RTC if (this->listenInfo.sendBufferSize != 0) { // NOTE: This may throw. - udpSocket->SetSendBufferSize(this->listenInfo.sendBufferSize); + this->udpSocket->SetSendBufferSize(this->listenInfo.sendBufferSize); } if (this->listenInfo.recvBufferSize != 0) { // NOTE: This may throw. - udpSocket->SetRecvBufferSize(this->listenInfo.recvBufferSize); + this->udpSocket->SetRecvBufferSize(this->listenInfo.recvBufferSize); } MS_DEBUG_TAG( diff --git a/worker/src/RTC/PlainTransport.cpp b/worker/src/RTC/PlainTransport.cpp index aa2dceafb8..4d7f505585 100644 --- a/worker/src/RTC/PlainTransport.cpp +++ b/worker/src/RTC/PlainTransport.cpp @@ -83,6 +83,44 @@ namespace RTC this->rtcpMux = options->rtcpMux(); this->comedia = options->comedia(); + if (!this->rtcpMux) + { + if (flatbuffers::IsFieldPresent(options, FBS::PlainTransport::PlainTransportOptions::VT_RTCPLISTENINFO)) + { + if (options->rtcpListenInfo()->protocol() != FBS::Transport::Protocol::UDP) + { + MS_THROW_TYPE_ERROR("unsupported RTCP listen protocol"); + } + + this->rtcpListenInfo.ip.assign(options->rtcpListenInfo()->ip()->str()); + + // This may throw. + Utils::IP::NormalizeIp(this->rtcpListenInfo.ip); + + if (flatbuffers::IsFieldPresent(options->rtcpListenInfo(), FBS::Transport::ListenInfo::VT_ANNOUNCEDIP)) + { + this->rtcpListenInfo.announcedIp.assign(options->rtcpListenInfo()->announcedIp()->str()); + } + + this->rtcpListenInfo.port = options->rtcpListenInfo()->port(); + + if (flatbuffers::IsFieldPresent(options->rtcpListenInfo(), FBS::Transport::ListenInfo::VT_SENDBUFFERSIZE)) + { + this->rtcpListenInfo.sendBufferSize = options->rtcpListenInfo()->sendBufferSize(); + } + + if (flatbuffers::IsFieldPresent(options->rtcpListenInfo(), FBS::Transport::ListenInfo::VT_RECVBUFFERSIZE)) + { + this->rtcpListenInfo.recvBufferSize = options->rtcpListenInfo()->recvBufferSize(); + } + } + // If rtcpListenInfo is not given, just clone listenInfo. + else + { + this->rtcpListenInfo = this->listenInfo; + } + } + if (options->enableSrtp()) { if (!flatbuffers::IsFieldPresent( @@ -151,30 +189,37 @@ namespace RTC if (this->listenInfo.sendBufferSize != 0) { // NOTE: This may throw. - udpSocket->SetSendBufferSize(this->listenInfo.sendBufferSize); + this->udpSocket->SetSendBufferSize(this->listenInfo.sendBufferSize); } if (this->listenInfo.recvBufferSize != 0) { // NOTE: This may throw. - udpSocket->SetRecvBufferSize(this->listenInfo.recvBufferSize); + this->udpSocket->SetRecvBufferSize(this->listenInfo.recvBufferSize); } if (!this->rtcpMux) { // This may throw. - this->rtcpUdpSocket = new RTC::UdpSocket(this, this->listenInfo.ip); + if (this->rtcpListenInfo.port != 0) + { + this->rtcpUdpSocket = new RTC::UdpSocket(this, this->rtcpListenInfo.ip, this->rtcpListenInfo.port); + } + else + { + this->rtcpUdpSocket = new RTC::UdpSocket(this, this->rtcpListenInfo.ip); + } - if (this->listenInfo.sendBufferSize != 0) + if (this->rtcpListenInfo.sendBufferSize != 0) { // NOTE: This may throw. - rtcpUdpSocket->SetSendBufferSize(this->listenInfo.sendBufferSize); + this->rtcpUdpSocket->SetSendBufferSize(this->rtcpListenInfo.sendBufferSize); } - if (this->listenInfo.recvBufferSize != 0) + if (this->rtcpListenInfo.recvBufferSize != 0) { // NOTE: This may throw. - rtcpUdpSocket->SetRecvBufferSize(this->listenInfo.recvBufferSize); + this->rtcpUdpSocket->SetRecvBufferSize(this->rtcpListenInfo.recvBufferSize); } } @@ -263,13 +308,13 @@ namespace RTC { std::string localIp; - if (this->listenInfo.announcedIp.empty()) + if (this->rtcpListenInfo.announcedIp.empty()) { localIp = this->rtcpUdpSocket->GetLocalIp(); } else { - localIp = this->listenInfo.announcedIp; + localIp = this->rtcpListenInfo.announcedIp; } rtcpTuple = FBS::Transport::CreateTupleDirect( @@ -645,9 +690,9 @@ namespace RTC this->rtcpUdpSocket, reinterpret_cast(&this->rtcpRemoteAddrStorage)); - if (!this->listenInfo.announcedIp.empty()) + if (!this->rtcpListenInfo.announcedIp.empty()) { - this->rtcpTuple->SetLocalAnnouncedIp(this->listenInfo.announcedIp); + this->rtcpTuple->SetLocalAnnouncedIp(this->rtcpListenInfo.announcedIp); } } } @@ -1076,9 +1121,9 @@ namespace RTC this->rtcpTuple = new RTC::TransportTuple(tuple); - if (!this->listenInfo.announcedIp.empty()) + if (!this->rtcpListenInfo.announcedIp.empty()) { - this->rtcpTuple->SetLocalAnnouncedIp(this->listenInfo.announcedIp); + this->rtcpTuple->SetLocalAnnouncedIp(this->rtcpListenInfo.announcedIp); } // Notify the Node PlainTransport. From 25ff0f046e9edfec68cbf0e8e91030e8aff33d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Tue, 6 Jun 2023 10:56:54 +0200 Subject: [PATCH 05/73] Remove explicit TypeError exceptions Already thown by flatbuffers. --- node/src/PipeTransport.ts | 53 ++++++++++------------ node/src/PlainTransport.ts | 61 ++++++++++++-------------- node/src/Router.ts | 2 +- node/src/WebRtcTransport.ts | 35 ++++++--------- node/src/tests/test-PipeTransport.ts | 4 +- node/src/tests/test-PlainTransport.ts | 4 +- node/src/tests/test-WebRtcServer.ts | 6 +-- node/src/tests/test-WebRtcTransport.ts | 4 +- 8 files changed, 69 insertions(+), 100 deletions(-) diff --git a/node/src/PipeTransport.ts b/node/src/PipeTransport.ts index 149d62c043..6021c58d0f 100644 --- a/node/src/PipeTransport.ts +++ b/node/src/PipeTransport.ts @@ -573,41 +573,34 @@ function createConnectRequest( } ): number { - try - { - let ipOffset = 0; - let srtpParametersOffset = 0; + let ipOffset = 0; + let srtpParametersOffset = 0; - if (ip) - { - ipOffset = builder.createString(ip); - } - - // Serialize SrtpParameters. - if (srtpParameters) - { - srtpParametersOffset = serializeSrtpParameters(builder, srtpParameters); - } + if (ip) + { + ipOffset = builder.createString(ip); + } - // Create PlainTransportConnectData. - FbsPipeTransport.ConnectRequest.startConnectRequest(builder); - FbsPipeTransport.ConnectRequest.addIp(builder, ipOffset); + // Serialize SrtpParameters. + if (srtpParameters) + { + srtpParametersOffset = serializeSrtpParameters(builder, srtpParameters); + } - if (typeof port === 'number') - { - FbsPipeTransport.ConnectRequest.addPort(builder, port); - } - if (srtpParameters) - { - FbsPipeTransport.ConnectRequest.addSrtpParameters( - builder, srtpParametersOffset - ); - } + // Create PlainTransportConnectData. + FbsPipeTransport.ConnectRequest.startConnectRequest(builder); + FbsPipeTransport.ConnectRequest.addIp(builder, ipOffset); - return FbsPipeTransport.ConnectRequest.endConnectRequest(builder); + if (typeof port === 'number') + { + FbsPipeTransport.ConnectRequest.addPort(builder, port); } - catch (error) + if (srtpParameters) { - throw new TypeError(`${error}`); + FbsPipeTransport.ConnectRequest.addSrtpParameters( + builder, srtpParametersOffset + ); } + + return FbsPipeTransport.ConnectRequest.endConnectRequest(builder); } diff --git a/node/src/PlainTransport.ts b/node/src/PlainTransport.ts index d82b713e19..778a0ab7f0 100644 --- a/node/src/PlainTransport.ts +++ b/node/src/PlainTransport.ts @@ -539,45 +539,38 @@ function createConnectRequest( } ): number { - try - { - let ipOffset = 0; - let srtpParametersOffset = 0; + let ipOffset = 0; + let srtpParametersOffset = 0; - if (ip) - { - ipOffset = builder.createString(ip); - } + if (ip) + { + ipOffset = builder.createString(ip); + } - // Serialize SrtpParameters. - if (srtpParameters) - { - srtpParametersOffset = serializeSrtpParameters(builder, srtpParameters); - } + // Serialize SrtpParameters. + if (srtpParameters) + { + srtpParametersOffset = serializeSrtpParameters(builder, srtpParameters); + } - // Create PlainTransportConnectData. - FbsPlainTransport.ConnectRequest.startConnectRequest(builder); - FbsPlainTransport.ConnectRequest.addIp(builder, ipOffset); + // Create PlainTransportConnectData. + FbsPlainTransport.ConnectRequest.startConnectRequest(builder); + FbsPlainTransport.ConnectRequest.addIp(builder, ipOffset); - if (typeof port === 'number') - { - FbsPlainTransport.ConnectRequest.addPort(builder, port); - } - if (typeof rtcpPort === 'number') - { - FbsPlainTransport.ConnectRequest.addRtcpPort(builder, rtcpPort); - } - if (srtpParameters) - { - FbsPlainTransport.ConnectRequest.addSrtpParameters( - builder, srtpParametersOffset - ); - } - - return FbsPlainTransport.ConnectRequest.endConnectRequest(builder); + if (typeof port === 'number') + { + FbsPlainTransport.ConnectRequest.addPort(builder, port); } - catch (error) + if (typeof rtcpPort === 'number') { - throw new TypeError(`${error}`); + FbsPlainTransport.ConnectRequest.addRtcpPort(builder, rtcpPort); } + if (srtpParameters) + { + FbsPlainTransport.ConnectRequest.addSrtpParameters( + builder, srtpParametersOffset + ); + } + + return FbsPlainTransport.ConnectRequest.endConnectRequest(builder); } diff --git a/node/src/Router.ts b/node/src/Router.ts index 1c4712eb1f..9fe609bf6a 100644 --- a/node/src/Router.ts +++ b/node/src/Router.ts @@ -432,7 +432,7 @@ export class Router (typeof numSctpStreams.OS !== 'number' || typeof numSctpStreams.MIS !== 'number') ) { - throw new TypeError('if given, numSctpStreams must contain OS and MID'); + throw new TypeError('if given, numSctpStreams must contain OS and MIS'); } else if (appData && typeof appData !== 'object') { diff --git a/node/src/WebRtcTransport.ts b/node/src/WebRtcTransport.ts index d7277e832b..2a3c75a159 100644 --- a/node/src/WebRtcTransport.ts +++ b/node/src/WebRtcTransport.ts @@ -783,29 +783,22 @@ function serializeDtlsParameters( { const fingerprints: number[] = []; - try + for (const fingerprint of dtlsParameters.fingerprints) { - for (const fingerprint of dtlsParameters.fingerprints) - { - const algorithmOffset = builder.createString(fingerprint.algorithm); - const valueOffset = builder.createString(fingerprint.value); - const fingerprintOffset = FbsWebRtcTransport.Fingerprint.createFingerprint( - builder, algorithmOffset, valueOffset); + const algorithmOffset = builder.createString(fingerprint.algorithm); + const valueOffset = builder.createString(fingerprint.value); + const fingerprintOffset = FbsWebRtcTransport.Fingerprint.createFingerprint( + builder, algorithmOffset, valueOffset); - fingerprints.push(fingerprintOffset); - } + fingerprints.push(fingerprintOffset); + } - const fingerprintsOffset = FbsWebRtcTransport.DtlsParameters.createFingerprintsVector( - builder, fingerprints); - const roleOffset = builder.createString(dtlsParameters.role); + const fingerprintsOffset = FbsWebRtcTransport.DtlsParameters.createFingerprintsVector( + builder, fingerprints); + const roleOffset = builder.createString(dtlsParameters.role); - return FbsWebRtcTransport.DtlsParameters.createDtlsParameters( - builder, - fingerprintsOffset, - roleOffset); - } - catch (error) - { - throw new TypeError(`${error}`); - } + return FbsWebRtcTransport.DtlsParameters.createDtlsParameters( + builder, + fingerprintsOffset, + roleOffset); } diff --git a/node/src/tests/test-PipeTransport.ts b/node/src/tests/test-PipeTransport.ts index 23ba30a7f2..6686e6a5e6 100644 --- a/node/src/tests/test-PipeTransport.ts +++ b/node/src/tests/test-PipeTransport.ts @@ -477,12 +477,10 @@ test('router.createPipeTransport() with wrong arguments rejects with TypeError', .rejects .toThrow(TypeError); - // TODO: Ideally this should reject with TypeError. See: - // https://github.com/versatica/mediasoup/pull/927#issuecomment-1507188359 // @ts-ignore await expect(router1.createPipeTransport({ listenIp: [ '127.0.0.1' ] })) .rejects - .toThrow(Error); + .toThrow(TypeError); await expect(router1.createPipeTransport( { diff --git a/node/src/tests/test-PlainTransport.ts b/node/src/tests/test-PlainTransport.ts index d64f93b467..4b45c1289b 100644 --- a/node/src/tests/test-PlainTransport.ts +++ b/node/src/tests/test-PlainTransport.ts @@ -162,12 +162,10 @@ test('router.createPlainTransport() with wrong arguments rejects with TypeError' .rejects .toThrow(TypeError); - // TODO: Ideally this should reject with TypeError. See: - // https://github.com/versatica/mediasoup/pull/927#issuecomment-1507188359 // @ts-ignore await expect(router.createPlainTransport({ listenIp: [ '127.0.0.1' ] })) .rejects - .toThrow(Error); + .toThrow(TypeError); await expect(router.createPipeTransport( { diff --git a/node/src/tests/test-WebRtcServer.ts b/node/src/tests/test-WebRtcServer.ts index b8edf82726..f6653dc82a 100644 --- a/node/src/tests/test-WebRtcServer.ts +++ b/node/src/tests/test-WebRtcServer.ts @@ -172,15 +172,11 @@ test('worker.createWebRtcServer() with wrong arguments rejects with TypeError', .rejects .toThrow(TypeError); - // TODO: Ideally this should reject with TypeError. See: - // https://github.com/versatica/mediasoup/pull/927#issuecomment-1507188359 // @ts-ignore await expect(worker.createWebRtcServer({ listenInfos: 'NOT-AN-ARRAY' })) .rejects - .toThrow(Error); + .toThrow(TypeError); - // TODO: Ideally this should reject with TypeError. See: - // https://github.com/versatica/mediasoup/pull/927#issuecomment-1507188359 // @ts-ignore await expect(worker.createWebRtcServer({ listenInfos: [ 'NOT-AN-OBJECT' ] })) .rejects diff --git a/node/src/tests/test-WebRtcTransport.ts b/node/src/tests/test-WebRtcTransport.ts index acd1651f18..6cd790b8d8 100644 --- a/node/src/tests/test-WebRtcTransport.ts +++ b/node/src/tests/test-WebRtcTransport.ts @@ -189,12 +189,10 @@ test('router.createWebRtcTransport() with wrong arguments rejects with TypeError .rejects .toThrow(TypeError); - // TODO: Ideally this should reject with TypeError. See: - // https://github.com/versatica/mediasoup/pull/927#issuecomment-1507188359 // @ts-ignore await expect(router.createWebRtcTransport({ listenIps: [ 123 ] })) .rejects - .toThrow(Error); + .toThrow(TypeError); // @ts-ignore await expect(router.createWebRtcTransport({ listenInfos: '127.0.0.1' })) From 7a9296975320199c0b6337c9b3d44adff03a763a Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Tue, 18 Apr 2023 14:16:41 +0300 Subject: [PATCH 06/73] Rust: WIP --- node/src/Channel.ts | 2 +- node/src/PipeTransport.ts | 4 +- node/src/PlainTransport.ts | 4 +- node/src/Transport.ts | 32 +- node/src/WebRtcTransport.ts | 4 +- node/src/tests/test-DirectTransport.ts | 2 +- node/src/tests/test-PlainTransport.ts | 2 +- node/src/tests/test-WebRtcTransport.ts | 2 +- rust/src/data_structures.rs | 13 + rust/src/fbs.rs | 1715 +++++++++----------- rust/src/macros.rs | 14 +- rust/src/messages.rs | 751 ++++++++- rust/src/router.rs | 8 +- rust/src/router/direct_transport.rs | 155 +- rust/src/router/pipe_transport.rs | 7 + rust/src/router/plain_transport.rs | 7 + rust/src/router/transport.rs | 91 +- rust/src/router/webrtc_transport.rs | 7 + rust/src/sctp_parameters.rs | 14 +- rust/src/webrtc_server.rs | 27 +- rust/src/worker.rs | 60 +- rust/src/worker/channel.rs | 49 +- rust/src/worker/utils.rs | 7 +- rust/tests/integration/direct_transport.rs | 1 + worker/Makefile | 2 +- worker/fbs/common.fbs | 2 +- worker/fbs/notification.fbs | 2 +- worker/fbs/request.fbs | 2 +- worker/fbs/router.fbs | 14 +- worker/fbs/transport.fbs | 42 +- worker/fbs/webRtcServer.fbs | 10 +- worker/fbs/worker.fbs | 12 +- worker/src/RTC/DirectTransport.cpp | 2 +- worker/src/RTC/Transport.cpp | 95 +- 34 files changed, 1927 insertions(+), 1234 deletions(-) diff --git a/node/src/Channel.ts b/node/src/Channel.ts index b2ca3f71e9..96969980bc 100644 --- a/node/src/Channel.ts +++ b/node/src/Channel.ts @@ -330,7 +330,7 @@ export class Channel extends EnhancedEventEmitter const id = this.#nextId; - const handlerIdOffset = this.#bufferBuilder.createString(handlerId); + const handlerIdOffset = this.#bufferBuilder.createString(handlerId ?? ''); let requestOffset: number; diff --git a/node/src/PipeTransport.ts b/node/src/PipeTransport.ts index 5f19519a49..defdc8344d 100644 --- a/node/src/PipeTransport.ts +++ b/node/src/PipeTransport.ts @@ -7,7 +7,7 @@ import { BaseTransportStats, parseBaseTransportDump, parseBaseTransportStats, - fbsSctpState2StcpState, + parseSctpState, parseTuple, parseTransportTraceEventData, Transport, @@ -421,7 +421,7 @@ export class PipeTransport data!.body(notification); - const sctpState = fbsSctpState2StcpState(notification.sctpState()); + const sctpState = parseSctpState(notification.sctpState()); this.#data.sctpState = sctpState; diff --git a/node/src/PlainTransport.ts b/node/src/PlainTransport.ts index 803442662e..4d95cfd09f 100644 --- a/node/src/PlainTransport.ts +++ b/node/src/PlainTransport.ts @@ -1,7 +1,7 @@ import * as flatbuffers from 'flatbuffers'; import { Logger } from './Logger'; import { - fbsSctpState2StcpState, + parseSctpState, BaseTransportDump, BaseTransportStats, parseTuple, @@ -413,7 +413,7 @@ export class PlainTransport data!.body(notification); - const sctpState = fbsSctpState2StcpState(notification.sctpState()); + const sctpState = parseSctpState(notification.sctpState()); this.#data.sctpState = sctpState; diff --git a/node/src/Transport.ts b/node/src/Transport.ts index c1cec39978..024f8392d8 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -155,7 +155,7 @@ export type BaseTransportDump = { consumerIds : string[]; mapSsrcConsumerId : { key: number; value: string }[]; mapRtxSsrcConsumerId : { key: number; value: string }[]; - recvRtpHeaderExtensions : { key: string; value: number }[]; + recvRtpHeaderExtensions : RecvRtpHeaderExtensions; rtpListener: RtpListenerDump; maxMessageSize: number; dataProducerIds : string[]; @@ -205,6 +205,14 @@ type SctpListenerDump = { streamIdTable : {key: number; value: string}[]; }; +type RecvRtpHeaderExtensions = { + mid?: number; + rid?: number; + rrid?: number; + absSendTime?: number; + transportWideCc01?: number; +}; + const logger = new Logger('Transport'); export class Transport @@ -1219,7 +1227,7 @@ export class Transport } } -export function fbsSctpState2StcpState(fbsSctpState: FbsSctpState): SctpState +export function parseSctpState(fbsSctpState: FbsSctpState): SctpState { switch (fbsSctpState) { @@ -1266,7 +1274,7 @@ export function parseBaseTransportDump( // Retrieve dataConsumerIds. const dataConsumerIds = utils.parseVector(binary, 'dataConsumerIds'); // Retrieve recvRtpHeaderExtesions. - const recvRtpHeaderExtensions = utils.parseStringUint8Vector(binary, 'recvRtpHeaderExtensions'); + const recvRtpHeaderExtensions = parseRecvRtpHeaderExtensions(binary.recvRtpHeaderExtensions()!); // Retrieve RtpListener. const rtpListener = parseRtpListenerDump(binary.rtpListener()!); @@ -1280,7 +1288,7 @@ export function parseBaseTransportDump( } // Retrieve sctpState. - const sctpState = binary.sctpState() === '' ? undefined : binary.sctpState() as SctpState; + const sctpState = binary.sctpState() === null ? undefined : parseSctpState(binary.sctpState()!); // Retrive sctpListener. const sctpListener = binary.sctpListener() ? @@ -1313,7 +1321,7 @@ export function parseBaseTransportStats( binary: FbsTransport.Stats ): BaseTransportStats { - const sctpState = binary.sctpState() === '' ? undefined : binary.sctpState() as SctpState; + const sctpState = binary.sctpState() === null ? undefined : parseSctpState(binary.sctpState()!); return { transportId : binary.transportId()!, @@ -1373,6 +1381,20 @@ export function parseTransportTraceEventData( } } +function parseRecvRtpHeaderExtensions(binary: FbsTransport.RecvRtpHeaderExtensions) + : RecvRtpHeaderExtensions +{ + return { + mid : binary.mid() !== null ? binary.mid()! : undefined, + rid : binary.rid() !== null ? binary.rid()! : undefined, + rrid : binary.rrid() !== null ? binary.rrid()! : undefined, + absSendTime : binary.absSendTime() !== null ? binary.absSendTime()! : undefined, + transportWideCc01 : binary.transportWideCc01() !== null ? + binary.transportWideCc01()! : + undefined + }; +} + function parseBweTraceInfo(binary: FbsTransport.BweTraceInfo): { desiredBitrate:number; diff --git a/node/src/WebRtcTransport.ts b/node/src/WebRtcTransport.ts index c5e43b9092..57bd4354d7 100644 --- a/node/src/WebRtcTransport.ts +++ b/node/src/WebRtcTransport.ts @@ -1,7 +1,7 @@ import * as flatbuffers from 'flatbuffers'; import { Logger } from './Logger'; import { - fbsSctpState2StcpState, + parseSctpState, parseBaseTransportDump, parseBaseTransportStats, parseTransportTraceEventData, @@ -580,7 +580,7 @@ export class WebRtcTransport data!.body(notification); - const sctpState = fbsSctpState2StcpState(notification.sctpState()); + const sctpState = parseSctpState(notification.sctpState()); this.#data.sctpState = sctpState; diff --git a/node/src/tests/test-DirectTransport.ts b/node/src/tests/test-DirectTransport.ts index a5d62c84d7..4167d2d23f 100644 --- a/node/src/tests/test-DirectTransport.ts +++ b/node/src/tests/test-DirectTransport.ts @@ -52,7 +52,7 @@ test('router.createDirectTransport() succeeds', async () => expect(data1.consumerIds).toEqual([]); expect(data1.dataProducerIds).toEqual([]); expect(data1.dataConsumerIds).toEqual([]); - expect(Array.isArray(data1.recvRtpHeaderExtensions)).toBe(true); + expect(data1.recvRtpHeaderExtensions).toBeDefined(); expect(typeof data1.rtpListener).toBe('object'); transport1.close(); diff --git a/node/src/tests/test-PlainTransport.ts b/node/src/tests/test-PlainTransport.ts index bee31c73d5..1630f9cc11 100644 --- a/node/src/tests/test-PlainTransport.ts +++ b/node/src/tests/test-PlainTransport.ts @@ -109,7 +109,7 @@ test('router.createPlainTransport() succeeds', async () => expect(data1.rtcpTuple).toEqual(transport1.rtcpTuple); expect(data1.sctpParameters).toEqual(transport1.sctpParameters); expect(data1.sctpState).toBe('new'); - expect(Array.isArray(data1.recvRtpHeaderExtensions)).toBe(true); + expect(data1.recvRtpHeaderExtensions).toBeDefined(); expect(typeof data1.rtpListener).toBe('object'); transport1.close(); diff --git a/node/src/tests/test-WebRtcTransport.ts b/node/src/tests/test-WebRtcTransport.ts index e5a9b4e19a..c4c122edca 100644 --- a/node/src/tests/test-WebRtcTransport.ts +++ b/node/src/tests/test-WebRtcTransport.ts @@ -166,7 +166,7 @@ test('router.createWebRtcTransport() succeeds', async () => expect(data1.dtlsState).toBe(transport1.dtlsState); expect(data1.sctpParameters).toEqual(transport1.sctpParameters); expect(data1.sctpState).toBe(transport1.sctpState); - expect(Array.isArray(data1.recvRtpHeaderExtensions)).toBe(true); + expect(data1.recvRtpHeaderExtensions).toBeDefined(); expect(typeof data1.rtpListener).toBe('object'); transport1.close(); diff --git a/rust/src/data_structures.rs b/rust/src/data_structures.rs index 3995f530cc..d1e18a4431 100644 --- a/rust/src/data_structures.rs +++ b/rust/src/data_structures.rs @@ -3,6 +3,7 @@ #[cfg(test)] mod tests; +use crate::fbs::sctp_association; use serde::de::{MapAccess, Visitor}; use serde::ser::SerializeStruct; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; @@ -266,6 +267,18 @@ pub enum SctpState { Closed, } +impl SctpState { + pub(crate) fn from_fbs(state: &sctp_association::SctpState) -> Self { + match state { + sctp_association::SctpState::New => Self::New, + sctp_association::SctpState::Connecting => Self::Connecting, + sctp_association::SctpState::Connected => Self::Connected, + sctp_association::SctpState::Failed => Self::Failed, + sctp_association::SctpState::Closed => Self::Closed, + } + } +} + /// DTLS role. #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index 7976abd4d4..20386acb08 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -1713,9 +1713,7 @@ mod root { )] pub struct StringStringArray { pub key: ::planus::alloc::string::String, - pub values: ::core::option::Option< - ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - >, + pub values: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, } impl StringStringArray { @@ -1723,9 +1721,7 @@ mod root { pub fn create( builder: &mut ::planus::Builder, field_key: impl ::planus::WriteAs<::planus::Offset>, - field_values: impl ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, + field_values: impl ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, ) -> ::planus::Offset { let prepared_key = field_key.prepare(builder); @@ -1735,17 +1731,13 @@ mod root { ::planus::table_writer::TableWriter::<6, 8>::new(builder); table_writer.calculate_size::<::planus::Offset>(2); - if prepared_values.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); - } + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); table_writer.finish_calculating(); unsafe { table_writer.write::<_, _, 4>(0, &prepared_key); - if let ::core::option::Option::Some(prepared_values) = prepared_values { - table_writer.write::<_, _, 4>(1, &prepared_values); - } + table_writer.write::<_, _, 4>(1, &prepared_values); } table_writer.finish() @@ -1794,11 +1786,9 @@ mod root { pub fn values( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - >, + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, > { - self.0.access(1, "StringStringArray", "values") + self.0.access_required(1, "StringStringArray", "values") } } @@ -1806,9 +1796,7 @@ mod root { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut f = f.debug_struct("StringStringArrayRef"); f.field("key", &self.key()); - if let ::core::option::Option::Some(field_values) = self.values().transpose() { - f.field("values", &field_values); - } + f.field("values", &self.values()); f.finish() } } @@ -1820,11 +1808,7 @@ mod root { fn try_from(value: StringStringArrayRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { key: ::core::convert::TryInto::try_into(value.key()?)?, - values: if let ::core::option::Option::Some(values) = value.values()? { - ::core::option::Option::Some(values.to_vec_result()?) - } else { - ::core::option::Option::None - }, + values: value.values()?.to_vec_result()?, }) } } @@ -18064,15 +18048,7 @@ mod root { } #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct GetStatsResponse { pub base: ::planus::alloc::boxed::Box, @@ -21436,6 +21412,314 @@ mod root { } } + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct RecvRtpHeaderExtensions { + pub mid: ::core::option::Option, + pub rid: ::core::option::Option, + pub rrid: ::core::option::Option, + pub abs_send_time: ::core::option::Option, + 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 { + #[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::<12, 5>::new(builder); + + if prepared_mid.is_some() { + table_writer.calculate_size::(2); + } + if prepared_rid.is_some() { + table_writer.calculate_size::(4); + } + if prepared_rrid.is_some() { + table_writer.calculate_size::(6); + } + if prepared_abs_send_time.is_some() { + table_writer.calculate_size::(8); + } + if prepared_transport_wide_cc01.is_some() { + table_writer.calculate_size::(10); + } + + table_writer.finish_calculating(); + + unsafe { + if let ::core::option::Option::Some(prepared_mid) = prepared_mid { + table_writer.write::<_, _, 1>(0, &prepared_mid); + } + if let ::core::option::Option::Some(prepared_rid) = prepared_rid { + table_writer.write::<_, _, 1>(1, &prepared_rid); + } + if let ::core::option::Option::Some(prepared_rrid) = prepared_rrid { + table_writer.write::<_, _, 1>(2, &prepared_rrid); + } + if let ::core::option::Option::Some(prepared_abs_send_time) = + prepared_abs_send_time + { + table_writer.write::<_, _, 1>(3, &prepared_abs_send_time); + } + if let ::core::option::Option::Some(prepared_transport_wide_cc01) = + prepared_transport_wide_cc01 + { + table_writer.write::<_, _, 1>(4, &prepared_transport_wide_cc01); + } + } + + table_writer.finish() + } + } + + impl ::planus::WriteAs<::planus::Offset> for RecvRtpHeaderExtensions { + type Prepared = ::planus::Offset; + + 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; + + 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 { + 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, + ) + } + } + + #[derive(Copy, Clone)] + pub struct RecvRtpHeaderExtensionsRef<'a>(::planus::table_reader::Table<'a>); + + impl<'a> RecvRtpHeaderExtensionsRef<'a> { + pub fn mid(&self) -> ::planus::Result<::core::option::Option> { + self.0.access(0, "RecvRtpHeaderExtensions", "mid") + } + + pub fn rid(&self) -> ::planus::Result<::core::option::Option> { + self.0.access(1, "RecvRtpHeaderExtensions", "rid") + } + + pub fn rrid(&self) -> ::planus::Result<::core::option::Option> { + self.0.access(2, "RecvRtpHeaderExtensions", "rrid") + } + + pub fn abs_send_time(&self) -> ::planus::Result<::core::option::Option> { + self.0.access(3, "RecvRtpHeaderExtensions", "abs_send_time") + } + + 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> { + 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; + 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, + ) + }) + } + } + #[derive( Clone, Debug, @@ -21458,13 +21742,13 @@ mod root { pub data_producer_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, pub data_consumer_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, pub recv_rtp_header_extensions: - ::planus::alloc::vec::Vec, + ::planus::alloc::boxed::Box, pub rtp_listener: ::planus::alloc::boxed::Box, pub max_message_size: u32, pub sctp_parameters: ::core::option::Option< ::planus::alloc::boxed::Box, >, - pub sctp_state: ::core::option::Option<::planus::alloc::string::String>, + pub sctp_state: ::core::option::Option, pub sctp_listener: ::core::option::Option<::planus::alloc::boxed::Box>, pub trace_event_types: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, @@ -21495,16 +21779,14 @@ mod root { ::planus::Offset<[::planus::Offset]>, >, field_recv_rtp_header_extensions: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, + ::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< - ::planus::Offset<::core::primitive::str>, - >, + field_sctp_state: impl ::planus::WriteAsOptional, field_sctp_listener: impl ::planus::WriteAsOptional< ::planus::Offset, >, @@ -21545,7 +21827,7 @@ mod root { let prepared_trace_event_types = field_trace_event_types.prepare(builder); let mut table_writer = - ::planus::table_writer::TableWriter::<32, 57>::new(builder); + ::planus::table_writer::TableWriter::<32, 54>::new(builder); table_writer.calculate_size::<::planus::Offset>(2); if prepared_direct.is_some() { @@ -21557,7 +21839,8 @@ mod root { table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(12); table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(14); table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(16); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(18); + table_writer + .calculate_size::<::planus::Offset>(18); table_writer.calculate_size::<::planus::Offset>(20); if prepared_max_message_size.is_some() { table_writer.calculate_size::(22); @@ -21566,7 +21849,7 @@ mod root { table_writer.calculate_size::<::planus::Offset>(24); } if prepared_sctp_state.is_some() { - table_writer.calculate_size::<::planus::Offset>(26); + table_writer.calculate_size::(26); } if prepared_sctp_listener.is_some() { table_writer.calculate_size::<::planus::Offset>(28); @@ -21595,11 +21878,6 @@ mod root { { table_writer.write::<_, _, 4>(11, &prepared_sctp_parameters); } - if let ::core::option::Option::Some(prepared_sctp_state) = - prepared_sctp_state - { - table_writer.write::<_, _, 4>(12, &prepared_sctp_state); - } if let ::core::option::Option::Some(prepared_sctp_listener) = prepared_sctp_listener { @@ -21609,6 +21887,11 @@ mod root { if let ::core::option::Option::Some(prepared_direct) = prepared_direct { table_writer.write::<_, _, 1>(1, &prepared_direct); } + if let ::core::option::Option::Some(prepared_sctp_state) = + prepared_sctp_state + { + table_writer.write::<_, _, 1>(12, &prepared_sctp_state); + } } table_writer.finish() @@ -21720,9 +22003,7 @@ mod root { pub fn recv_rtp_header_extensions( &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { + ) -> ::planus::Result> { self.0 .access_required(8, "Dump", "recv_rtp_header_extensions") } @@ -21747,7 +22028,7 @@ mod root { pub fn sctp_state( &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + ) -> ::planus::Result<::core::option::Option> { self.0.access(12, "Dump", "sctp_state") } @@ -21821,9 +22102,11 @@ mod root { .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: value - .recv_rtp_header_extensions()? - .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()?)?, ), @@ -22304,41 +22587,33 @@ mod root { } #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct Stats { pub transport_id: ::planus::alloc::string::String, pub timestamp: u64, - pub sctp_state: ::core::option::Option<::planus::alloc::string::String>, + pub sctp_state: ::core::option::Option, pub bytes_received: u64, - pub recv_bitrate: u64, + pub recv_bitrate: u32, pub bytes_sent: u64, - pub send_bitrate: u64, + pub send_bitrate: u32, pub rtp_bytes_received: u64, - pub rtp_recv_bitrate: u64, + pub rtp_recv_bitrate: u32, pub rtp_bytes_sent: u64, - pub rtp_send_bitrate: u64, + pub rtp_send_bitrate: u32, pub rtx_bytes_received: u64, - pub rtx_recv_bitrate: u64, + pub rtx_recv_bitrate: u32, pub rtx_bytes_sent: u64, - pub rtx_send_bitrate: u64, + pub rtx_send_bitrate: u32, pub probation_bytes_sent: u64, - pub probation_send_bitrate: u64, - pub available_outgoing_bitrate: u64, - pub available_incoming_bitrate: u64, - pub max_incoming_bitrate: u64, - pub max_outgoing_bitrate: u64, - pub min_outgoing_bitrate: u64, - pub rtp_packet_loss_received: u64, - pub rtp_packet_loss_sent: u64, + pub probation_send_bitrate: u32, + pub available_outgoing_bitrate: ::core::option::Option, + pub available_incoming_bitrate: ::core::option::Option, + pub max_incoming_bitrate: u32, + pub max_outgoing_bitrate: u32, + pub min_outgoing_bitrate: u32, + pub rtp_packet_loss_received: ::core::option::Option, + pub rtp_packet_loss_sent: ::core::option::Option, } impl Stats { @@ -22347,30 +22622,28 @@ mod root { builder: &mut ::planus::Builder, field_transport_id: impl ::planus::WriteAs<::planus::Offset>, field_timestamp: impl ::planus::WriteAsDefault, - field_sctp_state: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, + field_sctp_state: impl ::planus::WriteAsOptional, field_bytes_received: impl ::planus::WriteAsDefault, - field_recv_bitrate: impl ::planus::WriteAsDefault, + field_recv_bitrate: impl ::planus::WriteAsDefault, field_bytes_sent: impl ::planus::WriteAsDefault, - field_send_bitrate: 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_recv_bitrate: impl ::planus::WriteAsDefault, field_rtp_bytes_sent: impl ::planus::WriteAsDefault, - field_rtp_send_bitrate: 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_recv_bitrate: impl ::planus::WriteAsDefault, field_rtx_bytes_sent: impl ::planus::WriteAsDefault, - field_rtx_send_bitrate: 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::WriteAsDefault, - field_available_incoming_bitrate: impl ::planus::WriteAsDefault, - field_max_incoming_bitrate: impl ::planus::WriteAsDefault, - field_max_outgoing_bitrate: impl ::planus::WriteAsDefault, - field_min_outgoing_bitrate: impl ::planus::WriteAsDefault, - field_rtp_packet_loss_received: impl ::planus::WriteAsDefault, - field_rtp_packet_loss_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::WriteAsDefault, + field_max_outgoing_bitrate: impl ::planus::WriteAsDefault, + field_min_outgoing_bitrate: impl ::planus::WriteAsDefault, + 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); @@ -22409,10 +22682,10 @@ mod root { field_probation_send_bitrate.prepare(builder, &0); let prepared_available_outgoing_bitrate = - field_available_outgoing_bitrate.prepare(builder, &0); + field_available_outgoing_bitrate.prepare(builder); let prepared_available_incoming_bitrate = - field_available_incoming_bitrate.prepare(builder, &0); + field_available_incoming_bitrate.prepare(builder); let prepared_max_incoming_bitrate = field_max_incoming_bitrate.prepare(builder, &0); @@ -22424,83 +22697,82 @@ mod root { field_min_outgoing_bitrate.prepare(builder, &0); let prepared_rtp_packet_loss_received = - field_rtp_packet_loss_received.prepare(builder, &0); + field_rtp_packet_loss_received.prepare(builder); - let prepared_rtp_packet_loss_sent = - field_rtp_packet_loss_sent.prepare(builder, &0); + let prepared_rtp_packet_loss_sent = field_rtp_packet_loss_sent.prepare(builder); let mut table_writer = - ::planus::table_writer::TableWriter::<50, 184>::new(builder); + ::planus::table_writer::TableWriter::<50, 133>::new(builder); table_writer.calculate_size::<::planus::Offset>(2); if prepared_timestamp.is_some() { table_writer.calculate_size::(4); } if prepared_sctp_state.is_some() { - table_writer.calculate_size::<::planus::Offset>(6); + table_writer.calculate_size::(6); } if prepared_bytes_received.is_some() { table_writer.calculate_size::(8); } if prepared_recv_bitrate.is_some() { - table_writer.calculate_size::(10); + table_writer.calculate_size::(10); } if prepared_bytes_sent.is_some() { table_writer.calculate_size::(12); } if prepared_send_bitrate.is_some() { - table_writer.calculate_size::(14); + table_writer.calculate_size::(14); } if prepared_rtp_bytes_received.is_some() { table_writer.calculate_size::(16); } if prepared_rtp_recv_bitrate.is_some() { - table_writer.calculate_size::(18); + table_writer.calculate_size::(18); } if prepared_rtp_bytes_sent.is_some() { table_writer.calculate_size::(20); } if prepared_rtp_send_bitrate.is_some() { - table_writer.calculate_size::(22); + table_writer.calculate_size::(22); } if prepared_rtx_bytes_received.is_some() { table_writer.calculate_size::(24); } if prepared_rtx_recv_bitrate.is_some() { - table_writer.calculate_size::(26); + table_writer.calculate_size::(26); } if prepared_rtx_bytes_sent.is_some() { table_writer.calculate_size::(28); } if prepared_rtx_send_bitrate.is_some() { - table_writer.calculate_size::(30); + table_writer.calculate_size::(30); } if prepared_probation_bytes_sent.is_some() { table_writer.calculate_size::(32); } if prepared_probation_send_bitrate.is_some() { - table_writer.calculate_size::(34); + table_writer.calculate_size::(34); } if prepared_available_outgoing_bitrate.is_some() { - table_writer.calculate_size::(36); + table_writer.calculate_size::(36); } if prepared_available_incoming_bitrate.is_some() { - table_writer.calculate_size::(38); + table_writer.calculate_size::(38); } if prepared_max_incoming_bitrate.is_some() { - table_writer.calculate_size::(40); + table_writer.calculate_size::(40); } if prepared_max_outgoing_bitrate.is_some() { - table_writer.calculate_size::(42); + table_writer.calculate_size::(42); } if prepared_min_outgoing_bitrate.is_some() { - table_writer.calculate_size::(44); + table_writer.calculate_size::(44); } if prepared_rtp_packet_loss_received.is_some() { - table_writer.calculate_size::(46); + table_writer.calculate_size::(46); } if prepared_rtp_packet_loss_sent.is_some() { - table_writer.calculate_size::(48); + table_writer.calculate_size::(48); } table_writer.finish_calculating(); @@ -22515,111 +22787,111 @@ mod root { { table_writer.write::<_, _, 8>(3, &prepared_bytes_received); } - if let ::core::option::Option::Some(prepared_recv_bitrate) = - prepared_recv_bitrate - { - table_writer.write::<_, _, 8>(4, &prepared_recv_bitrate); - } if let ::core::option::Option::Some(prepared_bytes_sent) = prepared_bytes_sent { table_writer.write::<_, _, 8>(5, &prepared_bytes_sent); } - if let ::core::option::Option::Some(prepared_send_bitrate) = - prepared_send_bitrate - { - table_writer.write::<_, _, 8>(6, &prepared_send_bitrate); - } if let ::core::option::Option::Some(prepared_rtp_bytes_received) = prepared_rtp_bytes_received { table_writer.write::<_, _, 8>(7, &prepared_rtp_bytes_received); } - if let ::core::option::Option::Some(prepared_rtp_recv_bitrate) = - prepared_rtp_recv_bitrate - { - table_writer.write::<_, _, 8>(8, &prepared_rtp_recv_bitrate); - } if let ::core::option::Option::Some(prepared_rtp_bytes_sent) = prepared_rtp_bytes_sent { table_writer.write::<_, _, 8>(9, &prepared_rtp_bytes_sent); } - if let ::core::option::Option::Some(prepared_rtp_send_bitrate) = - prepared_rtp_send_bitrate - { - table_writer.write::<_, _, 8>(10, &prepared_rtp_send_bitrate); - } if let ::core::option::Option::Some(prepared_rtx_bytes_received) = prepared_rtx_bytes_received { table_writer.write::<_, _, 8>(11, &prepared_rtx_bytes_received); } - if let ::core::option::Option::Some(prepared_rtx_recv_bitrate) = - prepared_rtx_recv_bitrate - { - table_writer.write::<_, _, 8>(12, &prepared_rtx_recv_bitrate); - } if let ::core::option::Option::Some(prepared_rtx_bytes_sent) = prepared_rtx_bytes_sent { table_writer.write::<_, _, 8>(13, &prepared_rtx_bytes_sent); } - if let ::core::option::Option::Some(prepared_rtx_send_bitrate) = - prepared_rtx_send_bitrate - { - table_writer.write::<_, _, 8>(14, &prepared_rtx_send_bitrate); - } if let ::core::option::Option::Some(prepared_probation_bytes_sent) = prepared_probation_bytes_sent { table_writer.write::<_, _, 8>(15, &prepared_probation_bytes_sent); } + if let ::core::option::Option::Some(prepared_rtp_packet_loss_received) = + prepared_rtp_packet_loss_received + { + table_writer.write::<_, _, 8>(22, &prepared_rtp_packet_loss_received); + } + if let ::core::option::Option::Some(prepared_rtp_packet_loss_sent) = + prepared_rtp_packet_loss_sent + { + table_writer.write::<_, _, 8>(23, &prepared_rtp_packet_loss_sent); + } + table_writer.write::<_, _, 4>(0, &prepared_transport_id); + if let ::core::option::Option::Some(prepared_recv_bitrate) = + prepared_recv_bitrate + { + table_writer.write::<_, _, 4>(4, &prepared_recv_bitrate); + } + if let ::core::option::Option::Some(prepared_send_bitrate) = + prepared_send_bitrate + { + table_writer.write::<_, _, 4>(6, &prepared_send_bitrate); + } + if let ::core::option::Option::Some(prepared_rtp_recv_bitrate) = + prepared_rtp_recv_bitrate + { + table_writer.write::<_, _, 4>(8, &prepared_rtp_recv_bitrate); + } + if let ::core::option::Option::Some(prepared_rtp_send_bitrate) = + prepared_rtp_send_bitrate + { + table_writer.write::<_, _, 4>(10, &prepared_rtp_send_bitrate); + } + if let ::core::option::Option::Some(prepared_rtx_recv_bitrate) = + prepared_rtx_recv_bitrate + { + table_writer.write::<_, _, 4>(12, &prepared_rtx_recv_bitrate); + } + if let ::core::option::Option::Some(prepared_rtx_send_bitrate) = + prepared_rtx_send_bitrate + { + table_writer.write::<_, _, 4>(14, &prepared_rtx_send_bitrate); + } if let ::core::option::Option::Some(prepared_probation_send_bitrate) = prepared_probation_send_bitrate { - table_writer.write::<_, _, 8>(16, &prepared_probation_send_bitrate); + table_writer.write::<_, _, 4>(16, &prepared_probation_send_bitrate); } if let ::core::option::Option::Some(prepared_available_outgoing_bitrate) = prepared_available_outgoing_bitrate { - table_writer.write::<_, _, 8>(17, &prepared_available_outgoing_bitrate); + table_writer.write::<_, _, 4>(17, &prepared_available_outgoing_bitrate); } if let ::core::option::Option::Some(prepared_available_incoming_bitrate) = prepared_available_incoming_bitrate { - table_writer.write::<_, _, 8>(18, &prepared_available_incoming_bitrate); + table_writer.write::<_, _, 4>(18, &prepared_available_incoming_bitrate); } if let ::core::option::Option::Some(prepared_max_incoming_bitrate) = prepared_max_incoming_bitrate { - table_writer.write::<_, _, 8>(19, &prepared_max_incoming_bitrate); + table_writer.write::<_, _, 4>(19, &prepared_max_incoming_bitrate); } if let ::core::option::Option::Some(prepared_max_outgoing_bitrate) = prepared_max_outgoing_bitrate { - table_writer.write::<_, _, 8>(20, &prepared_max_outgoing_bitrate); + table_writer.write::<_, _, 4>(20, &prepared_max_outgoing_bitrate); } if let ::core::option::Option::Some(prepared_min_outgoing_bitrate) = prepared_min_outgoing_bitrate { - table_writer.write::<_, _, 8>(21, &prepared_min_outgoing_bitrate); + table_writer.write::<_, _, 4>(21, &prepared_min_outgoing_bitrate); } - if let ::core::option::Option::Some(prepared_rtp_packet_loss_received) = - prepared_rtp_packet_loss_received - { - table_writer.write::<_, _, 8>(22, &prepared_rtp_packet_loss_received); - } - if let ::core::option::Option::Some(prepared_rtp_packet_loss_sent) = - prepared_rtp_packet_loss_sent - { - table_writer.write::<_, _, 8>(23, &prepared_rtp_packet_loss_sent); - } - table_writer.write::<_, _, 4>(0, &prepared_transport_id); if let ::core::option::Option::Some(prepared_sctp_state) = prepared_sctp_state { - table_writer.write::<_, _, 4>(2, &prepared_sctp_state); + table_writer.write::<_, _, 1>(2, &prepared_sctp_state); } } @@ -22692,7 +22964,7 @@ mod root { pub fn sctp_state( &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + ) -> ::planus::Result<::core::option::Option> { self.0.access(2, "Stats", "sctp_state") } @@ -22703,7 +22975,7 @@ mod root { ) } - pub fn recv_bitrate(&self) -> ::planus::Result { + pub fn recv_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0.access(4, "Stats", "recv_bitrate")?.unwrap_or(0), ) @@ -22715,7 +22987,7 @@ mod root { ) } - pub fn send_bitrate(&self) -> ::planus::Result { + pub fn send_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0.access(6, "Stats", "send_bitrate")?.unwrap_or(0), ) @@ -22729,7 +23001,7 @@ mod root { ) } - pub fn rtp_recv_bitrate(&self) -> ::planus::Result { + pub fn rtp_recv_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0.access(8, "Stats", "rtp_recv_bitrate")?.unwrap_or(0), ) @@ -22741,7 +23013,7 @@ mod root { ) } - pub fn rtp_send_bitrate(&self) -> ::planus::Result { + pub fn rtp_send_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0.access(10, "Stats", "rtp_send_bitrate")?.unwrap_or(0), ) @@ -22755,7 +23027,7 @@ mod root { ) } - pub fn rtx_recv_bitrate(&self) -> ::planus::Result { + pub fn rtx_recv_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0.access(12, "Stats", "rtx_recv_bitrate")?.unwrap_or(0), ) @@ -22767,7 +23039,7 @@ mod root { ) } - pub fn rtx_send_bitrate(&self) -> ::planus::Result { + pub fn rtx_send_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0.access(14, "Stats", "rtx_send_bitrate")?.unwrap_or(0), ) @@ -22781,7 +23053,7 @@ mod root { ) } - pub fn probation_send_bitrate(&self) -> ::planus::Result { + pub fn probation_send_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 .access(16, "Stats", "probation_send_bitrate")? @@ -22789,23 +23061,19 @@ mod root { ) } - pub fn available_outgoing_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(17, "Stats", "available_outgoing_bitrate")? - .unwrap_or(0), - ) + pub fn available_outgoing_bitrate( + &self, + ) -> ::planus::Result<::core::option::Option> { + self.0.access(17, "Stats", "available_outgoing_bitrate") } - pub fn available_incoming_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(18, "Stats", "available_incoming_bitrate")? - .unwrap_or(0), - ) + pub fn available_incoming_bitrate( + &self, + ) -> ::planus::Result<::core::option::Option> { + self.0.access(18, "Stats", "available_incoming_bitrate") } - pub fn max_incoming_bitrate(&self) -> ::planus::Result { + pub fn max_incoming_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 .access(19, "Stats", "max_incoming_bitrate")? @@ -22813,7 +23081,7 @@ mod root { ) } - pub fn max_outgoing_bitrate(&self) -> ::planus::Result { + pub fn max_outgoing_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 .access(20, "Stats", "max_outgoing_bitrate")? @@ -22821,7 +23089,7 @@ mod root { ) } - pub fn min_outgoing_bitrate(&self) -> ::planus::Result { + pub fn min_outgoing_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 .access(21, "Stats", "min_outgoing_bitrate")? @@ -22829,20 +23097,16 @@ mod root { ) } - pub fn rtp_packet_loss_received(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(22, "Stats", "rtp_packet_loss_received")? - .unwrap_or(0), - ) + pub fn rtp_packet_loss_received( + &self, + ) -> ::planus::Result<::core::option::Option> { + self.0.access(22, "Stats", "rtp_packet_loss_received") } - pub fn rtp_packet_loss_sent(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(23, "Stats", "rtp_packet_loss_sent")? - .unwrap_or(0), - ) + pub fn rtp_packet_loss_sent( + &self, + ) -> ::planus::Result<::core::option::Option> { + self.0.access(23, "Stats", "rtp_packet_loss_sent") } } @@ -22870,19 +23134,35 @@ mod root { 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()); - f.field( - "available_outgoing_bitrate", - &self.available_outgoing_bitrate(), - ); - f.field( - "available_incoming_bitrate", - &self.available_incoming_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, + ); + } f.field("max_incoming_bitrate", &self.max_incoming_bitrate()); f.field("max_outgoing_bitrate", &self.max_outgoing_bitrate()); f.field("min_outgoing_bitrate", &self.min_outgoing_bitrate()); - f.field("rtp_packet_loss_received", &self.rtp_packet_loss_received()); - f.field("rtp_packet_loss_sent", &self.rtp_packet_loss_sent()); + 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() } } @@ -22940,12 +23220,26 @@ mod root { probation_send_bitrate: ::core::convert::TryInto::try_into( value.probation_send_bitrate()?, )?, - available_outgoing_bitrate: ::core::convert::TryInto::try_into( - value.available_outgoing_bitrate()?, - )?, - available_incoming_bitrate: ::core::convert::TryInto::try_into( - value.available_incoming_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: ::core::convert::TryInto::try_into( value.max_incoming_bitrate()?, )?, @@ -22955,12 +23249,26 @@ mod root { min_outgoing_bitrate: ::core::convert::TryInto::try_into( value.min_outgoing_bitrate()?, )?, - rtp_packet_loss_received: ::core::convert::TryInto::try_into( - value.rtp_packet_loss_received()?, - )?, - rtp_packet_loss_sent: ::core::convert::TryInto::try_into( - value.rtp_packet_loss_sent()?, - )?, + 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 + }, }) } } @@ -27553,29 +27861,16 @@ mod root { ::serde::Deserialize, )] pub struct Notification { - pub handler_id: ::core::option::Option<::planus::alloc::string::String>, + pub handler_id: ::planus::alloc::string::String, pub event: self::Event, pub body: ::core::option::Option, } - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for Notification { - fn default() -> Self { - Self { - handler_id: ::core::default::Default::default(), - event: self::Event::TransportSendRtcp, - body: ::core::default::Default::default(), - } - } - } - impl Notification { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_handler_id: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, + field_handler_id: impl ::planus::WriteAs<::planus::Offset>, field_event: impl ::planus::WriteAsDefault, field_body: impl ::planus::WriteAsOptionalUnion, ) -> ::planus::Offset { @@ -27589,9 +27884,7 @@ mod root { let mut table_writer = ::planus::table_writer::TableWriter::<8, 10>::new(builder); - if prepared_handler_id.is_some() { - table_writer.calculate_size::<::planus::Offset>(2); - } + table_writer.calculate_size::<::planus::Offset>(2); if prepared_event.is_some() { table_writer.calculate_size::(4); } @@ -27603,11 +27896,7 @@ mod root { table_writer.finish_calculating(); unsafe { - if let ::core::option::Option::Some(prepared_handler_id) = - prepared_handler_id - { - table_writer.write::<_, _, 4>(0, &prepared_handler_id); - } + table_writer.write::<_, _, 4>(0, &prepared_handler_id); if let ::core::option::Option::Some(prepared_body) = prepared_body { table_writer.write::<_, _, 4>(3, &prepared_body.offset()); } @@ -27658,11 +27947,8 @@ mod root { pub struct NotificationRef<'a>(::planus::table_reader::Table<'a>); impl<'a> NotificationRef<'a> { - pub fn handler_id( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(0, "Notification", "handler_id") + pub fn handler_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "Notification", "handler_id") } pub fn event(&self) -> ::planus::Result { @@ -27681,11 +27967,7 @@ mod root { 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"); - if let ::core::option::Option::Some(field_handler_id) = - self.handler_id().transpose() - { - f.field("handler_id", &field_handler_id); - } + 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); @@ -27700,15 +27982,7 @@ mod root { #[allow(unreachable_code)] fn try_from(value: NotificationRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - handler_id: if let ::core::option::Option::Some(handler_id) = - value.handler_id()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - handler_id, - )?) - } else { - ::core::option::Option::None - }, + 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)?) @@ -28860,31 +29134,17 @@ mod root { pub struct Request { pub id: u32, pub method: self::Method, - pub handler_id: ::core::option::Option<::planus::alloc::string::String>, + pub handler_id: ::planus::alloc::string::String, pub body: ::core::option::Option, } - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for Request { - fn default() -> Self { - Self { - id: 0, - method: self::Method::WorkerClose, - handler_id: ::core::default::Default::default(), - body: ::core::default::Default::default(), - } - } - } - impl Request { #[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::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, + field_handler_id: impl ::planus::WriteAs<::planus::Offset>, field_body: impl ::planus::WriteAsOptionalUnion, ) -> ::planus::Offset { let prepared_id = field_id.prepare(builder, &0); @@ -28904,9 +29164,7 @@ mod root { if prepared_method.is_some() { table_writer.calculate_size::(4); } - if prepared_handler_id.is_some() { - table_writer.calculate_size::<::planus::Offset>(6); - } + table_writer.calculate_size::<::planus::Offset>(6); if prepared_body.is_some() { table_writer.calculate_size::(8); table_writer.calculate_size::<::planus::Offset>(10); @@ -28918,11 +29176,7 @@ mod root { if let ::core::option::Option::Some(prepared_id) = prepared_id { table_writer.write::<_, _, 4>(0, &prepared_id); } - if let ::core::option::Option::Some(prepared_handler_id) = - prepared_handler_id - { - table_writer.write::<_, _, 4>(2, &prepared_handler_id); - } + table_writer.write::<_, _, 4>(2, &prepared_handler_id); if let ::core::option::Option::Some(prepared_body) = prepared_body { table_writer.write::<_, _, 4>(4, &prepared_body.offset()); } @@ -28985,11 +29239,8 @@ mod root { ) } - pub fn handler_id( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(2, "Request", "handler_id") + pub fn handler_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(2, "Request", "handler_id") } pub fn body(&self) -> ::planus::Result<::core::option::Option>> { @@ -29002,11 +29253,7 @@ mod root { let mut f = f.debug_struct("RequestRef"); f.field("id", &self.id()); f.field("method", &self.method()); - if let ::core::option::Option::Some(field_handler_id) = - self.handler_id().transpose() - { - f.field("handler_id", &field_handler_id); - } + f.field("handler_id", &self.handler_id()); if let ::core::option::Option::Some(field_body) = self.body().transpose() { f.field("body", &field_body); } @@ -29022,15 +29269,7 @@ mod root { ::core::result::Result::Ok(Self { id: ::core::convert::TryInto::try_into(value.id()?)?, method: ::core::convert::TryInto::try_into(value.method()?)?, - handler_id: if let ::core::option::Option::Some(handler_id) = - value.handler_id()? - { - ::core::option::Option::Some(::core::convert::TryInto::try_into( - handler_id, - )?) - } else { - ::core::option::Option::None - }, + 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 { @@ -30136,32 +30375,20 @@ mod root { ::serde::Deserialize, )] pub struct ChannelMessageHandlers { - pub channel_request_handlers: ::core::option::Option< + pub channel_request_handlers: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - >, - pub channel_notification_handlers: ::core::option::Option< + pub channel_notification_handlers: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - >, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for ChannelMessageHandlers { - fn default() -> Self { - Self { - channel_request_handlers: ::core::default::Default::default(), - channel_notification_handlers: ::core::default::Default::default(), - } - } } impl ChannelMessageHandlers { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_channel_request_handlers: impl ::planus::WriteAsOptional< + field_channel_request_handlers: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - field_channel_notification_handlers: impl ::planus::WriteAsOptional< + field_channel_notification_handlers: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, ) -> ::planus::Offset { @@ -30174,28 +30401,14 @@ mod root { let mut table_writer = ::planus::table_writer::TableWriter::<6, 8>::new(builder); - if prepared_channel_request_handlers.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); - } - if prepared_channel_notification_handlers.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); - } + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); table_writer.finish_calculating(); unsafe { - if let ::core::option::Option::Some(prepared_channel_request_handlers) = - prepared_channel_request_handlers - { - table_writer.write::<_, _, 4>(0, &prepared_channel_request_handlers); - } - if let ::core::option::Option::Some( - prepared_channel_notification_handlers, - ) = prepared_channel_notification_handlers - { - table_writer - .write::<_, _, 4>(1, &prepared_channel_notification_handlers); - } + table_writer.write::<_, _, 4>(0, &prepared_channel_request_handlers); + table_writer.write::<_, _, 4>(1, &prepared_channel_notification_handlers); } table_writer.finish() @@ -30247,42 +30460,33 @@ mod root { pub fn channel_request_handlers( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - >, + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, > { self.0 - .access(0, "ChannelMessageHandlers", "channel_request_handlers") + .access_required(0, "ChannelMessageHandlers", "channel_request_handlers") } pub fn channel_notification_handlers( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - >, + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, > { - self.0 - .access(1, "ChannelMessageHandlers", "channel_notification_handlers") + 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"); - if let ::core::option::Option::Some(field_channel_request_handlers) = - self.channel_request_handlers().transpose() - { - f.field("channel_request_handlers", &field_channel_request_handlers); - } - if let ::core::option::Option::Some(field_channel_notification_handlers) = - self.channel_notification_handlers().transpose() - { - f.field( - "channel_notification_handlers", - &field_channel_notification_handlers, - ); - } + f.field("channel_request_handlers", &self.channel_request_handlers()); + f.field( + "channel_notification_handlers", + &self.channel_notification_handlers(), + ); f.finish() } } @@ -30293,25 +30497,12 @@ mod root { #[allow(unreachable_code)] fn try_from(value: ChannelMessageHandlersRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - channel_request_handlers: if let ::core::option::Option::Some( - channel_request_handlers, - ) = value.channel_request_handlers()? - { - ::core::option::Option::Some(channel_request_handlers.to_vec_result()?) - } else { - ::core::option::Option::None - }, - channel_notification_handlers: if let ::core::option::Option::Some( - channel_notification_handlers, - ) = - value.channel_notification_handlers()? - { - ::core::option::Option::Some( - channel_notification_handlers.to_vec_result()?, - ) - } else { - ::core::option::Option::None - }, + channel_request_handlers: value + .channel_request_handlers()? + .to_vec_result()?, + channel_notification_handlers: value + .channel_notification_handlers()? + .to_vec_result()?, }) } } @@ -30401,27 +30592,10 @@ mod root { )] pub struct DumpResponse { pub pid: u32, - pub web_rtc_server_ids: ::core::option::Option< - ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - >, - pub router_ids: ::core::option::Option< - ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - >, - pub channel_message_handlers: ::core::option::Option< + pub web_rtc_server_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + pub router_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + pub channel_message_handlers: ::planus::alloc::boxed::Box, - >, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for DumpResponse { - fn default() -> Self { - Self { - pid: 0, - web_rtc_server_ids: ::core::default::Default::default(), - router_ids: ::core::default::Default::default(), - channel_message_handlers: ::core::default::Default::default(), - } - } } impl DumpResponse { @@ -30429,13 +30603,11 @@ mod root { pub fn create( builder: &mut ::planus::Builder, field_pid: impl ::planus::WriteAsDefault, - field_web_rtc_server_ids: impl ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - field_router_ids: impl ::planus::WriteAsOptional< + field_web_rtc_server_ids: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - field_channel_message_handlers: impl ::planus::WriteAsOptional< + field_router_ids: impl ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + field_channel_message_handlers: impl ::planus::WriteAs< ::planus::Offset, >, ) -> ::planus::Offset { @@ -30454,16 +30626,10 @@ mod root { if prepared_pid.is_some() { table_writer.calculate_size::(2); } - if prepared_web_rtc_server_ids.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); - } - if prepared_router_ids.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(6); - } - if prepared_channel_message_handlers.is_some() { - table_writer - .calculate_size::<::planus::Offset>(8); - } + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(6); + table_writer + .calculate_size::<::planus::Offset>(8); table_writer.finish_calculating(); @@ -30471,21 +30637,9 @@ mod root { if let ::core::option::Option::Some(prepared_pid) = prepared_pid { table_writer.write::<_, _, 4>(0, &prepared_pid); } - if let ::core::option::Option::Some(prepared_web_rtc_server_ids) = - prepared_web_rtc_server_ids - { - table_writer.write::<_, _, 4>(1, &prepared_web_rtc_server_ids); - } - if let ::core::option::Option::Some(prepared_router_ids) = - prepared_router_ids - { - table_writer.write::<_, _, 4>(2, &prepared_router_ids); - } - if let ::core::option::Option::Some(prepared_channel_message_handlers) = - prepared_channel_message_handlers - { - table_writer.write::<_, _, 4>(3, &prepared_channel_message_handlers); - } + table_writer.write::<_, _, 4>(1, &prepared_web_rtc_server_ids); + table_writer.write::<_, _, 4>(2, &prepared_router_ids); + table_writer.write::<_, _, 4>(3, &prepared_channel_message_handlers); } table_writer.finish() @@ -30542,28 +30696,25 @@ mod root { pub fn web_rtc_server_ids( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - >, + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, > { - self.0.access(1, "DumpResponse", "web_rtc_server_ids") + self.0 + .access_required(1, "DumpResponse", "web_rtc_server_ids") } pub fn router_ids( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - >, + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, > { - self.0.access(2, "DumpResponse", "router_ids") + self.0.access_required(2, "DumpResponse", "router_ids") } pub fn channel_message_handlers( &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(3, "DumpResponse", "channel_message_handlers") + ) -> ::planus::Result> { + self.0 + .access_required(3, "DumpResponse", "channel_message_handlers") } } @@ -30571,21 +30722,9 @@ mod root { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut f = f.debug_struct("DumpResponseRef"); f.field("pid", &self.pid()); - if let ::core::option::Option::Some(field_web_rtc_server_ids) = - self.web_rtc_server_ids().transpose() - { - f.field("web_rtc_server_ids", &field_web_rtc_server_ids); - } - if let ::core::option::Option::Some(field_router_ids) = - self.router_ids().transpose() - { - f.field("router_ids", &field_router_ids); - } - if let ::core::option::Option::Some(field_channel_message_handlers) = - self.channel_message_handlers().transpose() - { - f.field("channel_message_handlers", &field_channel_message_handlers); - } + 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() } } @@ -30597,31 +30736,11 @@ mod root { 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: if let ::core::option::Option::Some( - web_rtc_server_ids, - ) = value.web_rtc_server_ids()? - { - ::core::option::Option::Some(web_rtc_server_ids.to_vec_result()?) - } else { - ::core::option::Option::None - }, - router_ids: if let ::core::option::Option::Some(router_ids) = - value.router_ids()? - { - ::core::option::Option::Some(router_ids.to_vec_result()?) - } else { - ::core::option::Option::None - }, - channel_message_handlers: if let ::core::option::Option::Some( - channel_message_handlers, - ) = value.channel_message_handlers()? - { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(channel_message_handlers)?, - )) - } else { - ::core::option::Option::None - }, + 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()?)?, + ), }) } } @@ -31477,9 +31596,7 @@ mod root { )] pub struct CreateWebRtcServerRequest { pub web_rtc_server_id: ::planus::alloc::string::String, - pub listen_infos: ::core::option::Option< - ::planus::alloc::vec::Vec, - >, + pub listen_infos: ::planus::alloc::vec::Vec, } impl CreateWebRtcServerRequest { @@ -31487,7 +31604,7 @@ mod root { pub fn create( builder: &mut ::planus::Builder, field_web_rtc_server_id: impl ::planus::WriteAs<::planus::Offset>, - field_listen_infos: impl ::planus::WriteAsOptional< + field_listen_infos: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, ) -> ::planus::Offset { @@ -31499,21 +31616,15 @@ mod root { ::planus::table_writer::TableWriter::<6, 8>::new(builder); table_writer.calculate_size::<::planus::Offset>(2); - if prepared_listen_infos.is_some() { - table_writer.calculate_size::<::planus::Offset< - [::planus::Offset], - >>(4); - } + table_writer.calculate_size::<::planus::Offset< + [::planus::Offset], + >>(4); table_writer.finish_calculating(); unsafe { table_writer.write::<_, _, 4>(0, &prepared_web_rtc_server_id); - if let ::core::option::Option::Some(prepared_listen_infos) = - prepared_listen_infos - { - table_writer.write::<_, _, 4>(1, &prepared_listen_infos); - } + table_writer.write::<_, _, 4>(1, &prepared_listen_infos); } table_writer.finish() @@ -31570,15 +31681,13 @@ mod root { pub fn listen_infos( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector< - 'a, - ::planus::Result>, - >, + ::planus::Vector< + 'a, + ::planus::Result>, >, > { self.0 - .access(1, "CreateWebRtcServerRequest", "listen_infos") + .access_required(1, "CreateWebRtcServerRequest", "listen_infos") } } @@ -31586,11 +31695,7 @@ mod root { 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.field("listen_infos", &self.listen_infos()); f.finish() } } @@ -31604,13 +31709,7 @@ mod root { 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 - }, + listen_infos: value.listen_infos()?.to_vec_result()?, }) } } @@ -32215,25 +32314,18 @@ mod root { )] pub struct DumpResponse { pub id: ::planus::alloc::string::String, - pub transport_ids: ::core::option::Option< - ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - >, - pub rtp_observer_ids: ::core::option::Option< - ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - >, - pub map_producer_id_consumer_ids: ::core::option::Option< + pub transport_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + pub rtp_observer_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + pub map_producer_id_consumer_ids: ::planus::alloc::vec::Vec, - >, pub map_consumer_id_producer_id: - ::core::option::Option<::planus::alloc::vec::Vec>, - pub map_producer_id_observer_ids: ::core::option::Option< + ::planus::alloc::vec::Vec, + pub map_producer_id_observer_ids: ::planus::alloc::vec::Vec, - >, - pub map_data_producer_id_data_consumer_ids: ::core::option::Option< + pub map_data_producer_id_data_consumer_ids: ::planus::alloc::vec::Vec, - >, pub map_data_consumer_id_data_producer_id: - ::core::option::Option<::planus::alloc::vec::Vec>, + ::planus::alloc::vec::Vec, } impl DumpResponse { @@ -32241,25 +32333,25 @@ mod root { pub fn create( builder: &mut ::planus::Builder, field_id: impl ::planus::WriteAs<::planus::Offset>, - field_transport_ids: impl ::planus::WriteAsOptional< + field_transport_ids: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - field_rtp_observer_ids: impl ::planus::WriteAsOptional< + field_rtp_observer_ids: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - field_map_producer_id_consumer_ids: impl ::planus::WriteAsOptional< + field_map_producer_id_consumer_ids: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - field_map_consumer_id_producer_id: impl ::planus::WriteAsOptional< + field_map_consumer_id_producer_id: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - field_map_producer_id_observer_ids: impl ::planus::WriteAsOptional< + field_map_producer_id_observer_ids: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - field_map_data_producer_id_data_consumer_ids: impl ::planus::WriteAsOptional< + 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::WriteAsOptional< + field_map_data_consumer_id_data_producer_id: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, ) -> ::planus::Offset { @@ -32288,87 +32380,33 @@ mod root { ::planus::table_writer::TableWriter::<18, 32>::new(builder); table_writer.calculate_size::<::planus::Offset>(2); - if prepared_transport_ids.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); - } - if prepared_rtp_observer_ids.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(6); - } - if prepared_map_producer_id_consumer_ids.is_some() { - table_writer.calculate_size::<::planus::Offset< - [::planus::Offset], - >>(8); - } - if prepared_map_consumer_id_producer_id.is_some() { - table_writer.calculate_size::<::planus::Offset< - [::planus::Offset], - >>(10); - } - if prepared_map_producer_id_observer_ids.is_some() { - table_writer.calculate_size::<::planus::Offset< - [::planus::Offset], - >>(12); - } - if prepared_map_data_producer_id_data_consumer_ids.is_some() { - table_writer.calculate_size::<::planus::Offset< - [::planus::Offset], - >>(14); - } - if prepared_map_data_consumer_id_data_producer_id.is_some() { - table_writer.calculate_size::<::planus::Offset< - [::planus::Offset], - >>(16); - } + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(6); + table_writer.calculate_size::<::planus::Offset< + [::planus::Offset], + >>(8); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(10); + table_writer.calculate_size::<::planus::Offset< + [::planus::Offset], + >>(12); + table_writer.calculate_size::<::planus::Offset< + [::planus::Offset], + >>(14); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(16); table_writer.finish_calculating(); unsafe { table_writer.write::<_, _, 4>(0, &prepared_id); - if let ::core::option::Option::Some(prepared_transport_ids) = - prepared_transport_ids - { - table_writer.write::<_, _, 4>(1, &prepared_transport_ids); - } - if let ::core::option::Option::Some(prepared_rtp_observer_ids) = - prepared_rtp_observer_ids - { - table_writer.write::<_, _, 4>(2, &prepared_rtp_observer_ids); - } - if let ::core::option::Option::Some(prepared_map_producer_id_consumer_ids) = - prepared_map_producer_id_consumer_ids - { - table_writer - .write::<_, _, 4>(3, &prepared_map_producer_id_consumer_ids); - } - if let ::core::option::Option::Some(prepared_map_consumer_id_producer_id) = - prepared_map_consumer_id_producer_id - { - table_writer.write::<_, _, 4>(4, &prepared_map_consumer_id_producer_id); - } - if let ::core::option::Option::Some(prepared_map_producer_id_observer_ids) = - prepared_map_producer_id_observer_ids - { - table_writer - .write::<_, _, 4>(5, &prepared_map_producer_id_observer_ids); - } - if let ::core::option::Option::Some( - prepared_map_data_producer_id_data_consumer_ids, - ) = prepared_map_data_producer_id_data_consumer_ids - { - table_writer.write::<_, _, 4>( - 6, - &prepared_map_data_producer_id_data_consumer_ids, - ); - } - if let ::core::option::Option::Some( - prepared_map_data_consumer_id_data_producer_id, - ) = prepared_map_data_consumer_id_data_producer_id - { - table_writer.write::<_, _, 4>( - 7, - &prepared_map_data_consumer_id_data_producer_id, - ); - } + table_writer.write::<_, _, 4>(1, &prepared_transport_ids); + table_writer.write::<_, _, 4>(2, &prepared_rtp_observer_ids); + table_writer.write::<_, _, 4>(3, &prepared_map_producer_id_consumer_ids); + table_writer.write::<_, _, 4>(4, &prepared_map_consumer_id_producer_id); + table_writer.write::<_, _, 4>(5, &prepared_map_producer_id_observer_ids); + table_writer + .write::<_, _, 4>(6, &prepared_map_data_producer_id_data_consumer_ids); + table_writer + .write::<_, _, 4>(7, &prepared_map_data_consumer_id_data_producer_id); } table_writer.finish() @@ -32427,85 +32465,69 @@ mod root { pub fn transport_ids( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - >, + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, > { - self.0.access(1, "DumpResponse", "transport_ids") + self.0.access_required(1, "DumpResponse", "transport_ids") } pub fn rtp_observer_ids( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - >, + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, > { - self.0.access(2, "DumpResponse", "rtp_observer_ids") + self.0 + .access_required(2, "DumpResponse", "rtp_observer_ids") } pub fn map_producer_id_consumer_ids( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector< - 'a, - ::planus::Result>, - >, - >, + ::planus::Vector<'a, ::planus::Result>>, > { self.0 - .access(3, "DumpResponse", "map_producer_id_consumer_ids") + .access_required(3, "DumpResponse", "map_producer_id_consumer_ids") } pub fn map_consumer_id_producer_id( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, + ::planus::Vector<'a, ::planus::Result>>, > { self.0 - .access(4, "DumpResponse", "map_consumer_id_producer_id") + .access_required(4, "DumpResponse", "map_consumer_id_producer_id") } pub fn map_producer_id_observer_ids( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector< - 'a, - ::planus::Result>, - >, - >, + ::planus::Vector<'a, ::planus::Result>>, > { self.0 - .access(5, "DumpResponse", "map_producer_id_observer_ids") + .access_required(5, "DumpResponse", "map_producer_id_observer_ids") } pub fn map_data_producer_id_data_consumer_ids( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector< - 'a, - ::planus::Result>, - >, - >, + ::planus::Vector<'a, ::planus::Result>>, > { - self.0 - .access(6, "DumpResponse", "map_data_producer_id_data_consumer_ids") + self.0.access_required( + 6, + "DumpResponse", + "map_data_producer_id_data_consumer_ids", + ) } pub fn map_data_consumer_id_data_producer_id( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, + ::planus::Vector<'a, ::planus::Result>>, > { - self.0 - .access(7, "DumpResponse", "map_data_consumer_id_data_producer_id") + self.0.access_required( + 7, + "DumpResponse", + "map_data_consumer_id_data_producer_id", + ) } } @@ -32513,58 +32535,28 @@ mod root { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut f = f.debug_struct("DumpResponseRef"); f.field("id", &self.id()); - if let ::core::option::Option::Some(field_transport_ids) = - self.transport_ids().transpose() - { - f.field("transport_ids", &field_transport_ids); - } - if let ::core::option::Option::Some(field_rtp_observer_ids) = - self.rtp_observer_ids().transpose() - { - f.field("rtp_observer_ids", &field_rtp_observer_ids); - } - if let ::core::option::Option::Some(field_map_producer_id_consumer_ids) = - self.map_producer_id_consumer_ids().transpose() - { - f.field( - "map_producer_id_consumer_ids", - &field_map_producer_id_consumer_ids, - ); - } - if let ::core::option::Option::Some(field_map_consumer_id_producer_id) = - self.map_consumer_id_producer_id().transpose() - { - f.field( - "map_consumer_id_producer_id", - &field_map_consumer_id_producer_id, - ); - } - if let ::core::option::Option::Some(field_map_producer_id_observer_ids) = - self.map_producer_id_observer_ids().transpose() - { - f.field( - "map_producer_id_observer_ids", - &field_map_producer_id_observer_ids, - ); - } - if let ::core::option::Option::Some( - field_map_data_producer_id_data_consumer_ids, - ) = self.map_data_producer_id_data_consumer_ids().transpose() - { - f.field( - "map_data_producer_id_data_consumer_ids", - &field_map_data_producer_id_data_consumer_ids, - ); - } - if let ::core::option::Option::Some( - field_map_data_consumer_id_data_producer_id, - ) = self.map_data_consumer_id_data_producer_id().transpose() - { - f.field( - "map_data_consumer_id_data_producer_id", - &field_map_data_consumer_id_data_producer_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() } } @@ -32576,72 +32568,23 @@ mod root { fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { id: ::core::convert::TryInto::try_into(value.id()?)?, - transport_ids: if let ::core::option::Option::Some(transport_ids) = - value.transport_ids()? - { - ::core::option::Option::Some(transport_ids.to_vec_result()?) - } else { - ::core::option::Option::None - }, - rtp_observer_ids: if let ::core::option::Option::Some(rtp_observer_ids) = - value.rtp_observer_ids()? - { - ::core::option::Option::Some(rtp_observer_ids.to_vec_result()?) - } else { - ::core::option::Option::None - }, - map_producer_id_consumer_ids: if let ::core::option::Option::Some( - map_producer_id_consumer_ids, - ) = value.map_producer_id_consumer_ids()? - { - ::core::option::Option::Some( - map_producer_id_consumer_ids.to_vec_result()?, - ) - } else { - ::core::option::Option::None - }, - map_consumer_id_producer_id: if let ::core::option::Option::Some( - map_consumer_id_producer_id, - ) = value.map_consumer_id_producer_id()? - { - ::core::option::Option::Some( - map_consumer_id_producer_id.to_vec_result()?, - ) - } else { - ::core::option::Option::None - }, - map_producer_id_observer_ids: if let ::core::option::Option::Some( - map_producer_id_observer_ids, - ) = value.map_producer_id_observer_ids()? - { - ::core::option::Option::Some( - map_producer_id_observer_ids.to_vec_result()?, - ) - } else { - ::core::option::Option::None - }, - map_data_producer_id_data_consumer_ids: - if let ::core::option::Option::Some( - map_data_producer_id_data_consumer_ids, - ) = value.map_data_producer_id_data_consumer_ids()? - { - ::core::option::Option::Some( - map_data_producer_id_data_consumer_ids.to_vec_result()?, - ) - } else { - ::core::option::Option::None - }, - map_data_consumer_id_data_producer_id: if let ::core::option::Option::Some( - map_data_consumer_id_data_producer_id, - ) = - value.map_data_consumer_id_data_producer_id()? - { - ::core::option::Option::Some( - map_data_consumer_id_data_producer_id.to_vec_result()?, - ) - } else { - ::core::option::Option::None - }, + 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()?, }) } } @@ -35116,15 +35059,13 @@ mod root { )] pub struct DumpResponse { pub id: ::planus::alloc::string::String, - pub udp_sockets: ::core::option::Option<::planus::alloc::vec::Vec>, - pub tcp_servers: ::core::option::Option<::planus::alloc::vec::Vec>, - pub web_rtc_transport_ids: ::core::option::Option< + pub udp_sockets: ::planus::alloc::vec::Vec, + pub tcp_servers: ::planus::alloc::vec::Vec, + pub web_rtc_transport_ids: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - >, pub local_ice_username_fragments: - ::core::option::Option<::planus::alloc::vec::Vec>, - pub tuple_hashes: - ::core::option::Option<::planus::alloc::vec::Vec>, + ::planus::alloc::vec::Vec, + pub tuple_hashes: ::planus::alloc::vec::Vec, } impl DumpResponse { @@ -35132,19 +35073,19 @@ mod root { pub fn create( builder: &mut ::planus::Builder, field_id: impl ::planus::WriteAs<::planus::Offset>, - field_udp_sockets: impl ::planus::WriteAsOptional< + field_udp_sockets: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - field_tcp_servers: impl ::planus::WriteAsOptional< + field_tcp_servers: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - field_web_rtc_transport_ids: impl ::planus::WriteAsOptional< + field_web_rtc_transport_ids: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - field_local_ice_username_fragments: impl ::planus::WriteAsOptional< + field_local_ice_username_fragments: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - field_tuple_hashes: impl ::planus::WriteAsOptional< + field_tuple_hashes: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, ) -> ::planus::Offset { @@ -35166,58 +35107,26 @@ mod root { ::planus::table_writer::TableWriter::<14, 24>::new(builder); table_writer.calculate_size::<::planus::Offset>(2); - if prepared_udp_sockets.is_some() { - table_writer - .calculate_size::<::planus::Offset<[::planus::Offset]>>( - 4, - ); - } - if prepared_tcp_servers.is_some() { - table_writer - .calculate_size::<::planus::Offset<[::planus::Offset]>>( - 6, - ); - } - if prepared_web_rtc_transport_ids.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(8); - } - if prepared_local_ice_username_fragments.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(10); - } - if prepared_tuple_hashes.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(12); - } + table_writer + .calculate_size::<::planus::Offset<[::planus::Offset]>>(4); + table_writer + .calculate_size::<::planus::Offset<[::planus::Offset]>>(6); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(8); + table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(10); + table_writer + .calculate_size::<::planus::Offset<[::planus::Offset]>>( + 12, + ); table_writer.finish_calculating(); unsafe { table_writer.write::<_, _, 4>(0, &prepared_id); - if let ::core::option::Option::Some(prepared_udp_sockets) = - prepared_udp_sockets - { - table_writer.write::<_, _, 4>(1, &prepared_udp_sockets); - } - if let ::core::option::Option::Some(prepared_tcp_servers) = - prepared_tcp_servers - { - table_writer.write::<_, _, 4>(2, &prepared_tcp_servers); - } - if let ::core::option::Option::Some(prepared_web_rtc_transport_ids) = - prepared_web_rtc_transport_ids - { - table_writer.write::<_, _, 4>(3, &prepared_web_rtc_transport_ids); - } - if let ::core::option::Option::Some(prepared_local_ice_username_fragments) = - prepared_local_ice_username_fragments - { - table_writer - .write::<_, _, 4>(4, &prepared_local_ice_username_fragments); - } - if let ::core::option::Option::Some(prepared_tuple_hashes) = - prepared_tuple_hashes - { - table_writer.write::<_, _, 4>(5, &prepared_tuple_hashes); - } + table_writer.write::<_, _, 4>(1, &prepared_udp_sockets); + table_writer.write::<_, _, 4>(2, &prepared_tcp_servers); + table_writer.write::<_, _, 4>(3, &prepared_web_rtc_transport_ids); + table_writer.write::<_, _, 4>(4, &prepared_local_ice_username_fragments); + table_writer.write::<_, _, 4>(5, &prepared_tuple_hashes); } table_writer.finish() @@ -35273,53 +35182,41 @@ mod root { pub fn udp_sockets( &self, - ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, - > { - self.0.access(1, "DumpResponse", "udp_sockets") + ) -> ::planus::Result<::planus::Vector<'a, ::planus::Result>>> + { + self.0.access_required(1, "DumpResponse", "udp_sockets") } pub fn tcp_servers( &self, - ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, - > { - self.0.access(2, "DumpResponse", "tcp_servers") + ) -> ::planus::Result<::planus::Vector<'a, ::planus::Result>>> + { + self.0.access_required(2, "DumpResponse", "tcp_servers") } pub fn web_rtc_transport_ids( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - >, + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, > { - self.0.access(3, "DumpResponse", "web_rtc_transport_ids") + self.0 + .access_required(3, "DumpResponse", "web_rtc_transport_ids") } pub fn local_ice_username_fragments( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, + ::planus::Vector<'a, ::planus::Result>>, > { self.0 - .access(4, "DumpResponse", "local_ice_username_fragments") + .access_required(4, "DumpResponse", "local_ice_username_fragments") } pub fn tuple_hashes( &self, - ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, - > { - self.0.access(5, "DumpResponse", "tuple_hashes") + ) -> ::planus::Result<::planus::Vector<'a, ::planus::Result>>> + { + self.0.access_required(5, "DumpResponse", "tuple_hashes") } } @@ -35327,34 +35224,14 @@ mod root { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut f = f.debug_struct("DumpResponseRef"); f.field("id", &self.id()); - if let ::core::option::Option::Some(field_udp_sockets) = - self.udp_sockets().transpose() - { - f.field("udp_sockets", &field_udp_sockets); - } - if let ::core::option::Option::Some(field_tcp_servers) = - self.tcp_servers().transpose() - { - f.field("tcp_servers", &field_tcp_servers); - } - if let ::core::option::Option::Some(field_web_rtc_transport_ids) = - self.web_rtc_transport_ids().transpose() - { - f.field("web_rtc_transport_ids", &field_web_rtc_transport_ids); - } - if let ::core::option::Option::Some(field_local_ice_username_fragments) = - self.local_ice_username_fragments().transpose() - { - f.field( - "local_ice_username_fragments", - &field_local_ice_username_fragments, - ); - } - if let ::core::option::Option::Some(field_tuple_hashes) = - self.tuple_hashes().transpose() - { - f.field("tuple_hashes", &field_tuple_hashes); - } + 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() } } @@ -35366,45 +35243,13 @@ mod root { fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { id: ::core::convert::TryInto::try_into(value.id()?)?, - udp_sockets: if let ::core::option::Option::Some(udp_sockets) = - value.udp_sockets()? - { - ::core::option::Option::Some(udp_sockets.to_vec_result()?) - } else { - ::core::option::Option::None - }, - tcp_servers: if let ::core::option::Option::Some(tcp_servers) = - value.tcp_servers()? - { - ::core::option::Option::Some(tcp_servers.to_vec_result()?) - } else { - ::core::option::Option::None - }, - web_rtc_transport_ids: if let ::core::option::Option::Some( - web_rtc_transport_ids, - ) = value.web_rtc_transport_ids()? - { - ::core::option::Option::Some(web_rtc_transport_ids.to_vec_result()?) - } else { - ::core::option::Option::None - }, - local_ice_username_fragments: if let ::core::option::Option::Some( - local_ice_username_fragments, - ) = value.local_ice_username_fragments()? - { - ::core::option::Option::Some( - local_ice_username_fragments.to_vec_result()?, - ) - } else { - ::core::option::Option::None - }, - tuple_hashes: if let ::core::option::Option::Some(tuple_hashes) = - value.tuple_hashes()? - { - ::core::option::Option::Some(tuple_hashes.to_vec_result()?) - } else { - ::core::option::Option::None - }, + 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()?, }) } } @@ -39333,15 +39178,7 @@ mod root { } #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct GetStatsResponse { pub base: ::planus::alloc::boxed::Box, @@ -40705,15 +40542,7 @@ mod root { } #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct GetStatsResponse { pub base: ::planus::alloc::boxed::Box, @@ -43565,15 +43394,7 @@ mod root { } #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct GetStatsResponse { pub base: ::planus::alloc::boxed::Box, diff --git a/rust/src/macros.rs b/rust/src/macros.rs index 5fd5d4d128..f331a0ba00 100644 --- a/rust/src/macros.rs +++ b/rust/src/macros.rs @@ -18,7 +18,7 @@ macro_rules! uuid_based_wrapper_type { Eq, PartialEq, )] - pub struct $struct_name(uuid::Uuid); + pub struct $struct_name(::uuid::Uuid); impl std::fmt::Display for $struct_name { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -26,7 +26,15 @@ macro_rules! uuid_based_wrapper_type { } } - impl From<$struct_name> for uuid::Uuid { + impl ::std::str::FromStr for $struct_name { + type Err = ::uuid::Error; + + fn from_str(s: &str) -> Result { + ::uuid::Uuid::from_str(s).map(Self) + } + } + + impl From<$struct_name> for ::uuid::Uuid { fn from(id: $struct_name) -> Self { id.0 } @@ -34,7 +42,7 @@ macro_rules! uuid_based_wrapper_type { impl $struct_name { pub(super) fn new() -> Self { - $struct_name(uuid::Uuid::new_v4()) + $struct_name(::uuid::Uuid::new_v4()) } } diff --git a/rust/src/messages.rs b/rust/src/messages.rs index e09f22b5af..8d7c6ad84c 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -11,6 +11,7 @@ use crate::data_structures::{ SctpState, TransportTuple, }; use crate::direct_transport::DirectTransportOptions; +use crate::fbs::{direct_transport, message, request, response, router, transport, worker}; use crate::ortc::RtpMapping; use crate::pipe_transport::PipeTransportOptions; use crate::plain_transport::PlainTransportOptions; @@ -23,13 +24,18 @@ use crate::rtp_parameters::{MediaKind, RtpEncodingParameters, RtpParameters}; use crate::sctp_parameters::{NumSctpStreams, SctpParameters, SctpStreamParameters}; use crate::srtp_parameters::{SrtpCryptoSuite, SrtpParameters}; use crate::transport::{TransportId, TransportTraceEventType}; -use crate::webrtc_server::{WebRtcServerDump, WebRtcServerId, WebRtcServerListenInfos}; +use crate::webrtc_server::{ + WebRtcServerDump, WebRtcServerIceUsernameFragment, WebRtcServerId, WebRtcServerIpPort, + WebRtcServerListenInfos, WebRtcServerTupleHash, +}; use crate::webrtc_transport::{TransportListenIps, WebRtcTransportListen, WebRtcTransportOptions}; -use crate::worker::WorkerDump; +use crate::worker::{ChannelMessageHandlers, WorkerDump, WorkerUpdateSettings}; use parking_lot::Mutex; +use planus::Builder; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use serde_json::Value; +use std::error::Error; use std::fmt::{Debug, Display}; use std::net::IpAddr; use std::num::NonZeroU16; @@ -51,6 +57,29 @@ where } } +pub(crate) trait RequestFbs +where + Self: Debug, +{ + /// Request method to call on worker. + const METHOD: request::Method; + type HandlerId: Display; + type Response; + + /// Get a serialized message out of this request. + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec; + + /// Default response to return in case of soft error, such as channel already closed, entity + /// doesn't exist on worker during closing. + fn default_for_soft_error() -> Option { + None + } + + /// Convert generic response into specific type of this request. + fn convert_response(response: Option) + -> Result>; +} + pub(crate) trait Notification: Debug + Serialize { type HandlerId: Display; @@ -58,6 +87,97 @@ pub(crate) trait Notification: Debug + Serialize { fn as_event(&self) -> &'static str; } +// macro_rules! request_response_fbs { +// ( +// $handler_id_type: ty, +// $method: literal, +// $request_struct_name: ident { $( $(#[$request_field_name_attributes: meta])? $request_field_name: ident: $request_field_type: ty$(,)? )* }, +// $existing_response_type: ty, +// $default_for_soft_error: expr $(,)? +// ) => { +// #[derive(Debug, Serialize)] +// #[serde(rename_all = "camelCase")] +// pub(crate) struct $request_struct_name { +// $( +// $(#[$request_field_name_attributes])* +// pub(crate) $request_field_name: $request_field_type, +// )* +// } +// +// impl RequestFbs for $request_struct_name { +// type HandlerId = $handler_id_type; +// type Response = $existing_response_type; +// +// fn as_method(&self) -> &'static str { +// $method +// } +// +// fn default_for_soft_error() -> Option { +// $default_for_soft_error +// } +// } +// }; +// // Call above macro with no default for soft error +// ( +// $handler_id_type: ty, +// $method: literal, +// $request_struct_name: ident $request_struct_impl: tt $(,)? +// $existing_response_type: ty $(,)? +// ) => { +// request_response!( +// $handler_id_type, +// $method, +// $request_struct_name $request_struct_impl, +// $existing_response_type, +// None, +// ); +// }; +// // Call above macro with unit type as expected response +// ( +// $handler_id_type: ty, +// $method: literal, +// $request_struct_name: ident $request_struct_impl: tt $(,)? +// ) => { +// request_response!( +// $handler_id_type, +// $method, +// $request_struct_name $request_struct_impl, +// (), +// None, +// ); +// }; +// ( +// $handler_id_type: ty, +// $method: literal, +// $request_struct_name: ident { $( $(#[$request_field_name_attributes: meta])? $request_field_name: ident: $request_field_type: ty$(,)? )* }, +// $response_struct_name: ident { $( $response_field_name: ident: $response_field_type: ty$(,)? )* }, +// ) => { +// #[derive(Debug, Serialize)] +// #[serde(rename_all = "camelCase")] +// pub(crate) struct $request_struct_name { +// $( +// $(#[$request_field_name_attributes])* +// pub(crate) $request_field_name: $request_field_type, +// )* +// } +// +// #[derive(Debug, Deserialize)] +// #[serde(rename_all = "camelCase")] +// pub(crate) struct $response_struct_name { +// $( pub(crate) $response_field_name: $response_field_type, )* +// } +// +// impl RequestFbs for $request_struct_name { +// type HandlerId = $handler_id_type; +// type Response = $response_struct_name; +// +// fn as_method(&self) -> &'static str { +// $method +// } +// } +// }; +// } + macro_rules! request_response { ( $handler_id_type: ty, @@ -149,54 +269,464 @@ macro_rules! request_response { }; } -request_response!(&'static str, "worker.close", WorkerCloseRequest {}); +#[derive(Debug)] +pub(crate) struct WorkerCloseRequest {} -request_response!( - &'static str, - "worker.dump", - WorkerDumpRequest {}, - WorkerDump -); +impl RequestFbs for WorkerCloseRequest { + const METHOD: request::Method = request::Method::WorkerClose; + type HandlerId = &'static str; + type Response = (); -request_response!( - &'static str, - "worker.createWebRtcServer", - WorkerCreateWebRtcServerRequest { - #[serde(rename = "webRtcServerId")] - webrtc_server_id: WebRtcServerId, - listen_infos: WebRtcServerListenInfos, - }, -); + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); -request_response!( - &'static str, - "worker.closeWebRtcServer", - WebRtcServerCloseRequest { - #[serde(rename = "webRtcServerId")] - webrtc_server_id: WebRtcServerId, - }, - (), - Some(()), -); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); -request_response!( - WebRtcServerId, - "webRtcServer.dump", - WebRtcServerDumpRequest {}, - WebRtcServerDump, -); + builder.finish(message, None).to_vec() + } -request_response!( - &'static str, - "worker.closeRouter", - RouterCloseRequest { - router_id: RouterId, - }, - (), - Some(()), -); + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug)] +pub(crate) struct WorkerDumpRequest {} + +impl RequestFbs for WorkerDumpRequest { + const METHOD: request::Method = request::Method::WorkerDump; + type HandlerId = &'static str; + type Response = WorkerDump; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); -request_response!(RouterId, "router.dump", RouterDumpRequest {}, RouterDump); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::FbsWorkerDumpResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(WorkerDump { + router_ids: data + .router_ids + .into_iter() + .map(|id| id.parse()) + .collect::>()?, + webrtc_server_ids: data + .web_rtc_server_ids + .into_iter() + .map(|id| id.parse()) + .collect::>()?, + channel_message_handlers: ChannelMessageHandlers { + channel_request_handlers: data + .channel_message_handlers + .channel_request_handlers + .into_iter() + .map(|id| id.parse()) + .collect::>()?, + channel_notification_handlers: data + .channel_message_handlers + .channel_notification_handlers + .into_iter() + .map(|id| id.parse()) + .collect::>()?, + }, + }) + } +} + +#[derive(Debug)] +pub(crate) struct WorkerUpdateSettingsRequest { + pub(crate) data: WorkerUpdateSettings, +} + +impl RequestFbs for WorkerUpdateSettingsRequest { + const METHOD: request::Method = request::Method::WorkerUpdateSettings; + type HandlerId = &'static str; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = worker::UpdateSettingsRequest::create( + &mut builder, + self.data + .log_level + .as_ref() + .map(|log_level| log_level.as_str()), + self.data.log_tags.as_ref().map(|log_tags| { + log_tags + .iter() + .map(|log_tag| log_tag.as_str()) + .collect::>() + }), + ); + let request_body = request::Body::create_update_settings_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug)] +pub(crate) struct WorkerCreateWebRtcServerRequest { + pub(crate) webrtc_server_id: WebRtcServerId, + pub(crate) listen_infos: WebRtcServerListenInfos, +} + +impl RequestFbs for WorkerCreateWebRtcServerRequest { + const METHOD: request::Method = request::Method::WorkerCreateWebrtcServer; + type HandlerId = &'static str; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = worker::CreateWebRtcServerRequest::create( + &mut builder, + self.webrtc_server_id.to_string(), + self.listen_infos.to_fbs(), + ); + let request_body = request::Body::create_create_web_rtc_server_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug)] +pub(crate) struct WebRtcServerCloseRequest { + pub(crate) webrtc_server_id: WebRtcServerId, +} + +impl RequestFbs for WebRtcServerCloseRequest { + const METHOD: request::Method = request::Method::WorkerWebrtcServerClose; + type HandlerId = &'static str; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let data = worker::CloseWebRtcServerRequest::create( + &mut builder, + self.webrtc_server_id.to_string(), + ); + let request_body = request::Body::create_close_web_rtc_server_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug)] +pub(crate) struct WebRtcServerDumpRequest {} + +impl RequestFbs for WebRtcServerDumpRequest { + const METHOD: request::Method = request::Method::WebrtcServerDump; + type HandlerId = WebRtcServerId; + type Response = WebRtcServerDump; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::FbsWebRtcServerDumpResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(WebRtcServerDump { + id: data.id.parse()?, + udp_sockets: data + .udp_sockets + .into_iter() + .map(|ip_port| WebRtcServerIpPort { + ip: ip_port.ip.parse().unwrap(), + port: ip_port.port, + }) + .collect(), + tcp_servers: data + .tcp_servers + .into_iter() + .map(|ip_port| WebRtcServerIpPort { + ip: ip_port.ip.parse().unwrap(), + port: ip_port.port, + }) + .collect(), + webrtc_transport_ids: data + .web_rtc_transport_ids + .into_iter() + .map(|id| id.parse()) + .collect::>()?, + local_ice_username_fragments: data + .local_ice_username_fragments + .into_iter() + .map(|username_fragment| WebRtcServerIceUsernameFragment { + local_ice_username_fragment: username_fragment + .local_ice_username_fragment + .parse() + .unwrap(), + webrtc_transport_id: username_fragment.web_rtc_transport_id.parse().unwrap(), + }) + .collect(), + tuple_hashes: data + .tuple_hashes + .into_iter() + .map(|tuple_hash| WebRtcServerTupleHash { + tuple_hash: tuple_hash.local_ice_username_fragment, + webrtc_transport_id: tuple_hash.web_rtc_transport_id.parse().unwrap(), + }) + .collect(), + }) + } +} + +#[derive(Debug)] +pub(crate) struct WorkerCreateRouterRequest { + pub(crate) router_id: RouterId, +} + +impl RequestFbs for WorkerCreateRouterRequest { + const METHOD: request::Method = request::Method::WorkerCreateRouter; + type HandlerId = &'static str; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = worker::CreateRouterRequest::create(&mut builder, self.router_id.to_string()); + let request_body = request::Body::create_create_router_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug)] +pub(crate) struct RouterCloseRequest { + pub(crate) router_id: RouterId, +} + +impl RequestFbs for RouterCloseRequest { + const METHOD: request::Method = request::Method::WorkerCloseRouter; + type HandlerId = &'static str; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let data = worker::CloseRouterRequest::create(&mut builder, self.router_id.to_string()); + let request_body = request::Body::create_close_router_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug)] +pub(crate) struct RouterDumpRequest {} + +impl RequestFbs for RouterDumpRequest { + const METHOD: request::Method = request::Method::RouterDump; + type HandlerId = RouterId; + type Response = RouterDump; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::FbsRouterDumpResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(RouterDump { + id: data.id.parse()?, + map_consumer_id_producer_id: data + .map_consumer_id_producer_id + .into_iter() + .map(|key_value| Ok((key_value.key.parse()?, key_value.value.parse()?))) + .collect::>>()?, + map_data_consumer_id_data_producer_id: data + .map_data_consumer_id_data_producer_id + .into_iter() + .map(|key_value| Ok((key_value.key.parse()?, key_value.value.parse()?))) + .collect::>>()?, + map_data_producer_id_data_consumer_ids: data + .map_data_producer_id_data_consumer_ids + .into_iter() + .map(|key_values| { + Ok(( + key_values.key.parse()?, + key_values + .values + .into_iter() + .map(|value| value.parse()) + .collect::>()?, + )) + }) + .collect::>>()?, + map_producer_id_consumer_ids: data + .map_producer_id_consumer_ids + .into_iter() + .map(|key_values| { + Ok(( + key_values.key.parse()?, + key_values + .values + .into_iter() + .map(|value| value.parse()) + .collect::>()?, + )) + }) + .collect::>>()?, + map_producer_id_observer_ids: data + .map_producer_id_observer_ids + .into_iter() + .map(|key_values| { + Ok(( + key_values.key.parse()?, + key_values + .values + .into_iter() + .map(|value| value.parse()) + .collect::>()?, + )) + }) + .collect::>>()?, + rtp_observer_ids: data + .rtp_observer_ids + .into_iter() + .map(|id| id.parse()) + .collect::>()?, + transport_ids: data + .transport_ids + .into_iter() + .map(|id| id.parse()) + .collect::>()?, + }) + } +} #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] @@ -217,17 +747,61 @@ impl RouterCreateDirectTransportData { max_message_size: direct_transport_options.max_message_size, } } + + pub(crate) fn to_fbs(&self) -> direct_transport::DirectTransportOptions { + direct_transport::DirectTransportOptions { + base: Box::new(transport::Options { + direct: true, + max_message_size: u32::try_from(self.max_message_size).unwrap(), + initial_available_outgoing_bitrate: 0, + enable_sctp: false, + num_sctp_streams: None, + max_sctp_message_size: 0, + sctp_send_buffer_size: 0, + is_data_channel: false, + }), + } + } } -request_response!( - RouterId, - "router.createDirectTransport", - RouterCreateDirectTransportRequest { - #[serde(flatten)] - data: RouterCreateDirectTransportData, - }, - RouterCreateDirectTransportResponse {}, -); +#[derive(Debug)] +pub(crate) struct RouterCreateDirectTransportRequest { + pub(crate) data: RouterCreateDirectTransportData, +} + +impl RequestFbs for RouterCreateDirectTransportRequest { + const METHOD: request::Method = request::Method::RouterCreateDirectTransport; + type HandlerId = RouterId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = router::CreateDirectTransportRequest::create( + &mut builder, + self.data.transport_id.to_string(), + self.data.to_fbs(), + ); + let request_body = + request::Body::create_create_direct_transport_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} #[derive(Debug, Serialize)] #[serde(untagged)] @@ -514,6 +1088,41 @@ request_response!( Value, ); +#[derive(Debug)] +pub(crate) struct TransportDumpRequestNew {} + +impl RequestFbs for TransportDumpRequestNew { + const METHOD: request::Method = request::Method::TransportDump; + type HandlerId = TransportId; + type Response = response::Body; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + match response { + Some(data) => Ok(data), + _ => { + panic!("Wrong message from worker: {response:?}"); + } + } + } +} request_response!( TransportId, "transport.getStats", @@ -521,6 +1130,42 @@ request_response!( Value, ); +#[derive(Debug)] +pub(crate) struct TransportGetStatsRequestNew {} + +impl RequestFbs for TransportGetStatsRequestNew { + const METHOD: request::Method = request::Method::TransportGetStats; + type HandlerId = TransportId; + type Response = response::Body; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + match response { + Some(data) => Ok(data), + _ => { + panic!("Wrong message from worker: {response:?}"); + } + } + } +} + request_response!( TransportId, "transport.connect", diff --git a/rust/src/router.rs b/rust/src/router.rs index bca8accb7e..8fed49fa38 100644 --- a/rust/src/router.rs +++ b/rust/src/router.rs @@ -170,7 +170,7 @@ pub struct PipeProducerToRouterPair { } /// Error that caused [`Router::pipe_producer_to_router()`] to fail. -#[derive(Debug, Error, Eq, PartialEq)] +#[derive(Debug, Error)] pub enum PipeProducerToRouterError { /// Destination router must be different #[error("Destination router must be different")] @@ -398,7 +398,7 @@ impl Inner { let request = RouterCloseRequest { router_id: self.id }; self.executor .spawn(async move { - if let Err(error) = channel.request("", request).await { + if let Err(error) = channel.request_fbs("", request).await { error!("router closing failed on drop: {}", error); } }) @@ -529,7 +529,7 @@ impl Router { self.inner .channel - .request(self.inner.id, RouterDumpRequest {}) + .request_fbs(self.inner.id, RouterDumpRequest {}) .await } @@ -558,7 +558,7 @@ impl Router { self.inner .channel - .request( + .request_fbs( self.inner.id, RouterCreateDirectTransportRequest { data: RouterCreateDirectTransportData::from_options( diff --git a/rust/src/router/direct_transport.rs b/rust/src/router/direct_transport.rs index 87272f8e18..7c724bf4ad 100644 --- a/rust/src/router/direct_transport.rs +++ b/rust/src/router/direct_transport.rs @@ -5,6 +5,7 @@ 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, response}; use crate::messages::{TransportCloseRequest, TransportSendRtcpNotification}; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; @@ -23,6 +24,7 @@ use log::{debug, error}; use nohash_hasher::IntMap; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; +use std::error::Error; use std::fmt; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::{Arc, Weak}; @@ -57,17 +59,85 @@ pub struct DirectTransportDump { pub direct: bool, pub producer_ids: Vec, pub consumer_ids: Vec, - pub map_ssrc_consumer_id: IntMap, - pub map_rtx_ssrc_consumer_id: IntMap, + pub map_ssrc_consumer_id: Vec<(u32, ConsumerId)>, + pub map_rtx_ssrc_consumer_id: Vec<(u32, ConsumerId)>, pub data_producer_ids: Vec, pub data_consumer_ids: Vec, pub recv_rtp_header_extensions: RecvRtpHeaderExtensions, pub rtp_listener: RtpListener, - pub max_message_size: usize, + pub max_message_size: u32, pub sctp_parameters: Option, pub sctp_state: Option, pub sctp_listener: Option, - pub trace_event_types: String, + pub trace_event_types: Vec, +} + +impl DirectTransportDump { + pub(crate) fn from_fbs(dump: direct_transport::DumpResponse) -> Result> { + Ok(Self { + id: dump.base.id.parse()?, + direct: true, + producer_ids: dump + .base + .producer_ids + .iter() + .map(|producer_id| Ok(producer_id.parse()?)) + .collect::>>()?, + consumer_ids: dump + .base + .consumer_ids + .iter() + .map(|consumer_id| Ok(consumer_id.parse()?)) + .collect::>>()?, + map_ssrc_consumer_id: dump + .base + .map_ssrc_consumer_id + .iter() + .map(|key_value| Ok((key_value.key, key_value.value.parse()?))) + .collect::>>()?, + map_rtx_ssrc_consumer_id: dump + .base + .map_rtx_ssrc_consumer_id + .iter() + .map(|key_value| Ok((key_value.key, key_value.value.parse()?))) + .collect::>>()?, + data_producer_ids: dump + .base + .data_producer_ids + .iter() + .map(|data_producer_id| Ok(data_producer_id.parse()?)) + .collect::>>()?, + data_consumer_ids: dump + .base + .data_consumer_ids + .iter() + .map(|data_consumer_id| Ok(data_consumer_id.parse()?)) + .collect::>>()?, + recv_rtp_header_extensions: RecvRtpHeaderExtensions::from_fbs( + dump.base.recv_rtp_header_extensions.as_ref(), + ), + rtp_listener: RtpListener::from_fbs(dump.base.rtp_listener.as_ref())?, + max_message_size: dump.base.max_message_size, + sctp_parameters: dump + .base + .sctp_parameters + .as_ref() + .map(|parameters| SctpParameters::from_fbs(parameters.as_ref())), + sctp_state: dump + .base + .sctp_state + .map(|state| SctpState::from_fbs(&state)), + sctp_listener: dump.base.sctp_listener.as_ref().map(|listener| { + SctpListener::from_fbs(listener.as_ref()).expect("Error parsing SctpListner") + }), + trace_event_types: dump + .base + .trace_event_types + .iter() + .map(|event| event.to_string()) + .collect(), + }) + } } /// RTC statistics of the direct transport. @@ -77,36 +147,69 @@ pub struct DirectTransportDump { #[allow(missing_docs)] pub struct DirectTransportStat { // Common to all Transports. - // `type` field is present in worker, but ignored here pub transport_id: TransportId, pub timestamp: u64, pub sctp_state: Option, - pub bytes_received: usize, + pub bytes_received: u64, pub recv_bitrate: u32, - pub bytes_sent: usize, + pub bytes_sent: u64, pub send_bitrate: u32, - pub rtp_bytes_received: usize, + pub rtp_bytes_received: u64, pub rtp_recv_bitrate: u32, - pub rtp_bytes_sent: usize, + pub rtp_bytes_sent: u64, pub rtp_send_bitrate: u32, - pub rtx_bytes_received: usize, + pub rtx_bytes_received: u64, pub rtx_recv_bitrate: u32, - pub rtx_bytes_sent: usize, + pub rtx_bytes_sent: u64, pub rtx_send_bitrate: u32, - pub probation_bytes_sent: usize, + pub probation_bytes_sent: u64, pub probation_send_bitrate: u32, #[serde(skip_serializing_if = "Option::is_none")] pub available_outgoing_bitrate: Option, #[serde(skip_serializing_if = "Option::is_none")] pub available_incoming_bitrate: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub max_incoming_bitrate: Option, + pub max_incoming_bitrate: u32, + pub max_outgoing_bitrate: u32, + pub min_outgoing_bitrate: u32, #[serde(skip_serializing_if = "Option::is_none")] pub rtp_packet_loss_received: Option, #[serde(skip_serializing_if = "Option::is_none")] pub rtp_packet_loss_sent: Option, } +impl DirectTransportStat { + pub(crate) fn from_fbs( + stats: direct_transport::GetStatsResponse, + ) -> Result> { + Ok(Self { + transport_id: stats.base.transport_id.parse()?, + timestamp: stats.base.timestamp, + sctp_state: stats.base.sctp_state.as_ref().map(SctpState::from_fbs), + bytes_received: stats.base.bytes_received, + recv_bitrate: stats.base.recv_bitrate, + bytes_sent: stats.base.bytes_sent, + send_bitrate: stats.base.send_bitrate, + rtp_bytes_received: stats.base.rtp_bytes_received, + rtp_recv_bitrate: stats.base.rtp_recv_bitrate, + rtp_bytes_sent: stats.base.rtp_bytes_sent, + rtp_send_bitrate: stats.base.rtp_send_bitrate, + rtx_bytes_received: stats.base.rtx_bytes_received, + rtx_recv_bitrate: stats.base.rtx_recv_bitrate, + rtx_bytes_sent: stats.base.rtx_bytes_sent, + rtx_send_bitrate: stats.base.rtx_send_bitrate, + probation_bytes_sent: stats.base.probation_bytes_sent, + probation_send_bitrate: stats.base.probation_send_bitrate, + available_outgoing_bitrate: stats.base.available_outgoing_bitrate, + available_incoming_bitrate: stats.base.available_incoming_bitrate, + max_incoming_bitrate: stats.base.max_incoming_bitrate, + max_outgoing_bitrate: stats.base.max_outgoing_bitrate, + min_outgoing_bitrate: stats.base.min_outgoing_bitrate, + rtp_packet_loss_received: stats.base.rtp_packet_loss_received, + rtp_packet_loss_sent: stats.base.rtp_packet_loss_sent, + }) + } +} + #[derive(Default)] #[allow(clippy::type_complexity)] struct Handlers { @@ -367,11 +470,11 @@ impl TransportGeneric for DirectTransport { async fn dump(&self) -> Result { debug!("dump()"); - serde_json::from_value(self.dump_impl().await?).map_err(|error| { - RequestError::FailedToParse { - error: error.to_string(), - } - }) + if let response::Body::FbsDirectTransportDumpResponse(data) = self.dump_impl().await? { + Ok(DirectTransportDump::from_fbs(*data).expect("Error parsing dump response")) + } else { + panic!("Wrong message from worker"); + } } /// Returns current RTC statistics of the transport. @@ -381,11 +484,15 @@ impl TransportGeneric for DirectTransport { async fn get_stats(&self) -> Result, RequestError> { debug!("get_stats()"); - serde_json::from_value(self.get_stats_impl().await?).map_err(|error| { - RequestError::FailedToParse { - error: error.to_string(), - } - }) + if let response::Body::FbsDirectTransportGetStatsResponse(data) = + self.get_stats_impl().await? + { + Ok(vec![ + DirectTransportStat::from_fbs(*data).expect("Error parsing dump response") + ]) + } else { + panic!("Wrong message from worker"); + } } } diff --git a/rust/src/router/pipe_transport.rs b/rust/src/router/pipe_transport.rs index cb064463bc..e38df43481 100644 --- a/rust/src/router/pipe_transport.rs +++ b/rust/src/router/pipe_transport.rs @@ -413,21 +413,28 @@ impl TransportGeneric for PipeTransport { async fn dump(&self) -> Result { debug!("dump()"); + todo!(); + /* serde_json::from_value(self.dump_impl().await?).map_err(|error| { RequestError::FailedToParse { error: error.to_string(), } }) + */ } async fn get_stats(&self) -> Result, RequestError> { debug!("get_stats()"); + todo!(); + + /* serde_json::from_value(self.get_stats_impl().await?).map_err(|error| { RequestError::FailedToParse { error: error.to_string(), } }) + */ } } diff --git a/rust/src/router/plain_transport.rs b/rust/src/router/plain_transport.rs index c806751d50..a88b01afa6 100644 --- a/rust/src/router/plain_transport.rs +++ b/rust/src/router/plain_transport.rs @@ -443,21 +443,28 @@ impl TransportGeneric for PlainTransport { async fn dump(&self) -> Result { debug!("dump()"); + todo!(); + /* serde_json::from_value(self.dump_impl().await?).map_err(|error| { RequestError::FailedToParse { error: error.to_string(), } }) + */ } async fn get_stats(&self) -> Result, RequestError> { debug!("get_stats()"); + todo!(); + + /* serde_json::from_value(self.get_stats_impl().await?).map_err(|error| { RequestError::FailedToParse { error: error.to_string(), } }) + */ } } diff --git a/rust/src/router/transport.rs b/rust/src/router/transport.rs index d15771596e..bdad899f6e 100644 --- a/rust/src/router/transport.rs +++ b/rust/src/router/transport.rs @@ -2,9 +2,10 @@ 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, + TransportConsumeDataRequest, TransportConsumeRequest, TransportDumpRequestNew, + TransportEnableTraceEventRequest, TransportGetStatsRequestNew, TransportProduceDataRequest, TransportProduceRequest, TransportSetMaxIncomingBitrateRequest, TransportSetMaxOutgoingBitrateRequest, TransportSetMinOutgoingBitrateRequest, }; @@ -20,13 +21,11 @@ use crate::{ortc, uuid_based_wrapper_type}; use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::HandlerId; -use hash_hasher::HashedMap; use log::{error, warn}; use nohash_hasher::IntMap; use parking_lot::Mutex; -use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; -use serde_json::Value; +use std::error::Error; use std::fmt::Debug; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; @@ -79,12 +78,34 @@ pub enum TransportTraceEventType { #[serde(rename_all = "camelCase")] #[doc(hidden)] pub struct RtpListener { - /// Map from Ssrc (as string) to producer ID - pub mid_table: HashedMap, - /// Map from Ssrc (as string) to producer ID - pub rid_table: HashedMap, - /// Map from Ssrc (as string) to producer ID - pub ssrc_table: HashedMap, + /// Vector of mid and producer ID + pub mid_table: Vec<(String, ProducerId)>, + /// Vector of rid and producer ID + pub rid_table: Vec<(String, ProducerId)>, + /// Vector of Ssrc and producer ID + pub ssrc_table: Vec<(u32, ProducerId)>, +} + +impl RtpListener { + pub(crate) fn from_fbs(rtp_listener: &transport::RtpListener) -> Result> { + Ok(Self { + mid_table: rtp_listener + .mid_table + .iter() + .map(|key_value| Ok((key_value.key.to_string(), key_value.value.parse()?))) + .collect::>>()?, + rid_table: rtp_listener + .rid_table + .iter() + .map(|key_value| Ok((key_value.key.to_string(), key_value.value.parse()?))) + .collect::>>()?, + ssrc_table: rtp_listener + .ssrc_table + .iter() + .map(|key_value| Ok((key_value.key, key_value.value.parse()?))) + .collect::>>()?, + }) + } } #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)] @@ -98,12 +119,36 @@ pub struct RecvRtpHeaderExtensions { transport_wide_cc01: Option, } +impl RecvRtpHeaderExtensions { + pub(crate) fn from_fbs(extensions: &transport::RecvRtpHeaderExtensions) -> Self { + Self { + mid: extensions.mid, + rid: extensions.rid, + rrid: extensions.rrid, + abs_send_time: extensions.abs_send_time, + transport_wide_cc01: extensions.transport_wide_cc01, + } + } +} + #[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] #[doc(hidden)] pub struct SctpListener { - /// Map from stream ID (as string) to data producer ID - stream_id_table: HashedMap, + /// Vector of stream ID (as string) to data producer ID + stream_id_table: Vec<(u16, DataProducerId)>, +} + +impl SctpListener { + pub(crate) fn from_fbs(listener: &transport::SctpListener) -> Result> { + Ok(Self { + stream_id_table: listener + .stream_id_table + .iter() + .map(|key_value| Ok((key_value.key, key_value.value.parse()?))) + .collect::>>()?, + }) + } } #[derive(Debug, Copy, Clone, PartialEq)] @@ -255,9 +300,9 @@ pub trait Transport: Debug + Send + Sync { pub trait TransportGeneric: Transport + Clone + 'static { /// Dump data structure specific to each transport. #[doc(hidden)] - type Dump: Debug + DeserializeOwned + 'static; + type Dump: Debug + 'static; /// Stats data structure specific to each transport. - type Stat: Debug + DeserializeOwned + 'static; + type Stat: Debug + 'static; /// Dump Transport. async fn dump(&self) -> Result; @@ -268,7 +313,7 @@ pub trait TransportGeneric: Transport + Clone + 'static { } /// Error that caused [`Transport::produce`] to fail. -#[derive(Debug, Error, Eq, PartialEq)] +#[derive(Debug, Error)] pub enum ProduceError { /// Producer with the same id already exists. #[error("Producer with the same id \"{0}\" already exists")] @@ -285,7 +330,7 @@ pub enum ProduceError { } /// Error that caused [`Transport::consume`] to fail. -#[derive(Debug, Error, Eq, PartialEq)] +#[derive(Debug, Error)] pub enum ConsumeError { /// Producer with specified id not found. #[error("Producer with id \"{0}\" not found")] @@ -302,7 +347,7 @@ pub enum ConsumeError { } /// Error that caused [`Transport::produce_data`] to fail. -#[derive(Debug, Error, Eq, PartialEq)] +#[derive(Debug, Error)] pub enum ProduceDataError { /// Data producer with the same id already exists. #[error("Data producer with the same id \"{0}\" already exists")] @@ -316,7 +361,7 @@ pub enum ProduceDataError { } /// Error that caused [`Transport::consume_data`] to fail. -#[derive(Debug, Error, Eq, PartialEq)] +#[derive(Debug, Error)] pub enum ConsumeDataError { /// Data producer with specified id not found #[error("Data producer with id \"{0}\" not found")] @@ -361,15 +406,15 @@ pub(super) trait TransportImpl: TransportGeneric { } } - async fn dump_impl(&self) -> Result { + async fn dump_impl(&self) -> Result { self.channel() - .request(self.id(), TransportDumpRequest {}) + .request_fbs(self.id(), TransportDumpRequestNew {}) .await } - async fn get_stats_impl(&self) -> Result { + async fn get_stats_impl(&self) -> Result { self.channel() - .request(self.id(), TransportGetStatsRequest {}) + .request_fbs(self.id(), TransportGetStatsRequestNew {}) .await } diff --git a/rust/src/router/webrtc_transport.rs b/rust/src/router/webrtc_transport.rs index c2604ff519..ad23e19505 100644 --- a/rust/src/router/webrtc_transport.rs +++ b/rust/src/router/webrtc_transport.rs @@ -541,21 +541,28 @@ impl TransportGeneric for WebRtcTransport { async fn dump(&self) -> Result { debug!("dump()"); + todo!(); + /* serde_json::from_value(self.dump_impl().await?).map_err(|error| { RequestError::FailedToParse { error: error.to_string(), } }) + */ } async fn get_stats(&self) -> Result, RequestError> { debug!("get_stats()"); + todo!(); + + /* serde_json::from_value(self.get_stats_impl().await?).map_err(|error| { RequestError::FailedToParse { error: error.to_string(), } }) + */ } } diff --git a/rust/src/sctp_parameters.rs b/rust/src/sctp_parameters.rs index 51ac9b797a..c81f3e6c6a 100644 --- a/rust/src/sctp_parameters.rs +++ b/rust/src/sctp_parameters.rs @@ -1,5 +1,6 @@ //! Collection of SCTP-related data structures that are used to specify SCTP association parameters. +use crate::fbs::sctp_parameters; use serde::{Deserialize, Serialize}; /// Number of SCTP streams. @@ -55,7 +56,18 @@ pub struct SctpParameters { #[serde(rename = "MIS")] pub mis: u16, /// Maximum allowed size for SCTP messages. - pub max_message_size: usize, + pub max_message_size: u32, +} + +impl SctpParameters { + pub(crate) fn from_fbs(parameters: &sctp_parameters::SctpParameters) -> Self { + Self { + port: parameters.port, + os: parameters.os, + mis: parameters.mis, + max_message_size: parameters.max_message_size, + } + } } /// SCTP stream parameters describe the reliability of a certain SCTP stream. diff --git a/rust/src/webrtc_server.rs b/rust/src/webrtc_server.rs index 7d70430e0d..c9168fed48 100644 --- a/rust/src/webrtc_server.rs +++ b/rust/src/webrtc_server.rs @@ -11,6 +11,8 @@ mod tests; use crate::data_structures::{AppData, ListenIp, Protocol}; +use crate::fbs::transport; +use crate::fbs::web_rtc_server; use crate::messages::{WebRtcServerCloseRequest, WebRtcServerDumpRequest}; use crate::transport::TransportId; use crate::uuid_based_wrapper_type; @@ -87,6 +89,20 @@ pub struct WebRtcServerListenInfo { pub port: Option, } +impl WebRtcServerListenInfo { + pub(crate) fn to_fbs(self) -> web_rtc_server::ListenInfo { + web_rtc_server::ListenInfo { + protocol: match self.protocol { + Protocol::Tcp => transport::Protocol::Tcp, + Protocol::Udp => transport::Protocol::Udp, + }, + ip: self.listen_ip.ip.to_string(), + announced_ip: self.listen_ip.announced_ip.map(|ip| ip.to_string()), + port: self.port.unwrap_or(0), + } + } +} + /// Struct that protects an invariant of having non-empty list of listen infos. #[derive(Debug, Clone, Eq, PartialEq, Serialize)] pub struct WebRtcServerListenInfos(Vec); @@ -104,6 +120,13 @@ impl WebRtcServerListenInfos { self.0.push(listen_info); self } + + pub(crate) fn to_fbs(&self) -> Vec { + self.0 + .iter() + .map(|listen_info| listen_info.to_fbs()) + .collect() + } } impl Deref for WebRtcServerListenInfos { @@ -190,7 +213,7 @@ impl Inner { }; self.executor .spawn(async move { - if let Err(error) = channel.request("", request).await { + if let Err(error) = channel.request_fbs("", request).await { error!("WebRTC server closing failed on drop: {}", error); } }) @@ -292,7 +315,7 @@ impl WebRtcServer { self.inner .channel - .request(self.id(), WebRtcServerDumpRequest {}) + .request_fbs(self.id(), WebRtcServerDumpRequest {}) .await } diff --git a/rust/src/worker.rs b/rust/src/worker.rs index 2cbf4cad1c..ebe5f90846 100644 --- a/rust/src/worker.rs +++ b/rust/src/worker.rs @@ -7,7 +7,10 @@ mod utils; use crate::data_structures::AppData; use crate::fbs; -use crate::messages::{WorkerCreateWebRtcServerRequest, WorkerDumpRequest}; +use crate::messages::{ + WorkerCloseRequest, WorkerCreateRouterRequest, WorkerCreateWebRtcServerRequest, + WorkerDumpRequest, WorkerUpdateSettingsRequest, +}; pub use crate::ortc::RtpCapabilitiesError; use crate::router::{Router, RouterId, RouterOptions}; use crate::webrtc_server::{WebRtcServer, WebRtcServerId, WebRtcServerOptions}; @@ -22,8 +25,8 @@ use event_listener_primitives::{Bag, BagOnce, HandlerId}; use futures_lite::FutureExt; use log::{debug, error, warn}; use parking_lot::Mutex; -use planus::Builder; use serde::{Deserialize, Serialize}; +use std::error::Error; use std::ops::RangeInclusive; use std::path::PathBuf; use std::sync::atomic::{AtomicBool, Ordering}; @@ -39,7 +42,7 @@ uuid_based_wrapper_type!( ); /// Error that caused request to mediasoup-worker request to fail. -#[derive(Debug, Error, Eq, PartialEq)] +#[derive(Debug, Error)] pub enum RequestError { /// Channel already closed. #[error("Channel already closed")] @@ -62,6 +65,9 @@ pub enum RequestError { /// Worker did not return any data in response. #[error("Worker did not return any data in response")] NoData, + /// Response conversion error. + #[error("Response conversion error: {0}")] + ResponseConversion(Box), } /// Logging level for logs generated by the media worker thread (check the @@ -90,7 +96,7 @@ impl Default for WorkerLogLevel { } impl WorkerLogLevel { - fn as_str(self) -> &'static str { + pub(crate) fn as_str(self) -> &'static str { match self { Self::Debug => "debug", Self::Warn => "warn", @@ -134,7 +140,7 @@ pub enum WorkerLogTag { } impl WorkerLogTag { - fn as_str(self) -> &'static str { + pub(crate) fn as_str(self) -> &'static str { match self { Self::Info => "info", Self::Ice => "ice", @@ -285,7 +291,7 @@ pub struct WorkerDump { } /// Error that caused [`Worker::create_webrtc_server`] to fail. -#[derive(Debug, Error, Eq, PartialEq)] +#[derive(Debug, Error)] pub enum CreateWebRtcServerError { /// Request to worker failed #[error("Request to worker failed: {0}")] @@ -293,7 +299,7 @@ pub enum CreateWebRtcServerError { } /// Error that caused [`Worker::create_router`] to fail. -#[derive(Debug, Error, Eq, PartialEq)] +#[derive(Debug, Error)] pub enum CreateRouterError { /// RTP capabilities generation error #[error("RTP capabilities generation error: {0}")] @@ -545,13 +551,9 @@ impl Inner { if !already_closed { let channel = self.channel.clone(); - let builder = Builder::new(); - self.executor .spawn(async move { - let _ = channel - .request_fbs(builder, "", fbs::request::Method::WorkerClose, None) - .await; + let _ = channel.request_fbs("", WorkerCloseRequest {}).await; // Drop channels in here after response from worker drop(channel); @@ -620,31 +622,20 @@ impl Worker { pub async fn dump(&self) -> Result { debug!("dump()"); - self.inner.channel.request("", WorkerDumpRequest {}).await + self.inner + .channel + .request_fbs("", WorkerDumpRequest {}) + .await } /// Updates the worker settings in runtime. Just a subset of the worker settings can be updated. pub async fn update_settings(&self, data: WorkerUpdateSettings) -> Result<(), RequestError> { debug!("update_settings()"); - let mut builder = Builder::new(); - let settings = fbs::worker::UpdateSettingsRequest::create( - &mut builder, - data.log_level.unwrap_or_default().as_str(), - data.log_tags - .map(|tags| tags.iter().map(|tag| tag.as_str()).collect::>()), - ); - let body = fbs::request::Body::create_update_settings_request(&mut builder, settings); - match self .inner .channel - .request_fbs( - builder, - "", - fbs::request::Method::WorkerUpdateSettings, - Some(body), - ) + .request_fbs("", WorkerUpdateSettingsRequest { data }) .await { Ok(_) => Ok(()), @@ -675,7 +666,7 @@ impl Worker { self.inner .channel - .request( + .request_fbs( "", WorkerCreateWebRtcServerRequest { webrtc_server_id, @@ -722,18 +713,9 @@ impl Worker { let _buffer_guard = self.inner.channel.buffer_messages_for(router_id.into()); - let mut builder = Builder::new(); - let data = fbs::worker::CreateRouterRequest::create(&mut builder, router_id.to_string()); - let body = fbs::request::Body::create_create_router_request(&mut builder, data); - self.inner .channel - .request_fbs( - builder, - "", - fbs::request::Method::WorkerCreateRouter, - Some(body), - ) + .request_fbs("", WorkerCreateRouterRequest { router_id }) .await .map_err(CreateRouterError::Request)?; diff --git a/rust/src/worker/channel.rs b/rust/src/worker/channel.rs index 7ccee35b08..5cf485bf24 100644 --- a/rust/src/worker/channel.rs +++ b/rust/src/worker/channel.rs @@ -1,5 +1,5 @@ use crate::fbs::{message, notification, request, response}; -use crate::messages::{Notification, Request, WorkerCloseRequest}; +use crate::messages::{Notification, Request, RequestFbs, WorkerCloseRequest}; use crate::worker::common::{ EventHandlers, FBSEventHandlers, FBSWeakEventHandlers, SubscriptionTarget, WeakEventHandlers, }; @@ -12,7 +12,7 @@ use log::{debug, error, trace, warn}; use lru::LruCache; use mediasoup_sys::UvAsyncT; use parking_lot::Mutex; -use planus::{Builder, ReadAsRoot, UnionOffset}; +use planus::ReadAsRoot; use serde::Deserialize; use serde_json::Value; use std::any::TypeId; @@ -173,13 +173,7 @@ struct FBSRequestsContainer { handlers: HashedMap>, } -/* TODO: Remove. -impl Drop for RequestsContainer { - fn drop(&mut self) { - panic!(); - } -} -*/ +// TODO: Maybe remove /* struct OutgoingMessageRequest { message: Vec, @@ -283,7 +277,7 @@ impl Channel { match deserialize_message(message) { ChannelReceiveMessage::Notification(notification) => { let target_id: SubscriptionTarget = SubscriptionTarget::String( - notification.handler_id().unwrap().unwrap().to_string(), + notification.handler_id().unwrap().to_string(), ); if !non_buffered_notifications.contains(&target_id) { @@ -529,14 +523,13 @@ impl Channel { } } - pub(crate) async fn request_fbs( + pub(crate) async fn request_fbs( &self, - mut builder: Builder, handler_id: HandlerId, - method: request::Method, - body: Option>, - ) -> Result, RequestError> + request: R, + ) -> Result where + R: RequestFbs + 'static, HandlerId: Display, { let id; @@ -557,15 +550,9 @@ impl Channel { requests_container_lock.handlers.insert(id, result_sender); } - debug!("request() [method:{:?}, id:{}]", method, id); - - let request = - request::Request::create(&mut builder, id, method, handler_id.to_string(), body); + debug!("request() [method:{:?}, id:{}]", R::METHOD, id); - let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); - - let data = builder.finish(message, None).to_vec(); + let data = request.into_bytes(id, handler_id); let buffer = Arc::new(AtomicTake::new(data)); @@ -577,7 +564,7 @@ impl Channel { if let Some(handle) = outgoing_message_buffer.handle { if self.inner.worker_closed.load(Ordering::Acquire) { // Forbid all requests after worker closing except one worker closing request - if method != request::Method::WorkerClose { + if R::METHOD != request::Method::WorkerClose { return Err(RequestError::ChannelClosed); } } @@ -614,17 +601,23 @@ impl Channel { match response_result { Ok(data) => { - debug!("request succeeded [method:{:?}, id:{}]", method, id); + debug!("request succeeded [method:{:?}, id:{}]", R::METHOD, id); - Ok(data) + Ok(R::convert_response(data).map_err(RequestError::ResponseConversion)?) } Err(ResponseError { reason }) => { debug!( "request failed [method:{:?}, id:{}]: {}", - method, id, reason + R::METHOD, + id, + reason ); if reason.contains("not found") { - Err(RequestError::ChannelClosed) + if let Some(default_response) = R::default_for_soft_error() { + Ok(default_response) + } else { + Err(RequestError::ChannelClosed) + } } else { Err(RequestError::Response { reason }) } diff --git a/rust/src/worker/utils.rs b/rust/src/worker/utils.rs index 3fa01ace77..fbbd2e1c38 100644 --- a/rust/src/worker/utils.rs +++ b/rust/src/worker/utils.rs @@ -2,7 +2,7 @@ mod channel_read_fn; mod channel_write_fn; use crate::worker::channel::BufferMessagesGuard; -use crate::worker::{Channel, WorkerId}; +use crate::worker::{Channel, SubscriptionTarget, WorkerId}; pub(super) use channel_read_fn::{prepare_channel_read_fn, PreparedChannelRead}; pub(super) use channel_write_fn::{prepare_channel_write_fn, PreparedChannelWrite}; use std::ffi::CString; @@ -48,9 +48,8 @@ where { let (channel, prepared_channel_read, prepared_channel_write) = Channel::new(Arc::clone(&worker_closed)); - let buffer_worker_messages_guard = channel.buffer_messages_for( - super::common::SubscriptionTarget::String(std::process::id().to_string()), - ); + let buffer_worker_messages_guard = + channel.buffer_messages_for(SubscriptionTarget::String(std::process::id().to_string())); std::thread::Builder::new() .name(format!("mediasoup-worker-{id}")) diff --git a/rust/tests/integration/direct_transport.rs b/rust/tests/integration/direct_transport.rs index 70e8730683..d9ee6ac4db 100644 --- a/rust/tests/integration/direct_transport.rs +++ b/rust/tests/integration/direct_transport.rs @@ -135,6 +135,7 @@ fn get_stats_succeeds() { .expect("Failed to get stats on Direct transport"); assert_eq!(stats.len(), 1); + assert_eq!(stats[0].transport_id, transport.id()); assert_eq!(stats[0].bytes_received, 0); assert_eq!(stats[0].recv_bitrate, 0); diff --git a/worker/Makefile b/worker/Makefile index 4862f4266f..432e913b61 100644 --- a/worker/Makefile +++ b/worker/Makefile @@ -207,7 +207,7 @@ libmediasoup-worker: setup flatc $(MESON) compile -C $(BUILD_DIR) -j $(CORES) libmediasoup-worker $(MESON) install -C $(BUILD_DIR) --no-rebuild --tags libmediasoup-worker -flatc: +flatc: setup $(MESON) compile -C $(BUILD_DIR) flatc [ -d $(FLATC_OUT_DIR) ] || \ $(FLATC) --cpp --cpp-field-case-style lower --reflect-names --scoped-enums \ diff --git a/worker/fbs/common.fbs b/worker/fbs/common.fbs index f068118f45..48c3ad18f6 100644 --- a/worker/fbs/common.fbs +++ b/worker/fbs/common.fbs @@ -23,6 +23,6 @@ table Uint32String { table StringStringArray { key:string (required); - values:[string]; + values:[string] (required); } diff --git a/worker/fbs/notification.fbs b/worker/fbs/notification.fbs index 378fa3bc9c..67e5d99f9e 100644 --- a/worker/fbs/notification.fbs +++ b/worker/fbs/notification.fbs @@ -72,7 +72,7 @@ union Body { } table Notification { - handler_id:string; + handler_id:string (required); event:Event; body:Body; } diff --git a/worker/fbs/request.fbs b/worker/fbs/request.fbs index 58374d3e11..86464e73cb 100644 --- a/worker/fbs/request.fbs +++ b/worker/fbs/request.fbs @@ -115,7 +115,7 @@ union Body { table Request { id:uint32; method:Method; - handler_id:string; + handler_id:string (required); body:Body; } diff --git a/worker/fbs/router.fbs b/worker/fbs/router.fbs index ec204dddef..09cb8b6632 100644 --- a/worker/fbs/router.fbs +++ b/worker/fbs/router.fbs @@ -11,13 +11,13 @@ namespace FBS.Router; table DumpResponse { id:string (required); - transport_ids:[string]; - rtp_observer_ids:[string]; - map_producer_id_consumer_ids:[FBS.Common.StringStringArray]; - map_consumer_id_producer_id:[FBS.Common.StringString]; - map_producer_id_observer_ids:[FBS.Common.StringStringArray]; - map_data_producer_id_data_consumer_ids:[FBS.Common.StringStringArray]; - map_data_consumer_id_data_producer_id:[FBS.Common.StringString]; + transport_ids:[string] (required); + rtp_observer_ids:[string] (required); + map_producer_id_consumer_ids:[FBS.Common.StringStringArray] (required); + map_consumer_id_producer_id:[FBS.Common.StringString] (required); + map_producer_id_observer_ids:[FBS.Common.StringStringArray] (required); + map_data_producer_id_data_consumer_ids:[FBS.Common.StringStringArray] (required); + map_data_consumer_id_data_producer_id:[FBS.Common.StringString] (required); } table CreatePipeTransportRequest { diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs index c961a3f604..cc5bb526a8 100644 --- a/worker/fbs/transport.fbs +++ b/worker/fbs/transport.fbs @@ -91,6 +91,14 @@ table SctpListener { stream_id_table:[FBS.Common.Uint16String] (required); } +table RecvRtpHeaderExtensions { + mid:uint8 = null; + rid:uint8 = null; + rrid:uint8 = null; + abs_send_time:uint8 = null; + transport_wide_cc01:uint8 = null; +} + table Dump { id:string (required); direct:bool=false; @@ -100,11 +108,11 @@ table Dump { map_rtx_ssrc_consumer_id:[FBS.Common.Uint32String] (required); data_producer_ids:[string] (required); data_consumer_ids:[string] (required); - recv_rtp_header_extensions:[FBS.Common.StringUint8] (required); + recv_rtp_header_extensions:RecvRtpHeaderExtensions (required); rtp_listener:RtpListener (required); max_message_size:uint32; sctp_parameters:FBS.SctpParameters.SctpParameters; - sctp_state:string; + sctp_state:FBS.SctpAssociation.SctpState = null; sctp_listener: SctpListener; trace_event_types:[string] (required); } @@ -123,28 +131,28 @@ table Options { table Stats { transport_id:string (required); timestamp:uint64; - sctp_state:string; + sctp_state:FBS.SctpAssociation.SctpState = null; bytes_received:uint64; - recv_bitrate:uint64; + recv_bitrate:uint32; bytes_sent:uint64; - send_bitrate:uint64; + send_bitrate:uint32; rtp_bytes_received:uint64; - rtp_recv_bitrate:uint64; + rtp_recv_bitrate:uint32; rtp_bytes_sent:uint64; - rtp_send_bitrate:uint64; + rtp_send_bitrate:uint32; rtx_bytes_received:uint64; - rtx_recv_bitrate:uint64; + rtx_recv_bitrate:uint32; rtx_bytes_sent:uint64; - rtx_send_bitrate:uint64; + rtx_send_bitrate:uint32; probation_bytes_sent:uint64; - probation_send_bitrate:uint64; - available_outgoing_bitrate:uint64; - available_incoming_bitrate:uint64; - max_incoming_bitrate:uint64; - max_outgoing_bitrate:uint64; - min_outgoing_bitrate:uint64; - rtp_packet_loss_received:uint64; - rtp_packet_loss_sent:uint64; + probation_send_bitrate:uint32; + available_outgoing_bitrate:uint32 = null; + available_incoming_bitrate:uint32 = null; + max_incoming_bitrate:uint32; + max_outgoing_bitrate:uint32; + min_outgoing_bitrate:uint32; + rtp_packet_loss_received:float64 = null; + rtp_packet_loss_sent:float64 = null; } table SetMaxIncomingBitrateRequest { diff --git a/worker/fbs/webRtcServer.fbs b/worker/fbs/webRtcServer.fbs index 087f744088..4855fdfaa4 100644 --- a/worker/fbs/webRtcServer.fbs +++ b/worker/fbs/webRtcServer.fbs @@ -26,9 +26,9 @@ table TupleHash { table DumpResponse { id:string (required); - udp_sockets:[IpPort]; - tcp_servers:[IpPort]; - web_rtc_transport_ids:[string]; - local_ice_username_fragments:[IceUserNameFragment]; - tuple_hashes:[TupleHash]; + udp_sockets:[IpPort] (required); + tcp_servers:[IpPort] (required); + web_rtc_transport_ids:[string] (required); + local_ice_username_fragments:[IceUserNameFragment] (required); + tuple_hashes:[TupleHash] (required); } diff --git a/worker/fbs/worker.fbs b/worker/fbs/worker.fbs index 26b97b1437..92ed841554 100644 --- a/worker/fbs/worker.fbs +++ b/worker/fbs/worker.fbs @@ -3,15 +3,15 @@ include "webRtcServer.fbs"; namespace FBS.Worker; table ChannelMessageHandlers { - channel_request_handlers:[string]; - channel_notification_handlers:[string]; + channel_request_handlers:[string] (required); + channel_notification_handlers:[string] (required); } table DumpResponse { pid:uint32; - web_rtc_server_ids:[string]; - router_ids:[string]; - channel_message_handlers:ChannelMessageHandlers; + web_rtc_server_ids:[string] (required); + router_ids:[string] (required); + channel_message_handlers:ChannelMessageHandlers (required); } table ResourceUsageResponse { @@ -40,7 +40,7 @@ table UpdateSettingsRequest { table CreateWebRtcServerRequest { web_rtc_server_id:string (required); - listen_infos:[FBS.WebRtcServer.ListenInfo]; + listen_infos:[FBS.WebRtcServer.ListenInfo] (required); } table CloseWebRtcServerRequest { diff --git a/worker/src/RTC/DirectTransport.cpp b/worker/src/RTC/DirectTransport.cpp index f4822d74e2..3288433b29 100644 --- a/worker/src/RTC/DirectTransport.cpp +++ b/worker/src/RTC/DirectTransport.cpp @@ -72,7 +72,7 @@ namespace RTC { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_PipeTransport_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::FBS_DirectTransport_DumpResponse, dumpOffset); break; } diff --git a/worker/src/RTC/Transport.cpp b/worker/src/RTC/Transport.cpp index 5c14bfba63..9395390543 100644 --- a/worker/src/RTC/Transport.cpp +++ b/worker/src/RTC/Transport.cpp @@ -1,7 +1,7 @@ +#include "flatbuffers/stl_emulation.h" #define MS_CLASS "RTC::Transport" // #define MS_LOG_DEV_LEVEL 3 -#include "RTC/Transport.hpp" #include "Logger.hpp" #include "MediaSoupErrors.hpp" #include "Utils.hpp" @@ -19,6 +19,7 @@ #include "RTC/SimpleConsumer.hpp" #include "RTC/SimulcastConsumer.hpp" #include "RTC/SvcConsumer.hpp" +#include "RTC/Transport.hpp" #include // webrtc::RtpPacketSendInfo #include // std::ostream_iterator #include // std::multimap @@ -296,44 +297,30 @@ namespace RTC } // Add headerExtensionIds. - std::vector> recvRtpHeaderExtensions; - - if (this->recvRtpHeaderExtensionIds.mid != 0u) - { - recvRtpHeaderExtensions.emplace_back( - FBS::Common::CreateStringUint8Direct(builder, "mid", this->recvRtpHeaderExtensionIds.mid)); - } - - if (this->recvRtpHeaderExtensionIds.rid != 0u) - { - recvRtpHeaderExtensions.emplace_back( - FBS::Common::CreateStringUint8Direct(builder, "rid", this->recvRtpHeaderExtensionIds.rid)); - } - - if (this->recvRtpHeaderExtensionIds.rrid != 0u) - { - recvRtpHeaderExtensions.emplace_back(FBS::Common::CreateStringUint8Direct( - builder, "rrid", this->recvRtpHeaderExtensionIds.rrid)); - } - - if (this->recvRtpHeaderExtensionIds.absSendTime != 0u) - { - recvRtpHeaderExtensions.emplace_back(FBS::Common::CreateStringUint8Direct( - builder, "absSendTime", this->recvRtpHeaderExtensionIds.absSendTime)); - } - - if (this->recvRtpHeaderExtensionIds.transportWideCc01 != 0u) - { - recvRtpHeaderExtensions.emplace_back(FBS::Common::CreateStringUint8Direct( - builder, "transportWideCc01", this->recvRtpHeaderExtensionIds.transportWideCc01)); - } + auto recvRtpHeaderExtensions = FBS::Transport::CreateRecvRtpHeaderExtensions( + builder, + this->recvRtpHeaderExtensionIds.mid != 0u + ? flatbuffers::Optional(this->recvRtpHeaderExtensionIds.mid) + : flatbuffers::nullopt, + this->recvRtpHeaderExtensionIds.rid != 0u + ? flatbuffers::Optional(this->recvRtpHeaderExtensionIds.rid) + : flatbuffers::nullopt, + this->recvRtpHeaderExtensionIds.rrid != 0u + ? flatbuffers::Optional(this->recvRtpHeaderExtensionIds.rrid) + : flatbuffers::nullopt, + this->recvRtpHeaderExtensionIds.absSendTime != 0u + ? flatbuffers::Optional(this->recvRtpHeaderExtensionIds.absSendTime) + : flatbuffers::nullopt, + this->recvRtpHeaderExtensionIds.transportWideCc01 != 0u + ? flatbuffers::Optional(this->recvRtpHeaderExtensionIds.transportWideCc01) + : flatbuffers::nullopt); auto rtpListenerOffset = this->rtpListener.FillBuffer(builder); // Add sctpParameters. flatbuffers::Offset sctpParameters; // Add sctpState. - std::string sctpState; + FBS::SctpAssociation::SctpState sctpState; // Add sctpListener. flatbuffers::Offset sctpListener; @@ -345,19 +332,19 @@ namespace RTC switch (this->sctpAssociation->GetState()) { case RTC::SctpAssociation::SctpState::NEW: - sctpState = "new"; + sctpState = FBS::SctpAssociation::SctpState::NEW; break; case RTC::SctpAssociation::SctpState::CONNECTING: - sctpState = "connecting"; + sctpState = FBS::SctpAssociation::SctpState::CONNECTING; break; case RTC::SctpAssociation::SctpState::CONNECTED: - sctpState = "connected"; + sctpState = FBS::SctpAssociation::SctpState::CONNECTED; break; case RTC::SctpAssociation::SctpState::FAILED: - sctpState = "failed"; + sctpState = FBS::SctpAssociation::SctpState::FAILED; break; case RTC::SctpAssociation::SctpState::CLOSED: - sctpState = "closed"; + sctpState = FBS::SctpAssociation::SctpState::CLOSED; break; } @@ -386,11 +373,12 @@ namespace RTC &mapRtxSsrcConsumerId, &dataProducerIds, &dataConsumerIds, - &recvRtpHeaderExtensions, + recvRtpHeaderExtensions, rtpListenerOffset, this->maxMessageSize, sctpParameters, - sctpState.c_str(), + this->sctpAssociation ? flatbuffers::Optional(sctpState) + : flatbuffers::nullopt, sctpListener, &traceEventTypes); } @@ -403,7 +391,7 @@ namespace RTC auto nowMs = DepLibUV::GetTimeMs(); // Add sctpState. - std::string sctpState; + FBS::SctpAssociation::SctpState sctpState; if (this->sctpAssociation) { @@ -411,19 +399,19 @@ namespace RTC switch (this->sctpAssociation->GetState()) { case RTC::SctpAssociation::SctpState::NEW: - sctpState = "new"; + sctpState = FBS::SctpAssociation::SctpState::NEW; break; case RTC::SctpAssociation::SctpState::CONNECTING: - sctpState = "connecting"; + sctpState = FBS::SctpAssociation::SctpState::CONNECTING; break; case RTC::SctpAssociation::SctpState::CONNECTED: - sctpState = "connected"; + sctpState = FBS::SctpAssociation::SctpState::CONNECTED; break; case RTC::SctpAssociation::SctpState::FAILED: - sctpState = "failed"; + sctpState = FBS::SctpAssociation::SctpState::FAILED; break; case RTC::SctpAssociation::SctpState::CLOSED: - sctpState = "closed"; + sctpState = FBS::SctpAssociation::SctpState::CLOSED; break; } } @@ -435,7 +423,8 @@ namespace RTC // timestamp. nowMs, // sctpState. - sctpState.c_str(), + this->sctpAssociation ? flatbuffers::Optional(sctpState) + : flatbuffers::nullopt, // bytesReceived. this->recvTransmission.GetBytes(), // recvBitrate. @@ -465,9 +454,11 @@ namespace RTC // probationSendBitrate. this->sendProbationTransmission.GetBitrate(nowMs), // availableOutgoingBitrate. - this->tccClient ? this->tccClient->GetAvailableBitrate() : 0u, + this->tccClient ? flatbuffers::Optional(this->tccClient->GetAvailableBitrate()) + : flatbuffers::nullopt, // availableIncomingBitrate. - this->tccServer ? this->tccServer->GetAvailableBitrate() : 0u, + this->tccServer ? flatbuffers::Optional(this->tccServer->GetAvailableBitrate()) + : flatbuffers::nullopt, // maxIncomingBitrate. this->maxIncomingBitrate, // maxOutgoingBitrate. @@ -475,9 +466,11 @@ namespace RTC // minOutgoingBitrate. this->minOutgoingBitrate, // packetLossReceived. - this->tccServer ? this->tccServer->GetPacketLoss() : 0u, + this->tccServer ? flatbuffers::Optional(this->tccServer->GetPacketLoss()) + : flatbuffers::nullopt, // packetLossSent. - this->tccClient ? this->tccClient->GetPacketLoss() : 0u); + this->tccClient ? flatbuffers::Optional(this->tccClient->GetPacketLoss()) + : flatbuffers::nullopt); } void Transport::HandleRequest(Channel::ChannelRequest* request) From 4b104f6b830d777f9e98e0f5be27a7a173c6d7c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Thu, 22 Jun 2023 11:15:32 +0200 Subject: [PATCH 07/73] [flatbuffers] Add pause() and resume() in DataProducer and DataConsumer (#1104) --- node/src/Consumer.ts | 59 ++++---- node/src/DataConsumer.ts | 159 +++++++++++++++++++-- node/src/DataProducer.ts | 94 ++++++++++-- node/src/PipeTransport.ts | 2 +- node/src/PlainTransport.ts | 2 +- node/src/Producer.ts | 23 +-- node/src/Router.ts | 14 +- node/src/RtpObserver.ts | 10 +- node/src/Transport.ts | 76 +++++++--- node/src/WebRtcServer.ts | 4 +- node/src/WebRtcTransport.ts | 8 +- node/src/Worker.ts | 2 +- node/src/tests/test-DataConsumer.ts | 26 ++++ node/src/tests/test-DataProducer.ts | 26 ++++ node/src/tests/test-DirectTransport.ts | 43 +++++- rust/src/messages.rs | 29 ++++ rust/src/router/data_consumer.rs | 141 +++++++++++++++++- rust/src/router/data_producer.rs | 73 +++++++++- rust/src/router/producer.rs | 2 +- rust/src/router/transport.rs | 7 + rust/tests/integration/data_producer.rs | 61 ++++++++ rust/tests/integration/direct_transport.rs | 50 ++++++- worker/fbs/consumer.fbs | 4 +- worker/fbs/dataConsumer.fbs | 2 + worker/fbs/dataProducer.fbs | 1 + worker/fbs/notification.fbs | 4 +- worker/fbs/producer.fbs | 2 +- worker/fbs/request.fbs | 58 ++++---- worker/fbs/transport.fbs | 28 ++-- worker/include/RTC/DataConsumer.hpp | 16 +++ worker/include/RTC/DataProducer.hpp | 7 + worker/include/RTC/PipeConsumer.hpp | 4 +- worker/include/RTC/Router.hpp | 3 + worker/include/RTC/RtpObserver.hpp | 4 +- worker/include/RTC/Transport.hpp | 6 + worker/src/Channel/ChannelNotification.cpp | 4 +- worker/src/Channel/ChannelRequest.cpp | 128 +++++++++-------- worker/src/RTC/Consumer.cpp | 70 ++++++++- worker/src/RTC/DataConsumer.cpp | 103 ++++++++++++- worker/src/RTC/DataProducer.cpp | 67 ++++++++- worker/src/RTC/PipeTransport.cpp | 2 +- worker/src/RTC/PlainTransport.cpp | 2 +- worker/src/RTC/Producer.cpp | 69 ++++++++- worker/src/RTC/Router.cpp | 56 ++++++-- worker/src/RTC/RtpObserver.cpp | 8 +- worker/src/RTC/Transport.cpp | 18 ++- worker/src/RTC/WebRtcServer.cpp | 2 +- worker/src/RTC/WebRtcTransport.cpp | 2 +- worker/src/Worker.cpp | 4 +- 49 files changed, 1325 insertions(+), 260 deletions(-) diff --git a/node/src/Consumer.ts b/node/src/Consumer.ts index dcad582189..750c9b3f3d 100644 --- a/node/src/Consumer.ts +++ b/node/src/Consumer.ts @@ -37,7 +37,7 @@ export type ConsumerOptions = rtpCapabilities: RtpCapabilities; /** - * Whether the Consumer must start in paused mode. Default false. + * Whether the consumer must start in paused mode. Default false. * * When creating a video Consumer, it's recommended to set paused to true, * then transmit the Consumer parameters to the consuming endpoint and, once @@ -187,12 +187,14 @@ export type ConsumerObserverEvents = trace: [ConsumerTraceEventData]; }; -export type SimpleConsumerDump = BaseConsumerDump & { +export type SimpleConsumerDump = BaseConsumerDump & +{ type: string; rtpStream: RtpStreamDump; }; -export type SimulcastConsumerDump = BaseConsumerDump & { +export type SimulcastConsumerDump = BaseConsumerDump & +{ type: string; rtpStream: RtpStreamDump; preferredSpatialLayer: number; @@ -205,7 +207,8 @@ export type SimulcastConsumerDump = BaseConsumerDump & { export type SvcConsumerDump = SimulcastConsumerDump; -export type PipeConsumerDump = BaseConsumerDump & { +export type PipeConsumerDump = BaseConsumerDump & +{ type: string; rtpStreams: RtpStreamDump[]; }; @@ -229,20 +232,22 @@ type ConsumerData = type: ConsumerType; }; -type BaseConsumerDump = { +type BaseConsumerDump = +{ id: string; - producerId:string; - kind:MediaKind; - rtpParameters:RtpParameters; - consumableRtpEncodings?:RtpEncodingParameters[]; - supportedCodecPayloadTypes:number[]; - traceEventTypes:string[]; - paused:boolean; - producerPaused:boolean; - priority:number; + producerId: string; + kind: MediaKind; + rtpParameters: RtpParameters; + consumableRtpEncodings?: RtpEncodingParameters[]; + supportedCodecPayloadTypes: number[]; + traceEventTypes: string[]; + paused: boolean; + producerPaused: boolean; + priority: number; }; -type RtpStreamParameters = { +type RtpStreamParameters = +{ encodingIdx: number; ssrc: number; payloadType: number; @@ -261,22 +266,25 @@ type RtpStreamParameters = { temporalLayers: number; }; -type RtpStreamDump = { +type RtpStreamDump = +{ params: RtpStreamParameters; score: number; rtxStream?: RtxStreamDump; }; -type RtxStreamParameters = { - ssrc:number; - payloadType:number; - mimeType:string; +type RtxStreamParameters = +{ + ssrc: number; + payloadType: number; + mimeType: string; clockRate: number; - rrid?:string; - cname:string; + rrid?: string; + cname: string; }; -type RtxStreamDump = { +type RtxStreamDump = +{ params: RtxStreamParameters; }; @@ -353,11 +361,11 @@ export class Consumer this.#internal = internal; this.#data = data; this.#channel = channel; - this.#appData = appData || {} as ConsumerAppData; this.#paused = paused; this.#producerPaused = producerPaused; this.#score = score; this.#preferredLayers = preferredLayers; + this.#appData = appData || {} as ConsumerAppData; this.handleWorkerNotifications(); } @@ -695,7 +703,8 @@ export class Consumer if (status.preferredLayers) { - preferredLayers = { + preferredLayers = + { spatialLayer : status.preferredLayers.spatialLayer, temporalLayer : status.preferredLayers.temporalLayer !== null ? status.preferredLayers.temporalLayer : diff --git a/node/src/DataConsumer.ts b/node/src/DataConsumer.ts index fae9f463f8..92dee2141d 100644 --- a/node/src/DataConsumer.ts +++ b/node/src/DataConsumer.ts @@ -40,6 +40,11 @@ export type DataConsumerOptions = */ maxRetransmits?: number; + /** + * Whether the data consumer must start in paused mode. Default false. + */ + paused?: boolean; + /** * Custom application data. */ @@ -66,6 +71,8 @@ export type DataConsumerEvents = { transportclose: []; dataproducerclose: []; + dataproducerpause: []; + dataproducerresume: []; message: [Buffer, number]; sctpsendbufferfull: []; bufferedamountlow: [number]; @@ -77,10 +84,15 @@ export type DataConsumerEvents = export type DataConsumerObserverEvents = { close: []; + pause: []; + resume: []; }; -type DataConsumerDump = DataConsumerData & { +type DataConsumerDump = DataConsumerData & +{ id: string; + paused: boolean; + dataProducerPaused: boolean; }; type DataConsumerInternal = TransportInternal & @@ -114,6 +126,12 @@ export class DataConsumer // Closed flag. #closed = false; + // Paused flag. + #paused = false; + + // Associated DataProducer paused flag. + #dataProducerPaused = false; + // Custom app data. #appData: DataConsumerAppData; @@ -128,12 +146,16 @@ export class DataConsumer internal, data, channel, + paused, + dataProducerPaused, appData }: { internal: DataConsumerInternal; data: DataConsumerData; channel: Channel; + paused: boolean; + dataProducerPaused: boolean; appData?: DataConsumerAppData; } ) @@ -145,6 +167,8 @@ export class DataConsumer this.#internal = internal; this.#data = data; this.#channel = channel; + this.#paused = paused; + this.#dataProducerPaused = dataProducerPaused; this.#appData = appData || {} as DataConsumerAppData; this.handleWorkerNotifications(); @@ -206,6 +230,22 @@ export class DataConsumer return this.#data.protocol; } + /** + * Whether the DataConsumer is paused. + */ + get paused(): boolean + { + return this.#paused; + } + + /** + * Whether the associate DataProducer is paused. + */ + get dataProducerPaused(): boolean + { + return this.#dataProducerPaused; + } + /** * App custom data. */ @@ -253,7 +293,7 @@ export class DataConsumer ).pack(this.#channel.bufferBuilder); this.#channel.request( - FbsRequest.Method.TRANSPORT_CLOSE_DATA_CONSUMER, + FbsRequest.Method.TRANSPORT_CLOSE_DATACONSUMER, FbsRequest.Body.FBS_Transport_CloseDataConsumerRequest, requestOffset, this.#internal.transportId @@ -298,7 +338,7 @@ export class DataConsumer logger.debug('dump()'); const response = await this.#channel.request( - FbsRequest.Method.DATA_CONSUMER_DUMP, + FbsRequest.Method.DATACONSUMER_DUMP, undefined, undefined, this.#internal.dataConsumerId @@ -309,7 +349,7 @@ export class DataConsumer response.body(dumpResponse); - return parseDataConsumerDump(dumpResponse); + return parseDataConsumerDumpResponse(dumpResponse); } /** @@ -320,7 +360,7 @@ export class DataConsumer logger.debug('getStats()'); const response = await this.#channel.request( - FbsRequest.Method.DATA_CONSUMER_GET_STATS, + FbsRequest.Method.DATACONSUMER_GET_STATS, undefined, undefined, this.#internal.dataConsumerId @@ -334,6 +374,56 @@ export class DataConsumer return [ parseDataConsumerStats(data) ]; } + /** + * Pause the DataConsumer. + */ + async pause(): Promise + { + logger.debug('pause()'); + + const wasPaused = this.#paused; + + await this.#channel.request( + FbsRequest.Method.DATACONSUMER_PAUSE, + undefined, + undefined, + this.#internal.dataConsumerId + ); + + this.#paused = true; + + // Emit observer event. + if (!wasPaused) + { + this.#observer.safeEmit('pause'); + } + } + + /** + * Resume the DataConsumer. + */ + async resume(): Promise + { + logger.debug('resume()'); + + const wasPaused = this.#paused; + + await this.#channel.request( + FbsRequest.Method.DATACONSUMER_RESUME, + undefined, + undefined, + this.#internal.dataConsumerId + ); + + this.#paused = false; + + // Emit observer event. + if (wasPaused) + { + this.#observer.safeEmit('resume'); + } + } + /** * Set buffered amount low threshold. */ @@ -346,7 +436,7 @@ export class DataConsumer createSetBufferedAmountLowThresholdRequest(this.#channel.bufferBuilder, threshold); await this.#channel.request( - FbsRequest.Method.DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, + FbsRequest.Method.DATACONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, FbsRequest.Body.FBS_DataConsumer_SetBufferedAmountLowThresholdRequest, requestOffset, this.#internal.dataConsumerId @@ -423,7 +513,7 @@ export class DataConsumer ); await this.#channel.request( - FbsRequest.Method.DATA_CONSUMER_SEND, + FbsRequest.Method.DATACONSUMER_SEND, FbsRequest.Body.FBS_DataConsumer_SendRequest, requestOffset, this.#internal.dataConsumerId @@ -438,7 +528,7 @@ export class DataConsumer logger.debug('getBufferedAmount()'); const response = await this.#channel.request( - FbsRequest.Method.DATA_CONSUMER_GET_BUFFERED_AMOUNT, + FbsRequest.Method.DATACONSUMER_GET_BUFFERED_AMOUNT, undefined, undefined, this.#internal.dataConsumerId @@ -478,6 +568,50 @@ export class DataConsumer break; } + case Event.DATACONSUMER_DATAPRODUCER_PAUSE: + { + if (this.#dataProducerPaused) + { + break; + } + + const wasPaused = this.#paused || this.#dataProducerPaused; + + this.#dataProducerPaused = true; + + this.safeEmit('dataproducerpause'); + + // Emit observer event. + if (!wasPaused) + { + this.#observer.safeEmit('pause'); + } + + break; + } + + case Event.DATACONSUMER_DATAPRODUCER_RESUME: + { + if (!this.#dataProducerPaused) + { + break; + } + + const wasPaused = this.#paused || this.#dataProducerPaused; + + this.#dataProducerPaused = false; + + this.safeEmit('dataproducerresume'); + + // Emit observer event. + if (wasPaused && !this.#paused) + { + this.#observer.safeEmit('resume'); + } + + break; + } + case Event.DATACONSUMER_SCTP_SENDBUFFER_FULL: { this.safeEmit('sctpsendbufferfull'); @@ -527,7 +661,7 @@ export class DataConsumer } } -export function parseDataConsumerDump( +export function parseDataConsumerDumpResponse( data: FbsDataConsumer.DumpResponse ): DataConsumerDump { @@ -538,8 +672,11 @@ export function parseDataConsumerDump( sctpStreamParameters : data.sctpStreamParameters() !== null ? parseSctpStreamParameters(data.sctpStreamParameters()!) : undefined, - label : data.label()!, - protocol : data.protocol()! + label : data.label()!, + protocol : data.protocol()!, + paused : data.paused(), + dataProducerPaused : data.dataProducerPaused() + }; } diff --git a/node/src/DataProducer.ts b/node/src/DataProducer.ts index baeea34938..929856ad1d 100644 --- a/node/src/DataProducer.ts +++ b/node/src/DataProducer.ts @@ -32,6 +32,11 @@ export type DataProducerOptions = */ protocol?: string; + /** + * Whether the data producer must start in paused mode. Default false. + */ + paused?: boolean; + /** * Custom application data. */ @@ -63,10 +68,14 @@ export type DataProducerEvents = export type DataProducerObserverEvents = { close: []; + pause: []; + resume: []; }; -type DataProducerDump = DataProducerData & { +type DataProducerDump = DataProducerData & +{ id: string; + paused: boolean; }; type DataProducerInternal = TransportInternal & @@ -99,6 +108,9 @@ export class DataProducer // Closed flag. #closed = false; + // Paused flag. + #paused = false; + // Custom app data. #appData: DataProducerAppData; @@ -113,12 +125,14 @@ export class DataProducer internal, data, channel, + paused, appData }: { internal: DataProducerInternal; data: DataProducerData; channel: Channel; + paused: boolean; appData?: DataProducerAppData; } ) @@ -130,6 +144,7 @@ export class DataProducer this.#internal = internal; this.#data = data; this.#channel = channel; + this.#paused = paused; this.#appData = appData || {} as DataProducerAppData; this.handleWorkerNotifications(); @@ -183,6 +198,14 @@ export class DataProducer return this.#data.protocol; } + /** + * Whether the DataProducer is paused. + */ + get paused(): boolean + { + return this.#paused; + } + /** * App custom data. */ @@ -230,7 +253,7 @@ export class DataProducer ).pack(this.#channel.bufferBuilder); this.#channel.request( - FbsRequest.Method.TRANSPORT_CLOSE_DATA_PRODUCER, + FbsRequest.Method.TRANSPORT_CLOSE_DATAPRODUCER, FbsRequest.Body.FBS_Transport_CloseDataProducerRequest, requestOffset, this.#internal.transportId @@ -275,7 +298,7 @@ export class DataProducer logger.debug('dump()'); const response = await this.#channel.request( - FbsRequest.Method.DATA_PRODUCER_DUMP, + FbsRequest.Method.DATAPRODUCER_DUMP, undefined, undefined, this.#internal.dataProducerId @@ -286,7 +309,7 @@ export class DataProducer response.body(produceResponse); - return parseDataProducerDump(produceResponse); + return parseDataProducerDumpResponse(produceResponse); } /** @@ -297,7 +320,7 @@ export class DataProducer logger.debug('getStats()'); const response = await this.#channel.request( - FbsRequest.Method.DATA_PRODUCER_GET_STATS, + FbsRequest.Method.DATAPRODUCER_GET_STATS, undefined, undefined, this.#internal.dataProducerId @@ -311,6 +334,56 @@ export class DataProducer return [ parseDataProducerStats(data) ]; } + /** + * Pause the DataProducer. + */ + async pause(): Promise + { + logger.debug('pause()'); + + const wasPaused = this.#paused; + + await this.#channel.request( + FbsRequest.Method.DATAPRODUCER_PAUSE, + undefined, + undefined, + this.#internal.dataProducerId + ); + + this.#paused = true; + + // Emit observer event. + if (!wasPaused) + { + this.#observer.safeEmit('pause'); + } + } + + /** + * Resume the DataProducer. + */ + async resume(): Promise + { + logger.debug('resume()'); + + const wasPaused = this.#paused; + + await this.#channel.request( + FbsRequest.Method.DATAPRODUCER_RESUME, + undefined, + undefined, + this.#internal.dataProducerId + ); + + this.#paused = false; + + // Emit observer event. + if (wasPaused) + { + this.#observer.safeEmit('resume'); + } + } + /** * Send data (just valid for DataProducers created on a DirectTransport). */ @@ -354,10 +427,10 @@ export class DataProducer message = Buffer.alloc(1); } - let dataOffset = 0; - const builder = this.#channel.bufferBuilder; + let dataOffset = 0; + if (typeof message === 'string') { const messageOffset = builder.createString(message); @@ -381,7 +454,7 @@ export class DataProducer ); this.#channel.notify( - FbsNotification.Event.DATA_PRODUCER_SEND, + FbsNotification.Event.DATAPRODUCER_SEND, FbsNotification.Body.FBS_DataProducer_SendNotification, notificationOffset, this.#internal.dataProducerId @@ -394,7 +467,7 @@ export class DataProducer } } -export function parseDataProducerDump( +export function parseDataProducerDumpResponse( data: FbsDataProducer.DumpResponse ): DataProducerDump { @@ -405,7 +478,8 @@ export function parseDataProducerDump( parseSctpStreamParameters(data.sctpStreamParameters()!) : undefined, label : data.label()!, - protocol : data.protocol()! + protocol : data.protocol()!, + paused : data.paused() }; } diff --git a/node/src/PipeTransport.ts b/node/src/PipeTransport.ts index 6021c58d0f..447e60f60c 100644 --- a/node/src/PipeTransport.ts +++ b/node/src/PipeTransport.ts @@ -312,7 +312,7 @@ export class PipeTransport // Wait for response. const response = await this.channel.request( - FbsRequest.Method.PIPE_TRANSPORT_CONNECT, + FbsRequest.Method.PIPETRANSPORT_CONNECT, FbsRequest.Body.FBS_PipeTransport_ConnectRequest, requestOffset, this.internal.transportId diff --git a/node/src/PlainTransport.ts b/node/src/PlainTransport.ts index 778a0ab7f0..181feceaf9 100644 --- a/node/src/PlainTransport.ts +++ b/node/src/PlainTransport.ts @@ -355,7 +355,7 @@ export class PlainTransport // Wait for response. const response = await this.channel.request( - FbsRequest.Method.PLAIN_TRANSPORT_CONNECT, + FbsRequest.Method.PLAINTRANSPORT_CONNECT, FbsRequest.Body.FBS_PlainTransport_ConnectRequest, requestOffset, this.internal.transportId diff --git a/node/src/Producer.ts b/node/src/Producer.ts index 93e2d71506..fa19a4edcc 100644 --- a/node/src/Producer.ts +++ b/node/src/Producer.ts @@ -142,15 +142,16 @@ export type ProducerObserverEvents = trace: [ProducerTraceEventData]; }; -type ProducerDump = { +type ProducerDump = +{ id: string; kind: string; - type:ProducerType; - rtpParameters:RtpParameters; - rtpMapping:any; - rtpStreams:any; - traceEventTypes:string[]; - paused:boolean; + type: ProducerType; + rtpParameters: RtpParameters; + rtpMapping: any; + rtpStreams: any; + traceEventTypes: string[]; + paused: boolean; }; type ProducerInternal = TransportInternal & @@ -183,12 +184,12 @@ export class Producer // Closed flag. #closed = false; - // Custom app data. - #appData: ProducerAppData; - // Paused flag. #paused = false; + // Custom app data. + #appData: ProducerAppData; + // Current score. #score: ProducerScore[] = []; @@ -222,8 +223,8 @@ export class Producer this.#internal = internal; this.#data = data; this.#channel = channel; - this.#appData = appData || {} as ProducerAppData; this.#paused = paused; + this.#appData = appData || {} as ProducerAppData; this.handleWorkerNotifications(); } diff --git a/node/src/Router.ts b/node/src/Router.ts index 9fe609bf6a..41f7da45aa 100644 --- a/node/src/Router.ts +++ b/node/src/Router.ts @@ -553,8 +553,8 @@ export class Router const response = await this.#channel.request( webRtcServer - ? FbsRequest.Method.ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER - : FbsRequest.Method.ROUTER_CREATE_WEBRTC_TRANSPORT, + ? FbsRequest.Method.ROUTER_CREATE_WEBRTCTRANSPORT_WITH_SERVER + : FbsRequest.Method.ROUTER_CREATE_WEBRTCTRANSPORT, FbsRequest.Body.FBS_Router_CreateWebRtcTransportRequest, requestOffset, this.#internal.routerId @@ -718,7 +718,7 @@ export class Router ).pack(this.#channel.bufferBuilder); const response = await this.#channel.request( - FbsRequest.Method.ROUTER_CREATE_PLAIN_TRANSPORT, + FbsRequest.Method.ROUTER_CREATE_PLAINTRANSPORT, FbsRequest.Body.FBS_Router_CreatePlainTransportRequest, requestOffset, this.#internal.routerId @@ -854,7 +854,7 @@ export class Router ).pack(this.#channel.bufferBuilder); const response = await this.#channel.request( - FbsRequest.Method.ROUTER_CREATE_PIPE_TRANSPORT, + FbsRequest.Method.ROUTER_CREATE_PIPETRANSPORT, FbsRequest.Body.FBS_Router_CreatePipeTransportRequest, requestOffset, this.#internal.routerId @@ -951,7 +951,7 @@ export class Router ).pack(this.#channel.bufferBuilder); const response = await this.#channel.request( - FbsRequest.Method.ROUTER_CREATE_DIRECT_TRANSPORT, + FbsRequest.Method.ROUTER_CREATE_DIRECTTRANSPORT, FbsRequest.Body.FBS_Router_CreateDirectTransportRequest, requestOffset, this.#internal.routerId @@ -1401,7 +1401,7 @@ export class Router ).pack(this.#channel.bufferBuilder); await this.#channel.request( - FbsRequest.Method.ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER, + FbsRequest.Method.ROUTER_CREATE_ACTIVESPEAKEROBSERVER, FbsRequest.Body.FBS_Router_CreateActiveSpeakerObserverRequest, requestOffset, this.#internal.routerId @@ -1480,7 +1480,7 @@ export class Router ).pack(this.#channel.bufferBuilder); await this.#channel.request( - FbsRequest.Method.ROUTER_CREATE_AUDIO_LEVEL_OBSERVER, + FbsRequest.Method.ROUTER_CREATE_AUDIOLEVELOBSERVER, FbsRequest.Body.FBS_Router_CreateAudioLevelObserverRequest, requestOffset, this.#internal.routerId diff --git a/node/src/RtpObserver.ts b/node/src/RtpObserver.ts index 80fde13156..fa18136aeb 100644 --- a/node/src/RtpObserver.ts +++ b/node/src/RtpObserver.ts @@ -167,7 +167,7 @@ export class RtpObserver ).pack(this.channel.bufferBuilder); this.channel.request( - FbsRequest.Method.ROUTER_CLOSE_RTP_OBSERVER, + FbsRequest.Method.ROUTER_CLOSE_RTPOBSERVER, FbsRequest.Body.FBS_Router_CloseRtpObserverRequest, requestOffset, this.internal.routerId @@ -214,7 +214,7 @@ export class RtpObserver const wasPaused = this.#paused; await this.channel.request( - FbsRequest.Method.RTP_OBSERVER_PAUSE, + FbsRequest.Method.RTPOBSERVER_PAUSE, undefined, undefined, this.internal.rtpObserverId @@ -239,7 +239,7 @@ export class RtpObserver const wasPaused = this.#paused; await this.channel.request( - FbsRequest.Method.RTP_OBSERVER_RESUME, + FbsRequest.Method.RTPOBSERVER_RESUME, undefined, undefined, this.internal.rtpObserverId @@ -273,7 +273,7 @@ export class RtpObserver ).pack(this.channel.bufferBuilder); await this.channel.request( - FbsRequest.Method.RTP_OBSERVER_ADD_PRODUCER, + FbsRequest.Method.RTPOBSERVER_ADD_PRODUCER, FbsRequest.Body.FBS_RtpObserver_AddProducerRequest, requestOffset, this.internal.rtpObserverId @@ -302,7 +302,7 @@ export class RtpObserver ).pack(this.channel.bufferBuilder); await this.channel.request( - FbsRequest.Method.RTP_OBSERVER_REMOVE_PRODUCER, + FbsRequest.Method.RTPOBSERVER_REMOVE_PRODUCER, FbsRequest.Body.FBS_RtpObserver_RemoveProducerRequest, requestOffset, this.internal.rtpObserverId diff --git a/node/src/Transport.ts b/node/src/Transport.ts index a1ee90754f..f8af18ed19 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -16,13 +16,13 @@ import { DataProducer, DataProducerOptions, DataProducerType, - parseDataProducerDump + parseDataProducerDumpResponse } from './DataProducer'; import { DataConsumer, DataConsumerOptions, DataConsumerType, - parseDataConsumerDump + parseDataConsumerDumpResponse } from './DataConsumer'; import { MediaKind, @@ -186,7 +186,8 @@ export type TransportInternal = RouterInternal & transportId: string; }; -export type BaseTransportDump = { +export type BaseTransportDump = +{ id : string; direct : boolean; producerIds : string[]; @@ -204,7 +205,8 @@ export type BaseTransportDump = { traceEventTypes? : string[]; }; -export type BaseTransportStats = { +export type BaseTransportStats = +{ transportId: string; timestamp: number; sctpState?: SctpState; @@ -233,13 +235,15 @@ type TransportData = | PipeTransportData | DirectTransportData; -type RtpListenerDump = { +type RtpListenerDump = +{ ssrcTable : {key: number; value: string}[]; midTable : {key: number; value: string}[]; ridTable : {key: number; value: string}[]; }; -type SctpListenerDump = { +type SctpListenerDump = +{ streamIdTable : {key: number; value: string}[]; }; @@ -886,7 +890,7 @@ export class Transport } const consumerId = uuidv4(); - const consumeRequestOffset = createConsumeRequest({ + const requestOffset = createConsumeRequest({ builder : this.channel.bufferBuilder, producer, consumerId, @@ -900,7 +904,7 @@ export class Transport const response = await this.channel.request( FbsRequest.Method.TRANSPORT_CONSUME, FbsRequest.Body.FBS_Transport_ConsumeRequest, - consumeRequestOffset, + requestOffset, this.internal.transportId ); @@ -961,6 +965,7 @@ export class Transport sctpStreamParameters, label = '', protocol = '', + paused = false, appData }: DataProducerOptions = {} ): Promise> @@ -1005,7 +1010,8 @@ export class Transport type, sctpStreamParameters, label, - protocol + protocol, + paused }); const response = await this.channel.request( @@ -1016,11 +1022,12 @@ export class Transport ); /* Decode Response. */ - const produceResponse = new FbsDataProducer.DumpResponse(); + const produceDataResponse = new FbsDataProducer.DumpResponse(); - response.body(produceResponse); + response.body(produceDataResponse); + + const dump = parseDataProducerDumpResponse(produceDataResponse); - const data = parseDataProducerDump(produceResponse); const dataProducer = new DataProducer( { internal : @@ -1028,8 +1035,15 @@ export class Transport ...this.internal, dataProducerId }, - data, - channel : this.channel, + data : + { + type : dump.type, + sctpStreamParameters : dump.sctpStreamParameters, + label : dump.label, + protocol : dump.protocol + }, + channel : this.channel, + paused, appData }); @@ -1057,6 +1071,7 @@ export class Transport ordered, maxPacketLifeTime, maxRetransmits, + paused = false, appData }: DataConsumerOptions ): Promise> @@ -1139,7 +1154,8 @@ export class Transport type, sctpStreamParameters, label, - protocol + protocol, + paused }); const response = await this.channel.request( @@ -1150,11 +1166,12 @@ export class Transport ); /* Decode Response. */ - const consumeResponse = new FbsDataConsumer.DumpResponse(); + const consumeDataResponse = new FbsDataConsumer.DumpResponse(); - response.body(consumeResponse); + response.body(consumeDataResponse); + + const dump = parseDataConsumerDumpResponse(consumeDataResponse); - const data = parseDataConsumerDump(consumeResponse); const dataConsumer = new DataConsumer( { internal : @@ -1162,8 +1179,17 @@ export class Transport ...this.internal, dataConsumerId }, - data, - channel : this.channel, + data : + { + dataProducerId : dump.dataProducerId, + type : dump.type, + sctpStreamParameters : dump.sctpStreamParameters, + label : dump.label, + protocol : dump.protocol + }, + channel : this.channel, + paused : dump.paused, + dataProducerPaused : dump.dataProducerPaused, appData }); @@ -1556,7 +1582,8 @@ function createProduceDataRequest({ type, sctpStreamParameters, label, - protocol + protocol, + paused } : { builder : flatbuffers.Builder; dataProducerId: string; @@ -1564,6 +1591,7 @@ function createProduceDataRequest({ sctpStreamParameters?: SctpStreamParameters; label: string; protocol: string; + paused: boolean; }): number { const dataProducerIdOffset = builder.createString(dataProducerId); @@ -1593,6 +1621,7 @@ function createProduceDataRequest({ FbsTransport.ProduceDataRequest.addLabel(builder, labelOffset); FbsTransport.ProduceDataRequest.addProtocol(builder, protocolOffset); + FbsTransport.ProduceDataRequest.addPaused(builder, paused); return FbsTransport.ProduceDataRequest.endProduceDataRequest(builder); } @@ -1604,7 +1633,8 @@ function createConsumeDataRequest({ type, sctpStreamParameters, label, - protocol + protocol, + paused } : { builder : flatbuffers.Builder; dataConsumerId: string; @@ -1613,6 +1643,7 @@ function createConsumeDataRequest({ sctpStreamParameters?: SctpStreamParameters; label: string; protocol: string; + paused: boolean; }): number { const dataConsumerIdOffset = builder.createString(dataConsumerId); @@ -1644,6 +1675,7 @@ function createConsumeDataRequest({ FbsTransport.ConsumeDataRequest.addLabel(builder, labelOffset); FbsTransport.ConsumeDataRequest.addProtocol(builder, protocolOffset); + FbsTransport.ConsumeDataRequest.addPaused(builder, paused); return FbsTransport.ConsumeDataRequest.endConsumeDataRequest(builder); } diff --git a/node/src/WebRtcServer.ts b/node/src/WebRtcServer.ts index 71d1820028..8039f66e7c 100644 --- a/node/src/WebRtcServer.ts +++ b/node/src/WebRtcServer.ts @@ -162,7 +162,7 @@ export class WebRtcServer this.#internal.webRtcServerId).pack(this.#channel.bufferBuilder); this.#channel.request( - Method.WORKER_WEBRTC_SERVER_CLOSE, + Method.WORKER_WEBRTCSERVER_CLOSE, RequestBody.FBS_Worker_CloseWebRtcServerRequest, requestOffset) .catch(() => {}); @@ -217,7 +217,7 @@ export class WebRtcServer logger.debug('dump()'); const response = await this.#channel.request( - Method.WEBRTC_SERVER_DUMP, undefined, undefined, this.#internal.webRtcServerId); + Method.WEBRTCSERVER_DUMP, undefined, undefined, this.#internal.webRtcServerId); /* Decode Response. */ const dump = new FbsWebRtcServer.DumpResponse(); diff --git a/node/src/WebRtcTransport.ts b/node/src/WebRtcTransport.ts index 2a3c75a159..cc7184049f 100644 --- a/node/src/WebRtcTransport.ts +++ b/node/src/WebRtcTransport.ts @@ -477,7 +477,7 @@ export class WebRtcTransport // Wait for response. const response = await this.channel.request( - FbsRequest.Method.WEBRTC_TRANSPORT_CONNECT, + FbsRequest.Method.WEBRTCTRANSPORT_CONNECT, FbsRequest.Body.FBS_WebRtcTransport_ConnectRequest, requestOffset, this.internal.transportId @@ -512,7 +512,8 @@ export class WebRtcTransport response.body(restartIceResponse); - const iceParameters = { + const iceParameters = + { usernameFragment : restartIceResponse.usernameFragment()!, password : restartIceResponse.password()!, iceLite : restartIceResponse.iceLite() @@ -763,7 +764,8 @@ function parseDtlsParameters(binary: FbsWebRtcTransport.DtlsParameters): DtlsPar for (let i=0; i ).pack(this.#channel.bufferBuilder); await this.#channel.request( - FbsRequest.Method.WORKER_CREATE_WEBRTC_SERVER, + FbsRequest.Method.WORKER_CREATE_WEBRTCSERVER, FbsRequest.Body.FBS_Worker_CreateWebRtcServerRequest, createWebRtcServerRequestOffset ); diff --git a/node/src/tests/test-DataConsumer.ts b/node/src/tests/test-DataConsumer.ts index df6b829bdd..45973919bd 100644 --- a/node/src/tests/test-DataConsumer.ts +++ b/node/src/tests/test-DataConsumer.ts @@ -69,6 +69,7 @@ test('transport.consumeData() succeeds', async () => expect(dataConsumer1.sctpStreamParameters?.maxRetransmits).toBeUndefined(); expect(dataConsumer1.label).toBe('foo'); expect(dataConsumer1.protocol).toBe('bar'); + expect(dataConsumer1.paused).toBe(false); expect(dataConsumer1.appData).toEqual({ baz: 'LOL' }); const dump = await router.dump(); @@ -108,6 +109,7 @@ test('dataConsumer.dump() succeeds', async () => expect(data.sctpStreamParameters!.maxRetransmits).toBeUndefined(); expect(data.label).toBe('foo'); expect(data.protocol).toBe('bar'); + expect(data.paused).toBe(false); }, 2000); test('dataConsumer.getStats() succeeds', async () => @@ -135,6 +137,7 @@ test('transport.consumeData() on a DirectTransport succeeds', async () => dataConsumer2 = await transport3.consumeData( { dataProducerId : dataProducer.id, + paused : true, appData : { hehe: 'HEHE' } }); @@ -147,6 +150,7 @@ test('transport.consumeData() on a DirectTransport succeeds', async () => expect(dataConsumer2.sctpStreamParameters).toBeUndefined(); expect(dataConsumer2.label).toBe('foo'); expect(dataConsumer2.protocol).toBe('bar'); + expect(dataConsumer2.paused).toBe(true); expect(dataConsumer2.appData).toEqual({ hehe: 'HEHE' }); await expect(transport3.dump()) @@ -169,6 +173,7 @@ test('dataConsumer.dump() on a DirectTransport succeeds', async () => expect(data.sctpStreamParameters).toBeUndefined(); expect(data.label).toBe('foo'); expect(data.protocol).toBe('bar'); + expect(data.paused).toBe(true); }, 2000); test('dataConsumer.getStats() on a DirectTransport succeeds', async () => @@ -187,6 +192,27 @@ test('dataConsumer.getStats() on a DirectTransport succeeds', async () => ]); }, 2000); +test('dataConsumer.pause() and resume() succeed', async () => +{ + let data; + + await dataConsumer1.pause(); + + expect(dataConsumer1.paused).toBe(true); + + data = await dataConsumer1.dump(); + + expect(data.paused).toBe(true); + + await dataConsumer1.resume(); + + expect(dataConsumer1.paused).toBe(false); + + data = await dataConsumer1.dump(); + + expect(data.paused).toBe(false); +}, 2000); + test('dataConsumer.close() succeeds', async () => { const onObserverClose = jest.fn(); diff --git a/node/src/tests/test-DataProducer.ts b/node/src/tests/test-DataProducer.ts index 1b44e60cce..fecdca315d 100644 --- a/node/src/tests/test-DataProducer.ts +++ b/node/src/tests/test-DataProducer.ts @@ -56,6 +56,7 @@ test('transport1.produceData() succeeds', async () => expect(dataProducer1.sctpStreamParameters?.maxRetransmits).toBeUndefined(); expect(dataProducer1.label).toBe('foo'); expect(dataProducer1.protocol).toBe('bar'); + expect(dataProducer1.paused).toBe(false); expect(dataProducer1.appData).toEqual({ foo: 1, bar: '2' }); const dump = await router.dump(); @@ -92,6 +93,7 @@ test('transport2.produceData() succeeds', async () => }, label : 'foo', protocol : 'bar', + paused : true, appData : { foo: 1, bar: '2' } }); @@ -107,6 +109,7 @@ test('transport2.produceData() succeeds', async () => expect(dataProducer2.sctpStreamParameters?.maxRetransmits).toBe(3); expect(dataProducer2.label).toBe('foo'); expect(dataProducer2.protocol).toBe('bar'); + expect(dataProducer2.paused).toBe(true); expect(dataProducer2.appData).toEqual({ foo: 1, bar: '2' }); const dump = await router.dump(); @@ -187,6 +190,7 @@ test('dataProducer.dump() succeeds', async () => expect(data.sctpStreamParameters!.maxRetransmits).toBeUndefined(); expect(data.label).toBe('foo'); expect(data.protocol).toBe('bar'); + expect(data.paused).toBe(false); data = await dataProducer2.dump(); @@ -199,6 +203,7 @@ test('dataProducer.dump() succeeds', async () => expect(data.sctpStreamParameters!.maxRetransmits).toBe(3); expect(data.label).toBe('foo'); expect(data.protocol).toBe('bar'); + expect(data.paused).toBe(true); }, 2000); test('dataProducer.getStats() succeeds', async () => @@ -230,6 +235,27 @@ test('dataProducer.getStats() succeeds', async () => ]); }, 2000); +test('dataProducer.pause() and resume() succeed', async () => +{ + let data; + + await dataProducer1.pause(); + + expect(dataProducer1.paused).toBe(true); + + data = await dataProducer1.dump(); + + expect(data.paused).toBe(true); + + await dataProducer1.resume(); + + expect(dataProducer1.paused).toBe(false); + + data = await dataProducer1.dump(); + + expect(data.paused).toBe(false); +}, 2000); + test('dataProducer.close() succeeds', async () => { const onObserverClose = jest.fn(); diff --git a/node/src/tests/test-DirectTransport.ts b/node/src/tests/test-DirectTransport.ts index a5d62c84d7..d43b40f10a 100644 --- a/node/src/tests/test-DirectTransport.ts +++ b/node/src/tests/test-DirectTransport.ts @@ -117,7 +117,17 @@ test('dataProducer.send() succeeds', async () => dataProducerId : dataProducer.id }); const numMessages = 200; + const pauseSendingAtMessage = 10; + const resumeSendingAtMessage = 20; + const pauseReceivingAtMessage = 40; + const resumeReceivingAtMessage = 60; + const expectedReceivedNumMessages = + numMessages - + (resumeSendingAtMessage - pauseSendingAtMessage) - + (resumeReceivingAtMessage - pauseReceivingAtMessage); + let sentMessageBytes = 0; + let effectivelySentMessageBytes = 0; let recvMessageBytes = 0; let lastSentMessageId = 0; let lastRecvMessageId = 0; @@ -131,6 +141,23 @@ test('dataProducer.send() succeeds', async () => let ppid; let message; + if (id === pauseSendingAtMessage) + { + dataProducer.pause(); + } + else if (id === resumeSendingAtMessage) + { + dataProducer.resume(); + } + else if (id === pauseReceivingAtMessage) + { + dataConsumer.pause(); + } + else if (id === resumeReceivingAtMessage) + { + dataConsumer.resume(); + } + // Send string (WebRTC DataChannel string). if (id < numMessages / 2) { @@ -143,7 +170,15 @@ test('dataProducer.send() succeeds', async () => } dataProducer.send(message, ppid); - sentMessageBytes += Buffer.from(message).byteLength; + + const messageSize = Buffer.from(message).byteLength; + + sentMessageBytes += messageSize; + + if (!dataProducer.paused && !dataConsumer.paused) + { + effectivelySentMessageBytes += messageSize; + } if (id === numMessages) { @@ -178,8 +213,8 @@ test('dataProducer.send() succeeds', async () => }); expect(lastSentMessageId).toBe(numMessages); - expect(lastRecvMessageId).toBe(numMessages); - expect(recvMessageBytes).toBe(sentMessageBytes); + expect(lastRecvMessageId).toBe(expectedReceivedNumMessages); + expect(recvMessageBytes).toBe(effectivelySentMessageBytes); await expect(dataProducer.getStats()) .resolves @@ -202,7 +237,7 @@ test('dataProducer.send() succeeds', async () => type : 'data-consumer', label : dataConsumer.label, protocol : dataConsumer.protocol, - messagesSent : numMessages, + messagesSent : expectedReceivedNumMessages, bytesSent : recvMessageBytes } ]); diff --git a/rust/src/messages.rs b/rust/src/messages.rs index ebddba9d6e..98704e91b6 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -626,12 +626,14 @@ request_response!( sctp_stream_parameters: Option, label: String, protocol: String, + paused: bool, }, TransportProduceDataResponse { r#type: DataProducerType, sctp_stream_parameters: Option, label: String, protocol: String, + paused: bool, }, ); @@ -646,12 +648,15 @@ request_response!( sctp_stream_parameters: Option, label: String, protocol: String, + paused: bool, }, TransportConsumeDataResponse { r#type: DataConsumerType, sctp_stream_parameters: Option, label: String, protocol: String, + paused: bool, + data_producer_paused: bool, }, ); @@ -806,6 +811,18 @@ request_response!( Vec, ); +request_response!( + DataProducerId, + "dataProducer.pause", + DataProducerPauseRequest {} +); + +request_response!( + DataProducerId, + "dataProducer.resume", + DataProducerResumeRequest {} +); + #[derive(Debug, Copy, Clone, Serialize)] #[serde(into = "u32")] pub(crate) struct DataProducerSendNotification { @@ -851,6 +868,18 @@ request_response!( Vec, ); +request_response!( + DataConsumerId, + "dataConsumer.pause", + DataConsumerPauseRequest {}, +); + +request_response!( + DataConsumerId, + "dataConsumer.resume", + DataConsumerResumeRequest {}, +); + request_response!( DataConsumerId, "dataConsumer.getBufferedAmount", diff --git a/rust/src/router/data_consumer.rs b/rust/src/router/data_consumer.rs index 73d8f0da8e..888183ac25 100644 --- a/rust/src/router/data_consumer.rs +++ b/rust/src/router/data_consumer.rs @@ -5,8 +5,8 @@ use crate::data_producer::{DataProducer, DataProducerId, WeakDataProducer}; use crate::data_structures::{AppData, WebRtcMessage}; use crate::messages::{ DataConsumerCloseRequest, DataConsumerDumpRequest, DataConsumerGetBufferedAmountRequest, - DataConsumerGetStatsRequest, DataConsumerSendRequest, - DataConsumerSetBufferedAmountLowThresholdRequest, + DataConsumerGetStatsRequest, DataConsumerPauseRequest, DataConsumerResumeRequest, + DataConsumerSendRequest, DataConsumerSetBufferedAmountLowThresholdRequest, }; use crate::sctp_parameters::SctpStreamParameters; use crate::transport::Transport; @@ -51,6 +51,8 @@ pub struct DataConsumerOptions { /// Defaults to the value in the [`DataProducer`](crate::data_producer::DataProducer) if it /// has type `Sctp` or unset if it has type `Direct`. pub(super) max_retransmits: Option, + /// Whether the DataConsumer must start in paused mode. Default false. + pub paused: bool, /// Custom application data. pub app_data: AppData, } @@ -65,6 +67,7 @@ impl DataConsumerOptions { ordered: None, max_packet_life_time: None, max_retransmits: None, + paused: false, app_data: AppData::default(), } } @@ -77,6 +80,7 @@ impl DataConsumerOptions { ordered: Some(true), max_packet_life_time: None, max_retransmits: None, + paused: false, app_data: AppData::default(), } } @@ -89,6 +93,7 @@ impl DataConsumerOptions { ordered: None, max_packet_life_time: None, max_retransmits: None, + paused: false, app_data: AppData::default(), } } @@ -105,6 +110,7 @@ impl DataConsumerOptions { ordered: None, max_packet_life_time: Some(max_packet_life_time), max_retransmits: None, + paused: false, app_data: AppData::default(), } } @@ -120,6 +126,7 @@ impl DataConsumerOptions { ordered: None, max_packet_life_time: None, max_retransmits: Some(max_retransmits), + paused: false, app_data: AppData::default(), } } @@ -137,6 +144,8 @@ pub struct DataConsumerDump { pub protocol: String, pub sctp_stream_parameters: Option, pub buffered_amount_low_threshold: u32, + pub paused: bool, + pub data_producer_paused: bool, } /// RTC statistics of the data consumer. @@ -168,6 +177,8 @@ pub enum DataConsumerType { #[serde(tag = "event", rename_all = "lowercase", content = "data")] enum Notification { DataProducerClose, + DataProducerPause, + DataProducerResume, SctpSendBufferFull, // TODO. // Message { ppid: u32 }, @@ -184,6 +195,10 @@ struct Handlers { sctp_send_buffer_full: Bag>, buffered_amount_low: Bag>, data_producer_close: BagOnce>, + pause: Bag>, + resume: Bag>, + data_producer_pause: Bag>, + data_producer_resume: Bag>, transport_close: BagOnce>, close: BagOnce>, } @@ -196,6 +211,8 @@ struct Inner { protocol: String, data_producer_id: DataProducerId, direct: bool, + paused: Arc>, + data_producer_paused: Arc>, executor: Arc>, channel: Channel, handlers: Arc, @@ -263,6 +280,8 @@ impl fmt::Debug for RegularDataConsumer { .field("label", &self.inner.label) .field("protocol", &self.inner.protocol) .field("data_producer_id", &self.inner.data_producer_id) + .field("paused", &self.inner.paused) + .field("data_producer_paused", &self.inner.data_producer_paused) .field("transport", &self.inner.transport) .field("closed", &self.inner.closed) .finish() @@ -291,6 +310,8 @@ impl fmt::Debug for DirectDataConsumer { .field("label", &self.inner.label) .field("protocol", &self.inner.protocol) .field("data_producer_id", &self.inner.data_producer_id) + .field("paused", &self.inner.paused) + .field("data_producer_paused", &self.inner.data_producer_paused) .field("transport", &self.inner.transport) .field("closed", &self.inner.closed) .finish() @@ -338,9 +359,11 @@ impl DataConsumer { sctp_stream_parameters: Option, label: String, protocol: String, + paused: bool, data_producer: DataProducer, executor: Arc>, channel: Channel, + data_producer_paused: bool, app_data: AppData, transport: Arc, direct: bool, @@ -349,11 +372,16 @@ impl DataConsumer { let handlers = Arc::::default(); let closed = Arc::new(AtomicBool::new(false)); + let paused = Arc::new(Mutex::new(paused)); + #[allow(clippy::mutex_atomic)] + let data_producer_paused = Arc::new(Mutex::new(data_producer_paused)); let inner_weak = Arc::>>>::default(); let subscription_handler = { let handlers = Arc::clone(&handlers); let closed = Arc::clone(&closed); + let paused = Arc::clone(&paused); + let data_producer_paused = Arc::clone(&data_producer_paused); let inner_weak = Arc::clone(&inner_weak); channel.subscribe_to_notifications(id.into(), move |notification| { @@ -378,6 +406,29 @@ impl DataConsumer { } } } + Notification::DataProducerPause => { + let mut data_producer_paused = data_producer_paused.lock(); + let was_paused = *paused.lock() || *data_producer_paused; + *data_producer_paused = true; + + handlers.data_producer_pause.call_simple(); + + if !was_paused { + handlers.pause.call_simple(); + } + } + Notification::DataProducerResume => { + let mut data_producer_paused = data_producer_paused.lock(); + let paused = *paused.lock(); + let was_paused = paused || *data_producer_paused; + *data_producer_paused = false; + + handlers.data_producer_resume.call_simple(); + + if was_paused && !paused { + handlers.resume.call_simple(); + } + } Notification::SctpSendBufferFull => { handlers.sctp_send_buffer_full.call_simple(); } @@ -427,6 +478,8 @@ impl DataConsumer { label, protocol, data_producer_id: data_producer.id(), + paused, + data_producer_paused, direct, executor, channel, @@ -471,6 +524,19 @@ impl DataConsumer { self.inner().r#type } + /// Whether the data consumer is paused. It does not take into account whether the + /// associated data producer is paused. + #[must_use] + pub fn paused(&self) -> bool { + *self.inner().paused.lock() + } + + /// Whether the associate data producer is paused. + #[must_use] + pub fn producer_paused(&self) -> bool { + *self.inner().data_producer_paused.lock() + } + /// The SCTP stream parameters (just if the data consumer type is `Sctp`). #[must_use] pub fn sctp_stream_parameters(&self) -> Option { @@ -525,6 +591,46 @@ impl DataConsumer { .await } + /// Pauses the data consumer (no mossage is sent to the consuming endpoint). + pub async fn pause(&self) -> Result<(), RequestError> { + debug!("pause()"); + + self.inner() + .channel + .request(self.id(), DataConsumerPauseRequest {}) + .await?; + + let mut paused = self.inner().paused.lock(); + let was_paused = *paused || *self.inner().data_producer_paused.lock(); + *paused = true; + + if !was_paused { + self.inner().handlers.pause.call_simple(); + } + + Ok(()) + } + + /// Resumes the data consumer (messages are sent again to the consuming endpoint). + pub async fn resume(&self) -> Result<(), RequestError> { + debug!("resume()"); + + self.inner() + .channel + .request(self.id(), DataConsumerResumeRequest {}) + .await?; + + let mut paused = self.inner().paused.lock(); + let was_paused = *paused || *self.inner().data_producer_paused.lock(); + *paused = false; + + if was_paused { + self.inner().handlers.resume.call_simple(); + } + + Ok(()) + } + /// Returns the number of bytes of data currently buffered to be sent over the underlying SCTP /// association. /// @@ -611,6 +717,37 @@ impl DataConsumer { .add(Box::new(callback)) } + /// Callback is called when the data consumer or its associated data producer is + /// paused and, as result, the data consumer becomes paused. + pub fn on_pause(&self, callback: F) -> HandlerId { + self.inner().handlers.pause.add(Arc::new(callback)) + } + + /// Callback is called when the data consumer or its associated data producer is + /// resumed and, as result, the data consumer is no longer paused. + pub fn on_resume(&self, callback: F) -> HandlerId { + self.inner().handlers.resume.add(Arc::new(callback)) + } + + /// Callback is called when the associated data producer is paused. + pub fn on_data_producer_pause( + &self, + callback: F, + ) -> HandlerId { + self.inner() + .handlers + .data_producer_pause + .add(Arc::new(callback)) + } + + /// Callback is called when the associated data producer is resumed. + pub fn on_producer_resume(&self, callback: F) -> HandlerId { + self.inner() + .handlers + .data_producer_resume + .add(Arc::new(callback)) + } + /// Callback is called when the transport this data consumer belongs to is closed for whatever /// reason. The data consumer itself is also closed. pub fn on_transport_close(&self, callback: F) -> HandlerId { diff --git a/rust/src/router/data_producer.rs b/rust/src/router/data_producer.rs index 8a5daa0398..e58e37d1d8 100644 --- a/rust/src/router/data_producer.rs +++ b/rust/src/router/data_producer.rs @@ -4,14 +4,14 @@ mod tests; use crate::data_structures::{AppData, WebRtcMessage}; use crate::messages::{ DataProducerCloseRequest, DataProducerDumpRequest, DataProducerGetStatsRequest, - DataProducerSendNotification, + DataProducerPauseRequest, DataProducerResumeRequest, DataProducerSendNotification, }; use crate::sctp_parameters::SctpStreamParameters; use crate::transport::Transport; use crate::uuid_based_wrapper_type; use crate::worker::{Channel, NotificationError, RequestError}; use async_executor::Executor; -use event_listener_primitives::{BagOnce, HandlerId}; +use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; @@ -41,6 +41,8 @@ pub struct DataProducerOptions { pub label: String, /// Name of the sub-protocol used by this DataChannel. pub protocol: String, + /// Whether the data producer must start in paused mode. Default false. + pub paused: bool, /// Custom application data. pub app_data: AppData, } @@ -56,6 +58,7 @@ impl DataProducerOptions { sctp_stream_parameters: Some(sctp_stream_parameters), label: "".to_string(), protocol: "".to_string(), + paused: false, app_data: AppData::default(), } } @@ -68,6 +71,7 @@ impl DataProducerOptions { sctp_stream_parameters: Some(sctp_stream_parameters), label: "".to_string(), protocol: "".to_string(), + paused: false, app_data: AppData::default(), } } @@ -80,6 +84,7 @@ impl DataProducerOptions { sctp_stream_parameters: None, label: "".to_string(), protocol: "".to_string(), + paused: false, app_data: AppData::default(), } } @@ -105,6 +110,7 @@ pub struct DataProducerDump { pub label: String, pub protocol: String, pub sctp_stream_parameters: Option, + pub paused: bool, } /// RTC statistics of the data producer. @@ -124,6 +130,8 @@ pub struct DataProducerStat { #[derive(Default)] #[allow(clippy::type_complexity)] struct Handlers { + pause: Bag>, + resume: Bag>, transport_close: BagOnce>, close: BagOnce>, } @@ -134,6 +142,7 @@ struct Inner { sctp_stream_parameters: Option, label: String, protocol: String, + paused: AtomicBool, direct: bool, executor: Arc>, channel: Channel, @@ -193,6 +202,7 @@ impl fmt::Debug for RegularDataProducer { .field("sctp_stream_parameters", &self.inner.sctp_stream_parameters) .field("label", &self.inner.label) .field("protocol", &self.inner.protocol) + .field("paused", &self.inner.paused) .field("transport", &self.inner.transport) .field("closed", &self.inner.closed) .finish() @@ -220,6 +230,7 @@ impl fmt::Debug for DirectDataProducer { .field("sctp_stream_parameters", &self.inner.sctp_stream_parameters) .field("label", &self.inner.label) .field("protocol", &self.inner.protocol) + .field("paused", &self.inner.paused) .field("transport", &self.inner.transport) .field("closed", &self.inner.closed) .finish() @@ -266,6 +277,7 @@ impl DataProducer { sctp_stream_parameters: Option, label: String, protocol: String, + paused: bool, executor: Arc>, channel: Channel, app_data: AppData, @@ -294,6 +306,7 @@ impl DataProducer { sctp_stream_parameters, label, protocol, + paused: AtomicBool::new(paused), direct, executor, channel, @@ -336,6 +349,12 @@ impl DataProducer { self.inner().sctp_stream_parameters } + /// Whether the DataProducer is paused. + #[must_use] + pub fn paused(&self) -> bool { + self.inner().paused.load(Ordering::SeqCst) + } + /// The data producer label. #[must_use] pub fn label(&self) -> &String { @@ -384,6 +403,46 @@ impl DataProducer { .await } + /// Pauses the data producer (no message is sent to its associated data consumers). + /// Calls [`DataConsumer::on_data_producer_pause`](crate::data_consumer::DataConsumer::on_data_producer_pause) + /// callback on all its associated data consumers. + pub async fn pause(&self) -> Result<(), RequestError> { + debug!("pause()"); + + self.inner() + .channel + .request(self.id(), DataProducerPauseRequest {}) + .await?; + + let was_paused = self.inner().paused.swap(true, Ordering::SeqCst); + + if !was_paused { + self.inner().handlers.pause.call_simple(); + } + + Ok(()) + } + + /// Resumes the data producer (messages are sent to its associated data consumers). + /// Calls [`DataConsumer::on_data_producer_resume`](crate::data_consumer::DataConsumer::on_data_producer_resume) + /// callback on all its associated data consumers. + pub async fn resume(&self) -> Result<(), RequestError> { + debug!("resume()"); + + self.inner() + .channel + .request(self.id(), DataProducerResumeRequest {}) + .await?; + + let was_paused = self.inner().paused.swap(false, Ordering::SeqCst); + + if was_paused { + self.inner().handlers.resume.call_simple(); + } + + Ok(()) + } + /// Callback is called when the transport this data producer belongs to is closed for whatever /// reason. The producer itself is also closed. A `on_data_producer_close` callback is called on /// all its associated consumers. @@ -394,6 +453,16 @@ impl DataProducer { .add(Box::new(callback)) } + /// Callback is called when the data producer is paused. + pub fn on_pause(&self, callback: F) -> HandlerId { + self.inner().handlers.pause.add(Arc::new(callback)) + } + + /// Callback is called when the data producer is resumed. + pub fn on_resume(&self, callback: F) -> HandlerId { + self.inner().handlers.resume.add(Arc::new(callback)) + } + /// Callback is called when the producer is closed for whatever reason. /// /// NOTE: Callback will be called in place if data producer is already closed. diff --git a/rust/src/router/producer.rs b/rust/src/router/producer.rs index 3ee856b797..9634f3255b 100644 --- a/rust/src/router/producer.rs +++ b/rust/src/router/producer.rs @@ -617,7 +617,7 @@ impl Producer { Ok(()) } - /// Resumes the producer (no RTP is sent to its associated consumers). Calls + /// Resumes the producer (RTP is sent to its associated consumers). Calls /// [`Consumer::on_producer_resume`](crate::consumer::Consumer::on_producer_resume) callback on /// all its associated consumers. pub async fn resume(&self) -> Result<(), RequestError> { diff --git a/rust/src/router/transport.rs b/rust/src/router/transport.rs index d15771596e..a8aa857d82 100644 --- a/rust/src/router/transport.rs +++ b/rust/src/router/transport.rs @@ -634,6 +634,7 @@ pub(super) trait TransportImpl: TransportGeneric { sctp_stream_parameters, label, protocol, + paused, app_data, } = data_producer_options; @@ -651,6 +652,7 @@ pub(super) trait TransportImpl: TransportGeneric { sctp_stream_parameters, label, protocol, + paused, }, ) .await @@ -662,6 +664,7 @@ pub(super) trait TransportImpl: TransportGeneric { response.sctp_stream_parameters, response.label, response.protocol, + response.paused, Arc::clone(self.executor()), self.channel().clone(), app_data, @@ -681,6 +684,7 @@ pub(super) trait TransportImpl: TransportGeneric { ordered, max_packet_life_time, max_retransmits, + paused, app_data, } = data_consumer_options; @@ -745,6 +749,7 @@ pub(super) trait TransportImpl: TransportGeneric { sctp_stream_parameters, label: data_producer.label().clone(), protocol: data_producer.protocol().clone(), + paused, }, ) .await @@ -756,9 +761,11 @@ pub(super) trait TransportImpl: TransportGeneric { response.sctp_stream_parameters, response.label, response.protocol, + response.paused, data_producer, Arc::clone(self.executor()), self.channel().clone(), + response.data_producer_paused, app_data, Arc::new(self.clone()), transport_type == TransportType::Direct, diff --git a/rust/tests/integration/data_producer.rs b/rust/tests/integration/data_producer.rs index 7fb83ce83f..e753ff5eb5 100644 --- a/rust/tests/integration/data_producer.rs +++ b/rust/tests/integration/data_producer.rs @@ -130,6 +130,7 @@ fn transport_1_produce_data_succeeds() { } assert_eq!(data_producer1.label().as_str(), "foo"); assert_eq!(data_producer1.protocol().as_str(), "bar"); + assert!(!data_producer1.paused()); assert_eq!( data_producer1 .app_data() @@ -187,6 +188,7 @@ fn transport_2_produce_data_succeeds() { options.label = "foo".to_string(); options.protocol = "bar".to_string(); + options.paused = true; options.app_data = AppData::new(CustomAppData { foo: 1, baz: "2" }); options @@ -207,6 +209,7 @@ fn transport_2_produce_data_succeeds() { } assert_eq!(data_producer2.label().as_str(), "foo"); assert_eq!(data_producer2.protocol().as_str(), "bar"); + assert!(data_producer2.paused()); assert_eq!( data_producer2 .app_data() @@ -328,6 +331,7 @@ fn dump_succeeds() { } assert_eq!(dump.label.as_str(), "foo"); assert_eq!(dump.protocol.as_str(), "bar"); + assert!(!dump.paused); } { @@ -339,6 +343,7 @@ fn dump_succeeds() { options.label = "foo".to_string(); options.protocol = "bar".to_string(); + options.paused = true; options.app_data = AppData::new(CustomAppData { foo: 1, baz: "2" }); options @@ -363,6 +368,7 @@ fn dump_succeeds() { } assert_eq!(dump.label.as_str(), "foo"); assert_eq!(dump.protocol.as_str(), "bar"); + assert!(dump.paused); } }); } @@ -429,6 +435,61 @@ fn get_stats_succeeds() { }); } +#[test] +fn pause_and_resume_succeed() { + future::block_on(async move { + let (_worker, _router, transport1, _) = init().await; + + { + let data_producer1 = transport1 + .produce_data({ + let mut options = + DataProducerOptions::new_sctp(SctpStreamParameters::new_ordered(666)); + + options.label = "foo".to_string(); + options.protocol = "bar".to_string(); + options.app_data = AppData::new(CustomAppData { foo: 1, baz: "2" }); + + options + }) + .await + .expect("Failed to produce data"); + + { + data_producer1 + .pause() + .await + .expect("Failed to pause data producer"); + + assert!(data_producer1.paused()); + + let dump = data_producer1 + .dump() + .await + .expect("Failed to dump data producer"); + + assert!(dump.paused); + } + + { + data_producer1 + .resume() + .await + .expect("Failed to resume data producer"); + + assert!(!data_producer1.paused()); + + let dump = data_producer1 + .dump() + .await + .expect("Failed to dump data producer"); + + assert!(!dump.paused); + } + } + }); +} + #[test] fn close_event() { future::block_on(async move { diff --git a/rust/tests/integration/direct_transport.rs b/rust/tests/integration/direct_transport.rs index 70e8730683..0793351f64 100644 --- a/rust/tests/integration/direct_transport.rs +++ b/rust/tests/integration/direct_transport.rs @@ -179,7 +179,16 @@ fn send_succeeds() { .expect("Failed to consume data"); let num_messages = 200_usize; + let pause_sending_at_message = 10_usize; + let resume_sending_at_message = 20_usize; + let pause_receiving_at_message = 40_usize; + let resume_receiving_at_message = 60_usize; + let expected_received_num_messages = num_messages + - (resume_sending_at_message - pause_sending_at_message) + - (resume_receiving_at_message - pause_receiving_at_message); + let mut sent_message_bytes = 0_usize; + let mut effectively_sent_message_bytes = 0_usize; let recv_message_bytes = Arc::new(AtomicUsize::new(0)); let mut last_sent_message_id = 0_usize; let last_recv_message_id = Arc::new(AtomicUsize::new(0)); @@ -234,13 +243,45 @@ fn send_succeeds() { last_sent_message_id += 1; let id = last_sent_message_id; + if id == pause_sending_at_message { + data_producer + .pause() + .await + .expect("Failed to pause data producer"); + } else if id == resume_sending_at_message { + data_producer + .resume() + .await + .expect("Failed to resume data producer"); + } else if id == pause_receiving_at_message { + data_consumer + .pause() + .await + .expect("Failed to pause data consumer"); + } else if id == resume_receiving_at_message { + data_consumer + .resume() + .await + .expect("Failed to resume data consumer"); + } + let message = if id < num_messages / 2 { let content = id.to_string(); sent_message_bytes += content.len(); + + if !data_producer.paused() && !data_consumer.paused() { + effectively_sent_message_bytes += content.len(); + } + WebRtcMessage::String(content) } else { let content = id.to_string().into_bytes(); sent_message_bytes += content.len(); + + if !data_producer.paused() && !data_consumer.paused() { + effectively_sent_message_bytes += content.len(); + } + WebRtcMessage::Binary(Cow::from(content)) }; @@ -258,10 +299,13 @@ fn send_succeeds() { .expect("Failed tor receive all messages"); assert_eq!(last_sent_message_id, num_messages); - assert_eq!(last_recv_message_id.load(Ordering::SeqCst), num_messages); + assert_eq!( + last_recv_message_id.load(Ordering::SeqCst), + expected_received_num_messages + ); assert_eq!( recv_message_bytes.load(Ordering::SeqCst), - sent_message_bytes, + effectively_sent_message_bytes, ); { @@ -286,7 +330,7 @@ fn send_succeeds() { assert_eq!(stats.len(), 1); assert_eq!(&stats[0].label, data_consumer.label()); assert_eq!(&stats[0].protocol, data_consumer.protocol()); - assert_eq!(stats[0].messages_sent, num_messages); + assert_eq!(stats[0].messages_sent, expected_received_num_messages); assert_eq!( stats[0].bytes_sent, recv_message_bytes.load(Ordering::SeqCst), diff --git a/worker/fbs/consumer.fbs b/worker/fbs/consumer.fbs index 673269e848..e926006407 100644 --- a/worker/fbs/consumer.fbs +++ b/worker/fbs/consumer.fbs @@ -54,8 +54,8 @@ table BaseConsumerDump { consumable_rtp_encodings:[FBS.RtpParameters.RtpEncodingParameters]; supported_codec_payload_types:[uint8]; trace_event_types:[string] (required); - paused:bool = false; - producer_paused:bool = false; + paused:bool; + producer_paused:bool; priority:uint8; } diff --git a/worker/fbs/dataConsumer.fbs b/worker/fbs/dataConsumer.fbs index bd8a376303..54aa7a0904 100644 --- a/worker/fbs/dataConsumer.fbs +++ b/worker/fbs/dataConsumer.fbs @@ -18,6 +18,8 @@ table DumpResponse { sctp_stream_parameters: FBS.SctpParameters.SctpStreamParameters; label:string (required); protocol:string (required); + paused:bool; + data_producer_paused:bool; } table GetStatsResponse { diff --git a/worker/fbs/dataProducer.fbs b/worker/fbs/dataProducer.fbs index 0d05717010..969939cac9 100644 --- a/worker/fbs/dataProducer.fbs +++ b/worker/fbs/dataProducer.fbs @@ -8,6 +8,7 @@ table DumpResponse { sctp_stream_parameters: FBS.SctpParameters.SctpStreamParameters; label:string (required); protocol:string (required); + paused:bool; } table GetStatsResponse { diff --git a/worker/fbs/notification.fbs b/worker/fbs/notification.fbs index 378fa3bc9c..cbb8eb0b60 100644 --- a/worker/fbs/notification.fbs +++ b/worker/fbs/notification.fbs @@ -14,7 +14,7 @@ enum Event: uint8 { // Notifications to worker. TRANSPORT_SEND_RTCP = 0, PRODUCER_SEND, - DATA_PRODUCER_SEND, + DATAPRODUCER_SEND, // Notifications from worker. WORKER_RUNNING, TRANSPORT_SCTP_STATE_CHANGE, @@ -37,6 +37,8 @@ enum Event: uint8 { CONSUMER_TRACE, DATACONSUMER_BUFFERED_AMOUNT_LOW, DATACONSUMER_SCTP_SENDBUFFER_FULL, + DATACONSUMER_DATAPRODUCER_PAUSE, + DATACONSUMER_DATAPRODUCER_RESUME, DATACONSUMER_DATAPRODUCER_CLOSE, DATACONSUMER_MESSAGE, ACTIVESPEAKEROBSERVER_DOMINANT_SPEAKER, diff --git a/worker/fbs/producer.fbs b/worker/fbs/producer.fbs index 64d7d81ee2..b59813c672 100644 --- a/worker/fbs/producer.fbs +++ b/worker/fbs/producer.fbs @@ -15,7 +15,7 @@ table DumpResponse { rtp_mapping:FBS.RtpParameters.RtpMapping (required); rtp_streams:[FBS.RtpStream.Dump]; trace_event_types:[string] (required); - paused:bool = false; + paused:bool; } table GetStatsResponse { diff --git a/worker/fbs/request.fbs b/worker/fbs/request.fbs index 58374d3e11..7b6b0183dc 100644 --- a/worker/fbs/request.fbs +++ b/worker/fbs/request.fbs @@ -13,21 +13,21 @@ enum Method: uint8 { WORKER_DUMP, WORKER_GET_RESOURCE_USAGE, WORKER_UPDATE_SETTINGS, - WORKER_CREATE_WEBRTC_SERVER, + WORKER_CREATE_WEBRTCSERVER, WORKER_CREATE_ROUTER, - WORKER_WEBRTC_SERVER_CLOSE, + WORKER_WEBRTCSERVER_CLOSE, WORKER_CLOSE_ROUTER, - WEBRTC_SERVER_DUMP, + WEBRTCSERVER_DUMP, ROUTER_DUMP, - ROUTER_CREATE_WEBRTC_TRANSPORT, - ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER, - ROUTER_CREATE_PLAIN_TRANSPORT, - ROUTER_CREATE_PIPE_TRANSPORT, - ROUTER_CREATE_DIRECT_TRANSPORT, + ROUTER_CREATE_WEBRTCTRANSPORT, + ROUTER_CREATE_WEBRTCTRANSPORT_WITH_SERVER, + ROUTER_CREATE_PLAINTRANSPORT, + ROUTER_CREATE_PIPETRANSPORT, + ROUTER_CREATE_DIRECTTRANSPORT, ROUTER_CLOSE_TRANSPORT, - ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER, - ROUTER_CREATE_AUDIO_LEVEL_OBSERVER, - ROUTER_CLOSE_RTP_OBSERVER, + ROUTER_CREATE_ACTIVESPEAKEROBSERVER, + ROUTER_CREATE_AUDIOLEVELOBSERVER, + ROUTER_CLOSE_RTPOBSERVER, TRANSPORT_DUMP, TRANSPORT_GET_STATS, TRANSPORT_CONNECT, @@ -42,11 +42,11 @@ enum Method: uint8 { TRANSPORT_ENABLE_TRACE_EVENT, TRANSPORT_CLOSE_PRODUCER, TRANSPORT_CLOSE_CONSUMER, - TRANSPORT_CLOSE_DATA_PRODUCER, - TRANSPORT_CLOSE_DATA_CONSUMER, - PLAIN_TRANSPORT_CONNECT, - PIPE_TRANSPORT_CONNECT, - WEBRTC_TRANSPORT_CONNECT, + TRANSPORT_CLOSE_DATAPRODUCER, + TRANSPORT_CLOSE_DATACONSUMER, + PLAINTRANSPORT_CONNECT, + PIPETRANSPORT_CONNECT, + WEBRTCTRANSPORT_CONNECT, PRODUCER_DUMP, PRODUCER_GET_STATS, PRODUCER_PAUSE, @@ -60,17 +60,21 @@ enum Method: uint8 { CONSUMER_SET_PRIORITY, CONSUMER_REQUEST_KEY_FRAME, CONSUMER_ENABLE_TRACE_EVENT, - DATA_PRODUCER_DUMP, - DATA_PRODUCER_GET_STATS, - DATA_CONSUMER_DUMP, - DATA_CONSUMER_GET_STATS, - DATA_CONSUMER_GET_BUFFERED_AMOUNT, - DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, - DATA_CONSUMER_SEND, - RTP_OBSERVER_PAUSE, - RTP_OBSERVER_RESUME, - RTP_OBSERVER_ADD_PRODUCER, - RTP_OBSERVER_REMOVE_PRODUCER, + DATAPRODUCER_DUMP, + DATAPRODUCER_GET_STATS, + DATAPRODUCER_PAUSE, + DATAPRODUCER_RESUME, + DATACONSUMER_DUMP, + DATACONSUMER_GET_STATS, + DATACONSUMER_PAUSE, + DATACONSUMER_RESUME, + DATACONSUMER_GET_BUFFERED_AMOUNT, + DATACONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, + DATACONSUMER_SEND, + RTPOBSERVER_PAUSE, + RTPOBSERVER_RESUME, + RTPOBSERVER_ADD_PRODUCER, + RTPOBSERVER_REMOVE_PRODUCER, } union Body { diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs index 7e9b7dfca7..30f4958da0 100644 --- a/worker/fbs/transport.fbs +++ b/worker/fbs/transport.fbs @@ -23,6 +23,19 @@ table RestartIceResponse { ice_lite:bool; } +table ProduceRequest { + producer_id:string (required); + kind:FBS.RtpParameters.MediaKind; + rtp_parameters:FBS.RtpParameters.RtpParameters (required); + rtp_mapping:FBS.RtpParameters.RtpMapping (required); + key_frame_request_delay:uint16; + paused:bool = false; +} + +table ProduceResponse { + type:FBS.RtpParameters.Type; +} + table ConsumeRequest { consumer_id:string (required); producer_id:string (required); @@ -42,25 +55,13 @@ table ConsumeResponse { preferred_layers:FBS.Consumer.ConsumerLayers; } -table ProduceRequest { - producer_id:string (required); - kind:FBS.RtpParameters.MediaKind; - rtp_parameters:FBS.RtpParameters.RtpParameters (required); - rtp_mapping:FBS.RtpParameters.RtpMapping (required); - key_frame_request_delay:uint16; - paused:bool = false; -} - -table ProduceResponse { - type:FBS.RtpParameters.Type; -} - table ProduceDataRequest { data_producer_id:string (required); type:string (required); sctp_stream_parameters:FBS.SctpParameters.SctpStreamParameters; label:string; protocol:string; + paused:bool = false; } table ConsumeDataRequest { @@ -70,6 +71,7 @@ table ConsumeDataRequest { sctp_stream_parameters:FBS.SctpParameters.SctpStreamParameters; label:string; protocol:string; + paused:bool = false; } table Tuple { diff --git a/worker/include/RTC/DataConsumer.hpp b/worker/include/RTC/DataConsumer.hpp index d888e3c3c9..17e0e2c3e5 100644 --- a/worker/include/RTC/DataConsumer.hpp +++ b/worker/include/RTC/DataConsumer.hpp @@ -68,16 +68,30 @@ namespace RTC } bool IsActive() const { + // It's active it DataConsumer and DataProducer are not paused and the transport + // is connected. // clang-format off return ( this->transportConnected && (this->type == DataConsumer::Type::DIRECT || this->sctpAssociationConnected) && + !this->paused && + !this->dataProducerPaused && !this->dataProducerClosed ); // clang-format on } void TransportConnected(); void TransportDisconnected(); + bool IsPaused() const + { + return this->paused; + } + bool IsDataProducerPaused() const + { + return this->dataProducerPaused; + } + void DataProducerPaused(); + void DataProducerResumed(); void SctpAssociationConnected(); void SctpAssociationClosed(); void SctpAssociationBufferedAmount(uint32_t bufferedAmount); @@ -108,6 +122,8 @@ namespace RTC std::string protocol; bool transportConnected{ false }; bool sctpAssociationConnected{ false }; + bool paused{ false }; + bool dataProducerPaused{ false }; bool dataProducerClosed{ false }; size_t messagesSent{ 0u }; size_t bytesSent{ 0u }; diff --git a/worker/include/RTC/DataProducer.hpp b/worker/include/RTC/DataProducer.hpp index 6ebe066ba1..cdff1842d5 100644 --- a/worker/include/RTC/DataProducer.hpp +++ b/worker/include/RTC/DataProducer.hpp @@ -24,6 +24,8 @@ namespace RTC virtual void OnDataProducerReceiveData(RTC::DataProducer* producer, size_t len) = 0; virtual void OnDataProducerMessageReceived( RTC::DataProducer* dataProducer, uint32_t ppid, const uint8_t* msg, size_t len) = 0; + virtual void OnDataProducerPaused(RTC::DataProducer* dataProducer) = 0; + virtual void OnDataProducerResumed(RTC::DataProducer* dataProducer) = 0; }; public: @@ -55,6 +57,10 @@ namespace RTC { return this->sctpStreamParameters; } + bool IsPaused() const + { + return this->paused; + } void ReceiveMessage(uint32_t ppid, const uint8_t* msg, size_t len); /* Methods inherited from Channel::ChannelSocket::RequestHandler. */ @@ -80,6 +86,7 @@ namespace RTC RTC::SctpStreamParameters sctpStreamParameters; std::string label; std::string protocol; + bool paused{ false }; size_t messagesReceived{ 0u }; size_t bytesReceived{ 0u }; }; diff --git a/worker/include/RTC/PipeConsumer.hpp b/worker/include/RTC/PipeConsumer.hpp index 6d998124a5..252a1a7e69 100644 --- a/worker/include/RTC/PipeConsumer.hpp +++ b/worker/include/RTC/PipeConsumer.hpp @@ -1,5 +1,5 @@ -#ifndef MS_RTC_PIPE_CONSUMER_HPP -#define MS_RTC_PIPE_CONSUMER_HPP +#ifndef MS_RTC_PIPECONSUMER_HPP +#define MS_RTC_PIPECONSUMER_HPP #include "RTC/Consumer.hpp" #include "RTC/RtpStreamSend.hpp" diff --git a/worker/include/RTC/Router.hpp b/worker/include/RTC/Router.hpp index 1715b2a0b0..c7370b94e3 100644 --- a/worker/include/RTC/Router.hpp +++ b/worker/include/RTC/Router.hpp @@ -87,6 +87,9 @@ namespace RTC RTC::Transport* transport, RTC::Consumer* consumer, uint32_t mappedSsrc) override; void OnTransportNewDataProducer(RTC::Transport* transport, RTC::DataProducer* dataProducer) override; void OnTransportDataProducerClosed(RTC::Transport* transport, RTC::DataProducer* dataProducer) override; + void OnTransportDataProducerPaused(RTC::Transport* transport, RTC::DataProducer* dataProducer) override; + void OnTransportDataProducerResumed( + RTC::Transport* transport, RTC::DataProducer* dataProducer) override; void OnTransportDataProducerMessageReceived( RTC::Transport* transport, RTC::DataProducer* dataProducer, diff --git a/worker/include/RTC/RtpObserver.hpp b/worker/include/RTC/RtpObserver.hpp index 4c78a5f847..c17efdc5ad 100644 --- a/worker/include/RTC/RtpObserver.hpp +++ b/worker/include/RTC/RtpObserver.hpp @@ -1,5 +1,5 @@ -#ifndef MS_RTC_RTP_PACKET_OBSERVER_HPP -#define MS_RTC_RTP_PACKET_OBSERVER_HPP +#ifndef MS_RTC_RTP_OBSERVER_HPP +#define MS_RTC_RTP_OBSERVER_HPP #include "common.hpp" #include "RTC/Producer.hpp" diff --git a/worker/include/RTC/Transport.hpp b/worker/include/RTC/Transport.hpp index 957fff6f2e..48682dbe20 100644 --- a/worker/include/RTC/Transport.hpp +++ b/worker/include/RTC/Transport.hpp @@ -87,6 +87,10 @@ namespace RTC virtual void OnTransportConsumerClosed(RTC::Transport* transport, RTC::Consumer* consumer) = 0; virtual void OnTransportConsumerProducerClosed( RTC::Transport* transport, RTC::Consumer* consumer) = 0; + virtual void OnTransportDataProducerPaused( + RTC::Transport* transport, RTC::DataProducer* dataProducer) = 0; + virtual void OnTransportDataProducerResumed( + RTC::Transport* transport, RTC::DataProducer* dataProducer) = 0; virtual void OnTransportConsumerKeyFrameRequested( RTC::Transport* transport, RTC::Consumer* consumer, uint32_t mappedSsrc) = 0; virtual void OnTransportNewDataProducer( @@ -235,6 +239,8 @@ namespace RTC } void OnDataProducerMessageReceived( RTC::DataProducer* dataProducer, uint32_t ppid, const uint8_t* msg, size_t len) override; + void OnDataProducerPaused(RTC::DataProducer* dataProducer) override; + void OnDataProducerResumed(RTC::DataProducer* dataProducer) override; /* Pure virtual methods inherited from RTC::DataConsumer::Listener. */ public: diff --git a/worker/src/Channel/ChannelNotification.cpp b/worker/src/Channel/ChannelNotification.cpp index fd2b1809de..4603622ead 100644 --- a/worker/src/Channel/ChannelNotification.cpp +++ b/worker/src/Channel/ChannelNotification.cpp @@ -13,8 +13,8 @@ namespace Channel absl::flat_hash_map ChannelNotification::event2String = { { FBS::Notification::Event::TRANSPORT_SEND_RTCP, "transport.sendRtcp" }, - { FBS::Notification::Event::PRODUCER_SEND, "producer.send" }, - { FBS::Notification::Event::DATA_PRODUCER_SEND, "dataProducer.send" }, + { FBS::Notification::Event::PRODUCER_SEND, "producer.send" }, + { FBS::Notification::Event::DATAPRODUCER_SEND, "dataProducer.send" }, }; // clang-format on diff --git a/worker/src/Channel/ChannelRequest.cpp b/worker/src/Channel/ChannelRequest.cpp index 6b19ffffba..22ec2d04c9 100644 --- a/worker/src/Channel/ChannelRequest.cpp +++ b/worker/src/Channel/ChannelRequest.cpp @@ -12,68 +12,72 @@ namespace Channel // clang-format off absl::flat_hash_map ChannelRequest::method2String = { - { FBS::Request::Method::WORKER_CLOSE, "worker.close" }, - { FBS::Request::Method::WORKER_DUMP, "worker.dump" }, - { FBS::Request::Method::WORKER_GET_RESOURCE_USAGE, "worker.getResourceUsage" }, - { FBS::Request::Method::WORKER_UPDATE_SETTINGS, "worker.updateSettings" }, - { FBS::Request::Method::WORKER_CREATE_WEBRTC_SERVER, "worker.createWebRtcServer" }, - { FBS::Request::Method::WORKER_CREATE_ROUTER, "worker.createRouter" }, - { FBS::Request::Method::WORKER_WEBRTC_SERVER_CLOSE, "worker.closeWebRtcServer" }, - { FBS::Request::Method::WORKER_CLOSE_ROUTER, "worker.closeRouter" }, - { FBS::Request::Method::WEBRTC_SERVER_DUMP, "webRtcServer.dump" }, - { FBS::Request::Method::ROUTER_DUMP, "router.dump" }, - { FBS::Request::Method::ROUTER_CREATE_WEBRTC_TRANSPORT, "router.createWebRtcTransport" }, - { FBS::Request::Method::ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER, "router.createWebRtcTransportWithServer" }, - { FBS::Request::Method::ROUTER_CREATE_PLAIN_TRANSPORT, "router.createPlainTransport" }, - { FBS::Request::Method::ROUTER_CREATE_PIPE_TRANSPORT, "router.createPipeTransport" }, - { FBS::Request::Method::ROUTER_CREATE_DIRECT_TRANSPORT, "router.createDirectTransport" }, - { FBS::Request::Method::ROUTER_CLOSE_TRANSPORT, "router.closeTransport" }, - { FBS::Request::Method::ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER, "router.createActiveSpeakerObserver" }, - { FBS::Request::Method::ROUTER_CREATE_AUDIO_LEVEL_OBSERVER, "router.createAudioLevelObserver" }, - { FBS::Request::Method::ROUTER_CLOSE_RTP_OBSERVER, "router.closeRtpObserver" }, - { FBS::Request::Method::TRANSPORT_DUMP, "transport.dump" }, - { FBS::Request::Method::TRANSPORT_GET_STATS, "transport.getStats" }, - { FBS::Request::Method::TRANSPORT_CONNECT, "transport.connect" }, - { FBS::Request::Method::TRANSPORT_SET_MAX_INCOMING_BITRATE, "transport.setMaxIncomingBitrate" }, - { FBS::Request::Method::TRANSPORT_SET_MAX_OUTGOING_BITRATE, "transport.setMaxOutgoingBitrate" }, - { FBS::Request::Method::TRANSPORT_SET_MIN_OUTGOING_BITRATE, "transport.setMinOutgoingBitrate" }, - { FBS::Request::Method::TRANSPORT_RESTART_ICE, "transport.restartIce" }, - { FBS::Request::Method::TRANSPORT_PRODUCE, "transport.produce" }, - { FBS::Request::Method::TRANSPORT_PRODUCE_DATA, "transport.produceData" }, - { FBS::Request::Method::TRANSPORT_CONSUME, "transport.consume" }, - { FBS::Request::Method::TRANSPORT_CONSUME_DATA, "transport.consumeData" }, - { FBS::Request::Method::TRANSPORT_ENABLE_TRACE_EVENT, "transport.enableTraceEvent" }, - { FBS::Request::Method::TRANSPORT_CLOSE_PRODUCER, "transport.closeProducer" }, - { FBS::Request::Method::TRANSPORT_CLOSE_CONSUMER, "transport.closeConsumer" }, - { FBS::Request::Method::TRANSPORT_CLOSE_DATA_PRODUCER, "transport.closeDataProducer" }, - { FBS::Request::Method::TRANSPORT_CLOSE_DATA_CONSUMER, "transport.closeDataConsumer" }, - { FBS::Request::Method::PLAIN_TRANSPORT_CONNECT, "plainTransport.connect" }, - { FBS::Request::Method::PIPE_TRANSPORT_CONNECT, "pipeTransport.connect" }, - { FBS::Request::Method::WEBRTC_TRANSPORT_CONNECT, "webRtcTransport.connect" }, - { FBS::Request::Method::PRODUCER_DUMP, "producer.dump" }, - { FBS::Request::Method::PRODUCER_GET_STATS, "producer.getStats" }, - { FBS::Request::Method::PRODUCER_PAUSE, "producer.pause" }, - { FBS::Request::Method::PRODUCER_RESUME, "producer.resume" }, - { FBS::Request::Method::PRODUCER_ENABLE_TRACE_EVENT, "producer.enableTraceEvent" }, - { FBS::Request::Method::CONSUMER_DUMP, "consumer.dump" }, - { FBS::Request::Method::CONSUMER_GET_STATS, "consumer.getStats" }, - { FBS::Request::Method::CONSUMER_PAUSE, "consumer.pause" }, - { FBS::Request::Method::CONSUMER_RESUME, "consumer.resume" }, - { FBS::Request::Method::CONSUMER_SET_PREFERRED_LAYERS, "consumer.setPreferredLayers" }, - { FBS::Request::Method::CONSUMER_SET_PRIORITY, "consumer.setPriority" }, - { FBS::Request::Method::CONSUMER_REQUEST_KEY_FRAME, "consumer.requestKeyFrame" }, - { FBS::Request::Method::CONSUMER_ENABLE_TRACE_EVENT, "consumer.enableTraceEvent" }, - { FBS::Request::Method::DATA_PRODUCER_DUMP, "dataProducer.dump" }, - { FBS::Request::Method::DATA_PRODUCER_GET_STATS, "dataProducer.getStats" }, - { FBS::Request::Method::DATA_CONSUMER_DUMP, "dataConsumer.dump" }, - { FBS::Request::Method::DATA_CONSUMER_GET_STATS, "dataConsumer.getStats" }, - { FBS::Request::Method::DATA_CONSUMER_GET_BUFFERED_AMOUNT, "dataConsumer.getBufferedAmount" }, - { FBS::Request::Method::DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, "dataConsumer.setBufferedAmountLowThreshold" }, - { FBS::Request::Method::DATA_CONSUMER_SEND, "dataConsumer.send" }, - { FBS::Request::Method::RTP_OBSERVER_PAUSE, "rtpObserver.pause" }, - { FBS::Request::Method::RTP_OBSERVER_RESUME, "rtpObserver.resume" }, - { FBS::Request::Method::RTP_OBSERVER_ADD_PRODUCER, "rtpObserver.addProducer" }, - { FBS::Request::Method::RTP_OBSERVER_REMOVE_PRODUCER, "rtpObserver.removeProducer" }, + { FBS::Request::Method::WORKER_CLOSE, "worker.close" }, + { FBS::Request::Method::WORKER_DUMP, "worker.dump" }, + { FBS::Request::Method::WORKER_GET_RESOURCE_USAGE, "worker.getResourceUsage" }, + { FBS::Request::Method::WORKER_UPDATE_SETTINGS, "worker.updateSettings" }, + { FBS::Request::Method::WORKER_CREATE_WEBRTCSERVER, "worker.createWebRtcServer" }, + { FBS::Request::Method::WORKER_CREATE_ROUTER, "worker.createRouter" }, + { FBS::Request::Method::WORKER_WEBRTCSERVER_CLOSE, "worker.closeWebRtcServer" }, + { FBS::Request::Method::WORKER_CLOSE_ROUTER, "worker.closeRouter" }, + { FBS::Request::Method::WEBRTCSERVER_DUMP, "webRtcServer.dump" }, + { FBS::Request::Method::ROUTER_DUMP, "router.dump" }, + { FBS::Request::Method::ROUTER_CREATE_WEBRTCTRANSPORT, "router.createWebRtcTransport" }, + { FBS::Request::Method::ROUTER_CREATE_WEBRTCTRANSPORT_WITH_SERVER, "router.createWebRtcTransportWithServer" }, + { FBS::Request::Method::ROUTER_CREATE_PLAINTRANSPORT, "router.createPlainTransport" }, + { FBS::Request::Method::ROUTER_CREATE_PIPETRANSPORT, "router.createPipeTransport" }, + { FBS::Request::Method::ROUTER_CREATE_DIRECTTRANSPORT, "router.createDirectTransport" }, + { FBS::Request::Method::ROUTER_CLOSE_TRANSPORT, "router.closeTransport" }, + { FBS::Request::Method::ROUTER_CREATE_ACTIVESPEAKEROBSERVER, "router.createActiveSpeakerObserver" }, + { FBS::Request::Method::ROUTER_CREATE_AUDIOLEVELOBSERVER, "router.createAudioLevelObserver" }, + { FBS::Request::Method::ROUTER_CLOSE_RTPOBSERVER, "router.closeRtpObserver" }, + { FBS::Request::Method::TRANSPORT_DUMP, "transport.dump" }, + { FBS::Request::Method::TRANSPORT_GET_STATS, "transport.getStats" }, + { FBS::Request::Method::TRANSPORT_CONNECT, "transport.connect" }, + { FBS::Request::Method::TRANSPORT_SET_MAX_INCOMING_BITRATE, "transport.setMaxIncomingBitrate" }, + { FBS::Request::Method::TRANSPORT_SET_MAX_OUTGOING_BITRATE, "transport.setMaxOutgoingBitrate" }, + { FBS::Request::Method::TRANSPORT_SET_MIN_OUTGOING_BITRATE, "transport.setMinOutgoingBitrate" }, + { FBS::Request::Method::TRANSPORT_RESTART_ICE, "transport.restartIce" }, + { FBS::Request::Method::TRANSPORT_PRODUCE, "transport.produce" }, + { FBS::Request::Method::TRANSPORT_PRODUCE_DATA, "transport.produceData" }, + { FBS::Request::Method::TRANSPORT_CONSUME, "transport.consume" }, + { FBS::Request::Method::TRANSPORT_CONSUME_DATA, "transport.consumeData" }, + { FBS::Request::Method::TRANSPORT_ENABLE_TRACE_EVENT, "transport.enableTraceEvent" }, + { FBS::Request::Method::TRANSPORT_CLOSE_PRODUCER, "transport.closeProducer" }, + { FBS::Request::Method::TRANSPORT_CLOSE_CONSUMER, "transport.closeConsumer" }, + { FBS::Request::Method::TRANSPORT_CLOSE_DATAPRODUCER, "transport.closeDataProducer" }, + { FBS::Request::Method::TRANSPORT_CLOSE_DATACONSUMER, "transport.closeDataConsumer" }, + { FBS::Request::Method::PLAINTRANSPORT_CONNECT, "plainTransport.connect" }, + { FBS::Request::Method::PIPETRANSPORT_CONNECT, "pipeTransport.connect" }, + { FBS::Request::Method::WEBRTCTRANSPORT_CONNECT, "webRtcTransport.connect" }, + { FBS::Request::Method::PRODUCER_DUMP, "producer.dump" }, + { FBS::Request::Method::PRODUCER_GET_STATS, "producer.getStats" }, + { FBS::Request::Method::PRODUCER_PAUSE, "producer.pause" }, + { FBS::Request::Method::PRODUCER_RESUME, "producer.resume" }, + { FBS::Request::Method::PRODUCER_ENABLE_TRACE_EVENT, "producer.enableTraceEvent" }, + { FBS::Request::Method::CONSUMER_DUMP, "consumer.dump" }, + { FBS::Request::Method::CONSUMER_GET_STATS, "consumer.getStats" }, + { FBS::Request::Method::CONSUMER_PAUSE, "consumer.pause" }, + { FBS::Request::Method::CONSUMER_RESUME, "consumer.resume" }, + { FBS::Request::Method::CONSUMER_SET_PREFERRED_LAYERS, "consumer.setPreferredLayers" }, + { FBS::Request::Method::CONSUMER_SET_PRIORITY, "consumer.setPriority" }, + { FBS::Request::Method::CONSUMER_REQUEST_KEY_FRAME, "consumer.requestKeyFrame" }, + { FBS::Request::Method::CONSUMER_ENABLE_TRACE_EVENT, "consumer.enableTraceEvent" }, + { FBS::Request::Method::DATAPRODUCER_DUMP, "dataProducer.dump" }, + { FBS::Request::Method::DATAPRODUCER_GET_STATS, "dataProducer.getStats" }, + { FBS::Request::Method::DATAPRODUCER_PAUSE, "dataProducer.pause" }, + { FBS::Request::Method::DATAPRODUCER_RESUME, "dataProducer.resume" }, + { FBS::Request::Method::DATACONSUMER_DUMP, "dataConsumer.dump" }, + { FBS::Request::Method::DATACONSUMER_GET_STATS, "dataConsumer.getStats" }, + { FBS::Request::Method::DATACONSUMER_PAUSE, "dataConsumer.pause" }, + { FBS::Request::Method::DATACONSUMER_RESUME, "dataConsumer.resume" }, + { FBS::Request::Method::DATACONSUMER_GET_BUFFERED_AMOUNT, "dataConsumer.getBufferedAmount" }, + { FBS::Request::Method::DATACONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, "dataConsumer.setBufferedAmountLowThreshold" }, + { FBS::Request::Method::DATACONSUMER_SEND, "dataConsumer.send" }, + { FBS::Request::Method::RTPOBSERVER_PAUSE, "rtpObserver.pause" }, + { FBS::Request::Method::RTPOBSERVER_RESUME, "rtpObserver.resume" }, + { FBS::Request::Method::RTPOBSERVER_ADD_PRODUCER, "rtpObserver.addProducer" }, + { FBS::Request::Method::RTPOBSERVER_REMOVE_PRODUCER, "rtpObserver.removeProducer" }, }; // clang-format on diff --git a/worker/src/RTC/Consumer.cpp b/worker/src/RTC/Consumer.cpp index 97d56b0cc1..023b30310b 100644 --- a/worker/src/RTC/Consumer.cpp +++ b/worker/src/RTC/Consumer.cpp @@ -29,19 +29,27 @@ namespace RTC this->rtpParameters = RTC::RtpParameters(data->rtpParameters()); if (this->rtpParameters.encodings.empty()) + { MS_THROW_TYPE_ERROR("empty rtpParameters.encodings"); + } // All encodings must have SSRCs. for (auto& encoding : this->rtpParameters.encodings) { if (encoding.ssrc == 0) + { MS_THROW_TYPE_ERROR("invalid encoding in rtpParameters (missing ssrc)"); + } else if (encoding.hasRtx && encoding.rtx.ssrc == 0) + { MS_THROW_TYPE_ERROR("invalid encoding in rtpParameters (missing rtx.ssrc)"); + } } if (data->consumableRtpEncodings()->size() == 0) + { MS_THROW_TYPE_ERROR("empty consumableRtpEncodings"); + } this->consumableRtpEncodings.reserve(data->consumableRtpEncodings()->size()); @@ -56,7 +64,9 @@ namespace RTC auto& encoding = this->consumableRtpEncodings[i]; if (encoding.ssrc == 0u) + { MS_THROW_TYPE_ERROR("wrong encoding in consumableRtpEncodings (missing ssrc)"); + } } // Fill RTP header extension ids and their mapped values. @@ -64,7 +74,9 @@ namespace RTC for (auto& exten : this->rtpParameters.headerExtensions) { if (exten.id == 0u) + { MS_THROW_TYPE_ERROR("RTP extension id cannot be 0"); + } if (this->rtpHeaderExtensionIds.ssrcAudioLevel == 0u && exten.type == RTC::RtpHeaderExtensionUri::Type::SSRC_AUDIO_LEVEL) { @@ -109,7 +121,9 @@ namespace RTC for (auto& codec : this->rtpParameters.codecs) { if (codec.mimeType.IsMediaCodec()) + { this->supportedCodecPayloadTypes[codec.payloadType] = true; + } } // Fill media SSRCs vector. @@ -122,14 +136,20 @@ namespace RTC for (auto& encoding : this->rtpParameters.encodings) { if (encoding.hasRtx) + { this->rtxSsrcs.push_back(encoding.rtx.ssrc); + } } // Set the RTCP report generation interval. if (this->kind == RTC::Media::Kind::AUDIO) + { this->maxRtcpInterval = RTC::RTCP::MaxAudioIntervalMs; + } else + { this->maxRtcpInterval = RTC::RTCP::MaxVideoIntervalMs; + } } Consumer::~Consumer() @@ -160,22 +180,34 @@ namespace RTC for (auto i = 0; i < 128; ++i) { if (this->supportedCodecPayloadTypes[i]) + { supportedCodecPayloadTypes.push_back(i); + } } // Add traceEventTypes. std::vector> traceEventTypes; if (this->traceEventTypes.rtp) + { traceEventTypes.emplace_back(builder.CreateString("rtp")); + } if (this->traceEventTypes.keyframe) + { traceEventTypes.emplace_back(builder.CreateString("keyframe")); + } if (this->traceEventTypes.nack) + { traceEventTypes.emplace_back(builder.CreateString("nack")); + } if (this->traceEventTypes.pli) + { traceEventTypes.emplace_back(builder.CreateString("pli")); + } if (this->traceEventTypes.fir) + { traceEventTypes.emplace_back(builder.CreateString("fir")); + } return FBS::Consumer::CreateBaseConsumerDumpDirect( builder, @@ -213,7 +245,7 @@ namespace RTC { request->Accept(); - return; + break; } const bool wasActive = IsActive(); @@ -223,7 +255,9 @@ namespace RTC MS_DEBUG_DEV("Consumer paused [consumerId:%s]", this->id.c_str()); if (wasActive) + { UserOnPaused(); + } request->Accept(); @@ -236,7 +270,7 @@ namespace RTC { request->Accept(); - return; + break; } this->paused = false; @@ -244,7 +278,9 @@ namespace RTC MS_DEBUG_DEV("Consumer resumed [consumerId:%s]", this->id.c_str()); if (IsActive()) + { UserOnResumed(); + } request->Accept(); @@ -256,7 +292,9 @@ namespace RTC const auto* body = request->data->body_as(); if (body->priority() < 1u) + { MS_THROW_TYPE_ERROR("wrong priority (must be higher than 0)"); + } this->priority = body->priority(); @@ -280,15 +318,25 @@ namespace RTC const auto typeStr = type->str(); if (typeStr == "rtp") + { newTraceEventTypes.rtp = true; + } else if (typeStr == "keyframe") + { newTraceEventTypes.keyframe = true; + } else if (typeStr == "nack") + { newTraceEventTypes.nack = true; + } else if (typeStr == "pli") + { newTraceEventTypes.pli = true; + } else if (typeStr == "fir") + { newTraceEventTypes.fir = true; + } } this->traceEventTypes = newTraceEventTypes; @@ -310,7 +358,9 @@ namespace RTC MS_TRACE(); if (this->transportConnected) + { return; + } this->transportConnected = true; @@ -324,7 +374,9 @@ namespace RTC MS_TRACE(); if (!this->transportConnected) + { return; + } this->transportConnected = false; @@ -338,7 +390,9 @@ namespace RTC MS_TRACE(); if (this->producerPaused) + { return; + } const bool wasActive = IsActive(); @@ -347,7 +401,9 @@ namespace RTC MS_DEBUG_DEV("Producer paused [consumerId:%s]", this->id.c_str()); if (wasActive) + { UserOnPaused(); + } this->shared->channelNotifier->Emit(this->id, FBS::Notification::Event::CONSUMER_PRODUCER_PAUSE); } @@ -357,14 +413,18 @@ namespace RTC MS_TRACE(); if (!this->producerPaused) + { return; + } this->producerPaused = false; MS_DEBUG_DEV("Producer resumed [consumerId:%s]", this->id.c_str()); if (IsActive()) + { UserOnResumed(); + } this->shared->channelNotifier->Emit(this->id, FBS::Notification::Event::CONSUMER_PRODUCER_RESUME); } @@ -433,7 +493,9 @@ namespace RTC MS_TRACE(); if (!this->traceEventTypes.pli) + { return; + } auto traceInfo = FBS::Consumer::CreatePliTraceInfo(this->shared->channelNotifier->GetBufferBuilder(), ssrc); @@ -454,7 +516,9 @@ namespace RTC MS_TRACE(); if (!this->traceEventTypes.fir) + { return; + } auto traceInfo = FBS::Consumer::CreateFirTraceInfo(this->shared->channelNotifier->GetBufferBuilder(), ssrc); @@ -475,7 +539,9 @@ namespace RTC MS_TRACE(); if (!this->traceEventTypes.nack) + { return; + } auto notification = FBS::Consumer::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), diff --git a/worker/src/RTC/DataConsumer.cpp b/worker/src/RTC/DataConsumer.cpp index c3a0bdf9b1..71d1804a13 100644 --- a/worker/src/RTC/DataConsumer.cpp +++ b/worker/src/RTC/DataConsumer.cpp @@ -29,11 +29,17 @@ namespace RTC this->typeString = data->type()->str(); if (this->typeString == "sctp") + { this->type = DataConsumer::Type::SCTP; + } else if (this->typeString == "direct") + { this->type = DataConsumer::Type::DIRECT; + } else + { MS_THROW_TYPE_ERROR("invalid type"); + } if (this->type == DataConsumer::Type::SCTP) { @@ -48,10 +54,17 @@ namespace RTC } if (flatbuffers::IsFieldPresent(data, FBS::Transport::ConsumeDataRequest::VT_LABEL)) + { this->label = data->label()->str(); + } if (flatbuffers::IsFieldPresent(data, FBS::Transport::ConsumeDataRequest::VT_PROTOCOL)) + { this->protocol = data->protocol()->str(); + } + + // paused is set to false by default. + this->paused = data->paused(); // NOTE: This may throw. this->shared->channelMessageRegistrator->RegisterHandler( @@ -87,7 +100,9 @@ namespace RTC this->typeString.c_str(), sctpStreamParametersOffset, this->label.c_str(), - this->protocol.c_str()); + this->protocol.c_str(), + this->paused, + this->dataProducerPaused); } flatbuffers::Offset DataConsumer::FillBufferStats( @@ -117,7 +132,7 @@ namespace RTC switch (request->method) { - case Channel::ChannelRequest::Method::DATA_CONSUMER_DUMP: + case Channel::ChannelRequest::Method::DATACONSUMER_DUMP: { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); @@ -126,7 +141,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::DATA_CONSUMER_GET_STATS: + case Channel::ChannelRequest::Method::DATACONSUMER_GET_STATS: { auto responseOffset = FillBufferStats(request->GetBufferBuilder()); @@ -135,7 +150,43 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::DATA_CONSUMER_GET_BUFFERED_AMOUNT: + case Channel::ChannelRequest::Method::DATACONSUMER_PAUSE: + { + if (this->paused) + { + request->Accept(); + + break; + } + + this->paused = true; + + MS_DEBUG_DEV("DataConsumer paused [dataConsumerId:%s]", this->id.c_str()); + + request->Accept(); + + break; + } + + case Channel::ChannelRequest::Method::DATACONSUMER_RESUME: + { + if (!this->paused) + { + request->Accept(); + + break; + } + + this->paused = false; + + MS_DEBUG_DEV("DataConsumer resumed [dataConsumerId:%s]", this->id.c_str()); + + request->Accept(); + + break; + } + + case Channel::ChannelRequest::Method::DATACONSUMER_GET_BUFFERED_AMOUNT: { if (this->GetType() != RTC::DataConsumer::Type::SCTP) { @@ -157,7 +208,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD: + case Channel::ChannelRequest::Method::DATACONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD: { if (this->GetType() != DataConsumer::Type::SCTP) { @@ -190,7 +241,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::DATA_CONSUMER_SEND: + case Channel::ChannelRequest::Method::DATACONSUMER_SEND: { if (this->GetType() != RTC::DataConsumer::Type::SCTP) { @@ -231,9 +282,13 @@ namespace RTC [&request](bool queued, bool sctpSendBufferFull) { if (queued) + { request->Accept(); + } else + { request->Error(sctpSendBufferFull ? "sctpsendbufferfull" : "message send failed"); + } }); SendMessage(ppid, data, len, cb); @@ -266,6 +321,40 @@ namespace RTC MS_DEBUG_DEV("Transport disconnected [dataConsumerId:%s]", this->id.c_str()); } + void DataConsumer::DataProducerPaused() + { + MS_TRACE(); + + if (this->dataProducerPaused) + { + return; + } + + this->dataProducerPaused = true; + + MS_DEBUG_DEV("DataProducer paused [dataConsumerId:%s]", this->id.c_str()); + + this->shared->channelNotifier->Emit( + this->id, FBS::Notification::Event::DATACONSUMER_DATAPRODUCER_PAUSE); + } + + void DataConsumer::DataProducerResumed() + { + MS_TRACE(); + + if (!this->dataProducerPaused) + { + return; + } + + this->dataProducerPaused = false; + + MS_DEBUG_DEV("DataProducer resumed [dataConsumerId:%s]", this->id.c_str()); + + this->shared->channelNotifier->Emit( + this->id, FBS::Notification::Event::DATACONSUMER_DATAPRODUCER_RESUME); + } + void DataConsumer::SctpAssociationConnected() { MS_TRACE(); @@ -342,7 +431,9 @@ namespace RTC MS_TRACE(); if (!IsActive()) + { return; + } if (len > this->maxMessageSize) { diff --git a/worker/src/RTC/DataProducer.cpp b/worker/src/RTC/DataProducer.cpp index 3fffe1cc6e..7cae8497c9 100644 --- a/worker/src/RTC/DataProducer.cpp +++ b/worker/src/RTC/DataProducer.cpp @@ -25,11 +25,17 @@ namespace RTC this->typeString = data->type()->str(); if (this->typeString == "sctp") + { this->type = DataProducer::Type::SCTP; + } else if (this->typeString == "direct") + { this->type = DataProducer::Type::DIRECT; + } else + { MS_THROW_TYPE_ERROR("invalid type"); + } if (this->type == DataProducer::Type::SCTP) { @@ -44,10 +50,16 @@ namespace RTC } if (flatbuffers::IsFieldPresent(data, FBS::Transport::ProduceDataRequest::VT_LABEL)) + { this->label = data->label()->str(); + } if (flatbuffers::IsFieldPresent(data, FBS::Transport::ProduceDataRequest::VT_PROTOCOL)) + { this->protocol = data->protocol()->str(); + } + + this->paused = data->paused(); // NOTE: This may throw. this->shared->channelMessageRegistrator->RegisterHandler( @@ -82,7 +94,8 @@ namespace RTC this->typeString.c_str(), sctpStreamParametersOffset, this->label.c_str(), - this->protocol.c_str()); + this->protocol.c_str(), + this->paused); } flatbuffers::Offset DataProducer::FillBufferStats( @@ -110,7 +123,7 @@ namespace RTC switch (request->method) { - case Channel::ChannelRequest::Method::DATA_PRODUCER_DUMP: + case Channel::ChannelRequest::Method::DATAPRODUCER_DUMP: { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); @@ -119,7 +132,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::DATA_PRODUCER_GET_STATS: + case Channel::ChannelRequest::Method::DATAPRODUCER_GET_STATS: { auto responseOffset = FillBufferStats(request->GetBufferBuilder()); @@ -128,6 +141,46 @@ namespace RTC break; } + case Channel::ChannelRequest::Method::DATAPRODUCER_PAUSE: + { + if (this->paused) + { + request->Accept(); + + break; + } + + this->paused = true; + + MS_DEBUG_DEV("DataProducer paused [dataProducerId:%s]", this->id.c_str()); + + this->listener->OnDataProducerPaused(this); + + request->Accept(); + + break; + } + + case Channel::ChannelRequest::Method::DATAPRODUCER_RESUME: + { + if (!this->paused) + { + request->Accept(); + + break; + } + + this->paused = false; + + MS_DEBUG_DEV("DataProducer resumed [dataProducerId:%s]", this->id.c_str()); + + this->listener->OnDataProducerResumed(this); + + request->Accept(); + + break; + } + default: { MS_THROW_ERROR("unknown method '%s'", request->methodCStr); @@ -141,7 +194,7 @@ namespace RTC switch (notification->event) { - case Channel::ChannelNotification::Event::DATA_PRODUCER_SEND: + case Channel::ChannelNotification::Event::DATAPRODUCER_SEND: { const auto* body = notification->data->body_as(); const uint8_t* data{ nullptr }; @@ -188,6 +241,12 @@ namespace RTC this->messagesReceived++; this->bytesReceived += len; + // If paused stop here. + if (this->paused) + { + return; + } + this->listener->OnDataProducerMessageReceived(this, ppid, msg, len); } } // namespace RTC diff --git a/worker/src/RTC/PipeTransport.cpp b/worker/src/RTC/PipeTransport.cpp index 9b4a32672e..1c85ab7919 100644 --- a/worker/src/RTC/PipeTransport.cpp +++ b/worker/src/RTC/PipeTransport.cpp @@ -252,7 +252,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::PIPE_TRANSPORT_CONNECT: + case Channel::ChannelRequest::Method::PIPETRANSPORT_CONNECT: { // Ensure this method is not called twice. if (this->tuple) diff --git a/worker/src/RTC/PlainTransport.cpp b/worker/src/RTC/PlainTransport.cpp index 4d7f505585..32e0dc90b6 100644 --- a/worker/src/RTC/PlainTransport.cpp +++ b/worker/src/RTC/PlainTransport.cpp @@ -425,7 +425,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::PLAIN_TRANSPORT_CONNECT: + case Channel::ChannelRequest::Method::PLAINTRANSPORT_CONNECT: { // Ensure this method is not called twice. if (this->connectCalled) diff --git a/worker/src/RTC/Producer.cpp b/worker/src/RTC/Producer.cpp index b0113e87ec..9591576f69 100644 --- a/worker/src/RTC/Producer.cpp +++ b/worker/src/RTC/Producer.cpp @@ -200,9 +200,13 @@ namespace RTC // Set the RTCP report generation interval. if (this->kind == RTC::Media::Kind::AUDIO) + { this->maxRtcpInterval = RTC::RTCP::MaxAudioIntervalMs; + } else + { this->maxRtcpInterval = RTC::RTCP::MaxVideoIntervalMs; + } // Create a KeyFrameRequestManager. if (this->kind == RTC::Media::Kind::VIDEO) @@ -284,7 +288,9 @@ namespace RTC for (const auto* rtpStream : this->rtpStreamByEncodingIdx) { if (!rtpStream) + { continue; + } rtpStreams.emplace_back(rtpStream->FillBuffer(builder)); } @@ -293,15 +299,25 @@ namespace RTC std::vector> traceEventTypes; if (this->traceEventTypes.rtp) + { traceEventTypes.emplace_back(builder.CreateString("rtp")); + } if (this->traceEventTypes.keyframe) + { traceEventTypes.emplace_back(builder.CreateString("keyframe")); + } if (this->traceEventTypes.nack) + { traceEventTypes.emplace_back(builder.CreateString("nack")); + } if (this->traceEventTypes.pli) + { traceEventTypes.emplace_back(builder.CreateString("pli")); + } if (this->traceEventTypes.fir) + { traceEventTypes.emplace_back(builder.CreateString("fir")); + } return FBS::Producer::CreateDumpResponseDirect( builder, @@ -326,7 +342,9 @@ namespace RTC for (auto* rtpStream : this->rtpStreamByEncodingIdx) { if (!rtpStream) + { continue; + } rtpStreams.emplace_back(rtpStream->FillBufferStats(builder)); } @@ -364,7 +382,7 @@ namespace RTC { request->Accept(); - return; + break; } // Pause all streams. @@ -392,7 +410,7 @@ namespace RTC { request->Accept(); - return; + break; } // Resume all streams. @@ -439,15 +457,25 @@ namespace RTC const auto typeStr = type->str(); if (typeStr == "rtp") + { newTraceEventTypes.rtp = true; + } else if (typeStr == "keyframe") + { newTraceEventTypes.keyframe = true; + } else if (typeStr == "nack") + { newTraceEventTypes.nack = true; + } else if (typeStr == "pli") + { newTraceEventTypes.pli = true; + } else if (typeStr == "fir") + { newTraceEventTypes.fir = true; + } } this->traceEventTypes = newTraceEventTypes; @@ -485,9 +513,12 @@ namespace RTC break; } - // If this is the first time to receive a RTP packet then allocate the receiving buffer now. + // If this is the first time to receive a RTP packet then allocate the + // receiving buffer now. if (!Producer::buffer) + { Producer::buffer = new uint8_t[RTC::MtuSize + 100]; + } // Copy the received packet into this buffer so it can be expanded later. std::memcpy(Producer::buffer, body->data()->data(), static_cast(len)); @@ -553,7 +584,9 @@ namespace RTC { // May have to announce a new RTP stream to the listener. if (this->mapSsrcRtpStream.size() > numRtpStreamsBefore) + { NotifyNewRtpStream(rtpStream); + } packet->logger.Dropped(RtcLogger::RtpPacket::DropReason::RECV_RTP_STREAM_DISCARDED); @@ -590,7 +623,9 @@ namespace RTC // Tell the keyFrameRequestManager. if (this->keyFrameRequestManager) + { this->keyFrameRequestManager->KeyFrameReceived(packet->GetSsrc()); + } } // May have to announce a new RTP stream to the listener. @@ -599,7 +634,9 @@ namespace RTC // Request a key frame for this stream since we may have lost the first packets // (do not do it if this is a key frame). if (this->keyFrameRequestManager && !this->paused && !packet->IsKeyFrame()) + { this->keyFrameRequestManager->ForceKeyFrameNeeded(packet->GetSsrc()); + } // Update current packet. this->currentRtpPacket = packet; @@ -612,14 +649,18 @@ namespace RTC // If paused stop here. if (this->paused) + { return result; + } // May emit 'trace' event. EmitTraceEventRtpAndKeyFrameTypes(packet, isRtx); // Mangle the packet before providing the listener with it. if (!MangleRtpPacket(packet, rtpStream)) + { return ReceiveRtpPacketResult::DISCARDED; + } // Post-process the packet. PostProcessRtpPacket(packet); @@ -685,7 +726,9 @@ namespace RTC MS_TRACE(); if (static_cast((nowMs - this->lastRtcpSentTime) * 1.15) < this->maxRtcpInterval) + { return true; + } std::vector receiverReports; RTCP::ReceiverReferenceTime* receiverReferenceTimeReport{ nullptr }; @@ -700,7 +743,9 @@ namespace RTC auto* rtxReport = rtpStream->GetRtxRtcpReceiverReport(); if (rtxReport) + { receiverReports.push_back(rtxReport); + } } // Add a receiver reference time report if no present in the packet. @@ -715,7 +760,9 @@ namespace RTC // RTCP Compound packet buffer cannot hold the data. if (!packet->Add(receiverReports, receiverReferenceTimeReport)) + { return false; + } this->lastRtcpSentTime = nowMs; @@ -727,7 +774,9 @@ namespace RTC MS_TRACE(); if (!this->keyFrameRequestManager || this->paused) + { return; + } auto it = this->mapMappedSsrcSsrc.find(mappedSsrc); @@ -851,7 +900,9 @@ namespace RTC auto& encoding = this->rtpParameters.encodings[i]; if (encoding.rid != rid) + { continue; + } const auto* mediaCodec = this->rtpParameters.GetCodecForEncoding(encoding); const auto* rtxCodec = this->rtpParameters.GetRtxCodecForEncoding(encoding); @@ -1086,7 +1137,9 @@ namespace RTC // If the Producer is paused tell it to the new RtpStreamRecv. if (this->paused) + { rtpStream->Pause(); + } // Emit the first score event right now. EmitScore(); @@ -1151,7 +1204,9 @@ namespace RTC // This happens just once. if (extensions.capacity() != 24) + { extensions.reserve(24); + } extensions.clear(); @@ -1374,7 +1429,9 @@ namespace RTC for (const auto* rtpStream : this->rtpStreamByEncodingIdx) { if (!rtpStream) + { continue; + } scores.emplace_back(FBS::Producer::CreateScoreDirect( this->shared->channelNotifier->GetBufferBuilder(), @@ -1434,7 +1491,9 @@ namespace RTC MS_TRACE(); if (!this->traceEventTypes.pli) + { return; + } auto traceInfo = FBS::Producer::CreatePliTraceInfo(this->shared->channelNotifier->GetBufferBuilder(), ssrc); @@ -1455,7 +1514,9 @@ namespace RTC MS_TRACE(); if (!this->traceEventTypes.fir) + { return; + } auto traceInfo = FBS::Producer::CreateFirTraceInfo(this->shared->channelNotifier->GetBufferBuilder(), ssrc); @@ -1476,7 +1537,9 @@ namespace RTC MS_TRACE(); if (!this->traceEventTypes.nack) + { return; + } auto notification = FBS::Producer::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), diff --git a/worker/src/RTC/Router.cpp b/worker/src/RTC/Router.cpp index 487449dc55..fd4285c3e8 100644 --- a/worker/src/RTC/Router.cpp +++ b/worker/src/RTC/Router.cpp @@ -205,7 +205,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::ROUTER_CREATE_WEBRTC_TRANSPORT: + case Channel::ChannelRequest::Method::ROUTER_CREATE_WEBRTCTRANSPORT: { const auto* body = request->data->body_as(); @@ -230,7 +230,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER: + case Channel::ChannelRequest::Method::ROUTER_CREATE_WEBRTCTRANSPORT_WITH_SERVER: { const auto* body = request->data->body_as(); auto transportId = body->transportId()->str(); @@ -267,7 +267,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::ROUTER_CREATE_PLAIN_TRANSPORT: + case Channel::ChannelRequest::Method::ROUTER_CREATE_PLAINTRANSPORT: { const auto* body = request->data->body_as(); auto transportId = body->transportId()->str(); @@ -290,7 +290,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::ROUTER_CREATE_PIPE_TRANSPORT: + case Channel::ChannelRequest::Method::ROUTER_CREATE_PIPETRANSPORT: { const auto* body = request->data->body_as(); auto transportId = body->transportId()->str(); @@ -313,7 +313,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::ROUTER_CREATE_DIRECT_TRANSPORT: + case Channel::ChannelRequest::Method::ROUTER_CREATE_DIRECTTRANSPORT: { const auto* body = request->data->body_as(); auto transportId = body->transportId()->str(); @@ -336,7 +336,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER: + case Channel::ChannelRequest::Method::ROUTER_CREATE_ACTIVESPEAKEROBSERVER: { const auto* body = request->data->body_as(); auto rtpObserverId = body->activeSpeakerObserverId()->str(); @@ -357,7 +357,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::ROUTER_CREATE_AUDIO_LEVEL_OBSERVER: + case Channel::ChannelRequest::Method::ROUTER_CREATE_AUDIOLEVELOBSERVER: { const auto* body = request->data->body_as(); auto rtpObserverId = body->rtpObserverId()->str(); @@ -403,7 +403,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::ROUTER_CLOSE_RTP_OBSERVER: + case Channel::ChannelRequest::Method::ROUTER_CLOSE_RTPOBSERVER: { const auto* body = request->data->body_as(); auto rtpObserverId = body->rtpObserverId()->str(); @@ -709,7 +709,9 @@ namespace RTC // Update the Consumer status based on the Producer status. if (producer->IsPaused()) + { consumer->ProducerPaused(); + } // Insert the Consumer in the maps. auto& consumers = mapProducerConsumersIt->second; @@ -849,6 +851,32 @@ namespace RTC this->mapDataProducerDataConsumers.erase(mapDataProducerDataConsumersIt); } + inline void Router::OnTransportDataProducerPaused( + RTC::Transport* /*transport*/, RTC::DataProducer* dataProducer) + { + MS_TRACE(); + + auto& dataConsumers = this->mapDataProducerDataConsumers.at(dataProducer); + + for (auto* dataConsumer : dataConsumers) + { + dataConsumer->DataProducerPaused(); + } + } + + inline void Router::OnTransportDataProducerResumed( + RTC::Transport* /*transport*/, RTC::DataProducer* dataProducer) + { + MS_TRACE(); + + auto& dataConsumers = this->mapDataProducerDataConsumers.at(dataProducer); + + for (auto* dataConsumer : dataConsumers) + { + dataConsumer->DataProducerResumed(); + } + } + inline void Router::OnTransportDataProducerMessageReceived( RTC::Transport* /*transport*/, RTC::DataProducer* dataProducer, @@ -860,9 +888,9 @@ namespace RTC auto& dataConsumers = this->mapDataProducerDataConsumers.at(dataProducer); - for (auto* consumer : dataConsumers) + for (auto* dataConsumer : dataConsumers) { - consumer->SendMessage(ppid, msg, len); + dataConsumer->SendMessage(ppid, msg, len); } } @@ -874,7 +902,9 @@ namespace RTC auto mapDataProducersIt = this->mapDataProducers.find(dataProducerId); if (mapDataProducersIt == this->mapDataProducers.end()) + { MS_THROW_ERROR("DataProducer not found [dataProducerId:%s]", dataProducerId.c_str()); + } auto* dataProducer = mapDataProducersIt->second; auto mapDataProducerDataConsumersIt = this->mapDataProducerDataConsumers.find(dataProducer); @@ -886,6 +916,12 @@ namespace RTC this->mapDataConsumerDataProducer.find(dataConsumer) == this->mapDataConsumerDataProducer.end(), "DataConsumer already present in mapDataConsumerDataProducer"); + // Update the DataConsumer status based on the DataProducer status. + if (dataProducer->IsPaused()) + { + dataConsumer->DataProducerPaused(); + } + // Insert the DataConsumer in the maps. auto& dataConsumers = mapDataProducerDataConsumersIt->second; diff --git a/worker/src/RTC/RtpObserver.cpp b/worker/src/RTC/RtpObserver.cpp index b7db32ce1a..203ee99cea 100644 --- a/worker/src/RTC/RtpObserver.cpp +++ b/worker/src/RTC/RtpObserver.cpp @@ -26,7 +26,7 @@ namespace RTC switch (request->method) { - case Channel::ChannelRequest::Method::RTP_OBSERVER_PAUSE: + case Channel::ChannelRequest::Method::RTPOBSERVER_PAUSE: { this->Pause(); @@ -35,7 +35,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::RTP_OBSERVER_RESUME: + case Channel::ChannelRequest::Method::RTPOBSERVER_RESUME: { this->Resume(); @@ -44,7 +44,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::RTP_OBSERVER_ADD_PRODUCER: + case Channel::ChannelRequest::Method::RTPOBSERVER_ADD_PRODUCER: { const auto* body = request->data->body_as(); auto producerId = body->producerId()->str(); @@ -60,7 +60,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::RTP_OBSERVER_REMOVE_PRODUCER: + case Channel::ChannelRequest::Method::RTPOBSERVER_REMOVE_PRODUCER: { const auto* body = request->data->body_as(); auto producerId = body->producerId()->str(); diff --git a/worker/src/RTC/Transport.cpp b/worker/src/RTC/Transport.cpp index c6d64ca4e0..8db8bd6b21 100644 --- a/worker/src/RTC/Transport.cpp +++ b/worker/src/RTC/Transport.cpp @@ -1317,7 +1317,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::TRANSPORT_CLOSE_DATA_PRODUCER: + case Channel::ChannelRequest::Method::TRANSPORT_CLOSE_DATAPRODUCER: { const auto* body = request->data->body_as(); @@ -1352,7 +1352,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::TRANSPORT_CLOSE_DATA_CONSUMER: + case Channel::ChannelRequest::Method::TRANSPORT_CLOSE_DATACONSUMER: { const auto* body = request->data->body_as(); @@ -2656,6 +2656,20 @@ namespace RTC this->listener->OnTransportDataProducerMessageReceived(this, dataProducer, ppid, msg, len); } + inline void Transport::OnDataProducerPaused(RTC::DataProducer* dataProducer) + { + MS_TRACE(); + + this->listener->OnTransportDataProducerPaused(this, dataProducer); + } + + inline void Transport::OnDataProducerResumed(RTC::DataProducer* dataProducer) + { + MS_TRACE(); + + this->listener->OnTransportDataProducerResumed(this, dataProducer); + } + inline void Transport::OnDataConsumerSendMessage( RTC::DataConsumer* dataConsumer, uint32_t ppid, const uint8_t* msg, size_t len, onQueuedCallback* cb) { diff --git a/worker/src/RTC/WebRtcServer.cpp b/worker/src/RTC/WebRtcServer.cpp index de64910a95..e35a99bfc0 100644 --- a/worker/src/RTC/WebRtcServer.cpp +++ b/worker/src/RTC/WebRtcServer.cpp @@ -273,7 +273,7 @@ namespace RTC switch (request->method) { - case Channel::ChannelRequest::Method::WEBRTC_SERVER_DUMP: + case Channel::ChannelRequest::Method::WEBRTCSERVER_DUMP: { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); diff --git a/worker/src/RTC/WebRtcTransport.cpp b/worker/src/RTC/WebRtcTransport.cpp index a4d9cd2c00..90bf143516 100644 --- a/worker/src/RTC/WebRtcTransport.cpp +++ b/worker/src/RTC/WebRtcTransport.cpp @@ -496,7 +496,7 @@ namespace RTC break; } - case Channel::ChannelRequest::Method::WEBRTC_TRANSPORT_CONNECT: + case Channel::ChannelRequest::Method::WEBRTCTRANSPORT_CONNECT: { // Ensure this method is not called twice. if (this->connectCalled) diff --git a/worker/src/Worker.cpp b/worker/src/Worker.cpp index b372f60061..692988225f 100644 --- a/worker/src/Worker.cpp +++ b/worker/src/Worker.cpp @@ -268,7 +268,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) break; } - case Channel::ChannelRequest::Method::WORKER_CREATE_WEBRTC_SERVER: + case Channel::ChannelRequest::Method::WORKER_CREATE_WEBRTCSERVER: { try { @@ -298,7 +298,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) break; } - case Channel::ChannelRequest::Method::WORKER_WEBRTC_SERVER_CLOSE: + case Channel::ChannelRequest::Method::WORKER_WEBRTCSERVER_CLOSE: { RTC::WebRtcServer* webRtcServer{ nullptr }; From 14f736d4b2d8b688db60bc6f5828c73466b9da2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 13 Jul 2023 11:32:54 +0200 Subject: [PATCH 08/73] rust: remove unneeded file --- rust/src/fbs.dot | 5810 ---------------------------------------------- 1 file changed, 5810 deletions(-) delete mode 100644 rust/src/fbs.dot diff --git a/rust/src/fbs.dot b/rust/src/fbs.dot deleted file mode 100644 index 9da1aca27c..0000000000 --- a/rust/src/fbs.dot +++ /dev/null @@ -1,5810 +0,0 @@ -digraph G -{ - node[ shape = none ]; - rankdir=LR; - - decl0[ label=< - - - - - - - - - -
table FBS.ActiveSpeakerObserver.ActiveSpeakerObserverOptions
0intervaluint16 (2 bytes)default 0
> - ]; - - decl1[ label=< - - - - - - - - - -
table FBS.ActiveSpeakerObserver.DominantSpeakerNotification
0producer_idstring (4 bytes)required
> - ]; - - decl2[ label=< - - - - - - - - - - - - - - - - - - - - - -
table FBS.AudioLevelObserver.AudioLevelObserverOptions
0max_entriesuint16 (2 bytes)default 0
1thresholdint8 (1 bytes)default 0
2intervaluint16 (2 bytes)default 0
> - ]; - - decl3[ label=< - - - - - - - - - - - - - - - -
table FBS.AudioLevelObserver.Volume
0producer_idstring (4 bytes)required
1volumeint8 (1 bytes)default 0
> - ]; - - decl4[ label=< - - - - - - - - - -
table FBS.AudioLevelObserver.VolumesNotification
0volumes[FBS.AudioLevelObserver.Volume] (4 bytes)required
> - ]; - decl4:p0:e -> decl3:name [color = "#1143c1"]; - - decl5[ label=< - - - - - - - - - - - - - - - -
table FBS.Common.StringString
0keystring (4 bytes)required
1valuestring (4 bytes)required
> - ]; - - decl6[ label=< - - - - - - - - - - - - - - - -
table FBS.Common.StringUint8
0keystring (4 bytes)required
1valueuint8 (1 bytes)default 0
> - ]; - - decl7[ label=< - - - - - - - - - - - - - - - -
table FBS.Common.Uint16String
0keyuint16 (2 bytes)default 0
1valuestring (4 bytes)required
> - ]; - - decl8[ label=< - - - - - - - - - - - - - - - -
table FBS.Common.Uint32String
0keyuint32 (4 bytes)default 0
1valuestring (4 bytes)required
> - ]; - - decl9[ label=< - - - - - - - - - - - - - - - -
table FBS.Common.StringStringArray
0keystring (4 bytes)required
1values[string] (4 bytes)optional
> - ]; - - decl10[ label=< - - - - - - - - - - - - - - - -
table FBS.Consumer.ConsumerLayers
0spatial_layerint16 (2 bytes)default 0
1temporal_layerint16 (2 bytes)optional
> - ]; - - decl11[ label=< - - - - - - - - - - - - - - - - - - - - - -
table FBS.Consumer.ConsumerScore
0scoreuint8 (1 bytes)default 0
1producer_scoreuint8 (1 bytes)default 0
2producer_scores[uint8] (4 bytes)optional
> - ]; - - decl12[ label=< - - - - - - - - - -
table FBS.Consumer.SetPreferredLayersRequest
0preferred_layersFBS.Consumer.ConsumerLayers (4 bytes)required
> - ]; - decl12:p0:e -> decl10:name [color = "#b217ef"]; - - decl13[ label=< - - - - - - - - - -
table FBS.Consumer.SetPreferredLayersResponse
0preferred_layersFBS.Consumer.ConsumerLayers (4 bytes)optional
> - ]; - decl13:p0:e -> decl10:name [color = "#d36934"]; - - decl14[ label=< - - - - - - - - - -
table FBS.Consumer.SetPriorityRequest
0priorityuint8 (1 bytes)default 0
> - ]; - - decl15[ label=< - - - - - - - - - -
table FBS.Consumer.SetPriorityResponse
0priorityuint8 (1 bytes)default 0
> - ]; - - decl16[ label=< - - - - - - - - - -
table FBS.Consumer.EnableTraceEventRequest
0events[string] (4 bytes)required
> - ]; - - decl17[ label=< - - - - - - - - - - - - - - - - - - - - -
union FBS.Consumer.DumpData
SimpleConsumerDumpFBS.Consumer.SimpleConsumerDump
SimulcastConsumerDumpFBS.Consumer.SimulcastConsumerDump
SvcConsumerDumpFBS.Consumer.SvcConsumerDump
PipeConsumerDumpFBS.Consumer.PipeConsumerDump
> - ]; - decl17:p0:e -> decl20:name [color = "#34bc62"]; - decl17:p1:e -> decl21:name [color = "#3a1ca8"]; - decl17:p2:e -> decl22:name [color = "#037768"]; - decl17:p3:e -> decl23:name [color = "#d8735f"]; - - decl18[ label=< - - - - - - - - - - - - - - - -
table FBS.Consumer.DumpResponse
0 / 1dataFBS.Consumer.DumpData (4 bytes)optional
2typeFBS.RtpParameters.Type (1 bytes)default NONE
> - ]; - decl18:p0:e -> decl17:name [color = "#a0fc55"]; - decl18:p1:e -> decl37:name [color = "#d8735f"]; - - decl19[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Consumer.BaseConsumerDump
0idstring (4 bytes)required
1producer_idstring (4 bytes)required
2kindFBS.RtpParameters.MediaKind (1 bytes)default ALL
3rtp_parametersFBS.RtpParameters.RtpParameters (4 bytes)required
4consumable_rtp_encodings[FBS.RtpParameters.RtpEncodingParameters] (4 bytes)optional
5supported_codec_payload_types[uint8] (4 bytes)optional
6trace_event_types[string] (4 bytes)required
7pausedbool (1 bytes)default false
8producer_pausedbool (1 bytes)default false
9priorityuint8 (1 bytes)default 0
> - ]; - decl19:p2:e -> decl36:name [color = "#7c25aa"]; - decl19:p3:e -> decl51:name [color = "#1533db"]; - decl19:p4:e -> decl49:name [color = "#b717ed"]; - - decl20[ label=< - - - - - - - - - - - - - - - -
table FBS.Consumer.SimpleConsumerDump
0baseFBS.Consumer.BaseConsumerDump (4 bytes)required
1rtp_streamFBS.RtpStream.Dump (4 bytes)required
> - ]; - decl20:p0:e -> decl19:name [color = "#ef9e64"]; - decl20:p1:e -> decl56:name [color = "#3ed141"]; - - decl21[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Consumer.SimulcastConsumerDump
0baseFBS.Consumer.BaseConsumerDump (4 bytes)required
1rtp_streamFBS.RtpStream.Dump (4 bytes)required
2preferred_spatial_layerint16 (2 bytes)default 0
3target_spatial_layerint16 (2 bytes)default 0
4current_spatial_layerint16 (2 bytes)default 0
5preferred_temporal_layerint16 (2 bytes)default 0
6target_temporal_layerint16 (2 bytes)default 0
7current_temporal_layerint16 (2 bytes)default 0
> - ]; - decl21:p0:e -> decl19:name [color = "#421dd3"]; - decl21:p1:e -> decl56:name [color = "#a2d84b"]; - - decl22[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Consumer.SvcConsumerDump
0baseFBS.Consumer.BaseConsumerDump (4 bytes)required
1rtp_streamFBS.RtpStream.Dump (4 bytes)required
2preferred_spatial_layerint16 (2 bytes)default 0
3target_spatial_layerint16 (2 bytes)default 0
4current_spatial_layerint16 (2 bytes)default 0
5preferred_temporal_layerint16 (2 bytes)default 0
6target_temporal_layerint16 (2 bytes)default 0
7current_temporal_layerint16 (2 bytes)default 0
> - ]; - decl22:p0:e -> decl19:name [color = "#069901"]; - decl22:p1:e -> decl56:name [color = "#45149b"]; - - decl23[ label=< - - - - - - - - - - - - - - - -
table FBS.Consumer.PipeConsumerDump
0baseFBS.Consumer.BaseConsumerDump (4 bytes)required
1rtp_streams[FBS.RtpStream.Dump] (4 bytes)required
> - ]; - decl23:p0:e -> decl19:name [color = "#f70ca1"]; - decl23:p1:e -> decl56:name [color = "#f940bc"]; - - decl24[ label=< - - - - - - - - - -
table FBS.Consumer.GetStatsResponse
0stats[FBS.RtpStream.Stats] (4 bytes)optional
> - ]; - decl24:p0:e -> decl59:name [color = "#32d3bb"]; - - decl25[ label=< - - - - - - - - - -
table FBS.Consumer.LayersChangeNotification
0layersFBS.Consumer.ConsumerLayers (4 bytes)optional
> - ]; - decl25:p0:e -> decl10:name [color = "#f411ce"]; - - decl26[ label=< - - - - - - - - - -
table FBS.Consumer.RtpNotification
0data[uint8] (4 bytes)required
> - ]; - - decl27[ label=< - - - - - - - - - -
table FBS.Consumer.ScoreNotification
0scoreFBS.Consumer.ConsumerScore (4 bytes)required
> - ]; - decl27:p0:e -> decl11:name [color = "#d34428"]; - - decl28[ label=< - - - - - - - - - - - - - - - - - - - - - - - - -
enum FBS.Consumer.TraceType : uint8
KEYFRAME0
FIR1
NACK2
PLI3
RTP4
> - ]; - - decl29[ label=< - - - - - - - - - - - - -
enum FBS.Consumer.TraceDirection : uint8
DIRECTION_IN0
DIRECTION_OUT1
> - ]; - - decl30[ label=< - - - - - - - - - - - - - - - - - - - - -
union FBS.Consumer.TraceInfo
KeyFrameTraceInfoFBS.Consumer.KeyFrameTraceInfo
FirTraceInfoFBS.Consumer.FirTraceInfo
PliTraceInfoFBS.Consumer.PliTraceInfo
RtpTraceInfoFBS.Consumer.RtpTraceInfo
> - ]; - decl30:p0:e -> decl31:name [color = "#4bd8bc"]; - decl30:p1:e -> decl32:name [color = "#b9db23"]; - decl30:p2:e -> decl33:name [color = "#d6af22"]; - decl30:p3:e -> decl34:name [color = "#3cd157"]; - - decl31[ label=< - - - - - - - - - -
table FBS.Consumer.KeyFrameTraceInfo
0is_rtxbool (1 bytes)default false
> - ]; - - decl32[ label=< - - - - - - - - - -
table FBS.Consumer.FirTraceInfo
0ssrcuint32 (4 bytes)default 0
> - ]; - - decl33[ label=< - - - - - - - - - -
table FBS.Consumer.PliTraceInfo
0ssrcuint32 (4 bytes)default 0
> - ]; - - decl34[ label=< - - - - - - - - - -
table FBS.Consumer.RtpTraceInfo
0is_rtxbool (1 bytes)default false
> - ]; - - decl35[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Consumer.TraceNotification
0typeFBS.Consumer.TraceType (1 bytes)default KEYFRAME
1timestampuint64 (8 bytes)default 0
2directionFBS.Consumer.TraceDirection (1 bytes)default DIRECTION_IN
3 / 4infoFBS.Consumer.TraceInfo (4 bytes)optional
> - ]; - decl35:p0:e -> decl28:name [color = "#65d85d"]; - decl35:p2:e -> decl29:name [color = "#299ac6"]; - decl35:p3:e -> decl30:name [color = "#b3d84e"]; - - decl36[ label=< - - - - - - - - - - - - - - - - -
enum FBS.RtpParameters.MediaKind : uint8
ALL0
AUDIO1
VIDEO2
> - ]; - - decl37[ label=< - - - - - - - - - - - - - - - - - - - - - - - - -
enum FBS.RtpParameters.Type : uint8
NONE0
SIMPLE1
SIMULCAST2
SVC3
PIPE4
> - ]; - - decl38[ label=< - - - - - - - - - -
table FBS.RtpParameters.Boolean
0valueuint8 (1 bytes)default 0
> - ]; - - decl39[ label=< - - - - - - - - - -
table FBS.RtpParameters.Integer
0valueint32 (4 bytes)default 0
> - ]; - - decl40[ label=< - - - - - - - - - -
table FBS.RtpParameters.IntegerArray
0value[int32] (4 bytes)optional
> - ]; - - decl41[ label=< - - - - - - - - - -
table FBS.RtpParameters.Double
0valuefloat64 (8 bytes)default 0.0
> - ]; - - decl42[ label=< - - - - - - - - - -
table FBS.RtpParameters.String
0valuestring (4 bytes)optional
> - ]; - - decl43[ label=< - - - - - - - - - - - - - - - - - - - - - - - - -
union FBS.RtpParameters.Value
BooleanFBS.RtpParameters.Boolean
IntegerFBS.RtpParameters.Integer
DoubleFBS.RtpParameters.Double
StringFBS.RtpParameters.String
IntegerArrayFBS.RtpParameters.IntegerArray
> - ]; - decl43:p0:e -> decl38:name [color = "#3ed141"]; - decl43:p1:e -> decl39:name [color = "#dd4f99"]; - decl43:p2:e -> decl41:name [color = "#6a42b5"]; - decl43:p3:e -> decl42:name [color = "#d8755f"]; - decl43:p4:e -> decl40:name [color = "#5619c6"]; - - decl44[ label=< - - - - - - - - - - - - - - - -
table FBS.RtpParameters.Parameter
0namestring (4 bytes)required
1 / 2valueFBS.RtpParameters.Value (4 bytes)optional
> - ]; - decl44:p1:e -> decl43:name [color = "#2f68f9"]; - - decl45[ label=< - - - - - - - - - - - - - - - -
table FBS.RtpParameters.RtcpFeedback
0typestring (4 bytes)required
1parameterstring (4 bytes)optional
> - ]; - - decl46[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.RtpParameters.RtpCodecParameters
0mime_typestring (4 bytes)required
1payload_typeuint8 (1 bytes)default 0
2clock_rateuint32 (4 bytes)default 0
3channelsuint8 (1 bytes)optional
4parameters[FBS.RtpParameters.Parameter] (4 bytes)optional
5rtcp_feedback[FBS.RtpParameters.RtcpFeedback] (4 bytes)optional
> - ]; - decl46:p4:e -> decl44:name [color = "#29a5c4"]; - decl46:p5:e -> decl45:name [color = "#4ccc39"]; - - decl47[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.RtpParameters.RtpHeaderExtensionParameters
0uristring (4 bytes)required
1iduint8 (1 bytes)default 0
2encryptbool (1 bytes)default false
3parameters[FBS.RtpParameters.Parameter] (4 bytes)optional
> - ]; - decl47:p3:e -> decl44:name [color = "#dd52d4"]; - - decl48[ label=< - - - - - - - - - -
table FBS.RtpParameters.Rtx
0ssrcuint32 (4 bytes)default 0
> - ]; - - decl49[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.RtpParameters.RtpEncodingParameters
0ssrcuint32 (4 bytes)optional
1ridstring (4 bytes)optional
2codec_payload_typeuint8 (1 bytes)optional
3rtxFBS.RtpParameters.Rtx (4 bytes)optional
4dtxbool (1 bytes)default false
5scalability_modestring (4 bytes)optional
6max_bitrateuint32 (4 bytes)optional
> - ]; - decl49:p3:e -> decl48:name [color = "#73fc50"]; - - decl50[ label=< - - - - - - - - - - - - - - - -
table FBS.RtpParameters.RtcpParameters
0cnamestring (4 bytes)optional
1reduced_sizebool (1 bytes)default true
> - ]; - - decl51[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.RtpParameters.RtpParameters
0midstring (4 bytes)optional
1codecs[FBS.RtpParameters.RtpCodecParameters] (4 bytes)required
2header_extensions[FBS.RtpParameters.RtpHeaderExtensionParameters] (4 bytes)optional
3encodings[FBS.RtpParameters.RtpEncodingParameters] (4 bytes)optional
4rtcpFBS.RtpParameters.RtcpParameters (4 bytes)optional
> - ]; - decl51:p1:e -> decl46:name [color = "#fc2549"]; - decl51:p2:e -> decl47:name [color = "#09a51c"]; - decl51:p3:e -> decl49:name [color = "#3a08d1"]; - decl51:p4:e -> decl50:name [color = "#16ba52"]; - - decl52[ label=< - - - - - - - - - - - - - - - -
table FBS.RtpParameters.CodecMapping
0payload_typeuint8 (1 bytes)default 0
1mapped_payload_typeuint8 (1 bytes)default 0
> - ]; - - decl53[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.RtpParameters.EncodingMapping
0ridstring (4 bytes)optional
1ssrcuint32 (4 bytes)optional
2scalability_modestring (4 bytes)optional
3mapped_ssrcuint32 (4 bytes)default 0
> - ]; - - decl54[ label=< - - - - - - - - - - - - - - - -
table FBS.RtpParameters.RtpMapping
0codecs[FBS.RtpParameters.CodecMapping] (4 bytes)required
1encodings[FBS.RtpParameters.EncodingMapping] (4 bytes)required
> - ]; - decl54:p0:e -> decl52:name [color = "#fc0536"]; - decl54:p1:e -> decl53:name [color = "#f90764"]; - - decl55[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.RtpStream.Params
0encoding_idxuint32 (4 bytes)default 0
1ssrcuint32 (4 bytes)default 0
2payload_typeuint8 (1 bytes)default 0
3mime_typestring (4 bytes)required
4clock_rateuint32 (4 bytes)default 0
5ridstring (4 bytes)optional
6cnamestring (4 bytes)required
7rtx_ssrcuint32 (4 bytes)optional
8rtx_payload_typeuint8 (1 bytes)optional
9use_nackbool (1 bytes)default false
10use_plibool (1 bytes)default false
11use_firbool (1 bytes)default false
12use_in_band_fecbool (1 bytes)default false
13use_dtxbool (1 bytes)default false
14spatial_layersuint8 (1 bytes)default 0
15temporal_layersuint8 (1 bytes)default 0
> - ]; - - decl56[ label=< - - - - - - - - - - - - - - - - - - - - - -
table FBS.RtpStream.Dump
0paramsFBS.RtpStream.Params (4 bytes)required
1scoreuint8 (1 bytes)default 0
2rtx_streamFBS.RtxStream.RtxDump (4 bytes)optional
> - ]; - decl56:p0:e -> decl55:name [color = "#3dce45"]; - decl56:p2:e -> decl64:name [color = "#27d86e"]; - - decl57[ label=< - - - - - - - - - - - - - - - -
table FBS.RtpStream.BitrateByLayer
0layerstring (4 bytes)required
1bitrateuint64 (8 bytes)default 0
> - ]; - - decl58[ label=< - - - - - - - - - - - - - - - - -
union FBS.RtpStream.StatsData
BaseStatsFBS.RtpStream.BaseStats
RecvStatsFBS.RtpStream.RecvStats
SendStatsFBS.RtpStream.SendStats
> - ]; - decl58:p0:e -> decl60:name [color = "#38d178"]; - decl58:p1:e -> decl61:name [color = "#36d18b"]; - decl58:p2:e -> decl62:name [color = "#a9d84b"]; - - decl59[ label=< - - - - - - - - - -
table FBS.RtpStream.Stats
0 / 1dataFBS.RtpStream.StatsData (4 bytes)optional
> - ]; - decl59:p0:e -> decl58:name [color = "#2243c9"]; - - decl60[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.RtpStream.BaseStats
0timestampuint64 (8 bytes)default 0
1ssrcuint32 (4 bytes)default 0
2kindFBS.RtpParameters.MediaKind (1 bytes)default ALL
3mime_typestring (4 bytes)required
4packets_lostuint64 (8 bytes)default 0
5fraction_lostuint64 (8 bytes)default 0
6packets_discardeduint64 (8 bytes)default 0
7packets_retransmitteduint64 (8 bytes)default 0
8packets_repaireduint64 (8 bytes)default 0
9nack_countuint64 (8 bytes)default 0
10nack_packet_countuint64 (8 bytes)default 0
11pli_countuint64 (8 bytes)default 0
12fir_countuint64 (8 bytes)default 0
13scoreuint8 (1 bytes)default 0
14ridstring (4 bytes)optional
15rtx_ssrcuint32 (4 bytes)optional
16rtx_packets_discardeduint64 (8 bytes)default 0
17round_trip_timefloat32 (4 bytes)default 0.0
> - ]; - decl60:p2:e -> decl36:name [color = "#e61df4"]; - - decl61[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.RtpStream.RecvStats
0baseFBS.RtpStream.Stats (4 bytes)required
1jitteruint32 (4 bytes)default 0
2packet_countuint64 (8 bytes)default 0
3byte_countuint64 (8 bytes)default 0
4bitrateuint64 (8 bytes)default 0
5bitrate_by_layer[FBS.RtpStream.BitrateByLayer] (4 bytes)optional
> - ]; - decl61:p0:e -> decl59:name [color = "#d822f4"]; - decl61:p5:e -> decl57:name [color = "#32d3b8"]; - - decl62[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.RtpStream.SendStats
0baseFBS.RtpStream.Stats (4 bytes)required
1packet_countuint64 (8 bytes)default 0
2byte_countuint64 (8 bytes)default 0
3bitrateuint64 (8 bytes)default 0
> - ]; - decl62:p0:e -> decl59:name [color = "#e87f1e"]; - - decl63[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.RtxStream.Params
0ssrcuint32 (4 bytes)default 0
1payload_typeuint8 (1 bytes)default 0
2mime_typestring (4 bytes)required
3clock_rateuint32 (4 bytes)default 0
4rridstring (4 bytes)optional
5cnamestring (4 bytes)required
> - ]; - - decl64[ label=< - - - - - - - - - -
table FBS.RtxStream.RtxDump
0paramsFBS.RtxStream.Params (4 bytes)required
> - ]; - decl64:p0:e -> decl63:name [color = "#3ad167"]; - - decl65[ label=< - - - - - - - - - -
table FBS.DataConsumer.GetBufferedAmountResponse
0buffered_amountuint32 (4 bytes)default 0
> - ]; - - decl66[ label=< - - - - - - - - - -
table FBS.DataConsumer.SetBufferedAmountLowThresholdRequest
0thresholduint32 (4 bytes)default 0
> - ]; - - decl67[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.DataConsumer.DumpResponse
0idstring (4 bytes)required
1data_producer_idstring (4 bytes)required
2typestring (4 bytes)required
3sctp_stream_parametersFBS.SctpParameters.SctpStreamParameters (4 bytes)optional
4labelstring (4 bytes)required
5protocolstring (4 bytes)required
> - ]; - decl67:p3:e -> decl77:name [color = "#f450d6"]; - - decl68[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.DataConsumer.GetStatsResponse
0timestampuint64 (8 bytes)default 0
1labelstring (4 bytes)required
2protocolstring (4 bytes)required
3messages_sentuint64 (8 bytes)default 0
4bytes_sentuint64 (8 bytes)default 0
5buffered_amountuint32 (4 bytes)default 0
> - ]; - - decl69[ label=< - - - - - - - - - -
table FBS.DataConsumer.String
0valuestring (4 bytes)required
> - ]; - - decl70[ label=< - - - - - - - - - -
table FBS.DataConsumer.Binary
0value[uint8] (4 bytes)required
> - ]; - - decl71[ label=< - - - - - - - - - - - - -
union FBS.DataConsumer.Data
StringFBS.DataConsumer.String
BinaryFBS.DataConsumer.Binary
> - ]; - decl71:p0:e -> decl69:name [color = "#fc021f"]; - decl71:p1:e -> decl70:name [color = "#dbb357"]; - - decl72[ label=< - - - - - - - - - - - - - - - -
table FBS.DataConsumer.SendRequest
0ppiduint8 (1 bytes)default 0
1 / 2dataFBS.DataConsumer.Data (4 bytes)required
> - ]; - decl72:p1:e -> decl71:name [color = "#c915f2"]; - - decl73[ label=< - - - - - - - - - -
table FBS.DataConsumer.BufferedAmountLowNotification
0buffered_amountuint32 (4 bytes)default 0
> - ]; - - decl74[ label=< - - - - - - - - - - - - - - - -
table FBS.DataConsumer.MessageNotification
0ppiduint32 (4 bytes)default 0
1data[uint8] (4 bytes)required
> - ]; - - decl75[ label=< - - - - - - - - - - - - - - - -
table FBS.SctpParameters.NumSctpStreams
0osuint32 (4 bytes)default 1024
1misuint32 (4 bytes)default 1024
> - ]; - - decl76[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.SctpParameters.SctpParameters
0portuint16 (2 bytes)default 5000
1osuint16 (2 bytes)default 0
2misuint16 (2 bytes)default 0
3max_message_sizeuint32 (4 bytes)default 0
4send_buffer_sizeuint32 (4 bytes)default 0
5sctp_buffered_amountuint32 (4 bytes)default 0
6is_data_channelbool (1 bytes)default false
> - ]; - - decl77[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.SctpParameters.SctpStreamParameters
0stream_iduint16 (2 bytes)default 0
1orderedbool (1 bytes)optional
2max_packet_life_timeuint16 (2 bytes)optional
3max_retransmitsuint16 (2 bytes)optional
> - ]; - - decl78[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.DataProducer.DumpResponse
0idstring (4 bytes)required
1typestring (4 bytes)required
2sctp_stream_parametersFBS.SctpParameters.SctpStreamParameters (4 bytes)optional
3labelstring (4 bytes)required
4protocolstring (4 bytes)required
> - ]; - decl78:p2:e -> decl77:name [color = "#f7188f"]; - - decl79[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.DataProducer.GetStatsResponse
0timestampuint64 (8 bytes)default 0
1labelstring (4 bytes)required
2protocolstring (4 bytes)required
3messages_receiveduint64 (8 bytes)default 0
4bytes_receiveduint64 (8 bytes)default 0
5buffered_amountuint32 (4 bytes)default 0
> - ]; - - decl80[ label=< - - - - - - - - - -
table FBS.DataProducer.String
0valuestring (4 bytes)required
> - ]; - - decl81[ label=< - - - - - - - - - -
table FBS.DataProducer.Binary
0value[uint8] (4 bytes)required
> - ]; - - decl82[ label=< - - - - - - - - - - - - -
union FBS.DataProducer.Data
StringFBS.DataProducer.String
BinaryFBS.DataProducer.Binary
> - ]; - decl82:p0:e -> decl80:name [color = "#dda25a"]; - decl82:p1:e -> decl81:name [color = "#8d18e0"]; - - decl83[ label=< - - - - - - - - - - - - - - - -
table FBS.DataProducer.SendNotification
0ppiduint8 (1 bytes)default 0
1 / 2dataFBS.DataProducer.Data (4 bytes)required
> - ]; - decl83:p1:e -> decl82:name [color = "#bbdb2e"]; - - decl84[ label=< - - - - - - - - - -
table FBS.DirectTransport.DirectTransportOptions
0baseFBS.Transport.Options (4 bytes)required
> - ]; - decl84:p0:e -> decl102:name [color = "#fc0532"]; - - decl85[ label=< - - - - - - - - - -
table FBS.DirectTransport.DumpResponse
0baseFBS.Transport.Dump (4 bytes)required
> - ]; - decl85:p0:e -> decl101:name [color = "#4ae2ad"]; - - decl86[ label=< - - - - - - - - - -
table FBS.DirectTransport.GetStatsResponse
0baseFBS.Transport.Stats (4 bytes)required
> - ]; - decl86:p0:e -> decl103:name [color = "#dd5d9d"]; - - decl87[ label=< - - - - - - - - - -
table FBS.DirectTransport.RtcpNotification
0data[uint8] (4 bytes)required
> - ]; - - decl88[ label=< - - - - - - - - - - - - -
enum FBS.Transport.Protocol : uint8
UDP1
TCP2
> - ]; - - decl89[ label=< - - - - - - - - - - - - - - - -
table FBS.Transport.ListenIp
0ipstring (4 bytes)required
1announced_ipstring (4 bytes)optional
> - ]; - - decl90[ label=< - - - - - - - - - - - - - - - - - - - - - -
table FBS.Transport.RestartIceResponse
0username_fragmentstring (4 bytes)required
1passwordstring (4 bytes)required
2ice_litebool (1 bytes)default false
> - ]; - - decl91[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Transport.ConsumeRequest
0consumer_idstring (4 bytes)required
1producer_idstring (4 bytes)required
2kindFBS.RtpParameters.MediaKind (1 bytes)default ALL
3rtp_parametersFBS.RtpParameters.RtpParameters (4 bytes)required
4typeFBS.RtpParameters.Type (1 bytes)default NONE
5consumable_rtp_encodings[FBS.RtpParameters.RtpEncodingParameters] (4 bytes)required
6pausedbool (1 bytes)default false
7preferred_layersFBS.Consumer.ConsumerLayers (4 bytes)optional
8ignore_dtxbool (1 bytes)default false
> - ]; - decl91:p2:e -> decl36:name [color = "#3eefa5"]; - decl91:p3:e -> decl51:name [color = "#db8a5e"]; - decl91:p4:e -> decl37:name [color = "#ee13f2"]; - decl91:p5:e -> decl49:name [color = "#ba6534"]; - decl91:p7:e -> decl10:name [color = "#dd9b5d"]; - - decl92[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Transport.ConsumeResponse
0pausedbool (1 bytes)default false
1producer_pausedbool (1 bytes)default false
2scoreFBS.Consumer.ConsumerScore (4 bytes)optional
3preferred_layersFBS.Consumer.ConsumerLayers (4 bytes)optional
> - ]; - decl92:p2:e -> decl11:name [color = "#84af1d"]; - decl92:p3:e -> decl10:name [color = "#c1dd4f"]; - - decl93[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Transport.ProduceRequest
0producer_idstring (4 bytes)required
1kindFBS.RtpParameters.MediaKind (1 bytes)default ALL
2rtp_parametersFBS.RtpParameters.RtpParameters (4 bytes)required
3rtp_mappingFBS.RtpParameters.RtpMapping (4 bytes)required
4key_frame_request_delayuint16 (2 bytes)default 0
5pausedbool (1 bytes)default false
> - ]; - decl93:p1:e -> decl36:name [color = "#f90758"]; - decl93:p2:e -> decl51:name [color = "#d8795f"]; - decl93:p3:e -> decl54:name [color = "#ed23ba"]; - - decl94[ label=< - - - - - - - - - -
table FBS.Transport.ProduceResponse
0typeFBS.RtpParameters.Type (1 bytes)default NONE
> - ]; - decl94:p0:e -> decl37:name [color = "#3cd150"]; - - decl95[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Transport.ProduceDataRequest
0data_producer_idstring (4 bytes)required
1typestring (4 bytes)required
2sctp_stream_parametersFBS.SctpParameters.SctpStreamParameters (4 bytes)optional
3labelstring (4 bytes)optional
4protocolstring (4 bytes)optional
> - ]; - decl95:p2:e -> decl77:name [color = "#7318ce"]; - - decl96[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Transport.ConsumeDataRequest
0data_consumer_idstring (4 bytes)required
1data_producer_idstring (4 bytes)required
2typestring (4 bytes)required
3sctp_stream_parametersFBS.SctpParameters.SctpStreamParameters (4 bytes)optional
4labelstring (4 bytes)optional
5protocolstring (4 bytes)optional
> - ]; - decl96:p3:e -> decl77:name [color = "#2997c6"]; - - decl97[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Transport.Tuple
0local_ipstring (4 bytes)required
1local_portuint16 (2 bytes)default 0
2remote_ipstring (4 bytes)required
3remote_portuint16 (2 bytes)default 0
4protocolstring (4 bytes)required
> - ]; - - decl98[ label=< - - - - - - - - - - - - - - - -
table FBS.Transport.SrtpParameters
0crypto_suitestring (4 bytes)required
1key_base64string (4 bytes)required
> - ]; - - decl99[ label=< - - - - - - - - - - - - - - - - - - - - - -
table FBS.Transport.RtpListener
0ssrc_table[FBS.Common.Uint32String] (4 bytes)required
1mid_table[FBS.Common.StringString] (4 bytes)required
2rid_table[FBS.Common.StringString] (4 bytes)required
> - ]; - decl99:p0:e -> decl8:name [color = "#dda75a"]; - decl99:p1:e -> decl5:name [color = "#3dcc44"]; - decl99:p2:e -> decl5:name [color = "#e0ce57"]; - - decl100[ label=< - - - - - - - - - -
table FBS.Transport.SctpListener
0stream_id_table[FBS.Common.Uint16String] (4 bytes)required
> - ]; - decl100:p0:e -> decl7:name [color = "#d36847"]; - - decl101[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Transport.Dump
0idstring (4 bytes)required
1directbool (1 bytes)default false
2producer_ids[string] (4 bytes)required
3consumer_ids[string] (4 bytes)required
4map_ssrc_consumer_id[FBS.Common.Uint32String] (4 bytes)required
5map_rtx_ssrc_consumer_id[FBS.Common.Uint32String] (4 bytes)required
6data_producer_ids[string] (4 bytes)required
7data_consumer_ids[string] (4 bytes)required
8recv_rtp_header_extensions[FBS.Common.StringUint8] (4 bytes)required
9rtp_listenerFBS.Transport.RtpListener (4 bytes)required
10max_message_sizeuint32 (4 bytes)default 0
11sctp_parametersFBS.SctpParameters.SctpParameters (4 bytes)optional
12sctp_statestring (4 bytes)optional
13sctp_listenerFBS.Transport.SctpListener (4 bytes)optional
14trace_event_types[string] (4 bytes)required
> - ]; - decl101:p4:e -> decl8:name [color = "#8fd651"]; - decl101:p5:e -> decl8:name [color = "#78960d"]; - decl101:p8:e -> decl6:name [color = "#54d361"]; - decl101:p9:e -> decl99:name [color = "#1b98d6"]; - decl101:p11:e -> decl76:name [color = "#9a4dc6"]; - decl101:p13:e -> decl100:name [color = "#cdd64f"]; - - decl102[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Transport.Options
0directbool (1 bytes)default false
1max_message_sizeuint32 (4 bytes)default 0
2initial_available_outgoing_bitrateuint32 (4 bytes)default 0
3enable_sctpbool (1 bytes)default false
4num_sctp_streamsFBS.SctpParameters.NumSctpStreams (4 bytes)optional
5max_sctp_message_sizeuint32 (4 bytes)default 0
6sctp_send_buffer_sizeuint32 (4 bytes)default 0
7is_data_channelbool (1 bytes)default false
> - ]; - decl102:p4:e -> decl75:name [color = "#1529db"]; - - decl103[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Transport.Stats
0transport_idstring (4 bytes)required
1timestampuint64 (8 bytes)default 0
2sctp_statestring (4 bytes)optional
3bytes_receiveduint64 (8 bytes)default 0
4recv_bitrateuint64 (8 bytes)default 0
5bytes_sentuint64 (8 bytes)default 0
6send_bitrateuint64 (8 bytes)default 0
7rtp_bytes_receiveduint64 (8 bytes)default 0
8rtp_recv_bitrateuint64 (8 bytes)default 0
9rtp_bytes_sentuint64 (8 bytes)default 0
10rtp_send_bitrateuint64 (8 bytes)default 0
11rtx_bytes_receiveduint64 (8 bytes)default 0
12rtx_recv_bitrateuint64 (8 bytes)default 0
13rtx_bytes_sentuint64 (8 bytes)default 0
14rtx_send_bitrateuint64 (8 bytes)default 0
15probation_bytes_sentuint64 (8 bytes)default 0
16probation_send_bitrateuint64 (8 bytes)default 0
17available_outgoing_bitrateuint64 (8 bytes)default 0
18available_incoming_bitrateuint64 (8 bytes)default 0
19max_incoming_bitrateuint64 (8 bytes)default 0
20max_outgoing_bitrateuint64 (8 bytes)default 0
21min_outgoing_bitrateuint64 (8 bytes)default 0
22rtp_packet_loss_receiveduint64 (8 bytes)default 0
23rtp_packet_loss_sentuint64 (8 bytes)default 0
> - ]; - - decl104[ label=< - - - - - - - - - -
table FBS.Transport.SetMaxIncomingBitrateRequest
0max_incoming_bitrateuint32 (4 bytes)default 0
> - ]; - - decl105[ label=< - - - - - - - - - -
table FBS.Transport.SetMaxOutgoingBitrateRequest
0max_outgoing_bitrateuint32 (4 bytes)default 0
> - ]; - - decl106[ label=< - - - - - - - - - -
table FBS.Transport.SetMinOutgoingBitrateRequest
0min_outgoing_bitrateuint32 (4 bytes)default 0
> - ]; - - decl107[ label=< - - - - - - - - - -
table FBS.Transport.EnableTraceEventRequest
0events[string] (4 bytes)required
> - ]; - - decl108[ label=< - - - - - - - - - -
table FBS.Transport.CloseProducerRequest
0producer_idstring (4 bytes)required
> - ]; - - decl109[ label=< - - - - - - - - - -
table FBS.Transport.CloseConsumerRequest
0consumer_idstring (4 bytes)required
> - ]; - - decl110[ label=< - - - - - - - - - -
table FBS.Transport.CloseDataProducerRequest
0data_producer_idstring (4 bytes)required
> - ]; - - decl111[ label=< - - - - - - - - - -
table FBS.Transport.CloseDataConsumerRequest
0data_consumer_idstring (4 bytes)required
> - ]; - - decl112[ label=< - - - - - - - - - -
table FBS.Transport.SendRtcpNotification
0data[uint8] (4 bytes)required
> - ]; - - decl113[ label=< - - - - - - - - - -
table FBS.Transport.SctpStateChangeNotification
0sctp_stateFBS.SctpAssociation.SctpState (1 bytes)default NEW
> - ]; - decl113:p0:e -> decl120:name [color = "#cc8b3d"]; - - decl114[ label=< - - - - - - - - - - - - -
enum FBS.Transport.TraceType : uint8
PROBATION0
BWE1
> - ]; - - decl115[ label=< - - - - - - - - - - - - -
enum FBS.Transport.TraceDirection : uint8
DIRECTION_IN0
DIRECTION_OUT1
> - ]; - - decl116[ label=< - - - - - - - - -
union FBS.Transport.TraceInfo
BweTraceInfoFBS.Transport.BweTraceInfo
> - ]; - decl116:p0:e -> decl118:name [color = "#421dd3"]; - - decl117[ label=< - - - - - - - - - - - - -
enum FBS.Transport.BweType : uint8
TRANSPORT_CC0
REMB1
> - ]; - - decl118[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Transport.BweTraceInfo
0desired_bitrateuint32 (4 bytes)default 0
1effective_desired_bitrateuint32 (4 bytes)default 0
2min_bitrateuint32 (4 bytes)default 0
3max_bitrateuint32 (4 bytes)default 0
4start_bitrateuint32 (4 bytes)default 0
5max_padding_bitrateuint32 (4 bytes)default 0
6available_bitrateuint32 (4 bytes)default 0
7bwe_typeFBS.Transport.BweType (1 bytes)default TRANSPORT_CC
> - ]; - decl118:p7:e -> decl117:name [color = "#a35ae8"]; - - decl119[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Transport.TraceNotification
0typeFBS.Transport.TraceType (1 bytes)default PROBATION
1timestampuint64 (8 bytes)default 0
2directionFBS.Transport.TraceDirection (1 bytes)default DIRECTION_IN
3 / 4infoFBS.Transport.TraceInfo (4 bytes)optional
> - ]; - decl119:p0:e -> decl114:name [color = "#db8a5e"]; - decl119:p2:e -> decl115:name [color = "#dd9b5d"]; - decl119:p3:e -> decl116:name [color = "#d8825d"]; - - decl120[ label=< - - - - - - - - - - - - - - - - - - - - - - - - -
enum FBS.SctpAssociation.SctpState : uint8
NEW0
CONNECTING1
CONNECTED2
FAILED3
CLOSED4
> - ]; - - decl121[ label=< - - - - - - - - - -
table FBS.Log.Log
0datastring (4 bytes)required
> - ]; - - decl122[ label=< - - - - - - - - - - - - - - - - - - - - -
enum FBS.Message.Type : uint8
REQUEST0
RESPONSE1
NOTIFICATION2
LOG3
> - ]; - - decl123[ label=< - - - - - - - - - - - - - - - - - - - - -
union FBS.Message.Body
RequestFBS.Request.Request
ResponseFBS.Response.Response
NotificationFBS.Notification.Notification
LogFBS.Log.Log
> - ]; - decl123:p0:e -> decl130:name [color = "#f90466"]; - decl123:p1:e -> decl132:name [color = "#2ac967"]; - decl123:p2:e -> decl127:name [color = "#1c3fa8"]; - decl123:p3:e -> decl121:name [color = "#2684bf"]; - - decl124[ label=< - - - - - - - - - - - - - - - -
table FBS.Message.Message
0typeFBS.Message.Type (1 bytes)default REQUEST
1 / 2dataFBS.Message.Body (4 bytes)required
> - ]; - decl124:p0:e -> decl122:name [color = "#6511a0"]; - decl124:p1:e -> decl123:name [color = "#79d334"]; - - decl125[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
enum FBS.Notification.Event : uint8
TRANSPORT_SEND_RTCP0
PRODUCER_SEND1
DATA_PRODUCER_SEND2
WORKER_RUNNING3
TRANSPORT_SCTP_STATE_CHANGE4
TRANSPORT_TRACE5
WEBRTCTRANSPORT_ICE_SELECTED_TUPLE_CHANGE6
WEBRTCTRANSPORT_ICE_STATE_CHANGE7
WEBRTCTRANSPORT_DTLS_STATE_CHANGE8
PLAINTRANSPORT_TUPLE9
PLAINTRANSPORT_RTCP_TUPLE10
DIRECTTRANSPORT_RTCP11
PRODUCER_SCORE12
PRODUCER_TRACE13
PRODUCER_VIDEO_ORIENTATION_CHANGE14
CONSUMER_PRODUCER_PAUSE15
CONSUMER_PRODUCER_RESUME16
CONSUMER_PRODUCER_CLOSE17
CONSUMER_LAYERS_CHANGE18
CONSUMER_RTP19
CONSUMER_SCORE20
CONSUMER_TRACE21
DATACONSUMER_BUFFERED_AMOUNT_LOW22
DATACONSUMER_SCTP_SENDBUFFER_FULL23
DATACONSUMER_DATAPRODUCER_CLOSE24
DATACONSUMER_MESSAGE25
ACTIVESPEAKEROBSERVER_DOMINANT_SPEAKER26
AUDIOLEVELOBSERVER_SILENCE27
AUDIOLEVELOBSERVER_VOLUMES28
> - ]; - - decl126[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
union FBS.Notification.Body
SendRtcpNotificationFBS.Transport.SendRtcpNotification
SctpStateChangeNotificationFBS.Transport.SctpStateChangeNotification
SendNotificationFBS.DataProducer.SendNotification
TraceNotificationFBS.Consumer.TraceNotification
IceSelectedTupleChangeNotificationFBS.WebRtcTransport.IceSelectedTupleChangeNotification
IceStateChangeNotificationFBS.WebRtcTransport.IceStateChangeNotification
DtlsStateChangeNotificationFBS.WebRtcTransport.DtlsStateChangeNotification
TupleNotificationFBS.PlainTransport.TupleNotification
RtcpTupleNotificationFBS.PlainTransport.RtcpTupleNotification
RtcpNotificationFBS.DirectTransport.RtcpNotification
ScoreNotificationFBS.Consumer.ScoreNotification
VideoOrientationChangeNotificationFBS.Producer.VideoOrientationChangeNotification
LayersChangeNotificationFBS.Consumer.LayersChangeNotification
RtpNotificationFBS.Consumer.RtpNotification
MessageNotificationFBS.DataConsumer.MessageNotification
BufferedAmountLowNotificationFBS.DataConsumer.BufferedAmountLowNotification
DominantSpeakerNotificationFBS.ActiveSpeakerObserver.DominantSpeakerNotification
VolumesNotificationFBS.AudioLevelObserver.VolumesNotification
> - ]; - decl126:p0:e -> decl112:name [color = "#8816e0"]; - decl126:p1:e -> decl113:name [color = "#d86761"]; - decl126:p2:e -> decl83:name [color = "#2357c6"]; - decl126:p3:e -> decl35:name [color = "#7af44e"]; - decl126:p4:e -> decl194:name [color = "#ef8113"]; - decl126:p5:e -> decl197:name [color = "#173e82"]; - decl126:p6:e -> decl198:name [color = "#4edd44"]; - decl126:p7:e -> decl180:name [color = "#ee13f2"]; - decl126:p8:e -> decl181:name [color = "#fc9105"]; - decl126:p9:e -> decl87:name [color = "#2ad6a2"]; - decl126:p10:e -> decl27:name [color = "#16b73b"]; - decl126:p11:e -> decl161:name [color = "#33ce81"]; - decl126:p12:e -> decl25:name [color = "#521396"]; - decl126:p13:e -> decl26:name [color = "#ce1697"]; - decl126:p14:e -> decl74:name [color = "#381abc"]; - decl126:p15:e -> decl73:name [color = "#38d175"]; - decl126:p16:e -> decl1:name [color = "#b5d330"]; - decl126:p17:e -> decl4:name [color = "#37e218"]; - - decl127[ label=< - - - - - - - - - - - - - - - - - - - - - -
table FBS.Notification.Notification
0handler_idstring (4 bytes)optional
1eventFBS.Notification.Event (1 bytes)default TRANSPORT_SEND_RTCP
2 / 3bodyFBS.Notification.Body (4 bytes)optional
> - ]; - decl127:p1:e -> decl125:name [color = "#ef1fe1"]; - decl127:p2:e -> decl126:name [color = "#6f25dd"]; - - decl128[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
enum FBS.Request.Method : uint8
WORKER_CLOSE0
WORKER_DUMP1
WORKER_GET_RESOURCE_USAGE2
WORKER_UPDATE_SETTINGS3
WORKER_CREATE_WEBRTC_SERVER4
WORKER_CREATE_ROUTER5
WORKER_WEBRTC_SERVER_CLOSE6
WORKER_CLOSE_ROUTER7
WEBRTC_SERVER_DUMP8
ROUTER_DUMP9
ROUTER_CREATE_WEBRTC_TRANSPORT10
ROUTER_CREATE_WEBRTC_TRANSPORT_WITH_SERVER11
ROUTER_CREATE_PLAIN_TRANSPORT12
ROUTER_CREATE_PIPE_TRANSPORT13
ROUTER_CREATE_DIRECT_TRANSPORT14
ROUTER_CLOSE_TRANSPORT15
ROUTER_CREATE_ACTIVE_SPEAKER_OBSERVER16
ROUTER_CREATE_AUDIO_LEVEL_OBSERVER17
ROUTER_CLOSE_RTP_OBSERVER18
TRANSPORT_DUMP19
TRANSPORT_GET_STATS20
TRANSPORT_CONNECT21
TRANSPORT_SET_MAX_INCOMING_BITRATE22
TRANSPORT_SET_MAX_OUTGOING_BITRATE23
TRANSPORT_SET_MIN_OUTGOING_BITRATE24
TRANSPORT_RESTART_ICE25
TRANSPORT_PRODUCE26
TRANSPORT_PRODUCE_DATA27
TRANSPORT_CONSUME28
TRANSPORT_CONSUME_DATA29
TRANSPORT_ENABLE_TRACE_EVENT30
TRANSPORT_CLOSE_PRODUCER31
TRANSPORT_CLOSE_CONSUMER32
TRANSPORT_CLOSE_DATA_PRODUCER33
TRANSPORT_CLOSE_DATA_CONSUMER34
PLAIN_TRANSPORT_CONNECT35
PIPE_TRANSPORT_CONNECT36
WEBRTC_TRANSPORT_CONNECT37
PRODUCER_DUMP38
PRODUCER_GET_STATS39
PRODUCER_PAUSE40
PRODUCER_RESUME41
PRODUCER_ENABLE_TRACE_EVENT42
CONSUMER_DUMP43
CONSUMER_GET_STATS44
CONSUMER_PAUSE45
CONSUMER_RESUME46
CONSUMER_SET_PREFERRED_LAYERS47
CONSUMER_SET_PRIORITY48
CONSUMER_REQUEST_KEY_FRAME49
CONSUMER_ENABLE_TRACE_EVENT50
DATA_PRODUCER_DUMP51
DATA_PRODUCER_GET_STATS52
DATA_CONSUMER_DUMP53
DATA_CONSUMER_GET_STATS54
DATA_CONSUMER_GET_BUFFERED_AMOUNT55
DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD56
DATA_CONSUMER_SEND57
RTP_OBSERVER_PAUSE58
RTP_OBSERVER_RESUME59
RTP_OBSERVER_ADD_PRODUCER60
RTP_OBSERVER_REMOVE_PRODUCER61
> - ]; - - decl129[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
union FBS.Request.Body
UpdateSettingsRequestFBS.Worker.UpdateSettingsRequest
CreateWebRtcServerRequestFBS.Worker.CreateWebRtcServerRequest
CloseWebRtcServerRequestFBS.Worker.CloseWebRtcServerRequest
CreateRouterRequestFBS.Worker.CreateRouterRequest
CloseRouterRequestFBS.Worker.CloseRouterRequest
CreateWebRtcTransportRequestFBS.Router.CreateWebRtcTransportRequest
CreatePlainTransportRequestFBS.Router.CreatePlainTransportRequest
CreatePipeTransportRequestFBS.Router.CreatePipeTransportRequest
CreateDirectTransportRequestFBS.Router.CreateDirectTransportRequest
CreateActiveSpeakerObserverRequestFBS.Router.CreateActiveSpeakerObserverRequest
CreateAudioLevelObserverRequestFBS.Router.CreateAudioLevelObserverRequest
CloseTransportRequestFBS.Router.CloseTransportRequest
CloseRtpObserverRequestFBS.Router.CloseRtpObserverRequest
SetMaxIncomingBitrateRequestFBS.Transport.SetMaxIncomingBitrateRequest
SetMaxOutgoingBitrateRequestFBS.Transport.SetMaxOutgoingBitrateRequest
SetMinOutgoingBitrateRequestFBS.Transport.SetMinOutgoingBitrateRequest
ProduceRequestFBS.Transport.ProduceRequest
ConsumeRequestFBS.Transport.ConsumeRequest
ProduceDataRequestFBS.Transport.ProduceDataRequest
ConsumeDataRequestFBS.Transport.ConsumeDataRequest
EnableTraceEventRequestFBS.Consumer.EnableTraceEventRequest
CloseProducerRequestFBS.Transport.CloseProducerRequest
CloseConsumerRequestFBS.Transport.CloseConsumerRequest
CloseDataProducerRequestFBS.Transport.CloseDataProducerRequest
CloseDataConsumerRequestFBS.Transport.CloseDataConsumerRequest
ConnectRequestFBS.WebRtcTransport.ConnectRequest
SetPreferredLayersRequestFBS.Consumer.SetPreferredLayersRequest
SetPriorityRequestFBS.Consumer.SetPriorityRequest
SetBufferedAmountLowThresholdRequestFBS.DataConsumer.SetBufferedAmountLowThresholdRequest
SendRequestFBS.DataConsumer.SendRequest
AddProducerRequestFBS.RtpObserver.AddProducerRequest
RemoveProducerRequestFBS.RtpObserver.RemoveProducerRequest
> - ]; - decl129:p0:e -> decl136:name [color = "#37d337"]; - decl129:p1:e -> decl137:name [color = "#4dc1bf"]; - decl129:p2:e -> decl138:name [color = "#30d3ce"]; - decl129:p3:e -> decl139:name [color = "#f968bb"]; - decl129:p4:e -> decl140:name [color = "#0ba042"]; - decl129:p5:e -> decl144:name [color = "#ddab5a"]; - decl129:p6:e -> decl143:name [color = "#9551ba"]; - decl129:p7:e -> decl142:name [color = "#2eafdb"]; - decl129:p8:e -> decl145:name [color = "#3e95a3"]; - decl129:p9:e -> decl147:name [color = "#2ad630"]; - decl129:p10:e -> decl146:name [color = "#3b1dd1"]; - decl129:p11:e -> decl148:name [color = "#132ec6"]; - decl129:p12:e -> decl149:name [color = "#d115f2"]; - decl129:p13:e -> decl104:name [color = "#69f49e"]; - decl129:p14:e -> decl105:name [color = "#81ea10"]; - decl129:p15:e -> decl106:name [color = "#78bc29"]; - decl129:p16:e -> decl93:name [color = "#dd812a"]; - decl129:p17:e -> decl91:name [color = "#17b72a"]; - decl129:p18:e -> decl95:name [color = "#f970e2"]; - decl129:p19:e -> decl96:name [color = "#f90971"]; - decl129:p20:e -> decl16:name [color = "#d86361"]; - decl129:p21:e -> decl108:name [color = "#30d3cb"]; - decl129:p22:e -> decl109:name [color = "#fc1437"]; - decl129:p23:e -> decl110:name [color = "#7ffc5f"]; - decl129:p24:e -> decl111:name [color = "#fc0217"]; - decl129:p25:e -> decl190:name [color = "#9e16dd"]; - decl129:p26:e -> decl12:name [color = "#dbb657"]; - decl129:p27:e -> decl14:name [color = "#e0ce57"]; - decl129:p28:e -> decl66:name [color = "#46e2ac"]; - decl129:p29:e -> decl72:name [color = "#d86b61"]; - decl129:p30:e -> decl199:name [color = "#fc0c2c"]; - decl129:p31:e -> decl200:name [color = "#451dd3"]; - - decl130[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Request.Request
0iduint32 (4 bytes)default 0
1methodFBS.Request.Method (1 bytes)default WORKER_CLOSE
2handler_idstring (4 bytes)optional
3 / 4bodyFBS.Request.Body (4 bytes)optional
> - ]; - decl130:p1:e -> decl128:name [color = "#cbd330"]; - decl130:p3:e -> decl129:name [color = "#241ece"]; - - decl131[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
union FBS.Response.Body
DumpResponseFBS.DataConsumer.DumpResponse
ResourceUsageResponseFBS.Worker.ResourceUsageResponse
ProduceResponseFBS.Transport.ProduceResponse
ConsumeResponseFBS.Transport.ConsumeResponse
RestartIceResponseFBS.Transport.RestartIceResponse
ConnectResponseFBS.WebRtcTransport.ConnectResponse
GetStatsResponseFBS.DataConsumer.GetStatsResponse
SetPreferredLayersResponseFBS.Consumer.SetPreferredLayersResponse
SetPriorityResponseFBS.Consumer.SetPriorityResponse
GetBufferedAmountResponseFBS.DataConsumer.GetBufferedAmountResponse
> - ]; - decl131:p0:e -> decl67:name [color = "#f90758"]; - decl131:p1:e -> decl135:name [color = "#3cd152"]; - decl131:p2:e -> decl94:name [color = "#d86f5f"]; - decl131:p3:e -> decl92:name [color = "#3010e8"]; - decl131:p4:e -> decl90:name [color = "#dd46a6"]; - decl131:p5:e -> decl191:name [color = "#51dd44"]; - decl131:p6:e -> decl68:name [color = "#50d332"]; - decl131:p7:e -> decl13:name [color = "#c40762"]; - decl131:p8:e -> decl15:name [color = "#207a99"]; - decl131:p9:e -> decl65:name [color = "#5c1cdb"]; - - decl132[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Response.Response
0iduint32 (4 bytes)default 0
1acceptedbool (1 bytes)default false
2 / 3bodyFBS.Response.Body (4 bytes)optional
4errorstring (4 bytes)optional
5reasonstring (4 bytes)optional
> - ]; - decl132:p2:e -> decl131:name [color = "#48db5e"]; - - decl133[ label=< - - - - - - - - - - - - - - - -
table FBS.Worker.ChannelMessageHandlers
0channel_request_handlers[string] (4 bytes)optional
1channel_notification_handlers[string] (4 bytes)optional
> - ]; - - decl134[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Worker.DumpResponse
0piduint32 (4 bytes)default 0
1web_rtc_server_ids[string] (4 bytes)optional
2router_ids[string] (4 bytes)optional
3channel_message_handlersFBS.Worker.ChannelMessageHandlers (4 bytes)optional
> - ]; - decl134:p3:e -> decl133:name [color = "#3ed141"]; - - decl135[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Worker.ResourceUsageResponse
0ru_utimeuint64 (8 bytes)default 0
1ru_stimeuint64 (8 bytes)default 0
2ru_maxrssuint64 (8 bytes)default 0
3ru_ixrssuint64 (8 bytes)default 0
4ru_idrssuint64 (8 bytes)default 0
5ru_isrssuint64 (8 bytes)default 0
6ru_minfltuint64 (8 bytes)default 0
7ru_majfltuint64 (8 bytes)default 0
8ru_nswapuint64 (8 bytes)default 0
9ru_inblockuint64 (8 bytes)default 0
10ru_oublockuint64 (8 bytes)default 0
11ru_msgsnduint64 (8 bytes)default 0
12ru_msgrcvuint64 (8 bytes)default 0
13ru_nsignalsuint64 (8 bytes)default 0
14ru_nvcswuint64 (8 bytes)default 0
15ru_nivcswuint64 (8 bytes)default 0
> - ]; - - decl136[ label=< - - - - - - - - - - - - - - - -
table FBS.Worker.UpdateSettingsRequest
0log_levelstring (4 bytes)optional
1log_tags[string] (4 bytes)optional
> - ]; - - decl137[ label=< - - - - - - - - - - - - - - - -
table FBS.Worker.CreateWebRtcServerRequest
0web_rtc_server_idstring (4 bytes)required
1listen_infos[FBS.WebRtcServer.ListenInfo] (4 bytes)optional
> - ]; - decl137:p1:e -> decl150:name [color = "#d8715f"]; - - decl138[ label=< - - - - - - - - - -
table FBS.Worker.CloseWebRtcServerRequest
0web_rtc_server_idstring (4 bytes)required
> - ]; - - decl139[ label=< - - - - - - - - - -
table FBS.Worker.CreateRouterRequest
0router_idstring (4 bytes)required
> - ]; - - decl140[ label=< - - - - - - - - - -
table FBS.Worker.CloseRouterRequest
0router_idstring (4 bytes)required
> - ]; - - decl141[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Router.DumpResponse
0idstring (4 bytes)required
1transport_ids[string] (4 bytes)optional
2rtp_observer_ids[string] (4 bytes)optional
3map_producer_id_consumer_ids[FBS.Common.StringStringArray] (4 bytes)optional
4map_consumer_id_producer_id[FBS.Common.StringString] (4 bytes)optional
5map_producer_id_observer_ids[FBS.Common.StringStringArray] (4 bytes)optional
6map_data_producer_id_data_consumer_ids[FBS.Common.StringStringArray] (4 bytes)optional
7map_data_consumer_id_data_producer_id[FBS.Common.StringString] (4 bytes)optional
> - ]; - decl141:p3:e -> decl9:name [color = "#e738f7"]; - decl141:p4:e -> decl5:name [color = "#381dd1"]; - decl141:p5:e -> decl9:name [color = "#f92c9a"]; - decl141:p6:e -> decl9:name [color = "#3fd37d"]; - decl141:p7:e -> decl5:name [color = "#25a3a3"]; - - decl142[ label=< - - - - - - - - - - - - - - - -
table FBS.Router.CreatePipeTransportRequest
0transport_idstring (4 bytes)required
1optionsFBS.PipeTransport.PipeTransportOptions (4 bytes)required
> - ]; - decl142:p1:e -> decl170:name [color = "#35d6c8"]; - - decl143[ label=< - - - - - - - - - - - - - - - -
table FBS.Router.CreatePlainTransportRequest
0transport_idstring (4 bytes)required
1optionsFBS.PlainTransport.PlainTransportOptions (4 bytes)required
> - ]; - decl143:p1:e -> decl175:name [color = "#f90764"]; - - decl144[ label=< - - - - - - - - - - - - - - - -
table FBS.Router.CreateWebRtcTransportRequest
0transport_idstring (4 bytes)required
1optionsFBS.WebRtcTransport.WebRtcTransportOptions (4 bytes)required
> - ]; - decl144:p1:e -> decl185:name [color = "#f90798"]; - - decl145[ label=< - - - - - - - - - - - - - - - -
table FBS.Router.CreateDirectTransportRequest
0transport_idstring (4 bytes)required
1optionsFBS.DirectTransport.DirectTransportOptions (4 bytes)required
> - ]; - decl145:p1:e -> decl84:name [color = "#6def4c"]; - - decl146[ label=< - - - - - - - - - - - - - - - -
table FBS.Router.CreateAudioLevelObserverRequest
0rtp_observer_idstring (4 bytes)required
1optionsFBS.AudioLevelObserver.AudioLevelObserverOptions (4 bytes)required
> - ]; - decl146:p1:e -> decl2:name [color = "#2badc4"]; - - decl147[ label=< - - - - - - - - - - - - - - - -
table FBS.Router.CreateActiveSpeakerObserverRequest
0active_speaker_observer_idstring (4 bytes)required
1optionsFBS.ActiveSpeakerObserver.ActiveSpeakerObserverOptions (4 bytes)required
> - ]; - decl147:p1:e -> decl0:name [color = "#235cc6"]; - - decl148[ label=< - - - - - - - - - -
table FBS.Router.CloseTransportRequest
0transport_idstring (4 bytes)required
> - ]; - - decl149[ label=< - - - - - - - - - -
table FBS.Router.CloseRtpObserverRequest
0rtp_observer_idstring (4 bytes)required
> - ]; - - decl150[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.WebRtcServer.ListenInfo
0protocolFBS.Transport.Protocol (1 bytes)default UDP
1ipstring (4 bytes)required
2announced_ipstring (4 bytes)optional
3portuint16 (2 bytes)default 0
> - ]; - decl150:p0:e -> decl88:name [color = "#4e53db"]; - - decl151[ label=< - - - - - - - - - - - - - - - -
table FBS.WebRtcServer.IpPort
0ipstring (4 bytes)required
1portuint16 (2 bytes)default 0
> - ]; - - decl152[ label=< - - - - - - - - - - - - - - - -
table FBS.WebRtcServer.IceUserNameFragment
0local_ice_username_fragmentstring (4 bytes)required
1web_rtc_transport_idstring (4 bytes)required
> - ]; - - decl153[ label=< - - - - - - - - - - - - - - - -
table FBS.WebRtcServer.TupleHash
0local_ice_username_fragmentuint64 (8 bytes)default 0
1web_rtc_transport_idstring (4 bytes)required
> - ]; - - decl154[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.WebRtcServer.DumpResponse
0idstring (4 bytes)required
1udp_sockets[FBS.WebRtcServer.IpPort] (4 bytes)optional
2tcp_servers[FBS.WebRtcServer.IpPort] (4 bytes)optional
3web_rtc_transport_ids[string] (4 bytes)optional
4local_ice_username_fragments[FBS.WebRtcServer.IceUserNameFragment] (4 bytes)optional
5tuple_hashes[FBS.WebRtcServer.TupleHash] (4 bytes)optional
> - ]; - decl154:p1:e -> decl151:name [color = "#1c7089"]; - decl154:p2:e -> decl151:name [color = "#2246c9"]; - decl154:p4:e -> decl152:name [color = "#db328f"]; - decl154:p5:e -> decl153:name [color = "#a5d84b"]; - - decl155[ label=< - - - - - - - - - -
table FBS.Producer.EnableTraceEventRequest
0events[string] (4 bytes)required
> - ]; - - decl156[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Producer.DumpResponse
0idstring (4 bytes)required
1kindFBS.RtpParameters.MediaKind (1 bytes)default ALL
2typestring (4 bytes)required
3rtp_parametersFBS.RtpParameters.RtpParameters (4 bytes)required
4rtp_mappingFBS.RtpParameters.RtpMapping (4 bytes)required
5rtp_streams[FBS.RtpStream.Dump] (4 bytes)optional
6trace_event_types[string] (4 bytes)required
7pausedbool (1 bytes)default false
> - ]; - decl156:p1:e -> decl36:name [color = "#2249c9"]; - decl156:p3:e -> decl51:name [color = "#dd0b38"]; - decl156:p4:e -> decl54:name [color = "#5def4a"]; - decl156:p5:e -> decl56:name [color = "#29a5c4"]; - - decl157[ label=< - - - - - - - - - -
table FBS.Producer.GetStatsResponse
0stats[FBS.RtpStream.Stats] (4 bytes)optional
> - ]; - decl157:p0:e -> decl59:name [color = "#36d18b"]; - - decl158[ label=< - - - - - - - - - -
table FBS.Producer.SendNotification
0data[uint8] (4 bytes)required
> - ]; - - decl159[ label=< - - - - - - - - - - - - - - - - - - - - - -
table FBS.Producer.Score
0ssrcuint32 (4 bytes)default 0
1ridstring (4 bytes)optional
2scoreuint8 (1 bytes)default 0
> - ]; - - decl160[ label=< - - - - - - - - - -
table FBS.Producer.ScoreNotification
0scores[FBS.Producer.Score] (4 bytes)optional
> - ]; - decl160:p0:e -> decl159:name [color = "#1a137f"]; - - decl161[ label=< - - - - - - - - - - - - - - - - - - - - - -
table FBS.Producer.VideoOrientationChangeNotification
0camerabool (1 bytes)default false
1flipbool (1 bytes)default false
2rotationuint16 (2 bytes)default 0
> - ]; - - decl162[ label=< - - - - - - - - - - - - - - - - - - - - - - - - -
enum FBS.Producer.TraceType : uint8
KEYFRAME0
FIR1
NACK2
PLI3
RTP4
> - ]; - - decl163[ label=< - - - - - - - - - - - - -
enum FBS.Producer.TraceDirection : uint8
DIRECTION_IN0
DIRECTION_OUT1
> - ]; - - decl164[ label=< - - - - - - - - - - - - - - - - - - - - -
union FBS.Producer.TraceInfo
KeyFrameTraceInfoFBS.Producer.KeyFrameTraceInfo
FirTraceInfoFBS.Producer.FirTraceInfo
PliTraceInfoFBS.Producer.PliTraceInfo
RtpTraceInfoFBS.Producer.RtpTraceInfo
> - ]; - decl164:p0:e -> decl165:name [color = "#3d08d1"]; - decl164:p1:e -> decl166:name [color = "#cdd64f"]; - decl164:p2:e -> decl167:name [color = "#f90eb7"]; - decl164:p3:e -> decl168:name [color = "#8cfc37"]; - - decl165[ label=< - - - - - - - - - -
table FBS.Producer.KeyFrameTraceInfo
0is_rtxbool (1 bytes)default false
> - ]; - - decl166[ label=< - - - - - - - - - -
table FBS.Producer.FirTraceInfo
0ssrcuint32 (4 bytes)default 0
> - ]; - - decl167[ label=< - - - - - - - - - -
table FBS.Producer.PliTraceInfo
0ssrcuint32 (4 bytes)default 0
> - ]; - - decl168[ label=< - - - - - - - - - -
table FBS.Producer.RtpTraceInfo
0is_rtxbool (1 bytes)default false
> - ]; - - decl169[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.Producer.TraceNotification
0typeFBS.Producer.TraceType (1 bytes)default KEYFRAME
1timestampuint64 (8 bytes)default 0
2directionFBS.Producer.TraceDirection (1 bytes)default DIRECTION_IN
3 / 4infoFBS.Producer.TraceInfo (4 bytes)optional
> - ]; - decl169:p0:e -> decl162:name [color = "#1bba2b"]; - decl169:p2:e -> decl163:name [color = "#683cc1"]; - decl169:p3:e -> decl164:name [color = "#1bba2e"]; - - decl170[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.PipeTransport.PipeTransportOptions
0baseFBS.Transport.Options (4 bytes)required
1listen_ipFBS.Transport.ListenIp (4 bytes)required
2portuint16 (2 bytes)default 0
3enable_rtxbool (1 bytes)default false
4enable_srtpbool (1 bytes)default false
> - ]; - decl170:p0:e -> decl102:name [color = "#b3d84e"]; - decl170:p1:e -> decl89:name [color = "#c6d64f"]; - - decl171[ label=< - - - - - - - - - - - - - - - - - - - - - -
table FBS.PipeTransport.ConnectRequest
0ipstring (4 bytes)required
1portuint16 (2 bytes)optional
2srtp_parametersFBS.Transport.SrtpParameters (4 bytes)optional
> - ]; - decl171:p2:e -> decl98:name [color = "#d86361"]; - - decl172[ label=< - - - - - - - - - -
table FBS.PipeTransport.ConnectResponse
0tupleFBS.Transport.Tuple (4 bytes)optional
> - ]; - decl172:p0:e -> decl97:name [color = "#18ba40"]; - - decl173[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.PipeTransport.DumpResponse
0baseFBS.Transport.Dump (4 bytes)required
1tupleFBS.Transport.Tuple (4 bytes)required
2rtxbool (1 bytes)default false
3srtp_parametersFBS.Transport.SrtpParameters (4 bytes)optional
> - ]; - decl173:p0:e -> decl101:name [color = "#cea03b"]; - decl173:p1:e -> decl97:name [color = "#421dd3"]; - decl173:p3:e -> decl98:name [color = "#04f71d"]; - - decl174[ label=< - - - - - - - - - - - - - - - -
table FBS.PipeTransport.GetStatsResponse
0baseFBS.Transport.Stats (4 bytes)required
1tupleFBS.Transport.Tuple (4 bytes)required
> - ]; - decl174:p0:e -> decl103:name [color = "#c125ed"]; - decl174:p1:e -> decl97:name [color = "#dbb157"]; - - decl175[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.PlainTransport.PlainTransportOptions
0baseFBS.Transport.Options (4 bytes)optional
1listen_ipFBS.Transport.ListenIp (4 bytes)required
2portuint16 (2 bytes)default 0
3rtcp_muxbool (1 bytes)default false
4comediabool (1 bytes)default false
5enable_srtpbool (1 bytes)default false
6srtp_crypto_suitestring (4 bytes)optional
> - ]; - decl175:p0:e -> decl102:name [color = "#751add"]; - decl175:p1:e -> decl89:name [color = "#36d1c9"]; - - decl176[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.PlainTransport.ConnectRequest
0ipstring (4 bytes)optional
1portuint16 (2 bytes)optional
2rtcp_portuint16 (2 bytes)optional
3srtp_parametersFBS.Transport.SrtpParameters (4 bytes)optional
> - ]; - decl176:p3:e -> decl98:name [color = "#dda55a"]; - - decl177[ label=< - - - - - - - - - - - - - - - - - - - - - -
table FBS.PlainTransport.ConnectResponse
0tupleFBS.Transport.Tuple (4 bytes)required
1rtcp_tupleFBS.Transport.Tuple (4 bytes)optional
2srtp_parametersFBS.Transport.SrtpParameters (4 bytes)optional
> - ]; - decl177:p0:e -> decl97:name [color = "#3cd150"]; - decl177:p1:e -> decl97:name [color = "#223ec9"]; - decl177:p2:e -> decl98:name [color = "#8a42b7"]; - - decl178[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.PlainTransport.DumpResponse
0baseFBS.Transport.Dump (4 bytes)required
1rtcp_muxbool (1 bytes)default false
2comediabool (1 bytes)default false
3tupleFBS.Transport.Tuple (4 bytes)optional
4rtcp_tupleFBS.Transport.Tuple (4 bytes)optional
5srtp_parametersFBS.Transport.SrtpParameters (4 bytes)optional
> - ]; - decl178:p0:e -> decl101:name [color = "#1fdd65"]; - decl178:p3:e -> decl97:name [color = "#dd1ad0"]; - decl178:p4:e -> decl97:name [color = "#20db46"]; - decl178:p5:e -> decl98:name [color = "#d37c34"]; - - decl179[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.PlainTransport.GetStatsResponse
0baseFBS.Transport.Stats (4 bytes)required
1rtcp_muxbool (1 bytes)default false
2comediabool (1 bytes)default false
3tupleFBS.Transport.Tuple (4 bytes)required
4rtcp_tupleFBS.Transport.Tuple (4 bytes)optional
> - ]; - decl179:p0:e -> decl103:name [color = "#e2af5d"]; - decl179:p3:e -> decl97:name [color = "#c6d64f"]; - decl179:p4:e -> decl97:name [color = "#fc020f"]; - - decl180[ label=< - - - - - - - - - -
table FBS.PlainTransport.TupleNotification
0tupleFBS.Transport.Tuple (4 bytes)required
> - ]; - decl180:p0:e -> decl97:name [color = "#b217ef"]; - - decl181[ label=< - - - - - - - - - -
table FBS.PlainTransport.RtcpTupleNotification
0tupleFBS.Transport.Tuple (4 bytes)required
> - ]; - decl181:p0:e -> decl97:name [color = "#c915f2"]; - - decl182[ label=< - - - - - - - - - - - - - - - -
table FBS.WebRtcTransport.ListenIndividual
0listen_ips[FBS.Transport.ListenIp] (4 bytes)required
1portuint16 (2 bytes)default 0
> - ]; - decl182:p0:e -> decl89:name [color = "#d8715f"]; - - decl183[ label=< - - - - - - - - - -
table FBS.WebRtcTransport.ListenServer
0web_rtc_server_idstring (4 bytes)required
> - ]; - - decl184[ label=< - - - - - - - - - - - - -
union FBS.WebRtcTransport.Listen
ListenIndividualFBS.WebRtcTransport.ListenIndividual
ListenServerFBS.WebRtcTransport.ListenServer
> - ]; - decl184:p0:e -> decl182:name [color = "#ceef56"]; - decl184:p1:e -> decl183:name [color = "#3b1cc9"]; - - decl185[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.WebRtcTransport.WebRtcTransportOptions
0baseFBS.Transport.Options (4 bytes)required
1 / 2listenFBS.WebRtcTransport.Listen (4 bytes)required
3enable_udpbool (1 bytes)default true
4enable_tcpbool (1 bytes)default false
5prefer_udpbool (1 bytes)default false
6prefer_tcpbool (1 bytes)default false
> - ]; - decl185:p0:e -> decl102:name [color = "#f4a166"]; - decl185:p1:e -> decl184:name [color = "#e0de55"]; - - decl186[ label=< - - - - - - - - - - - - - - - -
table FBS.WebRtcTransport.Fingerprint
0algorithmstring (4 bytes)required
1valuestring (4 bytes)required
> - ]; - - decl187[ label=< - - - - - - - - - - - - - - - -
table FBS.WebRtcTransport.DtlsParameters
0fingerprints[FBS.WebRtcTransport.Fingerprint] (4 bytes)required
1rolestring (4 bytes)optional
> - ]; - decl187:p0:e -> decl186:name [color = "#d67331"]; - - decl188[ label=< - - - - - - - - - - - - - - - - - - - - - -
table FBS.WebRtcTransport.IceParameters
0username_fragmentstring (4 bytes)required
1passwordstring (4 bytes)required
2ice_litebool (1 bytes)default true
> - ]; - - decl189[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.WebRtcTransport.IceCandidate
0foundationstring (4 bytes)required
1priorityuint32 (4 bytes)default 0
2ipstring (4 bytes)required
3protocolstring (4 bytes)required
4portuint16 (2 bytes)default 0
5typestring (4 bytes)optional
6tcp_typestring (4 bytes)optional
> - ]; - - decl190[ label=< - - - - - - - - - -
table FBS.WebRtcTransport.ConnectRequest
0dtls_parametersFBS.WebRtcTransport.DtlsParameters (4 bytes)required
> - ]; - decl190:p0:e -> decl187:name [color = "#f40ec2"]; - - decl191[ label=< - - - - - - - - - -
table FBS.WebRtcTransport.ConnectResponse
0dtls_local_rolestring (4 bytes)required
> - ]; - - decl192[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.WebRtcTransport.DumpResponse
0baseFBS.Transport.Dump (4 bytes)required
1ice_rolestring (4 bytes)required
2ice_parametersFBS.WebRtcTransport.IceParameters (4 bytes)required
3ice_candidates[FBS.WebRtcTransport.IceCandidate] (4 bytes)required
4ice_statestring (4 bytes)required
5ice_selected_tupleFBS.Transport.Tuple (4 bytes)optional
6dtls_parametersFBS.WebRtcTransport.DtlsParameters (4 bytes)required
7dtls_statestring (4 bytes)required
> - ]; - decl192:p0:e -> decl101:name [color = "#db5e8a"]; - decl192:p2:e -> decl188:name [color = "#8fc629"]; - decl192:p3:e -> decl189:name [color = "#6b1add"]; - decl192:p5:e -> decl97:name [color = "#8d18e0"]; - decl192:p6:e -> decl187:name [color = "#489b0c"]; - - decl193[ label=< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
table FBS.WebRtcTransport.GetStatsResponse
0baseFBS.Transport.Stats (4 bytes)required
1ice_rolestring (4 bytes)required
2ice_statestring (4 bytes)required
3ice_selected_tupleFBS.Transport.Tuple (4 bytes)optional
4dtls_statestring (4 bytes)required
> - ]; - decl193:p0:e -> decl103:name [color = "#2cf209"]; - decl193:p3:e -> decl97:name [color = "#f411d6"]; - - decl194[ label=< - - - - - - - - - -
table FBS.WebRtcTransport.IceSelectedTupleChangeNotification
0tupleFBS.Transport.Tuple (4 bytes)required
> - ]; - decl194:p0:e -> decl97:name [color = "#9ed84b"]; - - decl195[ label=< - - - - - - - - - - - - - - - - - - - - - - - - -
enum FBS.WebRtcTransport.IceState : uint8
NEW0
CONNECTED1
COMPLETED2
DISCONNECTED3
CLOSED4
> - ]; - - decl196[ label=< - - - - - - - - - - - - - - - - - - - - - - - - -
enum FBS.WebRtcTransport.DtlsState : uint8
NEW0
CONNECTING1
CONNECTED2
FAILED3
CLOSED4
> - ]; - - decl197[ label=< - - - - - - - - - -
table FBS.WebRtcTransport.IceStateChangeNotification
0ice_stateFBS.WebRtcTransport.IceState (1 bytes)default NEW
> - ]; - decl197:p0:e -> decl195:name [color = "#32d3c0"]; - - decl198[ label=< - - - - - - - - - - - - - - - -
table FBS.WebRtcTransport.DtlsStateChangeNotification
0dtls_stateFBS.WebRtcTransport.DtlsState (1 bytes)default NEW
1remote_certstring (4 bytes)optional
> - ]; - decl198:p0:e -> decl196:name [color = "#f756ef"]; - - decl199[ label=< - - - - - - - - - -
table FBS.RtpObserver.AddProducerRequest
0producer_idstring (4 bytes)required
> - ]; - - decl200[ label=< - - - - - - - - - -
table FBS.RtpObserver.RemoveProducerRequest
0producer_idstring (4 bytes)required
> - ]; -} \ No newline at end of file From da152f778fa34f60544595d30182995412670438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 13 Jul 2023 13:11:09 +0200 Subject: [PATCH 09/73] rust: disable tests for unimplemented code And enable 'cargo test' workflow in GH actions. --- .github/workflows/mediasoup-rust.yaml | 14 ++++++------- rust/src/router.rs | 21 +++++++++++++++++++ .../router/active_speaker_observer/tests.rs | 1 + rust/src/router/audio_level_observer/tests.rs | 1 + rust/src/router/consumer/tests.rs | 2 ++ rust/src/router/data_consumer/tests.rs | 2 ++ rust/src/router/data_producer/tests.rs | 1 + rust/src/router/direct_transport/tests.rs | 1 + rust/src/router/pipe_transport/tests.rs | 2 ++ rust/src/router/plain_transport/tests.rs | 1 + rust/src/router/producer/tests.rs | 1 + rust/src/router/webrtc_transport/tests.rs | 3 +++ .../integration/active_speaker_observer.rs | 5 +++++ .../tests/integration/audio_level_observer.rs | 5 +++++ rust/tests/integration/consumer.rs | 12 +++++++++++ rust/tests/integration/data_consumer.rs | 8 +++++++ rust/tests/integration/data_producer.rs | 8 +++++++ rust/tests/integration/direct_transport.rs | 1 + rust/tests/integration/multiopus.rs | 3 +++ rust/tests/integration/pipe_transport.rs | 13 ++++++++++++ rust/tests/integration/plain_transport.rs | 9 ++++++++ rust/tests/integration/producer.rs | 12 +++++++++++ rust/tests/integration/smoke.rs | 1 + rust/tests/integration/webrtc_transport.rs | 14 +++++++++++++ 24 files changed, 134 insertions(+), 7 deletions(-) diff --git a/.github/workflows/mediasoup-rust.yaml b/.github/workflows/mediasoup-rust.yaml index 5dadcf2d6c..e3304d29a7 100644 --- a/.github/workflows/mediasoup-rust.yaml +++ b/.github/workflows/mediasoup-rust.yaml @@ -47,10 +47,10 @@ jobs: command: clippy args: --all-targets -- -D warnings - #- name: cargo test - # uses: actions-rs/cargo@v1 - # env: - # KEEP_BUILD_ARTIFACTS: '1' - # with: - # command: test - # args: --verbose + - name: cargo test + uses: actions-rs/cargo@v1 + env: + KEEP_BUILD_ARTIFACTS: '1' + with: + command: test + args: --verbose diff --git a/rust/src/router.rs b/rust/src/router.rs index 5c08cb0d8a..d843c3fd31 100644 --- a/rust/src/router.rs +++ b/rust/src/router.rs @@ -606,6 +606,9 @@ impl Router { /// protocol: Protocol::Udp, /// ip: IpAddr::V4(Ipv4Addr::LOCALHOST), /// announced_ip: Some("9.9.9.1".parse().unwrap()), + /// port: None, + /// send_buffer_size: None, + /// recv_buffer_size: None, /// }, /// ))) /// .await?; @@ -671,6 +674,9 @@ impl Router { /// protocol: Protocol::Udp, /// ip: IpAddr::V4(Ipv4Addr::LOCALHOST), /// announced_ip: Some("9.9.9.1".parse().unwrap()), + /// port: None, + /// send_buffer_size: None, + /// recv_buffer_size: None, /// })) /// .await?; /// # Ok(()) @@ -733,6 +739,9 @@ impl Router { /// protocol: Protocol::Udp, /// ip: IpAddr::V4(Ipv4Addr::LOCALHOST), /// announced_ip: Some("9.9.9.1".parse().unwrap()), + /// port: None, + /// send_buffer_size: None, + /// recv_buffer_size: None, /// })) /// .await?; /// # Ok(()) @@ -940,6 +949,9 @@ impl Router { /// protocol: Protocol::Udp, /// ip: IpAddr::V4(Ipv4Addr::LOCALHOST), /// announced_ip: Some("9.9.9.1".parse().unwrap()), + /// port: None, + /// send_buffer_size: None, + /// recv_buffer_size: None, /// }, /// ))) /// .await?; @@ -979,6 +991,9 @@ impl Router { /// protocol: Protocol::Udp, /// ip: IpAddr::V4(Ipv4Addr::LOCALHOST), /// announced_ip: Some("9.9.9.1".parse().unwrap()), + /// port: None, + /// send_buffer_size: None, + /// recv_buffer_size: None, /// }, /// ))) /// .await?; @@ -1161,6 +1176,9 @@ impl Router { /// protocol: Protocol::Udp, /// ip: IpAddr::V4(Ipv4Addr::LOCALHOST), /// announced_ip: Some("9.9.9.1".parse().unwrap()), + /// port: None, + /// send_buffer_size: None, + /// recv_buffer_size: None, /// }, /// )); /// options.enable_sctp = true; @@ -1189,6 +1207,9 @@ impl Router { /// protocol: Protocol::Udp, /// ip: IpAddr::V4(Ipv4Addr::LOCALHOST), /// announced_ip: Some("9.9.9.1".parse().unwrap()), + /// port: None, + /// send_buffer_size: None, + /// recv_buffer_size: None, /// }, /// )); /// options.enable_sctp = true; diff --git a/rust/src/router/active_speaker_observer/tests.rs b/rust/src/router/active_speaker_observer/tests.rs index 2493a8f133..4eb3acb31b 100644 --- a/rust/src/router/active_speaker_observer/tests.rs +++ b/rust/src/router/active_speaker_observer/tests.rs @@ -24,6 +24,7 @@ async fn init() -> Worker { } #[test] +#[ignore] fn router_close_event() { future::block_on(async move { let worker = init().await; diff --git a/rust/src/router/audio_level_observer/tests.rs b/rust/src/router/audio_level_observer/tests.rs index f2f3465e55..a7ba2a0db0 100644 --- a/rust/src/router/audio_level_observer/tests.rs +++ b/rust/src/router/audio_level_observer/tests.rs @@ -24,6 +24,7 @@ async fn init() -> Worker { } #[test] +#[ignore] fn router_close_event() { future::block_on(async move { let worker = init().await; diff --git a/rust/src/router/consumer/tests.rs b/rust/src/router/consumer/tests.rs index 8f4fe2a74a..bc2d6d8a11 100644 --- a/rust/src/router/consumer/tests.rs +++ b/rust/src/router/consumer/tests.rs @@ -105,6 +105,7 @@ async fn init() -> (Router, WebRtcTransport, WebRtcTransport) { } #[test] +#[ignore] fn producer_close_event() { future::block_on(async move { let (_router, transport_1, transport_2) = init().await; @@ -145,6 +146,7 @@ fn producer_close_event() { } #[test] +#[ignore] fn transport_close_event() { future::block_on(async move { let (router, transport_1, transport_2) = init().await; diff --git a/rust/src/router/data_consumer/tests.rs b/rust/src/router/data_consumer/tests.rs index 7ef9a80588..f9438befed 100644 --- a/rust/src/router/data_consumer/tests.rs +++ b/rust/src/router/data_consumer/tests.rs @@ -63,6 +63,7 @@ async fn init() -> (Router, DataProducer) { } #[test] +#[ignore] fn data_producer_close_event() { future::block_on(async move { let (router, data_producer) = init().await; @@ -116,6 +117,7 @@ fn data_producer_close_event() { } #[test] +#[ignore] fn transport_close_event() { future::block_on(async move { let (router, data_producer) = init().await; diff --git a/rust/src/router/data_producer/tests.rs b/rust/src/router/data_producer/tests.rs index 3bbb34db02..968213f8da 100644 --- a/rust/src/router/data_producer/tests.rs +++ b/rust/src/router/data_producer/tests.rs @@ -56,6 +56,7 @@ async fn init() -> (Router, WebRtcTransport) { } #[test] +#[ignore] fn transport_close_event() { future::block_on(async move { let (router, transport1) = init().await; diff --git a/rust/src/router/direct_transport/tests.rs b/rust/src/router/direct_transport/tests.rs index 5e19ed6fc8..61b75926e3 100644 --- a/rust/src/router/direct_transport/tests.rs +++ b/rust/src/router/direct_transport/tests.rs @@ -36,6 +36,7 @@ async fn init() -> (Router, DirectTransport) { } #[test] +#[ignore] fn router_close_event() { future::block_on(async move { let (router, transport) = init().await; diff --git a/rust/src/router/pipe_transport/tests.rs b/rust/src/router/pipe_transport/tests.rs index 54a1f22a48..ab93ff3097 100644 --- a/rust/src/router/pipe_transport/tests.rs +++ b/rust/src/router/pipe_transport/tests.rs @@ -122,6 +122,7 @@ async fn init() -> (Router, Router, WebRtcTransport, WebRtcTransport) { } #[test] +#[ignore] fn producer_close_is_transmitted_to_pipe_consumer() { future::block_on(async move { let (router1, router2, transport1, transport2) = init().await; @@ -161,6 +162,7 @@ fn producer_close_is_transmitted_to_pipe_consumer() { } #[test] +#[ignore] fn data_producer_close_is_transmitted_to_pipe_data_consumer() { future::block_on(async move { let (router1, router2, transport1, transport2) = init().await; diff --git a/rust/src/router/plain_transport/tests.rs b/rust/src/router/plain_transport/tests.rs index fcff706c5f..dcd29c636d 100644 --- a/rust/src/router/plain_transport/tests.rs +++ b/rust/src/router/plain_transport/tests.rs @@ -31,6 +31,7 @@ async fn init() -> Router { } #[test] +#[ignore] fn router_close_event() { future::block_on(async move { let router = init().await; diff --git a/rust/src/router/producer/tests.rs b/rust/src/router/producer/tests.rs index 92533c3c32..49ed0da09f 100644 --- a/rust/src/router/producer/tests.rs +++ b/rust/src/router/producer/tests.rs @@ -85,6 +85,7 @@ async fn init() -> (Router, WebRtcTransport) { } #[test] +#[ignore] fn transport_close_event() { future::block_on(async move { let (router, transport_1) = init().await; diff --git a/rust/src/router/webrtc_transport/tests.rs b/rust/src/router/webrtc_transport/tests.rs index 7502ef38c9..deb8f1f6dd 100644 --- a/rust/src/router/webrtc_transport/tests.rs +++ b/rust/src/router/webrtc_transport/tests.rs @@ -41,6 +41,7 @@ async fn init() -> (Worker, Router) { } #[test] +#[ignore] fn create_with_webrtc_server_succeeds() { future::block_on(async move { let (worker, router) = init().await; @@ -212,6 +213,7 @@ fn create_with_webrtc_server_succeeds() { } #[test] +#[ignore] fn router_close_event() { future::block_on(async move { let (_worker, router) = init().await; @@ -250,6 +252,7 @@ fn router_close_event() { } #[test] +#[ignore] fn webrtc_server_close_event() { future::block_on(async move { let (worker, router) = init().await; diff --git a/rust/tests/integration/active_speaker_observer.rs b/rust/tests/integration/active_speaker_observer.rs index 65d317d9ec..70c3ebac88 100644 --- a/rust/tests/integration/active_speaker_observer.rs +++ b/rust/tests/integration/active_speaker_observer.rs @@ -44,6 +44,7 @@ async fn init() -> Worker { } #[test] +#[ignore] fn create() { future::block_on(async move { let worker = init().await; @@ -84,6 +85,7 @@ fn create() { } #[test] +#[ignore] fn weak() { future::block_on(async move { let worker = init().await; @@ -109,6 +111,7 @@ fn weak() { } #[test] +#[ignore] fn pause_resume() { future::block_on(async move { let worker = init().await; @@ -138,6 +141,7 @@ fn pause_resume() { } #[test] +#[ignore] fn close_event() { future::block_on(async move { let worker = init().await; @@ -163,6 +167,7 @@ fn close_event() { } #[test] +#[ignore] fn drop_test() { future::block_on(async move { let worker = init().await; diff --git a/rust/tests/integration/audio_level_observer.rs b/rust/tests/integration/audio_level_observer.rs index 702f2f8e64..1debee206d 100644 --- a/rust/tests/integration/audio_level_observer.rs +++ b/rust/tests/integration/audio_level_observer.rs @@ -44,6 +44,7 @@ async fn init() -> Worker { } #[test] +#[ignore] fn create() { future::block_on(async move { let worker = init().await; @@ -84,6 +85,7 @@ fn create() { } #[test] +#[ignore] fn weak() { future::block_on(async move { let worker = init().await; @@ -109,6 +111,7 @@ fn weak() { } #[test] +#[ignore] fn pause_resume() { future::block_on(async move { let worker = init().await; @@ -135,6 +138,7 @@ fn pause_resume() { } #[test] +#[ignore] fn close_event() { future::block_on(async move { let worker = init().await; @@ -160,6 +164,7 @@ fn close_event() { } #[test] +#[ignore] fn drop_test() { future::block_on(async move { let worker = init().await; diff --git a/rust/tests/integration/consumer.rs b/rust/tests/integration/consumer.rs index 7ebb7e9ba0..b0be538762 100644 --- a/rust/tests/integration/consumer.rs +++ b/rust/tests/integration/consumer.rs @@ -372,6 +372,7 @@ async fn init() -> ( } #[test] +#[ignore] fn consume_succeeds() { future::block_on(async move { let (_executor_guard, _worker, router, transport_1, transport_2) = init().await; @@ -706,6 +707,7 @@ fn consume_succeeds() { } #[test] +#[ignore] fn consume_with_enable_rtx_succeeds() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -749,6 +751,7 @@ fn consume_with_enable_rtx_succeeds() { } #[test] +#[ignore] fn consumer_with_user_defined_mid() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -802,6 +805,7 @@ fn consumer_with_user_defined_mid() { } #[test] +#[ignore] fn weak() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -832,6 +836,7 @@ fn weak() { } #[test] +#[ignore] fn consume_incompatible_rtp_capabilities() { future::block_on(async move { let (_executor_guard, _worker, router, transport_1, transport_2) = init().await; @@ -889,6 +894,7 @@ fn consume_incompatible_rtp_capabilities() { } #[test] +#[ignore] fn dump_succeeds() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -1134,6 +1140,7 @@ fn dump_succeeds() { } #[test] +#[ignore] fn get_stats_succeeds() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -1230,6 +1237,7 @@ fn get_stats_succeeds() { } #[test] +#[ignore] fn pause_resume_succeeds() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -1272,6 +1280,7 @@ fn pause_resume_succeeds() { } #[test] +#[ignore] fn set_preferred_layers_succeeds() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -1343,6 +1352,7 @@ fn set_preferred_layers_succeeds() { } #[test] +#[ignore] fn set_unset_priority_succeeds() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -1383,6 +1393,7 @@ fn set_unset_priority_succeeds() { } #[test] +#[ignore] fn producer_pause_resume_events() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -1441,6 +1452,7 @@ fn producer_pause_resume_events() { } #[test] +#[ignore] fn close_event() { future::block_on(async move { let (_executor_guard, _worker, router, transport_1, transport_2) = init().await; diff --git a/rust/tests/integration/data_consumer.rs b/rust/tests/integration/data_consumer.rs index 30b3688279..85eaaf6a42 100644 --- a/rust/tests/integration/data_consumer.rs +++ b/rust/tests/integration/data_consumer.rs @@ -88,6 +88,7 @@ async fn init() -> (Worker, Router, WebRtcTransport, DataProducer) { } #[test] +#[ignore] fn consume_data_succeeds() { future::block_on(async move { let (_worker, router, _transport1, data_producer) = init().await; @@ -191,6 +192,7 @@ fn consume_data_succeeds() { } #[test] +#[ignore] fn weak() { future::block_on(async move { let (_worker, router, _transport1, data_producer) = init().await; @@ -238,6 +240,7 @@ fn weak() { } #[test] +#[ignore] fn dump_succeeds() { future::block_on(async move { let (_worker, _router, transport, data_producer) = init().await; @@ -284,6 +287,7 @@ fn dump_succeeds() { } #[test] +#[ignore] fn get_stats_succeeds() { future::block_on(async move { let (_worker, _router, transport, data_producer) = init().await; @@ -316,6 +320,7 @@ fn get_stats_succeeds() { } #[test] +#[ignore] fn consume_data_on_direct_transport_succeeds() { future::block_on(async move { let (_worker, router, _transport1, data_producer) = init().await; @@ -375,6 +380,7 @@ fn consume_data_on_direct_transport_succeeds() { } #[test] +#[ignore] fn dump_on_direct_transport_succeeds() { future::block_on(async move { let (_worker, router, _transport1, data_producer) = init().await; @@ -410,6 +416,7 @@ fn dump_on_direct_transport_succeeds() { } #[test] +#[ignore] fn get_stats_on_direct_transport_succeeds() { future::block_on(async move { let (_worker, router, _transport1, data_producer) = init().await; @@ -444,6 +451,7 @@ fn get_stats_on_direct_transport_succeeds() { } #[test] +#[ignore] fn close_event() { future::block_on(async move { let (_worker, router, _transport1, data_producer) = init().await; diff --git a/rust/tests/integration/data_producer.rs b/rust/tests/integration/data_producer.rs index e753ff5eb5..ebcaf59f63 100644 --- a/rust/tests/integration/data_producer.rs +++ b/rust/tests/integration/data_producer.rs @@ -87,6 +87,7 @@ async fn init() -> (Worker, Router, WebRtcTransport, PlainTransport) { } #[test] +#[ignore] fn transport_1_produce_data_succeeds() { future::block_on(async move { let (_worker, router, transport1, _transport2) = init().await; @@ -164,6 +165,7 @@ fn transport_1_produce_data_succeeds() { } #[test] +#[ignore] fn transport_2_produce_data_succeeds() { future::block_on(async move { let (_worker, router, _transport1, transport2) = init().await; @@ -243,6 +245,7 @@ fn transport_2_produce_data_succeeds() { } #[test] +#[ignore] fn weak() { future::block_on(async move { let (_worker, _router, transport1, _transport2) = init().await; @@ -272,6 +275,7 @@ fn weak() { } #[test] +#[ignore] fn produce_data_used_stream_id_rejects() { future::block_on(async move { let (_worker, _router, transport1, _transport2) = init().await; @@ -295,6 +299,7 @@ fn produce_data_used_stream_id_rejects() { } #[test] +#[ignore] fn dump_succeeds() { future::block_on(async move { let (_worker, _router, transport1, transport2) = init().await; @@ -374,6 +379,7 @@ fn dump_succeeds() { } #[test] +#[ignore] fn get_stats_succeeds() { future::block_on(async move { let (_worker, _router, transport1, transport2) = init().await; @@ -436,6 +442,7 @@ fn get_stats_succeeds() { } #[test] +#[ignore] fn pause_and_resume_succeed() { future::block_on(async move { let (_worker, _router, transport1, _) = init().await; @@ -491,6 +498,7 @@ fn pause_and_resume_succeed() { } #[test] +#[ignore] fn close_event() { future::block_on(async move { let (_worker, router, transport1, _transport2) = init().await; diff --git a/rust/tests/integration/direct_transport.rs b/rust/tests/integration/direct_transport.rs index 5b3100f94d..03de1a2cec 100644 --- a/rust/tests/integration/direct_transport.rs +++ b/rust/tests/integration/direct_transport.rs @@ -157,6 +157,7 @@ fn get_stats_succeeds() { } #[test] +#[ignore] fn send_succeeds() { future::block_on(async move { let (_worker, _router, transport) = init().await; diff --git a/rust/tests/integration/multiopus.rs b/rust/tests/integration/multiopus.rs index 650b450cd0..30e613c1e9 100644 --- a/rust/tests/integration/multiopus.rs +++ b/rust/tests/integration/multiopus.rs @@ -148,6 +148,7 @@ async fn init() -> (Router, WebRtcTransport) { } #[test] +#[ignore] fn produce_and_consume_succeeds() { future::block_on(async move { let (router, transport) = init().await; @@ -206,6 +207,7 @@ fn produce_and_consume_succeeds() { } #[test] +#[ignore] fn fails_to_consume_wrong_parameters() { future::block_on(async move { let (_router, transport) = init().await; @@ -259,6 +261,7 @@ fn fails_to_consume_wrong_parameters() { } #[test] +#[ignore] fn fails_to_consume_wrong_channels() { future::block_on(async move { let (router, transport) = init().await; diff --git a/rust/tests/integration/pipe_transport.rs b/rust/tests/integration/pipe_transport.rs index 242c37a483..985e2d1b7b 100644 --- a/rust/tests/integration/pipe_transport.rs +++ b/rust/tests/integration/pipe_transport.rs @@ -280,6 +280,7 @@ async fn init() -> ( } #[test] +#[ignore] fn pipe_to_router_succeeds_with_audio() { future::block_on(async move { let (_worker1, _worker2, router1, router2, transport1, _transport2) = init().await; @@ -401,6 +402,7 @@ fn pipe_to_router_succeeds_with_audio() { } #[test] +#[ignore] fn pipe_to_router_succeeds_with_video() { future::block_on(async move { let (_worker1, _worker2, router1, router2, transport1, _transport2) = init().await; @@ -561,6 +563,7 @@ fn pipe_to_router_succeeds_with_video() { } #[test] +#[ignore] fn pipe_to_router_fails_if_both_routers_belong_to_the_same_worker() { future::block_on(async move { let (worker1, _worker2, router1, _router2, transport1, _transport2) = init().await; @@ -594,6 +597,7 @@ fn pipe_to_router_fails_if_both_routers_belong_to_the_same_worker() { } #[test] +#[ignore] fn weak() { future::block_on(async move { let (_worker1, _worker2, router1, _router2, _transport1, _transport2) = init().await; @@ -626,6 +630,7 @@ fn weak() { } #[test] +#[ignore] fn create_with_fixed_port_succeeds() { future::block_on(async move { let (_worker1, _worker2, router1, _router2, _transport1, _transport2) = init().await; @@ -651,6 +656,7 @@ fn create_with_fixed_port_succeeds() { } #[test] +#[ignore] fn create_with_enable_rtx_succeeds() { future::block_on(async move { let (_worker1, _worker2, router1, _router2, transport1, _transport2) = init().await; @@ -763,6 +769,7 @@ fn create_with_enable_rtx_succeeds() { } #[test] +#[ignore] fn create_with_enable_srtp_succeeds() { future::block_on(async move { let (_worker1, _worker2, router1, _router2, _transport1, _transport2) = init().await; @@ -819,6 +826,7 @@ fn create_with_enable_srtp_succeeds() { } #[test] +#[ignore] fn create_with_invalid_srtp_parameters_fails() { future::block_on(async move { let (_worker1, _worker2, router1, _router2, _transport1, _transport2) = init().await; @@ -854,6 +862,7 @@ fn create_with_invalid_srtp_parameters_fails() { } #[test] +#[ignore] fn consume_for_pipe_producer_succeeds() { future::block_on(async move { let (_worker1, _worker2, router1, router2, transport1, transport2) = init().await; @@ -944,6 +953,7 @@ fn consume_for_pipe_producer_succeeds() { } #[test] +#[ignore] fn producer_pause_resume_are_transmitted_to_pipe_consumer() { future::block_on(async move { let (_worker1, _worker2, router1, router2, transport1, transport2) = init().await; @@ -1024,6 +1034,7 @@ fn producer_pause_resume_are_transmitted_to_pipe_consumer() { } #[test] +#[ignore] fn pipe_to_router_succeeds_with_data() { future::block_on(async move { let (_worker1, _worker2, router1, router2, transport1, _transport2) = init().await; @@ -1096,6 +1107,7 @@ fn pipe_to_router_succeeds_with_data() { } #[test] +#[ignore] fn data_consume_for_pipe_data_producer_succeeds() { future::block_on(async move { let (_worker1, _worker2, router1, router2, transport1, transport2) = init().await; @@ -1135,6 +1147,7 @@ fn data_consume_for_pipe_data_producer_succeeds() { } #[test] +#[ignore] fn pipe_to_router_called_twice_generates_single_pair() { future::block_on(async move { let (worker1, worker2, _router1, _router2, _transport1, _transport2) = init().await; diff --git a/rust/tests/integration/plain_transport.rs b/rust/tests/integration/plain_transport.rs index 761d102be9..3ac40d9bf8 100644 --- a/rust/tests/integration/plain_transport.rs +++ b/rust/tests/integration/plain_transport.rs @@ -82,6 +82,7 @@ async fn init() -> (Worker, Router) { } #[test] +#[ignore] fn create_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -269,6 +270,7 @@ fn create_succeeds() { } #[test] +#[ignore] fn create_with_fixed_port_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -294,6 +296,7 @@ fn create_with_fixed_port_succeeds() { } #[test] +#[ignore] fn weak() { future::block_on(async move { let (_worker, router) = init().await; @@ -326,6 +329,7 @@ fn weak() { } #[test] +#[ignore] fn create_enable_srtp_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -392,6 +396,7 @@ fn create_enable_srtp_succeeds() { } #[test] +#[ignore] fn create_non_bindable_ip() { future::block_on(async move { let (_worker, router) = init().await; @@ -413,6 +418,7 @@ fn create_non_bindable_ip() { } #[test] +#[ignore] fn get_stats_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -473,6 +479,7 @@ fn get_stats_succeeds() { } #[test] +#[ignore] fn connect_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -548,6 +555,7 @@ fn connect_succeeds() { } #[test] +#[ignore] fn connect_wrong_arguments() { future::block_on(async move { let (_worker, router) = init().await; @@ -588,6 +596,7 @@ fn connect_wrong_arguments() { } #[test] +#[ignore] fn close_event() { future::block_on(async move { let (_worker, router) = init().await; diff --git a/rust/tests/integration/producer.rs b/rust/tests/integration/producer.rs index f0055301dc..9ccf443b31 100644 --- a/rust/tests/integration/producer.rs +++ b/rust/tests/integration/producer.rs @@ -225,6 +225,7 @@ async fn init() -> (Worker, Router, WebRtcTransport, WebRtcTransport) { } #[test] +#[ignore] fn produce_succeeds_1() { future::block_on(async move { let (_worker, router, transport_1, _transport_2) = init().await; @@ -305,6 +306,7 @@ fn produce_succeeds_1() { } #[test] +#[ignore] fn produce_succeeds_2() { future::block_on(async move { let (_worker, router, _transport_1, transport_2) = init().await; @@ -372,6 +374,7 @@ fn produce_succeeds_2() { } #[test] +#[ignore] fn weak() { future::block_on(async move { let (_worker, _router, transport_1, _transport_2) = init().await; @@ -392,6 +395,7 @@ fn weak() { } #[test] +#[ignore] fn produce_wrong_arguments() { future::block_on(async move { let (_worker, _router, transport_1, _transport_2) = init().await; @@ -494,6 +498,7 @@ fn produce_wrong_arguments() { } #[test] +#[ignore] fn produce_unsupported_codecs() { future::block_on(async move { let (_worker, _router, transport_1, _transport_2) = init().await; @@ -571,6 +576,7 @@ fn produce_unsupported_codecs() { } #[test] +#[ignore] fn produce_already_used_mid_ssrc() { future::block_on(async move { let (_worker, _router, transport_1, transport_2) = init().await; @@ -642,6 +648,7 @@ fn produce_already_used_mid_ssrc() { } #[test] +#[ignore] fn produce_no_mid_single_encoding_without_dir_or_ssrc() { future::block_on(async move { let (_worker, _router, transport_1, _transport_2) = init().await; @@ -672,6 +679,7 @@ fn produce_no_mid_single_encoding_without_dir_or_ssrc() { } #[test] +#[ignore] fn dump_succeeds() { future::block_on(async move { let (_worker, _router, transport_1, transport_2) = init().await; @@ -785,6 +793,7 @@ fn dump_succeeds() { } #[test] +#[ignore] fn get_stats_succeeds() { future::block_on(async move { let (_worker, _router, transport_1, transport_2) = init().await; @@ -820,6 +829,7 @@ fn get_stats_succeeds() { } #[test] +#[ignore] fn pause_resume_succeeds() { future::block_on(async move { let (_worker, _router, transport_1, _transport_2) = init().await; @@ -864,6 +874,7 @@ fn pause_resume_succeeds() { } #[test] +#[ignore] fn enable_trace_event_succeeds() { future::block_on(async move { let (_worker, _router, transport_1, _transport_2) = init().await; @@ -907,6 +918,7 @@ fn enable_trace_event_succeeds() { } #[test] +#[ignore] fn close_event() { future::block_on(async move { let (_worker, router, transport_1, _transport_2) = init().await; diff --git a/rust/tests/integration/smoke.rs b/rust/tests/integration/smoke.rs index 2f1a46f658..8932aef4c9 100644 --- a/rust/tests/integration/smoke.rs +++ b/rust/tests/integration/smoke.rs @@ -35,6 +35,7 @@ fn init() { } #[test] +#[ignore] fn smoke() { init(); diff --git a/rust/tests/integration/webrtc_transport.rs b/rust/tests/integration/webrtc_transport.rs index ccb811cd6f..21c562bf2f 100644 --- a/rust/tests/integration/webrtc_transport.rs +++ b/rust/tests/integration/webrtc_transport.rs @@ -88,6 +88,7 @@ async fn init() -> (Worker, Router) { } #[test] +#[ignore] fn create_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -266,6 +267,7 @@ fn create_succeeds() { } #[test] +#[ignore] fn create_with_fixed_port_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -291,6 +293,7 @@ fn create_with_fixed_port_succeeds() { } #[test] +#[ignore] fn weak() { future::block_on(async move { let (_worker, router) = init().await; @@ -320,6 +323,7 @@ fn weak() { } #[test] +#[ignore] fn create_non_bindable_ip() { future::block_on(async move { let (_worker, router) = init().await; @@ -343,6 +347,7 @@ fn create_non_bindable_ip() { } #[test] +#[ignore] fn get_stats_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -394,6 +399,7 @@ fn get_stats_succeeds() { } #[test] +#[ignore] fn connect_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -443,6 +449,7 @@ fn connect_succeeds() { } #[test] +#[ignore] fn set_max_incoming_bitrate_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -475,6 +482,7 @@ fn set_max_incoming_bitrate_succeeds() { } #[test] +#[ignore] fn set_max_outgoing_bitrate_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -507,6 +515,7 @@ fn set_max_outgoing_bitrate_succeeds() { } #[test] +#[ignore] fn set_min_outgoing_bitrate_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -539,6 +548,7 @@ fn set_min_outgoing_bitrate_succeeds() { } #[test] +#[ignore] fn set_max_outgoing_bitrate_fails_if_value_is_lower_than_current_min_limit() { future::block_on(async move { let (_worker, router) = init().await; @@ -576,6 +586,7 @@ fn set_max_outgoing_bitrate_fails_if_value_is_lower_than_current_min_limit() { } #[test] +#[ignore] fn set_min_outgoing_bitrate_fails_if_value_is_higher_than_current_max_limit() { future::block_on(async move { let (_worker, router) = init().await; @@ -613,6 +624,7 @@ fn set_min_outgoing_bitrate_fails_if_value_is_higher_than_current_max_limit() { } #[test] +#[ignore] fn restart_ice_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -648,6 +660,7 @@ fn restart_ice_succeeds() { } #[test] +#[ignore] fn enable_trace_event_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -714,6 +727,7 @@ fn enable_trace_event_succeeds() { } #[test] +#[ignore] fn close_event() { future::block_on(async move { let (_worker, router) = init().await; From 8b23595a43fac6ac8d2c8e10b648b9cdf7ab67fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Thu, 13 Jul 2023 17:18:05 +0200 Subject: [PATCH 10/73] cosmetic --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fc31878be..70d83d9cf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ * Add pause/resume API in `DataProducer` and `DataConsumer` ([PR #1104](https://github.com/versatica/mediasoup/pull/1104)). * `Worker`: Add `Transport::Destroying()` protected method ([PR #1114](https://github.com/versatica/mediasoup/pull/1114)). * `RtpStreamRecv`: Fix jitter calculation ([PR #1117](https://github.com/versatica/mediasoup/pull/1117), thanks to @penguinol). -* Revert "Node: make types.ts only export types rather than the entire class/code" ([PR #1109](https://github.com/versatica/mediasoup/pull/1109)) because it requires `typescript` >= 5 in the apps that import mediasoup and we don't want to be that strict yet. +* Revert "Node: make `types.ts` only export types rather than the entire class/code" ([PR #1109](https://github.com/versatica/mediasoup/pull/1109)) because it requires `typescript` >= 5 in the apps that import mediasoup and we don't want to be that strict yet. ### 3.12.5 From 40379354cb60634c4051f5c2a9657b5964211aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Mon, 17 Jul 2023 14:13:08 +0200 Subject: [PATCH 11/73] Fix DirectTransport test when using pause/resume() As explained in https://github.com/versatica/mediasoup/pull/1064#issuecomment-1637902087 and messages below it --- node/src/tests/test-DirectTransport.ts | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/node/src/tests/test-DirectTransport.ts b/node/src/tests/test-DirectTransport.ts index adffb2e06c..f495b4004f 100644 --- a/node/src/tests/test-DirectTransport.ts +++ b/node/src/tests/test-DirectTransport.ts @@ -132,10 +132,14 @@ test('dataProducer.send() succeeds', async () => let lastSentMessageId = 0; let lastRecvMessageId = 0; - await new Promise((resolve) => + // eslint-disable-next-line no-async-promise-executor + await new Promise(async (resolve) => { // Send messages over the sctpSendStream created above. - const interval = setInterval(() => + + sendNextMessage(); + + async function sendNextMessage() { const id = ++lastSentMessageId; let ppid; @@ -143,19 +147,19 @@ test('dataProducer.send() succeeds', async () => if (id === pauseSendingAtMessage) { - dataProducer.pause(); + await dataProducer.pause(); } else if (id === resumeSendingAtMessage) { - dataProducer.resume(); + await dataProducer.resume(); } else if (id === pauseReceivingAtMessage) { - dataConsumer.pause(); + await dataConsumer.pause(); } else if (id === resumeReceivingAtMessage) { - dataConsumer.resume(); + await dataConsumer.resume(); } // Send string (WebRTC DataChannel string). @@ -180,11 +184,11 @@ test('dataProducer.send() succeeds', async () => effectivelySentMessageBytes += messageSize; } - if (id === numMessages) + if (id < numMessages) { - clearInterval(interval); + sendNextMessage(); } - }, 0); + } dataConsumer.on('message', (message, ppid) => { @@ -195,7 +199,6 @@ test('dataProducer.send() succeeds', async () => if (id === numMessages) { - clearInterval(interval); resolve(); } From 39d2b1e10421745219ba73fa55a050a2767432d2 Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Sun, 30 Jul 2023 23:58:07 +0300 Subject: [PATCH 12/73] Update planus and re-generate types --- rust/Cargo.toml | 2 +- rust/src/fbs.rs | 43466 +++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 38795 insertions(+), 4673 deletions(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 8b1755d7fe..1760125b11 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -35,7 +35,7 @@ hash_hasher = "2.0.3" log = "0.4.17" nohash-hasher = "0.2.0" once_cell = "1.16.0" -planus = "0.3.1" +planus = "0.4.0" serde_json = "1.0.87" serde_repr = "0.1.9" thiserror = "1.0.37" diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index d8d4f1dee1..b7cc195bd0 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -1,14 +1,30 @@ //! Flatbuffers data structures compiled from `.fbs` files pub use root::fbs::*; -const _: () = ::planus::check_version_compatibility("planus-0.3.1"); +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, @@ -21,6 +37,7 @@ mod root { ::serde::Deserialize, )] pub struct ActiveSpeakerObserverOptions { + /// The field `interval` in the table `ActiveSpeakerObserverOptions` pub interval: u16, } @@ -32,6 +49,12 @@ mod root { } 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, @@ -39,22 +62,22 @@ mod root { ) -> ::planus::Offset { let prepared_interval = field_interval.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 2>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_interval.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_interval) = prepared_interval { - table_writer.write::<_, _, 2>(0, &prepared_interval); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_interval) = + prepared_interval + { + object_writer.write::<_, _, 2>(&prepared_interval); + } + }); } - - table_writer.finish() + builder.current_offset() } } @@ -63,6 +86,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -76,6 +100,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -86,18 +111,110 @@ mod root { } impl ::planus::WriteAsOffset for ActiveSpeakerObserverOptions { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - ActiveSpeakerObserverOptions::create(builder, &self.interval) + 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 @@ -129,6 +246,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ActiveSpeakerObserverOptionsRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -162,6 +280,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -202,6 +321,10 @@ mod root { } } + /// 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, @@ -214,10 +337,17 @@ mod root { ::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, @@ -225,18 +355,16 @@ mod root { ) -> ::planus::Offset { let prepared_producer_id = field_producer_id.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_producer_id); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_producer_id); + }); } - - table_writer.finish() + builder.current_offset() } } @@ -245,6 +373,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -258,6 +387,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -268,6 +398,7 @@ mod root { } impl ::planus::WriteAsOffset for DominantSpeakerNotification { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -276,10 +407,91 @@ mod root { } } + /// 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") @@ -308,6 +520,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DominantSpeakerNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -341,6 +554,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -381,7 +595,15 @@ mod root { } } } + /// 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, @@ -394,8 +616,11 @@ mod root { ::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, } @@ -411,6 +636,12 @@ mod root { } 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, @@ -419,48 +650,48 @@ mod root { 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::<8, 5>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<10> = + ::core::default::Default::default(); if prepared_max_entries.is_some() { - table_writer.calculate_size::(2); - } - if prepared_threshold.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(0); } if prepared_interval.is_some() { - table_writer.calculate_size::(6); + table_writer.write_entry::(2); } - - table_writer.finish_calculating(); - - unsafe { - if let ::core::option::Option::Some(prepared_max_entries) = - prepared_max_entries - { - table_writer.write::<_, _, 2>(0, &prepared_max_entries); - } - if let ::core::option::Option::Some(prepared_interval) = prepared_interval { - table_writer.write::<_, _, 2>(2, &prepared_interval); - } - if let ::core::option::Option::Some(prepared_threshold) = prepared_threshold - { - table_writer.write::<_, _, 1>(1, &prepared_threshold); - } + if prepared_threshold.is_some() { + table_writer.write_entry::(1); } - table_writer.finish() + 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, @@ -474,6 +705,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -484,23 +716,172 @@ mod root { } 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, + 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 @@ -509,6 +890,8 @@ mod root { ) } + /// Getter for the [`threshold` field](AudioLevelObserverOptions#structfield.threshold). + #[inline] pub fn threshold(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -517,6 +900,8 @@ mod root { ) } + /// Getter for the [`interval` field](AudioLevelObserverOptions#structfield.interval). + #[inline] pub fn interval(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -550,6 +935,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for AudioLevelObserverOptionsRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -583,6 +969,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -623,6 +1010,10 @@ mod root { } } + /// 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, @@ -635,11 +1026,19 @@ mod root { ::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, @@ -647,33 +1046,31 @@ mod root { 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::<6, 5>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); + 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.calculate_size::(4); + table_writer.write_entry::(1); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_producer_id); - if let ::core::option::Option::Some(prepared_volume) = prepared_volume { - table_writer.write::<_, _, 1>(1, &prepared_volume); - } + 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); + } + }); } - - table_writer.finish() + 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) } @@ -682,6 +1079,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Volume { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -691,19 +1089,116 @@ mod root { } 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 { - Volume::create(builder, &self.producer_id, &self.volume) + ::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)) } @@ -731,6 +1226,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for VolumeRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -762,6 +1258,7 @@ mod root { 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) } @@ -798,6 +1295,10 @@ mod root { } } + /// 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, @@ -810,10 +1311,17 @@ mod root { ::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, @@ -823,25 +1331,24 @@ mod root { ) -> ::planus::Offset { let prepared_volumes = field_volumes.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); table_writer - .calculate_size::<::planus::Offset<[::planus::Offset]>>(2); - - table_writer.finish_calculating(); + .write_entry::<::planus::Offset<[::planus::Offset]>>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_volumes); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_volumes); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for VolumesNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -853,6 +1360,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for VolumesNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -862,6 +1370,7 @@ mod root { } impl ::planus::WriteAsOffset for VolumesNotification { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -870,10 +1379,89 @@ mod root { } } + /// 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>>> @@ -902,6 +1490,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for VolumesNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -933,6 +1522,7 @@ mod root { 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) } @@ -973,7 +1563,15 @@ mod root { } } } + /// 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:4` #[derive( Clone, Debug, @@ -986,11 +1584,19 @@ mod root { ::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, @@ -998,29 +1604,27 @@ mod root { 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::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_key); - table_writer.write::<_, _, 4>(1, &prepared_value); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_key); + object_writer.write::<_, _, 4>(&prepared_value); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for StringString { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -1032,6 +1636,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for StringString { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -1041,6 +1646,7 @@ mod root { } impl ::planus::WriteAsOffset for StringString { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -1049,14 +1655,114 @@ mod root { } } + /// 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") } @@ -1084,6 +1790,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for StringStringRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -1115,6 +1822,7 @@ mod root { 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) } @@ -1151,6 +1859,10 @@ mod root { } } + /// The table `StringUint8` in the namespace `FBS.Common` + /// + /// Generated from these locations: + /// * Table `StringUint8` in the file `../worker/fbs/common.fbs:9` #[derive( Clone, Debug, @@ -1163,11 +1875,19 @@ mod root { ::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, @@ -1175,33 +1895,31 @@ mod root { 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::<6, 5>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); + 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.calculate_size::(4); + table_writer.write_entry::(1); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_key); - if let ::core::option::Option::Some(prepared_value) = prepared_value { - table_writer.write::<_, _, 1>(1, &prepared_value); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for StringUint8 { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -1213,6 +1931,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for StringUint8 { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -1222,22 +1941,130 @@ mod root { } impl ::planus::WriteAsOffset for StringUint8 { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - StringUint8::create(builder, &self.key, &self.value) + 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), @@ -1267,6 +2094,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for StringUint8Ref<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -1298,6 +2126,7 @@ mod root { 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) } @@ -1334,6 +2163,10 @@ mod root { } } + /// The table `Uint16String` in the namespace `FBS.Common` + /// + /// Generated from these locations: + /// * Table `Uint16String` in the file `../worker/fbs/common.fbs:14` #[derive( Clone, Debug, @@ -1346,11 +2179,19 @@ mod root { ::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, @@ -1358,33 +2199,31 @@ mod root { 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::<6, 6>::new(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.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.calculate_size::<::planus::Offset>(4); - - table_writer.finish_calculating(); unsafe { - table_writer.write::<_, _, 4>(1, &prepared_value); - if let ::core::option::Option::Some(prepared_key) = prepared_key { - table_writer.write::<_, _, 2>(0, &prepared_key); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for Uint16String { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -1396,6 +2235,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Uint16String { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -1405,24 +2245,132 @@ mod root { } impl ::planus::WriteAsOffset for Uint16String { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - Uint16String::create(builder, &self.key, &self.value) + 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") } @@ -1450,6 +2398,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for Uint16StringRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -1481,6 +2430,7 @@ mod root { 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) } @@ -1517,6 +2467,10 @@ mod root { } } + /// The table `Uint32String` in the namespace `FBS.Common` + /// + /// Generated from these locations: + /// * Table `Uint32String` in the file `../worker/fbs/common.fbs:19` #[derive( Clone, Debug, @@ -1529,11 +2483,19 @@ mod root { ::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, @@ -1541,33 +2503,31 @@ mod root { 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::<6, 8>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<8> = + ::core::default::Default::default(); if prepared_key.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.calculate_size::<::planus::Offset>(4); - - table_writer.finish_calculating(); + table_writer.write_entry::<::planus::Offset>(1); unsafe { - if let ::core::option::Option::Some(prepared_key) = prepared_key { - table_writer.write::<_, _, 4>(0, &prepared_key); - } - table_writer.write::<_, _, 4>(1, &prepared_value); + 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); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for Uint32String { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -1579,6 +2539,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Uint32String { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -1588,24 +2549,132 @@ mod root { } 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 { - Uint32String::create(builder, &self.key, &self.value) + ::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") } @@ -1633,6 +2702,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for Uint32StringRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -1664,6 +2734,7 @@ mod root { 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) } @@ -1700,6 +2771,10 @@ mod root { } } + /// The table `StringStringArray` in the namespace `FBS.Common` + /// + /// Generated from these locations: + /// * Table `StringStringArray` in the file `../worker/fbs/common.fbs:24` #[derive( Clone, Debug, @@ -1712,11 +2787,19 @@ mod root { ::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, @@ -1724,29 +2807,27 @@ mod root { 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::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_key); - table_writer.write::<_, _, 4>(1, &prepared_values); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_key); + object_writer.write::<_, _, 4>(&prepared_values); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for StringStringArray { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -1758,6 +2839,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for StringStringArray { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -1767,6 +2849,7 @@ mod root { } impl ::planus::WriteAsOffset for StringStringArray { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -1775,14 +2858,115 @@ mod root { } } + /// 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< @@ -1814,6 +2998,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for StringStringArrayRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -1845,6 +3030,7 @@ mod root { 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) } @@ -1881,7 +3067,15 @@ mod root { } } } + /// 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:6` #[derive( Clone, Debug, @@ -1894,7 +3088,9 @@ mod root { ::serde::Deserialize, )] pub struct ConsumerLayers { + /// The field `spatial_layer` in the table `ConsumerLayers` pub spatial_layer: i16, + /// The field `temporal_layer` in the table `ConsumerLayers` pub temporal_layer: ::core::option::Option, } @@ -1909,6 +3105,12 @@ mod root { } 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, @@ -1916,41 +3118,39 @@ mod root { 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::<6, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<8> = + ::core::default::Default::default(); if prepared_spatial_layer.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } if prepared_temporal_layer.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(1); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_spatial_layer) = - prepared_spatial_layer - { - table_writer.write::<_, _, 2>(0, &prepared_spatial_layer); - } - if let ::core::option::Option::Some(prepared_temporal_layer) = - prepared_temporal_layer - { - table_writer.write::<_, _, 2>(1, &prepared_temporal_layer); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_spatial_layer) = + prepared_spatial_layer + { + object_writer.write::<_, _, 2>(&prepared_spatial_layer); + } + if let ::core::option::Option::Some(prepared_temporal_layer) = + prepared_temporal_layer + { + object_writer.write::<_, _, 2>(&prepared_temporal_layer); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for ConsumerLayers { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -1962,6 +3162,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ConsumerLayers { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -1971,18 +3172,127 @@ mod root { } impl ::planus::WriteAsOffset for ConsumerLayers { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - ConsumerLayers::create(builder, &self.spatial_layer, &self.temporal_layer) + 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 @@ -1991,6 +3301,8 @@ mod root { ) } + /// 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") } @@ -2030,6 +3342,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ConsumerLayersRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -2061,6 +3374,7 @@ mod root { 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) } @@ -2097,6 +3411,10 @@ mod root { } } + /// The table `ConsumerScore` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `ConsumerScore` in the file `../worker/fbs/consumer.fbs:11` #[derive( Clone, Debug, @@ -2109,8 +3427,11 @@ mod root { ::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: ::core::option::Option<::planus::alloc::vec::Vec>, } @@ -2126,6 +3447,12 @@ mod root { } 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, @@ -2134,49 +3461,46 @@ mod root { field_producer_scores: impl ::planus::WriteAsOptional<::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::<8, 6>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<10> = + ::core::default::Default::default(); + if prepared_producer_scores.is_some() { + table_writer.write_entry::<::planus::Offset<[u8]>>(2); + } if prepared_score.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } if prepared_producer_score.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(1); } - if prepared_producer_scores.is_some() { - table_writer.calculate_size::<::planus::Offset<[u8]>>(6); - } - - table_writer.finish_calculating(); unsafe { - if let ::core::option::Option::Some(prepared_producer_scores) = - prepared_producer_scores - { - table_writer.write::<_, _, 4>(2, &prepared_producer_scores); - } - if let ::core::option::Option::Some(prepared_score) = prepared_score { - table_writer.write::<_, _, 1>(0, &prepared_score); - } - if let ::core::option::Option::Some(prepared_producer_score) = - prepared_producer_score - { - table_writer.write::<_, _, 1>(1, &prepared_producer_score); - } - } - - table_writer.finish() + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_producer_scores) = + prepared_producer_scores + { + 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, @@ -2188,6 +3512,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ConsumerScore { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -2197,29 +3522,169 @@ mod root { } impl ::planus::WriteAsOffset for ConsumerScore { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { ConsumerScore::create( builder, - &self.score, - &self.producer_score, + 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::WriteAsOptional<::planus::Offset<[u8]>>, + { + let (v0, v1) = self.0; + ConsumerScoreBuilder((v0, v1, value)) + } + + /// Sets the [`producer_scores` field](ConsumerScore#structfield.producer_scores) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn producer_scores_as_null(self) -> ConsumerScoreBuilder<(T0, T1, ())> { + self.producer_scores(()) + } + } + + 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::WriteAsOptional<::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::WriteAsOptional<::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::WriteAsOptional<::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 @@ -2228,10 +3693,11 @@ mod root { ) } + /// Getter for the [`producer_scores` field](ConsumerScore#structfield.producer_scores). + #[inline] pub fn producer_scores( &self, - ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, u8>>> - { + ) -> ::planus::Result<::core::option::Option<&'a [u8]>> { self.0.access(2, "ConsumerScore", "producer_scores") } } @@ -2260,18 +3726,13 @@ mod root { producer_score: ::core::convert::TryInto::try_into( value.producer_score()?, )?, - producer_scores: if let ::core::option::Option::Some(producer_scores) = - value.producer_scores()? - { - ::core::option::Option::Some(producer_scores.to_vec()?) - } else { - ::core::option::Option::None - }, + producer_scores: value.producer_scores()?.map(|v| v.to_vec()), }) } } impl<'a> ::planus::TableRead<'a> for ConsumerScoreRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -2303,6 +3764,7 @@ mod root { 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) } @@ -2339,6 +3801,10 @@ mod root { } } + /// The table `SetPreferredLayersRequest` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `SetPreferredLayersRequest` in the file `../worker/fbs/consumer.fbs:17` #[derive( Clone, Debug, @@ -2351,6 +3817,7 @@ mod root { ::serde::Deserialize, )] pub struct SetPreferredLayersRequest { + /// The field `preferred_layers` in the table `SetPreferredLayersRequest` pub preferred_layers: ::planus::alloc::boxed::Box, } @@ -2364,6 +3831,12 @@ mod root { } 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, @@ -2373,24 +3846,23 @@ mod root { ) -> ::planus::Offset { let prepared_preferred_layers = field_preferred_layers.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_preferred_layers); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_preferred_layers); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for SetPreferredLayersRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -2404,6 +3876,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -2414,6 +3887,7 @@ mod root { } impl ::planus::WriteAsOffset for SetPreferredLayersRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -2422,10 +3896,94 @@ mod root { } } + /// 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") @@ -2454,6 +4012,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SetPreferredLayersRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -2487,6 +4046,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -2527,6 +4087,10 @@ mod root { } } + /// The table `SetPreferredLayersResponse` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `SetPreferredLayersResponse` in the file `../worker/fbs/consumer.fbs:21` #[derive( Clone, Debug, @@ -2539,6 +4103,7 @@ mod root { ::serde::Deserialize, )] pub struct SetPreferredLayersResponse { + /// The field `preferred_layers` in the table `SetPreferredLayersResponse` pub preferred_layers: ::core::option::Option<::planus::alloc::boxed::Box>, } @@ -2553,6 +4118,12 @@ mod root { } 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, @@ -2562,24 +4133,22 @@ mod root { ) -> ::planus::Offset { let prepared_preferred_layers = field_preferred_layers.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_preferred_layers.is_some() { - table_writer.calculate_size::<::planus::Offset>(2); + table_writer.write_entry::<::planus::Offset>(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_preferred_layers) = - prepared_preferred_layers - { - table_writer.write::<_, _, 4>(0, &prepared_preferred_layers); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } @@ -2588,6 +4157,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -2601,6 +4171,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -2611,6 +4182,7 @@ mod root { } impl ::planus::WriteAsOffset for SetPreferredLayersResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -2619,10 +4191,101 @@ mod root { } } + /// 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>> @@ -2666,6 +4329,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SetPreferredLayersResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -2699,6 +4363,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -2739,6 +4404,10 @@ mod root { } } + /// The table `SetPriorityRequest` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `SetPriorityRequest` in the file `../worker/fbs/consumer.fbs:25` #[derive( Clone, Debug, @@ -2751,6 +4420,7 @@ mod root { ::serde::Deserialize, )] pub struct SetPriorityRequest { + /// The field `priority` in the table `SetPriorityRequest` pub priority: u8, } @@ -2762,6 +4432,12 @@ mod root { } 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, @@ -2769,28 +4445,29 @@ mod root { ) -> ::planus::Offset { let prepared_priority = field_priority.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 1>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_priority.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_priority) = prepared_priority { - table_writer.write::<_, _, 1>(0, &prepared_priority); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_priority) = + prepared_priority + { + object_writer.write::<_, _, 1>(&prepared_priority); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for SetPriorityRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -2802,6 +4479,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for SetPriorityRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -2811,18 +4489,107 @@ mod root { } impl ::planus::WriteAsOffset for SetPriorityRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - SetPriorityRequest::create(builder, &self.priority) + 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 @@ -2852,6 +4619,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SetPriorityRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -2883,6 +4651,7 @@ mod root { 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) } @@ -2919,6 +4688,10 @@ mod root { } } + /// The table `SetPriorityResponse` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `SetPriorityResponse` in the file `../worker/fbs/consumer.fbs:29` #[derive( Clone, Debug, @@ -2931,6 +4704,7 @@ mod root { ::serde::Deserialize, )] pub struct SetPriorityResponse { + /// The field `priority` in the table `SetPriorityResponse` pub priority: u8, } @@ -2942,6 +4716,12 @@ mod root { } 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, @@ -2949,28 +4729,29 @@ mod root { ) -> ::planus::Offset { let prepared_priority = field_priority.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 1>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_priority.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_priority) = prepared_priority { - table_writer.write::<_, _, 1>(0, &prepared_priority); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_priority) = + prepared_priority + { + object_writer.write::<_, _, 1>(&prepared_priority); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for SetPriorityResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -2982,6 +4763,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for SetPriorityResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -2991,18 +4773,107 @@ mod root { } 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 { - SetPriorityResponse::create(builder, &self.priority) + 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 @@ -3032,6 +4903,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SetPriorityResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -3063,6 +4935,7 @@ mod root { 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) } @@ -3103,6 +4976,10 @@ mod root { } } + /// The table `EnableTraceEventRequest` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/consumer.fbs:33` #[derive( Clone, Debug, @@ -3115,10 +4992,17 @@ mod root { ::serde::Deserialize, )] pub struct EnableTraceEventRequest { + /// The field `events` in the table `EnableTraceEventRequest` pub events: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, } 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, @@ -3126,24 +5010,23 @@ mod root { ) -> ::planus::Offset { let prepared_events = field_events.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_events); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_events); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for EnableTraceEventRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -3157,6 +5040,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -3167,6 +5051,7 @@ mod root { } impl ::planus::WriteAsOffset for EnableTraceEventRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -3175,10 +5060,91 @@ mod root { } } + /// 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<[::planus::Offset]>>, + { + 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< @@ -3209,6 +5175,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for EnableTraceEventRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -3240,6 +5207,7 @@ mod root { 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) } @@ -3280,17 +5248,35 @@ mod root { } } + /// The union `DumpData` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Union `DumpData` in the file `../worker/fbs/consumer.fbs:37` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub enum DumpData { + /// The variant of type `SimpleConsumerDump` in the union `DumpData` SimpleConsumerDump(::planus::alloc::boxed::Box), + + /// The variant of type `SimulcastConsumerDump` in the union `DumpData` SimulcastConsumerDump(::planus::alloc::boxed::Box), + + /// The variant of type `SvcConsumerDump` in the union `DumpData` SvcConsumerDump(::planus::alloc::boxed::Box), + + /// The variant of type `PipeConsumerDump` in the union `DumpData` PipeConsumerDump(::planus::alloc::boxed::Box), } impl DumpData { + /// Creates a [DumpDataBuilder] for serializing an instance of this table. + #[inline] + pub fn builder() -> DumpDataBuilder<::planus::Uninitialized> { + DumpDataBuilder(::planus::Uninitialized) + } + + #[inline] pub fn create_simple_consumer_dump( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -3298,6 +5284,7 @@ mod root { ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) } + #[inline] pub fn create_simulcast_consumer_dump( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -3305,6 +5292,7 @@ mod root { ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) } + #[inline] pub fn create_svc_consumer_dump( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -3312,6 +5300,7 @@ mod root { ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) } + #[inline] pub fn create_pipe_consumer_dump( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -3321,6 +5310,7 @@ mod root { } impl ::planus::WriteAsUnion for DumpData { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { match self { Self::SimpleConsumerDump(value) => { @@ -3340,6 +5330,7 @@ mod root { } impl ::planus::WriteAsOptionalUnion for DumpData { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -3348,6 +5339,179 @@ mod root { } } + /// Builder for serializing an instance of the [DumpData] type. + /// + /// Can be created using the [DumpData::builder] method. + #[derive(Debug)] + #[must_use] + pub struct DumpDataBuilder(T); + + impl DumpDataBuilder<::planus::Uninitialized> { + /// Creates an instance of the [`SimpleConsumerDump` variant](DumpData#variant.SimpleConsumerDump). + #[inline] + pub fn simple_consumer_dump( + self, + value: T, + ) -> DumpDataBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, + { + DumpDataBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`SimulcastConsumerDump` variant](DumpData#variant.SimulcastConsumerDump). + #[inline] + pub fn simulcast_consumer_dump( + self, + value: T, + ) -> DumpDataBuilder<::planus::Initialized<2, T>> + where + T: ::planus::WriteAsOffset, + { + DumpDataBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`SvcConsumerDump` variant](DumpData#variant.SvcConsumerDump). + #[inline] + pub fn svc_consumer_dump( + self, + value: T, + ) -> DumpDataBuilder<::planus::Initialized<3, T>> + where + T: ::planus::WriteAsOffset, + { + DumpDataBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`PipeConsumerDump` variant](DumpData#variant.PipeConsumerDump). + #[inline] + pub fn pipe_consumer_dump( + self, + value: T, + ) -> DumpDataBuilder<::planus::Initialized<4, T>> + where + T: ::planus::WriteAsOffset, + { + DumpDataBuilder(::planus::Initialized(value)) + } + } + + impl DumpDataBuilder<::planus::Initialized> { + /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [DumpData]. + #[inline] + pub fn finish( + self, + builder: &mut ::planus::Builder, + ) -> ::planus::UnionOffset + where + Self: ::planus::WriteAsUnion, + { + ::planus::WriteAsUnion::prepare(&self, builder) + } + } + + impl ::planus::WriteAsUnion for DumpDataBuilder<::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 DumpDataBuilder<::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 DumpDataBuilder<::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 DumpDataBuilder<::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 DumpDataBuilder<::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 DumpDataBuilder<::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 DumpDataBuilder<::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 DumpDataBuilder<::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 [DumpData]. #[derive(Copy, Clone, Debug)] pub enum DumpDataRef<'a> { SimpleConsumerDump(self::SimpleConsumerDumpRef<'a>), @@ -3362,25 +5526,25 @@ mod root { fn try_from(value: DumpDataRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(match value { DumpDataRef::SimpleConsumerDump(value) => { - DumpData::SimpleConsumerDump(::planus::alloc::boxed::Box::new( + Self::SimpleConsumerDump(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } DumpDataRef::SimulcastConsumerDump(value) => { - DumpData::SimulcastConsumerDump(::planus::alloc::boxed::Box::new( + Self::SimulcastConsumerDump(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } DumpDataRef::SvcConsumerDump(value) => { - DumpData::SvcConsumerDump(::planus::alloc::boxed::Box::new( + Self::SvcConsumerDump(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } DumpDataRef::PipeConsumerDump(value) => { - DumpData::PipeConsumerDump(::planus::alloc::boxed::Box::new( + Self::PipeConsumerDump(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -3414,11 +5578,17 @@ mod root { } } + /// The table `DumpResponse` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `DumpResponse` in the file `../worker/fbs/consumer.fbs:44` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct DumpResponse { + /// The field `data` in the table `DumpResponse` pub data: ::core::option::Option, + /// The field `type` in the table `DumpResponse` pub type_: super::rtp_parameters::Type, } @@ -3433,6 +5603,12 @@ mod root { } 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, @@ -3443,42 +5619,42 @@ mod root { >, ) -> ::planus::Offset { let prepared_data = field_data.prepare(builder); - let prepared_type_ = field_type_.prepare(builder, &super::rtp_parameters::Type::None); - let mut table_writer = - ::planus::table_writer::TableWriter::<8, 6>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<10> = + ::core::default::Default::default(); if prepared_data.is_some() { - table_writer.calculate_size::(2); - table_writer.calculate_size::<::planus::Offset>(4); + table_writer.write_entry::<::planus::Offset>(1); + } + if prepared_data.is_some() { + table_writer.write_entry::(0); } if prepared_type_.is_some() { - table_writer.calculate_size::(6); + table_writer.write_entry::(2); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_data) = prepared_data { - table_writer.write::<_, _, 4>(1, &prepared_data.offset()); - } - if let ::core::option::Option::Some(prepared_data) = prepared_data { - table_writer.write::<_, _, 1>(0, &prepared_data.tag()); - } - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - table_writer.write::<_, _, 1>(2, &prepared_type_); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_data) = prepared_data { + object_writer.write::<_, _, 4>(&prepared_data.offset()); + } + if let ::core::option::Option::Some(prepared_data) = prepared_data { + object_writer.write::<_, _, 1>(&prepared_data.tag()); + } + if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { + object_writer.write::<_, _, 1>(&prepared_type_); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -3490,6 +5666,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -3499,18 +5676,143 @@ mod root { } impl ::planus::WriteAsOffset for DumpResponse { + #[inline] + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + DumpResponse::create(builder, &self.data, self.type_) + } + } + + /// 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::WriteAsOptionalUnion, + { + DumpResponseBuilder((value,)) + } + + /// Sets the [`data` field](DumpResponse#structfield.data) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn data_as_null(self) -> DumpResponseBuilder<((),)> { + self.data(()) + } + } + + 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< + super::rtp_parameters::Type, + super::rtp_parameters::Type, + >, + { + 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)> { + /// 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::WriteAsOptionalUnion, + T1: ::planus::WriteAsDefault< + super::rtp_parameters::Type, + super::rtp_parameters::Type, + >, + > ::planus::WriteAs<::planus::Offset> + for DumpResponseBuilder<(T0, T1)> + { + type Prepared = ::planus::Offset; + + #[inline] + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) + } + } + + impl< + T0: ::planus::WriteAsOptionalUnion, + T1: ::planus::WriteAsDefault< + super::rtp_parameters::Type, + super::rtp_parameters::Type, + >, + > ::planus::WriteAsOptional<::planus::Offset> + for DumpResponseBuilder<(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::WriteAsOptionalUnion, + T1: ::planus::WriteAsDefault< + super::rtp_parameters::Type, + super::rtp_parameters::Type, + >, + > ::planus::WriteAsOffset for DumpResponseBuilder<(T0, T1)> + { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - DumpResponse::create(builder, &self.data, &self.type_) + let (v0, v1) = &self.0; + DumpResponse::create(builder, v0, v1) } } + /// 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<::core::option::Option>> @@ -3518,6 +5820,8 @@ mod root { self.0.access_union(0, "DumpResponse", "data") } + /// Getter for the [`type` field](DumpResponse#structfield.type_). + #[inline] pub fn type_(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -3555,6 +5859,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -3586,6 +5891,7 @@ mod root { 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) } @@ -3622,27 +5928,47 @@ mod root { } } + /// The table `BaseConsumerDump` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `BaseConsumerDump` in the file `../worker/fbs/consumer.fbs:49` #[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 `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: ::core::option::Option< ::planus::alloc::vec::Vec, >, + /// The field `supported_codec_payload_types` in the table `BaseConsumerDump` pub supported_codec_payload_types: ::core::option::Option<::planus::alloc::vec::Vec>, + /// The field `trace_event_types` in the table `BaseConsumerDump` pub trace_event_types: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + /// 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, @@ -3671,101 +5997,91 @@ mod root { field_priority: impl ::planus::WriteAsDefault, ) -> ::planus::Offset { let prepared_id = field_id.prepare(builder); - let prepared_producer_id = field_producer_id.prepare(builder); - let prepared_kind = field_kind.prepare(builder, &super::rtp_parameters::MediaKind::All); - 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::<22, 28>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); - if prepared_kind.is_some() { - table_writer.calculate_size::(6); - } + 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); table_writer - .calculate_size::<::planus::Offset>( - 8, - ); + .write_entry::<::planus::Offset>(3); if prepared_consumable_rtp_encodings.is_some() { - table_writer.calculate_size::<::planus::Offset< + table_writer.write_entry::<::planus::Offset< [::planus::Offset], - >>(10); + >>(4); } if prepared_supported_codec_payload_types.is_some() { - table_writer.calculate_size::<::planus::Offset<[u8]>>(12); + table_writer.write_entry::<::planus::Offset<[u8]>>(5); + } + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(6); + if prepared_kind.is_some() { + table_writer.write_entry::(2); } - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(14); if prepared_paused.is_some() { - table_writer.calculate_size::(16); + table_writer.write_entry::(7); } if prepared_producer_paused.is_some() { - table_writer.calculate_size::(18); + table_writer.write_entry::(8); } if prepared_priority.is_some() { - table_writer.calculate_size::(20); + table_writer.write_entry::(9); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_id); - table_writer.write::<_, _, 4>(1, &prepared_producer_id); - table_writer.write::<_, _, 4>(3, &prepared_rtp_parameters); - if let ::core::option::Option::Some(prepared_consumable_rtp_encodings) = - prepared_consumable_rtp_encodings - { - table_writer.write::<_, _, 4>(4, &prepared_consumable_rtp_encodings); - } - if let ::core::option::Option::Some( - prepared_supported_codec_payload_types, - ) = prepared_supported_codec_payload_types - { - table_writer - .write::<_, _, 4>(5, &prepared_supported_codec_payload_types); - } - table_writer.write::<_, _, 4>(6, &prepared_trace_event_types); - if let ::core::option::Option::Some(prepared_kind) = prepared_kind { - table_writer.write::<_, _, 1>(2, &prepared_kind); - } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - table_writer.write::<_, _, 1>(7, &prepared_paused); - } - if let ::core::option::Option::Some(prepared_producer_paused) = - prepared_producer_paused - { - table_writer.write::<_, _, 1>(8, &prepared_producer_paused); - } - if let ::core::option::Option::Some(prepared_priority) = prepared_priority { - table_writer.write::<_, _, 1>(9, &prepared_priority); - } - } - - table_writer.finish() + 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); + if let ::core::option::Option::Some(prepared_consumable_rtp_encodings) = + prepared_consumable_rtp_encodings + { + object_writer.write::<_, _, 4>(&prepared_consumable_rtp_encodings); + } + if let ::core::option::Option::Some( + prepared_supported_codec_payload_types, + ) = prepared_supported_codec_payload_types + { + object_writer + .write::<_, _, 4>(&prepared_supported_codec_payload_types); + } + 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_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, @@ -3777,6 +6093,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for BaseConsumerDump { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -3786,6 +6103,7 @@ mod root { } impl ::planus::WriteAsOffset for BaseConsumerDump { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -3794,30 +6112,381 @@ mod root { builder, &self.id, &self.producer_id, - &self.kind, + 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, + 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 [`producer_id` field](BaseConsumerDump#structfield.producer_id). + #[inline] + #[allow(clippy::type_complexity)] + pub fn producer_id(self, value: T1) -> BaseConsumerDumpBuilder<(T0, T1)> + where + T1: ::planus::WriteAs<::planus::Offset>, + { + let (v0,) = self.0; + BaseConsumerDumpBuilder((v0, value)) + } + } + + impl BaseConsumerDumpBuilder<(T0, T1)> { + /// Setter for the [`kind` field](BaseConsumerDump#structfield.kind). + #[inline] + #[allow(clippy::type_complexity)] + pub fn kind(self, value: T2) -> BaseConsumerDumpBuilder<(T0, T1, T2)> + where + T2: ::planus::WriteAsDefault< + super::rtp_parameters::MediaKind, + super::rtp_parameters::MediaKind, + >, + { + let (v0, v1) = self.0; + BaseConsumerDumpBuilder((v0, v1, 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, ::planus::DefaultValue)> { + self.kind(::planus::DefaultValue) + } + } + + impl BaseConsumerDumpBuilder<(T0, T1, T2)> { + /// Setter for the [`rtp_parameters` field](BaseConsumerDump#structfield.rtp_parameters). + #[inline] + #[allow(clippy::type_complexity)] + pub fn rtp_parameters( + self, + value: T3, + ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3)> + where + T3: ::planus::WriteAs<::planus::Offset>, + { + let (v0, v1, v2) = self.0; + BaseConsumerDumpBuilder((v0, v1, v2, value)) + } + } + + impl BaseConsumerDumpBuilder<(T0, T1, T2, T3)> { + /// Setter for the [`consumable_rtp_encodings` field](BaseConsumerDump#structfield.consumable_rtp_encodings). + #[inline] + #[allow(clippy::type_complexity)] + pub fn consumable_rtp_encodings( + self, + value: T4, + ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4)> + where + T4: ::planus::WriteAsOptional< + ::planus::Offset< + [::planus::Offset], + >, + >, + { + let (v0, v1, v2, v3) = self.0; + BaseConsumerDumpBuilder((v0, v1, v2, v3, value)) + } + + /// Sets the [`consumable_rtp_encodings` field](BaseConsumerDump#structfield.consumable_rtp_encodings) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn consumable_rtp_encodings_as_null( + self, + ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, ())> { + self.consumable_rtp_encodings(()) + } + } + + impl BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4)> { + /// 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: T5, + ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> + where + T5: ::planus::WriteAsOptional<::planus::Offset<[u8]>>, + { + let (v0, v1, v2, v3, v4) = self.0; + BaseConsumerDumpBuilder((v0, v1, v2, v3, v4, value)) + } + + /// Sets the [`supported_codec_payload_types` field](BaseConsumerDump#structfield.supported_codec_payload_types) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn supported_codec_payload_types_as_null( + self, + ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, ())> { + self.supported_codec_payload_types(()) + } + } + + impl BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> { + /// Setter for the [`trace_event_types` field](BaseConsumerDump#structfield.trace_event_types). + #[inline] + #[allow(clippy::type_complexity)] + pub fn trace_event_types( + self, + value: T6, + ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> + where + T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + { + 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 [`paused` field](BaseConsumerDump#structfield.paused). + #[inline] + #[allow(clippy::type_complexity)] + pub fn paused( + self, + value: T7, + ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + where + T7: ::planus::WriteAsDefault, + { + let (v0, v1, v2, v3, v4, v5, v6) = self.0; + BaseConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, v6, 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, ::planus::DefaultValue)> + { + self.paused(::planus::DefaultValue) + } + } + + impl BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { + /// Setter for the [`producer_paused` field](BaseConsumerDump#structfield.producer_paused). + #[inline] + #[allow(clippy::type_complexity)] + pub fn producer_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 [`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, ::planus::DefaultValue)> + { + self.producer_paused(::planus::DefaultValue) + } + } + + impl + BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> + { + /// Setter for the [`priority` field](BaseConsumerDump#structfield.priority). + #[inline] + #[allow(clippy::type_complexity)] + pub fn priority( + 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 [`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, + ::planus::DefaultValue, + )> { + self.priority(::planus::DefaultValue) + } + } + + impl + BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> + { + /// 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::WriteAs<::planus::Offset>, + T2: ::planus::WriteAsDefault< + super::rtp_parameters::MediaKind, + super::rtp_parameters::MediaKind, + >, + T3: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAsOptional< + ::planus::Offset< + [::planus::Offset], + >, + >, + T5: ::planus::WriteAsOptional<::planus::Offset<[u8]>>, + T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T7: ::planus::WriteAsDefault, + T8: ::planus::WriteAsDefault, + T9: ::planus::WriteAsDefault, + > ::planus::WriteAs<::planus::Offset> + for BaseConsumerDumpBuilder<(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::rtp_parameters::MediaKind, + super::rtp_parameters::MediaKind, + >, + T3: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAsOptional< + ::planus::Offset< + [::planus::Offset], + >, + >, + T5: ::planus::WriteAsOptional<::planus::Offset<[u8]>>, + T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T7: ::planus::WriteAsDefault, + T8: ::planus::WriteAsDefault, + T9: ::planus::WriteAsDefault, + > ::planus::WriteAsOptional<::planus::Offset> + for BaseConsumerDumpBuilder<(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::rtp_parameters::MediaKind, + super::rtp_parameters::MediaKind, + >, + T3: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAsOptional< + ::planus::Offset< + [::planus::Offset], + >, + >, + T5: ::planus::WriteAsOptional<::planus::Offset<[u8]>>, + T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T7: ::planus::WriteAsDefault, + T8: ::planus::WriteAsDefault, + T9: ::planus::WriteAsDefault, + > ::planus::WriteAsOffset + for BaseConsumerDumpBuilder<(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; + BaseConsumerDump::create(builder, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) + } + } + + /// 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 [`producer_id` field](BaseConsumerDump#structfield.producer_id). + #[inline] pub fn producer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { self.0.access_required(1, "BaseConsumerDump", "producer_id") } + /// Getter for the [`kind` field](BaseConsumerDump#structfield.kind). + #[inline] pub fn kind(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -3826,6 +6495,8 @@ mod root { ) } + /// Getter for the [`rtp_parameters` field](BaseConsumerDump#structfield.rtp_parameters). + #[inline] pub fn rtp_parameters( &self, ) -> ::planus::Result> { @@ -3833,6 +6504,8 @@ mod root { .access_required(3, "BaseConsumerDump", "rtp_parameters") } + /// Getter for the [`consumable_rtp_encodings` field](BaseConsumerDump#structfield.consumable_rtp_encodings). + #[inline] pub fn consumable_rtp_encodings( &self, ) -> ::planus::Result< @@ -3847,14 +6520,17 @@ mod root { .access(4, "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<::core::option::Option<::planus::Vector<'a, u8>>> - { + ) -> ::planus::Result<::core::option::Option<&'a [u8]>> { self.0 .access(5, "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< @@ -3864,6 +6540,8 @@ mod root { .access_required(6, "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 @@ -3872,6 +6550,8 @@ mod root { ) } + /// Getter for the [`producer_paused` field](BaseConsumerDump#structfield.producer_paused). + #[inline] pub fn producer_paused(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -3880,6 +6560,8 @@ mod root { ) } + /// Getter for the [`priority` field](BaseConsumerDump#structfield.priority). + #[inline] pub fn priority(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -3937,15 +6619,9 @@ mod root { } else { ::core::option::Option::None }, - supported_codec_payload_types: if let ::core::option::Option::Some( - supported_codec_payload_types, - ) = - value.supported_codec_payload_types()? - { - ::core::option::Option::Some(supported_codec_payload_types.to_vec()?) - } else { - ::core::option::Option::None - }, + supported_codec_payload_types: value + .supported_codec_payload_types()? + .map(|v| v.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( @@ -3957,6 +6633,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for BaseConsumerDumpRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -3988,6 +6665,7 @@ mod root { 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) } @@ -4024,15 +6702,27 @@ mod root { } } + /// The table `SimpleConsumerDump` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `SimpleConsumerDump` in the file `../worker/fbs/consumer.fbs:62` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct SimpleConsumerDump { + /// The field `base` in the table `SimpleConsumerDump` pub base: ::planus::alloc::boxed::Box, + /// The field `rtp_stream` in the table `SimpleConsumerDump` pub rtp_stream: ::planus::alloc::boxed::Box, } impl SimpleConsumerDump { + /// Creates a [SimpleConsumerDumpBuilder] for serializing an instance of this table. + #[inline] + pub fn builder() -> SimpleConsumerDumpBuilder<()> { + SimpleConsumerDumpBuilder(()) + } + #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, @@ -4040,29 +6730,27 @@ mod root { field_rtp_stream: impl ::planus::WriteAs<::planus::Offset>, ) -> ::planus::Offset { let prepared_base = field_base.prepare(builder); - let prepared_rtp_stream = field_rtp_stream.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_base); - table_writer.write::<_, _, 4>(1, &prepared_rtp_stream); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_base); + object_writer.write::<_, _, 4>(&prepared_rtp_stream); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for SimpleConsumerDump { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -4074,6 +6762,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for SimpleConsumerDump { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -4083,6 +6772,7 @@ mod root { } impl ::planus::WriteAsOffset for SimpleConsumerDump { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -4091,14 +6781,115 @@ mod root { } } + /// Builder for serializing an instance of the [SimpleConsumerDump] type. + /// + /// Can be created using the [SimpleConsumerDump::builder] method. + #[derive(Debug)] + #[must_use] + pub struct SimpleConsumerDumpBuilder(State); + + impl SimpleConsumerDumpBuilder<()> { + /// Setter for the [`base` field](SimpleConsumerDump#structfield.base). + #[inline] + #[allow(clippy::type_complexity)] + pub fn base(self, value: T0) -> SimpleConsumerDumpBuilder<(T0,)> + where + T0: ::planus::WriteAs<::planus::Offset>, + { + SimpleConsumerDumpBuilder((value,)) + } + } + + impl SimpleConsumerDumpBuilder<(T0,)> { + /// Setter for the [`rtp_stream` field](SimpleConsumerDump#structfield.rtp_stream). + #[inline] + #[allow(clippy::type_complexity)] + pub fn rtp_stream(self, value: T1) -> SimpleConsumerDumpBuilder<(T0, T1)> + where + T1: ::planus::WriteAs<::planus::Offset>, + { + let (v0,) = self.0; + SimpleConsumerDumpBuilder((v0, value)) + } + } + + impl SimpleConsumerDumpBuilder<(T0, T1)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SimpleConsumerDump]. + #[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 SimpleConsumerDumpBuilder<(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 SimpleConsumerDumpBuilder<(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 SimpleConsumerDumpBuilder<(T0, T1)> + { + #[inline] + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + let (v0, v1) = &self.0; + SimpleConsumerDump::create(builder, v0, v1) + } + } + + /// Reference to a deserialized [SimpleConsumerDump]. #[derive(Copy, Clone)] pub struct SimpleConsumerDumpRef<'a>(::planus::table_reader::Table<'a>); impl<'a> SimpleConsumerDumpRef<'a> { + /// Getter for the [`base` field](SimpleConsumerDump#structfield.base). + #[inline] pub fn base(&self) -> ::planus::Result> { self.0.access_required(0, "SimpleConsumerDump", "base") } + /// Getter for the [`rtp_stream` field](SimpleConsumerDump#structfield.rtp_stream). + #[inline] pub fn rtp_stream(&self) -> ::planus::Result> { self.0 .access_required(1, "SimpleConsumerDump", "rtp_stream") @@ -4131,6 +6922,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SimpleConsumerDumpRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -4162,6 +6954,7 @@ mod root { impl ::planus::VectorWrite<::planus::Offset> for SimpleConsumerDump { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -4198,21 +6991,39 @@ mod root { } } + /// The table `SimulcastConsumerDump` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `SimulcastConsumerDump` in the file `../worker/fbs/consumer.fbs:67` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct SimulcastConsumerDump { + /// The field `base` in the table `SimulcastConsumerDump` pub base: ::planus::alloc::boxed::Box, + /// The field `rtp_stream` in the table `SimulcastConsumerDump` pub rtp_stream: ::planus::alloc::boxed::Box, + /// The field `preferred_spatial_layer` in the table `SimulcastConsumerDump` pub preferred_spatial_layer: i16, + /// The field `target_spatial_layer` in the table `SimulcastConsumerDump` pub target_spatial_layer: i16, + /// The field `current_spatial_layer` in the table `SimulcastConsumerDump` pub current_spatial_layer: i16, + /// The field `preferred_temporal_layer` in the table `SimulcastConsumerDump` pub preferred_temporal_layer: i16, + /// The field `target_temporal_layer` in the table `SimulcastConsumerDump` pub target_temporal_layer: i16, + /// The field `current_temporal_layer` in the table `SimulcastConsumerDump` pub current_temporal_layer: i16, } impl SimulcastConsumerDump { + /// Creates a [SimulcastConsumerDumpBuilder] for serializing an instance of this table. + #[inline] + pub fn builder() -> SimulcastConsumerDumpBuilder<()> { + SimulcastConsumerDumpBuilder(()) + } + #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, @@ -4226,95 +7037,87 @@ mod root { field_current_temporal_layer: impl ::planus::WriteAsDefault, ) -> ::planus::Offset { let prepared_base = field_base.prepare(builder); - let prepared_rtp_stream = field_rtp_stream.prepare(builder); - let prepared_preferred_spatial_layer = field_preferred_spatial_layer.prepare(builder, &0); - let prepared_target_spatial_layer = field_target_spatial_layer.prepare(builder, &0); - let prepared_current_spatial_layer = field_current_spatial_layer.prepare(builder, &0); - let prepared_preferred_temporal_layer = field_preferred_temporal_layer.prepare(builder, &0); - let prepared_target_temporal_layer = field_target_temporal_layer.prepare(builder, &0); - let prepared_current_temporal_layer = field_current_temporal_layer.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<18, 20>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); + 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_preferred_spatial_layer.is_some() { - table_writer.calculate_size::(6); + table_writer.write_entry::(2); } if prepared_target_spatial_layer.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(3); } if prepared_current_spatial_layer.is_some() { - table_writer.calculate_size::(10); + table_writer.write_entry::(4); } if prepared_preferred_temporal_layer.is_some() { - table_writer.calculate_size::(12); + table_writer.write_entry::(5); } if prepared_target_temporal_layer.is_some() { - table_writer.calculate_size::(14); + table_writer.write_entry::(6); } if prepared_current_temporal_layer.is_some() { - table_writer.calculate_size::(16); + table_writer.write_entry::(7); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_base); - table_writer.write::<_, _, 4>(1, &prepared_rtp_stream); - if let ::core::option::Option::Some(prepared_preferred_spatial_layer) = - prepared_preferred_spatial_layer - { - table_writer.write::<_, _, 2>(2, &prepared_preferred_spatial_layer); - } - if let ::core::option::Option::Some(prepared_target_spatial_layer) = - prepared_target_spatial_layer - { - table_writer.write::<_, _, 2>(3, &prepared_target_spatial_layer); - } - if let ::core::option::Option::Some(prepared_current_spatial_layer) = - prepared_current_spatial_layer - { - table_writer.write::<_, _, 2>(4, &prepared_current_spatial_layer); - } - if let ::core::option::Option::Some(prepared_preferred_temporal_layer) = - prepared_preferred_temporal_layer - { - table_writer.write::<_, _, 2>(5, &prepared_preferred_temporal_layer); - } - if let ::core::option::Option::Some(prepared_target_temporal_layer) = - prepared_target_temporal_layer - { - table_writer.write::<_, _, 2>(6, &prepared_target_temporal_layer); - } - if let ::core::option::Option::Some(prepared_current_temporal_layer) = - prepared_current_temporal_layer - { - table_writer.write::<_, _, 2>(7, &prepared_current_temporal_layer); - } - } - - table_writer.finish() + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_base); + object_writer.write::<_, _, 4>(&prepared_rtp_stream); + 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 SimulcastConsumerDump { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -4326,6 +7129,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for SimulcastConsumerDump { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -4336,6 +7140,7 @@ mod root { } impl ::planus::WriteAsOffset for SimulcastConsumerDump { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -4344,29 +7149,317 @@ mod root { builder, &self.base, &self.rtp_stream, - &self.preferred_spatial_layer, - &self.target_spatial_layer, - &self.current_spatial_layer, - &self.preferred_temporal_layer, - &self.target_temporal_layer, - &self.current_temporal_layer, + 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 [SimulcastConsumerDump] type. + /// + /// Can be created using the [SimulcastConsumerDump::builder] method. + #[derive(Debug)] + #[must_use] + pub struct SimulcastConsumerDumpBuilder(State); + + impl SimulcastConsumerDumpBuilder<()> { + /// Setter for the [`base` field](SimulcastConsumerDump#structfield.base). + #[inline] + #[allow(clippy::type_complexity)] + pub fn base(self, value: T0) -> SimulcastConsumerDumpBuilder<(T0,)> + where + T0: ::planus::WriteAs<::planus::Offset>, + { + SimulcastConsumerDumpBuilder((value,)) + } + } + + impl SimulcastConsumerDumpBuilder<(T0,)> { + /// Setter for the [`rtp_stream` field](SimulcastConsumerDump#structfield.rtp_stream). + #[inline] + #[allow(clippy::type_complexity)] + pub fn rtp_stream(self, value: T1) -> SimulcastConsumerDumpBuilder<(T0, T1)> + where + T1: ::planus::WriteAs<::planus::Offset>, + { + let (v0,) = self.0; + SimulcastConsumerDumpBuilder((v0, value)) + } + } + + impl SimulcastConsumerDumpBuilder<(T0, T1)> { + /// Setter for the [`preferred_spatial_layer` field](SimulcastConsumerDump#structfield.preferred_spatial_layer). + #[inline] + #[allow(clippy::type_complexity)] + pub fn preferred_spatial_layer( + self, + value: T2, + ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2)> + where + T2: ::planus::WriteAsDefault, + { + let (v0, v1) = self.0; + SimulcastConsumerDumpBuilder((v0, v1, value)) + } + + /// Sets the [`preferred_spatial_layer` field](SimulcastConsumerDump#structfield.preferred_spatial_layer) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn preferred_spatial_layer_as_default( + self, + ) -> SimulcastConsumerDumpBuilder<(T0, T1, ::planus::DefaultValue)> + { + self.preferred_spatial_layer(::planus::DefaultValue) + } + } + + impl SimulcastConsumerDumpBuilder<(T0, T1, T2)> { + /// Setter for the [`target_spatial_layer` field](SimulcastConsumerDump#structfield.target_spatial_layer). + #[inline] + #[allow(clippy::type_complexity)] + pub fn target_spatial_layer( + self, + value: T3, + ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, T3)> + where + T3: ::planus::WriteAsDefault, + { + let (v0, v1, v2) = self.0; + SimulcastConsumerDumpBuilder((v0, v1, v2, value)) + } + + /// Sets the [`target_spatial_layer` field](SimulcastConsumerDump#structfield.target_spatial_layer) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn target_spatial_layer_as_default( + self, + ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, ::planus::DefaultValue)> + { + self.target_spatial_layer(::planus::DefaultValue) + } + } + + impl SimulcastConsumerDumpBuilder<(T0, T1, T2, T3)> { + /// Setter for the [`current_spatial_layer` field](SimulcastConsumerDump#structfield.current_spatial_layer). + #[inline] + #[allow(clippy::type_complexity)] + pub fn current_spatial_layer( + self, + value: T4, + ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4)> + where + T4: ::planus::WriteAsDefault, + { + let (v0, v1, v2, v3) = self.0; + SimulcastConsumerDumpBuilder((v0, v1, v2, v3, value)) + } + + /// Sets the [`current_spatial_layer` field](SimulcastConsumerDump#structfield.current_spatial_layer) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn current_spatial_layer_as_default( + self, + ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> + { + self.current_spatial_layer(::planus::DefaultValue) + } + } + + impl SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4)> { + /// Setter for the [`preferred_temporal_layer` field](SimulcastConsumerDump#structfield.preferred_temporal_layer). + #[inline] + #[allow(clippy::type_complexity)] + pub fn preferred_temporal_layer( + self, + value: T5, + ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> + where + T5: ::planus::WriteAsDefault, + { + let (v0, v1, v2, v3, v4) = self.0; + SimulcastConsumerDumpBuilder((v0, v1, v2, v3, v4, value)) + } + + /// Sets the [`preferred_temporal_layer` field](SimulcastConsumerDump#structfield.preferred_temporal_layer) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn preferred_temporal_layer_as_default( + self, + ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> + { + self.preferred_temporal_layer(::planus::DefaultValue) + } + } + + impl SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> { + /// Setter for the [`target_temporal_layer` field](SimulcastConsumerDump#structfield.target_temporal_layer). + #[inline] + #[allow(clippy::type_complexity)] + pub fn target_temporal_layer( + self, + value: T6, + ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> + where + T6: ::planus::WriteAsDefault, + { + let (v0, v1, v2, v3, v4, v5) = self.0; + SimulcastConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, value)) + } + + /// Sets the [`target_temporal_layer` field](SimulcastConsumerDump#structfield.target_temporal_layer) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn target_temporal_layer_as_default( + self, + ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, ::planus::DefaultValue)> + { + self.target_temporal_layer(::planus::DefaultValue) + } + } + + impl SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> { + /// Setter for the [`current_temporal_layer` field](SimulcastConsumerDump#structfield.current_temporal_layer). + #[inline] + #[allow(clippy::type_complexity)] + pub fn current_temporal_layer( + self, + value: T7, + ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + where + T7: ::planus::WriteAsDefault, + { + let (v0, v1, v2, v3, v4, v5, v6) = self.0; + SimulcastConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, v6, value)) + } + + /// Sets the [`current_temporal_layer` field](SimulcastConsumerDump#structfield.current_temporal_layer) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn current_temporal_layer_as_default( + self, + ) -> SimulcastConsumerDumpBuilder<( + T0, + T1, + T2, + T3, + T4, + T5, + T6, + ::planus::DefaultValue, + )> { + self.current_temporal_layer(::planus::DefaultValue) + } + } + + impl + SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SimulcastConsumerDump]. + #[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, + T4: ::planus::WriteAsDefault, + T5: ::planus::WriteAsDefault, + T6: ::planus::WriteAsDefault, + T7: ::planus::WriteAsDefault, + > ::planus::WriteAs<::planus::Offset> + for SimulcastConsumerDumpBuilder<(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, + T3: ::planus::WriteAsDefault, + T4: ::planus::WriteAsDefault, + T5: ::planus::WriteAsDefault, + T6: ::planus::WriteAsDefault, + T7: ::planus::WriteAsDefault, + > ::planus::WriteAsOptional<::planus::Offset> + for SimulcastConsumerDumpBuilder<(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, + T3: ::planus::WriteAsDefault, + T4: ::planus::WriteAsDefault, + T5: ::planus::WriteAsDefault, + T6: ::planus::WriteAsDefault, + T7: ::planus::WriteAsDefault, + > ::planus::WriteAsOffset + for SimulcastConsumerDumpBuilder<(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; + SimulcastConsumerDump::create(builder, v0, v1, v2, v3, v4, v5, v6, v7) + } + } + + /// Reference to a deserialized [SimulcastConsumerDump]. #[derive(Copy, Clone)] pub struct SimulcastConsumerDumpRef<'a>(::planus::table_reader::Table<'a>); impl<'a> SimulcastConsumerDumpRef<'a> { + /// Getter for the [`base` field](SimulcastConsumerDump#structfield.base). + #[inline] pub fn base(&self) -> ::planus::Result> { self.0.access_required(0, "SimulcastConsumerDump", "base") } + /// Getter for the [`rtp_stream` field](SimulcastConsumerDump#structfield.rtp_stream). + #[inline] pub fn rtp_stream(&self) -> ::planus::Result> { self.0 .access_required(1, "SimulcastConsumerDump", "rtp_stream") } + /// Getter for the [`preferred_spatial_layer` field](SimulcastConsumerDump#structfield.preferred_spatial_layer). + #[inline] pub fn preferred_spatial_layer(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -4375,6 +7468,8 @@ mod root { ) } + /// Getter for the [`target_spatial_layer` field](SimulcastConsumerDump#structfield.target_spatial_layer). + #[inline] pub fn target_spatial_layer(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -4383,6 +7478,8 @@ mod root { ) } + /// Getter for the [`current_spatial_layer` field](SimulcastConsumerDump#structfield.current_spatial_layer). + #[inline] pub fn current_spatial_layer(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -4391,6 +7488,8 @@ mod root { ) } + /// Getter for the [`preferred_temporal_layer` field](SimulcastConsumerDump#structfield.preferred_temporal_layer). + #[inline] pub fn preferred_temporal_layer(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -4399,6 +7498,8 @@ mod root { ) } + /// Getter for the [`target_temporal_layer` field](SimulcastConsumerDump#structfield.target_temporal_layer). + #[inline] pub fn target_temporal_layer(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -4407,6 +7508,8 @@ mod root { ) } + /// Getter for the [`current_temporal_layer` field](SimulcastConsumerDump#structfield.current_temporal_layer). + #[inline] pub fn current_temporal_layer(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -4466,6 +7569,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SimulcastConsumerDumpRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -4497,6 +7601,7 @@ mod root { impl ::planus::VectorWrite<::planus::Offset> for SimulcastConsumerDump { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -4537,21 +7642,39 @@ mod root { } } + /// The table `SvcConsumerDump` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `SvcConsumerDump` in the file `../worker/fbs/consumer.fbs:78` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct SvcConsumerDump { + /// The field `base` in the table `SvcConsumerDump` pub base: ::planus::alloc::boxed::Box, + /// The field `rtp_stream` in the table `SvcConsumerDump` pub rtp_stream: ::planus::alloc::boxed::Box, + /// The field `preferred_spatial_layer` in the table `SvcConsumerDump` pub preferred_spatial_layer: i16, + /// The field `target_spatial_layer` in the table `SvcConsumerDump` pub target_spatial_layer: i16, + /// The field `current_spatial_layer` in the table `SvcConsumerDump` pub current_spatial_layer: i16, + /// The field `preferred_temporal_layer` in the table `SvcConsumerDump` pub preferred_temporal_layer: i16, + /// The field `target_temporal_layer` in the table `SvcConsumerDump` pub target_temporal_layer: i16, + /// The field `current_temporal_layer` in the table `SvcConsumerDump` pub current_temporal_layer: i16, } impl SvcConsumerDump { + /// Creates a [SvcConsumerDumpBuilder] for serializing an instance of this table. + #[inline] + pub fn builder() -> SvcConsumerDumpBuilder<()> { + SvcConsumerDumpBuilder(()) + } + #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, @@ -4565,95 +7688,87 @@ mod root { field_current_temporal_layer: impl ::planus::WriteAsDefault, ) -> ::planus::Offset { let prepared_base = field_base.prepare(builder); - let prepared_rtp_stream = field_rtp_stream.prepare(builder); - let prepared_preferred_spatial_layer = field_preferred_spatial_layer.prepare(builder, &0); - let prepared_target_spatial_layer = field_target_spatial_layer.prepare(builder, &0); - let prepared_current_spatial_layer = field_current_spatial_layer.prepare(builder, &0); - let prepared_preferred_temporal_layer = field_preferred_temporal_layer.prepare(builder, &0); - let prepared_target_temporal_layer = field_target_temporal_layer.prepare(builder, &0); - let prepared_current_temporal_layer = field_current_temporal_layer.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<18, 20>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); + 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_preferred_spatial_layer.is_some() { - table_writer.calculate_size::(6); + table_writer.write_entry::(2); } if prepared_target_spatial_layer.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(3); } if prepared_current_spatial_layer.is_some() { - table_writer.calculate_size::(10); + table_writer.write_entry::(4); } if prepared_preferred_temporal_layer.is_some() { - table_writer.calculate_size::(12); + table_writer.write_entry::(5); } if prepared_target_temporal_layer.is_some() { - table_writer.calculate_size::(14); + table_writer.write_entry::(6); } if prepared_current_temporal_layer.is_some() { - table_writer.calculate_size::(16); + table_writer.write_entry::(7); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_base); - table_writer.write::<_, _, 4>(1, &prepared_rtp_stream); - if let ::core::option::Option::Some(prepared_preferred_spatial_layer) = - prepared_preferred_spatial_layer - { - table_writer.write::<_, _, 2>(2, &prepared_preferred_spatial_layer); - } - if let ::core::option::Option::Some(prepared_target_spatial_layer) = - prepared_target_spatial_layer - { - table_writer.write::<_, _, 2>(3, &prepared_target_spatial_layer); - } - if let ::core::option::Option::Some(prepared_current_spatial_layer) = - prepared_current_spatial_layer - { - table_writer.write::<_, _, 2>(4, &prepared_current_spatial_layer); - } - if let ::core::option::Option::Some(prepared_preferred_temporal_layer) = - prepared_preferred_temporal_layer - { - table_writer.write::<_, _, 2>(5, &prepared_preferred_temporal_layer); - } - if let ::core::option::Option::Some(prepared_target_temporal_layer) = - prepared_target_temporal_layer - { - table_writer.write::<_, _, 2>(6, &prepared_target_temporal_layer); - } - if let ::core::option::Option::Some(prepared_current_temporal_layer) = - prepared_current_temporal_layer - { - table_writer.write::<_, _, 2>(7, &prepared_current_temporal_layer); - } - } - - table_writer.finish() + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_base); + object_writer.write::<_, _, 4>(&prepared_rtp_stream); + 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 SvcConsumerDump { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -4665,6 +7780,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for SvcConsumerDump { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -4674,6 +7790,7 @@ mod root { } impl ::planus::WriteAsOffset for SvcConsumerDump { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -4682,28 +7799,303 @@ mod root { builder, &self.base, &self.rtp_stream, - &self.preferred_spatial_layer, - &self.target_spatial_layer, - &self.current_spatial_layer, - &self.preferred_temporal_layer, - &self.target_temporal_layer, - &self.current_temporal_layer, + 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 [SvcConsumerDump] type. + /// + /// Can be created using the [SvcConsumerDump::builder] method. + #[derive(Debug)] + #[must_use] + pub struct SvcConsumerDumpBuilder(State); + + impl SvcConsumerDumpBuilder<()> { + /// Setter for the [`base` field](SvcConsumerDump#structfield.base). + #[inline] + #[allow(clippy::type_complexity)] + pub fn base(self, value: T0) -> SvcConsumerDumpBuilder<(T0,)> + where + T0: ::planus::WriteAs<::planus::Offset>, + { + SvcConsumerDumpBuilder((value,)) + } + } + + impl SvcConsumerDumpBuilder<(T0,)> { + /// Setter for the [`rtp_stream` field](SvcConsumerDump#structfield.rtp_stream). + #[inline] + #[allow(clippy::type_complexity)] + pub fn rtp_stream(self, value: T1) -> SvcConsumerDumpBuilder<(T0, T1)> + where + T1: ::planus::WriteAs<::planus::Offset>, + { + let (v0,) = self.0; + SvcConsumerDumpBuilder((v0, value)) + } + } + + impl SvcConsumerDumpBuilder<(T0, T1)> { + /// Setter for the [`preferred_spatial_layer` field](SvcConsumerDump#structfield.preferred_spatial_layer). + #[inline] + #[allow(clippy::type_complexity)] + pub fn preferred_spatial_layer( + self, + value: T2, + ) -> SvcConsumerDumpBuilder<(T0, T1, T2)> + where + T2: ::planus::WriteAsDefault, + { + let (v0, v1) = self.0; + SvcConsumerDumpBuilder((v0, v1, value)) + } + + /// Sets the [`preferred_spatial_layer` field](SvcConsumerDump#structfield.preferred_spatial_layer) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn preferred_spatial_layer_as_default( + self, + ) -> SvcConsumerDumpBuilder<(T0, T1, ::planus::DefaultValue)> { + self.preferred_spatial_layer(::planus::DefaultValue) + } + } + + impl SvcConsumerDumpBuilder<(T0, T1, T2)> { + /// Setter for the [`target_spatial_layer` field](SvcConsumerDump#structfield.target_spatial_layer). + #[inline] + #[allow(clippy::type_complexity)] + pub fn target_spatial_layer( + self, + value: T3, + ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3)> + where + T3: ::planus::WriteAsDefault, + { + let (v0, v1, v2) = self.0; + SvcConsumerDumpBuilder((v0, v1, v2, value)) + } + + /// Sets the [`target_spatial_layer` field](SvcConsumerDump#structfield.target_spatial_layer) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn target_spatial_layer_as_default( + self, + ) -> SvcConsumerDumpBuilder<(T0, T1, T2, ::planus::DefaultValue)> { + self.target_spatial_layer(::planus::DefaultValue) + } + } + + impl SvcConsumerDumpBuilder<(T0, T1, T2, T3)> { + /// Setter for the [`current_spatial_layer` field](SvcConsumerDump#structfield.current_spatial_layer). + #[inline] + #[allow(clippy::type_complexity)] + pub fn current_spatial_layer( + self, + value: T4, + ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4)> + where + T4: ::planus::WriteAsDefault, + { + let (v0, v1, v2, v3) = self.0; + SvcConsumerDumpBuilder((v0, v1, v2, v3, value)) + } + + /// Sets the [`current_spatial_layer` field](SvcConsumerDump#structfield.current_spatial_layer) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn current_spatial_layer_as_default( + self, + ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> + { + self.current_spatial_layer(::planus::DefaultValue) + } + } + + impl SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4)> { + /// Setter for the [`preferred_temporal_layer` field](SvcConsumerDump#structfield.preferred_temporal_layer). + #[inline] + #[allow(clippy::type_complexity)] + pub fn preferred_temporal_layer( + self, + value: T5, + ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> + where + T5: ::planus::WriteAsDefault, + { + let (v0, v1, v2, v3, v4) = self.0; + SvcConsumerDumpBuilder((v0, v1, v2, v3, v4, value)) + } + + /// Sets the [`preferred_temporal_layer` field](SvcConsumerDump#structfield.preferred_temporal_layer) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn preferred_temporal_layer_as_default( + self, + ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> + { + self.preferred_temporal_layer(::planus::DefaultValue) + } + } + + impl SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> { + /// Setter for the [`target_temporal_layer` field](SvcConsumerDump#structfield.target_temporal_layer). + #[inline] + #[allow(clippy::type_complexity)] + pub fn target_temporal_layer( + self, + value: T6, + ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> + where + T6: ::planus::WriteAsDefault, + { + let (v0, v1, v2, v3, v4, v5) = self.0; + SvcConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, value)) + } + + /// Sets the [`target_temporal_layer` field](SvcConsumerDump#structfield.target_temporal_layer) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn target_temporal_layer_as_default( + self, + ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, ::planus::DefaultValue)> + { + self.target_temporal_layer(::planus::DefaultValue) + } + } + + impl SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> { + /// Setter for the [`current_temporal_layer` field](SvcConsumerDump#structfield.current_temporal_layer). + #[inline] + #[allow(clippy::type_complexity)] + pub fn current_temporal_layer( + self, + value: T7, + ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + where + T7: ::planus::WriteAsDefault, + { + let (v0, v1, v2, v3, v4, v5, v6) = self.0; + SvcConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, v6, value)) + } + + /// Sets the [`current_temporal_layer` field](SvcConsumerDump#structfield.current_temporal_layer) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn current_temporal_layer_as_default( + self, + ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, ::planus::DefaultValue)> + { + self.current_temporal_layer(::planus::DefaultValue) + } + } + + impl SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SvcConsumerDump]. + #[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, + T4: ::planus::WriteAsDefault, + T5: ::planus::WriteAsDefault, + T6: ::planus::WriteAsDefault, + T7: ::planus::WriteAsDefault, + > ::planus::WriteAs<::planus::Offset> + for SvcConsumerDumpBuilder<(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, + T3: ::planus::WriteAsDefault, + T4: ::planus::WriteAsDefault, + T5: ::planus::WriteAsDefault, + T6: ::planus::WriteAsDefault, + T7: ::planus::WriteAsDefault, + > ::planus::WriteAsOptional<::planus::Offset> + for SvcConsumerDumpBuilder<(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, + T3: ::planus::WriteAsDefault, + T4: ::planus::WriteAsDefault, + T5: ::planus::WriteAsDefault, + T6: ::planus::WriteAsDefault, + T7: ::planus::WriteAsDefault, + > ::planus::WriteAsOffset + for SvcConsumerDumpBuilder<(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; + SvcConsumerDump::create(builder, v0, v1, v2, v3, v4, v5, v6, v7) + } + } + + /// Reference to a deserialized [SvcConsumerDump]. #[derive(Copy, Clone)] pub struct SvcConsumerDumpRef<'a>(::planus::table_reader::Table<'a>); impl<'a> SvcConsumerDumpRef<'a> { + /// Getter for the [`base` field](SvcConsumerDump#structfield.base). + #[inline] pub fn base(&self) -> ::planus::Result> { self.0.access_required(0, "SvcConsumerDump", "base") } + /// Getter for the [`rtp_stream` field](SvcConsumerDump#structfield.rtp_stream). + #[inline] pub fn rtp_stream(&self) -> ::planus::Result> { self.0.access_required(1, "SvcConsumerDump", "rtp_stream") } + /// Getter for the [`preferred_spatial_layer` field](SvcConsumerDump#structfield.preferred_spatial_layer). + #[inline] pub fn preferred_spatial_layer(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -4712,6 +8104,8 @@ mod root { ) } + /// Getter for the [`target_spatial_layer` field](SvcConsumerDump#structfield.target_spatial_layer). + #[inline] pub fn target_spatial_layer(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -4720,6 +8114,8 @@ mod root { ) } + /// Getter for the [`current_spatial_layer` field](SvcConsumerDump#structfield.current_spatial_layer). + #[inline] pub fn current_spatial_layer(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -4728,6 +8124,8 @@ mod root { ) } + /// Getter for the [`preferred_temporal_layer` field](SvcConsumerDump#structfield.preferred_temporal_layer). + #[inline] pub fn preferred_temporal_layer(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -4736,6 +8134,8 @@ mod root { ) } + /// Getter for the [`target_temporal_layer` field](SvcConsumerDump#structfield.target_temporal_layer). + #[inline] pub fn target_temporal_layer(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -4744,6 +8144,8 @@ mod root { ) } + /// Getter for the [`current_temporal_layer` field](SvcConsumerDump#structfield.current_temporal_layer). + #[inline] pub fn current_temporal_layer(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -4803,6 +8205,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SvcConsumerDumpRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -4834,6 +8237,7 @@ mod root { impl ::planus::VectorWrite<::planus::Offset> for SvcConsumerDump { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -4870,15 +8274,27 @@ mod root { } } + /// The table `PipeConsumerDump` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `PipeConsumerDump` in the file `../worker/fbs/consumer.fbs:89` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct PipeConsumerDump { + /// The field `base` in the table `PipeConsumerDump` pub base: ::planus::alloc::boxed::Box, + /// The field `rtp_streams` in the table `PipeConsumerDump` pub rtp_streams: ::planus::alloc::vec::Vec, } impl PipeConsumerDump { + /// Creates a [PipeConsumerDumpBuilder] for serializing an instance of this table. + #[inline] + pub fn builder() -> PipeConsumerDumpBuilder<()> { + PipeConsumerDumpBuilder(()) + } + #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, @@ -4888,29 +8304,27 @@ mod root { >, ) -> ::planus::Offset { let prepared_base = field_base.prepare(builder); - let prepared_rtp_streams = field_rtp_streams.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_base); - table_writer.write::<_, _, 4>(1, &prepared_rtp_streams); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_base); + object_writer.write::<_, _, 4>(&prepared_rtp_streams); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for PipeConsumerDump { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -4922,6 +8336,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for PipeConsumerDump { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -4931,6 +8346,7 @@ mod root { } impl ::planus::WriteAsOffset for PipeConsumerDump { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -4939,14 +8355,122 @@ mod root { } } + /// Builder for serializing an instance of the [PipeConsumerDump] type. + /// + /// Can be created using the [PipeConsumerDump::builder] method. + #[derive(Debug)] + #[must_use] + pub struct PipeConsumerDumpBuilder(State); + + impl PipeConsumerDumpBuilder<()> { + /// Setter for the [`base` field](PipeConsumerDump#structfield.base). + #[inline] + #[allow(clippy::type_complexity)] + pub fn base(self, value: T0) -> PipeConsumerDumpBuilder<(T0,)> + where + T0: ::planus::WriteAs<::planus::Offset>, + { + PipeConsumerDumpBuilder((value,)) + } + } + + impl PipeConsumerDumpBuilder<(T0,)> { + /// Setter for the [`rtp_streams` field](PipeConsumerDump#structfield.rtp_streams). + #[inline] + #[allow(clippy::type_complexity)] + pub fn rtp_streams(self, value: T1) -> PipeConsumerDumpBuilder<(T0, T1)> + where + T1: ::planus::WriteAs< + ::planus::Offset<[::planus::Offset]>, + >, + { + let (v0,) = self.0; + PipeConsumerDumpBuilder((v0, value)) + } + } + + impl PipeConsumerDumpBuilder<(T0, T1)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [PipeConsumerDump]. + #[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 PipeConsumerDumpBuilder<(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 PipeConsumerDumpBuilder<(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 PipeConsumerDumpBuilder<(T0, T1)> + { + #[inline] + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + let (v0, v1) = &self.0; + PipeConsumerDump::create(builder, v0, v1) + } + } + + /// Reference to a deserialized [PipeConsumerDump]. #[derive(Copy, Clone)] pub struct PipeConsumerDumpRef<'a>(::planus::table_reader::Table<'a>); impl<'a> PipeConsumerDumpRef<'a> { + /// Getter for the [`base` field](PipeConsumerDump#structfield.base). + #[inline] pub fn base(&self) -> ::planus::Result> { self.0.access_required(0, "PipeConsumerDump", "base") } + /// Getter for the [`rtp_streams` field](PipeConsumerDump#structfield.rtp_streams). + #[inline] pub fn rtp_streams( &self, ) -> ::planus::Result< @@ -4980,6 +8504,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for PipeConsumerDumpRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -5011,6 +8536,7 @@ mod root { impl ::planus::VectorWrite<::planus::Offset> for PipeConsumerDump { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -5047,10 +8573,15 @@ mod root { } } + /// The table `GetStatsResponse` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `GetStatsResponse` in the file `../worker/fbs/consumer.fbs:94` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct GetStatsResponse { + /// The field `stats` in the table `GetStatsResponse` pub stats: ::core::option::Option<::planus::alloc::vec::Vec>, } @@ -5065,6 +8596,12 @@ mod root { } 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, @@ -5074,28 +8611,27 @@ mod root { ) -> ::planus::Offset { let prepared_stats = field_stats.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_stats.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_stats) = prepared_stats { - table_writer.write::<_, _, 4>(0, &prepared_stats); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_stats) = prepared_stats { + object_writer.write::<_, _, 4>(&prepared_stats); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -5107,6 +8643,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -5116,6 +8653,7 @@ mod root { } impl ::planus::WriteAsOffset for GetStatsResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -5124,10 +8662,107 @@ mod root { } } + /// 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::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + { + GetStatsResponseBuilder((value,)) + } + + /// Sets the [`stats` field](GetStatsResponse#structfield.stats) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn stats_as_null(self) -> GetStatsResponseBuilder<((),)> { + self.stats(()) + } + } + + 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::WriteAsOptional< + ::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::WriteAsOptional< + ::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::WriteAsOptional< + ::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< @@ -5165,6 +8800,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -5196,6 +8832,7 @@ mod root { 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) } @@ -5232,6 +8869,10 @@ mod root { } } + /// The table `LayersChangeNotification` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `LayersChangeNotification` in the file `../worker/fbs/consumer.fbs:100` #[derive( Clone, Debug, @@ -5244,6 +8885,7 @@ mod root { ::serde::Deserialize, )] pub struct LayersChangeNotification { + /// The field `layers` in the table `LayersChangeNotification` pub layers: ::core::option::Option<::planus::alloc::boxed::Box>, } @@ -5258,6 +8900,12 @@ mod root { } 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, @@ -5265,28 +8913,27 @@ mod root { ) -> ::planus::Offset { let prepared_layers = field_layers.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_layers.is_some() { - table_writer.calculate_size::<::planus::Offset>(2); + table_writer.write_entry::<::planus::Offset>(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_layers) = prepared_layers { - table_writer.write::<_, _, 4>(0, &prepared_layers); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_layers) = prepared_layers { + object_writer.write::<_, _, 4>(&prepared_layers); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for LayersChangeNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -5300,6 +8947,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -5310,6 +8958,7 @@ mod root { } impl ::planus::WriteAsOffset for LayersChangeNotification { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -5318,10 +8967,98 @@ mod root { } } + /// 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::WriteAsOptional<::planus::Offset>, + { + LayersChangeNotificationBuilder((value,)) + } + + /// Sets the [`layers` field](LayersChangeNotification#structfield.layers) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn layers_as_null(self) -> LayersChangeNotificationBuilder<((),)> { + self.layers(()) + } + } + + 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<::core::option::Option>> @@ -5358,6 +9095,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for LayersChangeNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -5391,6 +9129,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -5431,6 +9170,10 @@ mod root { } } + /// The table `RtpNotification` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `RtpNotification` in the file `../worker/fbs/consumer.fbs:104` #[derive( Clone, Debug, @@ -5443,10 +9186,17 @@ mod root { ::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, @@ -5454,24 +9204,23 @@ mod root { ) -> ::planus::Offset { let prepared_data = field_data.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset<[u8]>>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset<[u8]>>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_data); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_data); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for RtpNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -5483,6 +9232,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for RtpNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -5492,6 +9242,7 @@ mod root { } impl ::planus::WriteAsOffset for RtpNotification { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -5500,11 +9251,90 @@ mod root { } } + /// 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> { - pub fn data(&self) -> ::planus::Result<::planus::Vector<'a, u8>> { + /// Getter for the [`data` field](RtpNotification#structfield.data). + #[inline] + pub fn data(&self) -> ::planus::Result<&'a [u8]> { self.0.access_required(0, "RtpNotification", "data") } } @@ -5523,12 +9353,13 @@ mod root { #[allow(unreachable_code)] fn try_from(value: RtpNotificationRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - data: value.data()?.to_vec()?, + data: value.data()?.to_vec(), }) } } impl<'a> ::planus::TableRead<'a> for RtpNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -5560,6 +9391,7 @@ mod root { 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) } @@ -5596,6 +9428,10 @@ mod root { } } + /// The table `ScoreNotification` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `ScoreNotification` in the file `../worker/fbs/consumer.fbs:108` #[derive( Clone, Debug, @@ -5608,6 +9444,7 @@ mod root { ::serde::Deserialize, )] pub struct ScoreNotification { + /// The field `score` in the table `ScoreNotification` pub score: ::planus::alloc::boxed::Box, } @@ -5621,6 +9458,12 @@ mod root { } 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, @@ -5628,24 +9471,23 @@ mod root { ) -> ::planus::Offset { let prepared_score = field_score.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_score); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_score); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for ScoreNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -5657,6 +9499,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ScoreNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -5666,6 +9509,7 @@ mod root { } impl ::planus::WriteAsOffset for ScoreNotification { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -5674,10 +9518,89 @@ mod root { } } + /// 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") } @@ -5705,6 +9628,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ScoreNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -5736,6 +9660,7 @@ mod root { 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) } @@ -5772,6 +9697,10 @@ mod root { } } + /// The enum `TraceType` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Enum `TraceType` in the file `../worker/fbs/consumer.fbs:112` #[derive( Copy, Clone, @@ -5786,15 +9715,31 @@ mod root { )] #[repr(u8)] pub enum TraceType { + /// The variant `KEYFRAME` in the enum `TraceType` Keyframe = 0, + + /// The variant `FIR` in the enum `TraceType` Fir = 1, + + /// The variant `NACK` in the enum `TraceType` Nack = 2, + + /// The variant `PLI` in the enum `TraceType` Pli = 3, + + /// The variant `RTP` in the enum `TraceType` Rtp = 4, } + impl TraceType { + /// Array containing all valid variants of TraceType + pub const ENUM_VALUES: [Self; 5] = + [Self::Keyframe, Self::Fir, Self::Nack, Self::Pli, Self::Rtp]; + } + impl ::core::convert::TryFrom for TraceType { type Error = ::planus::errors::UnknownEnumTagKind; + #[inline] fn try_from( value: u8, ) -> ::core::result::Result @@ -5815,6 +9760,7 @@ mod root { } impl ::core::convert::From for u8 { + #[inline] fn from(value: TraceType) -> Self { value as u8 } @@ -5875,6 +9821,7 @@ mod root { } impl<'buf> ::planus::TableRead<'buf> for TraceType { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, @@ -5893,7 +9840,7 @@ mod root { offset: usize, ) -> ::core::result::Result { - let value = ::from_buffer(buffer, offset); + let value = *buffer.buffer.get_unchecked(offset); let value: ::core::result::Result = ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { @@ -5911,6 +9858,7 @@ mod root { type Value = Self; + #[inline] fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { *self } @@ -5932,6 +9880,10 @@ mod root { } } + /// The enum `TraceDirection` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Enum `TraceDirection` in the file `../worker/fbs/consumer.fbs:114` #[derive( Copy, Clone, @@ -5946,12 +9898,21 @@ mod root { )] #[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 @@ -5969,6 +9930,7 @@ mod root { } impl ::core::convert::From for u8 { + #[inline] fn from(value: TraceDirection) -> Self { value as u8 } @@ -6029,6 +9991,7 @@ mod root { } impl<'buf> ::planus::TableRead<'buf> for TraceDirection { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, @@ -6047,7 +10010,7 @@ mod root { offset: usize, ) -> ::core::result::Result { - let value = ::from_buffer(buffer, offset); + let value = *buffer.buffer.get_unchecked(offset); let value: ::core::result::Result = ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { @@ -6065,6 +10028,7 @@ mod root { type Value = Self; + #[inline] fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { *self } @@ -6086,6 +10050,10 @@ mod root { } } + /// The union `TraceInfo` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Union `TraceInfo` in the file `../worker/fbs/consumer.fbs:116` #[derive( Clone, Debug, @@ -6098,13 +10066,27 @@ mod root { ::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, @@ -6112,6 +10094,7 @@ mod root { ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) } + #[inline] pub fn create_fir_trace_info( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -6119,6 +10102,7 @@ mod root { ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) } + #[inline] pub fn create_pli_trace_info( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -6126,6 +10110,7 @@ mod root { ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) } + #[inline] pub fn create_rtp_trace_info( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -6135,6 +10120,7 @@ mod root { } impl ::planus::WriteAsUnion for TraceInfo { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { match self { Self::KeyFrameTraceInfo(value) => { @@ -6148,6 +10134,7 @@ mod root { } impl ::planus::WriteAsOptionalUnion for TraceInfo { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -6156,6 +10143,179 @@ mod root { } } + /// 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>), @@ -6170,25 +10330,25 @@ mod root { fn try_from(value: TraceInfoRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(match value { TraceInfoRef::KeyFrameTraceInfo(value) => { - TraceInfo::KeyFrameTraceInfo(::planus::alloc::boxed::Box::new( + Self::KeyFrameTraceInfo(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } TraceInfoRef::FirTraceInfo(value) => { - TraceInfo::FirTraceInfo(::planus::alloc::boxed::Box::new( + Self::FirTraceInfo(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } TraceInfoRef::PliTraceInfo(value) => { - TraceInfo::PliTraceInfo(::planus::alloc::boxed::Box::new( + Self::PliTraceInfo(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } TraceInfoRef::RtpTraceInfo(value) => { - TraceInfo::RtpTraceInfo(::planus::alloc::boxed::Box::new( + Self::RtpTraceInfo(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -6222,6 +10382,10 @@ mod root { } } + /// The table `KeyFrameTraceInfo` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/consumer.fbs:123` #[derive( Clone, Debug, @@ -6234,6 +10398,7 @@ mod root { ::serde::Deserialize, )] pub struct KeyFrameTraceInfo { + /// The field `is_rtx` in the table `KeyFrameTraceInfo` pub is_rtx: bool, } @@ -6245,6 +10410,12 @@ mod root { } 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, @@ -6252,28 +10423,27 @@ mod root { ) -> ::planus::Offset { let prepared_is_rtx = field_is_rtx.prepare(builder, &false); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 1>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_is_rtx.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { - table_writer.write::<_, _, 1>(0, &prepared_is_rtx); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { + object_writer.write::<_, _, 1>(&prepared_is_rtx); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for KeyFrameTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -6285,6 +10455,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for KeyFrameTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -6294,18 +10465,107 @@ mod root { } impl ::planus::WriteAsOffset for KeyFrameTraceInfo { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - KeyFrameTraceInfo::create(builder, &self.is_rtx) + KeyFrameTraceInfo::create(builder, 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 [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx). + #[inline] + #[allow(clippy::type_complexity)] + pub fn is_rtx(self, value: T0) -> KeyFrameTraceInfoBuilder<(T0,)> + where + T0: ::planus::WriteAsDefault, + { + KeyFrameTraceInfoBuilder((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<(::planus::DefaultValue,)> { + self.is_rtx(::planus::DefaultValue) + } + } + + impl KeyFrameTraceInfoBuilder<(T0,)> { + /// 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> + ::planus::WriteAs<::planus::Offset> + for KeyFrameTraceInfoBuilder<(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 KeyFrameTraceInfoBuilder<(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 KeyFrameTraceInfoBuilder<(T0,)> + { + #[inline] + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + let (v0,) = &self.0; + KeyFrameTraceInfo::create(builder, v0) + } + } + + /// Reference to a deserialized [KeyFrameTraceInfo]. #[derive(Copy, Clone)] pub struct KeyFrameTraceInfoRef<'a>(::planus::table_reader::Table<'a>); impl<'a> KeyFrameTraceInfoRef<'a> { + /// Getter for the [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx). + #[inline] pub fn is_rtx(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -6335,6 +10595,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for KeyFrameTraceInfoRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -6366,6 +10627,7 @@ mod root { 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) } @@ -6402,6 +10664,10 @@ mod root { } } + /// The table `FirTraceInfo` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `FirTraceInfo` in the file `../worker/fbs/consumer.fbs:127` #[derive( Clone, Debug, @@ -6414,6 +10680,7 @@ mod root { ::serde::Deserialize, )] pub struct FirTraceInfo { + /// The field `ssrc` in the table `FirTraceInfo` pub ssrc: u32, } @@ -6425,6 +10692,12 @@ mod root { } 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, @@ -6432,28 +10705,27 @@ mod root { ) -> ::planus::Offset { let prepared_ssrc = field_ssrc.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_ssrc.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - table_writer.write::<_, _, 4>(0, &prepared_ssrc); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + object_writer.write::<_, _, 4>(&prepared_ssrc); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for FirTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -6465,6 +10737,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for FirTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -6474,18 +10747,104 @@ mod root { } impl ::planus::WriteAsOffset for FirTraceInfo { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - FirTraceInfo::create(builder, &self.ssrc) + 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), @@ -6513,6 +10872,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for FirTraceInfoRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -6544,6 +10904,7 @@ mod root { 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) } @@ -6580,6 +10941,10 @@ mod root { } } + /// The table `PliTraceInfo` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `PliTraceInfo` in the file `../worker/fbs/consumer.fbs:131` #[derive( Clone, Debug, @@ -6592,6 +10957,7 @@ mod root { ::serde::Deserialize, )] pub struct PliTraceInfo { + /// The field `ssrc` in the table `PliTraceInfo` pub ssrc: u32, } @@ -6603,6 +10969,12 @@ mod root { } 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, @@ -6610,28 +10982,27 @@ mod root { ) -> ::planus::Offset { let prepared_ssrc = field_ssrc.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_ssrc.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - table_writer.write::<_, _, 4>(0, &prepared_ssrc); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + object_writer.write::<_, _, 4>(&prepared_ssrc); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for PliTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -6643,6 +11014,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for PliTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -6652,18 +11024,104 @@ mod root { } impl ::planus::WriteAsOffset for PliTraceInfo { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - PliTraceInfo::create(builder, &self.ssrc) + 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), @@ -6691,6 +11149,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for PliTraceInfoRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -6722,6 +11181,7 @@ mod root { 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) } @@ -6758,6 +11218,10 @@ mod root { } } + /// The table `RtpTraceInfo` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `RtpTraceInfo` in the file `../worker/fbs/consumer.fbs:135` #[derive( Clone, Debug, @@ -6770,6 +11234,7 @@ mod root { ::serde::Deserialize, )] pub struct RtpTraceInfo { + /// The field `is_rtx` in the table `RtpTraceInfo` pub is_rtx: bool, } @@ -6781,6 +11246,12 @@ mod root { } 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, @@ -6788,28 +11259,27 @@ mod root { ) -> ::planus::Offset { let prepared_is_rtx = field_is_rtx.prepare(builder, &false); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 1>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_is_rtx.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { - table_writer.write::<_, _, 1>(0, &prepared_is_rtx); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { + object_writer.write::<_, _, 1>(&prepared_is_rtx); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for RtpTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -6821,6 +11291,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for RtpTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -6830,18 +11301,104 @@ mod root { } impl ::planus::WriteAsOffset for RtpTraceInfo { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - RtpTraceInfo::create(builder, &self.is_rtx) + RtpTraceInfo::create(builder, 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 [`is_rtx` field](RtpTraceInfo#structfield.is_rtx). + #[inline] + #[allow(clippy::type_complexity)] + pub fn is_rtx(self, value: T0) -> RtpTraceInfoBuilder<(T0,)> + where + T0: ::planus::WriteAsDefault, + { + RtpTraceInfoBuilder((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<(::planus::DefaultValue,)> { + self.is_rtx(::planus::DefaultValue) + } + } + + impl RtpTraceInfoBuilder<(T0,)> { + /// 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> + ::planus::WriteAs<::planus::Offset> for RtpTraceInfoBuilder<(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 RtpTraceInfoBuilder<(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 RtpTraceInfoBuilder<(T0,)> + { + #[inline] + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + let (v0,) = &self.0; + RtpTraceInfo::create(builder, v0) + } + } + + /// Reference to a deserialized [RtpTraceInfo]. #[derive(Copy, Clone)] pub struct RtpTraceInfoRef<'a>(::planus::table_reader::Table<'a>); impl<'a> RtpTraceInfoRef<'a> { + /// 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(0, "RtpTraceInfo", "is_rtx")?.unwrap_or(false), @@ -6869,6 +11426,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RtpTraceInfoRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -6900,6 +11458,7 @@ mod root { 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) } @@ -6936,6 +11495,10 @@ mod root { } } + /// The table `TraceNotification` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Table `TraceNotification` in the file `../worker/fbs/consumer.fbs:139` #[derive( Clone, Debug, @@ -6948,9 +11511,13 @@ mod root { ::serde::Deserialize, )] pub struct TraceNotification { + /// The field `type` in the table `TraceNotification` pub type_: self::TraceType, + /// The field `timestamp` in the table `TraceNotification` pub timestamp: u64, + /// The field `direction` in the table `TraceNotification` pub direction: self::TraceDirection, + /// The field `info` in the table `TraceNotification` pub info: ::core::option::Option, } @@ -6967,6 +11534,12 @@ mod root { } 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, @@ -6979,60 +11552,60 @@ mod root { field_info: impl ::planus::WriteAsOptionalUnion, ) -> ::planus::Offset { let prepared_type_ = field_type_.prepare(builder, &self::TraceType::Keyframe); - let prepared_timestamp = field_timestamp.prepare(builder, &0); - let prepared_direction = field_direction.prepare(builder, &self::TraceDirection::DirectionIn); - let prepared_info = field_info.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<10, 15>::new(builder); - - if prepared_type_.is_some() { - table_writer.calculate_size::(2); - } + let mut table_writer: ::planus::table_writer::TableWriter<14> = + ::core::default::Default::default(); if prepared_timestamp.is_some() { - table_writer.calculate_size::(4); + 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.calculate_size::(6); + table_writer.write_entry::(2); } if prepared_info.is_some() { - table_writer.calculate_size::(8); - table_writer.calculate_size::<::planus::Offset>(10); + table_writer.write_entry::(3); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_timestamp) = prepared_timestamp - { - table_writer.write::<_, _, 8>(1, &prepared_timestamp); - } - if let ::core::option::Option::Some(prepared_info) = prepared_info { - table_writer.write::<_, _, 4>(4, &prepared_info.offset()); - } - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - table_writer.write::<_, _, 1>(0, &prepared_type_); - } - if let ::core::option::Option::Some(prepared_direction) = prepared_direction - { - table_writer.write::<_, _, 1>(2, &prepared_direction); - } - if let ::core::option::Option::Some(prepared_info) = prepared_info { - table_writer.write::<_, _, 1>(3, &prepared_info.tag()); - } - } - - table_writer.finish() + 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, @@ -7044,6 +11617,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for TraceNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -7053,24 +11627,190 @@ mod root { } 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.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, + { + 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, + 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, + 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, + 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 @@ -7079,6 +11819,8 @@ mod root { ) } + /// Getter for the [`timestamp` field](TraceNotification#structfield.timestamp). + #[inline] pub fn timestamp(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -7087,6 +11829,8 @@ mod root { ) } + /// Getter for the [`direction` field](TraceNotification#structfield.direction). + #[inline] pub fn direction(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -7095,6 +11839,8 @@ mod root { ) } + /// Getter for the [`info` field](TraceNotification#structfield.info). + #[inline] pub fn info( &self, ) -> ::planus::Result<::core::option::Option>> @@ -7135,6 +11881,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for TraceNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -7166,6 +11913,7 @@ mod root { 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) } @@ -7202,7 +11950,15 @@ mod root { } } } + /// 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:4` #[derive( Copy, Clone, @@ -7217,13 +11973,24 @@ mod root { )] #[repr(u8)] pub enum MediaKind { + /// The variant `ALL` in the enum `MediaKind` All = 0, + + /// The variant `AUDIO` in the enum `MediaKind` Audio = 1, + + /// The variant `VIDEO` in the enum `MediaKind` Video = 2, } + impl MediaKind { + /// Array containing all valid variants of MediaKind + pub const ENUM_VALUES: [Self; 3] = [Self::All, Self::Audio, Self::Video]; + } + impl ::core::convert::TryFrom for MediaKind { type Error = ::planus::errors::UnknownEnumTagKind; + #[inline] fn try_from( value: u8, ) -> ::core::result::Result @@ -7242,6 +12009,7 @@ mod root { } impl ::core::convert::From for u8 { + #[inline] fn from(value: MediaKind) -> Self { value as u8 } @@ -7302,6 +12070,7 @@ mod root { } impl<'buf> ::planus::TableRead<'buf> for MediaKind { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, @@ -7320,7 +12089,7 @@ mod root { offset: usize, ) -> ::core::result::Result { - let value = ::from_buffer(buffer, offset); + let value = *buffer.buffer.get_unchecked(offset); let value: ::core::result::Result = ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { @@ -7338,6 +12107,7 @@ mod root { type Value = Self; + #[inline] fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { *self } @@ -7359,6 +12129,10 @@ mod root { } } + /// The enum `Type` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Enum `Type` in the file `../worker/fbs/rtpParameters.fbs:5` #[derive( Copy, Clone, @@ -7373,15 +12147,36 @@ mod root { )] #[repr(u8)] pub enum Type { + /// The variant `NONE` in the enum `Type` None = 0, + + /// The variant `SIMPLE` in the enum `Type` Simple = 1, + + /// The variant `SIMULCAST` in the enum `Type` Simulcast = 2, + + /// The variant `SVC` in the enum `Type` Svc = 3, + + /// The variant `PIPE` in the enum `Type` Pipe = 4, } + impl Type { + /// Array containing all valid variants of Type + pub const ENUM_VALUES: [Self; 5] = [ + Self::None, + 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 @@ -7402,6 +12197,7 @@ mod root { } impl ::core::convert::From for u8 { + #[inline] fn from(value: Type) -> Self { value as u8 } @@ -7462,6 +12258,7 @@ mod root { } impl<'buf> ::planus::TableRead<'buf> for Type { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, @@ -7480,7 +12277,7 @@ mod root { offset: usize, ) -> ::core::result::Result { - let value = ::from_buffer(buffer, offset); + let value = *buffer.buffer.get_unchecked(offset); let value: ::core::result::Result = ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { @@ -7498,6 +12295,7 @@ mod root { type Value = Self; + #[inline] fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { *self } @@ -7519,6 +12317,10 @@ mod root { } } + /// The table `Boolean` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Table `Boolean` in the file `../worker/fbs/rtpParameters.fbs:8` #[derive( Clone, Debug, @@ -7531,6 +12333,7 @@ mod root { ::serde::Deserialize, )] pub struct Boolean { + /// The field `value` in the table `Boolean` pub value: u8, } @@ -7542,6 +12345,12 @@ mod root { } 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, @@ -7549,28 +12358,27 @@ mod root { ) -> ::planus::Offset { let prepared_value = field_value.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 1>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_value.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_value) = prepared_value { - table_writer.write::<_, _, 1>(0, &prepared_value); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_value) = prepared_value { + object_writer.write::<_, _, 1>(&prepared_value); + } + }); } - - table_writer.finish() + 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) } @@ -7579,6 +12387,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Boolean { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -7588,15 +12397,91 @@ mod root { } 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 { - Boolean::create(builder, &self.value) + ::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)) } @@ -7622,6 +12507,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for BooleanRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -7653,6 +12539,7 @@ mod root { 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) } @@ -7689,6 +12576,10 @@ mod root { } } + /// The table `Integer` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Table `Integer` in the file `../worker/fbs/rtpParameters.fbs:12` #[derive( Clone, Debug, @@ -7701,6 +12592,7 @@ mod root { ::serde::Deserialize, )] pub struct Integer { + /// The field `value` in the table `Integer` pub value: i32, } @@ -7712,6 +12604,12 @@ mod root { } impl Integer { + /// Creates a [IntegerBuilder] for serializing an instance of this table. + #[inline] + pub fn builder() -> IntegerBuilder<()> { + IntegerBuilder(()) + } + #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, @@ -7719,28 +12617,27 @@ mod root { ) -> ::planus::Offset { let prepared_value = field_value.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_value.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_value) = prepared_value { - table_writer.write::<_, _, 4>(0, &prepared_value); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_value) = prepared_value { + object_writer.write::<_, _, 4>(&prepared_value); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for Integer { type Prepared = ::planus::Offset; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } @@ -7749,6 +12646,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Integer { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -7758,15 +12656,91 @@ mod root { } impl ::planus::WriteAsOffset for Integer { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Integer::create(builder, &self.value) + Integer::create(builder, self.value) } } + /// Builder for serializing an instance of the [Integer] type. + /// + /// Can be created using the [Integer::builder] method. + #[derive(Debug)] + #[must_use] + pub struct IntegerBuilder(State); + + impl IntegerBuilder<()> { + /// Setter for the [`value` field](Integer#structfield.value). + #[inline] + #[allow(clippy::type_complexity)] + pub fn value(self, value: T0) -> IntegerBuilder<(T0,)> + where + T0: ::planus::WriteAsDefault, + { + IntegerBuilder((value,)) + } + + /// Sets the [`value` field](Integer#structfield.value) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn value_as_default(self) -> IntegerBuilder<(::planus::DefaultValue,)> { + self.value(::planus::DefaultValue) + } + } + + impl IntegerBuilder<(T0,)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Integer]. + #[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 IntegerBuilder<(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 IntegerBuilder<(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 IntegerBuilder<(T0,)> + { + #[inline] + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + let (v0,) = &self.0; + Integer::create(builder, v0) + } + } + + /// Reference to a deserialized [Integer]. #[derive(Copy, Clone)] pub struct IntegerRef<'a>(::planus::table_reader::Table<'a>); impl<'a> IntegerRef<'a> { + /// Getter for the [`value` field](Integer#structfield.value). + #[inline] pub fn value(&self) -> ::planus::Result { ::core::result::Result::Ok(self.0.access(0, "Integer", "value")?.unwrap_or(0)) } @@ -7792,6 +12766,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for IntegerRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -7823,6 +12798,7 @@ mod root { impl ::planus::VectorWrite<::planus::Offset> for Integer { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -7859,6 +12835,10 @@ mod root { } } + /// The table `IntegerArray` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Table `IntegerArray` in the file `../worker/fbs/rtpParameters.fbs:16` #[derive( Clone, Debug, @@ -7871,6 +12851,7 @@ mod root { ::serde::Deserialize, )] pub struct IntegerArray { + /// The field `value` in the table `IntegerArray` pub value: ::core::option::Option<::planus::alloc::vec::Vec>, } @@ -7884,6 +12865,12 @@ mod root { } impl IntegerArray { + /// Creates a [IntegerArrayBuilder] for serializing an instance of this table. + #[inline] + pub fn builder() -> IntegerArrayBuilder<()> { + IntegerArrayBuilder(()) + } + #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, @@ -7891,28 +12878,27 @@ mod root { ) -> ::planus::Offset { let prepared_value = field_value.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_value.is_some() { - table_writer.calculate_size::<::planus::Offset<[i32]>>(2); + table_writer.write_entry::<::planus::Offset<[i32]>>(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_value) = prepared_value { - table_writer.write::<_, _, 4>(0, &prepared_value); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_value) = prepared_value { + object_writer.write::<_, _, 4>(&prepared_value); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for IntegerArray { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -7924,6 +12910,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for IntegerArray { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -7933,6 +12920,7 @@ mod root { } impl ::planus::WriteAsOffset for IntegerArray { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -7941,10 +12929,95 @@ mod root { } } + /// Builder for serializing an instance of the [IntegerArray] type. + /// + /// Can be created using the [IntegerArray::builder] method. + #[derive(Debug)] + #[must_use] + pub struct IntegerArrayBuilder(State); + + impl IntegerArrayBuilder<()> { + /// Setter for the [`value` field](IntegerArray#structfield.value). + #[inline] + #[allow(clippy::type_complexity)] + pub fn value(self, value: T0) -> IntegerArrayBuilder<(T0,)> + where + T0: ::planus::WriteAsOptional<::planus::Offset<[i32]>>, + { + IntegerArrayBuilder((value,)) + } + + /// Sets the [`value` field](IntegerArray#structfield.value) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn value_as_null(self) -> IntegerArrayBuilder<((),)> { + self.value(()) + } + } + + impl IntegerArrayBuilder<(T0,)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [IntegerArray]. + #[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 IntegerArrayBuilder<(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 IntegerArrayBuilder<(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 IntegerArrayBuilder<(T0,)> + { + #[inline] + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + let (v0,) = &self.0; + IntegerArray::create(builder, v0) + } + } + + /// Reference to a deserialized [IntegerArray]. #[derive(Copy, Clone)] pub struct IntegerArrayRef<'a>(::planus::table_reader::Table<'a>); impl<'a> IntegerArrayRef<'a> { + /// Getter for the [`value` field](IntegerArray#structfield.value). + #[inline] pub fn value( &self, ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, i32>>> @@ -7979,6 +13052,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for IntegerArrayRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -8010,6 +13084,7 @@ mod root { impl ::planus::VectorWrite<::planus::Offset> for IntegerArray { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -8046,10 +13121,15 @@ mod root { } } + /// The table `Double` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Table `Double` in the file `../worker/fbs/rtpParameters.fbs:20` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct Double { + /// The field `value` in the table `Double` pub value: f64, } @@ -8061,6 +13141,12 @@ mod root { } 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, @@ -8068,28 +13154,27 @@ mod root { ) -> ::planus::Offset { let prepared_value = field_value.prepare(builder, &0.0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 8>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_value.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_value) = prepared_value { - table_writer.write::<_, _, 8>(0, &prepared_value); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_value) = prepared_value { + object_writer.write::<_, _, 8>(&prepared_value); + } + }); } - - table_writer.finish() + 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) } @@ -8098,6 +13183,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Double { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -8107,15 +13193,91 @@ mod root { } 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 { - Double::create(builder, &self.value) + 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)) } @@ -8141,6 +13303,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DoubleRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -8172,6 +13335,7 @@ mod root { 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) } @@ -8208,6 +13372,10 @@ mod root { } } + /// The table `String` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Table `String` in the file `../worker/fbs/rtpParameters.fbs:24` #[derive( Clone, Debug, @@ -8220,6 +13388,7 @@ mod root { ::serde::Deserialize, )] pub struct String { + /// The field `value` in the table `String` pub value: ::core::option::Option<::planus::alloc::string::String>, } @@ -8233,6 +13402,12 @@ mod root { } 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, @@ -8242,28 +13417,27 @@ mod root { ) -> ::planus::Offset { let prepared_value = field_value.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_value.is_some() { - table_writer.calculate_size::<::planus::Offset>(2); + table_writer.write_entry::<::planus::Offset>(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_value) = prepared_value { - table_writer.write::<_, _, 4>(0, &prepared_value); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_value) = prepared_value { + object_writer.write::<_, _, 4>(&prepared_value); + } + }); } - - table_writer.finish() + 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) } @@ -8272,6 +13446,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for String { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -8281,15 +13456,91 @@ mod root { } 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::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + { + StringBuilder((value,)) + } + + /// Sets the [`value` field](String#structfield.value) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn value_as_null(self) -> StringBuilder<((),)> { + self.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<::core::option::Option<&'a ::core::primitive::str>> @@ -8324,6 +13575,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for StringRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -8355,6 +13607,7 @@ mod root { 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) } @@ -8391,18 +13644,38 @@ mod root { } } + /// The union `Value` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Union `Value` in the file `../worker/fbs/rtpParameters.fbs:28` #[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 `Integer` in the union `Value` Integer(::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 `IntegerArray` in the union `Value` IntegerArray(::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, @@ -8410,6 +13683,7 @@ mod root { ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) } + #[inline] pub fn create_integer( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -8417,6 +13691,7 @@ mod root { ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) } + #[inline] pub fn create_double( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -8424,6 +13699,7 @@ mod root { ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) } + #[inline] pub fn create_string( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -8431,6 +13707,7 @@ mod root { ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) } + #[inline] pub fn create_integer_array( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -8440,6 +13717,7 @@ mod root { } 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), @@ -8452,6 +13730,7 @@ mod root { } impl ::planus::WriteAsOptionalUnion for Value { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -8460,6 +13739,183 @@ mod root { } } + /// 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 [`Integer` variant](Value#variant.Integer). + #[inline] + pub fn integer(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 [`IntegerArray` variant](Value#variant.IntegerArray). + #[inline] + pub fn integer_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>), @@ -8475,27 +13931,27 @@ mod root { fn try_from(value: ValueRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(match value { ValueRef::Boolean(value) => { - Value::Boolean(::planus::alloc::boxed::Box::new( + Self::Boolean(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } ValueRef::Integer(value) => { - Value::Integer(::planus::alloc::boxed::Box::new( + Self::Integer(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - ValueRef::Double(value) => Value::Double(::planus::alloc::boxed::Box::new( + ValueRef::Double(value) => Self::Double(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )), - ValueRef::String(value) => Value::String(::planus::alloc::boxed::Box::new( + ValueRef::String(value) => Self::String(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )), ValueRef::IntegerArray(value) => { - Value::IntegerArray(::planus::alloc::boxed::Box::new( + Self::IntegerArray(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -8532,15 +13988,27 @@ mod root { } } + /// The table `Parameter` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Table `Parameter` in the file `../worker/fbs/rtpParameters.fbs:36` #[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: ::core::option::Option, } 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, @@ -8548,37 +14016,37 @@ mod root { field_value: impl ::planus::WriteAsOptionalUnion, ) -> ::planus::Offset { let prepared_name = field_name.prepare(builder); - let prepared_value = field_value.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<6, 9>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); + let mut table_writer: ::planus::table_writer::TableWriter<10> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); if prepared_value.is_some() { - table_writer.calculate_size::(4); - table_writer.calculate_size::<::planus::Offset>(6); + table_writer.write_entry::<::planus::Offset>(2); + } + if prepared_value.is_some() { + table_writer.write_entry::(1); } - - table_writer.finish_calculating(); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_name); - if let ::core::option::Option::Some(prepared_value) = prepared_value { - table_writer.write::<_, _, 4>(2, &prepared_value.offset()); - } - if let ::core::option::Option::Some(prepared_value) = prepared_value { - table_writer.write::<_, _, 1>(1, &prepared_value.tag()); - } + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_name); + if let ::core::option::Option::Some(prepared_value) = prepared_value { + object_writer.write::<_, _, 4>(&prepared_value.offset()); + } + if let ::core::option::Option::Some(prepared_value) = prepared_value { + object_writer.write::<_, _, 1>(&prepared_value.tag()); + } + }); } - - table_writer.finish() + 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) } @@ -8587,6 +14055,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Parameter { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -8596,19 +14065,117 @@ mod root { } 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::WriteAsOptionalUnion, + { + let (v0,) = self.0; + ParameterBuilder((v0, value)) + } + + /// Sets the [`value` field](Parameter#structfield.value) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn value_as_null(self) -> ParameterBuilder<(T0, ())> { + self.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::WriteAsOptionalUnion, + > ::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::WriteAsOptionalUnion, + > ::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::WriteAsOptionalUnion, + > ::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<::core::option::Option>> { @@ -8644,6 +14211,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ParameterRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -8675,6 +14243,7 @@ mod root { 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) } @@ -8711,6 +14280,10 @@ mod root { } } + /// The table `RtcpFeedback` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Table `RtcpFeedback` in the file `../worker/fbs/rtpParameters.fbs:41` #[derive( Clone, Debug, @@ -8723,11 +14296,19 @@ mod root { ::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, @@ -8737,34 +14318,33 @@ mod root { >, ) -> ::planus::Offset { let prepared_type_ = field_type_.prepare(builder); - let prepared_parameter = field_parameter.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); + 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.calculate_size::<::planus::Offset>(4); + table_writer.write_entry::<::planus::Offset>(1); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_type_); - if let ::core::option::Option::Some(prepared_parameter) = prepared_parameter - { - table_writer.write::<_, _, 4>(1, &prepared_parameter); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for RtcpFeedback { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -8776,6 +14356,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for RtcpFeedback { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -8785,6 +14366,7 @@ mod root { } impl ::planus::WriteAsOffset for RtcpFeedback { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -8793,14 +14375,121 @@ mod root { } } + /// 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>> @@ -8843,6 +14532,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RtcpFeedbackRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -8874,6 +14564,7 @@ mod root { 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) } @@ -8910,20 +14601,36 @@ mod root { } } + /// The table `RtpCodecParameters` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Table `RtpCodecParameters` in the file `../worker/fbs/rtpParameters.fbs:46` #[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, @@ -8939,73 +14646,72 @@ mod root { >, ) -> ::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::<14, 18>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - if prepared_payload_type.is_some() { - table_writer.calculate_size::(4); - } + 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.calculate_size::(6); - } - if prepared_channels.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(2); } if prepared_parameters.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(10); + table_writer + .write_entry::<::planus::Offset<[::planus::Offset]>>( + 4, + ); } if prepared_rtcp_feedback.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(12); + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(5); } - - table_writer.finish_calculating(); - - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_mime_type); - if let ::core::option::Option::Some(prepared_clock_rate) = - prepared_clock_rate - { - table_writer.write::<_, _, 4>(2, &prepared_clock_rate); - } - if let ::core::option::Option::Some(prepared_parameters) = - prepared_parameters - { - table_writer.write::<_, _, 4>(4, &prepared_parameters); - } - if let ::core::option::Option::Some(prepared_rtcp_feedback) = - prepared_rtcp_feedback - { - table_writer.write::<_, _, 4>(5, &prepared_rtcp_feedback); - } - if let ::core::option::Option::Some(prepared_payload_type) = - prepared_payload_type - { - table_writer.write::<_, _, 1>(1, &prepared_payload_type); - } - if let ::core::option::Option::Some(prepared_channels) = prepared_channels { - table_writer.write::<_, _, 1>(3, &prepared_channels); - } + if prepared_payload_type.is_some() { + table_writer.write_entry::(1); + } + if prepared_channels.is_some() { + table_writer.write_entry::(3); } - table_writer.finish() + 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, @@ -9017,6 +14723,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for RtpCodecParameters { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -9026,6 +14733,7 @@ mod root { } impl ::planus::WriteAsOffset for RtpCodecParameters { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -9033,23 +14741,251 @@ mod root { RtpCodecParameters::create( builder, &self.mime_type, - &self.payload_type, - &self.clock_rate, - &self.channels, + 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 @@ -9058,6 +14994,8 @@ mod root { ) } + /// Getter for the [`clock_rate` field](RtpCodecParameters#structfield.clock_rate). + #[inline] pub fn clock_rate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -9066,10 +15004,14 @@ mod root { ) } + /// 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< @@ -9080,6 +15022,8 @@ mod root { self.0.access(4, "RtpCodecParameters", "parameters") } + /// Getter for the [`rtcp_feedback` field](RtpCodecParameters#structfield.rtcp_feedback). + #[inline] pub fn rtcp_feedback( &self, ) -> ::planus::Result< @@ -9153,6 +15097,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RtpCodecParametersRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -9184,6 +15129,7 @@ mod root { 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) } @@ -9220,17 +15166,31 @@ mod root { } } + /// The table `RtpHeaderExtensionParameters` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Table `RtpHeaderExtensionParameters` in the file `../worker/fbs/rtpParameters.fbs:55` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct RtpHeaderExtensionParameters { + /// The field `uri` in the table `RtpHeaderExtensionParameters` pub uri: ::planus::alloc::string::String, + /// 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>, } 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, @@ -9242,45 +15202,44 @@ mod root { >, ) -> ::planus::Offset { let prepared_uri = field_uri.prepare(builder); - 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::<10, 10>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); + let mut table_writer: ::planus::table_writer::TableWriter<12> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); + if prepared_parameters.is_some() { + table_writer + .write_entry::<::planus::Offset<[::planus::Offset]>>( + 3, + ); + } if prepared_id.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(1); } if prepared_encrypt.is_some() { - table_writer.calculate_size::(6); - } - if prepared_parameters.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(8); + table_writer.write_entry::(2); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_uri); - if let ::core::option::Option::Some(prepared_parameters) = - prepared_parameters - { - table_writer.write::<_, _, 4>(3, &prepared_parameters); - } - if let ::core::option::Option::Some(prepared_id) = prepared_id { - table_writer.write::<_, _, 1>(1, &prepared_id); - } - if let ::core::option::Option::Some(prepared_encrypt) = prepared_encrypt { - table_writer.write::<_, _, 1>(2, &prepared_encrypt); - } - } - - table_writer.finish() + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_uri); + if let ::core::option::Option::Some(prepared_parameters) = + prepared_parameters + { + object_writer.write::<_, _, 4>(&prepared_parameters); + } + 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() } } @@ -9289,6 +15248,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -9302,6 +15262,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -9312,6 +15273,7 @@ mod root { } impl ::planus::WriteAsOffset for RtpHeaderExtensionParameters { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -9319,22 +15281,200 @@ mod root { RtpHeaderExtensionParameters::create( builder, &self.uri, - &self.id, - &self.encrypt, + 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::WriteAs<::planus::Offset>, + { + RtpHeaderExtensionParametersBuilder((value,)) + } + } + + 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::WriteAs<::planus::Offset>, + 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::WriteAs<::planus::Offset>, + 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::WriteAs<::planus::Offset>, + 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<&'a ::core::primitive::str> { self.0 .access_required(0, "RtpHeaderExtensionParameters", "uri") } + /// Getter for the [`id` field](RtpHeaderExtensionParameters#structfield.id). + #[inline] pub fn id(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -9343,6 +15483,8 @@ mod root { ) } + /// Getter for the [`encrypt` field](RtpHeaderExtensionParameters#structfield.encrypt). + #[inline] pub fn encrypt(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -9351,6 +15493,8 @@ mod root { ) } + /// Getter for the [`parameters` field](RtpHeaderExtensionParameters#structfield.parameters). + #[inline] pub fn parameters( &self, ) -> ::planus::Result< @@ -9401,6 +15545,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RtpHeaderExtensionParametersRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -9434,6 +15579,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -9474,6 +15620,10 @@ mod root { } } + /// The table `Rtx` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Table `Rtx` in the file `../worker/fbs/rtpParameters.fbs:62` #[derive( Clone, Debug, @@ -9486,6 +15636,7 @@ mod root { ::serde::Deserialize, )] pub struct Rtx { + /// The field `ssrc` in the table `Rtx` pub ssrc: u32, } @@ -9497,6 +15648,12 @@ mod root { } 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, @@ -9504,28 +15661,27 @@ mod root { ) -> ::planus::Offset { let prepared_ssrc = field_ssrc.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_ssrc.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - table_writer.write::<_, _, 4>(0, &prepared_ssrc); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + object_writer.write::<_, _, 4>(&prepared_ssrc); + } + }); } - - table_writer.finish() + 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) } @@ -9534,6 +15690,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Rtx { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -9543,15 +15700,89 @@ mod root { } 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 { - Rtx::create(builder, &self.ssrc) + 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)) } @@ -9577,6 +15808,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RtxRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -9604,6 +15836,7 @@ mod root { 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) } @@ -9640,6 +15873,10 @@ mod root { } } + /// The table `RtpEncodingParameters` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Table `RtpEncodingParameters` in the file `../worker/fbs/rtpParameters.fbs:66` #[derive( Clone, Debug, @@ -9652,12 +15889,19 @@ mod root { ::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, } @@ -9677,6 +15921,12 @@ mod root { } 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, @@ -9691,83 +15941,76 @@ mod root { 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::<16, 22>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<18> = + ::core::default::Default::default(); if prepared_ssrc.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } if prepared_rid.is_some() { - table_writer.calculate_size::<::planus::Offset>(4); - } - if prepared_codec_payload_type.is_some() { - table_writer.calculate_size::(6); + table_writer.write_entry::<::planus::Offset>(1); } if prepared_rtx.is_some() { - table_writer.calculate_size::<::planus::Offset>(8); - } - if prepared_dtx.is_some() { - table_writer.calculate_size::(10); + table_writer.write_entry::<::planus::Offset>(3); } if prepared_scalability_mode.is_some() { - table_writer.calculate_size::<::planus::Offset>(12); + table_writer.write_entry::<::planus::Offset>(5); } if prepared_max_bitrate.is_some() { - table_writer.calculate_size::(14); + table_writer.write_entry::(6); } - - table_writer.finish_calculating(); - - unsafe { - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - table_writer.write::<_, _, 4>(0, &prepared_ssrc); - } - if let ::core::option::Option::Some(prepared_rid) = prepared_rid { - table_writer.write::<_, _, 4>(1, &prepared_rid); - } - if let ::core::option::Option::Some(prepared_rtx) = prepared_rtx { - table_writer.write::<_, _, 4>(3, &prepared_rtx); - } - if let ::core::option::Option::Some(prepared_scalability_mode) = - prepared_scalability_mode - { - table_writer.write::<_, _, 4>(5, &prepared_scalability_mode); - } - if let ::core::option::Option::Some(prepared_max_bitrate) = - prepared_max_bitrate - { - table_writer.write::<_, _, 4>(6, &prepared_max_bitrate); - } - if let ::core::option::Option::Some(prepared_codec_payload_type) = - prepared_codec_payload_type - { - table_writer.write::<_, _, 1>(2, &prepared_codec_payload_type); - } - if let ::core::option::Option::Some(prepared_dtx) = prepared_dtx { - table_writer.write::<_, _, 1>(4, &prepared_dtx); - } + if prepared_codec_payload_type.is_some() { + table_writer.write_entry::(2); + } + if prepared_dtx.is_some() { + table_writer.write_entry::(4); } - table_writer.finish() + 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, @@ -9779,6 +16022,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for RtpEncodingParameters { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -9789,31 +16033,284 @@ mod root { } impl ::planus::WriteAsOffset for RtpEncodingParameters { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { RtpEncodingParameters::create( builder, - &self.ssrc, + self.ssrc, &self.rid, - &self.codec_payload_type, + self.codec_payload_type, &self.rtx, - &self.dtx, + self.dtx, &self.scalability_mode, - &self.max_bitrate, + 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>> @@ -9821,15 +16318,21 @@ mod root { 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 @@ -9838,6 +16341,8 @@ mod root { ) } + /// 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>> @@ -9846,6 +16351,8 @@ mod root { .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") } @@ -9940,6 +16447,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RtpEncodingParametersRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -9971,6 +16479,7 @@ mod root { 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) } @@ -10011,6 +16520,10 @@ mod root { } } + /// The table `RtcpParameters` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Table `RtcpParameters` in the file `../worker/fbs/rtpParameters.fbs:76` #[derive( Clone, Debug, @@ -10023,7 +16536,9 @@ mod root { ::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, } @@ -10038,6 +16553,12 @@ mod root { } 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, @@ -10047,39 +16568,37 @@ mod root { 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::<6, 5>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<8> = + ::core::default::Default::default(); if prepared_cname.is_some() { - table_writer.calculate_size::<::planus::Offset>(2); + table_writer.write_entry::<::planus::Offset>(0); } if prepared_reduced_size.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(1); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_cname) = prepared_cname { - table_writer.write::<_, _, 4>(0, &prepared_cname); - } - if let ::core::option::Option::Some(prepared_reduced_size) = - prepared_reduced_size - { - table_writer.write::<_, _, 1>(1, &prepared_reduced_size); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for RtcpParameters { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -10091,6 +16610,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for RtcpParameters { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -10100,18 +16620,133 @@ mod root { } 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 { - RtcpParameters::create(builder, &self.cname, &self.reduced_size) + ::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>> @@ -10119,6 +16754,8 @@ mod root { 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 @@ -10156,6 +16793,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RtcpParametersRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -10187,6 +16825,7 @@ mod root { 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) } @@ -10223,21 +16862,36 @@ mod root { } } + /// The table `RtpParameters` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Table `RtpParameters` in the file `../worker/fbs/rtpParameters.fbs:81` #[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: ::core::option::Option< ::planus::alloc::vec::Vec, >, + /// The field `encodings` in the table `RtpParameters` pub encodings: ::core::option::Option<::planus::alloc::vec::Vec>, + /// The field `rtcp` in the table `RtpParameters` pub rtcp: ::core::option::Option<::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, @@ -10254,64 +16908,60 @@ mod root { field_rtcp: impl ::planus::WriteAsOptional<::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::<12, 20>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<14> = + ::core::default::Default::default(); if prepared_mid.is_some() { - table_writer.calculate_size::<::planus::Offset>(2); + table_writer.write_entry::<::planus::Offset>(0); } - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(1); if prepared_header_extensions.is_some() { - table_writer.calculate_size::<::planus::Offset< + table_writer.write_entry::<::planus::Offset< [::planus::Offset], - >>(6); + >>(2); } if prepared_encodings.is_some() { - table_writer.calculate_size::<::planus::Offset< + table_writer.write_entry::<::planus::Offset< [::planus::Offset], - >>(8); + >>(3); } if prepared_rtcp.is_some() { - table_writer.calculate_size::<::planus::Offset>(10); + table_writer.write_entry::<::planus::Offset>(4); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_mid) = prepared_mid { - table_writer.write::<_, _, 4>(0, &prepared_mid); - } - table_writer.write::<_, _, 4>(1, &prepared_codecs); - if let ::core::option::Option::Some(prepared_header_extensions) = - prepared_header_extensions - { - table_writer.write::<_, _, 4>(2, &prepared_header_extensions); - } - if let ::core::option::Option::Some(prepared_encodings) = prepared_encodings - { - table_writer.write::<_, _, 4>(3, &prepared_encodings); - } - if let ::core::option::Option::Some(prepared_rtcp) = prepared_rtcp { - table_writer.write::<_, _, 4>(4, &prepared_rtcp); - } - } - - table_writer.finish() + 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); + if let ::core::option::Option::Some(prepared_header_extensions) = + prepared_header_extensions + { + object_writer.write::<_, _, 4>(&prepared_header_extensions); + } + if let ::core::option::Option::Some(prepared_encodings) = + prepared_encodings + { + object_writer.write::<_, _, 4>(&prepared_encodings); + } + if let ::core::option::Option::Some(prepared_rtcp) = prepared_rtcp { + 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, @@ -10323,6 +16973,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for RtpParameters { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -10332,6 +16983,7 @@ mod root { } impl ::planus::WriteAsOffset for RtpParameters { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -10347,10 +16999,209 @@ mod root { } } + /// 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::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + { + let (v0, v1) = self.0; + RtpParametersBuilder((v0, v1, value)) + } + + /// Sets the [`header_extensions` field](RtpParameters#structfield.header_extensions) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn header_extensions_as_null(self) -> RtpParametersBuilder<(T0, T1, ())> { + self.header_extensions(()) + } + } + + 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::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + { + let (v0, v1, v2) = self.0; + RtpParametersBuilder((v0, v1, v2, value)) + } + + /// Sets the [`encodings` field](RtpParameters#structfield.encodings) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn encodings_as_null(self) -> RtpParametersBuilder<(T0, T1, T2, ())> { + self.encodings(()) + } + } + + 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::WriteAsOptional<::planus::Offset>, + { + let (v0, v1, v2, v3) = self.0; + RtpParametersBuilder((v0, v1, v2, v3, value)) + } + + /// Sets the [`rtcp` field](RtpParameters#structfield.rtcp) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn rtcp_as_null(self) -> RtpParametersBuilder<(T0, T1, T2, T3, ())> { + self.rtcp(()) + } + } + + 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::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + T3: ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + T4: ::planus::WriteAsOptional<::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::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + T3: ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + T4: ::planus::WriteAsOptional<::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::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + T3: ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + T4: ::planus::WriteAsOptional<::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>> @@ -10358,6 +17209,8 @@ mod root { self.0.access(0, "RtpParameters", "mid") } + /// Getter for the [`codecs` field](RtpParameters#structfield.codecs). + #[inline] pub fn codecs( &self, ) -> ::planus::Result< @@ -10366,6 +17219,8 @@ mod root { 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< @@ -10379,6 +17234,8 @@ mod root { self.0.access(2, "RtpParameters", "header_extensions") } + /// Getter for the [`encodings` field](RtpParameters#structfield.encodings). + #[inline] pub fn encodings( &self, ) -> ::planus::Result< @@ -10389,6 +17246,8 @@ mod root { self.0.access(3, "RtpParameters", "encodings") } + /// Getter for the [`rtcp` field](RtpParameters#structfield.rtcp). + #[inline] pub fn rtcp( &self, ) -> ::planus::Result<::core::option::Option>> @@ -10459,6 +17318,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RtpParametersRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -10490,6 +17350,7 @@ mod root { 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) } @@ -10526,6 +17387,10 @@ mod root { } } + /// The table `CodecMapping` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Table `CodecMapping` in the file `../worker/fbs/rtpParameters.fbs:89` #[derive( Clone, Debug, @@ -10538,7 +17403,9 @@ mod root { ::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, } @@ -10553,6 +17420,12 @@ mod root { } 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, @@ -10560,42 +17433,40 @@ mod root { 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::<6, 2>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<8> = + ::core::default::Default::default(); if prepared_payload_type.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } if prepared_mapped_payload_type.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(1); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_payload_type) = - prepared_payload_type - { - table_writer.write::<_, _, 1>(0, &prepared_payload_type); - } - if let ::core::option::Option::Some(prepared_mapped_payload_type) = - prepared_mapped_payload_type - { - table_writer.write::<_, _, 1>(1, &prepared_mapped_payload_type); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for CodecMapping { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -10607,6 +17478,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for CodecMapping { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -10616,18 +17488,129 @@ mod root { } 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) + 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 @@ -10636,6 +17619,8 @@ mod root { ) } + /// 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 @@ -10669,6 +17654,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CodecMappingRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -10700,6 +17686,7 @@ mod root { 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) } @@ -10736,6 +17723,10 @@ mod root { } } + /// The table `EncodingMapping` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Table `EncodingMapping` in the file `../worker/fbs/rtpParameters.fbs:94` #[derive( Clone, Debug, @@ -10748,9 +17739,13 @@ mod root { ::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, } @@ -10767,6 +17762,12 @@ mod root { } 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, @@ -10778,57 +17779,53 @@ mod root { 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::<10, 16>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<12> = + ::core::default::Default::default(); if prepared_rid.is_some() { - table_writer.calculate_size::<::planus::Offset>(2); + table_writer.write_entry::<::planus::Offset>(0); } if prepared_ssrc.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(1); } if prepared_scalability_mode.is_some() { - table_writer.calculate_size::<::planus::Offset>(6); + table_writer.write_entry::<::planus::Offset>(2); } if prepared_mapped_ssrc.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(3); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_rid) = prepared_rid { - table_writer.write::<_, _, 4>(0, &prepared_rid); - } - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - table_writer.write::<_, _, 4>(1, &prepared_ssrc); - } - if let ::core::option::Option::Some(prepared_scalability_mode) = - prepared_scalability_mode - { - table_writer.write::<_, _, 4>(2, &prepared_scalability_mode); - } - if let ::core::option::Option::Some(prepared_mapped_ssrc) = - prepared_mapped_ssrc - { - table_writer.write::<_, _, 4>(3, &prepared_mapped_ssrc); - } - } - - table_writer.finish() + 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, @@ -10840,6 +17837,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for EncodingMapping { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -10849,6 +17847,7 @@ mod root { } impl ::planus::WriteAsOffset for EncodingMapping { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -10856,17 +17855,178 @@ mod root { EncodingMapping::create( builder, &self.rid, - &self.ssrc, + self.ssrc, &self.scalability_mode, - &self.mapped_ssrc, + 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>> @@ -10874,10 +18034,14 @@ mod root { 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>> @@ -10885,6 +18049,8 @@ mod root { 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 @@ -10944,6 +18110,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for EncodingMappingRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -10975,6 +18142,7 @@ mod root { 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) } @@ -11011,6 +18179,10 @@ mod root { } } + /// The table `RtpMapping` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Table `RtpMapping` in the file `../worker/fbs/rtpParameters.fbs:101` #[derive( Clone, Debug, @@ -11023,11 +18195,19 @@ mod root { ::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, @@ -11039,32 +18219,31 @@ mod root { >, ) -> ::planus::Offset { let prepared_codecs = field_codecs.prepare(builder); - let prepared_encodings = field_encodings.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<6, 8>::new(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 - .calculate_size::<::planus::Offset<[::planus::Offset]>>( - 2, + .write_entry::<::planus::Offset<[::planus::Offset]>>( + 1, ); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); - - table_writer.finish_calculating(); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_codecs); - table_writer.write::<_, _, 4>(1, &prepared_encodings); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_codecs); + object_writer.write::<_, _, 4>(&prepared_encodings); + }); } - - table_writer.finish() + 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) } @@ -11073,6 +18252,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for RtpMapping { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -11082,15 +18262,106 @@ mod root { } 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< @@ -11099,6 +18370,8 @@ mod root { self.0.access_required(0, "RtpMapping", "codecs") } + /// Getter for the [`encodings` field](RtpMapping#structfield.encodings). + #[inline] pub fn encodings( &self, ) -> ::planus::Result< @@ -11130,6 +18403,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RtpMappingRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -11161,6 +18435,7 @@ mod root { 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) } @@ -11197,7 +18472,15 @@ mod root { } } } + /// 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, @@ -11210,25 +18493,47 @@ mod root { ::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, @@ -11250,155 +18555,146 @@ mod root { 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::<34, 37>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<36> = + ::core::default::Default::default(); if prepared_encoding_idx.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } if prepared_ssrc.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(1); } - if prepared_payload_type.is_some() { - table_writer.calculate_size::(6); - } - table_writer.calculate_size::<::planus::Offset>(8); + table_writer.write_entry::<::planus::Offset>(3); if prepared_clock_rate.is_some() { - table_writer.calculate_size::(10); + table_writer.write_entry::(4); } if prepared_rid.is_some() { - table_writer.calculate_size::<::planus::Offset>(12); + table_writer.write_entry::<::planus::Offset>(5); } - table_writer.calculate_size::<::planus::Offset>(14); + table_writer.write_entry::<::planus::Offset>(6); if prepared_rtx_ssrc.is_some() { - table_writer.calculate_size::(16); + 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.calculate_size::(18); + table_writer.write_entry::(8); } if prepared_use_nack.is_some() { - table_writer.calculate_size::(20); + table_writer.write_entry::(9); } if prepared_use_pli.is_some() { - table_writer.calculate_size::(22); + table_writer.write_entry::(10); } if prepared_use_fir.is_some() { - table_writer.calculate_size::(24); + table_writer.write_entry::(11); } if prepared_use_in_band_fec.is_some() { - table_writer.calculate_size::(26); + table_writer.write_entry::(12); } if prepared_use_dtx.is_some() { - table_writer.calculate_size::(28); + table_writer.write_entry::(13); } if prepared_spatial_layers.is_some() { - table_writer.calculate_size::(30); + table_writer.write_entry::(14); } if prepared_temporal_layers.is_some() { - table_writer.calculate_size::(32); + table_writer.write_entry::(15); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_encoding_idx) = - prepared_encoding_idx - { - table_writer.write::<_, _, 4>(0, &prepared_encoding_idx); - } - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - table_writer.write::<_, _, 4>(1, &prepared_ssrc); - } - table_writer.write::<_, _, 4>(3, &prepared_mime_type); - if let ::core::option::Option::Some(prepared_clock_rate) = - prepared_clock_rate - { - table_writer.write::<_, _, 4>(4, &prepared_clock_rate); - } - if let ::core::option::Option::Some(prepared_rid) = prepared_rid { - table_writer.write::<_, _, 4>(5, &prepared_rid); - } - table_writer.write::<_, _, 4>(6, &prepared_cname); - if let ::core::option::Option::Some(prepared_rtx_ssrc) = prepared_rtx_ssrc { - table_writer.write::<_, _, 4>(7, &prepared_rtx_ssrc); - } - if let ::core::option::Option::Some(prepared_payload_type) = - prepared_payload_type - { - table_writer.write::<_, _, 1>(2, &prepared_payload_type); - } - if let ::core::option::Option::Some(prepared_rtx_payload_type) = - prepared_rtx_payload_type - { - table_writer.write::<_, _, 1>(8, &prepared_rtx_payload_type); - } - if let ::core::option::Option::Some(prepared_use_nack) = prepared_use_nack { - table_writer.write::<_, _, 1>(9, &prepared_use_nack); - } - if let ::core::option::Option::Some(prepared_use_pli) = prepared_use_pli { - table_writer.write::<_, _, 1>(10, &prepared_use_pli); - } - if let ::core::option::Option::Some(prepared_use_fir) = prepared_use_fir { - table_writer.write::<_, _, 1>(11, &prepared_use_fir); - } - if let ::core::option::Option::Some(prepared_use_in_band_fec) = - prepared_use_in_band_fec - { - table_writer.write::<_, _, 1>(12, &prepared_use_in_band_fec); - } - if let ::core::option::Option::Some(prepared_use_dtx) = prepared_use_dtx { - table_writer.write::<_, _, 1>(13, &prepared_use_dtx); - } - if let ::core::option::Option::Some(prepared_spatial_layers) = - prepared_spatial_layers - { - table_writer.write::<_, _, 1>(14, &prepared_spatial_layers); - } - if let ::core::option::Option::Some(prepared_temporal_layers) = - prepared_temporal_layers - { - table_writer.write::<_, _, 1>(15, &prepared_temporal_layers); - } - } - - table_writer.finish() + 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) } @@ -11407,6 +18703,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Params { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -11416,59 +18713,756 @@ mod root { } 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.encoding_idx, + self.ssrc, + self.payload_type, &self.mime_type, - &self.clock_rate, + 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, + 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>> @@ -11476,36 +19470,50 @@ mod root { 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 @@ -11514,18 +19522,24 @@ mod root { ) } + /// 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), @@ -11619,6 +19633,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ParamsRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -11650,6 +19665,7 @@ mod root { 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) } @@ -11686,6 +19702,10 @@ mod root { } } + /// 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, @@ -11698,13 +19718,22 @@ mod root { ::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, @@ -11715,44 +19744,40 @@ mod root { >, ) -> ::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::<8, 9>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - if prepared_score.is_some() { - table_writer.calculate_size::(4); - } + 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 - .calculate_size::<::planus::Offset>(6); + table_writer.write_entry::<::planus::Offset>(2); + } + if prepared_score.is_some() { + table_writer.write_entry::(1); } - - table_writer.finish_calculating(); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_params); - if let ::core::option::Option::Some(prepared_rtx_stream) = - prepared_rtx_stream - { - table_writer.write::<_, _, 4>(2, &prepared_rtx_stream); - } - if let ::core::option::Option::Some(prepared_score) = prepared_score { - table_writer.write::<_, _, 1>(1, &prepared_score); - } + 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); + } + }); } - - table_writer.finish() + 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) } @@ -11761,6 +19786,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Dump { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -11770,23 +19796,145 @@ mod root { } 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 { - Dump::create(builder, &self.params, &self.score, &self.rtx_stream) + 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>> @@ -11833,6 +19981,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DumpRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -11860,6 +20009,7 @@ mod root { 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) } @@ -11896,6 +20046,10 @@ mod root { } } + /// 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, @@ -11908,11 +20062,19 @@ mod root { ::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: u64, } 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, @@ -11920,33 +20082,32 @@ mod root { 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::<6, 12>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); + let mut table_writer: ::planus::table_writer::TableWriter<8> = + ::core::default::Default::default(); if prepared_bitrate.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(1); } - - table_writer.finish_calculating(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - if let ::core::option::Option::Some(prepared_bitrate) = prepared_bitrate { - table_writer.write::<_, _, 8>(1, &prepared_bitrate); - } - table_writer.write::<_, _, 4>(0, &prepared_layer); + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_bitrate) = prepared_bitrate + { + object_writer.write::<_, _, 8>(&prepared_bitrate); + } + object_writer.write::<_, _, 4>(&prepared_layer); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for BitrateByLayer { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -11958,6 +20119,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for BitrateByLayer { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -11967,22 +20129,132 @@ mod root { } 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 { - BitrateByLayer::create(builder, &self.layer, &self.bitrate) + 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), @@ -12012,6 +20284,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for BitrateByLayerRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -12043,6 +20316,7 @@ mod root { 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) } @@ -12079,16 +20353,32 @@ mod root { } } + /// 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, @@ -12096,6 +20386,7 @@ mod root { ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) } + #[inline] pub fn create_recv_stats( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -12103,6 +20394,7 @@ mod root { ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) } + #[inline] pub fn create_send_stats( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -12112,6 +20404,7 @@ mod root { } 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), @@ -12122,6 +20415,7 @@ mod root { } impl ::planus::WriteAsOptionalUnion for StatsData { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -12130,6 +20424,142 @@ mod root { } } + /// 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>), @@ -12143,19 +20573,19 @@ mod root { fn try_from(value: StatsDataRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(match value { StatsDataRef::BaseStats(value) => { - StatsData::BaseStats(::planus::alloc::boxed::Box::new( + Self::BaseStats(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } StatsDataRef::RecvStats(value) => { - StatsData::RecvStats(::planus::alloc::boxed::Box::new( + Self::RecvStats(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } StatsDataRef::SendStats(value) => { - StatsData::SendStats(::planus::alloc::boxed::Box::new( + Self::SendStats(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -12186,10 +20616,15 @@ mod root { } } + /// 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: ::core::option::Option, } @@ -12203,6 +20638,12 @@ mod root { } 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, @@ -12210,32 +20651,33 @@ mod root { ) -> ::planus::Offset { let prepared_data = field_data.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 5>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<8> = + ::core::default::Default::default(); if prepared_data.is_some() { - table_writer.calculate_size::(2); - table_writer.calculate_size::<::planus::Offset>(4); + table_writer.write_entry::<::planus::Offset>(1); + } + if prepared_data.is_some() { + table_writer.write_entry::(0); } - - table_writer.finish_calculating(); unsafe { - if let ::core::option::Option::Some(prepared_data) = prepared_data { - table_writer.write::<_, _, 4>(1, &prepared_data.offset()); - } - if let ::core::option::Option::Some(prepared_data) = prepared_data { - table_writer.write::<_, _, 1>(0, &prepared_data.tag()); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_data) = prepared_data { + object_writer.write::<_, _, 4>(&prepared_data.offset()); + } + if let ::core::option::Option::Some(prepared_data) = prepared_data { + object_writer.write::<_, _, 1>(&prepared_data.tag()); + } + }); } - - table_writer.finish() + 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) } @@ -12244,6 +20686,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Stats { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -12253,15 +20696,91 @@ mod root { } 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::WriteAsOptionalUnion, + { + StatsBuilder((value,)) + } + + /// Sets the [`data` field](Stats#structfield.data) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn data_as_null(self) -> StatsBuilder<((),)> { + self.data(()) + } + } + + 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<::core::option::Option>> @@ -12296,6 +20815,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for StatsRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -12327,6 +20847,7 @@ mod root { 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) } @@ -12363,31 +20884,59 @@ mod root { } } + /// 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: u64, + /// 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, @@ -12414,185 +20963,172 @@ mod root { 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::All); - 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::<38, 110>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<40> = + ::core::default::Default::default(); if prepared_timestamp.is_some() { - table_writer.calculate_size::(2); - } - if prepared_ssrc.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(0); } - if prepared_kind.is_some() { - table_writer.calculate_size::(6); - } - table_writer.calculate_size::<::planus::Offset>(8); if prepared_packets_lost.is_some() { - table_writer.calculate_size::(10); + table_writer.write_entry::(4); } if prepared_fraction_lost.is_some() { - table_writer.calculate_size::(12); + table_writer.write_entry::(5); } if prepared_packets_discarded.is_some() { - table_writer.calculate_size::(14); + table_writer.write_entry::(6); } if prepared_packets_retransmitted.is_some() { - table_writer.calculate_size::(16); + table_writer.write_entry::(7); } if prepared_packets_repaired.is_some() { - table_writer.calculate_size::(18); + table_writer.write_entry::(8); } if prepared_nack_count.is_some() { - table_writer.calculate_size::(20); + table_writer.write_entry::(9); } if prepared_nack_packet_count.is_some() { - table_writer.calculate_size::(22); + table_writer.write_entry::(10); } if prepared_pli_count.is_some() { - table_writer.calculate_size::(24); + table_writer.write_entry::(11); } if prepared_fir_count.is_some() { - table_writer.calculate_size::(26); + table_writer.write_entry::(12); } - if prepared_score.is_some() { - table_writer.calculate_size::(28); + 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.calculate_size::<::planus::Offset>(30); + table_writer.write_entry::<::planus::Offset>(14); } if prepared_rtx_ssrc.is_some() { - table_writer.calculate_size::(32); - } - if prepared_rtx_packets_discarded.is_some() { - table_writer.calculate_size::(34); + table_writer.write_entry::(15); } if prepared_round_trip_time.is_some() { - table_writer.calculate_size::(36); + table_writer.write_entry::(17); } - - table_writer.finish_calculating(); - - unsafe { - if let ::core::option::Option::Some(prepared_timestamp) = prepared_timestamp - { - table_writer.write::<_, _, 8>(0, &prepared_timestamp); - } - if let ::core::option::Option::Some(prepared_packets_lost) = - prepared_packets_lost - { - table_writer.write::<_, _, 8>(4, &prepared_packets_lost); - } - if let ::core::option::Option::Some(prepared_fraction_lost) = - prepared_fraction_lost - { - table_writer.write::<_, _, 8>(5, &prepared_fraction_lost); - } - if let ::core::option::Option::Some(prepared_packets_discarded) = - prepared_packets_discarded - { - table_writer.write::<_, _, 8>(6, &prepared_packets_discarded); - } - if let ::core::option::Option::Some(prepared_packets_retransmitted) = - prepared_packets_retransmitted - { - table_writer.write::<_, _, 8>(7, &prepared_packets_retransmitted); - } - if let ::core::option::Option::Some(prepared_packets_repaired) = - prepared_packets_repaired - { - table_writer.write::<_, _, 8>(8, &prepared_packets_repaired); - } - if let ::core::option::Option::Some(prepared_nack_count) = - prepared_nack_count - { - table_writer.write::<_, _, 8>(9, &prepared_nack_count); - } - if let ::core::option::Option::Some(prepared_nack_packet_count) = - prepared_nack_packet_count - { - table_writer.write::<_, _, 8>(10, &prepared_nack_packet_count); - } - if let ::core::option::Option::Some(prepared_pli_count) = prepared_pli_count - { - table_writer.write::<_, _, 8>(11, &prepared_pli_count); - } - if let ::core::option::Option::Some(prepared_fir_count) = prepared_fir_count - { - table_writer.write::<_, _, 8>(12, &prepared_fir_count); - } - if let ::core::option::Option::Some(prepared_rtx_packets_discarded) = - prepared_rtx_packets_discarded - { - table_writer.write::<_, _, 8>(16, &prepared_rtx_packets_discarded); - } - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - table_writer.write::<_, _, 4>(1, &prepared_ssrc); - } - table_writer.write::<_, _, 4>(3, &prepared_mime_type); - if let ::core::option::Option::Some(prepared_rid) = prepared_rid { - table_writer.write::<_, _, 4>(14, &prepared_rid); - } - if let ::core::option::Option::Some(prepared_rtx_ssrc) = prepared_rtx_ssrc { - table_writer.write::<_, _, 4>(15, &prepared_rtx_ssrc); - } - if let ::core::option::Option::Some(prepared_round_trip_time) = - prepared_round_trip_time - { - table_writer.write::<_, _, 4>(17, &prepared_round_trip_time); - } - if let ::core::option::Option::Some(prepared_kind) = prepared_kind { - table_writer.write::<_, _, 1>(2, &prepared_kind); - } - if let ::core::option::Option::Some(prepared_score) = prepared_score { - table_writer.write::<_, _, 1>(13, &prepared_score); - } + if prepared_kind.is_some() { + table_writer.write_entry::(2); + } + if prepared_score.is_some() { + table_writer.write_entry::(13); } - table_writer.finish() + 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_fraction_lost) = + prepared_fraction_lost + { + object_writer.write::<_, _, 8>(&prepared_fraction_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_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) } @@ -12601,6 +21137,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for BaseStats { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -12610,45 +21147,990 @@ mod root { } 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.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.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, + 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 @@ -12657,22 +22139,30 @@ mod root { ) } + /// 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 @@ -12681,6 +22171,8 @@ mod root { ) } + /// Getter for the [`packets_retransmitted` field](BaseStats#structfield.packets_retransmitted). + #[inline] pub fn packets_retransmitted(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -12689,6 +22181,8 @@ mod root { ) } + /// Getter for the [`packets_repaired` field](BaseStats#structfield.packets_repaired). + #[inline] pub fn packets_repaired(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -12697,12 +22191,16 @@ mod root { ) } + /// 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 @@ -12711,24 +22209,32 @@ mod root { ) } + /// 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>> @@ -12736,10 +22242,14 @@ mod root { 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 @@ -12748,6 +22258,8 @@ mod root { ) } + /// 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 @@ -12841,6 +22353,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for BaseStatsRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -12872,6 +22385,7 @@ mod root { 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) } @@ -12908,15 +22422,25 @@ mod root { } } + /// 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: u64, + /// The field `bitrate_by_layer` in the table `RecvStats` pub bitrate_by_layer: ::core::option::Option<::planus::alloc::vec::Vec>, } @@ -12936,6 +22460,12 @@ mod root { } 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, @@ -12949,71 +22479,66 @@ mod root { >, ) -> ::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::<14, 36>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - if prepared_jitter.is_some() { - table_writer.calculate_size::(4); - } + let mut table_writer: ::planus::table_writer::TableWriter<16> = + ::core::default::Default::default(); if prepared_packet_count.is_some() { - table_writer.calculate_size::(6); + table_writer.write_entry::(2); } if prepared_byte_count.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(3); } if prepared_bitrate.is_some() { - table_writer.calculate_size::(10); + table_writer.write_entry::(4); + } + table_writer.write_entry::<::planus::Offset>(0); + if prepared_jitter.is_some() { + table_writer.write_entry::(1); } if prepared_bitrate_by_layer.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(12); + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(5); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_packet_count) = - prepared_packet_count - { - table_writer.write::<_, _, 8>(2, &prepared_packet_count); - } - if let ::core::option::Option::Some(prepared_byte_count) = - prepared_byte_count - { - table_writer.write::<_, _, 8>(3, &prepared_byte_count); - } - if let ::core::option::Option::Some(prepared_bitrate) = prepared_bitrate { - table_writer.write::<_, _, 8>(4, &prepared_bitrate); - } - table_writer.write::<_, _, 4>(0, &prepared_base); - if let ::core::option::Option::Some(prepared_jitter) = prepared_jitter { - table_writer.write::<_, _, 4>(1, &prepared_jitter); - } - if let ::core::option::Option::Some(prepared_bitrate_by_layer) = - prepared_bitrate_by_layer - { - table_writer.write::<_, _, 4>(5, &prepared_bitrate_by_layer); - } - } - - table_writer.finish() + 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); + } + if let ::core::option::Option::Some(prepared_bitrate) = prepared_bitrate + { + object_writer.write::<_, _, 8>(&prepared_bitrate); + } + 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_by_layer) = + prepared_bitrate_by_layer + { + 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) } @@ -13022,6 +22547,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for RecvStats { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -13031,51 +22557,270 @@ mod root { } 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.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::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + { + let (v0, v1, v2, v3, v4) = self.0; + RecvStatsBuilder((v0, v1, v2, v3, v4, value)) + } + + /// Sets the [`bitrate_by_layer` field](RecvStats#structfield.bitrate_by_layer) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn bitrate_by_layer_as_null( + self, + ) -> RecvStatsBuilder<(T0, T1, T2, T3, T4, ())> { + self.bitrate_by_layer(()) + } + } + + 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::WriteAsOptional< + ::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::WriteAsOptional< + ::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::WriteAsOptional< + ::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< @@ -13129,6 +22874,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RecvStatsRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -13160,6 +22906,7 @@ mod root { 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) } @@ -13196,13 +22943,21 @@ mod root { } } + /// 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: u64, } @@ -13219,6 +22974,12 @@ mod root { } 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, @@ -13228,53 +22989,50 @@ mod root { 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::<10, 28>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); + let mut table_writer: ::planus::table_writer::TableWriter<12> = + ::core::default::Default::default(); if prepared_packet_count.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(1); } if prepared_byte_count.is_some() { - table_writer.calculate_size::(6); + table_writer.write_entry::(2); } if prepared_bitrate.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(3); } - - table_writer.finish_calculating(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - if let ::core::option::Option::Some(prepared_packet_count) = - prepared_packet_count - { - table_writer.write::<_, _, 8>(1, &prepared_packet_count); - } - if let ::core::option::Option::Some(prepared_byte_count) = - prepared_byte_count - { - table_writer.write::<_, _, 8>(2, &prepared_byte_count); - } - if let ::core::option::Option::Some(prepared_bitrate) = prepared_bitrate { - table_writer.write::<_, _, 8>(3, &prepared_bitrate); - } - table_writer.write::<_, _, 4>(0, &prepared_base); - } - - table_writer.finish() + 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); + } + if let ::core::option::Option::Some(prepared_bitrate) = prepared_bitrate + { + object_writer.write::<_, _, 8>(&prepared_bitrate); + } + object_writer.write::<_, _, 4>(&prepared_base); + }); + } + 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) } @@ -13283,6 +23041,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for SendStats { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -13292,37 +23051,192 @@ mod root { } 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, + 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), @@ -13358,6 +23272,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SendStatsRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -13389,6 +23304,7 @@ mod root { 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) } @@ -13425,7 +23341,15 @@ mod root { } } } + /// 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:4` #[derive( Clone, Debug, @@ -13438,15 +23362,27 @@ mod root { ::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, @@ -13458,65 +23394,59 @@ mod root { 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::<14, 21>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<16> = + ::core::default::Default::default(); if prepared_ssrc.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - if prepared_payload_type.is_some() { - table_writer.calculate_size::(4); - } - table_writer.calculate_size::<::planus::Offset>(6); + table_writer.write_entry::<::planus::Offset>(2); if prepared_clock_rate.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(3); } if prepared_rrid.is_some() { - table_writer.calculate_size::<::planus::Offset>(10); + table_writer.write_entry::<::planus::Offset>(4); } - table_writer.calculate_size::<::planus::Offset>(12); - - table_writer.finish_calculating(); - - unsafe { - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - table_writer.write::<_, _, 4>(0, &prepared_ssrc); - } - table_writer.write::<_, _, 4>(2, &prepared_mime_type); - if let ::core::option::Option::Some(prepared_clock_rate) = - prepared_clock_rate - { - table_writer.write::<_, _, 4>(3, &prepared_clock_rate); - } - if let ::core::option::Option::Some(prepared_rrid) = prepared_rrid { - table_writer.write::<_, _, 4>(4, &prepared_rrid); - } - table_writer.write::<_, _, 4>(5, &prepared_cname); - if let ::core::option::Option::Some(prepared_payload_type) = - prepared_payload_type - { - table_writer.write::<_, _, 1>(1, &prepared_payload_type); - } + table_writer.write_entry::<::planus::Offset>(5); + if prepared_payload_type.is_some() { + table_writer.write_entry::(1); } - table_writer.finish() + 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) } @@ -13525,6 +23455,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Params { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -13534,43 +23465,237 @@ mod root { } impl ::planus::WriteAsOffset for Params { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { Params::create( builder, - &self.ssrc, - &self.payload_type, + self.ssrc, + self.payload_type, &self.mime_type, - &self.clock_rate, + 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>> @@ -13578,6 +23703,8 @@ mod root { 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") } @@ -13619,6 +23746,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ParamsRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -13650,6 +23778,7 @@ mod root { 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) } @@ -13686,6 +23815,10 @@ mod root { } } + /// The table `RtxDump` in the namespace `FBS.RtxStream` + /// + /// Generated from these locations: + /// * Table `RtxDump` in the file `../worker/fbs/rtxStream.fbs:14` #[derive( Clone, Debug, @@ -13698,10 +23831,17 @@ mod root { ::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, @@ -13709,24 +23849,23 @@ mod root { ) -> ::planus::Offset { let prepared_params = field_params.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_params); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_params); + }); } - - table_writer.finish() + 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) } @@ -13735,6 +23874,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for RtxDump { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -13744,15 +23884,84 @@ mod root { } 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") } @@ -13780,6 +23989,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RtxDumpRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -13811,6 +24021,7 @@ mod root { 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) } @@ -13847,7 +24058,15 @@ mod root { } } } + /// 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:6` #[derive( Clone, Debug, @@ -13860,6 +24079,7 @@ mod root { ::serde::Deserialize, )] pub struct GetBufferedAmountResponse { + /// The field `buffered_amount` in the table `GetBufferedAmountResponse` pub buffered_amount: u32, } @@ -13871,6 +24091,12 @@ mod root { } 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, @@ -13878,30 +24104,29 @@ mod root { ) -> ::planus::Offset { let prepared_buffered_amount = field_buffered_amount.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_buffered_amount.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_buffered_amount) = - prepared_buffered_amount - { - table_writer.write::<_, _, 4>(0, &prepared_buffered_amount); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for GetBufferedAmountResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -13915,6 +24140,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -13925,18 +24151,112 @@ mod root { } 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 { - GetBufferedAmountResponse::create(builder, &self.buffered_amount) + 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 @@ -13968,6 +24288,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for GetBufferedAmountResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -14001,6 +24322,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -14041,6 +24363,10 @@ mod root { } } + /// The table `SetBufferedAmountLowThresholdRequest` in the namespace `FBS.DataConsumer` + /// + /// Generated from these locations: + /// * Table `SetBufferedAmountLowThresholdRequest` in the file `../worker/fbs/dataConsumer.fbs:10` #[derive( Clone, Debug, @@ -14053,6 +24379,7 @@ mod root { ::serde::Deserialize, )] pub struct SetBufferedAmountLowThresholdRequest { + /// The field `threshold` in the table `SetBufferedAmountLowThresholdRequest` pub threshold: u32, } @@ -14064,6 +24391,12 @@ mod root { } 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, @@ -14071,23 +24404,22 @@ mod root { ) -> ::planus::Offset { let prepared_threshold = field_threshold.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_threshold.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_threshold) = prepared_threshold - { - table_writer.write::<_, _, 4>(0, &prepared_threshold); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_threshold) = + prepared_threshold + { + object_writer.write::<_, _, 4>(&prepared_threshold); + } + }); } - - table_writer.finish() + builder.current_offset() } } @@ -14096,6 +24428,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -14109,6 +24442,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -14121,20 +24455,115 @@ mod root { impl ::planus::WriteAsOffset for SetBufferedAmountLowThresholdRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - SetBufferedAmountLowThresholdRequest::create(builder, &self.threshold) + 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 @@ -14168,6 +24597,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SetBufferedAmountLowThresholdRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -14201,6 +24631,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -14241,6 +24672,10 @@ mod root { } } + /// The table `DumpResponse` in the namespace `FBS.DataConsumer` + /// + /// Generated from these locations: + /// * Table `DumpResponse` in the file `../worker/fbs/dataConsumer.fbs:14` #[derive( Clone, Debug, @@ -14253,19 +24688,33 @@ mod root { ::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_: ::planus::alloc::string::String, + /// 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, + /// The field `data_producer_paused` in the table `DumpResponse` pub data_producer_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, @@ -14281,71 +24730,63 @@ mod root { field_data_producer_paused: impl ::planus::WriteAsDefault, ) -> ::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); - 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_data_producer_paused = field_data_producer_paused.prepare(builder, &false); - let mut table_writer = - ::planus::table_writer::TableWriter::<18, 26>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); - table_writer.calculate_size::<::planus::Offset>(6); + 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); + table_writer.write_entry::<::planus::Offset>(2); if prepared_sctp_stream_parameters.is_some() { - table_writer.calculate_size::<::planus::Offset>(8); + table_writer.write_entry::<::planus::Offset>(3); } - table_writer.calculate_size::<::planus::Offset>(10); - table_writer.calculate_size::<::planus::Offset>(12); + table_writer.write_entry::<::planus::Offset>(4); + table_writer.write_entry::<::planus::Offset>(5); if prepared_paused.is_some() { - table_writer.calculate_size::(14); + table_writer.write_entry::(6); } if prepared_data_producer_paused.is_some() { - table_writer.calculate_size::(16); + table_writer.write_entry::(7); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_id); - table_writer.write::<_, _, 4>(1, &prepared_data_producer_id); - table_writer.write::<_, _, 4>(2, &prepared_type_); - if let ::core::option::Option::Some(prepared_sctp_stream_parameters) = - prepared_sctp_stream_parameters - { - table_writer.write::<_, _, 4>(3, &prepared_sctp_stream_parameters); - } - table_writer.write::<_, _, 4>(4, &prepared_label); - table_writer.write::<_, _, 4>(5, &prepared_protocol); - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - table_writer.write::<_, _, 1>(6, &prepared_paused); - } - if let ::core::option::Option::Some(prepared_data_producer_paused) = - prepared_data_producer_paused - { - table_writer.write::<_, _, 1>(7, &prepared_data_producer_paused); - } - } - - table_writer.finish() + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_id); + object_writer.write::<_, _, 4>(&prepared_data_producer_id); + object_writer.write::<_, _, 4>(&prepared_type_); + 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_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, @@ -14357,6 +24798,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -14366,6 +24808,7 @@ mod root { } impl ::planus::WriteAsOffset for DumpResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -14378,29 +24821,279 @@ mod root { &self.sctp_stream_parameters, &self.label, &self.protocol, - &self.paused, - &self.data_producer_paused, + self.paused, + self.data_producer_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 [`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::WriteAs<::planus::Offset>, + { + let (v0, v1) = self.0; + DumpResponseBuilder((v0, v1, value)) + } + } + + 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 [`paused` field](DumpResponse#structfield.paused). + #[inline] + #[allow(clippy::type_complexity)] + pub fn paused( + 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 [`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, ::planus::DefaultValue)> + { + self.paused(::planus::DefaultValue) + } + } + + impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> { + /// Setter for the [`data_producer_paused` field](DumpResponse#structfield.data_producer_paused). + #[inline] + #[allow(clippy::type_complexity)] + pub fn data_producer_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 [`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, ::planus::DefaultValue)> + { + self.data_producer_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::WriteAs<::planus::Offset>, + T2: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAsOptional< + ::planus::Offset, + >, + T4: ::planus::WriteAs<::planus::Offset>, + T5: ::planus::WriteAs<::planus::Offset>, + T6: ::planus::WriteAsDefault, + 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::WriteAs<::planus::Offset>, + T2: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAsOptional< + ::planus::Offset, + >, + T4: ::planus::WriteAs<::planus::Offset>, + T5: ::planus::WriteAs<::planus::Offset>, + T6: ::planus::WriteAsDefault, + 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::WriteAs<::planus::Offset>, + T2: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAsOptional< + ::planus::Offset, + >, + T4: ::planus::WriteAs<::planus::Offset>, + T5: ::planus::WriteAs<::planus::Offset>, + T6: ::planus::WriteAsDefault, + 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 [`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<&'a ::core::primitive::str> { self.0.access_required(2, "DumpResponse", "type_") } + /// Getter for the [`sctp_stream_parameters` field](DumpResponse#structfield.sctp_stream_parameters). + #[inline] pub fn sctp_stream_parameters( &self, ) -> ::planus::Result< @@ -14409,20 +25102,28 @@ mod root { 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 [`paused` field](DumpResponse#structfield.paused). + #[inline] pub fn paused(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0.access(6, "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 @@ -14483,6 +25184,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -14514,6 +25216,7 @@ mod root { 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) } @@ -14550,6 +25253,10 @@ mod root { } } + /// The table `GetStatsResponse` in the namespace `FBS.DataConsumer` + /// + /// Generated from these locations: + /// * Table `GetStatsResponse` in the file `../worker/fbs/dataConsumer.fbs:25` #[derive( Clone, Debug, @@ -14562,15 +25269,27 @@ mod root { ::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, @@ -14582,68 +25301,63 @@ mod root { 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::<14, 36>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<16> = + ::core::default::Default::default(); if prepared_timestamp.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.calculate_size::<::planus::Offset>(4); - table_writer.calculate_size::<::planus::Offset>(6); if prepared_messages_sent.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(3); } if prepared_bytes_sent.is_some() { - table_writer.calculate_size::(10); + 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.calculate_size::(12); + table_writer.write_entry::(5); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_timestamp) = prepared_timestamp - { - table_writer.write::<_, _, 8>(0, &prepared_timestamp); - } - if let ::core::option::Option::Some(prepared_messages_sent) = - prepared_messages_sent - { - table_writer.write::<_, _, 8>(3, &prepared_messages_sent); - } - if let ::core::option::Option::Some(prepared_bytes_sent) = - prepared_bytes_sent - { - table_writer.write::<_, _, 8>(4, &prepared_bytes_sent); - } - table_writer.write::<_, _, 4>(1, &prepared_label); - table_writer.write::<_, _, 4>(2, &prepared_protocol); - if let ::core::option::Option::Some(prepared_buffered_amount) = - prepared_buffered_amount - { - table_writer.write::<_, _, 4>(5, &prepared_buffered_amount); - } - } - - table_writer.finish() + 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, @@ -14655,6 +25369,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -14664,26 +25379,237 @@ mod root { } impl ::planus::WriteAsOffset for GetStatsResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { GetStatsResponse::create( builder, - &self.timestamp, + self.timestamp, &self.label, &self.protocol, - &self.messages_sent, - &self.bytes_sent, - &self.buffered_amount, + 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 @@ -14692,14 +25618,20 @@ mod root { ) } + /// 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 @@ -14708,6 +25640,8 @@ mod root { ) } + /// Getter for the [`bytes_sent` field](GetStatsResponse#structfield.bytes_sent). + #[inline] pub fn bytes_sent(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -14716,6 +25650,8 @@ mod root { ) } + /// Getter for the [`buffered_amount` field](GetStatsResponse#structfield.buffered_amount). + #[inline] pub fn buffered_amount(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -14757,6 +25693,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -14788,6 +25725,7 @@ mod root { 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) } @@ -14824,6 +25762,10 @@ mod root { } } + /// The table `String` in the namespace `FBS.DataConsumer` + /// + /// Generated from these locations: + /// * Table `String` in the file `../worker/fbs/dataConsumer.fbs:34` #[derive( Clone, Debug, @@ -14836,10 +25778,17 @@ mod root { ::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, @@ -14847,24 +25796,23 @@ mod root { ) -> ::planus::Offset { let prepared_value = field_value.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_value); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_value); + }); } - - table_writer.finish() + 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) } @@ -14873,6 +25821,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for String { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -14882,15 +25831,84 @@ mod root { } 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") } @@ -14916,6 +25934,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for StringRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -14947,6 +25966,7 @@ mod root { 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) } @@ -14983,6 +26003,10 @@ mod root { } } + /// The table `Binary` in the namespace `FBS.DataConsumer` + /// + /// Generated from these locations: + /// * Table `Binary` in the file `../worker/fbs/dataConsumer.fbs:38` #[derive( Clone, Debug, @@ -14995,10 +26019,17 @@ mod root { ::serde::Deserialize, )] pub struct Binary { + /// The field `value` in the table `Binary` pub value: ::planus::alloc::vec::Vec, } impl Binary { + /// Creates a [BinaryBuilder] for serializing an instance of this table. + #[inline] + pub fn builder() -> BinaryBuilder<()> { + BinaryBuilder(()) + } + #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, @@ -15006,24 +26037,23 @@ mod root { ) -> ::planus::Offset { let prepared_value = field_value.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset<[u8]>>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset<[u8]>>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_value); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_value); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for Binary { type Prepared = ::planus::Offset; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } @@ -15032,6 +26062,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Binary { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -15041,16 +26072,85 @@ mod root { } impl ::planus::WriteAsOffset for Binary { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { Binary::create(builder, &self.value) } } + /// Builder for serializing an instance of the [Binary] type. + /// + /// Can be created using the [Binary::builder] method. + #[derive(Debug)] + #[must_use] + pub struct BinaryBuilder(State); + + impl BinaryBuilder<()> { + /// Setter for the [`value` field](Binary#structfield.value). + #[inline] + #[allow(clippy::type_complexity)] + pub fn value(self, value: T0) -> BinaryBuilder<(T0,)> + where + T0: ::planus::WriteAs<::planus::Offset<[u8]>>, + { + BinaryBuilder((value,)) + } + } + + impl BinaryBuilder<(T0,)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Binary]. + #[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 BinaryBuilder<(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 BinaryBuilder<(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 BinaryBuilder<(T0,)> + { + #[inline] + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + let (v0,) = &self.0; + Binary::create(builder, v0) + } + } + + /// Reference to a deserialized [Binary]. #[derive(Copy, Clone)] pub struct BinaryRef<'a>(::planus::table_reader::Table<'a>); impl<'a> BinaryRef<'a> { - pub fn value(&self) -> ::planus::Result<::planus::Vector<'a, u8>> { + /// Getter for the [`value` field](Binary#structfield.value). + #[inline] + pub fn value(&self) -> ::planus::Result<&'a [u8]> { self.0.access_required(0, "Binary", "value") } } @@ -15069,12 +26169,13 @@ mod root { #[allow(unreachable_code)] fn try_from(value: BinaryRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - value: value.value()?.to_vec()?, + value: value.value()?.to_vec(), }) } } impl<'a> ::planus::TableRead<'a> for BinaryRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -15106,6 +26207,7 @@ mod root { impl ::planus::VectorWrite<::planus::Offset> for Binary { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -15142,6 +26244,10 @@ mod root { } } + /// The union `Data` in the namespace `FBS.DataConsumer` + /// + /// Generated from these locations: + /// * Union `Data` in the file `../worker/fbs/dataConsumer.fbs:42` #[derive( Clone, Debug, @@ -15154,11 +26260,21 @@ mod root { ::serde::Deserialize, )] pub enum Data { + /// The variant of type `String` in the union `Data` String(::planus::alloc::boxed::Box), + + /// The variant of type `Binary` in the union `Data` Binary(::planus::alloc::boxed::Box), } impl Data { + /// Creates a [DataBuilder] for serializing an instance of this table. + #[inline] + pub fn builder() -> DataBuilder<::planus::Uninitialized> { + DataBuilder(::planus::Uninitialized) + } + + #[inline] pub fn create_string( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -15166,6 +26282,7 @@ mod root { ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) } + #[inline] pub fn create_binary( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -15175,6 +26292,7 @@ mod root { } impl ::planus::WriteAsUnion for Data { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { match self { Self::String(value) => Self::create_string(builder, value), @@ -15184,6 +26302,7 @@ mod root { } impl ::planus::WriteAsOptionalUnion for Data { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -15192,6 +26311,90 @@ mod root { } } + /// Builder for serializing an instance of the [Data] type. + /// + /// Can be created using the [Data::builder] method. + #[derive(Debug)] + #[must_use] + pub struct DataBuilder(T); + + impl DataBuilder<::planus::Uninitialized> { + /// Creates an instance of the [`String` variant](Data#variant.String). + #[inline] + pub fn string(self, value: T) -> DataBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, + { + DataBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`Binary` variant](Data#variant.Binary). + #[inline] + pub fn binary(self, value: T) -> DataBuilder<::planus::Initialized<2, T>> + where + T: ::planus::WriteAsOffset, + { + DataBuilder(::planus::Initialized(value)) + } + } + + impl DataBuilder<::planus::Initialized> { + /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Data]. + #[inline] + pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset + where + Self: ::planus::WriteAsUnion, + { + ::planus::WriteAsUnion::prepare(&self, builder) + } + } + + impl ::planus::WriteAsUnion for DataBuilder<::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 DataBuilder<::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 DataBuilder<::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 DataBuilder<::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 [Data]. #[derive(Copy, Clone, Debug)] pub enum DataRef<'a> { String(self::StringRef<'a>), @@ -15203,11 +26406,11 @@ mod root { fn try_from(value: DataRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(match value { - DataRef::String(value) => Data::String(::planus::alloc::boxed::Box::new( + DataRef::String(value) => Self::String(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )), - DataRef::Binary(value) => Data::Binary(::planus::alloc::boxed::Box::new( + DataRef::Binary(value) => Self::Binary(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )), }) @@ -15234,6 +26437,10 @@ mod root { } } + /// The table `SendRequest` in the namespace `FBS.DataConsumer` + /// + /// Generated from these locations: + /// * Table `SendRequest` in the file `../worker/fbs/dataConsumer.fbs:47` #[derive( Clone, Debug, @@ -15246,11 +26453,19 @@ mod root { ::serde::Deserialize, )] pub struct SendRequest { + /// The field `ppid` in the table `SendRequest` pub ppid: u8, + /// The field `data` in the table `SendRequest` pub data: self::Data, } 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, @@ -15258,35 +26473,33 @@ mod root { field_data: impl ::planus::WriteAsUnion, ) -> ::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::<6, 6>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<10> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(2); if prepared_ppid.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.calculate_size::(4); - table_writer.calculate_size::<::planus::Offset>(6); - - table_writer.finish_calculating(); + table_writer.write_entry::(1); unsafe { - table_writer.write::<_, _, 4>(2, &prepared_data.offset()); - if let ::core::option::Option::Some(prepared_ppid) = prepared_ppid { - table_writer.write::<_, _, 1>(0, &prepared_ppid); - } - table_writer.write::<_, _, 1>(1, &prepared_data.tag()); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_data.offset()); + if let ::core::option::Option::Some(prepared_ppid) = prepared_ppid { + object_writer.write::<_, _, 1>(&prepared_ppid); + } + object_writer.write::<_, _, 1>(&prepared_data.tag()); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for SendRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -15298,6 +26511,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for SendRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -15307,24 +26521,125 @@ mod root { } 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::WriteAsUnion, + { + 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, T1: ::planus::WriteAsUnion> + ::planus::WriteAs<::planus::Offset> for SendRequestBuilder<(T0, T1)> + { + type Prepared = ::planus::Offset; + + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - SendRequest::create(builder, &self.ppid, &self.data) + ::planus::WriteAsOffset::prepare(self, builder) } } + impl, T1: ::planus::WriteAsUnion> + ::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, T1: ::planus::WriteAsUnion> + ::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> { self.0.access_union_required(1, "SendRequest", "data") } @@ -15352,6 +26667,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SendRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -15383,6 +26699,7 @@ mod root { 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) } @@ -15419,6 +26736,10 @@ mod root { } } + /// The table `BufferedAmountLowNotification` in the namespace `FBS.DataConsumer` + /// + /// Generated from these locations: + /// * Table `BufferedAmountLowNotification` in the file `../worker/fbs/dataConsumer.fbs:54` #[derive( Clone, Debug, @@ -15431,6 +26752,7 @@ mod root { ::serde::Deserialize, )] pub struct BufferedAmountLowNotification { + /// The field `buffered_amount` in the table `BufferedAmountLowNotification` pub buffered_amount: u32, } @@ -15442,6 +26764,12 @@ mod root { } 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, @@ -15449,24 +26777,22 @@ mod root { ) -> ::planus::Offset { let prepared_buffered_amount = field_buffered_amount.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_buffered_amount.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_buffered_amount) = - prepared_buffered_amount - { - table_writer.write::<_, _, 4>(0, &prepared_buffered_amount); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } @@ -15475,6 +26801,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -15488,6 +26815,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -15498,18 +26826,113 @@ mod root { } impl ::planus::WriteAsOffset for BufferedAmountLowNotification { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - BufferedAmountLowNotification::create(builder, &self.buffered_amount) + 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 @@ -15543,6 +26966,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for BufferedAmountLowNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -15576,6 +27000,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -15616,6 +27041,10 @@ mod root { } } + /// The table `MessageNotification` in the namespace `FBS.DataConsumer` + /// + /// Generated from these locations: + /// * Table `MessageNotification` in the file `../worker/fbs/dataConsumer.fbs:58` #[derive( Clone, Debug, @@ -15628,11 +27057,19 @@ mod root { ::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, @@ -15640,33 +27077,31 @@ mod root { 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::<6, 8>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<8> = + ::core::default::Default::default(); if prepared_ppid.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.calculate_size::<::planus::Offset<[u8]>>(4); - - table_writer.finish_calculating(); + table_writer.write_entry::<::planus::Offset<[u8]>>(1); unsafe { - if let ::core::option::Option::Some(prepared_ppid) = prepared_ppid { - table_writer.write::<_, _, 4>(0, &prepared_ppid); - } - table_writer.write::<_, _, 4>(1, &prepared_data); + 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); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for MessageNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -15678,6 +27113,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for MessageNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -15687,18 +27123,127 @@ mod root { } 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 { - MessageNotification::create(builder, &self.ppid, &self.data) + ::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 @@ -15707,7 +27252,9 @@ mod root { ) } - pub fn data(&self) -> ::planus::Result<::planus::Vector<'a, u8>> { + /// Getter for the [`data` field](MessageNotification#structfield.data). + #[inline] + pub fn data(&self) -> ::planus::Result<&'a [u8]> { self.0.access_required(1, "MessageNotification", "data") } } @@ -15728,12 +27275,13 @@ mod root { 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()?, + data: value.data()?.to_vec(), }) } } impl<'a> ::planus::TableRead<'a> for MessageNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -15765,6 +27313,7 @@ mod root { 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) } @@ -15805,7 +27354,15 @@ mod root { } } } + /// 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:4` #[derive( Clone, Debug, @@ -15818,7 +27375,9 @@ mod root { ::serde::Deserialize, )] pub struct NumSctpStreams { + /// The field `os` in the table `NumSctpStreams` pub os: u32, + /// The field `mis` in the table `NumSctpStreams` pub mis: u32, } @@ -15833,6 +27392,12 @@ mod root { } 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, @@ -15840,37 +27405,35 @@ mod root { 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::<6, 8>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<8> = + ::core::default::Default::default(); if prepared_os.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } if prepared_mis.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(1); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_os) = prepared_os { - table_writer.write::<_, _, 4>(0, &prepared_os); - } - if let ::core::option::Option::Some(prepared_mis) = prepared_mis { - table_writer.write::<_, _, 4>(1, &prepared_mis); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_os) = prepared_os { + object_writer.write::<_, _, 4>(&prepared_os); + } + if let ::core::option::Option::Some(prepared_mis) = prepared_mis { + object_writer.write::<_, _, 4>(&prepared_mis); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for NumSctpStreams { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -15882,6 +27445,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for NumSctpStreams { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -15891,24 +27455,139 @@ mod root { } impl ::planus::WriteAsOffset for NumSctpStreams { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - NumSctpStreams::create(builder, &self.os, &self.mis) + 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), @@ -15938,6 +27617,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for NumSctpStreamsRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -15969,6 +27649,7 @@ mod root { 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) } @@ -16005,6 +27686,10 @@ mod root { } } + /// The table `SctpParameters` in the namespace `FBS.SctpParameters` + /// + /// Generated from these locations: + /// * Table `SctpParameters` in the file `../worker/fbs/sctpParameters.fbs:9` #[derive( Clone, Debug, @@ -16017,12 +27702,19 @@ mod root { ::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, } @@ -16042,6 +27734,12 @@ mod root { } 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, @@ -16054,86 +27752,79 @@ mod root { 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::<16, 19>::new(builder); - - if prepared_port.is_some() { - table_writer.calculate_size::(2); - } - if prepared_os.is_some() { - table_writer.calculate_size::(4); - } - if prepared_mis.is_some() { - table_writer.calculate_size::(6); - } + let mut table_writer: ::planus::table_writer::TableWriter<18> = + ::core::default::Default::default(); if prepared_max_message_size.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(3); } if prepared_send_buffer_size.is_some() { - table_writer.calculate_size::(10); + table_writer.write_entry::(4); } if prepared_sctp_buffered_amount.is_some() { - table_writer.calculate_size::(12); + 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.calculate_size::(14); + table_writer.write_entry::(6); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_max_message_size) = - prepared_max_message_size - { - table_writer.write::<_, _, 4>(3, &prepared_max_message_size); - } - if let ::core::option::Option::Some(prepared_send_buffer_size) = - prepared_send_buffer_size - { - table_writer.write::<_, _, 4>(4, &prepared_send_buffer_size); - } - if let ::core::option::Option::Some(prepared_sctp_buffered_amount) = - prepared_sctp_buffered_amount - { - table_writer.write::<_, _, 4>(5, &prepared_sctp_buffered_amount); - } - if let ::core::option::Option::Some(prepared_port) = prepared_port { - table_writer.write::<_, _, 2>(0, &prepared_port); - } - if let ::core::option::Option::Some(prepared_os) = prepared_os { - table_writer.write::<_, _, 2>(1, &prepared_os); - } - if let ::core::option::Option::Some(prepared_mis) = prepared_mis { - table_writer.write::<_, _, 2>(2, &prepared_mis); - } - if let ::core::option::Option::Some(prepared_is_data_channel) = - prepared_is_data_channel - { - table_writer.write::<_, _, 1>(6, &prepared_is_data_channel); - } - } - - table_writer.finish() + 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, @@ -16145,6 +27836,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for SctpParameters { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -16154,45 +27846,305 @@ mod root { } 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, + 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 @@ -16201,6 +28153,8 @@ mod root { ) } + /// 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 @@ -16209,6 +28163,8 @@ mod root { ) } + /// 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 @@ -16217,6 +28173,8 @@ mod root { ) } + /// 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 @@ -16266,6 +28224,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SctpParametersRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -16297,6 +28256,7 @@ mod root { 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) } @@ -16333,6 +28293,10 @@ mod root { } } + /// The table `SctpStreamParameters` in the namespace `FBS.SctpParameters` + /// + /// Generated from these locations: + /// * Table `SctpStreamParameters` in the file `../worker/fbs/sctpParameters.fbs:20` #[derive( Clone, Debug, @@ -16345,9 +28309,13 @@ mod root { ::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, } @@ -16364,6 +28332,12 @@ mod root { } 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, @@ -16373,58 +28347,56 @@ mod root { 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::<10, 7>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<12> = + ::core::default::Default::default(); if prepared_stream_id.is_some() { - table_writer.calculate_size::(2); - } - if prepared_ordered.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(0); } if prepared_max_packet_life_time.is_some() { - table_writer.calculate_size::(6); + table_writer.write_entry::(2); } if prepared_max_retransmits.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(3); } - - table_writer.finish_calculating(); - - unsafe { - if let ::core::option::Option::Some(prepared_stream_id) = prepared_stream_id - { - table_writer.write::<_, _, 2>(0, &prepared_stream_id); - } - if let ::core::option::Option::Some(prepared_max_packet_life_time) = - prepared_max_packet_life_time - { - table_writer.write::<_, _, 2>(2, &prepared_max_packet_life_time); - } - if let ::core::option::Option::Some(prepared_max_retransmits) = - prepared_max_retransmits - { - table_writer.write::<_, _, 2>(3, &prepared_max_retransmits); - } - if let ::core::option::Option::Some(prepared_ordered) = prepared_ordered { - table_writer.write::<_, _, 1>(1, &prepared_ordered); - } + if prepared_ordered.is_some() { + table_writer.write_entry::(1); } - table_writer.finish() + 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, @@ -16436,6 +28408,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for SctpStreamParameters { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -16446,24 +28419,197 @@ mod root { } 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, + 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 @@ -16472,10 +28618,14 @@ mod root { ) } + /// 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> { @@ -16483,6 +28633,8 @@ mod root { .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") } @@ -16548,6 +28700,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SctpStreamParametersRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -16579,6 +28732,7 @@ mod root { 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) } @@ -16619,7 +28773,15 @@ mod root { } } } + /// The namespace `FBS.DataProducer` + /// + /// Generated from these locations: + /// * File `../worker/fbs/dataProducer.fbs` pub mod data_producer { + /// The table `DumpResponse` in the namespace `FBS.DataProducer` + /// + /// Generated from these locations: + /// * Table `DumpResponse` in the file `../worker/fbs/dataProducer.fbs:5` #[derive( Clone, Debug, @@ -16632,17 +28794,29 @@ mod root { ::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_: ::planus::alloc::string::String, + /// 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, @@ -16656,56 +28830,50 @@ mod root { field_paused: impl ::planus::WriteAsDefault, ) -> ::planus::Offset { let prepared_id = field_id.prepare(builder); - let prepared_type_ = field_type_.prepare(builder); - 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::<14, 21>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); + 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>(1); if prepared_sctp_stream_parameters.is_some() { - table_writer.calculate_size::<::planus::Offset>(6); + table_writer.write_entry::<::planus::Offset>(2); } - table_writer.calculate_size::<::planus::Offset>(8); - table_writer.calculate_size::<::planus::Offset>(10); + table_writer.write_entry::<::planus::Offset>(3); + table_writer.write_entry::<::planus::Offset>(4); if prepared_paused.is_some() { - table_writer.calculate_size::(12); + table_writer.write_entry::(5); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_id); - table_writer.write::<_, _, 4>(1, &prepared_type_); - if let ::core::option::Option::Some(prepared_sctp_stream_parameters) = - prepared_sctp_stream_parameters - { - table_writer.write::<_, _, 4>(2, &prepared_sctp_stream_parameters); - } - table_writer.write::<_, _, 4>(3, &prepared_label); - table_writer.write::<_, _, 4>(4, &prepared_protocol); - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - table_writer.write::<_, _, 1>(5, &prepared_paused); - } + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_id); + object_writer.write::<_, _, 4>(&prepared_type_); + 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_paused) = prepared_paused { + object_writer.write::<_, _, 1>(&prepared_paused); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -16717,6 +28885,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -16726,6 +28895,7 @@ mod root { } impl ::planus::WriteAsOffset for DumpResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -16737,23 +28907,218 @@ mod root { &self.sctp_stream_parameters, &self.label, &self.protocol, - &self.paused, + 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::WriteAs<::planus::Offset>, + { + let (v0,) = self.0; + DumpResponseBuilder((v0, value)) + } + } + + 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::WriteAs<::planus::Offset>, + 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::WriteAs<::planus::Offset>, + 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::WriteAs<::planus::Offset>, + 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<&'a ::core::primitive::str> { self.0.access_required(1, "DumpResponse", "type_") } + /// Getter for the [`sctp_stream_parameters` field](DumpResponse#structfield.sctp_stream_parameters). + #[inline] pub fn sctp_stream_parameters( &self, ) -> ::planus::Result< @@ -16762,14 +29127,20 @@ mod root { 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), @@ -16820,6 +29191,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -16851,6 +29223,7 @@ mod root { 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) } @@ -16887,6 +29260,10 @@ mod root { } } + /// The table `GetStatsResponse` in the namespace `FBS.DataProducer` + /// + /// Generated from these locations: + /// * Table `GetStatsResponse` in the file `../worker/fbs/dataProducer.fbs:14` #[derive( Clone, Debug, @@ -16899,15 +29276,27 @@ mod root { ::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, @@ -16919,68 +29308,63 @@ mod root { 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::<14, 36>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<16> = + ::core::default::Default::default(); if prepared_timestamp.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.calculate_size::<::planus::Offset>(4); - table_writer.calculate_size::<::planus::Offset>(6); if prepared_messages_received.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(3); } if prepared_bytes_received.is_some() { - table_writer.calculate_size::(10); + 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.calculate_size::(12); + table_writer.write_entry::(5); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_timestamp) = prepared_timestamp - { - table_writer.write::<_, _, 8>(0, &prepared_timestamp); - } - if let ::core::option::Option::Some(prepared_messages_received) = - prepared_messages_received - { - table_writer.write::<_, _, 8>(3, &prepared_messages_received); - } - if let ::core::option::Option::Some(prepared_bytes_received) = - prepared_bytes_received - { - table_writer.write::<_, _, 8>(4, &prepared_bytes_received); - } - table_writer.write::<_, _, 4>(1, &prepared_label); - table_writer.write::<_, _, 4>(2, &prepared_protocol); - if let ::core::option::Option::Some(prepared_buffered_amount) = - prepared_buffered_amount - { - table_writer.write::<_, _, 4>(5, &prepared_buffered_amount); - } - } - - table_writer.finish() + 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, @@ -16992,6 +29376,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -17001,26 +29386,237 @@ mod root { } impl ::planus::WriteAsOffset for GetStatsResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { GetStatsResponse::create( builder, - &self.timestamp, + self.timestamp, &self.label, &self.protocol, - &self.messages_received, - &self.bytes_received, - &self.buffered_amount, + 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 @@ -17029,14 +29625,20 @@ mod root { ) } + /// 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 @@ -17045,6 +29647,8 @@ mod root { ) } + /// Getter for the [`bytes_received` field](GetStatsResponse#structfield.bytes_received). + #[inline] pub fn bytes_received(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -17053,6 +29657,8 @@ mod root { ) } + /// Getter for the [`buffered_amount` field](GetStatsResponse#structfield.buffered_amount). + #[inline] pub fn buffered_amount(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -17098,6 +29704,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -17129,6 +29736,7 @@ mod root { 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) } @@ -17165,6 +29773,10 @@ mod root { } } + /// The table `String` in the namespace `FBS.DataProducer` + /// + /// Generated from these locations: + /// * Table `String` in the file `../worker/fbs/dataProducer.fbs:23` #[derive( Clone, Debug, @@ -17177,10 +29789,17 @@ mod root { ::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, @@ -17188,24 +29807,23 @@ mod root { ) -> ::planus::Offset { let prepared_value = field_value.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_value); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_value); + }); } - - table_writer.finish() + 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) } @@ -17214,6 +29832,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for String { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -17223,15 +29842,84 @@ mod root { } 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") } @@ -17257,6 +29945,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for StringRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -17288,6 +29977,7 @@ mod root { 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) } @@ -17324,6 +30014,10 @@ mod root { } } + /// The table `Binary` in the namespace `FBS.DataProducer` + /// + /// Generated from these locations: + /// * Table `Binary` in the file `../worker/fbs/dataProducer.fbs:27` #[derive( Clone, Debug, @@ -17336,10 +30030,17 @@ mod root { ::serde::Deserialize, )] pub struct Binary { + /// The field `value` in the table `Binary` pub value: ::planus::alloc::vec::Vec, } impl Binary { + /// Creates a [BinaryBuilder] for serializing an instance of this table. + #[inline] + pub fn builder() -> BinaryBuilder<()> { + BinaryBuilder(()) + } + #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, @@ -17347,24 +30048,23 @@ mod root { ) -> ::planus::Offset { let prepared_value = field_value.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset<[u8]>>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset<[u8]>>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_value); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_value); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for Binary { type Prepared = ::planus::Offset; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } @@ -17373,6 +30073,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Binary { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -17382,16 +30083,85 @@ mod root { } impl ::planus::WriteAsOffset for Binary { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { Binary::create(builder, &self.value) } } + /// Builder for serializing an instance of the [Binary] type. + /// + /// Can be created using the [Binary::builder] method. + #[derive(Debug)] + #[must_use] + pub struct BinaryBuilder(State); + + impl BinaryBuilder<()> { + /// Setter for the [`value` field](Binary#structfield.value). + #[inline] + #[allow(clippy::type_complexity)] + pub fn value(self, value: T0) -> BinaryBuilder<(T0,)> + where + T0: ::planus::WriteAs<::planus::Offset<[u8]>>, + { + BinaryBuilder((value,)) + } + } + + impl BinaryBuilder<(T0,)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Binary]. + #[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 BinaryBuilder<(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 BinaryBuilder<(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 BinaryBuilder<(T0,)> + { + #[inline] + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + let (v0,) = &self.0; + Binary::create(builder, v0) + } + } + + /// Reference to a deserialized [Binary]. #[derive(Copy, Clone)] pub struct BinaryRef<'a>(::planus::table_reader::Table<'a>); impl<'a> BinaryRef<'a> { - pub fn value(&self) -> ::planus::Result<::planus::Vector<'a, u8>> { + /// Getter for the [`value` field](Binary#structfield.value). + #[inline] + pub fn value(&self) -> ::planus::Result<&'a [u8]> { self.0.access_required(0, "Binary", "value") } } @@ -17410,12 +30180,13 @@ mod root { #[allow(unreachable_code)] fn try_from(value: BinaryRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - value: value.value()?.to_vec()?, + value: value.value()?.to_vec(), }) } } impl<'a> ::planus::TableRead<'a> for BinaryRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -17447,6 +30218,7 @@ mod root { impl ::planus::VectorWrite<::planus::Offset> for Binary { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -17483,6 +30255,10 @@ mod root { } } + /// The union `Data` in the namespace `FBS.DataProducer` + /// + /// Generated from these locations: + /// * Union `Data` in the file `../worker/fbs/dataProducer.fbs:31` #[derive( Clone, Debug, @@ -17495,11 +30271,21 @@ mod root { ::serde::Deserialize, )] pub enum Data { + /// The variant of type `String` in the union `Data` String(::planus::alloc::boxed::Box), + + /// The variant of type `Binary` in the union `Data` Binary(::planus::alloc::boxed::Box), } impl Data { + /// Creates a [DataBuilder] for serializing an instance of this table. + #[inline] + pub fn builder() -> DataBuilder<::planus::Uninitialized> { + DataBuilder(::planus::Uninitialized) + } + + #[inline] pub fn create_string( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -17507,6 +30293,7 @@ mod root { ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) } + #[inline] pub fn create_binary( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -17516,6 +30303,7 @@ mod root { } impl ::planus::WriteAsUnion for Data { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { match self { Self::String(value) => Self::create_string(builder, value), @@ -17525,6 +30313,7 @@ mod root { } impl ::planus::WriteAsOptionalUnion for Data { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -17533,6 +30322,90 @@ mod root { } } + /// Builder for serializing an instance of the [Data] type. + /// + /// Can be created using the [Data::builder] method. + #[derive(Debug)] + #[must_use] + pub struct DataBuilder(T); + + impl DataBuilder<::planus::Uninitialized> { + /// Creates an instance of the [`String` variant](Data#variant.String). + #[inline] + pub fn string(self, value: T) -> DataBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, + { + DataBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`Binary` variant](Data#variant.Binary). + #[inline] + pub fn binary(self, value: T) -> DataBuilder<::planus::Initialized<2, T>> + where + T: ::planus::WriteAsOffset, + { + DataBuilder(::planus::Initialized(value)) + } + } + + impl DataBuilder<::planus::Initialized> { + /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Data]. + #[inline] + pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset + where + Self: ::planus::WriteAsUnion, + { + ::planus::WriteAsUnion::prepare(&self, builder) + } + } + + impl ::planus::WriteAsUnion for DataBuilder<::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 DataBuilder<::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 DataBuilder<::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 DataBuilder<::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 [Data]. #[derive(Copy, Clone, Debug)] pub enum DataRef<'a> { String(self::StringRef<'a>), @@ -17544,11 +30417,11 @@ mod root { fn try_from(value: DataRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(match value { - DataRef::String(value) => Data::String(::planus::alloc::boxed::Box::new( + DataRef::String(value) => Self::String(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )), - DataRef::Binary(value) => Data::Binary(::planus::alloc::boxed::Box::new( + DataRef::Binary(value) => Self::Binary(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )), }) @@ -17575,6 +30448,10 @@ mod root { } } + /// The table `SendNotification` in the namespace `FBS.DataProducer` + /// + /// Generated from these locations: + /// * Table `SendNotification` in the file `../worker/fbs/dataProducer.fbs:36` #[derive( Clone, Debug, @@ -17587,11 +30464,19 @@ mod root { ::serde::Deserialize, )] pub struct SendNotification { + /// The field `ppid` in the table `SendNotification` pub ppid: u8, + /// The field `data` in the table `SendNotification` pub data: self::Data, } 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, @@ -17599,35 +30484,33 @@ mod root { field_data: impl ::planus::WriteAsUnion, ) -> ::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::<6, 6>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<10> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(2); if prepared_ppid.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.calculate_size::(4); - table_writer.calculate_size::<::planus::Offset>(6); - - table_writer.finish_calculating(); + table_writer.write_entry::(1); unsafe { - table_writer.write::<_, _, 4>(2, &prepared_data.offset()); - if let ::core::option::Option::Some(prepared_ppid) = prepared_ppid { - table_writer.write::<_, _, 1>(0, &prepared_ppid); - } - table_writer.write::<_, _, 1>(1, &prepared_data.tag()); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_data.offset()); + if let ::core::option::Option::Some(prepared_ppid) = prepared_ppid { + object_writer.write::<_, _, 1>(&prepared_ppid); + } + object_writer.write::<_, _, 1>(&prepared_data.tag()); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for SendNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -17639,6 +30522,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for SendNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -17648,24 +30532,126 @@ mod root { } impl ::planus::WriteAsOffset for SendNotification { + #[inline] + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SendNotification::create(builder, self.ppid, &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 [`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::WriteAsUnion, + { + let (v0,) = self.0; + SendNotificationBuilder((v0, value)) + } + } + + impl SendNotificationBuilder<(T0, T1)> { + /// 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, T1: ::planus::WriteAsUnion> + ::planus::WriteAs<::planus::Offset> + for SendNotificationBuilder<(T0, T1)> + { + type Prepared = ::planus::Offset; + + #[inline] + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) + } + } + + impl, T1: ::planus::WriteAsUnion> + ::planus::WriteAsOptional<::planus::Offset> + for SendNotificationBuilder<(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::WriteAsUnion> + ::planus::WriteAsOffset for SendNotificationBuilder<(T0, T1)> + { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - SendNotification::create(builder, &self.ppid, &self.data) + let (v0, v1) = &self.0; + SendNotification::create(builder, v0, v1) } } + /// 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> { self.0.access_union_required(1, "SendNotification", "data") } @@ -17693,6 +30679,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SendNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -17724,6 +30711,7 @@ mod root { 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) } @@ -17760,7 +30748,15 @@ mod root { } } } + /// 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, @@ -17773,6 +30769,7 @@ mod root { ::serde::Deserialize, )] pub struct DirectTransportOptions { + /// The field `base` in the table `DirectTransportOptions` pub base: ::planus::alloc::boxed::Box, } @@ -17786,6 +30783,12 @@ mod root { } 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, @@ -17793,24 +30796,23 @@ mod root { ) -> ::planus::Offset { let prepared_base = field_base.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_base); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_base); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for DirectTransportOptions { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -17824,6 +30826,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -17834,6 +30837,7 @@ mod root { } impl ::planus::WriteAsOffset for DirectTransportOptions { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -17842,10 +30846,91 @@ mod root { } } + /// 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") } @@ -17873,6 +30958,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DirectTransportOptionsRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -17904,6 +30990,7 @@ mod root { 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) } @@ -17944,6 +31031,10 @@ mod root { } } + /// 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, @@ -17956,10 +31047,17 @@ mod root { ::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, @@ -17967,24 +31065,23 @@ mod root { ) -> ::planus::Offset { let prepared_base = field_base.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_base); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_base); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -17996,6 +31093,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -18005,6 +31103,7 @@ mod root { } impl ::planus::WriteAsOffset for DumpResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -18013,10 +31112,88 @@ mod root { } } + /// 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") } @@ -18044,6 +31221,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -18075,6 +31253,7 @@ mod root { 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) } @@ -18111,14 +31290,25 @@ mod root { } } + /// 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, @@ -18126,24 +31316,23 @@ mod root { ) -> ::planus::Offset { let prepared_base = field_base.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_base); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_base); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -18155,6 +31344,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -18164,6 +31354,7 @@ mod root { } impl ::planus::WriteAsOffset for GetStatsResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -18172,10 +31363,89 @@ mod root { } } + /// 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") } @@ -18203,6 +31473,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -18234,6 +31505,7 @@ mod root { 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) } @@ -18270,6 +31542,10 @@ mod root { } } + /// 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, @@ -18282,10 +31558,17 @@ mod root { ::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, @@ -18293,24 +31576,23 @@ mod root { ) -> ::planus::Offset { let prepared_data = field_data.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset<[u8]>>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset<[u8]>>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_data); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_data); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for RtcpNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -18322,6 +31604,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for RtcpNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -18331,6 +31614,7 @@ mod root { } impl ::planus::WriteAsOffset for RtcpNotification { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -18339,11 +31623,90 @@ mod root { } } + /// 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> { - pub fn data(&self) -> ::planus::Result<::planus::Vector<'a, u8>> { + /// Getter for the [`data` field](RtcpNotification#structfield.data). + #[inline] + pub fn data(&self) -> ::planus::Result<&'a [u8]> { self.0.access_required(0, "RtcpNotification", "data") } } @@ -18362,12 +31725,13 @@ mod root { #[allow(unreachable_code)] fn try_from(value: RtcpNotificationRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - data: value.data()?.to_vec()?, + data: value.data()?.to_vec(), }) } } impl<'a> ::planus::TableRead<'a> for RtcpNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -18399,6 +31763,7 @@ mod root { 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) } @@ -18435,7 +31800,15 @@ mod root { } } } + /// 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:9` #[derive( Copy, Clone, @@ -18450,12 +31823,21 @@ mod root { )] #[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 @@ -18473,6 +31855,7 @@ mod root { } impl ::core::convert::From for u8 { + #[inline] fn from(value: Protocol) -> Self { value as u8 } @@ -18533,6 +31916,7 @@ mod root { } impl<'buf> ::planus::TableRead<'buf> for Protocol { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, @@ -18551,7 +31935,7 @@ mod root { offset: usize, ) -> ::core::result::Result { - let value = ::from_buffer(buffer, offset); + let value = *buffer.buffer.get_unchecked(offset); let value: ::core::result::Result = ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { @@ -18569,6 +31953,7 @@ mod root { type Value = Self; + #[inline] fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { *self } @@ -18590,6 +31975,10 @@ mod root { } } + /// The table `ListenInfo` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `ListenInfo` in the file `../worker/fbs/transport.fbs:11` #[derive( Clone, Debug, @@ -18602,15 +31991,27 @@ mod root { ::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, @@ -18624,71 +32025,67 @@ mod root { 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::<14, 19>::new(builder); - - if prepared_protocol.is_some() { - table_writer.calculate_size::(2); - } - table_writer.calculate_size::<::planus::Offset>(4); + 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.calculate_size::<::planus::Offset>(6); - } - if prepared_port.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::<::planus::Offset>(2); } if prepared_send_buffer_size.is_some() { - table_writer.calculate_size::(10); + table_writer.write_entry::(4); } if prepared_recv_buffer_size.is_some() { - table_writer.calculate_size::(12); + table_writer.write_entry::(5); } - - table_writer.finish_calculating(); - - unsafe { - table_writer.write::<_, _, 4>(1, &prepared_ip); - if let ::core::option::Option::Some(prepared_announced_ip) = - prepared_announced_ip - { - table_writer.write::<_, _, 4>(2, &prepared_announced_ip); - } - if let ::core::option::Option::Some(prepared_send_buffer_size) = - prepared_send_buffer_size - { - table_writer.write::<_, _, 4>(4, &prepared_send_buffer_size); - } - if let ::core::option::Option::Some(prepared_recv_buffer_size) = - prepared_recv_buffer_size - { - table_writer.write::<_, _, 4>(5, &prepared_recv_buffer_size); - } - if let ::core::option::Option::Some(prepared_port) = prepared_port { - table_writer.write::<_, _, 2>(3, &prepared_port); - } - if let ::core::option::Option::Some(prepared_protocol) = prepared_protocol { - table_writer.write::<_, _, 1>(0, &prepared_protocol); - } + if prepared_port.is_some() { + table_writer.write_entry::(3); + } + if prepared_protocol.is_some() { + table_writer.write_entry::(0); } - table_writer.finish() + 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) } @@ -18697,6 +32094,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ListenInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -18706,23 +32104,226 @@ mod root { } impl ::planus::WriteAsOffset for ListenInfo { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { ListenInfo::create( builder, - &self.protocol, + self.protocol, &self.ip, &self.announced_ip, - &self.port, - &self.send_buffer_size, - &self.recv_buffer_size, + 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 @@ -18731,10 +32332,14 @@ mod root { ) } + /// 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>> @@ -18742,10 +32347,14 @@ mod root { 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 @@ -18754,6 +32363,8 @@ mod root { ) } + /// 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 @@ -18809,6 +32420,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ListenInfoRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -18840,6 +32452,7 @@ mod root { 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) } @@ -18876,6 +32489,10 @@ mod root { } } + /// The table `RestartIceResponse` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `RestartIceResponse` in the file `../worker/fbs/transport.fbs:20` #[derive( Clone, Debug, @@ -18888,12 +32505,21 @@ mod root { ::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, @@ -18902,37 +32528,36 @@ mod root { 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::<8, 9>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); + 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.calculate_size::(6); + table_writer.write_entry::(2); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_username_fragment); - table_writer.write::<_, _, 4>(1, &prepared_password); - if let ::core::option::Option::Some(prepared_ice_lite) = prepared_ice_lite { - table_writer.write::<_, _, 1>(2, &prepared_ice_lite); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for RestartIceResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -18944,6 +32569,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for RestartIceResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -18953,6 +32579,7 @@ mod root { } impl ::planus::WriteAsOffset for RestartIceResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -18961,24 +32588,152 @@ mod root { builder, &self.username_fragment, &self.password, - &self.ice_lite, + 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 @@ -19014,6 +32769,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RestartIceResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -19045,6 +32801,7 @@ mod root { 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) } @@ -19081,20 +32838,36 @@ mod root { } } + /// The table `ProduceRequest` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `ProduceRequest` in the file `../worker/fbs/transport.fbs:26` #[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: u16, + /// 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, @@ -19113,65 +32886,57 @@ mod root { 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::All); - 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::<14, 16>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - if prepared_kind.is_some() { - table_writer.calculate_size::(4); - } + let mut table_writer: ::planus::table_writer::TableWriter<16> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); table_writer - .calculate_size::<::planus::Offset>( - 6, - ); + .write_entry::<::planus::Offset>(2); table_writer - .calculate_size::<::planus::Offset>(8); + .write_entry::<::planus::Offset>(3); if prepared_key_frame_request_delay.is_some() { - table_writer.calculate_size::(10); + table_writer.write_entry::(4); + } + if prepared_kind.is_some() { + table_writer.write_entry::(1); } if prepared_paused.is_some() { - table_writer.calculate_size::(12); + table_writer.write_entry::(5); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_producer_id); - table_writer.write::<_, _, 4>(2, &prepared_rtp_parameters); - table_writer.write::<_, _, 4>(3, &prepared_rtp_mapping); - if let ::core::option::Option::Some(prepared_key_frame_request_delay) = - prepared_key_frame_request_delay - { - table_writer.write::<_, _, 2>(4, &prepared_key_frame_request_delay); - } - if let ::core::option::Option::Some(prepared_kind) = prepared_kind { - table_writer.write::<_, _, 1>(1, &prepared_kind); - } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - table_writer.write::<_, _, 1>(5, &prepared_paused); - } - } - - table_writer.finish() + 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::<_, _, 2>(&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, @@ -19183,6 +32948,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ProduceRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -19192,6 +32958,7 @@ mod root { } impl ::planus::WriteAsOffset for ProduceRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -19199,23 +32966,235 @@ mod root { ProduceRequest::create( builder, &self.producer_id, - &self.kind, + self.kind, &self.rtp_parameters, &self.rtp_mapping, - &self.key_frame_request_delay, - &self.paused, + 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 @@ -19224,6 +33203,8 @@ mod root { ) } + /// Getter for the [`rtp_parameters` field](ProduceRequest#structfield.rtp_parameters). + #[inline] pub fn rtp_parameters( &self, ) -> ::planus::Result> { @@ -19231,12 +33212,16 @@ mod root { .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 @@ -19245,6 +33230,8 @@ mod root { ) } + /// Getter for the [`paused` field](ProduceRequest#structfield.paused). + #[inline] pub fn paused(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -19290,6 +33277,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ProduceRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -19321,6 +33309,7 @@ mod root { 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) } @@ -19357,6 +33346,10 @@ mod root { } } + /// The table `ProduceResponse` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `ProduceResponse` in the file `../worker/fbs/transport.fbs:35` #[derive( Clone, Debug, @@ -19369,6 +33362,7 @@ mod root { ::serde::Deserialize, )] pub struct ProduceResponse { + /// The field `type` in the table `ProduceResponse` pub type_: super::rtp_parameters::Type, } @@ -19382,6 +33376,12 @@ mod root { } 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, @@ -19393,28 +33393,27 @@ mod root { let prepared_type_ = field_type_.prepare(builder, &super::rtp_parameters::Type::None); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 1>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_type_.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - table_writer.write::<_, _, 1>(0, &prepared_type_); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { + object_writer.write::<_, _, 1>(&prepared_type_); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for ProduceResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -19426,6 +33425,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ProduceResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -19435,18 +33435,120 @@ mod root { } impl ::planus::WriteAsOffset for ProduceResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - ProduceResponse::create(builder, &self.type_) + 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 @@ -19476,6 +33578,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ProduceResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -19507,6 +33610,7 @@ mod root { 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) } @@ -19543,26 +33647,45 @@ mod root { } } + /// The table `ConsumeRequest` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `ConsumeRequest` in the file `../worker/fbs/transport.fbs:39` #[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, @@ -19591,92 +33714,79 @@ mod root { 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::All); - let prepared_rtp_parameters = field_rtp_parameters.prepare(builder); - let prepared_type_ = field_type_.prepare(builder, &super::rtp_parameters::Type::None); - 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::<20, 24>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); + 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.calculate_size::(6); + table_writer.write_entry::(2); } - table_writer - .calculate_size::<::planus::Offset>( - 8, - ); if prepared_type_.is_some() { - table_writer.calculate_size::(10); + table_writer.write_entry::(4); } - table_writer.calculate_size::<::planus::Offset< - [::planus::Offset], - >>(12); if prepared_paused.is_some() { - table_writer.calculate_size::(14); - } - if prepared_preferred_layers.is_some() { - table_writer - .calculate_size::<::planus::Offset>( - 16, - ); + table_writer.write_entry::(6); } if prepared_ignore_dtx.is_some() { - table_writer.calculate_size::(18); + table_writer.write_entry::(8); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_consumer_id); - table_writer.write::<_, _, 4>(1, &prepared_producer_id); - table_writer.write::<_, _, 4>(3, &prepared_rtp_parameters); - table_writer.write::<_, _, 4>(5, &prepared_consumable_rtp_encodings); - if let ::core::option::Option::Some(prepared_preferred_layers) = - prepared_preferred_layers - { - table_writer.write::<_, _, 4>(7, &prepared_preferred_layers); - } - if let ::core::option::Option::Some(prepared_kind) = prepared_kind { - table_writer.write::<_, _, 1>(2, &prepared_kind); - } - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - table_writer.write::<_, _, 1>(4, &prepared_type_); - } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - table_writer.write::<_, _, 1>(6, &prepared_paused); - } - if let ::core::option::Option::Some(prepared_ignore_dtx) = - prepared_ignore_dtx - { - table_writer.write::<_, _, 1>(8, &prepared_ignore_dtx); - } - } - - table_writer.finish() + 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, @@ -19688,6 +33798,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ConsumeRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -19697,6 +33808,7 @@ mod root { } impl ::planus::WriteAsOffset for ConsumeRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -19705,29 +33817,351 @@ mod root { builder, &self.consumer_id, &self.producer_id, - &self.kind, + self.kind, &self.rtp_parameters, - &self.type_, + self.type_, &self.consumable_rtp_encodings, - &self.paused, + self.paused, &self.preferred_layers, - &self.ignore_dtx, + 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 @@ -19736,6 +34170,8 @@ mod root { ) } + /// Getter for the [`rtp_parameters` field](ConsumeRequest#structfield.rtp_parameters). + #[inline] pub fn rtp_parameters( &self, ) -> ::planus::Result> { @@ -19743,6 +34179,8 @@ mod root { .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 @@ -19751,6 +34189,8 @@ mod root { ) } + /// Getter for the [`consumable_rtp_encodings` field](ConsumeRequest#structfield.consumable_rtp_encodings). + #[inline] pub fn consumable_rtp_encodings( &self, ) -> ::planus::Result< @@ -19763,6 +34203,8 @@ mod root { .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 @@ -19771,6 +34213,8 @@ mod root { ) } + /// Getter for the [`preferred_layers` field](ConsumeRequest#structfield.preferred_layers). + #[inline] pub fn preferred_layers( &self, ) -> ::planus::Result<::core::option::Option>> @@ -19778,6 +34222,8 @@ mod root { 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 @@ -19839,6 +34285,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ConsumeRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -19870,6 +34317,7 @@ mod root { 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) } @@ -19906,6 +34354,10 @@ mod root { } } + /// The table `ConsumeResponse` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `ConsumeResponse` in the file `../worker/fbs/transport.fbs:51` #[derive( Clone, Debug, @@ -19918,11 +34370,15 @@ mod root { ::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: ::core::option::Option< ::planus::alloc::boxed::Box, >, + /// The field `preferred_layers` in the table `ConsumeResponse` pub preferred_layers: ::core::option::Option< ::planus::alloc::boxed::Box, >, @@ -19941,6 +34397,12 @@ mod root { } 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, @@ -19954,59 +34416,55 @@ mod root { >, ) -> ::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::<10, 10>::new(builder); - - if prepared_paused.is_some() { - table_writer.calculate_size::(2); - } - if prepared_producer_paused.is_some() { - table_writer.calculate_size::(4); - } + let mut table_writer: ::planus::table_writer::TableWriter<12> = + ::core::default::Default::default(); if prepared_score.is_some() { table_writer - .calculate_size::<::planus::Offset>(6); + .write_entry::<::planus::Offset>(2); } if prepared_preferred_layers.is_some() { table_writer - .calculate_size::<::planus::Offset>(8); + .write_entry::<::planus::Offset>(3); } - - table_writer.finish_calculating(); - - unsafe { - if let ::core::option::Option::Some(prepared_score) = prepared_score { - table_writer.write::<_, _, 4>(2, &prepared_score); - } - if let ::core::option::Option::Some(prepared_preferred_layers) = - prepared_preferred_layers - { - table_writer.write::<_, _, 4>(3, &prepared_preferred_layers); - } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - table_writer.write::<_, _, 1>(0, &prepared_paused); - } - if let ::core::option::Option::Some(prepared_producer_paused) = - prepared_producer_paused - { - table_writer.write::<_, _, 1>(1, &prepared_producer_paused); - } + if prepared_paused.is_some() { + table_writer.write_entry::(0); + } + if prepared_producer_paused.is_some() { + table_writer.write_entry::(1); } - table_writer.finish() + unsafe { + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_score) = prepared_score { + 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, @@ -20018,6 +34476,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ConsumeResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -20027,24 +34486,193 @@ mod root { } impl ::planus::WriteAsOffset for ConsumeResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { ConsumeResponse::create( builder, - &self.paused, - &self.producer_paused, + 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::WriteAsOptional<::planus::Offset>, + { + let (v0, v1) = self.0; + ConsumeResponseBuilder((v0, v1, value)) + } + + /// Sets the [`score` field](ConsumeResponse#structfield.score) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn score_as_null(self) -> ConsumeResponseBuilder<(T0, T1, ())> { + self.score(()) + } + } + + 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::WriteAsOptional<::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::WriteAsOptional<::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::WriteAsOptional<::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 @@ -20053,6 +34681,8 @@ mod root { ) } + /// Getter for the [`producer_paused` field](ConsumeResponse#structfield.producer_paused). + #[inline] pub fn producer_paused(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -20061,6 +34691,8 @@ mod root { ) } + /// Getter for the [`score` field](ConsumeResponse#structfield.score). + #[inline] pub fn score( &self, ) -> ::planus::Result<::core::option::Option>> @@ -20068,6 +34700,8 @@ mod root { self.0.access(2, "ConsumeResponse", "score") } + /// Getter for the [`preferred_layers` field](ConsumeResponse#structfield.preferred_layers). + #[inline] pub fn preferred_layers( &self, ) -> ::planus::Result<::core::option::Option>> @@ -20124,6 +34758,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ConsumeResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -20155,6 +34790,7 @@ mod root { 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) } @@ -20191,6 +34827,10 @@ mod root { } } + /// The table `ProduceDataRequest` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `ProduceDataRequest` in the file `../worker/fbs/transport.fbs:58` #[derive( Clone, Debug, @@ -20203,17 +34843,29 @@ mod root { ::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_: ::planus::alloc::string::String, + /// 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, @@ -20231,64 +34883,60 @@ mod root { 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); - 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::<14, 21>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); + 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>(1); if prepared_sctp_stream_parameters.is_some() { - table_writer.calculate_size::<::planus::Offset>(6); + table_writer.write_entry::<::planus::Offset>(2); } if prepared_label.is_some() { - table_writer.calculate_size::<::planus::Offset>(8); + table_writer.write_entry::<::planus::Offset>(3); } if prepared_protocol.is_some() { - table_writer.calculate_size::<::planus::Offset>(10); + table_writer.write_entry::<::planus::Offset>(4); } if prepared_paused.is_some() { - table_writer.calculate_size::(12); + table_writer.write_entry::(5); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_data_producer_id); - table_writer.write::<_, _, 4>(1, &prepared_type_); - if let ::core::option::Option::Some(prepared_sctp_stream_parameters) = - prepared_sctp_stream_parameters - { - table_writer.write::<_, _, 4>(2, &prepared_sctp_stream_parameters); - } - if let ::core::option::Option::Some(prepared_label) = prepared_label { - table_writer.write::<_, _, 4>(3, &prepared_label); - } - if let ::core::option::Option::Some(prepared_protocol) = prepared_protocol { - table_writer.write::<_, _, 4>(4, &prepared_protocol); - } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - table_writer.write::<_, _, 1>(5, &prepared_paused); - } - } - - table_writer.finish() + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_data_producer_id); + object_writer.write::<_, _, 4>(&prepared_type_); + 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_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, @@ -20300,6 +34948,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ProduceDataRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -20309,6 +34958,7 @@ mod root { } impl ::planus::WriteAsOffset for ProduceDataRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -20320,24 +34970,241 @@ mod root { &self.sctp_stream_parameters, &self.label, &self.protocol, - &self.paused, + 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::WriteAs<::planus::Offset>, + { + let (v0,) = self.0; + ProduceDataRequestBuilder((v0, value)) + } + } + + 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::WriteAs<::planus::Offset>, + 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::WriteAs<::planus::Offset>, + 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::WriteAs<::planus::Offset>, + 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<&'a ::core::primitive::str> { self.0.access_required(1, "ProduceDataRequest", "type_") } + /// Getter for the [`sctp_stream_parameters` field](ProduceDataRequest#structfield.sctp_stream_parameters). + #[inline] pub fn sctp_stream_parameters( &self, ) -> ::planus::Result< @@ -20347,6 +35214,8 @@ mod root { .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>> @@ -20354,6 +35223,8 @@ mod root { 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>> @@ -20361,6 +35232,8 @@ mod root { 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 @@ -20433,6 +35306,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ProduceDataRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -20464,6 +35338,7 @@ mod root { 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) } @@ -20500,6 +35375,10 @@ mod root { } } + /// The table `ConsumeDataRequest` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `ConsumeDataRequest` in the file `../worker/fbs/transport.fbs:67` #[derive( Clone, Debug, @@ -20512,18 +35391,31 @@ mod root { ::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_: ::planus::alloc::string::String, + /// 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, } 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, @@ -20542,68 +35434,63 @@ mod root { field_paused: impl ::planus::WriteAsDefault, ) -> ::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); - 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, 25>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); - table_writer.calculate_size::<::planus::Offset>(6); + 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); + table_writer.write_entry::<::planus::Offset>(2); if prepared_sctp_stream_parameters.is_some() { - table_writer.calculate_size::<::planus::Offset>(8); + table_writer.write_entry::<::planus::Offset>(3); } if prepared_label.is_some() { - table_writer.calculate_size::<::planus::Offset>(10); + table_writer.write_entry::<::planus::Offset>(4); } if prepared_protocol.is_some() { - table_writer.calculate_size::<::planus::Offset>(12); + table_writer.write_entry::<::planus::Offset>(5); } if prepared_paused.is_some() { - table_writer.calculate_size::(14); + table_writer.write_entry::(6); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_data_consumer_id); - table_writer.write::<_, _, 4>(1, &prepared_data_producer_id); - table_writer.write::<_, _, 4>(2, &prepared_type_); - if let ::core::option::Option::Some(prepared_sctp_stream_parameters) = - prepared_sctp_stream_parameters - { - table_writer.write::<_, _, 4>(3, &prepared_sctp_stream_parameters); - } - if let ::core::option::Option::Some(prepared_label) = prepared_label { - table_writer.write::<_, _, 4>(4, &prepared_label); - } - if let ::core::option::Option::Some(prepared_protocol) = prepared_protocol { - table_writer.write::<_, _, 4>(5, &prepared_protocol); - } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - table_writer.write::<_, _, 1>(6, &prepared_paused); - } - } - - table_writer.finish() + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_data_consumer_id); + object_writer.write::<_, _, 4>(&prepared_data_producer_id); + object_writer.write::<_, _, 4>(&prepared_type_); + 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_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, @@ -20615,6 +35502,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ConsumeDataRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -20624,6 +35512,7 @@ mod root { } impl ::planus::WriteAsOffset for ConsumeDataRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -20636,29 +35525,266 @@ mod root { &self.sctp_stream_parameters, &self.label, &self.protocol, - &self.paused, + self.paused, ) } } + /// 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::WriteAs<::planus::Offset>, + { + let (v0, v1) = self.0; + ConsumeDataRequestBuilder((v0, v1, value)) + } + } + + 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)> { + /// 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::WriteAs<::planus::Offset>, + T3: ::planus::WriteAsOptional< + ::planus::Offset, + >, + T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T6: ::planus::WriteAsDefault, + > ::planus::WriteAs<::planus::Offset> + for ConsumeDataRequestBuilder<(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::WriteAs<::planus::Offset>, + T3: ::planus::WriteAsOptional< + ::planus::Offset, + >, + T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T6: ::planus::WriteAsDefault, + > ::planus::WriteAsOptional<::planus::Offset> + for ConsumeDataRequestBuilder<(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::WriteAs<::planus::Offset>, + T3: ::planus::WriteAsOptional< + ::planus::Offset, + >, + T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T6: ::planus::WriteAsDefault, + > ::planus::WriteAsOffset + for ConsumeDataRequestBuilder<(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; + ConsumeDataRequest::create(builder, v0, v1, v2, v3, v4, v5, v6) + } + } + + /// 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<&'a ::core::primitive::str> { self.0.access_required(2, "ConsumeDataRequest", "type_") } + /// Getter for the [`sctp_stream_parameters` field](ConsumeDataRequest#structfield.sctp_stream_parameters). + #[inline] pub fn sctp_stream_parameters( &self, ) -> ::planus::Result< @@ -20668,6 +35794,8 @@ mod root { .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>> @@ -20675,6 +35803,8 @@ mod root { 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>> @@ -20682,6 +35812,8 @@ mod root { 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 @@ -20758,6 +35890,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ConsumeDataRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -20789,6 +35922,7 @@ mod root { 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) } @@ -20825,6 +35959,10 @@ mod root { } } + /// The table `Tuple` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `Tuple` in the file `../worker/fbs/transport.fbs:77` #[derive( Clone, Debug, @@ -20837,14 +35975,25 @@ mod root { ::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: ::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: ::planus::alloc::string::String, } 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, @@ -20855,53 +36004,48 @@ mod root { field_protocol: impl ::planus::WriteAs<::planus::Offset>, ) -> ::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); - let mut table_writer = - ::planus::table_writer::TableWriter::<12, 16>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); + 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>(2); + table_writer.write_entry::<::planus::Offset>(4); if prepared_local_port.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(1); } - table_writer.calculate_size::<::planus::Offset>(6); if prepared_remote_port.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(3); } - table_writer.calculate_size::<::planus::Offset>(10); - - table_writer.finish_calculating(); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_local_ip); - table_writer.write::<_, _, 4>(2, &prepared_remote_ip); - table_writer.write::<_, _, 4>(4, &prepared_protocol); - if let ::core::option::Option::Some(prepared_local_port) = - prepared_local_port - { - table_writer.write::<_, _, 2>(1, &prepared_local_port); - } - if let ::core::option::Option::Some(prepared_remote_port) = - prepared_remote_port - { - table_writer.write::<_, _, 2>(3, &prepared_remote_port); - } - } - - table_writer.finish() + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_local_ip); + object_writer.write::<_, _, 4>(&prepared_remote_ip); + object_writer.write::<_, _, 4>(&prepared_protocol); + 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); + } + }); + } + 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) } @@ -20910,6 +36054,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Tuple { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -20919,42 +36064,204 @@ mod root { } 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.local_port, &self.remote_ip, - &self.remote_port, + 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::WriteAs<::planus::Offset>, + { + let (v0, v1) = self.0; + TupleBuilder((v0, v1, value)) + } + } + + 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::WriteAs<::planus::Offset>, + { + let (v0, v1, v2, v3) = self.0; + TupleBuilder((v0, v1, v2, v3, value)) + } + } + + 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::WriteAs<::planus::Offset>, + T3: ::planus::WriteAsDefault, + T4: ::planus::WriteAs<::planus::Offset>, + > ::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::WriteAs<::planus::Offset>, + T3: ::planus::WriteAsDefault, + T4: ::planus::WriteAs<::planus::Offset>, + > ::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::WriteAs<::planus::Offset>, + T3: ::planus::WriteAsDefault, + T4: ::planus::WriteAs<::planus::Offset>, + > ::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<&'a ::core::primitive::str> { self.0.access_required(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<&'a ::core::primitive::str> { self.0.access_required(4, "Tuple", "protocol") } @@ -20988,6 +36295,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for TupleRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -21019,6 +36327,7 @@ mod root { 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) } @@ -21055,6 +36364,10 @@ mod root { } } + /// The table `SrtpParameters` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `SrtpParameters` in the file `../worker/fbs/transport.fbs:85` #[derive( Clone, Debug, @@ -21067,11 +36380,19 @@ mod root { ::serde::Deserialize, )] pub struct SrtpParameters { + /// The field `crypto_suite` in the table `SrtpParameters` pub crypto_suite: ::planus::alloc::string::String, + /// 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, @@ -21079,29 +36400,27 @@ mod root { field_key_base64: impl ::planus::WriteAs<::planus::Offset>, ) -> ::planus::Offset { let prepared_crypto_suite = field_crypto_suite.prepare(builder); - let prepared_key_base64 = field_key_base64.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_crypto_suite); - table_writer.write::<_, _, 4>(1, &prepared_key_base64); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_crypto_suite); + object_writer.write::<_, _, 4>(&prepared_key_base64); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for SrtpParameters { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -21113,6 +36432,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for SrtpParameters { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -21122,6 +36442,7 @@ mod root { } impl ::planus::WriteAsOffset for SrtpParameters { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -21130,14 +36451,114 @@ mod root { } } + /// 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::WriteAs<::planus::Offset>, + { + SrtpParametersBuilder((value,)) + } + } + + 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::WriteAs<::planus::Offset>, + 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::WriteAs<::planus::Offset>, + 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::WriteAs<::planus::Offset>, + 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<&'a ::core::primitive::str> { self.0.access_required(0, "SrtpParameters", "crypto_suite") } + /// 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") } @@ -21165,6 +36586,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SrtpParametersRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -21196,6 +36618,7 @@ mod root { 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) } @@ -21232,6 +36655,10 @@ mod root { } } + /// The table `RtpListener` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `RtpListener` in the file `../worker/fbs/transport.fbs:90` #[derive( Clone, Debug, @@ -21244,12 +36671,21 @@ mod root { ::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, @@ -21264,33 +36700,30 @@ mod root { >, ) -> ::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::<8, 12>::new(builder); - - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(6); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_ssrc_table); - table_writer.write::<_, _, 4>(1, &prepared_mid_table); - table_writer.write::<_, _, 4>(2, &prepared_rid_table); + 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); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for RtpListener { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -21302,6 +36735,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for RtpListener { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -21311,6 +36745,7 @@ mod root { } impl ::planus::WriteAsOffset for RtpListener { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -21319,10 +36754,148 @@ mod root { } } + /// 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< @@ -21331,6 +36904,8 @@ mod root { 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< @@ -21339,6 +36914,8 @@ mod root { 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< @@ -21372,6 +36949,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RtpListenerRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -21403,6 +36981,7 @@ mod root { 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) } @@ -21439,6 +37018,10 @@ mod root { } } + /// The table `SctpListener` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `SctpListener` in the file `../worker/fbs/transport.fbs:96` #[derive( Clone, Debug, @@ -21451,10 +37034,17 @@ mod root { ::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, @@ -21464,24 +37054,23 @@ mod root { ) -> ::planus::Offset { let prepared_stream_id_table = field_stream_id_table.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_stream_id_table); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_stream_id_table); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for SctpListener { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -21493,6 +37082,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for SctpListener { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -21502,6 +37092,7 @@ mod root { } impl ::planus::WriteAsOffset for SctpListener { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -21510,10 +37101,99 @@ mod root { } } + /// 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< @@ -21543,6 +37223,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SctpListenerRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -21574,6 +37255,7 @@ mod root { 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) } @@ -21610,6 +37292,10 @@ mod root { } } + /// The table `RecvRtpHeaderExtensions` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `RecvRtpHeaderExtensions` in the file `../worker/fbs/transport.fbs:100` #[derive( Clone, Debug, @@ -21622,10 +37308,15 @@ mod root { ::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, } @@ -21643,6 +37334,12 @@ mod root { } 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, @@ -21653,65 +37350,60 @@ mod root { 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::<12, 5>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<14> = + ::core::default::Default::default(); if prepared_mid.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } if prepared_rid.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(1); } if prepared_rrid.is_some() { - table_writer.calculate_size::(6); + table_writer.write_entry::(2); } if prepared_abs_send_time.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(3); } if prepared_transport_wide_cc01.is_some() { - table_writer.calculate_size::(10); + table_writer.write_entry::(4); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_mid) = prepared_mid { - table_writer.write::<_, _, 1>(0, &prepared_mid); - } - if let ::core::option::Option::Some(prepared_rid) = prepared_rid { - table_writer.write::<_, _, 1>(1, &prepared_rid); - } - if let ::core::option::Option::Some(prepared_rrid) = prepared_rrid { - table_writer.write::<_, _, 1>(2, &prepared_rrid); - } - if let ::core::option::Option::Some(prepared_abs_send_time) = - prepared_abs_send_time - { - table_writer.write::<_, _, 1>(3, &prepared_abs_send_time); - } - if let ::core::option::Option::Some(prepared_transport_wide_cc01) = - prepared_transport_wide_cc01 - { - table_writer.write::<_, _, 1>(4, &prepared_transport_wide_cc01); - } - } - - table_writer.finish() + 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, @@ -21725,6 +37417,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -21735,41 +37428,243 @@ mod root { } 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, + 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") @@ -21847,6 +37742,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RecvRtpHeaderExtensionsRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -21878,6 +37774,7 @@ mod root { 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) } @@ -21918,6 +37815,10 @@ mod root { } } + /// The table `Options` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `Options` in the file `../worker/fbs/transport.fbs:108` #[derive( Clone, Debug, @@ -21930,15 +37831,23 @@ mod root { ::serde::Deserialize, )] pub struct Options { + /// The field `direct` in the table `Options` pub direct: bool, + /// The field `max_message_size` in the table `Options` pub max_message_size: u32, + /// The field `initial_available_outgoing_bitrate` in the table `Options` pub initial_available_outgoing_bitrate: u32, + /// 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, } @@ -21959,6 +37868,12 @@ mod root { } 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, @@ -21974,104 +37889,96 @@ mod root { 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, &0); - let prepared_initial_available_outgoing_bitrate = field_initial_available_outgoing_bitrate.prepare(builder, &0); - 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::<18, 23>::new(builder); - - if prepared_direct.is_some() { - table_writer.calculate_size::(2); - } + let mut table_writer: ::planus::table_writer::TableWriter<20> = + ::core::default::Default::default(); if prepared_max_message_size.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(1); } if prepared_initial_available_outgoing_bitrate.is_some() { - table_writer.calculate_size::(6); - } - if prepared_enable_sctp.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(2); } if prepared_num_sctp_streams.is_some() { - table_writer.calculate_size::<::planus::Offset>(10); + table_writer.write_entry::<::planus::Offset>(4); } if prepared_max_sctp_message_size.is_some() { - table_writer.calculate_size::(12); + table_writer.write_entry::(5); } if prepared_sctp_send_buffer_size.is_some() { - table_writer.calculate_size::(14); + 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.calculate_size::(16); + table_writer.write_entry::(7); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_max_message_size) = - prepared_max_message_size - { - table_writer.write::<_, _, 4>(1, &prepared_max_message_size); - } - if let ::core::option::Option::Some( - prepared_initial_available_outgoing_bitrate, - ) = prepared_initial_available_outgoing_bitrate - { - table_writer - .write::<_, _, 4>(2, &prepared_initial_available_outgoing_bitrate); - } - if let ::core::option::Option::Some(prepared_num_sctp_streams) = - prepared_num_sctp_streams - { - table_writer.write::<_, _, 4>(4, &prepared_num_sctp_streams); - } - if let ::core::option::Option::Some(prepared_max_sctp_message_size) = - prepared_max_sctp_message_size - { - table_writer.write::<_, _, 4>(5, &prepared_max_sctp_message_size); - } - if let ::core::option::Option::Some(prepared_sctp_send_buffer_size) = - prepared_sctp_send_buffer_size - { - table_writer.write::<_, _, 4>(6, &prepared_sctp_send_buffer_size); - } - if let ::core::option::Option::Some(prepared_direct) = prepared_direct { - table_writer.write::<_, _, 1>(0, &prepared_direct); - } - if let ::core::option::Option::Some(prepared_enable_sctp) = - prepared_enable_sctp - { - table_writer.write::<_, _, 1>(3, &prepared_enable_sctp); - } - if let ::core::option::Option::Some(prepared_is_data_channel) = - prepared_is_data_channel - { - table_writer.write::<_, _, 1>(7, &prepared_is_data_channel); - } - } - - table_writer.finish() + 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) } @@ -22080,6 +37987,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Options { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -22089,31 +37997,310 @@ mod root { } 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.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, + 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::WriteAsDefault, + { + let (v0,) = self.0; + OptionsBuilder((v0, value)) + } + + /// Sets the [`max_message_size` field](Options#structfield.max_message_size) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn max_message_size_as_default( + self, + ) -> OptionsBuilder<(T0, ::planus::DefaultValue)> { + self.max_message_size(::planus::DefaultValue) + } + } + + 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::WriteAsDefault, + { + let (v0, v1) = self.0; + OptionsBuilder((v0, v1, value)) + } + + /// Sets the [`initial_available_outgoing_bitrate` field](Options#structfield.initial_available_outgoing_bitrate) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn initial_available_outgoing_bitrate_as_default( + self, + ) -> OptionsBuilder<(T0, T1, ::planus::DefaultValue)> { + self.initial_available_outgoing_bitrate(::planus::DefaultValue) + } + } + + 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::WriteAsDefault, + T2: ::planus::WriteAsDefault, + 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::WriteAsDefault, + T2: ::planus::WriteAsDefault, + 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::WriteAsDefault, + T2: ::planus::WriteAsDefault, + 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::result::Result::Ok( self.0 @@ -22122,6 +38309,8 @@ mod root { ) } + /// 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::result::Result::Ok( self.0 @@ -22130,12 +38319,16 @@ mod root { ) } + /// 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< @@ -22144,6 +38337,8 @@ mod root { 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 @@ -22152,6 +38347,8 @@ mod root { ) } + /// 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 @@ -22160,6 +38357,8 @@ mod root { ) } + /// 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 @@ -22228,6 +38427,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for OptionsRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -22259,6 +38459,7 @@ mod root { 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) } @@ -22295,6 +38496,10 @@ mod root { } } + /// The table `Dump` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `Dump` in the file `../worker/fbs/transport.fbs:119` #[derive( Clone, Debug, @@ -22307,29 +38512,50 @@ mod root { ::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<::planus::alloc::string::String>, } 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, @@ -22370,112 +38596,96 @@ mod root { >, ) -> ::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::<32, 54>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - if prepared_direct.is_some() { - table_writer.calculate_size::(4); - } - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(6); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(8); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(10); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(12); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(14); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(16); - table_writer - .calculate_size::<::planus::Offset>(18); - table_writer.calculate_size::<::planus::Offset>(20); + 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.calculate_size::(22); + table_writer.write_entry::(10); } if prepared_sctp_parameters.is_some() { - table_writer.calculate_size::<::planus::Offset>(24); - } - if prepared_sctp_state.is_some() { - table_writer.calculate_size::(26); + table_writer.write_entry::<::planus::Offset>(11); } if prepared_sctp_listener.is_some() { - table_writer.calculate_size::<::planus::Offset>(28); + table_writer.write_entry::<::planus::Offset>(13); } - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(30); - - table_writer.finish_calculating(); - - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_id); - table_writer.write::<_, _, 4>(2, &prepared_producer_ids); - table_writer.write::<_, _, 4>(3, &prepared_consumer_ids); - table_writer.write::<_, _, 4>(4, &prepared_map_ssrc_consumer_id); - table_writer.write::<_, _, 4>(5, &prepared_map_rtx_ssrc_consumer_id); - table_writer.write::<_, _, 4>(6, &prepared_data_producer_ids); - table_writer.write::<_, _, 4>(7, &prepared_data_consumer_ids); - table_writer.write::<_, _, 4>(8, &prepared_recv_rtp_header_extensions); - table_writer.write::<_, _, 4>(9, &prepared_rtp_listener); - if let ::core::option::Option::Some(prepared_max_message_size) = - prepared_max_message_size - { - table_writer.write::<_, _, 4>(10, &prepared_max_message_size); - } - if let ::core::option::Option::Some(prepared_sctp_parameters) = - prepared_sctp_parameters - { - table_writer.write::<_, _, 4>(11, &prepared_sctp_parameters); - } - if let ::core::option::Option::Some(prepared_sctp_listener) = - prepared_sctp_listener - { - table_writer.write::<_, _, 4>(13, &prepared_sctp_listener); - } - table_writer.write::<_, _, 4>(14, &prepared_trace_event_types); - if let ::core::option::Option::Some(prepared_direct) = prepared_direct { - table_writer.write::<_, _, 1>(1, &prepared_direct); - } - if let ::core::option::Option::Some(prepared_sctp_state) = - prepared_sctp_state - { - table_writer.write::<_, _, 1>(12, &prepared_sctp_state); - } + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(14); + if prepared_direct.is_some() { + table_writer.write_entry::(1); + } + if prepared_sctp_state.is_some() { + table_writer.write_entry::(12); } - table_writer.finish() + 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) } @@ -22484,6 +38694,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Dump { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -22493,11 +38704,12 @@ mod root { } impl ::planus::WriteAsOffset for Dump { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { Dump::create( builder, &self.id, - &self.direct, + self.direct, &self.producer_ids, &self.consumer_ids, &self.map_ssrc_consumer_id, @@ -22506,27 +38718,538 @@ mod root { &self.data_consumer_ids, &self.recv_rtp_header_extensions, &self.rtp_listener, - &self.max_message_size, + self.max_message_size, &self.sctp_parameters, - &self.sctp_state, + 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<[::planus::Offset]>>, + { + 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<[::planus::Offset]>>, + > ::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<[::planus::Offset]>>, + > ::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<[::planus::Offset]>>, + > ::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< @@ -22535,6 +39258,8 @@ mod root { 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< @@ -22543,6 +39268,8 @@ mod root { 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< @@ -22551,6 +39278,8 @@ mod root { 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< @@ -22560,6 +39289,8 @@ mod root { .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< @@ -22568,6 +39299,8 @@ mod root { 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< @@ -22576,6 +39309,8 @@ mod root { 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> { @@ -22583,16 +39318,22 @@ mod root { .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< @@ -22601,6 +39342,8 @@ mod root { 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> @@ -22608,6 +39351,8 @@ mod root { 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>> @@ -22615,6 +39360,8 @@ mod root { 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< @@ -22721,6 +39468,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DumpRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -22748,6 +39496,7 @@ mod root { 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) } @@ -22784,37 +39533,71 @@ mod root { } } + /// The table `Stats` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `Stats` in the file `../worker/fbs/transport.fbs:137` #[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: u32, + /// The field `max_outgoing_bitrate` in the table `Stats` pub max_outgoing_bitrate: u32, + /// The field `min_outgoing_bitrate` in the table `Stats` pub min_outgoing_bitrate: u32, + /// 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, @@ -22844,262 +39627,243 @@ mod root { 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, &0); - let prepared_max_outgoing_bitrate = field_max_outgoing_bitrate.prepare(builder, &0); - let prepared_min_outgoing_bitrate = field_min_outgoing_bitrate.prepare(builder, &0); - 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::<50, 133>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); + let mut table_writer: ::planus::table_writer::TableWriter<52> = + ::core::default::Default::default(); if prepared_timestamp.is_some() { - table_writer.calculate_size::(4); - } - if prepared_sctp_state.is_some() { - table_writer.calculate_size::(6); + table_writer.write_entry::(1); } if prepared_bytes_received.is_some() { - table_writer.calculate_size::(8); - } - if prepared_recv_bitrate.is_some() { - table_writer.calculate_size::(10); + table_writer.write_entry::(3); } if prepared_bytes_sent.is_some() { - table_writer.calculate_size::(12); - } - if prepared_send_bitrate.is_some() { - table_writer.calculate_size::(14); + table_writer.write_entry::(5); } if prepared_rtp_bytes_received.is_some() { - table_writer.calculate_size::(16); - } - if prepared_rtp_recv_bitrate.is_some() { - table_writer.calculate_size::(18); + table_writer.write_entry::(7); } if prepared_rtp_bytes_sent.is_some() { - table_writer.calculate_size::(20); - } - if prepared_rtp_send_bitrate.is_some() { - table_writer.calculate_size::(22); + table_writer.write_entry::(9); } if prepared_rtx_bytes_received.is_some() { - table_writer.calculate_size::(24); - } - if prepared_rtx_recv_bitrate.is_some() { - table_writer.calculate_size::(26); + table_writer.write_entry::(11); } if prepared_rtx_bytes_sent.is_some() { - table_writer.calculate_size::(28); - } - if prepared_rtx_send_bitrate.is_some() { - table_writer.calculate_size::(30); + table_writer.write_entry::(13); } if prepared_probation_bytes_sent.is_some() { - table_writer.calculate_size::(32); + 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.calculate_size::(34); + table_writer.write_entry::(16); } if prepared_available_outgoing_bitrate.is_some() { - table_writer.calculate_size::(36); + table_writer.write_entry::(17); } if prepared_available_incoming_bitrate.is_some() { - table_writer.calculate_size::(38); + table_writer.write_entry::(18); } if prepared_max_incoming_bitrate.is_some() { - table_writer.calculate_size::(40); + table_writer.write_entry::(19); } if prepared_max_outgoing_bitrate.is_some() { - table_writer.calculate_size::(42); + table_writer.write_entry::(20); } if prepared_min_outgoing_bitrate.is_some() { - table_writer.calculate_size::(44); - } - if prepared_rtp_packet_loss_received.is_some() { - table_writer.calculate_size::(46); + table_writer.write_entry::(21); } - if prepared_rtp_packet_loss_sent.is_some() { - table_writer.calculate_size::(48); + if prepared_sctp_state.is_some() { + table_writer.write_entry::(2); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_timestamp) = prepared_timestamp - { - table_writer.write::<_, _, 8>(1, &prepared_timestamp); - } - if let ::core::option::Option::Some(prepared_bytes_received) = - prepared_bytes_received - { - table_writer.write::<_, _, 8>(3, &prepared_bytes_received); - } - if let ::core::option::Option::Some(prepared_bytes_sent) = - prepared_bytes_sent - { - table_writer.write::<_, _, 8>(5, &prepared_bytes_sent); - } - if let ::core::option::Option::Some(prepared_rtp_bytes_received) = - prepared_rtp_bytes_received - { - table_writer.write::<_, _, 8>(7, &prepared_rtp_bytes_received); - } - if let ::core::option::Option::Some(prepared_rtp_bytes_sent) = - prepared_rtp_bytes_sent - { - table_writer.write::<_, _, 8>(9, &prepared_rtp_bytes_sent); - } - if let ::core::option::Option::Some(prepared_rtx_bytes_received) = - prepared_rtx_bytes_received - { - table_writer.write::<_, _, 8>(11, &prepared_rtx_bytes_received); - } - if let ::core::option::Option::Some(prepared_rtx_bytes_sent) = - prepared_rtx_bytes_sent - { - table_writer.write::<_, _, 8>(13, &prepared_rtx_bytes_sent); - } - if let ::core::option::Option::Some(prepared_probation_bytes_sent) = - prepared_probation_bytes_sent - { - table_writer.write::<_, _, 8>(15, &prepared_probation_bytes_sent); - } - if let ::core::option::Option::Some(prepared_rtp_packet_loss_received) = - prepared_rtp_packet_loss_received - { - table_writer.write::<_, _, 8>(22, &prepared_rtp_packet_loss_received); - } - if let ::core::option::Option::Some(prepared_rtp_packet_loss_sent) = - prepared_rtp_packet_loss_sent - { - table_writer.write::<_, _, 8>(23, &prepared_rtp_packet_loss_sent); - } - table_writer.write::<_, _, 4>(0, &prepared_transport_id); - if let ::core::option::Option::Some(prepared_recv_bitrate) = - prepared_recv_bitrate - { - table_writer.write::<_, _, 4>(4, &prepared_recv_bitrate); - } - if let ::core::option::Option::Some(prepared_send_bitrate) = - prepared_send_bitrate - { - table_writer.write::<_, _, 4>(6, &prepared_send_bitrate); - } - if let ::core::option::Option::Some(prepared_rtp_recv_bitrate) = - prepared_rtp_recv_bitrate - { - table_writer.write::<_, _, 4>(8, &prepared_rtp_recv_bitrate); - } - if let ::core::option::Option::Some(prepared_rtp_send_bitrate) = - prepared_rtp_send_bitrate - { - table_writer.write::<_, _, 4>(10, &prepared_rtp_send_bitrate); - } - if let ::core::option::Option::Some(prepared_rtx_recv_bitrate) = - prepared_rtx_recv_bitrate - { - table_writer.write::<_, _, 4>(12, &prepared_rtx_recv_bitrate); - } - if let ::core::option::Option::Some(prepared_rtx_send_bitrate) = - prepared_rtx_send_bitrate - { - table_writer.write::<_, _, 4>(14, &prepared_rtx_send_bitrate); - } - if let ::core::option::Option::Some(prepared_probation_send_bitrate) = - prepared_probation_send_bitrate - { - table_writer.write::<_, _, 4>(16, &prepared_probation_send_bitrate); - } - if let ::core::option::Option::Some(prepared_available_outgoing_bitrate) = - prepared_available_outgoing_bitrate - { - table_writer.write::<_, _, 4>(17, &prepared_available_outgoing_bitrate); - } - if let ::core::option::Option::Some(prepared_available_incoming_bitrate) = - prepared_available_incoming_bitrate - { - table_writer.write::<_, _, 4>(18, &prepared_available_incoming_bitrate); - } - if let ::core::option::Option::Some(prepared_max_incoming_bitrate) = - prepared_max_incoming_bitrate - { - table_writer.write::<_, _, 4>(19, &prepared_max_incoming_bitrate); - } - if let ::core::option::Option::Some(prepared_max_outgoing_bitrate) = - prepared_max_outgoing_bitrate - { - table_writer.write::<_, _, 4>(20, &prepared_max_outgoing_bitrate); - } - if let ::core::option::Option::Some(prepared_min_outgoing_bitrate) = - prepared_min_outgoing_bitrate - { - table_writer.write::<_, _, 4>(21, &prepared_min_outgoing_bitrate); - } - if let ::core::option::Option::Some(prepared_sctp_state) = - prepared_sctp_state - { - table_writer.write::<_, _, 1>(2, &prepared_sctp_state); - } - } - - table_writer.finish() + 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) } @@ -23108,6 +39872,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Stats { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -23117,210 +39882,2074 @@ mod root { } 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, + 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, ) } } - #[derive(Copy, Clone)] - pub struct StatsRef<'a>(::planus::table_reader::Table<'a>); + /// 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<'a> StatsRef<'a> { - pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "Stats", "transport_id") + 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,)) } + } - pub fn timestamp(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(1, "Stats", "timestamp")?.unwrap_or(0)) + 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)) } - pub fn sctp_state( - &self, - ) -> ::planus::Result<::core::option::Option> + /// 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, { - self.0.access(2, "Stats", "sctp_state") + let (v0, v1) = self.0; + StatsBuilder((v0, v1, value)) } - pub fn bytes_received(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(3, "Stats", "bytes_received")?.unwrap_or(0), - ) + /// 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(()) } + } - pub fn recv_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(4, "Stats", "recv_bitrate")?.unwrap_or(0), - ) + 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)) } - pub fn bytes_sent(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(5, "Stats", "bytes_sent")?.unwrap_or(0), - ) + /// 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) } + } - pub fn send_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(6, "Stats", "send_bitrate")?.unwrap_or(0), - ) + 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)) } - pub fn rtp_bytes_received(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(7, "Stats", "rtp_bytes_received")? - .unwrap_or(0), - ) + /// 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) } + } - pub fn rtp_recv_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(8, "Stats", "rtp_recv_bitrate")?.unwrap_or(0), - ) + 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)) } - pub fn rtp_bytes_sent(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(9, "Stats", "rtp_bytes_sent")?.unwrap_or(0), - ) + /// 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) } + } - pub fn rtp_send_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(10, "Stats", "rtp_send_bitrate")?.unwrap_or(0), - ) + 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)) } - pub fn rtx_bytes_received(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(11, "Stats", "rtx_bytes_received")? - .unwrap_or(0), - ) + /// 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) } + } - pub fn rtx_recv_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(12, "Stats", "rtx_recv_bitrate")?.unwrap_or(0), - ) + 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)) } - pub fn rtx_bytes_sent(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(13, "Stats", "rtx_bytes_sent")?.unwrap_or(0), - ) + /// 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) } + } - pub fn rtx_send_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(14, "Stats", "rtx_send_bitrate")?.unwrap_or(0), - ) + 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)) } - pub fn probation_bytes_sent(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(15, "Stats", "probation_bytes_sent")? - .unwrap_or(0), - ) + /// 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) } + } - pub fn probation_send_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(16, "Stats", "probation_send_bitrate")? - .unwrap_or(0), - ) + 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)) } - pub fn available_outgoing_bitrate( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(17, "Stats", "available_outgoing_bitrate") + /// 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) } + } - pub fn available_incoming_bitrate( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(18, "Stats", "available_incoming_bitrate") + 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)) } - pub fn max_incoming_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(19, "Stats", "max_incoming_bitrate")? - .unwrap_or(0), - ) + /// 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)) } - pub fn max_outgoing_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(20, "Stats", "max_outgoing_bitrate")? - .unwrap_or(0), - ) + /// 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)) } - pub fn min_outgoing_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(21, "Stats", "min_outgoing_bitrate")? - .unwrap_or(0), - ) + /// 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)) } - pub fn rtp_packet_loss_received( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(22, "Stats", "rtp_packet_loss_received") + /// 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, + )) } - pub fn rtp_packet_loss_sent( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0.access(23, "Stats", "rtp_packet_loss_sent") + /// 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, + )) } - } - 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()); + /// 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::WriteAsDefault, + { + 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 the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn max_incoming_bitrate_as_default( + self, + ) -> StatsBuilder<( + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + ::planus::DefaultValue, + )> { + self.max_incoming_bitrate(::planus::DefaultValue) + } + } + + 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::WriteAsDefault, + { + 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 the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn max_outgoing_bitrate_as_default( + self, + ) -> StatsBuilder<( + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + ::planus::DefaultValue, + )> { + self.max_outgoing_bitrate(::planus::DefaultValue) + } + } + + 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::WriteAsDefault, + { + 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 the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn min_outgoing_bitrate_as_default( + self, + ) -> StatsBuilder<( + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + ::planus::DefaultValue, + )> { + self.min_outgoing_bitrate(::planus::DefaultValue) + } + } + + 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::WriteAsDefault, + T20: ::planus::WriteAsDefault, + T21: ::planus::WriteAsDefault, + 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::WriteAsDefault, + T20: ::planus::WriteAsDefault, + T21: ::planus::WriteAsDefault, + 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::WriteAsDefault, + T20: ::planus::WriteAsDefault, + T21: ::planus::WriteAsDefault, + 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::result::Result::Ok( + self.0 + .access(19, "Stats", "max_incoming_bitrate")? + .unwrap_or(0), + ) + } + + /// Getter for the [`max_outgoing_bitrate` field](Stats#structfield.max_outgoing_bitrate). + #[inline] + pub fn max_outgoing_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(20, "Stats", "max_outgoing_bitrate")? + .unwrap_or(0), + ) + } + + /// Getter for the [`min_outgoing_bitrate` field](Stats#structfield.min_outgoing_bitrate). + #[inline] + pub fn min_outgoing_bitrate(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(21, "Stats", "min_outgoing_bitrate")? + .unwrap_or(0), + ) + } + + /// 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()); @@ -23472,6 +42101,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for StatsRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -23503,6 +42133,7 @@ mod root { 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) } @@ -23539,6 +42170,10 @@ mod root { } } + /// The table `SetMaxIncomingBitrateRequest` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `SetMaxIncomingBitrateRequest` in the file `../worker/fbs/transport.fbs:164` #[derive( Clone, Debug, @@ -23551,6 +42186,7 @@ mod root { ::serde::Deserialize, )] pub struct SetMaxIncomingBitrateRequest { + /// The field `max_incoming_bitrate` in the table `SetMaxIncomingBitrateRequest` pub max_incoming_bitrate: u32, } @@ -23564,6 +42200,12 @@ mod root { } 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, @@ -23572,24 +42214,22 @@ mod root { let prepared_max_incoming_bitrate = field_max_incoming_bitrate.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_max_incoming_bitrate.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_max_incoming_bitrate) = - prepared_max_incoming_bitrate - { - table_writer.write::<_, _, 4>(0, &prepared_max_incoming_bitrate); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } @@ -23598,6 +42238,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -23611,6 +42252,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -23621,18 +42263,113 @@ mod root { } 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 { - SetMaxIncomingBitrateRequest::create(builder, &self.max_incoming_bitrate) + 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 @@ -23666,6 +42403,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SetMaxIncomingBitrateRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -23699,6 +42437,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -23739,6 +42478,10 @@ mod root { } } + /// The table `SetMaxOutgoingBitrateRequest` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `SetMaxOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:168` #[derive( Clone, Debug, @@ -23751,6 +42494,7 @@ mod root { ::serde::Deserialize, )] pub struct SetMaxOutgoingBitrateRequest { + /// The field `max_outgoing_bitrate` in the table `SetMaxOutgoingBitrateRequest` pub max_outgoing_bitrate: u32, } @@ -23764,6 +42508,12 @@ mod root { } 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, @@ -23772,24 +42522,22 @@ mod root { let prepared_max_outgoing_bitrate = field_max_outgoing_bitrate.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_max_outgoing_bitrate.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_max_outgoing_bitrate) = - prepared_max_outgoing_bitrate - { - table_writer.write::<_, _, 4>(0, &prepared_max_outgoing_bitrate); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } @@ -23798,6 +42546,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -23811,6 +42560,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -23821,18 +42571,113 @@ mod root { } 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 { - SetMaxOutgoingBitrateRequest::create(builder, &self.max_outgoing_bitrate) + 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 @@ -23866,6 +42711,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SetMaxOutgoingBitrateRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -23899,6 +42745,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -23939,6 +42786,10 @@ mod root { } } + /// The table `SetMinOutgoingBitrateRequest` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `SetMinOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:172` #[derive( Clone, Debug, @@ -23951,6 +42802,7 @@ mod root { ::serde::Deserialize, )] pub struct SetMinOutgoingBitrateRequest { + /// The field `min_outgoing_bitrate` in the table `SetMinOutgoingBitrateRequest` pub min_outgoing_bitrate: u32, } @@ -23964,6 +42816,12 @@ mod root { } 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, @@ -23972,24 +42830,22 @@ mod root { let prepared_min_outgoing_bitrate = field_min_outgoing_bitrate.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_min_outgoing_bitrate.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_min_outgoing_bitrate) = - prepared_min_outgoing_bitrate - { - table_writer.write::<_, _, 4>(0, &prepared_min_outgoing_bitrate); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } @@ -23998,6 +42854,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24011,6 +42868,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24021,18 +42879,113 @@ mod root { } 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 { - SetMinOutgoingBitrateRequest::create(builder, &self.min_outgoing_bitrate) + 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 @@ -24066,6 +43019,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SetMinOutgoingBitrateRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -24099,6 +43053,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -24139,6 +43094,10 @@ mod root { } } + /// The table `EnableTraceEventRequest` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/transport.fbs:176` #[derive( Clone, Debug, @@ -24151,10 +43110,17 @@ mod root { ::serde::Deserialize, )] pub struct EnableTraceEventRequest { + /// The field `events` in the table `EnableTraceEventRequest` pub events: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, } 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, @@ -24162,24 +43128,23 @@ mod root { ) -> ::planus::Offset { let prepared_events = field_events.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_events); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_events); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for EnableTraceEventRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24193,6 +43158,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24203,6 +43169,7 @@ mod root { } impl ::planus::WriteAsOffset for EnableTraceEventRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24211,10 +43178,91 @@ mod root { } } + /// 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<[::planus::Offset]>>, + { + 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< @@ -24245,6 +43293,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for EnableTraceEventRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -24276,6 +43325,7 @@ mod root { 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) } @@ -24316,6 +43366,10 @@ mod root { } } + /// The table `CloseProducerRequest` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `CloseProducerRequest` in the file `../worker/fbs/transport.fbs:180` #[derive( Clone, Debug, @@ -24328,10 +43382,17 @@ mod root { ::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, @@ -24339,24 +43400,23 @@ mod root { ) -> ::planus::Offset { let prepared_producer_id = field_producer_id.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_producer_id); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_producer_id); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for CloseProducerRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24368,6 +43428,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for CloseProducerRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24378,6 +43439,7 @@ mod root { } impl ::planus::WriteAsOffset for CloseProducerRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24386,10 +43448,91 @@ mod root { } } + /// 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") @@ -24416,6 +43559,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CloseProducerRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -24447,6 +43591,7 @@ mod root { 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) } @@ -24487,6 +43632,10 @@ mod root { } } + /// The table `CloseConsumerRequest` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `CloseConsumerRequest` in the file `../worker/fbs/transport.fbs:184` #[derive( Clone, Debug, @@ -24499,10 +43648,17 @@ mod root { ::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, @@ -24510,24 +43666,23 @@ mod root { ) -> ::planus::Offset { let prepared_consumer_id = field_consumer_id.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_consumer_id); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_consumer_id); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for CloseConsumerRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24539,6 +43694,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for CloseConsumerRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24549,6 +43705,7 @@ mod root { } impl ::planus::WriteAsOffset for CloseConsumerRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24557,10 +43714,91 @@ mod root { } } + /// 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") @@ -24587,6 +43825,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CloseConsumerRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -24618,6 +43857,7 @@ mod root { 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) } @@ -24658,6 +43898,10 @@ mod root { } } + /// The table `CloseDataProducerRequest` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `CloseDataProducerRequest` in the file `../worker/fbs/transport.fbs:188` #[derive( Clone, Debug, @@ -24670,10 +43914,17 @@ mod root { ::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, @@ -24681,24 +43932,23 @@ mod root { ) -> ::planus::Offset { let prepared_data_producer_id = field_data_producer_id.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_data_producer_id); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_data_producer_id); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for CloseDataProducerRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24712,6 +43962,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24722,6 +43973,7 @@ mod root { } impl ::planus::WriteAsOffset for CloseDataProducerRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24730,10 +43982,94 @@ mod root { } } + /// 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") @@ -24762,6 +44098,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CloseDataProducerRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -24795,6 +44132,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -24835,6 +44173,10 @@ mod root { } } + /// The table `CloseDataConsumerRequest` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `CloseDataConsumerRequest` in the file `../worker/fbs/transport.fbs:192` #[derive( Clone, Debug, @@ -24847,10 +44189,17 @@ mod root { ::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, @@ -24858,24 +44207,23 @@ mod root { ) -> ::planus::Offset { let prepared_data_consumer_id = field_data_consumer_id.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_data_consumer_id); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_data_consumer_id); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for CloseDataConsumerRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24889,6 +44237,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24899,6 +44248,7 @@ mod root { } impl ::planus::WriteAsOffset for CloseDataConsumerRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -24907,10 +44257,94 @@ mod root { } } + /// 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") @@ -24939,6 +44373,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CloseDataConsumerRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -24972,6 +44407,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -25012,6 +44448,10 @@ mod root { } } + /// The table `SendRtcpNotification` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `SendRtcpNotification` in the file `../worker/fbs/transport.fbs:198` #[derive( Clone, Debug, @@ -25024,10 +44464,17 @@ mod root { ::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, @@ -25035,24 +44482,23 @@ mod root { ) -> ::planus::Offset { let prepared_data = field_data.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset<[u8]>>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset<[u8]>>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_data); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_data); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for SendRtcpNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -25064,6 +44510,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for SendRtcpNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -25074,6 +44521,7 @@ mod root { } impl ::planus::WriteAsOffset for SendRtcpNotification { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -25082,11 +44530,92 @@ mod root { } } + /// 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> { - pub fn data(&self) -> ::planus::Result<::planus::Vector<'a, u8>> { + /// Getter for the [`data` field](SendRtcpNotification#structfield.data). + #[inline] + pub fn data(&self) -> ::planus::Result<&'a [u8]> { self.0.access_required(0, "SendRtcpNotification", "data") } } @@ -25105,12 +44634,13 @@ mod root { #[allow(unreachable_code)] fn try_from(value: SendRtcpNotificationRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - data: value.data()?.to_vec()?, + data: value.data()?.to_vec(), }) } } impl<'a> ::planus::TableRead<'a> for SendRtcpNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -25142,6 +44672,7 @@ mod root { 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) } @@ -25182,6 +44713,10 @@ mod root { } } + /// The table `SctpStateChangeNotification` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `SctpStateChangeNotification` in the file `../worker/fbs/transport.fbs:204` #[derive( Clone, Debug, @@ -25194,6 +44729,7 @@ mod root { ::serde::Deserialize, )] pub struct SctpStateChangeNotification { + /// The field `sctp_state` in the table `SctpStateChangeNotification` pub sctp_state: super::sctp_association::SctpState, } @@ -25207,6 +44743,12 @@ mod root { } 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, @@ -25218,24 +44760,22 @@ mod root { let prepared_sctp_state = field_sctp_state.prepare(builder, &super::sctp_association::SctpState::New); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 1>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_sctp_state.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_sctp_state) = - prepared_sctp_state - { - table_writer.write::<_, _, 1>(0, &prepared_sctp_state); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } @@ -25244,6 +44784,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -25257,6 +44798,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -25267,18 +44809,125 @@ mod root { } 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 { - SctpStateChangeNotification::create(builder, &self.sctp_state) + 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 @@ -25310,6 +44959,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for SctpStateChangeNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -25343,6 +44993,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -25383,6 +45034,10 @@ mod root { } } + /// The enum `TraceType` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Enum `TraceType` in the file `../worker/fbs/transport.fbs:208` #[derive( Copy, Clone, @@ -25397,12 +45052,21 @@ mod root { )] #[repr(u8)] pub enum TraceType { + /// The variant `PROBATION` in the enum `TraceType` Probation = 0, + + /// The variant `BWE` in the enum `TraceType` Bwe = 1, } + impl TraceType { + /// Array containing all valid variants of TraceType + pub const ENUM_VALUES: [Self; 2] = [Self::Probation, Self::Bwe]; + } + impl ::core::convert::TryFrom for TraceType { type Error = ::planus::errors::UnknownEnumTagKind; + #[inline] fn try_from( value: u8, ) -> ::core::result::Result @@ -25420,6 +45084,7 @@ mod root { } impl ::core::convert::From for u8 { + #[inline] fn from(value: TraceType) -> Self { value as u8 } @@ -25480,6 +45145,7 @@ mod root { } impl<'buf> ::planus::TableRead<'buf> for TraceType { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, @@ -25498,7 +45164,7 @@ mod root { offset: usize, ) -> ::core::result::Result { - let value = ::from_buffer(buffer, offset); + let value = *buffer.buffer.get_unchecked(offset); let value: ::core::result::Result = ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { @@ -25516,6 +45182,7 @@ mod root { type Value = Self; + #[inline] fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { *self } @@ -25537,6 +45204,10 @@ mod root { } } + /// The enum `TraceDirection` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Enum `TraceDirection` in the file `../worker/fbs/transport.fbs:210` #[derive( Copy, Clone, @@ -25551,12 +45222,21 @@ mod root { )] #[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 @@ -25574,6 +45254,7 @@ mod root { } impl ::core::convert::From for u8 { + #[inline] fn from(value: TraceDirection) -> Self { value as u8 } @@ -25634,6 +45315,7 @@ mod root { } impl<'buf> ::planus::TableRead<'buf> for TraceDirection { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, @@ -25652,7 +45334,7 @@ mod root { offset: usize, ) -> ::core::result::Result { - let value = ::from_buffer(buffer, offset); + let value = *buffer.buffer.get_unchecked(offset); let value: ::core::result::Result = ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { @@ -25670,6 +45352,7 @@ mod root { type Value = Self; + #[inline] fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { *self } @@ -25691,6 +45374,10 @@ mod root { } } + /// The union `TraceInfo` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:212` #[derive( Clone, Debug, @@ -25703,10 +45390,18 @@ mod root { ::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, @@ -25716,6 +45411,7 @@ mod root { } 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), @@ -25724,6 +45420,7 @@ mod root { } impl ::planus::WriteAsOptionalUnion for TraceInfo { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -25732,6 +45429,68 @@ mod root { } } + /// 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>), @@ -25743,7 +45502,7 @@ mod root { fn try_from(value: TraceInfoRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(match value { TraceInfoRef::BweTraceInfo(value) => { - TraceInfo::BweTraceInfo(::planus::alloc::boxed::Box::new( + Self::BweTraceInfo(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -25768,6 +45527,10 @@ mod root { } } + /// The enum `BweType` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:216` #[derive( Copy, Clone, @@ -25782,12 +45545,21 @@ mod root { )] #[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 @@ -25805,6 +45577,7 @@ mod root { } impl ::core::convert::From for u8 { + #[inline] fn from(value: BweType) -> Self { value as u8 } @@ -25865,6 +45638,7 @@ mod root { } impl<'buf> ::planus::TableRead<'buf> for BweType { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, @@ -25883,7 +45657,7 @@ mod root { offset: usize, ) -> ::core::result::Result { - let value = ::from_buffer(buffer, offset); + let value = *buffer.buffer.get_unchecked(offset); let value: ::core::result::Result = ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { @@ -25901,6 +45675,7 @@ mod root { type Value = Self; + #[inline] fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { *self } @@ -25922,6 +45697,10 @@ mod root { } } + /// The table `BweTraceInfo` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:218` #[derive( Clone, Debug, @@ -25934,13 +45713,21 @@ mod root { ::serde::Deserialize, )] pub struct BweTraceInfo { + /// 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, + /// The field `bwe_type` in the table `BweTraceInfo` pub bwe_type: self::BweType, } @@ -25961,6 +45748,12 @@ mod root { } 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, @@ -25974,102 +45767,97 @@ mod root { field_bwe_type: impl ::planus::WriteAsDefault, ) -> ::planus::Offset { 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 prepared_bwe_type = field_bwe_type.prepare(builder, &self::BweType::TransportCc); - let mut table_writer = - ::planus::table_writer::TableWriter::<18, 29>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<20> = + ::core::default::Default::default(); if prepared_desired_bitrate.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } if prepared_effective_desired_bitrate.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(1); } if prepared_min_bitrate.is_some() { - table_writer.calculate_size::(6); + table_writer.write_entry::(2); } if prepared_max_bitrate.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(3); } if prepared_start_bitrate.is_some() { - table_writer.calculate_size::(10); + table_writer.write_entry::(4); } if prepared_max_padding_bitrate.is_some() { - table_writer.calculate_size::(12); + table_writer.write_entry::(5); } if prepared_available_bitrate.is_some() { - table_writer.calculate_size::(14); + table_writer.write_entry::(6); } if prepared_bwe_type.is_some() { - table_writer.calculate_size::(16); + table_writer.write_entry::(7); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_desired_bitrate) = - prepared_desired_bitrate - { - table_writer.write::<_, _, 4>(0, &prepared_desired_bitrate); - } - if let ::core::option::Option::Some(prepared_effective_desired_bitrate) = - prepared_effective_desired_bitrate - { - table_writer.write::<_, _, 4>(1, &prepared_effective_desired_bitrate); - } - if let ::core::option::Option::Some(prepared_min_bitrate) = - prepared_min_bitrate - { - table_writer.write::<_, _, 4>(2, &prepared_min_bitrate); - } - if let ::core::option::Option::Some(prepared_max_bitrate) = - prepared_max_bitrate - { - table_writer.write::<_, _, 4>(3, &prepared_max_bitrate); - } - if let ::core::option::Option::Some(prepared_start_bitrate) = - prepared_start_bitrate - { - table_writer.write::<_, _, 4>(4, &prepared_start_bitrate); - } - if let ::core::option::Option::Some(prepared_max_padding_bitrate) = - prepared_max_padding_bitrate - { - table_writer.write::<_, _, 4>(5, &prepared_max_padding_bitrate); - } - if let ::core::option::Option::Some(prepared_available_bitrate) = - prepared_available_bitrate - { - table_writer.write::<_, _, 4>(6, &prepared_available_bitrate); - } - if let ::core::option::Option::Some(prepared_bwe_type) = prepared_bwe_type { - table_writer.write::<_, _, 1>(7, &prepared_bwe_type); - } - } - - table_writer.finish() + 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, @@ -26081,6 +45869,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for BweTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -26090,28 +45879,314 @@ mod root { } impl ::planus::WriteAsOffset for BweTraceInfo { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { BweTraceInfo::create( builder, - &self.desired_bitrate, - &self.effective_desired_bitrate, - &self.min_bitrate, - &self.max_bitrate, - &self.start_bitrate, - &self.max_padding_bitrate, - &self.available_bitrate, - &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, + self.bwe_type, ) } } + /// 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 [`desired_bitrate` field](BweTraceInfo#structfield.desired_bitrate). + #[inline] + #[allow(clippy::type_complexity)] + pub fn desired_bitrate(self, value: T0) -> BweTraceInfoBuilder<(T0,)> + where + T0: ::planus::WriteAsDefault, + { + BweTraceInfoBuilder((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<(::planus::DefaultValue,)> { + self.desired_bitrate(::planus::DefaultValue) + } + } + + impl BweTraceInfoBuilder<(T0,)> { + /// Setter for the [`effective_desired_bitrate` field](BweTraceInfo#structfield.effective_desired_bitrate). + #[inline] + #[allow(clippy::type_complexity)] + pub fn effective_desired_bitrate( + self, + value: T1, + ) -> BweTraceInfoBuilder<(T0, T1)> + where + T1: ::planus::WriteAsDefault, + { + let (v0,) = self.0; + BweTraceInfoBuilder((v0, 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, ::planus::DefaultValue)> { + self.effective_desired_bitrate(::planus::DefaultValue) + } + } + + impl BweTraceInfoBuilder<(T0, T1)> { + /// Setter for the [`min_bitrate` field](BweTraceInfo#structfield.min_bitrate). + #[inline] + #[allow(clippy::type_complexity)] + pub fn min_bitrate(self, value: T2) -> BweTraceInfoBuilder<(T0, T1, T2)> + where + T2: ::planus::WriteAsDefault, + { + let (v0, v1) = self.0; + BweTraceInfoBuilder((v0, v1, 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, ::planus::DefaultValue)> { + self.min_bitrate(::planus::DefaultValue) + } + } + + impl BweTraceInfoBuilder<(T0, T1, T2)> { + /// Setter for the [`max_bitrate` field](BweTraceInfo#structfield.max_bitrate). + #[inline] + #[allow(clippy::type_complexity)] + pub fn max_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 [`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, ::planus::DefaultValue)> { + self.max_bitrate(::planus::DefaultValue) + } + } + + impl BweTraceInfoBuilder<(T0, T1, T2, T3)> { + /// Setter for the [`start_bitrate` field](BweTraceInfo#structfield.start_bitrate). + #[inline] + #[allow(clippy::type_complexity)] + pub fn start_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 [`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, ::planus::DefaultValue)> { + self.start_bitrate(::planus::DefaultValue) + } + } + + impl BweTraceInfoBuilder<(T0, T1, T2, T3, T4)> { + /// Setter for the [`max_padding_bitrate` field](BweTraceInfo#structfield.max_padding_bitrate). + #[inline] + #[allow(clippy::type_complexity)] + pub fn max_padding_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 [`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, ::planus::DefaultValue)> + { + self.max_padding_bitrate(::planus::DefaultValue) + } + } + + impl BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5)> { + /// Setter for the [`available_bitrate` field](BweTraceInfo#structfield.available_bitrate). + #[inline] + #[allow(clippy::type_complexity)] + pub fn available_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 [`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, ::planus::DefaultValue)> + { + self.available_bitrate(::planus::DefaultValue) + } + } + + impl BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6)> { + /// Setter for the [`bwe_type` field](BweTraceInfo#structfield.bwe_type). + #[inline] + #[allow(clippy::type_complexity)] + pub fn bwe_type( + 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 [`bwe_type` field](BweTraceInfo#structfield.bwe_type) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn bwe_type_as_default( + self, + ) -> BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6, ::planus::DefaultValue)> + { + self.bwe_type(::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 [`desired_bitrate` field](BweTraceInfo#structfield.desired_bitrate). + #[inline] pub fn desired_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -26120,6 +46195,8 @@ mod root { ) } + /// 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 @@ -26128,6 +46205,8 @@ mod root { ) } + /// Getter for the [`min_bitrate` field](BweTraceInfo#structfield.min_bitrate). + #[inline] pub fn min_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -26136,6 +46215,8 @@ mod root { ) } + /// Getter for the [`max_bitrate` field](BweTraceInfo#structfield.max_bitrate). + #[inline] pub fn max_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -26144,6 +46225,8 @@ mod root { ) } + /// Getter for the [`start_bitrate` field](BweTraceInfo#structfield.start_bitrate). + #[inline] pub fn start_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -26152,6 +46235,8 @@ mod root { ) } + /// 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 @@ -26160,6 +46245,8 @@ mod root { ) } + /// Getter for the [`available_bitrate` field](BweTraceInfo#structfield.available_bitrate). + #[inline] pub fn available_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -26168,6 +46255,8 @@ mod root { ) } + /// Getter for the [`bwe_type` field](BweTraceInfo#structfield.bwe_type). + #[inline] pub fn bwe_type(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -26222,6 +46311,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for BweTraceInfoRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -26253,6 +46343,7 @@ mod root { 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) } @@ -26289,6 +46380,10 @@ mod root { } } + /// The table `TraceNotification` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:229` #[derive( Clone, Debug, @@ -26301,9 +46396,13 @@ mod root { ::serde::Deserialize, )] pub struct TraceNotification { + /// The field `type` in the table `TraceNotification` pub type_: self::TraceType, + /// The field `timestamp` in the table `TraceNotification` pub timestamp: u64, + /// The field `direction` in the table `TraceNotification` pub direction: self::TraceDirection, + /// The field `info` in the table `TraceNotification` pub info: ::core::option::Option, } @@ -26320,6 +46419,12 @@ mod root { } 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, @@ -26332,60 +46437,60 @@ mod root { field_info: impl ::planus::WriteAsOptionalUnion, ) -> ::planus::Offset { let prepared_type_ = field_type_.prepare(builder, &self::TraceType::Probation); - let prepared_timestamp = field_timestamp.prepare(builder, &0); - let prepared_direction = field_direction.prepare(builder, &self::TraceDirection::DirectionIn); - let prepared_info = field_info.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<10, 15>::new(builder); - - if prepared_type_.is_some() { - table_writer.calculate_size::(2); - } + let mut table_writer: ::planus::table_writer::TableWriter<14> = + ::core::default::Default::default(); if prepared_timestamp.is_some() { - table_writer.calculate_size::(4); + 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.calculate_size::(6); + table_writer.write_entry::(2); } if prepared_info.is_some() { - table_writer.calculate_size::(8); - table_writer.calculate_size::<::planus::Offset>(10); + table_writer.write_entry::(3); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_timestamp) = prepared_timestamp - { - table_writer.write::<_, _, 8>(1, &prepared_timestamp); - } - if let ::core::option::Option::Some(prepared_info) = prepared_info { - table_writer.write::<_, _, 4>(4, &prepared_info.offset()); - } - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - table_writer.write::<_, _, 1>(0, &prepared_type_); - } - if let ::core::option::Option::Some(prepared_direction) = prepared_direction - { - table_writer.write::<_, _, 1>(2, &prepared_direction); - } - if let ::core::option::Option::Some(prepared_info) = prepared_info { - table_writer.write::<_, _, 1>(3, &prepared_info.tag()); - } - } - - table_writer.finish() + 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, @@ -26397,6 +46502,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for TraceNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -26406,24 +46512,190 @@ mod root { } 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.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, + { + 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, + 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, + 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, + 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 @@ -26432,6 +46704,8 @@ mod root { ) } + /// Getter for the [`timestamp` field](TraceNotification#structfield.timestamp). + #[inline] pub fn timestamp(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -26440,6 +46714,8 @@ mod root { ) } + /// Getter for the [`direction` field](TraceNotification#structfield.direction). + #[inline] pub fn direction(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -26448,6 +46724,8 @@ mod root { ) } + /// Getter for the [`info` field](TraceNotification#structfield.info). + #[inline] pub fn info( &self, ) -> ::planus::Result<::core::option::Option>> @@ -26488,6 +46766,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for TraceNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -26519,6 +46798,7 @@ mod root { 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) } @@ -26555,7 +46835,15 @@ mod root { } } } + /// 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:4` #[derive( Copy, Clone, @@ -26570,15 +46858,36 @@ mod root { )] #[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 @@ -26599,6 +46908,7 @@ mod root { } impl ::core::convert::From for u8 { + #[inline] fn from(value: SctpState) -> Self { value as u8 } @@ -26659,6 +46969,7 @@ mod root { } impl<'buf> ::planus::TableRead<'buf> for SctpState { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, @@ -26677,7 +46988,7 @@ mod root { offset: usize, ) -> ::core::result::Result { - let value = ::from_buffer(buffer, offset); + let value = *buffer.buffer.get_unchecked(offset); let value: ::core::result::Result = ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { @@ -26695,6 +47006,7 @@ mod root { type Value = Self; + #[inline] fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { *self } @@ -26716,7 +47028,15 @@ mod root { } } } + /// 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:4` #[derive( Clone, Debug, @@ -26729,10 +47049,17 @@ mod root { ::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, @@ -26740,24 +47067,23 @@ mod root { ) -> ::planus::Offset { let prepared_data = field_data.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_data); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_data); + }); } - - table_writer.finish() + 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) } @@ -26766,6 +47092,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Log { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -26775,15 +47102,84 @@ mod root { } 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") } @@ -26809,6 +47205,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for LogRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -26836,6 +47233,7 @@ mod root { 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) } @@ -26872,7 +47270,15 @@ mod root { } } } + /// 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, @@ -26887,14 +47293,28 @@ mod root { )] #[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 @@ -26914,6 +47334,7 @@ mod root { } impl ::core::convert::From for u8 { + #[inline] fn from(value: Type) -> Self { value as u8 } @@ -26974,6 +47395,7 @@ mod root { } impl<'buf> ::planus::TableRead<'buf> for Type { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, @@ -26992,7 +47414,7 @@ mod root { offset: usize, ) -> ::core::result::Result { - let value = ::from_buffer(buffer, offset); + let value = *buffer.buffer.get_unchecked(offset); let value: ::core::result::Result = ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { @@ -27010,6 +47432,7 @@ mod root { type Value = Self; + #[inline] fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { *self } @@ -27031,17 +47454,35 @@ mod root { } } + /// 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 of type `FBS.Request.Request` in the union `Body` Request(::planus::alloc::boxed::Box), + + /// The variant of type `FBS.Response.Response` in the union `Body` Response(::planus::alloc::boxed::Box), + + /// The variant of type `FBS.Notification.Notification` in the union `Body` Notification(::planus::alloc::boxed::Box), + + /// The variant of type `FBS.Log.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, @@ -27049,6 +47490,7 @@ mod root { ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) } + #[inline] pub fn create_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -27056,6 +47498,7 @@ mod root { ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) } + #[inline] pub fn create_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -27063,6 +47506,7 @@ mod root { ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) } + #[inline] pub fn create_log( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -27072,6 +47516,7 @@ mod root { } 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), @@ -27083,6 +47528,7 @@ mod root { } impl ::planus::WriteAsOptionalUnion for Body { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -27091,6 +47537,152 @@ mod root { } } + /// 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>), @@ -27104,23 +47696,23 @@ mod root { fn try_from(value: BodyRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(match value { - BodyRef::Request(value) => Body::Request(::planus::alloc::boxed::Box::new( + BodyRef::Request(value) => Self::Request(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )), BodyRef::Response(value) => { - Body::Response(::planus::alloc::boxed::Box::new( + Self::Response(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::Notification(value) => { - Body::Notification(::planus::alloc::boxed::Box::new( + Self::Notification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::Log(value) => Body::Log(::planus::alloc::boxed::Box::new( + BodyRef::Log(value) => Self::Log(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )), }) @@ -27153,15 +47745,27 @@ mod root { } } + /// 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, @@ -27169,35 +47773,33 @@ mod root { 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::<6, 6>::new(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.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.calculate_size::(4); - table_writer.calculate_size::<::planus::Offset>(6); - - table_writer.finish_calculating(); + table_writer.write_entry::(1); unsafe { - table_writer.write::<_, _, 4>(2, &prepared_data.offset()); - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - table_writer.write::<_, _, 1>(0, &prepared_type_); - } - table_writer.write::<_, _, 1>(1, &prepared_data.tag()); + 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()); + }); } - - table_writer.finish() + 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) } @@ -27206,6 +47808,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Message { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -27215,15 +47818,111 @@ mod root { } 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 { - Message::create(builder, &self.type_, &self.data) + 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 @@ -27232,6 +47931,8 @@ mod root { ) } + /// Getter for the [`data` field](Message#structfield.data). + #[inline] pub fn data(&self) -> ::planus::Result> { self.0.access_union_required(1, "Message", "data") } @@ -27259,6 +47960,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for MessageRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -27290,6 +47992,7 @@ mod root { 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) } @@ -27326,7 +48029,15 @@ mod root { } } } + /// 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, @@ -27341,41 +48052,140 @@ mod root { )] #[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 @@ -27426,6 +48236,7 @@ mod root { } impl ::core::convert::From for u8 { + #[inline] fn from(value: Event) -> Self { value as u8 } @@ -27486,6 +48297,7 @@ mod root { } impl<'buf> ::planus::TableRead<'buf> for Event { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, @@ -27504,7 +48316,7 @@ mod root { offset: usize, ) -> ::core::result::Result { - let value = ::from_buffer(buffer, offset); + let value = *buffer.buffer.get_unchecked(offset); let value: ::core::result::Result = ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { @@ -27522,6 +48334,7 @@ mod root { type Value = Self; + #[inline] fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { *self } @@ -27543,6 +48356,10 @@ mod root { } } + /// The union `Body` in the namespace `FBS.Notification` + /// + /// Generated from these locations: + /// * Union `Body` in the file `../worker/fbs/notification.fbs:49` #[derive( Clone, Debug, @@ -27555,69 +48372,111 @@ mod root { ::serde::Deserialize, )] pub enum Body { + /// The variant of type `FBS.Transport.SendRtcpNotification` in the union `Body` SendRtcpNotification( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Transport.SctpStateChangeNotification` in the union `Body` SctpStateChangeNotification( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.DataProducer.SendNotification` in the union `Body` SendNotification( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Consumer.TraceNotification` in the union `Body` TraceNotification(::planus::alloc::boxed::Box), + + /// The variant of type `FBS.WebRtcTransport.IceSelectedTupleChangeNotification` in the union `Body` IceSelectedTupleChangeNotification( ::planus::alloc::boxed::Box< super::web_rtc_transport::IceSelectedTupleChangeNotification, >, ), + + /// The variant of type `FBS.WebRtcTransport.IceStateChangeNotification` in the union `Body` IceStateChangeNotification( ::planus::alloc::boxed::Box< super::web_rtc_transport::IceStateChangeNotification, >, ), + + /// The variant of type `FBS.WebRtcTransport.DtlsStateChangeNotification` in the union `Body` DtlsStateChangeNotification( ::planus::alloc::boxed::Box< super::web_rtc_transport::DtlsStateChangeNotification, >, ), + + /// The variant of type `FBS.PlainTransport.TupleNotification` in the union `Body` TupleNotification( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.PlainTransport.RtcpTupleNotification` in the union `Body` RtcpTupleNotification( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.DirectTransport.RtcpNotification` in the union `Body` RtcpNotification( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Consumer.ScoreNotification` in the union `Body` ScoreNotification(::planus::alloc::boxed::Box), + + /// The variant of type `FBS.Producer.VideoOrientationChangeNotification` in the union `Body` VideoOrientationChangeNotification( ::planus::alloc::boxed::Box< super::producer::VideoOrientationChangeNotification, >, ), + + /// The variant of type `FBS.Consumer.LayersChangeNotification` in the union `Body` LayersChangeNotification( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Consumer.RtpNotification` in the union `Body` RtpNotification(::planus::alloc::boxed::Box), + + /// The variant of type `FBS.DataConsumer.MessageNotification` in the union `Body` MessageNotification( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.DataConsumer.BufferedAmountLowNotification` in the union `Body` BufferedAmountLowNotification( ::planus::alloc::boxed::Box< super::data_consumer::BufferedAmountLowNotification, >, ), + + /// The variant of type `FBS.ActiveSpeakerObserver.DominantSpeakerNotification` in the union `Body` DominantSpeakerNotification( ::planus::alloc::boxed::Box< super::active_speaker_observer::DominantSpeakerNotification, >, ), + + /// The variant of type `FBS.AudioLevelObserver.VolumesNotification` in the union `Body` VolumesNotification( ::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_send_rtcp_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -27625,6 +48484,7 @@ mod root { ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) } + #[inline] pub fn create_sctp_state_change_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -27632,6 +48492,7 @@ mod root { ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) } + #[inline] pub fn create_send_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -27639,6 +48500,7 @@ mod root { ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) } + #[inline] pub fn create_trace_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -27646,6 +48508,7 @@ mod root { ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) } + #[inline] pub fn create_ice_selected_tuple_change_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset< @@ -27655,6 +48518,7 @@ mod root { ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) } + #[inline] pub fn create_ice_state_change_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset< @@ -27664,6 +48528,7 @@ mod root { ::planus::UnionOffset::new(6, value.prepare(builder).downcast()) } + #[inline] pub fn create_dtls_state_change_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset< @@ -27673,6 +48538,7 @@ mod root { ::planus::UnionOffset::new(7, value.prepare(builder).downcast()) } + #[inline] pub fn create_tuple_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -27680,6 +48546,7 @@ mod root { ::planus::UnionOffset::new(8, value.prepare(builder).downcast()) } + #[inline] pub fn create_rtcp_tuple_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -27687,6 +48554,7 @@ mod root { ::planus::UnionOffset::new(9, value.prepare(builder).downcast()) } + #[inline] pub fn create_rtcp_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -27694,6 +48562,7 @@ mod root { ::planus::UnionOffset::new(10, value.prepare(builder).downcast()) } + #[inline] pub fn create_score_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -27701,6 +48570,7 @@ mod root { ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) } + #[inline] pub fn create_video_orientation_change_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset< @@ -27710,6 +48580,7 @@ mod root { ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) } + #[inline] pub fn create_layers_change_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -27717,6 +48588,7 @@ mod root { ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) } + #[inline] pub fn create_rtp_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -27724,6 +48596,7 @@ mod root { ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) } + #[inline] pub fn create_message_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -27731,6 +48604,7 @@ mod root { ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) } + #[inline] pub fn create_buffered_amount_low_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset< @@ -27740,6 +48614,7 @@ mod root { ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) } + #[inline] pub fn create_dominant_speaker_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset< @@ -27749,6 +48624,7 @@ mod root { ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) } + #[inline] pub fn create_volumes_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset< @@ -27760,6 +48636,7 @@ mod root { } impl ::planus::WriteAsUnion for Body { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { match self { Self::SendRtcpNotification(value) => { @@ -27821,6 +48698,7 @@ mod root { } impl ::planus::WriteAsOptionalUnion for Body { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -27829,6 +48707,656 @@ mod root { } } + /// 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 [`SendRtcpNotification` variant](Body#variant.SendRtcpNotification). + #[inline] + pub fn send_rtcp_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`SctpStateChangeNotification` variant](Body#variant.SctpStateChangeNotification). + #[inline] + pub fn 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 [`SendNotification` variant](Body#variant.SendNotification). + #[inline] + pub fn send_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<3, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`TraceNotification` variant](Body#variant.TraceNotification). + #[inline] + pub fn trace_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<4, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`IceSelectedTupleChangeNotification` variant](Body#variant.IceSelectedTupleChangeNotification). + #[inline] + pub fn ice_selected_tuple_change_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<5, T>> + where + T: ::planus::WriteAsOffset< + super::web_rtc_transport::IceSelectedTupleChangeNotification, + >, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`IceStateChangeNotification` variant](Body#variant.IceStateChangeNotification). + #[inline] + pub fn ice_state_change_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<6, T>> + where + T: ::planus::WriteAsOffset< + super::web_rtc_transport::IceStateChangeNotification, + >, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`DtlsStateChangeNotification` variant](Body#variant.DtlsStateChangeNotification). + #[inline] + pub fn dtls_state_change_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<7, T>> + where + T: ::planus::WriteAsOffset< + super::web_rtc_transport::DtlsStateChangeNotification, + >, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`TupleNotification` variant](Body#variant.TupleNotification). + #[inline] + pub fn tuple_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<8, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`RtcpTupleNotification` variant](Body#variant.RtcpTupleNotification). + #[inline] + pub fn rtcp_tuple_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<9, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`RtcpNotification` variant](Body#variant.RtcpNotification). + #[inline] + pub fn rtcp_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<10, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`ScoreNotification` variant](Body#variant.ScoreNotification). + #[inline] + pub fn score_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<11, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`VideoOrientationChangeNotification` variant](Body#variant.VideoOrientationChangeNotification). + #[inline] + pub fn video_orientation_change_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<12, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`LayersChangeNotification` variant](Body#variant.LayersChangeNotification). + #[inline] + pub fn layers_change_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<13, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`RtpNotification` variant](Body#variant.RtpNotification). + #[inline] + pub fn rtp_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<14, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`MessageNotification` variant](Body#variant.MessageNotification). + #[inline] + pub fn message_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<15, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`BufferedAmountLowNotification` variant](Body#variant.BufferedAmountLowNotification). + #[inline] + pub fn buffered_amount_low_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<16, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`DominantSpeakerNotification` variant](Body#variant.DominantSpeakerNotification). + #[inline] + pub fn dominant_speaker_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<17, T>> + where + T: ::planus::WriteAsOffset< + super::active_speaker_observer::DominantSpeakerNotification, + >, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`VolumesNotification` variant](Body#variant.VolumesNotification). + #[inline] + pub fn volumes_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<18, 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< + super::web_rtc_transport::IceSelectedTupleChangeNotification, + >, + { + #[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< + 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<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< + super::active_speaker_observer::DominantSpeakerNotification, + >, + { + #[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< + 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<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)) + } + } + + /// Reference to a deserialized [Body]. #[derive(Copy, Clone, Debug)] pub enum BodyRef<'a> { SendRtcpNotification(super::transport::SendRtcpNotificationRef<'a>), @@ -27869,31 +49397,31 @@ mod root { fn try_from(value: BodyRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(match value { BodyRef::SendRtcpNotification(value) => { - Body::SendRtcpNotification(::planus::alloc::boxed::Box::new( + Self::SendRtcpNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::SctpStateChangeNotification(value) => { - Body::SctpStateChangeNotification(::planus::alloc::boxed::Box::new( + Self::SctpStateChangeNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::SendNotification(value) => { - Body::SendNotification(::planus::alloc::boxed::Box::new( + Self::SendNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::TraceNotification(value) => { - Body::TraceNotification(::planus::alloc::boxed::Box::new( + Self::TraceNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::IceSelectedTupleChangeNotification(value) => { - Body::IceSelectedTupleChangeNotification( + Self::IceSelectedTupleChangeNotification( ::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, ), @@ -27901,43 +49429,43 @@ mod root { } BodyRef::IceStateChangeNotification(value) => { - Body::IceStateChangeNotification(::planus::alloc::boxed::Box::new( + Self::IceStateChangeNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::DtlsStateChangeNotification(value) => { - Body::DtlsStateChangeNotification(::planus::alloc::boxed::Box::new( + Self::DtlsStateChangeNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::TupleNotification(value) => { - Body::TupleNotification(::planus::alloc::boxed::Box::new( + Self::TupleNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::RtcpTupleNotification(value) => { - Body::RtcpTupleNotification(::planus::alloc::boxed::Box::new( + Self::RtcpTupleNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::RtcpNotification(value) => { - Body::RtcpNotification(::planus::alloc::boxed::Box::new( + Self::RtcpNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::ScoreNotification(value) => { - Body::ScoreNotification(::planus::alloc::boxed::Box::new( + Self::ScoreNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::VideoOrientationChangeNotification(value) => { - Body::VideoOrientationChangeNotification( + Self::VideoOrientationChangeNotification( ::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, ), @@ -27945,37 +49473,37 @@ mod root { } BodyRef::LayersChangeNotification(value) => { - Body::LayersChangeNotification(::planus::alloc::boxed::Box::new( + Self::LayersChangeNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::RtpNotification(value) => { - Body::RtpNotification(::planus::alloc::boxed::Box::new( + Self::RtpNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::MessageNotification(value) => { - Body::MessageNotification(::planus::alloc::boxed::Box::new( + Self::MessageNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::BufferedAmountLowNotification(value) => { - Body::BufferedAmountLowNotification(::planus::alloc::boxed::Box::new( + Self::BufferedAmountLowNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::DominantSpeakerNotification(value) => { - Body::DominantSpeakerNotification(::planus::alloc::boxed::Box::new( + Self::DominantSpeakerNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::VolumesNotification(value) => { - Body::VolumesNotification(::planus::alloc::boxed::Box::new( + Self::VolumesNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -28051,6 +49579,10 @@ mod root { } } + /// The table `Notification` in the namespace `FBS.Notification` + /// + /// Generated from these locations: + /// * Table `Notification` in the file `../worker/fbs/notification.fbs:76` #[derive( Clone, Debug, @@ -28063,12 +49595,21 @@ mod root { ::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, @@ -28077,46 +49618,45 @@ mod root { 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::<8, 10>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); + 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.calculate_size::(4); + table_writer.write_entry::(1); } if prepared_body.is_some() { - table_writer.calculate_size::(6); - table_writer.calculate_size::<::planus::Offset>(8); + table_writer.write_entry::(2); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_handler_id); - if let ::core::option::Option::Some(prepared_body) = prepared_body { - table_writer.write::<_, _, 4>(3, &prepared_body.offset()); - } - if let ::core::option::Option::Some(prepared_event) = prepared_event { - table_writer.write::<_, _, 1>(1, &prepared_event); - } - if let ::core::option::Option::Some(prepared_body) = prepared_body { - table_writer.write::<_, _, 1>(2, &prepared_body.tag()); - } + 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()); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for Notification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -28128,6 +49668,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Notification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -28137,49 +49678,182 @@ mod root { } 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) + Notification::create(builder, &self.handler_id, self.event, &self.body) } } - #[derive(Copy, Clone)] - pub struct NotificationRef<'a>(::planus::table_reader::Table<'a>); + /// 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<'a> NotificationRef<'a> { - pub fn handler_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "Notification", "handler_id") + 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,)) } + } - pub fn event(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "Notification", "event")? - .unwrap_or(self::Event::TransportSendRtcp), - ) + 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)) } - pub fn body(&self) -> ::planus::Result<::core::option::Option>> { - self.0.access_union(2, "Notification", "body") + /// 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<'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 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<'a> ::core::convert::TryFrom> for Notification { - type Error = ::planus::Error; + 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 { @@ -28196,6 +49870,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for NotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -28227,6 +49902,7 @@ mod root { 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) } @@ -28263,7 +49939,15 @@ mod root { } } } + /// 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, @@ -28278,76 +49962,280 @@ mod root { )] #[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 `RTPOBSERVER_PAUSE` in the enum `Method` RtpobserverPause = 62, + + /// The variant `RTPOBSERVER_RESUME` in the enum `Method` RtpobserverResume = 63, + + /// The variant `RTPOBSERVER_ADD_PRODUCER` in the enum `Method` RtpobserverAddProducer = 64, + + /// The variant `RTPOBSERVER_REMOVE_PRODUCER` in the enum `Method` RtpobserverRemoveProducer = 65, } + impl Method { + /// Array containing all valid variants of Method + pub const ENUM_VALUES: [Self; 66] = [ + 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::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 @@ -28433,6 +50321,7 @@ mod root { } impl ::core::convert::From for u8 { + #[inline] fn from(value: Method) -> Self { value as u8 } @@ -28493,6 +50382,7 @@ mod root { } impl<'buf> ::planus::TableRead<'buf> for Method { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, @@ -28511,7 +50401,7 @@ mod root { offset: usize, ) -> ::core::result::Result { - let value = ::from_buffer(buffer, offset); + let value = *buffer.buffer.get_unchecked(offset); let value: ::core::result::Result = ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { @@ -28529,6 +50419,7 @@ mod root { type Value = Self; + #[inline] fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { *self } @@ -28550,103 +50441,177 @@ mod root { } } + /// The union `Body` in the namespace `FBS.Request` + /// + /// Generated from these locations: + /// * Union `Body` in the file `../worker/fbs/request.fbs:80` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub enum Body { + /// The variant of type `FBS.Worker.UpdateSettingsRequest` in the union `Body` UpdateSettingsRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Worker.CreateWebRtcServerRequest` in the union `Body` CreateWebRtcServerRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Worker.CloseWebRtcServerRequest` in the union `Body` CloseWebRtcServerRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Worker.CreateRouterRequest` in the union `Body` CreateRouterRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Worker.CloseRouterRequest` in the union `Body` CloseRouterRequest(::planus::alloc::boxed::Box), + + /// The variant of type `FBS.Router.CreateWebRtcTransportRequest` in the union `Body` CreateWebRtcTransportRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Router.CreatePlainTransportRequest` in the union `Body` CreatePlainTransportRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Router.CreatePipeTransportRequest` in the union `Body` CreatePipeTransportRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Router.CreateDirectTransportRequest` in the union `Body` CreateDirectTransportRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Router.CreateActiveSpeakerObserverRequest` in the union `Body` CreateActiveSpeakerObserverRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Router.CreateAudioLevelObserverRequest` in the union `Body` CreateAudioLevelObserverRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Router.CloseTransportRequest` in the union `Body` CloseTransportRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Router.CloseRtpObserverRequest` in the union `Body` CloseRtpObserverRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Transport.SetMaxIncomingBitrateRequest` in the union `Body` SetMaxIncomingBitrateRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Transport.SetMaxOutgoingBitrateRequest` in the union `Body` SetMaxOutgoingBitrateRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Transport.SetMinOutgoingBitrateRequest` in the union `Body` SetMinOutgoingBitrateRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Transport.ProduceRequest` in the union `Body` ProduceRequest(::planus::alloc::boxed::Box), + + /// The variant of type `FBS.Transport.ConsumeRequest` in the union `Body` ConsumeRequest(::planus::alloc::boxed::Box), + + /// The variant of type `FBS.Transport.ProduceDataRequest` in the union `Body` ProduceDataRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Transport.ConsumeDataRequest` in the union `Body` ConsumeDataRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Consumer.EnableTraceEventRequest` in the union `Body` EnableTraceEventRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Transport.CloseProducerRequest` in the union `Body` CloseProducerRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Transport.CloseConsumerRequest` in the union `Body` CloseConsumerRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Transport.CloseDataProducerRequest` in the union `Body` CloseDataProducerRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Transport.CloseDataConsumerRequest` in the union `Body` CloseDataConsumerRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.WebRtcTransport.ConnectRequest` in the union `Body` ConnectRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Consumer.SetPreferredLayersRequest` in the union `Body` SetPreferredLayersRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.Consumer.SetPriorityRequest` in the union `Body` SetPriorityRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.DataConsumer.SetBufferedAmountLowThresholdRequest` in the union `Body` SetBufferedAmountLowThresholdRequest( ::planus::alloc::boxed::Box< super::data_consumer::SetBufferedAmountLowThresholdRequest, >, ), + + /// The variant of type `FBS.DataConsumer.SendRequest` in the union `Body` SendRequest(::planus::alloc::boxed::Box), + + /// The variant of type `FBS.RtpObserver.AddProducerRequest` in the union `Body` AddProducerRequest( ::planus::alloc::boxed::Box, ), + + /// The variant of type `FBS.RtpObserver.RemoveProducerRequest` in the union `Body` RemoveProducerRequest( ::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_update_settings_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28654,6 +50619,7 @@ mod root { ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) } + #[inline] pub fn create_create_web_rtc_server_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28661,6 +50627,7 @@ mod root { ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) } + #[inline] pub fn create_close_web_rtc_server_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28668,6 +50635,7 @@ mod root { ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) } + #[inline] pub fn create_create_router_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28675,6 +50643,7 @@ mod root { ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) } + #[inline] pub fn create_close_router_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28682,6 +50651,7 @@ mod root { ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) } + #[inline] pub fn create_create_web_rtc_transport_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28689,6 +50659,7 @@ mod root { ::planus::UnionOffset::new(6, value.prepare(builder).downcast()) } + #[inline] pub fn create_create_plain_transport_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28696,6 +50667,7 @@ mod root { ::planus::UnionOffset::new(7, value.prepare(builder).downcast()) } + #[inline] pub fn create_create_pipe_transport_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28703,6 +50675,7 @@ mod root { ::planus::UnionOffset::new(8, value.prepare(builder).downcast()) } + #[inline] pub fn create_create_direct_transport_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28710,6 +50683,7 @@ mod root { ::planus::UnionOffset::new(9, value.prepare(builder).downcast()) } + #[inline] pub fn create_create_active_speaker_observer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset< @@ -28719,6 +50693,7 @@ mod root { ::planus::UnionOffset::new(10, value.prepare(builder).downcast()) } + #[inline] pub fn create_create_audio_level_observer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28726,6 +50701,7 @@ mod root { ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) } + #[inline] pub fn create_close_transport_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28733,6 +50709,7 @@ mod root { ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) } + #[inline] pub fn create_close_rtp_observer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28740,6 +50717,7 @@ mod root { ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) } + #[inline] pub fn create_set_max_incoming_bitrate_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28747,6 +50725,7 @@ mod root { ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) } + #[inline] pub fn create_set_max_outgoing_bitrate_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28754,6 +50733,7 @@ mod root { ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) } + #[inline] pub fn create_set_min_outgoing_bitrate_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28761,6 +50741,7 @@ mod root { ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) } + #[inline] pub fn create_produce_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28768,6 +50749,7 @@ mod root { ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) } + #[inline] pub fn create_consume_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28775,6 +50757,7 @@ mod root { ::planus::UnionOffset::new(18, value.prepare(builder).downcast()) } + #[inline] pub fn create_produce_data_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28782,6 +50765,7 @@ mod root { ::planus::UnionOffset::new(19, value.prepare(builder).downcast()) } + #[inline] pub fn create_consume_data_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28789,6 +50773,7 @@ mod root { ::planus::UnionOffset::new(20, value.prepare(builder).downcast()) } + #[inline] pub fn create_enable_trace_event_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28796,6 +50781,7 @@ mod root { ::planus::UnionOffset::new(21, value.prepare(builder).downcast()) } + #[inline] pub fn create_close_producer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28803,6 +50789,7 @@ mod root { ::planus::UnionOffset::new(22, value.prepare(builder).downcast()) } + #[inline] pub fn create_close_consumer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28810,6 +50797,7 @@ mod root { ::planus::UnionOffset::new(23, value.prepare(builder).downcast()) } + #[inline] pub fn create_close_data_producer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28817,6 +50805,7 @@ mod root { ::planus::UnionOffset::new(24, value.prepare(builder).downcast()) } + #[inline] pub fn create_close_data_consumer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28824,6 +50813,7 @@ mod root { ::planus::UnionOffset::new(25, value.prepare(builder).downcast()) } + #[inline] pub fn create_connect_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28831,6 +50821,7 @@ mod root { ::planus::UnionOffset::new(26, value.prepare(builder).downcast()) } + #[inline] pub fn create_set_preferred_layers_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28838,6 +50829,7 @@ mod root { ::planus::UnionOffset::new(27, value.prepare(builder).downcast()) } + #[inline] pub fn create_set_priority_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28845,6 +50837,7 @@ mod root { ::planus::UnionOffset::new(28, value.prepare(builder).downcast()) } + #[inline] pub fn create_set_buffered_amount_low_threshold_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset< @@ -28854,6 +50847,7 @@ mod root { ::planus::UnionOffset::new(29, value.prepare(builder).downcast()) } + #[inline] pub fn create_send_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28861,6 +50855,7 @@ mod root { ::planus::UnionOffset::new(30, value.prepare(builder).downcast()) } + #[inline] pub fn create_add_producer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28868,6 +50863,7 @@ mod root { ::planus::UnionOffset::new(31, value.prepare(builder).downcast()) } + #[inline] pub fn create_remove_producer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -28877,6 +50873,7 @@ mod root { } impl ::planus::WriteAsUnion for Body { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { match self { Self::UpdateSettingsRequest(value) => { @@ -28972,6 +50969,7 @@ mod root { } impl ::planus::WriteAsOptionalUnion for Body { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -28980,269 +50978,1382 @@ mod root { } } - #[derive(Copy, Clone, Debug)] - pub enum BodyRef<'a> { - UpdateSettingsRequest(super::worker::UpdateSettingsRequestRef<'a>), - CreateWebRtcServerRequest(super::worker::CreateWebRtcServerRequestRef<'a>), - CloseWebRtcServerRequest(super::worker::CloseWebRtcServerRequestRef<'a>), - CreateRouterRequest(super::worker::CreateRouterRequestRef<'a>), - CloseRouterRequest(super::worker::CloseRouterRequestRef<'a>), - CreateWebRtcTransportRequest(super::router::CreateWebRtcTransportRequestRef<'a>), - CreatePlainTransportRequest(super::router::CreatePlainTransportRequestRef<'a>), - CreatePipeTransportRequest(super::router::CreatePipeTransportRequestRef<'a>), - CreateDirectTransportRequest(super::router::CreateDirectTransportRequestRef<'a>), - CreateActiveSpeakerObserverRequest( - super::router::CreateActiveSpeakerObserverRequestRef<'a>, - ), - CreateAudioLevelObserverRequest( - super::router::CreateAudioLevelObserverRequestRef<'a>, - ), - CloseTransportRequest(super::router::CloseTransportRequestRef<'a>), - CloseRtpObserverRequest(super::router::CloseRtpObserverRequestRef<'a>), - SetMaxIncomingBitrateRequest(super::transport::SetMaxIncomingBitrateRequestRef<'a>), - SetMaxOutgoingBitrateRequest(super::transport::SetMaxOutgoingBitrateRequestRef<'a>), - SetMinOutgoingBitrateRequest(super::transport::SetMinOutgoingBitrateRequestRef<'a>), - ProduceRequest(super::transport::ProduceRequestRef<'a>), - ConsumeRequest(super::transport::ConsumeRequestRef<'a>), - ProduceDataRequest(super::transport::ProduceDataRequestRef<'a>), - ConsumeDataRequest(super::transport::ConsumeDataRequestRef<'a>), - EnableTraceEventRequest(super::consumer::EnableTraceEventRequestRef<'a>), - CloseProducerRequest(super::transport::CloseProducerRequestRef<'a>), - CloseConsumerRequest(super::transport::CloseConsumerRequestRef<'a>), - CloseDataProducerRequest(super::transport::CloseDataProducerRequestRef<'a>), - CloseDataConsumerRequest(super::transport::CloseDataConsumerRequestRef<'a>), - ConnectRequest(super::web_rtc_transport::ConnectRequestRef<'a>), - SetPreferredLayersRequest(super::consumer::SetPreferredLayersRequestRef<'a>), - SetPriorityRequest(super::consumer::SetPriorityRequestRef<'a>), - SetBufferedAmountLowThresholdRequest( - super::data_consumer::SetBufferedAmountLowThresholdRequestRef<'a>, - ), - SendRequest(super::data_consumer::SendRequestRef<'a>), - AddProducerRequest(super::rtp_observer::AddProducerRequestRef<'a>), - RemoveProducerRequest(super::rtp_observer::RemoveProducerRequestRef<'a>), - } + /// 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<'a> ::core::convert::TryFrom> for Body { - type Error = ::planus::Error; + impl BodyBuilder<::planus::Uninitialized> { + /// Creates an instance of the [`UpdateSettingsRequest` variant](Body#variant.UpdateSettingsRequest). + #[inline] + pub fn update_settings_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - fn try_from(value: BodyRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - BodyRef::UpdateSettingsRequest(value) => { - Body::UpdateSettingsRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`CreateWebRtcServerRequest` variant](Body#variant.CreateWebRtcServerRequest). + #[inline] + pub fn create_web_rtc_server_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<2, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::CreateWebRtcServerRequest(value) => { - Body::CreateWebRtcServerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`CloseWebRtcServerRequest` variant](Body#variant.CloseWebRtcServerRequest). + #[inline] + pub fn close_web_rtc_server_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<3, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::CloseWebRtcServerRequest(value) => { - Body::CloseWebRtcServerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`CreateRouterRequest` variant](Body#variant.CreateRouterRequest). + #[inline] + pub fn create_router_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<4, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::CreateRouterRequest(value) => { - Body::CreateRouterRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`CloseRouterRequest` variant](Body#variant.CloseRouterRequest). + #[inline] + pub fn close_router_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<5, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::CloseRouterRequest(value) => { - Body::CloseRouterRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`CreateWebRtcTransportRequest` variant](Body#variant.CreateWebRtcTransportRequest). + #[inline] + pub fn create_web_rtc_transport_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<6, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::CreateWebRtcTransportRequest(value) => { - Body::CreateWebRtcTransportRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`CreatePlainTransportRequest` variant](Body#variant.CreatePlainTransportRequest). + #[inline] + pub fn create_plain_transport_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<7, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::CreatePlainTransportRequest(value) => { - Body::CreatePlainTransportRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`CreatePipeTransportRequest` variant](Body#variant.CreatePipeTransportRequest). + #[inline] + pub fn create_pipe_transport_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<8, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::CreatePipeTransportRequest(value) => { - Body::CreatePipeTransportRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`CreateDirectTransportRequest` variant](Body#variant.CreateDirectTransportRequest). + #[inline] + pub fn create_direct_transport_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<9, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::CreateDirectTransportRequest(value) => { - Body::CreateDirectTransportRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`CreateActiveSpeakerObserverRequest` variant](Body#variant.CreateActiveSpeakerObserverRequest). + #[inline] + pub fn create_active_speaker_observer_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<10, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::CreateActiveSpeakerObserverRequest(value) => { - Body::CreateActiveSpeakerObserverRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } + /// Creates an instance of the [`CreateAudioLevelObserverRequest` variant](Body#variant.CreateAudioLevelObserverRequest). + #[inline] + pub fn create_audio_level_observer_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<11, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::CreateAudioLevelObserverRequest(value) => { - Body::CreateAudioLevelObserverRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`CloseTransportRequest` variant](Body#variant.CloseTransportRequest). + #[inline] + pub fn close_transport_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<12, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::CloseTransportRequest(value) => { - Body::CloseTransportRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`CloseRtpObserverRequest` variant](Body#variant.CloseRtpObserverRequest). + #[inline] + pub fn close_rtp_observer_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<13, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::CloseRtpObserverRequest(value) => { - Body::CloseRtpObserverRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`SetMaxIncomingBitrateRequest` variant](Body#variant.SetMaxIncomingBitrateRequest). + #[inline] + pub fn set_max_incoming_bitrate_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<14, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::SetMaxIncomingBitrateRequest(value) => { - Body::SetMaxIncomingBitrateRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`SetMaxOutgoingBitrateRequest` variant](Body#variant.SetMaxOutgoingBitrateRequest). + #[inline] + pub fn set_max_outgoing_bitrate_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<15, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::SetMaxOutgoingBitrateRequest(value) => { - Body::SetMaxOutgoingBitrateRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`SetMinOutgoingBitrateRequest` variant](Body#variant.SetMinOutgoingBitrateRequest). + #[inline] + pub fn set_min_outgoing_bitrate_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<16, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::SetMinOutgoingBitrateRequest(value) => { - Body::SetMinOutgoingBitrateRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`ProduceRequest` variant](Body#variant.ProduceRequest). + #[inline] + pub fn produce_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<17, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::ProduceRequest(value) => { - Body::ProduceRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`ConsumeRequest` variant](Body#variant.ConsumeRequest). + #[inline] + pub fn consume_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<18, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::ConsumeRequest(value) => { - Body::ConsumeRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`ProduceDataRequest` variant](Body#variant.ProduceDataRequest). + #[inline] + pub fn produce_data_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<19, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::ProduceDataRequest(value) => { - Body::ProduceDataRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`ConsumeDataRequest` variant](Body#variant.ConsumeDataRequest). + #[inline] + pub fn consume_data_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<20, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::ConsumeDataRequest(value) => { - Body::ConsumeDataRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`EnableTraceEventRequest` variant](Body#variant.EnableTraceEventRequest). + #[inline] + pub fn enable_trace_event_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<21, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::EnableTraceEventRequest(value) => { - Body::EnableTraceEventRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`CloseProducerRequest` variant](Body#variant.CloseProducerRequest). + #[inline] + pub fn close_producer_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<22, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::CloseProducerRequest(value) => { - Body::CloseProducerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`CloseConsumerRequest` variant](Body#variant.CloseConsumerRequest). + #[inline] + pub fn close_consumer_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<23, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::CloseConsumerRequest(value) => { - Body::CloseConsumerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`CloseDataProducerRequest` variant](Body#variant.CloseDataProducerRequest). + #[inline] + pub fn close_data_producer_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<24, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::CloseDataProducerRequest(value) => { - Body::CloseDataProducerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`CloseDataConsumerRequest` variant](Body#variant.CloseDataConsumerRequest). + #[inline] + pub fn close_data_consumer_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<25, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::CloseDataConsumerRequest(value) => { - Body::CloseDataConsumerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`ConnectRequest` variant](Body#variant.ConnectRequest). + #[inline] + pub fn connect_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<26, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::ConnectRequest(value) => { - Body::ConnectRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`SetPreferredLayersRequest` variant](Body#variant.SetPreferredLayersRequest). + #[inline] + pub fn set_preferred_layers_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<27, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::SetPreferredLayersRequest(value) => { - Body::SetPreferredLayersRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`SetPriorityRequest` variant](Body#variant.SetPriorityRequest). + #[inline] + pub fn set_priority_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<28, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::SetPriorityRequest(value) => { - Body::SetPriorityRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`SetBufferedAmountLowThresholdRequest` variant](Body#variant.SetBufferedAmountLowThresholdRequest). + #[inline] + pub fn set_buffered_amount_low_threshold_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<29, T>> + where + T: ::planus::WriteAsOffset< + super::data_consumer::SetBufferedAmountLowThresholdRequest, + >, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::SetBufferedAmountLowThresholdRequest(value) => { - Body::SetBufferedAmountLowThresholdRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } + /// Creates an instance of the [`SendRequest` variant](Body#variant.SendRequest). + #[inline] + pub fn send_request(self, value: T) -> BodyBuilder<::planus::Initialized<30, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::SendRequest(value) => { - Body::SendRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`AddProducerRequest` variant](Body#variant.AddProducerRequest). + #[inline] + pub fn add_producer_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<31, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - BodyRef::AddProducerRequest(value) => { - Body::AddProducerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// Creates an instance of the [`RemoveProducerRequest` variant](Body#variant.RemoveProducerRequest). + #[inline] + pub fn remove_producer_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<32, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + } - BodyRef::RemoveProducerRequest(value) => { - Body::RemoveProducerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(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<'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::UpdateSettingsRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::CreateWebRtcServerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 3 => ::core::result::Result::Ok(Self::CloseWebRtcServerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 4 => ::core::result::Result::Ok(Self::CreateRouterRequest( + 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< + super::data_consumer::SetBufferedAmountLowThresholdRequest, + >, + { + #[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< + 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<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)) + } + } + + /// Reference to a deserialized [Body]. + #[derive(Copy, Clone, Debug)] + pub enum BodyRef<'a> { + UpdateSettingsRequest(super::worker::UpdateSettingsRequestRef<'a>), + CreateWebRtcServerRequest(super::worker::CreateWebRtcServerRequestRef<'a>), + CloseWebRtcServerRequest(super::worker::CloseWebRtcServerRequestRef<'a>), + CreateRouterRequest(super::worker::CreateRouterRequestRef<'a>), + CloseRouterRequest(super::worker::CloseRouterRequestRef<'a>), + CreateWebRtcTransportRequest(super::router::CreateWebRtcTransportRequestRef<'a>), + CreatePlainTransportRequest(super::router::CreatePlainTransportRequestRef<'a>), + CreatePipeTransportRequest(super::router::CreatePipeTransportRequestRef<'a>), + CreateDirectTransportRequest(super::router::CreateDirectTransportRequestRef<'a>), + CreateActiveSpeakerObserverRequest( + super::router::CreateActiveSpeakerObserverRequestRef<'a>, + ), + CreateAudioLevelObserverRequest( + super::router::CreateAudioLevelObserverRequestRef<'a>, + ), + CloseTransportRequest(super::router::CloseTransportRequestRef<'a>), + CloseRtpObserverRequest(super::router::CloseRtpObserverRequestRef<'a>), + SetMaxIncomingBitrateRequest(super::transport::SetMaxIncomingBitrateRequestRef<'a>), + SetMaxOutgoingBitrateRequest(super::transport::SetMaxOutgoingBitrateRequestRef<'a>), + SetMinOutgoingBitrateRequest(super::transport::SetMinOutgoingBitrateRequestRef<'a>), + ProduceRequest(super::transport::ProduceRequestRef<'a>), + ConsumeRequest(super::transport::ConsumeRequestRef<'a>), + ProduceDataRequest(super::transport::ProduceDataRequestRef<'a>), + ConsumeDataRequest(super::transport::ConsumeDataRequestRef<'a>), + EnableTraceEventRequest(super::consumer::EnableTraceEventRequestRef<'a>), + CloseProducerRequest(super::transport::CloseProducerRequestRef<'a>), + CloseConsumerRequest(super::transport::CloseConsumerRequestRef<'a>), + CloseDataProducerRequest(super::transport::CloseDataProducerRequestRef<'a>), + CloseDataConsumerRequest(super::transport::CloseDataConsumerRequestRef<'a>), + ConnectRequest(super::web_rtc_transport::ConnectRequestRef<'a>), + SetPreferredLayersRequest(super::consumer::SetPreferredLayersRequestRef<'a>), + SetPriorityRequest(super::consumer::SetPriorityRequestRef<'a>), + SetBufferedAmountLowThresholdRequest( + super::data_consumer::SetBufferedAmountLowThresholdRequestRef<'a>, + ), + SendRequest(super::data_consumer::SendRequestRef<'a>), + AddProducerRequest(super::rtp_observer::AddProducerRequestRef<'a>), + RemoveProducerRequest(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::UpdateSettingsRequest(value) => { + Self::UpdateSettingsRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreateWebRtcServerRequest(value) => { + Self::CreateWebRtcServerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseWebRtcServerRequest(value) => { + Self::CloseWebRtcServerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreateRouterRequest(value) => { + Self::CreateRouterRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseRouterRequest(value) => { + Self::CloseRouterRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreateWebRtcTransportRequest(value) => { + Self::CreateWebRtcTransportRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreatePlainTransportRequest(value) => { + Self::CreatePlainTransportRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreatePipeTransportRequest(value) => { + Self::CreatePipeTransportRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreateDirectTransportRequest(value) => { + Self::CreateDirectTransportRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreateActiveSpeakerObserverRequest(value) => { + Self::CreateActiveSpeakerObserverRequest( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::CreateAudioLevelObserverRequest(value) => { + Self::CreateAudioLevelObserverRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseTransportRequest(value) => { + Self::CloseTransportRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseRtpObserverRequest(value) => { + Self::CloseRtpObserverRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetMaxIncomingBitrateRequest(value) => { + Self::SetMaxIncomingBitrateRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetMaxOutgoingBitrateRequest(value) => { + Self::SetMaxOutgoingBitrateRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetMinOutgoingBitrateRequest(value) => { + Self::SetMinOutgoingBitrateRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::ProduceRequest(value) => { + Self::ProduceRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::ConsumeRequest(value) => { + Self::ConsumeRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::ProduceDataRequest(value) => { + Self::ProduceDataRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::ConsumeDataRequest(value) => { + Self::ConsumeDataRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::EnableTraceEventRequest(value) => { + Self::EnableTraceEventRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseProducerRequest(value) => { + Self::CloseProducerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseConsumerRequest(value) => { + Self::CloseConsumerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseDataProducerRequest(value) => { + Self::CloseDataProducerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseDataConsumerRequest(value) => { + Self::CloseDataConsumerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::ConnectRequest(value) => { + Self::ConnectRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetPreferredLayersRequest(value) => { + Self::SetPreferredLayersRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetPriorityRequest(value) => { + Self::SetPriorityRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetBufferedAmountLowThresholdRequest(value) => { + Self::SetBufferedAmountLowThresholdRequest( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::SendRequest(value) => { + Self::SendRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::AddProducerRequest(value) => { + Self::AddProducerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::RemoveProducerRequest(value) => { + Self::RemoveProducerRequest(::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::UpdateSettingsRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 2 => ::core::result::Result::Ok(Self::CreateWebRtcServerRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 3 => ::core::result::Result::Ok(Self::CloseWebRtcServerRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 4 => ::core::result::Result::Ok(Self::CreateRouterRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), 5 => ::core::result::Result::Ok(Self::CloseRouterRequest( @@ -29338,17 +52449,31 @@ mod root { } } + /// The table `Request` in the namespace `FBS.Request` + /// + /// Generated from these locations: + /// * Table `Request` in the file `../worker/fbs/request.fbs:119` #[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, @@ -29358,53 +52483,51 @@ mod root { 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::<10, 14>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<14> = + ::core::default::Default::default(); if prepared_id.is_some() { - table_writer.calculate_size::(2); + 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.calculate_size::(4); + table_writer.write_entry::(1); } - table_writer.calculate_size::<::planus::Offset>(6); if prepared_body.is_some() { - table_writer.calculate_size::(8); - table_writer.calculate_size::<::planus::Offset>(10); + table_writer.write_entry::(3); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_id) = prepared_id { - table_writer.write::<_, _, 4>(0, &prepared_id); - } - table_writer.write::<_, _, 4>(2, &prepared_handler_id); - if let ::core::option::Option::Some(prepared_body) = prepared_body { - table_writer.write::<_, _, 4>(4, &prepared_body.offset()); - } - if let ::core::option::Option::Some(prepared_method) = prepared_method { - table_writer.write::<_, _, 1>(1, &prepared_method); - } - if let ::core::option::Option::Some(prepared_body) = prepared_body { - table_writer.write::<_, _, 1>(3, &prepared_body.tag()); - } - } - - table_writer.finish() + 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) } @@ -29413,6 +52536,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Request { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -29422,25 +52546,164 @@ mod root { } 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, - ) + 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 @@ -29449,10 +52712,14 @@ mod root { ) } + /// 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") } @@ -29490,6 +52757,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -29521,6 +52789,7 @@ mod root { 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) } @@ -29557,93 +52826,165 @@ mod root { } } } + /// 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 `FBS_Worker_DumpResponse` in the union `Body` FbsWorkerDumpResponse(::planus::alloc::boxed::Box), + + /// The variant `FBS_Worker_ResourceUsageResponse` in the union `Body` FbsWorkerResourceUsageResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_WebRtcServer_DumpResponse` in the union `Body` FbsWebRtcServerDumpResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_Router_DumpResponse` in the union `Body` FbsRouterDumpResponse(::planus::alloc::boxed::Box), + + /// The variant `FBS_Transport_ProduceResponse` in the union `Body` FbsTransportProduceResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_Transport_ConsumeResponse` in the union `Body` FbsTransportConsumeResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_Transport_RestartIceResponse` in the union `Body` FbsTransportRestartIceResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_PlainTransport_ConnectResponse` in the union `Body` FbsPlainTransportConnectResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_PlainTransport_DumpResponse` in the union `Body` FbsPlainTransportDumpResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_PlainTransport_GetStatsResponse` in the union `Body` FbsPlainTransportGetStatsResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_PipeTransport_ConnectResponse` in the union `Body` FbsPipeTransportConnectResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_PipeTransport_DumpResponse` in the union `Body` FbsPipeTransportDumpResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_PipeTransport_GetStatsResponse` in the union `Body` FbsPipeTransportGetStatsResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_DirectTransport_DumpResponse` in the union `Body` FbsDirectTransportDumpResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_DirectTransport_GetStatsResponse` in the union `Body` FbsDirectTransportGetStatsResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_WebRtcTransport_ConnectResponse` in the union `Body` FbsWebRtcTransportConnectResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_WebRtcTransport_DumpResponse` in the union `Body` FbsWebRtcTransportDumpResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_WebRtcTransport_GetStatsResponse` in the union `Body` FbsWebRtcTransportGetStatsResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_Producer_DumpResponse` in the union `Body` FbsProducerDumpResponse(::planus::alloc::boxed::Box), + + /// The variant `FBS_Producer_GetStatsResponse` in the union `Body` FbsProducerGetStatsResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_Consumer_DumpResponse` in the union `Body` FbsConsumerDumpResponse(::planus::alloc::boxed::Box), + + /// The variant `FBS_Consumer_GetStatsResponse` in the union `Body` FbsConsumerGetStatsResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_Consumer_SetPreferredLayersResponse` in the union `Body` FbsConsumerSetPreferredLayersResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_Consumer_SetPriorityResponse` in the union `Body` FbsConsumerSetPriorityResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_DataProducer_DumpResponse` in the union `Body` FbsDataProducerDumpResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_DataProducer_GetStatsResponse` in the union `Body` FbsDataProducerGetStatsResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_DataConsumer_GetBufferedAmountResponse` in the union `Body` FbsDataConsumerGetBufferedAmountResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_DataConsumer_DumpResponse` in the union `Body` FbsDataConsumerDumpResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_DataConsumer_GetStatsResponse` in the union `Body` FbsDataConsumerGetStatsResponse( ::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_fbs_worker_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29651,6 +52992,7 @@ mod root { ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_worker_resource_usage_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29658,6 +53000,7 @@ mod root { ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_web_rtc_server_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29665,6 +53008,7 @@ mod root { ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_router_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29672,6 +53016,7 @@ mod root { ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_transport_produce_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29679,6 +53024,7 @@ mod root { ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_transport_consume_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29686,6 +53032,7 @@ mod root { ::planus::UnionOffset::new(6, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_transport_restart_ice_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29693,6 +53040,7 @@ mod root { ::planus::UnionOffset::new(7, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_plain_transport_connect_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29700,6 +53048,7 @@ mod root { ::planus::UnionOffset::new(8, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_plain_transport_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29707,6 +53056,7 @@ mod root { ::planus::UnionOffset::new(9, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_plain_transport_get_stats_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29714,6 +53064,7 @@ mod root { ::planus::UnionOffset::new(10, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_pipe_transport_connect_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29721,6 +53072,7 @@ mod root { ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_pipe_transport_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29728,6 +53080,7 @@ mod root { ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_pipe_transport_get_stats_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29735,6 +53088,7 @@ mod root { ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_direct_transport_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29742,6 +53096,7 @@ mod root { ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_direct_transport_get_stats_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29749,6 +53104,7 @@ mod root { ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_web_rtc_transport_connect_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29756,6 +53112,7 @@ mod root { ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_web_rtc_transport_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29763,6 +53120,7 @@ mod root { ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_web_rtc_transport_get_stats_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29770,6 +53128,7 @@ mod root { ::planus::UnionOffset::new(18, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_producer_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29777,6 +53136,7 @@ mod root { ::planus::UnionOffset::new(19, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_producer_get_stats_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29784,6 +53144,7 @@ mod root { ::planus::UnionOffset::new(20, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_consumer_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29791,6 +53152,7 @@ mod root { ::planus::UnionOffset::new(21, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_consumer_get_stats_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29798,6 +53160,7 @@ mod root { ::planus::UnionOffset::new(22, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_consumer_set_preferred_layers_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29805,6 +53168,7 @@ mod root { ::planus::UnionOffset::new(23, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_consumer_set_priority_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29812,6 +53176,7 @@ mod root { ::planus::UnionOffset::new(24, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_data_producer_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29819,6 +53184,7 @@ mod root { ::planus::UnionOffset::new(25, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_data_producer_get_stats_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29826,6 +53192,7 @@ mod root { ::planus::UnionOffset::new(26, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_data_consumer_get_buffered_amount_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29833,6 +53200,7 @@ mod root { ::planus::UnionOffset::new(27, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_data_consumer_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29840,6 +53208,7 @@ mod root { ::planus::UnionOffset::new(28, value.prepare(builder).downcast()) } + #[inline] pub fn create_fbs_data_consumer_get_stats_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -29849,6 +53218,7 @@ mod root { } impl ::planus::WriteAsUnion for Body { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { match self { Self::FbsWorkerDumpResponse(value) => { @@ -29945,6 +53315,7 @@ mod root { } impl ::planus::WriteAsOptionalUnion for Body { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -29953,6 +53324,1014 @@ mod root { } } + /// 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 [`FBS_Worker_DumpResponse` variant](Body#variant.FbsWorkerDumpResponse). + #[inline] + pub fn fbs_worker_dump_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`FBS_Worker_ResourceUsageResponse` variant](Body#variant.FbsWorkerResourceUsageResponse). + #[inline] + pub fn fbs_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 [`FBS_WebRtcServer_DumpResponse` variant](Body#variant.FbsWebRtcServerDumpResponse). + #[inline] + pub fn fbs_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 [`FBS_Router_DumpResponse` variant](Body#variant.FbsRouterDumpResponse). + #[inline] + pub fn fbs_router_dump_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<4, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`FBS_Transport_ProduceResponse` variant](Body#variant.FbsTransportProduceResponse). + #[inline] + pub fn fbs_transport_produce_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<5, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`FBS_Transport_ConsumeResponse` variant](Body#variant.FbsTransportConsumeResponse). + #[inline] + pub fn fbs_transport_consume_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<6, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`FBS_Transport_RestartIceResponse` variant](Body#variant.FbsTransportRestartIceResponse). + #[inline] + pub fn fbs_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 [`FBS_PlainTransport_ConnectResponse` variant](Body#variant.FbsPlainTransportConnectResponse). + #[inline] + pub fn fbs_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 [`FBS_PlainTransport_DumpResponse` variant](Body#variant.FbsPlainTransportDumpResponse). + #[inline] + pub fn fbs_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 [`FBS_PlainTransport_GetStatsResponse` variant](Body#variant.FbsPlainTransportGetStatsResponse). + #[inline] + pub fn fbs_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 [`FBS_PipeTransport_ConnectResponse` variant](Body#variant.FbsPipeTransportConnectResponse). + #[inline] + pub fn fbs_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 [`FBS_PipeTransport_DumpResponse` variant](Body#variant.FbsPipeTransportDumpResponse). + #[inline] + pub fn fbs_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 [`FBS_PipeTransport_GetStatsResponse` variant](Body#variant.FbsPipeTransportGetStatsResponse). + #[inline] + pub fn fbs_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 [`FBS_DirectTransport_DumpResponse` variant](Body#variant.FbsDirectTransportDumpResponse). + #[inline] + pub fn fbs_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 [`FBS_DirectTransport_GetStatsResponse` variant](Body#variant.FbsDirectTransportGetStatsResponse). + #[inline] + pub fn fbs_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 [`FBS_WebRtcTransport_ConnectResponse` variant](Body#variant.FbsWebRtcTransportConnectResponse). + #[inline] + pub fn fbs_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 [`FBS_WebRtcTransport_DumpResponse` variant](Body#variant.FbsWebRtcTransportDumpResponse). + #[inline] + pub fn fbs_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 [`FBS_WebRtcTransport_GetStatsResponse` variant](Body#variant.FbsWebRtcTransportGetStatsResponse). + #[inline] + pub fn fbs_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 [`FBS_Producer_DumpResponse` variant](Body#variant.FbsProducerDumpResponse). + #[inline] + pub fn fbs_producer_dump_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<19, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`FBS_Producer_GetStatsResponse` variant](Body#variant.FbsProducerGetStatsResponse). + #[inline] + pub fn fbs_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 [`FBS_Consumer_DumpResponse` variant](Body#variant.FbsConsumerDumpResponse). + #[inline] + pub fn fbs_consumer_dump_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<21, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`FBS_Consumer_GetStatsResponse` variant](Body#variant.FbsConsumerGetStatsResponse). + #[inline] + pub fn fbs_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 [`FBS_Consumer_SetPreferredLayersResponse` variant](Body#variant.FbsConsumerSetPreferredLayersResponse). + #[inline] + pub fn fbs_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 [`FBS_Consumer_SetPriorityResponse` variant](Body#variant.FbsConsumerSetPriorityResponse). + #[inline] + pub fn fbs_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 [`FBS_DataProducer_DumpResponse` variant](Body#variant.FbsDataProducerDumpResponse). + #[inline] + pub fn fbs_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 [`FBS_DataProducer_GetStatsResponse` variant](Body#variant.FbsDataProducerGetStatsResponse). + #[inline] + pub fn fbs_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 [`FBS_DataConsumer_GetBufferedAmountResponse` variant](Body#variant.FbsDataConsumerGetBufferedAmountResponse). + #[inline] + pub fn fbs_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 [`FBS_DataConsumer_DumpResponse` variant](Body#variant.FbsDataConsumerDumpResponse). + #[inline] + pub fn fbs_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 [`FBS_DataConsumer_GetStatsResponse` variant](Body#variant.FbsDataConsumerGetStatsResponse). + #[inline] + pub fn fbs_data_consumer_get_stats_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<29, 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)) + } + } + + /// Reference to a deserialized [Body]. #[derive(Copy, Clone, Debug)] pub enum BodyRef<'a> { FbsWorkerDumpResponse(super::worker::DumpResponseRef<'a>), @@ -30000,49 +54379,49 @@ mod root { fn try_from(value: BodyRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(match value { BodyRef::FbsWorkerDumpResponse(value) => { - Body::FbsWorkerDumpResponse(::planus::alloc::boxed::Box::new( + Self::FbsWorkerDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsWorkerResourceUsageResponse(value) => { - Body::FbsWorkerResourceUsageResponse(::planus::alloc::boxed::Box::new( + Self::FbsWorkerResourceUsageResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsWebRtcServerDumpResponse(value) => { - Body::FbsWebRtcServerDumpResponse(::planus::alloc::boxed::Box::new( + Self::FbsWebRtcServerDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsRouterDumpResponse(value) => { - Body::FbsRouterDumpResponse(::planus::alloc::boxed::Box::new( + Self::FbsRouterDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsTransportProduceResponse(value) => { - Body::FbsTransportProduceResponse(::planus::alloc::boxed::Box::new( + Self::FbsTransportProduceResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsTransportConsumeResponse(value) => { - Body::FbsTransportConsumeResponse(::planus::alloc::boxed::Box::new( + Self::FbsTransportConsumeResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsTransportRestartIceResponse(value) => { - Body::FbsTransportRestartIceResponse(::planus::alloc::boxed::Box::new( + Self::FbsTransportRestartIceResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsPlainTransportConnectResponse(value) => { - Body::FbsPlainTransportConnectResponse( + Self::FbsPlainTransportConnectResponse( ::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, ), @@ -30050,13 +54429,13 @@ mod root { } BodyRef::FbsPlainTransportDumpResponse(value) => { - Body::FbsPlainTransportDumpResponse(::planus::alloc::boxed::Box::new( + Self::FbsPlainTransportDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsPlainTransportGetStatsResponse(value) => { - Body::FbsPlainTransportGetStatsResponse( + Self::FbsPlainTransportGetStatsResponse( ::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, ), @@ -30064,19 +54443,19 @@ mod root { } BodyRef::FbsPipeTransportConnectResponse(value) => { - Body::FbsPipeTransportConnectResponse(::planus::alloc::boxed::Box::new( + Self::FbsPipeTransportConnectResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsPipeTransportDumpResponse(value) => { - Body::FbsPipeTransportDumpResponse(::planus::alloc::boxed::Box::new( + Self::FbsPipeTransportDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsPipeTransportGetStatsResponse(value) => { - Body::FbsPipeTransportGetStatsResponse( + Self::FbsPipeTransportGetStatsResponse( ::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, ), @@ -30084,13 +54463,13 @@ mod root { } BodyRef::FbsDirectTransportDumpResponse(value) => { - Body::FbsDirectTransportDumpResponse(::planus::alloc::boxed::Box::new( + Self::FbsDirectTransportDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsDirectTransportGetStatsResponse(value) => { - Body::FbsDirectTransportGetStatsResponse( + Self::FbsDirectTransportGetStatsResponse( ::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, ), @@ -30098,7 +54477,7 @@ mod root { } BodyRef::FbsWebRtcTransportConnectResponse(value) => { - Body::FbsWebRtcTransportConnectResponse( + Self::FbsWebRtcTransportConnectResponse( ::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, ), @@ -30106,13 +54485,13 @@ mod root { } BodyRef::FbsWebRtcTransportDumpResponse(value) => { - Body::FbsWebRtcTransportDumpResponse(::planus::alloc::boxed::Box::new( + Self::FbsWebRtcTransportDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsWebRtcTransportGetStatsResponse(value) => { - Body::FbsWebRtcTransportGetStatsResponse( + Self::FbsWebRtcTransportGetStatsResponse( ::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, ), @@ -30120,31 +54499,31 @@ mod root { } BodyRef::FbsProducerDumpResponse(value) => { - Body::FbsProducerDumpResponse(::planus::alloc::boxed::Box::new( + Self::FbsProducerDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsProducerGetStatsResponse(value) => { - Body::FbsProducerGetStatsResponse(::planus::alloc::boxed::Box::new( + Self::FbsProducerGetStatsResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsConsumerDumpResponse(value) => { - Body::FbsConsumerDumpResponse(::planus::alloc::boxed::Box::new( + Self::FbsConsumerDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsConsumerGetStatsResponse(value) => { - Body::FbsConsumerGetStatsResponse(::planus::alloc::boxed::Box::new( + Self::FbsConsumerGetStatsResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsConsumerSetPreferredLayersResponse(value) => { - Body::FbsConsumerSetPreferredLayersResponse( + Self::FbsConsumerSetPreferredLayersResponse( ::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, ), @@ -30152,25 +54531,25 @@ mod root { } BodyRef::FbsConsumerSetPriorityResponse(value) => { - Body::FbsConsumerSetPriorityResponse(::planus::alloc::boxed::Box::new( + Self::FbsConsumerSetPriorityResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsDataProducerDumpResponse(value) => { - Body::FbsDataProducerDumpResponse(::planus::alloc::boxed::Box::new( + Self::FbsDataProducerDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsDataProducerGetStatsResponse(value) => { - Body::FbsDataProducerGetStatsResponse(::planus::alloc::boxed::Box::new( + Self::FbsDataProducerGetStatsResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsDataConsumerGetBufferedAmountResponse(value) => { - Body::FbsDataConsumerGetBufferedAmountResponse( + Self::FbsDataConsumerGetBufferedAmountResponse( ::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, ), @@ -30178,13 +54557,13 @@ mod root { } BodyRef::FbsDataConsumerDumpResponse(value) => { - Body::FbsDataConsumerDumpResponse(::planus::alloc::boxed::Box::new( + Self::FbsDataConsumerDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } BodyRef::FbsDataConsumerGetStatsResponse(value) => { - Body::FbsDataConsumerGetStatsResponse(::planus::alloc::boxed::Box::new( + Self::FbsDataConsumerGetStatsResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -30297,14 +54676,23 @@ mod root { } } + /// The table `Response` in the namespace `FBS.Response` + /// + /// Generated from these locations: + /// * Table `Response` in the file `../worker/fbs/response.fbs:44` #[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>, } @@ -30322,6 +54710,12 @@ mod root { } 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, @@ -30336,65 +54730,64 @@ mod root { >, ) -> ::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::<14, 18>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<16> = + ::core::default::Default::default(); if prepared_id.is_some() { - table_writer.calculate_size::(2); - } - if prepared_accepted.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(0); } if prepared_body.is_some() { - table_writer.calculate_size::(6); - table_writer.calculate_size::<::planus::Offset>(8); + table_writer.write_entry::<::planus::Offset>(3); } if prepared_error.is_some() { - table_writer.calculate_size::<::planus::Offset>(10); + table_writer.write_entry::<::planus::Offset>(4); } if prepared_reason.is_some() { - table_writer.calculate_size::<::planus::Offset>(12); + table_writer.write_entry::<::planus::Offset>(5); } - - table_writer.finish_calculating(); - - unsafe { - if let ::core::option::Option::Some(prepared_id) = prepared_id { - table_writer.write::<_, _, 4>(0, &prepared_id); - } - if let ::core::option::Option::Some(prepared_body) = prepared_body { - table_writer.write::<_, _, 4>(3, &prepared_body.offset()); - } - if let ::core::option::Option::Some(prepared_error) = prepared_error { - table_writer.write::<_, _, 4>(4, &prepared_error); - } - if let ::core::option::Option::Some(prepared_reason) = prepared_reason { - table_writer.write::<_, _, 4>(5, &prepared_reason); - } - if let ::core::option::Option::Some(prepared_accepted) = prepared_accepted { - table_writer.write::<_, _, 1>(1, &prepared_accepted); - } - if let ::core::option::Option::Some(prepared_body) = prepared_body { - table_writer.write::<_, _, 1>(2, &prepared_body.tag()); - } + if prepared_accepted.is_some() { + table_writer.write_entry::(1); + } + if prepared_body.is_some() { + table_writer.write_entry::(2); } - table_writer.finish() + 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) } @@ -30403,6 +54796,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Response { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -30412,11 +54806,12 @@ mod root { } impl ::planus::WriteAsOffset for Response { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { Response::create( builder, - &self.id, - &self.accepted, + self.id, + self.accepted, &self.body, &self.error, &self.reason, @@ -30424,24 +54819,202 @@ mod root { } } + /// 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>> @@ -30449,6 +55022,8 @@ mod root { 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>> @@ -30505,6 +55080,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -30536,6 +55112,7 @@ mod root { 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) } @@ -30572,7 +55149,15 @@ mod root { } } } + /// 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, @@ -30585,13 +55170,21 @@ mod root { ::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, @@ -30604,30 +55197,28 @@ mod root { ) -> ::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::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_channel_request_handlers); - table_writer.write::<_, _, 4>(1, &prepared_channel_notification_handlers); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_channel_request_handlers); + object_writer.write::<_, _, 4>(&prepared_channel_notification_handlers); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for ChannelMessageHandlers { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -30641,6 +55232,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -30651,6 +55243,7 @@ mod root { } impl ::planus::WriteAsOffset for ChannelMessageHandlers { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -30663,10 +55256,116 @@ mod root { } } + /// 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< @@ -30676,6 +55375,8 @@ mod root { .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< @@ -30718,6 +55419,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ChannelMessageHandlersRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -30749,6 +55451,7 @@ mod root { 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) } @@ -30789,6 +55492,10 @@ mod root { } } + /// 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, @@ -30801,14 +55508,24 @@ mod root { ::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, @@ -30822,43 +55539,38 @@ mod root { >, ) -> ::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::<10, 16>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<12> = + ::core::default::Default::default(); if prepared_pid.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(6); - table_writer - .calculate_size::<::planus::Offset>(8); - - table_writer.finish_calculating(); + 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 { - if let ::core::option::Option::Some(prepared_pid) = prepared_pid { - table_writer.write::<_, _, 4>(0, &prepared_pid); - } - table_writer.write::<_, _, 4>(1, &prepared_web_rtc_server_ids); - table_writer.write::<_, _, 4>(2, &prepared_router_ids); - table_writer.write::<_, _, 4>(3, &prepared_channel_message_handlers); + 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); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -30870,6 +55582,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -30879,13 +55592,14 @@ mod root { } impl ::planus::WriteAsOffset for DumpResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { DumpResponse::create( builder, - &self.pid, + self.pid, &self.web_rtc_server_ids, &self.router_ids, &self.channel_message_handlers, @@ -30893,16 +55607,158 @@ mod root { } } + /// 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< @@ -30912,6 +55768,8 @@ mod root { .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< @@ -30920,6 +55778,8 @@ mod root { 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> { @@ -30956,6 +55816,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -30987,6 +55848,7 @@ mod root { 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) } @@ -31023,6 +55885,10 @@ mod root { } } + /// 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, @@ -31035,21 +55901,37 @@ mod root { ::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, } @@ -31078,6 +55960,12 @@ mod root { } 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, @@ -31099,161 +55987,165 @@ mod root { 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::<34, 128>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<36> = + ::core::default::Default::default(); if prepared_ru_utime.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } if prepared_ru_stime.is_some() { - table_writer.calculate_size::(4); + table_writer.write_entry::(1); } if prepared_ru_maxrss.is_some() { - table_writer.calculate_size::(6); + table_writer.write_entry::(2); } if prepared_ru_ixrss.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(3); } if prepared_ru_idrss.is_some() { - table_writer.calculate_size::(10); + table_writer.write_entry::(4); } if prepared_ru_isrss.is_some() { - table_writer.calculate_size::(12); + table_writer.write_entry::(5); } if prepared_ru_minflt.is_some() { - table_writer.calculate_size::(14); + table_writer.write_entry::(6); } if prepared_ru_majflt.is_some() { - table_writer.calculate_size::(16); + table_writer.write_entry::(7); } if prepared_ru_nswap.is_some() { - table_writer.calculate_size::(18); + table_writer.write_entry::(8); } if prepared_ru_inblock.is_some() { - table_writer.calculate_size::(20); + table_writer.write_entry::(9); } if prepared_ru_oublock.is_some() { - table_writer.calculate_size::(22); + table_writer.write_entry::(10); } if prepared_ru_msgsnd.is_some() { - table_writer.calculate_size::(24); + table_writer.write_entry::(11); } if prepared_ru_msgrcv.is_some() { - table_writer.calculate_size::(26); + table_writer.write_entry::(12); } if prepared_ru_nsignals.is_some() { - table_writer.calculate_size::(28); + table_writer.write_entry::(13); } if prepared_ru_nvcsw.is_some() { - table_writer.calculate_size::(30); + table_writer.write_entry::(14); } if prepared_ru_nivcsw.is_some() { - table_writer.calculate_size::(32); + table_writer.write_entry::(15); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_ru_utime) = prepared_ru_utime { - table_writer.write::<_, _, 8>(0, &prepared_ru_utime); - } - if let ::core::option::Option::Some(prepared_ru_stime) = prepared_ru_stime { - table_writer.write::<_, _, 8>(1, &prepared_ru_stime); - } - if let ::core::option::Option::Some(prepared_ru_maxrss) = prepared_ru_maxrss - { - table_writer.write::<_, _, 8>(2, &prepared_ru_maxrss); - } - if let ::core::option::Option::Some(prepared_ru_ixrss) = prepared_ru_ixrss { - table_writer.write::<_, _, 8>(3, &prepared_ru_ixrss); - } - if let ::core::option::Option::Some(prepared_ru_idrss) = prepared_ru_idrss { - table_writer.write::<_, _, 8>(4, &prepared_ru_idrss); - } - if let ::core::option::Option::Some(prepared_ru_isrss) = prepared_ru_isrss { - table_writer.write::<_, _, 8>(5, &prepared_ru_isrss); - } - if let ::core::option::Option::Some(prepared_ru_minflt) = prepared_ru_minflt - { - table_writer.write::<_, _, 8>(6, &prepared_ru_minflt); - } - if let ::core::option::Option::Some(prepared_ru_majflt) = prepared_ru_majflt - { - table_writer.write::<_, _, 8>(7, &prepared_ru_majflt); - } - if let ::core::option::Option::Some(prepared_ru_nswap) = prepared_ru_nswap { - table_writer.write::<_, _, 8>(8, &prepared_ru_nswap); - } - if let ::core::option::Option::Some(prepared_ru_inblock) = - prepared_ru_inblock - { - table_writer.write::<_, _, 8>(9, &prepared_ru_inblock); - } - if let ::core::option::Option::Some(prepared_ru_oublock) = - prepared_ru_oublock - { - table_writer.write::<_, _, 8>(10, &prepared_ru_oublock); - } - if let ::core::option::Option::Some(prepared_ru_msgsnd) = prepared_ru_msgsnd - { - table_writer.write::<_, _, 8>(11, &prepared_ru_msgsnd); - } - if let ::core::option::Option::Some(prepared_ru_msgrcv) = prepared_ru_msgrcv - { - table_writer.write::<_, _, 8>(12, &prepared_ru_msgrcv); - } - if let ::core::option::Option::Some(prepared_ru_nsignals) = - prepared_ru_nsignals - { - table_writer.write::<_, _, 8>(13, &prepared_ru_nsignals); - } - if let ::core::option::Option::Some(prepared_ru_nvcsw) = prepared_ru_nvcsw { - table_writer.write::<_, _, 8>(14, &prepared_ru_nvcsw); - } - if let ::core::option::Option::Some(prepared_ru_nivcsw) = prepared_ru_nivcsw - { - table_writer.write::<_, _, 8>(15, &prepared_ru_nivcsw); - } - } - - table_writer.finish() + 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, @@ -31265,6 +56157,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ResourceUsageResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -31275,36 +56168,873 @@ mod root { } 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, + 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 @@ -31313,6 +57043,8 @@ mod root { ) } + /// Getter for the [`ru_stime` field](ResourceUsageResponse#structfield.ru_stime). + #[inline] pub fn ru_stime(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -31321,6 +57053,8 @@ mod root { ) } + /// Getter for the [`ru_maxrss` field](ResourceUsageResponse#structfield.ru_maxrss). + #[inline] pub fn ru_maxrss(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -31329,6 +57063,8 @@ mod root { ) } + /// Getter for the [`ru_ixrss` field](ResourceUsageResponse#structfield.ru_ixrss). + #[inline] pub fn ru_ixrss(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -31337,6 +57073,8 @@ mod root { ) } + /// Getter for the [`ru_idrss` field](ResourceUsageResponse#structfield.ru_idrss). + #[inline] pub fn ru_idrss(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -31345,6 +57083,8 @@ mod root { ) } + /// Getter for the [`ru_isrss` field](ResourceUsageResponse#structfield.ru_isrss). + #[inline] pub fn ru_isrss(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -31353,6 +57093,8 @@ mod root { ) } + /// Getter for the [`ru_minflt` field](ResourceUsageResponse#structfield.ru_minflt). + #[inline] pub fn ru_minflt(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -31361,6 +57103,8 @@ mod root { ) } + /// Getter for the [`ru_majflt` field](ResourceUsageResponse#structfield.ru_majflt). + #[inline] pub fn ru_majflt(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -31369,6 +57113,8 @@ mod root { ) } + /// Getter for the [`ru_nswap` field](ResourceUsageResponse#structfield.ru_nswap). + #[inline] pub fn ru_nswap(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -31377,6 +57123,8 @@ mod root { ) } + /// Getter for the [`ru_inblock` field](ResourceUsageResponse#structfield.ru_inblock). + #[inline] pub fn ru_inblock(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -31385,6 +57133,8 @@ mod root { ) } + /// Getter for the [`ru_oublock` field](ResourceUsageResponse#structfield.ru_oublock). + #[inline] pub fn ru_oublock(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -31393,6 +57143,8 @@ mod root { ) } + /// Getter for the [`ru_msgsnd` field](ResourceUsageResponse#structfield.ru_msgsnd). + #[inline] pub fn ru_msgsnd(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -31401,6 +57153,8 @@ mod root { ) } + /// Getter for the [`ru_msgrcv` field](ResourceUsageResponse#structfield.ru_msgrcv). + #[inline] pub fn ru_msgrcv(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -31409,6 +57163,8 @@ mod root { ) } + /// Getter for the [`ru_nsignals` field](ResourceUsageResponse#structfield.ru_nsignals). + #[inline] pub fn ru_nsignals(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -31417,6 +57173,8 @@ mod root { ) } + /// Getter for the [`ru_nvcsw` field](ResourceUsageResponse#structfield.ru_nvcsw). + #[inline] pub fn ru_nvcsw(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -31425,6 +57183,8 @@ mod root { ) } + /// Getter for the [`ru_nivcsw` field](ResourceUsageResponse#structfield.ru_nivcsw). + #[inline] pub fn ru_nivcsw(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -31484,6 +57244,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ResourceUsageResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -31515,6 +57276,7 @@ mod root { 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) } @@ -31555,6 +57317,10 @@ mod root { } } + /// 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, @@ -31567,7 +57333,9 @@ mod root { ::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>, >, @@ -31584,6 +57352,12 @@ mod root { } 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, @@ -31595,38 +57369,39 @@ mod root { >, ) -> ::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::<6, 8>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<8> = + ::core::default::Default::default(); if prepared_log_level.is_some() { - table_writer.calculate_size::<::planus::Offset>(2); + table_writer.write_entry::<::planus::Offset>(0); } if prepared_log_tags.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(1); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_log_level) = prepared_log_level - { - table_writer.write::<_, _, 4>(0, &prepared_log_level); - } - if let ::core::option::Option::Some(prepared_log_tags) = prepared_log_tags { - table_writer.write::<_, _, 4>(1, &prepared_log_tags); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for UpdateSettingsRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -31638,6 +57413,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for UpdateSettingsRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -31648,6 +57424,7 @@ mod root { } impl ::planus::WriteAsOffset for UpdateSettingsRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -31656,10 +57433,124 @@ mod root { } } + /// 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>> @@ -31667,6 +57558,8 @@ mod root { 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< @@ -31722,6 +57615,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for UpdateSettingsRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -31753,6 +57647,7 @@ mod root { 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) } @@ -31793,6 +57688,10 @@ mod root { } } + /// 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, @@ -31805,12 +57704,20 @@ mod root { ::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, @@ -31820,37 +57727,35 @@ mod root { >, ) -> ::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::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); + 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.calculate_size::<::planus::Offset< + table_writer.write_entry::<::planus::Offset< [::planus::Offset], - >>(4); + >>(1); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_web_rtc_server_id); - if let ::core::option::Option::Some(prepared_listen_infos) = - prepared_listen_infos - { - table_writer.write::<_, _, 4>(1, &prepared_listen_infos); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for CreateWebRtcServerRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -31864,6 +57769,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -31874,6 +57780,7 @@ mod root { } impl ::planus::WriteAsOffset for CreateWebRtcServerRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -31886,15 +57793,138 @@ mod root { } } + /// 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< @@ -31941,6 +57971,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CreateWebRtcServerRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -31974,6 +58005,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -32014,6 +58046,10 @@ mod root { } } + /// 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, @@ -32026,10 +58062,17 @@ mod root { ::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, @@ -32037,24 +58080,23 @@ mod root { ) -> ::planus::Offset { let prepared_web_rtc_server_id = field_web_rtc_server_id.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_web_rtc_server_id); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_web_rtc_server_id); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for CloseWebRtcServerRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -32068,6 +58110,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -32078,6 +58121,7 @@ mod root { } impl ::planus::WriteAsOffset for CloseWebRtcServerRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -32086,10 +58130,94 @@ mod root { } } + /// 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") @@ -32118,6 +58246,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CloseWebRtcServerRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -32151,6 +58280,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -32191,6 +58321,10 @@ mod root { } } + /// 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, @@ -32203,10 +58337,17 @@ mod root { ::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, @@ -32214,24 +58355,23 @@ mod root { ) -> ::planus::Offset { let prepared_router_id = field_router_id.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_router_id); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_router_id); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for CreateRouterRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -32243,6 +58383,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for CreateRouterRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -32252,6 +58393,7 @@ mod root { } impl ::planus::WriteAsOffset for CreateRouterRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -32260,10 +58402,89 @@ mod root { } } + /// 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") @@ -32290,6 +58511,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CreateRouterRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -32321,6 +58543,7 @@ mod root { 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) } @@ -32361,6 +58584,10 @@ mod root { } } + /// 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, @@ -32373,10 +58600,17 @@ mod root { ::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, @@ -32384,24 +58618,23 @@ mod root { ) -> ::planus::Offset { let prepared_router_id = field_router_id.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_router_id); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_router_id); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for CloseRouterRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -32413,6 +58646,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for CloseRouterRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -32422,6 +58656,7 @@ mod root { } impl ::planus::WriteAsOffset for CloseRouterRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -32430,10 +58665,89 @@ mod root { } } + /// 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") } @@ -32459,6 +58773,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CloseRouterRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -32490,6 +58805,7 @@ mod root { 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) } @@ -32526,7 +58842,15 @@ mod root { } } } + /// 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, @@ -32539,22 +58863,36 @@ mod root { ::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, @@ -32582,66 +58920,58 @@ mod root { >, ) -> ::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::<18, 32>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(4); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(6); - table_writer.calculate_size::<::planus::Offset< + 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], - >>(8); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(10); - table_writer.calculate_size::<::planus::Offset< + >>(3); + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(4); + table_writer.write_entry::<::planus::Offset< [::planus::Offset], - >>(12); - table_writer.calculate_size::<::planus::Offset< + >>(5); + table_writer.write_entry::<::planus::Offset< [::planus::Offset], - >>(14); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(16); - - table_writer.finish_calculating(); + >>(6); + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(7); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_id); - table_writer.write::<_, _, 4>(1, &prepared_transport_ids); - table_writer.write::<_, _, 4>(2, &prepared_rtp_observer_ids); - table_writer.write::<_, _, 4>(3, &prepared_map_producer_id_consumer_ids); - table_writer.write::<_, _, 4>(4, &prepared_map_consumer_id_producer_id); - table_writer.write::<_, _, 4>(5, &prepared_map_producer_id_observer_ids); - table_writer - .write::<_, _, 4>(6, &prepared_map_data_producer_id_data_consumer_ids); - table_writer - .write::<_, _, 4>(7, &prepared_map_data_consumer_id_data_producer_id); + 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); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -32653,6 +58983,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -32662,6 +58993,7 @@ mod root { } impl ::planus::WriteAsOffset for DumpResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -32680,14 +59012,266 @@ mod root { } } + /// 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< @@ -32696,6 +59280,8 @@ mod root { 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< @@ -32705,6 +59291,8 @@ mod root { .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< @@ -32714,6 +59302,8 @@ mod root { .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< @@ -32723,6 +59313,8 @@ mod root { .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< @@ -32732,6 +59324,8 @@ mod root { .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< @@ -32744,6 +59338,8 @@ mod root { ) } + /// 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< @@ -32816,6 +59412,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -32847,6 +59444,7 @@ mod root { 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) } @@ -32883,6 +59481,10 @@ mod root { } } + /// 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, @@ -32895,12 +59497,20 @@ mod root { ::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, @@ -32910,23 +59520,20 @@ mod root { >, ) -> ::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::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_transport_id); - table_writer.write::<_, _, 4>(1, &prepared_options); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_transport_id); + object_writer.write::<_, _, 4>(&prepared_options); + }); } - - table_writer.finish() + builder.current_offset() } } @@ -32935,6 +59542,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -32948,6 +59556,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -32958,6 +59567,7 @@ mod root { } impl ::planus::WriteAsOffset for CreatePipeTransportRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -32966,15 +59576,126 @@ mod root { } } + /// 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> @@ -33010,6 +59731,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CreatePipeTransportRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -33043,6 +59765,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -33083,6 +59806,10 @@ mod root { } } + /// 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, @@ -33095,12 +59822,20 @@ mod root { ::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, @@ -33110,23 +59845,20 @@ mod root { >, ) -> ::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::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_transport_id); - table_writer.write::<_, _, 4>(1, &prepared_options); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_transport_id); + object_writer.write::<_, _, 4>(&prepared_options); + }); } - - table_writer.finish() + builder.current_offset() } } @@ -33135,6 +59867,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -33148,6 +59881,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -33158,6 +59892,7 @@ mod root { } impl ::planus::WriteAsOffset for CreatePlainTransportRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -33166,15 +59901,129 @@ mod root { } } + /// 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> @@ -33210,6 +60059,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CreatePlainTransportRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -33243,6 +60093,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -33283,6 +60134,10 @@ mod root { } } + /// 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, @@ -33295,12 +60150,20 @@ mod root { ::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, @@ -33310,23 +60173,20 @@ mod root { >, ) -> ::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::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_transport_id); - table_writer.write::<_, _, 4>(1, &prepared_options); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_transport_id); + object_writer.write::<_, _, 4>(&prepared_options); + }); } - - table_writer.finish() + builder.current_offset() } } @@ -33335,6 +60195,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -33348,6 +60209,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -33358,6 +60220,7 @@ mod root { } impl ::planus::WriteAsOffset for CreateWebRtcTransportRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -33366,15 +60229,129 @@ mod root { } } + /// 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> @@ -33410,6 +60387,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CreateWebRtcTransportRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -33443,6 +60421,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -33483,6 +60462,10 @@ mod root { } } + /// 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, @@ -33495,12 +60478,20 @@ mod root { ::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, @@ -33510,23 +60501,20 @@ mod root { >, ) -> ::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::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_transport_id); - table_writer.write::<_, _, 4>(1, &prepared_options); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_transport_id); + object_writer.write::<_, _, 4>(&prepared_options); + }); } - - table_writer.finish() + builder.current_offset() } } @@ -33535,6 +60523,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -33548,6 +60537,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -33558,6 +60548,7 @@ mod root { } impl ::planus::WriteAsOffset for CreateDirectTransportRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -33566,15 +60557,129 @@ mod root { } } + /// 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> @@ -33610,6 +60715,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CreateDirectTransportRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -33643,6 +60749,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -33683,6 +60790,10 @@ mod root { } } + /// 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, @@ -33695,13 +60806,21 @@ mod root { ::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, @@ -33711,25 +60830,22 @@ mod root { >, ) -> ::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::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset< + 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, - >>(4); - - table_writer.finish_calculating(); + >>(1); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_rtp_observer_id); - table_writer.write::<_, _, 4>(1, &prepared_options); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_rtp_observer_id); + object_writer.write::<_, _, 4>(&prepared_options); + }); } - - table_writer.finish() + builder.current_offset() } } @@ -33738,6 +60854,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -33751,6 +60868,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -33761,6 +60879,7 @@ mod root { } impl ::planus::WriteAsOffset for CreateAudioLevelObserverRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -33773,15 +60892,132 @@ mod root { } } + /// 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> @@ -33821,6 +61057,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CreateAudioLevelObserverRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -33854,6 +61091,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -33894,6 +61132,10 @@ mod root { } } + /// 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, @@ -33906,13 +61148,21 @@ mod root { ::serde::Deserialize, )] pub struct CreateActiveSpeakerObserverRequest { + /// The field `active_speaker_observer_id` in the table `CreateActiveSpeakerObserverRequest` pub active_speaker_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, @@ -33925,25 +61175,22 @@ mod root { ) -> ::planus::Offset { let prepared_active_speaker_observer_id = field_active_speaker_observer_id.prepare(builder); - let prepared_options = field_options.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset< + 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, - >>(4); - - table_writer.finish_calculating(); + >>(1); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_active_speaker_observer_id); - table_writer.write::<_, _, 4>(1, &prepared_options); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_active_speaker_observer_id); + object_writer.write::<_, _, 4>(&prepared_options); + }); } - - table_writer.finish() + builder.current_offset() } } @@ -33952,6 +61199,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -33965,6 +61213,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -33977,6 +61226,7 @@ mod root { impl ::planus::WriteAsOffset for CreateActiveSpeakerObserverRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -33989,10 +61239,134 @@ mod root { } } + /// 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 [`active_speaker_observer_id` field](CreateActiveSpeakerObserverRequest#structfield.active_speaker_observer_id). + #[inline] + #[allow(clippy::type_complexity)] + pub fn active_speaker_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 [`active_speaker_observer_id` field](CreateActiveSpeakerObserverRequest#structfield.active_speaker_observer_id). + #[inline] pub fn active_speaker_observer_id( &self, ) -> ::planus::Result<&'a ::core::primitive::str> { @@ -34003,6 +61377,8 @@ mod root { ) } + /// Getter for the [`options` field](CreateActiveSpeakerObserverRequest#structfield.options). + #[inline] pub fn options( &self, ) -> ::planus::Result< @@ -34046,6 +61422,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CreateActiveSpeakerObserverRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -34079,6 +61456,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -34119,6 +61497,10 @@ mod root { } } + /// 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, @@ -34131,10 +61513,17 @@ mod root { ::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, @@ -34142,24 +61531,23 @@ mod root { ) -> ::planus::Offset { let prepared_transport_id = field_transport_id.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_transport_id); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_transport_id); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for CloseTransportRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -34171,6 +61559,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for CloseTransportRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -34181,6 +61570,7 @@ mod root { } impl ::planus::WriteAsOffset for CloseTransportRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -34189,10 +61579,91 @@ mod root { } } + /// 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") @@ -34219,6 +61690,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CloseTransportRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -34250,6 +61722,7 @@ mod root { 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) } @@ -34290,6 +61763,10 @@ mod root { } } + /// 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, @@ -34302,10 +61779,17 @@ mod root { ::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, @@ -34313,24 +61797,23 @@ mod root { ) -> ::planus::Offset { let prepared_rtp_observer_id = field_rtp_observer_id.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_rtp_observer_id); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_rtp_observer_id); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for CloseRtpObserverRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -34344,6 +61827,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -34354,6 +61838,7 @@ mod root { } impl ::planus::WriteAsOffset for CloseRtpObserverRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -34362,10 +61847,91 @@ mod root { } } + /// 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") @@ -34394,6 +61960,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for CloseRtpObserverRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -34425,6 +61992,7 @@ mod root { 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) } @@ -34465,7 +62033,15 @@ mod root { } } } + /// 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, @@ -34478,11 +62054,19 @@ mod root { ::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, @@ -34490,33 +62074,31 @@ mod root { 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::<6, 6>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); + 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.calculate_size::(4); + table_writer.write_entry::(1); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_ip); - if let ::core::option::Option::Some(prepared_port) = prepared_port { - table_writer.write::<_, _, 2>(1, &prepared_port); - } + 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); + } + }); } - - table_writer.finish() + 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) } @@ -34525,6 +62107,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for IpPort { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -34534,19 +62117,116 @@ mod root { } impl ::planus::WriteAsOffset for IpPort { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - IpPort::create(builder, &self.ip, &self.port) + 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)) } @@ -34574,6 +62254,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for IpPortRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -34605,6 +62286,7 @@ mod root { 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) } @@ -34641,6 +62323,10 @@ mod root { } } + /// 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, @@ -34653,11 +62339,19 @@ mod root { ::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, @@ -34666,29 +62360,27 @@ mod root { ) -> ::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::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_local_ice_username_fragment); - table_writer.write::<_, _, 4>(1, &prepared_web_rtc_transport_id); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_local_ice_username_fragment); + object_writer.write::<_, _, 4>(&prepared_web_rtc_transport_id); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for IceUserNameFragment { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -34700,6 +62392,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for IceUserNameFragment { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -34709,6 +62402,7 @@ mod root { } impl ::planus::WriteAsOffset for IceUserNameFragment { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -34721,10 +62415,115 @@ mod root { } } + /// 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> { @@ -34732,6 +62531,8 @@ mod root { .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") @@ -34767,6 +62568,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for IceUserNameFragmentRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -34798,6 +62600,7 @@ mod root { 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) } @@ -34838,6 +62641,10 @@ mod root { } } + /// 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, @@ -34850,11 +62657,19 @@ mod root { ::serde::Deserialize, )] pub struct TupleHash { + /// The field `local_ice_username_fragment` in the table `TupleHash` pub local_ice_username_fragment: 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, @@ -34863,35 +62678,35 @@ mod root { ) -> ::planus::Offset { let prepared_local_ice_username_fragment = field_local_ice_username_fragment.prepare(builder, &0); - let prepared_web_rtc_transport_id = field_web_rtc_transport_id.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<6, 12>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<8> = + ::core::default::Default::default(); if prepared_local_ice_username_fragment.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.calculate_size::<::planus::Offset>(4); - - table_writer.finish_calculating(); + table_writer.write_entry::<::planus::Offset>(1); unsafe { - if let ::core::option::Option::Some(prepared_local_ice_username_fragment) = - prepared_local_ice_username_fragment - { - table_writer.write::<_, _, 8>(0, &prepared_local_ice_username_fragment); - } - table_writer.write::<_, _, 4>(1, &prepared_web_rtc_transport_id); + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some( + prepared_local_ice_username_fragment, + ) = prepared_local_ice_username_fragment + { + object_writer + .write::<_, _, 8>(&prepared_local_ice_username_fragment); + } + object_writer.write::<_, _, 4>(&prepared_web_rtc_transport_id); + }); } - - table_writer.finish() + 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) } @@ -34900,6 +62715,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for TupleHash { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -34909,19 +62725,117 @@ mod root { } impl ::planus::WriteAsOffset for TupleHash { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { TupleHash::create( builder, - &self.local_ice_username_fragment, + self.local_ice_username_fragment, &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 [`local_ice_username_fragment` field](TupleHash#structfield.local_ice_username_fragment). + #[inline] + #[allow(clippy::type_complexity)] + pub fn local_ice_username_fragment(self, value: T0) -> TupleHashBuilder<(T0,)> + where + T0: ::planus::WriteAsDefault, + { + TupleHashBuilder((value,)) + } + + /// Sets the [`local_ice_username_fragment` field](TupleHash#structfield.local_ice_username_fragment) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn local_ice_username_fragment_as_default( + self, + ) -> TupleHashBuilder<(::planus::DefaultValue,)> { + self.local_ice_username_fragment(::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 [`local_ice_username_fragment` field](TupleHash#structfield.local_ice_username_fragment). + #[inline] pub fn local_ice_username_fragment(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -34930,6 +62844,8 @@ mod root { ) } + /// 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") @@ -34965,6 +62881,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for TupleHashRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -34996,6 +62913,7 @@ mod root { 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) } @@ -35032,6 +62950,10 @@ mod root { } } + /// 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, @@ -35044,17 +62966,29 @@ mod root { ::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, @@ -35076,52 +63010,44 @@ mod root { >, ) -> ::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::<14, 24>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); + let mut table_writer: ::planus::table_writer::TableWriter<16> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); table_writer - .calculate_size::<::planus::Offset<[::planus::Offset]>>(4); + .write_entry::<::planus::Offset<[::planus::Offset]>>(1); table_writer - .calculate_size::<::planus::Offset<[::planus::Offset]>>(6); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(8); - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(10); + .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 - .calculate_size::<::planus::Offset<[::planus::Offset]>>( - 12, - ); - - table_writer.finish_calculating(); + .write_entry::<::planus::Offset<[::planus::Offset]>>(5); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_id); - table_writer.write::<_, _, 4>(1, &prepared_udp_sockets); - table_writer.write::<_, _, 4>(2, &prepared_tcp_servers); - table_writer.write::<_, _, 4>(3, &prepared_web_rtc_transport_ids); - table_writer.write::<_, _, 4>(4, &prepared_local_ice_username_fragments); - table_writer.write::<_, _, 4>(5, &prepared_tuple_hashes); + 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); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -35133,6 +63059,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -35142,6 +63069,7 @@ mod root { } impl ::planus::WriteAsOffset for DumpResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -35158,14 +63086,196 @@ mod root { } } + /// 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>>> @@ -35173,6 +63283,8 @@ mod root { 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>>> @@ -35180,6 +63292,8 @@ mod root { 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< @@ -35189,6 +63303,8 @@ mod root { .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< @@ -35198,6 +63314,8 @@ mod root { .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>>> @@ -35241,6 +63359,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -35272,6 +63391,7 @@ mod root { 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) } @@ -35308,7 +63428,15 @@ mod root { } } } + /// The namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * File `../worker/fbs/producer.fbs` pub mod producer { + /// The table `EnableTraceEventRequest` in the namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/producer.fbs:6` #[derive( Clone, Debug, @@ -35321,10 +63449,17 @@ mod root { ::serde::Deserialize, )] pub struct EnableTraceEventRequest { + /// The field `events` in the table `EnableTraceEventRequest` pub events: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, } 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, @@ -35332,24 +63467,23 @@ mod root { ) -> ::planus::Offset { let prepared_events = field_events.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_events); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_events); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for EnableTraceEventRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -35363,6 +63497,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -35373,6 +63508,7 @@ mod root { } impl ::planus::WriteAsOffset for EnableTraceEventRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -35381,10 +63517,91 @@ mod root { } } + /// 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<[::planus::Offset]>>, + { + 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< @@ -35415,6 +63632,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for EnableTraceEventRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -35446,6 +63664,7 @@ mod root { 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) } @@ -35486,23 +63705,41 @@ mod root { } } + /// The table `DumpResponse` in the namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * Table `DumpResponse` in the file `../worker/fbs/producer.fbs:10` #[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_: ::planus::alloc::string::String, + /// 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: ::core::option::Option<::planus::alloc::vec::Vec>, + /// The field `trace_event_types` in the table `DumpResponse` pub trace_event_types: ::planus::alloc::vec::Vec<::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, @@ -35527,72 +63764,62 @@ mod root { 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::All); - let prepared_type_ = field_type_.prepare(builder); - 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::<18, 26>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - if prepared_kind.is_some() { - table_writer.calculate_size::(4); - } - table_writer.calculate_size::<::planus::Offset>(6); + 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 - .calculate_size::<::planus::Offset>( - 8, - ); + .write_entry::<::planus::Offset>(3); table_writer - .calculate_size::<::planus::Offset>(10); + .write_entry::<::planus::Offset>(4); if prepared_rtp_streams.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(12); + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(5); + } + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(6); + if prepared_kind.is_some() { + table_writer.write_entry::(1); } - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(14); if prepared_paused.is_some() { - table_writer.calculate_size::(16); + table_writer.write_entry::(7); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_id); - table_writer.write::<_, _, 4>(2, &prepared_type_); - table_writer.write::<_, _, 4>(3, &prepared_rtp_parameters); - table_writer.write::<_, _, 4>(4, &prepared_rtp_mapping); - if let ::core::option::Option::Some(prepared_rtp_streams) = - prepared_rtp_streams - { - table_writer.write::<_, _, 4>(5, &prepared_rtp_streams); - } - table_writer.write::<_, _, 4>(6, &prepared_trace_event_types); - if let ::core::option::Option::Some(prepared_kind) = prepared_kind { - table_writer.write::<_, _, 1>(1, &prepared_kind); - } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - table_writer.write::<_, _, 1>(7, &prepared_paused); - } - } - - table_writer.finish() + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_id); + object_writer.write::<_, _, 4>(&prepared_type_); + object_writer.write::<_, _, 4>(&prepared_rtp_parameters); + object_writer.write::<_, _, 4>(&prepared_rtp_mapping); + if let ::core::option::Option::Some(prepared_rtp_streams) = + prepared_rtp_streams + { + 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_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, @@ -35604,6 +63831,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -35613,6 +63841,7 @@ mod root { } impl ::planus::WriteAsOffset for DumpResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -35620,25 +63849,275 @@ mod root { DumpResponse::create( builder, &self.id, - &self.kind, + self.kind, &self.type_, &self.rtp_parameters, &self.rtp_mapping, &self.rtp_streams, &self.trace_event_types, - &self.paused, + 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::WriteAs<::planus::Offset>, + { + let (v0, v1) = self.0; + DumpResponseBuilder((v0, v1, value)) + } + } + + 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::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + { + let (v0, v1, v2, v3, v4) = self.0; + DumpResponseBuilder((v0, v1, v2, v3, v4, value)) + } + + /// Sets the [`rtp_streams` field](DumpResponse#structfield.rtp_streams) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn rtp_streams_as_null(self) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, ())> { + self.rtp_streams(()) + } + } + + 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<[::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 [`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::WriteAs<::planus::Offset>, + T3: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAs<::planus::Offset>, + T5: ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + T6: ::planus::WriteAs<::planus::Offset<[::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< + super::rtp_parameters::MediaKind, + super::rtp_parameters::MediaKind, + >, + T2: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAs<::planus::Offset>, + T5: ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + T6: ::planus::WriteAs<::planus::Offset<[::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< + super::rtp_parameters::MediaKind, + super::rtp_parameters::MediaKind, + >, + T2: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAs<::planus::Offset>, + T5: ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + T6: ::planus::WriteAs<::planus::Offset<[::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 [`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 @@ -35647,22 +64126,30 @@ mod root { ) } + /// Getter for the [`type` field](DumpResponse#structfield.type_). + #[inline] pub fn type_(&self) -> ::planus::Result<&'a ::core::primitive::str> { self.0.access_required(2, "DumpResponse", "type_") } + /// 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< @@ -35673,6 +64160,8 @@ mod root { self.0.access(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< @@ -35682,6 +64171,8 @@ mod root { .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), @@ -35737,6 +64228,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -35768,6 +64260,7 @@ mod root { 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) } @@ -35804,10 +64297,15 @@ mod root { } } + /// The table `GetStatsResponse` in the namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * Table `GetStatsResponse` in the file `../worker/fbs/producer.fbs:21` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct GetStatsResponse { + /// The field `stats` in the table `GetStatsResponse` pub stats: ::core::option::Option<::planus::alloc::vec::Vec>, } @@ -35822,6 +64320,12 @@ mod root { } 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, @@ -35831,28 +64335,27 @@ mod root { ) -> ::planus::Offset { let prepared_stats = field_stats.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_stats.is_some() { - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_stats) = prepared_stats { - table_writer.write::<_, _, 4>(0, &prepared_stats); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_stats) = prepared_stats { + object_writer.write::<_, _, 4>(&prepared_stats); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -35864,6 +64367,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -35873,6 +64377,7 @@ mod root { } impl ::planus::WriteAsOffset for GetStatsResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -35881,10 +64386,107 @@ mod root { } } + /// 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::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + { + GetStatsResponseBuilder((value,)) + } + + /// Sets the [`stats` field](GetStatsResponse#structfield.stats) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn stats_as_null(self) -> GetStatsResponseBuilder<((),)> { + self.stats(()) + } + } + + 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::WriteAsOptional< + ::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::WriteAsOptional< + ::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::WriteAsOptional< + ::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< @@ -35922,6 +64524,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -35953,6 +64556,7 @@ mod root { 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) } @@ -35989,6 +64593,10 @@ mod root { } } + /// The table `SendNotification` in the namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * Table `SendNotification` in the file `../worker/fbs/producer.fbs:25` #[derive( Clone, Debug, @@ -36001,10 +64609,17 @@ mod root { ::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, @@ -36012,24 +64627,23 @@ mod root { ) -> ::planus::Offset { let prepared_data = field_data.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset<[u8]>>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset<[u8]>>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_data); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_data); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for SendNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -36041,6 +64655,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for SendNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -36050,6 +64665,7 @@ mod root { } impl ::planus::WriteAsOffset for SendNotification { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -36058,11 +64674,90 @@ mod root { } } + /// 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> { - pub fn data(&self) -> ::planus::Result<::planus::Vector<'a, u8>> { + /// Getter for the [`data` field](SendNotification#structfield.data). + #[inline] + pub fn data(&self) -> ::planus::Result<&'a [u8]> { self.0.access_required(0, "SendNotification", "data") } } @@ -36081,12 +64776,13 @@ mod root { #[allow(unreachable_code)] fn try_from(value: SendNotificationRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - data: value.data()?.to_vec()?, + data: value.data()?.to_vec(), }) } } impl<'a> ::planus::TableRead<'a> for SendNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -36118,6 +64814,7 @@ mod root { 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) } @@ -36154,6 +64851,10 @@ mod root { } } + /// The table `Score` in the namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * Table `Score` in the file `../worker/fbs/producer.fbs:31` #[derive( Clone, Debug, @@ -36166,8 +64867,11 @@ mod root { ::serde::Deserialize, )] pub struct Score { + /// 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, } @@ -36183,6 +64887,12 @@ mod root { } 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, @@ -36191,45 +64901,42 @@ mod root { field_score: impl ::planus::WriteAsDefault, ) -> ::planus::Offset { 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::<8, 9>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<10> = + ::core::default::Default::default(); if prepared_ssrc.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } if prepared_rid.is_some() { - table_writer.calculate_size::<::planus::Offset>(4); + table_writer.write_entry::<::planus::Offset>(1); } if prepared_score.is_some() { - table_writer.calculate_size::(6); + table_writer.write_entry::(2); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - table_writer.write::<_, _, 4>(0, &prepared_ssrc); - } - if let ::core::option::Option::Some(prepared_rid) = prepared_rid { - table_writer.write::<_, _, 4>(1, &prepared_rid); - } - if let ::core::option::Option::Some(prepared_score) = prepared_score { - table_writer.write::<_, _, 1>(2, &prepared_score); - } + 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_score) = prepared_score { + object_writer.write::<_, _, 1>(&prepared_score); + } + }); } - - table_writer.finish() + 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) } @@ -36238,6 +64945,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Score { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -36247,19 +64955,147 @@ mod root { } impl ::planus::WriteAsOffset for Score { + #[inline] + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Score::create(builder, 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 [`ssrc` field](Score#structfield.ssrc). + #[inline] + #[allow(clippy::type_complexity)] + pub fn ssrc(self, value: T0) -> ScoreBuilder<(T0,)> + where + T0: ::planus::WriteAsDefault, + { + ScoreBuilder((value,)) + } + + /// Sets the [`ssrc` field](Score#structfield.ssrc) to the default value. + #[inline] + #[allow(clippy::type_complexity)] + pub fn ssrc_as_default(self) -> ScoreBuilder<(::planus::DefaultValue,)> { + self.ssrc(::planus::DefaultValue) + } + } + + impl ScoreBuilder<(T0,)> { + /// Setter for the [`rid` field](Score#structfield.rid). + #[inline] + #[allow(clippy::type_complexity)] + pub fn rid(self, value: T1) -> ScoreBuilder<(T0, T1)> + where + T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + { + let (v0,) = self.0; + ScoreBuilder((v0, value)) + } + + /// Sets the [`rid` field](Score#structfield.rid) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn rid_as_null(self) -> ScoreBuilder<(T0, ())> { + self.rid(()) + } + } + + impl ScoreBuilder<(T0, T1)> { + /// Setter for the [`score` field](Score#structfield.score). + #[inline] + #[allow(clippy::type_complexity)] + pub fn score(self, value: T2) -> ScoreBuilder<(T0, T1, T2)> + where + T2: ::planus::WriteAsDefault, + { + let (v0, v1) = self.0; + ScoreBuilder((v0, v1, 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, ::planus::DefaultValue)> { + self.score(::planus::DefaultValue) + } + } + + impl ScoreBuilder<(T0, T1, T2)> { + /// 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::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T2: ::planus::WriteAsDefault, + > ::planus::WriteAs<::planus::Offset> for ScoreBuilder<(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::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T2: ::planus::WriteAsDefault, + > ::planus::WriteAsOptional<::planus::Offset> + for ScoreBuilder<(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::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T2: ::planus::WriteAsDefault, + > ::planus::WriteAsOffset for ScoreBuilder<(T0, T1, T2)> + { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Score::create(builder, &self.ssrc, &self.rid, &self.score) + let (v0, v1, v2) = &self.0; + Score::create(builder, v0, v1, v2) } } + /// Reference to a deserialized [Score]. #[derive(Copy, Clone)] pub struct ScoreRef<'a>(::planus::table_reader::Table<'a>); impl<'a> ScoreRef<'a> { + /// Getter for the [`ssrc` field](Score#structfield.ssrc). + #[inline] pub fn ssrc(&self) -> ::planus::Result { ::core::result::Result::Ok(self.0.access(0, "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>> @@ -36267,6 +65103,8 @@ mod root { self.0.access(1, "Score", "rid") } + /// Getter for the [`score` field](Score#structfield.score). + #[inline] pub fn score(&self) -> ::planus::Result { ::core::result::Result::Ok(self.0.access(2, "Score", "score")?.unwrap_or(0)) } @@ -36302,6 +65140,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ScoreRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -36333,6 +65172,7 @@ mod root { 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) } @@ -36369,6 +65209,10 @@ mod root { } } + /// The table `ScoreNotification` in the namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * Table `ScoreNotification` in the file `../worker/fbs/producer.fbs:37` #[derive( Clone, Debug, @@ -36381,6 +65225,7 @@ mod root { ::serde::Deserialize, )] pub struct ScoreNotification { + /// The field `scores` in the table `ScoreNotification` pub scores: ::core::option::Option<::planus::alloc::vec::Vec>, } @@ -36394,6 +65239,12 @@ mod root { } 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, @@ -36403,29 +65254,28 @@ mod root { ) -> ::planus::Offset { let prepared_scores = field_scores.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_scores.is_some() { table_writer - .calculate_size::<::planus::Offset<[::planus::Offset]>>(2); + .write_entry::<::planus::Offset<[::planus::Offset]>>(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_scores) = prepared_scores { - table_writer.write::<_, _, 4>(0, &prepared_scores); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_scores) = prepared_scores { + object_writer.write::<_, _, 4>(&prepared_scores); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for ScoreNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -36437,6 +65287,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ScoreNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -36446,6 +65297,7 @@ mod root { } impl ::planus::WriteAsOffset for ScoreNotification { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -36454,10 +65306,101 @@ mod root { } } + /// 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::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + { + ScoreNotificationBuilder((value,)) + } + + /// Sets the [`scores` field](ScoreNotification#structfield.scores) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn scores_as_null(self) -> ScoreNotificationBuilder<((),)> { + self.scores(()) + } + } + + 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< + T0: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, + > ::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< + T0: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, + > ::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< + T0: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, + > ::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< @@ -36495,6 +65438,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ScoreNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -36526,6 +65470,7 @@ mod root { 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) } @@ -36562,6 +65507,10 @@ mod root { } } + /// The table `VideoOrientationChangeNotification` in the namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * Table `VideoOrientationChangeNotification` in the file `../worker/fbs/producer.fbs:41` #[derive( Clone, Debug, @@ -36574,8 +65523,11 @@ mod root { ::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, } @@ -36591,6 +65543,12 @@ mod root { } 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, @@ -36599,39 +65557,37 @@ mod root { 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::<8, 4>::new(builder); - + 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.calculate_size::(2); + table_writer.write_entry::(0); } if prepared_flip.is_some() { - table_writer.calculate_size::(4); - } - if prepared_rotation.is_some() { - table_writer.calculate_size::(6); + table_writer.write_entry::(1); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_rotation) = prepared_rotation { - table_writer.write::<_, _, 2>(2, &prepared_rotation); - } - if let ::core::option::Option::Some(prepared_camera) = prepared_camera { - table_writer.write::<_, _, 1>(0, &prepared_camera); - } - if let ::core::option::Option::Some(prepared_flip) = prepared_flip { - table_writer.write::<_, _, 1>(1, &prepared_flip); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } @@ -36640,6 +65596,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -36653,6 +65610,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -36665,23 +65623,181 @@ mod root { impl ::planus::WriteAsOffset for VideoOrientationChangeNotification { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { VideoOrientationChangeNotification::create( builder, - &self.camera, - &self.flip, - &self.rotation, + 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 @@ -36690,6 +65806,8 @@ mod root { ) } + /// Getter for the [`flip` field](VideoOrientationChangeNotification#structfield.flip). + #[inline] pub fn flip(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -36698,6 +65816,8 @@ mod root { ) } + /// Getter for the [`rotation` field](VideoOrientationChangeNotification#structfield.rotation). + #[inline] pub fn rotation(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -36735,6 +65855,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for VideoOrientationChangeNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -36768,6 +65889,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -36808,6 +65930,10 @@ mod root { } } + /// The enum `TraceType` in the namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * Enum `TraceType` in the file `../worker/fbs/producer.fbs:47` #[derive( Copy, Clone, @@ -36822,15 +65948,31 @@ mod root { )] #[repr(u8)] pub enum TraceType { + /// The variant `KEYFRAME` in the enum `TraceType` Keyframe = 0, + + /// The variant `FIR` in the enum `TraceType` Fir = 1, + + /// The variant `NACK` in the enum `TraceType` Nack = 2, + + /// The variant `PLI` in the enum `TraceType` Pli = 3, + + /// The variant `RTP` in the enum `TraceType` Rtp = 4, } + impl TraceType { + /// Array containing all valid variants of TraceType + pub const ENUM_VALUES: [Self; 5] = + [Self::Keyframe, Self::Fir, Self::Nack, Self::Pli, Self::Rtp]; + } + impl ::core::convert::TryFrom for TraceType { type Error = ::planus::errors::UnknownEnumTagKind; + #[inline] fn try_from( value: u8, ) -> ::core::result::Result @@ -36851,6 +65993,7 @@ mod root { } impl ::core::convert::From for u8 { + #[inline] fn from(value: TraceType) -> Self { value as u8 } @@ -36911,6 +66054,7 @@ mod root { } impl<'buf> ::planus::TableRead<'buf> for TraceType { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, @@ -36929,7 +66073,7 @@ mod root { offset: usize, ) -> ::core::result::Result { - let value = ::from_buffer(buffer, offset); + let value = *buffer.buffer.get_unchecked(offset); let value: ::core::result::Result = ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { @@ -36947,6 +66091,7 @@ mod root { type Value = Self; + #[inline] fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { *self } @@ -36968,6 +66113,10 @@ mod root { } } + /// The enum `TraceDirection` in the namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * Enum `TraceDirection` in the file `../worker/fbs/producer.fbs:49` #[derive( Copy, Clone, @@ -36982,12 +66131,21 @@ mod root { )] #[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 @@ -37005,6 +66163,7 @@ mod root { } impl ::core::convert::From for u8 { + #[inline] fn from(value: TraceDirection) -> Self { value as u8 } @@ -37065,6 +66224,7 @@ mod root { } impl<'buf> ::planus::TableRead<'buf> for TraceDirection { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, @@ -37083,7 +66243,7 @@ mod root { offset: usize, ) -> ::core::result::Result { - let value = ::from_buffer(buffer, offset); + let value = *buffer.buffer.get_unchecked(offset); let value: ::core::result::Result = ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { @@ -37101,6 +66261,7 @@ mod root { type Value = Self; + #[inline] fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { *self } @@ -37122,6 +66283,10 @@ mod root { } } + /// The union `TraceInfo` in the namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * Union `TraceInfo` in the file `../worker/fbs/producer.fbs:51` #[derive( Clone, Debug, @@ -37134,13 +66299,27 @@ mod root { ::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, @@ -37148,6 +66327,7 @@ mod root { ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) } + #[inline] pub fn create_fir_trace_info( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -37155,6 +66335,7 @@ mod root { ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) } + #[inline] pub fn create_pli_trace_info( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -37162,6 +66343,7 @@ mod root { ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) } + #[inline] pub fn create_rtp_trace_info( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -37171,6 +66353,7 @@ mod root { } impl ::planus::WriteAsUnion for TraceInfo { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { match self { Self::KeyFrameTraceInfo(value) => { @@ -37184,6 +66367,7 @@ mod root { } impl ::planus::WriteAsOptionalUnion for TraceInfo { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -37192,6 +66376,179 @@ mod root { } } + /// 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>), @@ -37206,25 +66563,25 @@ mod root { fn try_from(value: TraceInfoRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(match value { TraceInfoRef::KeyFrameTraceInfo(value) => { - TraceInfo::KeyFrameTraceInfo(::planus::alloc::boxed::Box::new( + Self::KeyFrameTraceInfo(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } TraceInfoRef::FirTraceInfo(value) => { - TraceInfo::FirTraceInfo(::planus::alloc::boxed::Box::new( + Self::FirTraceInfo(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } TraceInfoRef::PliTraceInfo(value) => { - TraceInfo::PliTraceInfo(::planus::alloc::boxed::Box::new( + Self::PliTraceInfo(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } TraceInfoRef::RtpTraceInfo(value) => { - TraceInfo::RtpTraceInfo(::planus::alloc::boxed::Box::new( + Self::RtpTraceInfo(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -37258,6 +66615,10 @@ mod root { } } + /// The table `KeyFrameTraceInfo` in the namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/producer.fbs:58` #[derive( Clone, Debug, @@ -37270,6 +66631,7 @@ mod root { ::serde::Deserialize, )] pub struct KeyFrameTraceInfo { + /// The field `is_rtx` in the table `KeyFrameTraceInfo` pub is_rtx: bool, } @@ -37281,6 +66643,12 @@ mod root { } 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, @@ -37288,28 +66656,27 @@ mod root { ) -> ::planus::Offset { let prepared_is_rtx = field_is_rtx.prepare(builder, &false); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 1>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_is_rtx.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { - table_writer.write::<_, _, 1>(0, &prepared_is_rtx); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { + object_writer.write::<_, _, 1>(&prepared_is_rtx); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for KeyFrameTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -37321,6 +66688,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for KeyFrameTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -37330,18 +66698,107 @@ mod root { } impl ::planus::WriteAsOffset for KeyFrameTraceInfo { + #[inline] + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + KeyFrameTraceInfo::create(builder, 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 [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx). + #[inline] + #[allow(clippy::type_complexity)] + pub fn is_rtx(self, value: T0) -> KeyFrameTraceInfoBuilder<(T0,)> + where + T0: ::planus::WriteAsDefault, + { + KeyFrameTraceInfoBuilder((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<(::planus::DefaultValue,)> { + self.is_rtx(::planus::DefaultValue) + } + } + + impl KeyFrameTraceInfoBuilder<(T0,)> { + /// 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> + ::planus::WriteAs<::planus::Offset> + for KeyFrameTraceInfoBuilder<(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 KeyFrameTraceInfoBuilder<(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 KeyFrameTraceInfoBuilder<(T0,)> + { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - KeyFrameTraceInfo::create(builder, &self.is_rtx) + let (v0,) = &self.0; + KeyFrameTraceInfo::create(builder, v0) } } + /// Reference to a deserialized [KeyFrameTraceInfo]. #[derive(Copy, Clone)] pub struct KeyFrameTraceInfoRef<'a>(::planus::table_reader::Table<'a>); impl<'a> KeyFrameTraceInfoRef<'a> { + /// Getter for the [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx). + #[inline] pub fn is_rtx(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -37371,6 +66828,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for KeyFrameTraceInfoRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -37402,6 +66860,7 @@ mod root { 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) } @@ -37438,6 +66897,10 @@ mod root { } } + /// The table `FirTraceInfo` in the namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * Table `FirTraceInfo` in the file `../worker/fbs/producer.fbs:62` #[derive( Clone, Debug, @@ -37450,6 +66913,7 @@ mod root { ::serde::Deserialize, )] pub struct FirTraceInfo { + /// The field `ssrc` in the table `FirTraceInfo` pub ssrc: u32, } @@ -37461,6 +66925,12 @@ mod root { } 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, @@ -37468,28 +66938,27 @@ mod root { ) -> ::planus::Offset { let prepared_ssrc = field_ssrc.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_ssrc.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - table_writer.write::<_, _, 4>(0, &prepared_ssrc); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + object_writer.write::<_, _, 4>(&prepared_ssrc); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for FirTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -37501,6 +66970,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for FirTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -37510,18 +66980,104 @@ mod root { } 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 { - FirTraceInfo::create(builder, &self.ssrc) + 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), @@ -37549,6 +67105,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for FirTraceInfoRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -37580,6 +67137,7 @@ mod root { 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) } @@ -37616,6 +67174,10 @@ mod root { } } + /// The table `PliTraceInfo` in the namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * Table `PliTraceInfo` in the file `../worker/fbs/producer.fbs:66` #[derive( Clone, Debug, @@ -37628,6 +67190,7 @@ mod root { ::serde::Deserialize, )] pub struct PliTraceInfo { + /// The field `ssrc` in the table `PliTraceInfo` pub ssrc: u32, } @@ -37639,6 +67202,12 @@ mod root { } 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, @@ -37646,28 +67215,27 @@ mod root { ) -> ::planus::Offset { let prepared_ssrc = field_ssrc.prepare(builder, &0); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_ssrc.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - table_writer.write::<_, _, 4>(0, &prepared_ssrc); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + object_writer.write::<_, _, 4>(&prepared_ssrc); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for PliTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -37679,6 +67247,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for PliTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -37688,18 +67257,104 @@ mod root { } 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 { - PliTraceInfo::create(builder, &self.ssrc) + 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), @@ -37727,6 +67382,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for PliTraceInfoRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -37758,6 +67414,7 @@ mod root { 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) } @@ -37794,6 +67451,10 @@ mod root { } } + /// The table `RtpTraceInfo` in the namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * Table `RtpTraceInfo` in the file `../worker/fbs/producer.fbs:70` #[derive( Clone, Debug, @@ -37806,6 +67467,7 @@ mod root { ::serde::Deserialize, )] pub struct RtpTraceInfo { + /// The field `is_rtx` in the table `RtpTraceInfo` pub is_rtx: bool, } @@ -37817,6 +67479,12 @@ mod root { } 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, @@ -37824,28 +67492,27 @@ mod root { ) -> ::planus::Offset { let prepared_is_rtx = field_is_rtx.prepare(builder, &false); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 1>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_is_rtx.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { - table_writer.write::<_, _, 1>(0, &prepared_is_rtx); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { + object_writer.write::<_, _, 1>(&prepared_is_rtx); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for RtpTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -37857,6 +67524,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for RtpTraceInfo { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -37866,18 +67534,104 @@ mod root { } impl ::planus::WriteAsOffset for RtpTraceInfo { + #[inline] + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + RtpTraceInfo::create(builder, 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 [`is_rtx` field](RtpTraceInfo#structfield.is_rtx). + #[inline] + #[allow(clippy::type_complexity)] + pub fn is_rtx(self, value: T0) -> RtpTraceInfoBuilder<(T0,)> + where + T0: ::planus::WriteAsDefault, + { + RtpTraceInfoBuilder((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<(::planus::DefaultValue,)> { + self.is_rtx(::planus::DefaultValue) + } + } + + impl RtpTraceInfoBuilder<(T0,)> { + /// 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> + ::planus::WriteAs<::planus::Offset> for RtpTraceInfoBuilder<(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 RtpTraceInfoBuilder<(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 RtpTraceInfoBuilder<(T0,)> + { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - RtpTraceInfo::create(builder, &self.is_rtx) + let (v0,) = &self.0; + RtpTraceInfo::create(builder, v0) } } + /// Reference to a deserialized [RtpTraceInfo]. #[derive(Copy, Clone)] pub struct RtpTraceInfoRef<'a>(::planus::table_reader::Table<'a>); impl<'a> RtpTraceInfoRef<'a> { + /// 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(0, "RtpTraceInfo", "is_rtx")?.unwrap_or(false), @@ -37905,6 +67659,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RtpTraceInfoRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -37936,6 +67691,7 @@ mod root { 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) } @@ -37972,6 +67728,10 @@ mod root { } } + /// The table `TraceNotification` in the namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * Table `TraceNotification` in the file `../worker/fbs/producer.fbs:74` #[derive( Clone, Debug, @@ -37984,9 +67744,13 @@ mod root { ::serde::Deserialize, )] pub struct TraceNotification { + /// The field `type` in the table `TraceNotification` pub type_: self::TraceType, + /// The field `timestamp` in the table `TraceNotification` pub timestamp: u64, + /// The field `direction` in the table `TraceNotification` pub direction: self::TraceDirection, + /// The field `info` in the table `TraceNotification` pub info: ::core::option::Option, } @@ -38003,6 +67767,12 @@ mod root { } 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, @@ -38015,60 +67785,60 @@ mod root { field_info: impl ::planus::WriteAsOptionalUnion, ) -> ::planus::Offset { let prepared_type_ = field_type_.prepare(builder, &self::TraceType::Keyframe); - let prepared_timestamp = field_timestamp.prepare(builder, &0); - let prepared_direction = field_direction.prepare(builder, &self::TraceDirection::DirectionIn); - let prepared_info = field_info.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<10, 15>::new(builder); - - if prepared_type_.is_some() { - table_writer.calculate_size::(2); - } + let mut table_writer: ::planus::table_writer::TableWriter<14> = + ::core::default::Default::default(); if prepared_timestamp.is_some() { - table_writer.calculate_size::(4); + 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.calculate_size::(6); + table_writer.write_entry::(2); } if prepared_info.is_some() { - table_writer.calculate_size::(8); - table_writer.calculate_size::<::planus::Offset>(10); + table_writer.write_entry::(3); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_timestamp) = prepared_timestamp - { - table_writer.write::<_, _, 8>(1, &prepared_timestamp); - } - if let ::core::option::Option::Some(prepared_info) = prepared_info { - table_writer.write::<_, _, 4>(4, &prepared_info.offset()); - } - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - table_writer.write::<_, _, 1>(0, &prepared_type_); - } - if let ::core::option::Option::Some(prepared_direction) = prepared_direction - { - table_writer.write::<_, _, 1>(2, &prepared_direction); - } - if let ::core::option::Option::Some(prepared_info) = prepared_info { - table_writer.write::<_, _, 1>(3, &prepared_info.tag()); - } - } - - table_writer.finish() + 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, @@ -38080,6 +67850,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for TraceNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -38089,24 +67860,190 @@ mod root { } 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.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, + { + 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, + 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, + 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, + 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 @@ -38115,6 +68052,8 @@ mod root { ) } + /// Getter for the [`timestamp` field](TraceNotification#structfield.timestamp). + #[inline] pub fn timestamp(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -38123,6 +68062,8 @@ mod root { ) } + /// Getter for the [`direction` field](TraceNotification#structfield.direction). + #[inline] pub fn direction(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -38131,6 +68072,8 @@ mod root { ) } + /// Getter for the [`info` field](TraceNotification#structfield.info). + #[inline] pub fn info( &self, ) -> ::planus::Result<::core::option::Option>> @@ -38171,6 +68114,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for TraceNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -38202,6 +68146,7 @@ mod root { 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) } @@ -38238,7 +68183,15 @@ mod root { } } } + /// 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:5` #[derive( Clone, Debug, @@ -38251,13 +68204,23 @@ mod root { ::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, @@ -38269,50 +68232,45 @@ mod root { 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::<10, 10>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer - .calculate_size::<::planus::Offset>(4); + 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.calculate_size::(6); + table_writer.write_entry::(2); } if prepared_enable_srtp.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(3); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_base); - table_writer.write::<_, _, 4>(1, &prepared_listen_info); - if let ::core::option::Option::Some(prepared_enable_rtx) = - prepared_enable_rtx - { - table_writer.write::<_, _, 1>(2, &prepared_enable_rtx); - } - if let ::core::option::Option::Some(prepared_enable_srtp) = - prepared_enable_srtp - { - table_writer.write::<_, _, 1>(3, &prepared_enable_srtp); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for PipeTransportOptions { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -38324,6 +68282,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for PipeTransportOptions { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -38334,6 +68293,7 @@ mod root { } impl ::planus::WriteAsOffset for PipeTransportOptions { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -38342,25 +68302,183 @@ mod root { builder, &self.base, &self.listen_info, - &self.enable_rtx, - &self.enable_srtp, + 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 @@ -38369,6 +68487,8 @@ mod root { ) } + /// Getter for the [`enable_srtp` field](PipeTransportOptions#structfield.enable_srtp). + #[inline] pub fn enable_srtp(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -38408,6 +68528,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for PipeTransportOptionsRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -38439,6 +68560,7 @@ mod root { 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) } @@ -38479,6 +68601,10 @@ mod root { } } + /// The table `ConnectRequest` in the namespace `FBS.PipeTransport` + /// + /// Generated from these locations: + /// * Table `ConnectRequest` in the file `../worker/fbs/pipeTransport.fbs:12` #[derive( Clone, Debug, @@ -38491,14 +68617,23 @@ mod root { ::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, @@ -38509,46 +68644,41 @@ mod root { >, ) -> ::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::<8, 10>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - if prepared_port.is_some() { - table_writer.calculate_size::(4); - } + 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 - .calculate_size::<::planus::Offset>( - 6, - ); + .write_entry::<::planus::Offset>(2); + } + if prepared_port.is_some() { + table_writer.write_entry::(1); } - - table_writer.finish_calculating(); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_ip); - if let ::core::option::Option::Some(prepared_srtp_parameters) = - prepared_srtp_parameters - { - table_writer.write::<_, _, 4>(2, &prepared_srtp_parameters); - } - if let ::core::option::Option::Some(prepared_port) = prepared_port { - table_writer.write::<_, _, 2>(1, &prepared_port); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for ConnectRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -38560,6 +68690,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ConnectRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -38569,26 +68700,161 @@ mod root { } 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 { - ConnectRequest::create(builder, &self.ip, &self.port, &self.srtp_parameters) + 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>> @@ -38639,6 +68905,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ConnectRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -38670,6 +68937,7 @@ mod root { 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) } @@ -38706,6 +68974,10 @@ mod root { } } + /// The table `ConnectResponse` in the namespace `FBS.PipeTransport` + /// + /// Generated from these locations: + /// * Table `ConnectResponse` in the file `../worker/fbs/pipeTransport.fbs:18` #[derive( Clone, Debug, @@ -38718,6 +68990,7 @@ mod root { ::serde::Deserialize, )] pub struct ConnectResponse { + /// The field `tuple` in the table `ConnectResponse` pub tuple: ::core::option::Option<::planus::alloc::boxed::Box>, } @@ -38732,6 +69005,12 @@ mod root { } 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, @@ -38741,28 +69020,27 @@ mod root { ) -> ::planus::Offset { let prepared_tuple = field_tuple.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_tuple.is_some() { - table_writer.calculate_size::<::planus::Offset>(2); + table_writer.write_entry::<::planus::Offset>(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_tuple) = prepared_tuple { - table_writer.write::<_, _, 4>(0, &prepared_tuple); - } + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_tuple) = prepared_tuple { + object_writer.write::<_, _, 4>(&prepared_tuple); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for ConnectResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -38774,6 +69052,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ConnectResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -38783,6 +69062,7 @@ mod root { } impl ::planus::WriteAsOffset for ConnectResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -38791,10 +69071,96 @@ mod root { } } + /// 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::WriteAsOptional<::planus::Offset>, + { + ConnectResponseBuilder((value,)) + } + + /// Sets the [`tuple` field](ConnectResponse#structfield.tuple) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn tuple_as_null(self) -> ConnectResponseBuilder<((),)> { + self.tuple(()) + } + } + + 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<::core::option::Option>> @@ -38831,6 +69197,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ConnectResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -38862,6 +69229,7 @@ mod root { 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) } @@ -38898,6 +69266,10 @@ mod root { } } + /// The table `DumpResponse` in the namespace `FBS.PipeTransport` + /// + /// Generated from these locations: + /// * Table `DumpResponse` in the file `../worker/fbs/pipeTransport.fbs:22` #[derive( Clone, Debug, @@ -38910,15 +69282,25 @@ mod root { ::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, @@ -38930,50 +69312,44 @@ mod root { >, ) -> ::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::<10, 13>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); - if prepared_rtx.is_some() { - table_writer.calculate_size::(6); - } + 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 - .calculate_size::<::planus::Offset>( - 8, - ); + .write_entry::<::planus::Offset>(3); + } + if prepared_rtx.is_some() { + table_writer.write_entry::(2); } - - table_writer.finish_calculating(); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_base); - table_writer.write::<_, _, 4>(1, &prepared_tuple); - if let ::core::option::Option::Some(prepared_srtp_parameters) = - prepared_srtp_parameters - { - table_writer.write::<_, _, 4>(3, &prepared_srtp_parameters); - } - if let ::core::option::Option::Some(prepared_rtx) = prepared_rtx { - table_writer.write::<_, _, 1>(2, &prepared_rtx); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -38985,6 +69361,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -38994,6 +69371,7 @@ mod root { } impl ::planus::WriteAsOffset for DumpResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -39002,30 +69380,184 @@ mod root { builder, &self.base, &self.tuple, - &self.rtx, + 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>> @@ -39076,6 +69608,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -39107,6 +69640,7 @@ mod root { 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) } @@ -39143,15 +69677,27 @@ mod root { } } + /// The table `GetStatsResponse` in the namespace `FBS.PipeTransport` + /// + /// Generated from these locations: + /// * Table `GetStatsResponse` in the file `../worker/fbs/pipeTransport.fbs:29` #[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, @@ -39159,29 +69705,27 @@ mod root { 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::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_base); - table_writer.write::<_, _, 4>(1, &prepared_tuple); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_base); + object_writer.write::<_, _, 4>(&prepared_tuple); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -39193,6 +69737,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -39202,6 +69747,7 @@ mod root { } impl ::planus::WriteAsOffset for GetStatsResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -39210,14 +69756,114 @@ mod root { } } + /// 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") } @@ -39249,6 +69895,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -39280,6 +69927,7 @@ mod root { 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) } @@ -39316,7 +69964,15 @@ mod root { } } } + /// 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:6` #[derive( Clone, Debug, @@ -39329,19 +69985,32 @@ mod root { ::serde::Deserialize, )] pub struct PlainTransportOptions { + /// The field `base` in the table `PlainTransportOptions` pub base: ::core::option::Option<::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<::planus::alloc::string::String>, } 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, @@ -39362,82 +70031,76 @@ mod root { >, ) -> ::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::<16, 19>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<18> = + ::core::default::Default::default(); if prepared_base.is_some() { - table_writer - .calculate_size::<::planus::Offset>(2); + table_writer.write_entry::<::planus::Offset>(0); } - table_writer - .calculate_size::<::planus::Offset>(4); + table_writer.write_entry::<::planus::Offset>(1); if prepared_rtcp_listen_info.is_some() { table_writer - .calculate_size::<::planus::Offset>(6); + .write_entry::<::planus::Offset>(2); + } + if prepared_srtp_crypto_suite.is_some() { + table_writer.write_entry::<::planus::Offset>(6); } if prepared_rtcp_mux.is_some() { - table_writer.calculate_size::(8); + table_writer.write_entry::(3); } if prepared_comedia.is_some() { - table_writer.calculate_size::(10); + table_writer.write_entry::(4); } if prepared_enable_srtp.is_some() { - table_writer.calculate_size::(12); - } - if prepared_srtp_crypto_suite.is_some() { - table_writer.calculate_size::<::planus::Offset>(14); + table_writer.write_entry::(5); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_base) = prepared_base { - table_writer.write::<_, _, 4>(0, &prepared_base); - } - table_writer.write::<_, _, 4>(1, &prepared_listen_info); - if let ::core::option::Option::Some(prepared_rtcp_listen_info) = - prepared_rtcp_listen_info - { - table_writer.write::<_, _, 4>(2, &prepared_rtcp_listen_info); - } - if let ::core::option::Option::Some(prepared_srtp_crypto_suite) = - prepared_srtp_crypto_suite - { - table_writer.write::<_, _, 4>(6, &prepared_srtp_crypto_suite); - } - if let ::core::option::Option::Some(prepared_rtcp_mux) = prepared_rtcp_mux { - table_writer.write::<_, _, 1>(3, &prepared_rtcp_mux); - } - if let ::core::option::Option::Some(prepared_comedia) = prepared_comedia { - table_writer.write::<_, _, 1>(4, &prepared_comedia); - } - if let ::core::option::Option::Some(prepared_enable_srtp) = - prepared_enable_srtp - { - table_writer.write::<_, _, 1>(5, &prepared_enable_srtp); - } - } - - table_writer.finish() + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_base) = prepared_base { + 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_srtp_crypto_suite) = + prepared_srtp_crypto_suite + { + object_writer.write::<_, _, 4>(&prepared_srtp_crypto_suite); + } + 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); + } + }); + } + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for PlainTransportOptions { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -39449,6 +70112,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for PlainTransportOptions { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -39459,6 +70123,7 @@ mod root { } impl ::planus::WriteAsOffset for PlainTransportOptions { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -39468,18 +70133,268 @@ mod root { &self.base, &self.listen_info, &self.rtcp_listen_info, - &self.rtcp_mux, - &self.comedia, - &self.enable_srtp, + 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::WriteAsOptional<::planus::Offset>, + { + PlainTransportOptionsBuilder((value,)) + } + + /// Sets the [`base` field](PlainTransportOptions#structfield.base) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn base_as_null(self) -> PlainTransportOptionsBuilder<((),)> { + self.base(()) + } + } + + 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<::planus::Offset<::core::primitive::str>>, + { + 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::WriteAsOptional<::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::Offset<::core::primitive::str>>, + > ::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::WriteAsOptional<::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::Offset<::core::primitive::str>>, + > ::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::WriteAsOptional<::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::Offset<::core::primitive::str>>, + > ::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<::core::option::Option>> @@ -39487,11 +70402,15 @@ mod root { self.0.access(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>> @@ -39500,6 +70419,8 @@ mod root { .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 @@ -39508,6 +70429,8 @@ mod root { ) } + /// Getter for the [`comedia` field](PlainTransportOptions#structfield.comedia). + #[inline] pub fn comedia(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -39516,6 +70439,8 @@ mod root { ) } + /// Getter for the [`enable_srtp` field](PlainTransportOptions#structfield.enable_srtp). + #[inline] pub fn enable_srtp(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -39524,6 +70449,8 @@ mod root { ) } + /// Getter for the [`srtp_crypto_suite` field](PlainTransportOptions#structfield.srtp_crypto_suite). + #[inline] pub fn srtp_crypto_suite( &self, ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> @@ -39599,6 +70526,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for PlainTransportOptionsRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -39630,6 +70558,7 @@ mod root { 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) } @@ -39670,6 +70599,10 @@ mod root { } } + /// The table `ConnectRequest` in the namespace `FBS.PlainTransport` + /// + /// Generated from these locations: + /// * Table `ConnectRequest` in the file `../worker/fbs/plainTransport.fbs:16` #[derive( Clone, Debug, @@ -39682,9 +70615,13 @@ mod root { ::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, >, @@ -39703,6 +70640,12 @@ mod root { } 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, @@ -39714,59 +70657,54 @@ mod root { >, ) -> ::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::<10, 12>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<12> = + ::core::default::Default::default(); if prepared_ip.is_some() { - table_writer.calculate_size::<::planus::Offset>(2); + 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.calculate_size::(4); + table_writer.write_entry::(1); } if prepared_rtcp_port.is_some() { - table_writer.calculate_size::(6); + table_writer.write_entry::(2); } - if prepared_srtp_parameters.is_some() { - table_writer - .calculate_size::<::planus::Offset>( - 8, - ); - } - - table_writer.finish_calculating(); unsafe { - if let ::core::option::Option::Some(prepared_ip) = prepared_ip { - table_writer.write::<_, _, 4>(0, &prepared_ip); - } - if let ::core::option::Option::Some(prepared_srtp_parameters) = - prepared_srtp_parameters - { - table_writer.write::<_, _, 4>(3, &prepared_srtp_parameters); - } - if let ::core::option::Option::Some(prepared_port) = prepared_port { - table_writer.write::<_, _, 2>(1, &prepared_port); - } - if let ::core::option::Option::Some(prepared_rtcp_port) = prepared_rtcp_port - { - table_writer.write::<_, _, 2>(2, &prepared_rtcp_port); - } - } - - table_writer.finish() + 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, @@ -39778,6 +70716,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ConnectRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -39787,6 +70726,7 @@ mod root { } impl ::planus::WriteAsOffset for ConnectRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -39794,17 +70734,181 @@ mod root { ConnectRequest::create( builder, &self.ip, - &self.port, - &self.rtcp_port, + 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>> @@ -39812,14 +70916,20 @@ mod root { 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>> @@ -39890,6 +71000,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ConnectRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -39921,6 +71032,7 @@ mod root { 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) } @@ -39957,6 +71069,10 @@ mod root { } } + /// The table `ConnectResponse` in the namespace `FBS.PlainTransport` + /// + /// Generated from these locations: + /// * Table `ConnectResponse` in the file `../worker/fbs/plainTransport.fbs:23` #[derive( Clone, Debug, @@ -39969,15 +71085,24 @@ mod root { ::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, @@ -39990,48 +71115,43 @@ mod root { >, ) -> ::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::<8, 12>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); + 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.calculate_size::<::planus::Offset>(4); + table_writer.write_entry::<::planus::Offset>(1); } if prepared_srtp_parameters.is_some() { table_writer - .calculate_size::<::planus::Offset>( - 6, - ); + .write_entry::<::planus::Offset>(2); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_tuple); - if let ::core::option::Option::Some(prepared_rtcp_tuple) = - prepared_rtcp_tuple - { - table_writer.write::<_, _, 4>(1, &prepared_rtcp_tuple); - } - if let ::core::option::Option::Some(prepared_srtp_parameters) = - prepared_srtp_parameters - { - table_writer.write::<_, _, 4>(2, &prepared_srtp_parameters); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for ConnectResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -40043,6 +71163,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ConnectResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -40052,6 +71173,7 @@ mod root { } impl ::planus::WriteAsOffset for ConnectResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -40065,14 +71187,147 @@ mod root { } } + /// 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>> @@ -40080,6 +71335,8 @@ mod root { 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>> @@ -40138,6 +71395,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ConnectResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -40169,6 +71427,7 @@ mod root { 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) } @@ -40205,6 +71464,10 @@ mod root { } } + /// The table `DumpResponse` in the namespace `FBS.PlainTransport` + /// + /// Generated from these locations: + /// * Table `DumpResponse` in the file `../worker/fbs/plainTransport.fbs:29` #[derive( Clone, Debug, @@ -40217,19 +71480,31 @@ mod root { ::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: ::core::option::Option<::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, @@ -40247,73 +71522,67 @@ mod root { >, ) -> ::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::<14, 18>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - if prepared_rtcp_mux.is_some() { - table_writer.calculate_size::(4); - } - if prepared_comedia.is_some() { - table_writer.calculate_size::(6); - } + let mut table_writer: ::planus::table_writer::TableWriter<16> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); if prepared_tuple.is_some() { - table_writer.calculate_size::<::planus::Offset>(8); + table_writer.write_entry::<::planus::Offset>(3); } if prepared_rtcp_tuple.is_some() { - table_writer - .calculate_size::<::planus::Offset>(10); + table_writer.write_entry::<::planus::Offset>(4); } if prepared_srtp_parameters.is_some() { table_writer - .calculate_size::<::planus::Offset>( - 12, - ); + .write_entry::<::planus::Offset>(5); } - - table_writer.finish_calculating(); - - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_base); - if let ::core::option::Option::Some(prepared_tuple) = prepared_tuple { - table_writer.write::<_, _, 4>(3, &prepared_tuple); - } - if let ::core::option::Option::Some(prepared_rtcp_tuple) = - prepared_rtcp_tuple - { - table_writer.write::<_, _, 4>(4, &prepared_rtcp_tuple); - } - if let ::core::option::Option::Some(prepared_srtp_parameters) = - prepared_srtp_parameters - { - table_writer.write::<_, _, 4>(5, &prepared_srtp_parameters); - } - if let ::core::option::Option::Some(prepared_rtcp_mux) = prepared_rtcp_mux { - table_writer.write::<_, _, 1>(1, &prepared_rtcp_mux); - } - if let ::core::option::Option::Some(prepared_comedia) = prepared_comedia { - table_writer.write::<_, _, 1>(2, &prepared_comedia); - } + if prepared_rtcp_mux.is_some() { + table_writer.write_entry::(1); + } + if prepared_comedia.is_some() { + table_writer.write_entry::(2); } - table_writer.finish() + unsafe { + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_base); + if let ::core::option::Option::Some(prepared_tuple) = prepared_tuple { + 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, @@ -40325,6 +71594,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -40334,6 +71604,7 @@ mod root { } impl ::planus::WriteAsOffset for DumpResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -40341,8 +71612,8 @@ mod root { DumpResponse::create( builder, &self.base, - &self.rtcp_mux, - &self.comedia, + self.rtcp_mux, + self.comedia, &self.tuple, &self.rtcp_tuple, &self.srtp_parameters, @@ -40350,14 +71621,225 @@ mod root { } } + /// 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::WriteAsOptional<::planus::Offset>, + { + let (v0, v1, v2) = self.0; + DumpResponseBuilder((v0, v1, v2, value)) + } + + /// Sets the [`tuple` field](DumpResponse#structfield.tuple) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn tuple_as_null(self) -> DumpResponseBuilder<(T0, T1, T2, ())> { + self.tuple(()) + } + } + + 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::WriteAsOptional<::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::WriteAsOptional<::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::WriteAsOptional<::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 @@ -40366,6 +71848,8 @@ mod root { ) } + /// Getter for the [`comedia` field](DumpResponse#structfield.comedia). + #[inline] pub fn comedia(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -40374,6 +71858,8 @@ mod root { ) } + /// Getter for the [`tuple` field](DumpResponse#structfield.tuple). + #[inline] pub fn tuple( &self, ) -> ::planus::Result<::core::option::Option>> @@ -40381,6 +71867,8 @@ mod root { self.0.access(3, "DumpResponse", "tuple") } + /// Getter for the [`rtcp_tuple` field](DumpResponse#structfield.rtcp_tuple). + #[inline] pub fn rtcp_tuple( &self, ) -> ::planus::Result<::core::option::Option>> @@ -40388,6 +71876,8 @@ mod root { 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>> @@ -40460,6 +71950,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -40491,6 +71982,7 @@ mod root { 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) } @@ -40527,19 +72019,34 @@ mod root { } } + /// The table `GetStatsResponse` in the namespace `FBS.PlainTransport` + /// + /// Generated from these locations: + /// * Table `GetStatsResponse` in the file `../worker/fbs/plainTransport.fbs:38` #[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, @@ -40552,56 +72059,53 @@ mod root { >, ) -> ::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::<12, 14>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); + 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.calculate_size::(4); + table_writer.write_entry::(1); } if prepared_comedia.is_some() { - table_writer.calculate_size::(6); + table_writer.write_entry::(2); } - table_writer.calculate_size::<::planus::Offset>(8); - if prepared_rtcp_tuple.is_some() { - table_writer - .calculate_size::<::planus::Offset>(10); - } - - table_writer.finish_calculating(); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_base); - table_writer.write::<_, _, 4>(3, &prepared_tuple); - if let ::core::option::Option::Some(prepared_rtcp_tuple) = - prepared_rtcp_tuple - { - table_writer.write::<_, _, 4>(4, &prepared_rtcp_tuple); - } - if let ::core::option::Option::Some(prepared_rtcp_mux) = prepared_rtcp_mux { - table_writer.write::<_, _, 1>(1, &prepared_rtcp_mux); - } - if let ::core::option::Option::Some(prepared_comedia) = prepared_comedia { - table_writer.write::<_, _, 1>(2, &prepared_comedia); - } - } - - table_writer.finish() + 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, @@ -40613,6 +72117,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -40622,6 +72127,7 @@ mod root { } impl ::planus::WriteAsOffset for GetStatsResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -40629,22 +72135,199 @@ mod root { GetStatsResponse::create( builder, &self.base, - &self.rtcp_mux, - &self.comedia, + 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 @@ -40653,6 +72336,8 @@ mod root { ) } + /// Getter for the [`comedia` field](GetStatsResponse#structfield.comedia). + #[inline] pub fn comedia(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 @@ -40661,10 +72346,14 @@ mod root { ) } + /// 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>> @@ -40717,6 +72406,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -40748,6 +72438,7 @@ mod root { 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) } @@ -40784,6 +72475,10 @@ mod root { } } + /// The table `TupleNotification` in the namespace `FBS.PlainTransport` + /// + /// Generated from these locations: + /// * Table `TupleNotification` in the file `../worker/fbs/plainTransport.fbs:48` #[derive( Clone, Debug, @@ -40796,10 +72491,17 @@ mod root { ::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, @@ -40807,24 +72509,23 @@ mod root { ) -> ::planus::Offset { let prepared_tuple = field_tuple.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_tuple); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_tuple); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for TupleNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -40836,6 +72537,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for TupleNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -40845,6 +72547,7 @@ mod root { } impl ::planus::WriteAsOffset for TupleNotification { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -40853,10 +72556,89 @@ mod root { } } + /// 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") } @@ -40884,6 +72666,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for TupleNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -40915,6 +72698,7 @@ mod root { 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) } @@ -40951,6 +72735,10 @@ mod root { } } + /// The table `RtcpTupleNotification` in the namespace `FBS.PlainTransport` + /// + /// Generated from these locations: + /// * Table `RtcpTupleNotification` in the file `../worker/fbs/plainTransport.fbs:52` #[derive( Clone, Debug, @@ -40963,10 +72751,17 @@ mod root { ::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, @@ -40974,24 +72769,23 @@ mod root { ) -> ::planus::Offset { let prepared_tuple = field_tuple.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_tuple); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_tuple); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for RtcpTupleNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41003,6 +72797,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for RtcpTupleNotification { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41013,6 +72808,7 @@ mod root { } impl ::planus::WriteAsOffset for RtcpTupleNotification { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41021,10 +72817,91 @@ mod root { } } + /// 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") } @@ -41052,6 +72929,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RtcpTupleNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -41083,6 +72961,7 @@ mod root { 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) } @@ -41123,7 +73002,15 @@ mod root { } } } + /// 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, @@ -41136,10 +73023,17 @@ mod root { ::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, @@ -41149,24 +73043,23 @@ mod root { ) -> ::planus::Offset { let prepared_listen_infos = field_listen_infos.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset<[::planus::Offset]>>(2); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_listen_infos); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_listen_infos); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for ListenIndividual { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41178,6 +73071,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ListenIndividual { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41187,6 +73081,7 @@ mod root { } impl ::planus::WriteAsOffset for ListenIndividual { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41195,10 +73090,100 @@ mod root { } } + /// 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< @@ -41229,6 +73214,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ListenIndividualRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -41260,6 +73246,7 @@ mod root { 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) } @@ -41296,6 +73283,10 @@ mod root { } } + /// 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, @@ -41308,10 +73299,17 @@ mod root { ::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, @@ -41319,24 +73317,23 @@ mod root { ) -> ::planus::Offset { let prepared_web_rtc_server_id = field_web_rtc_server_id.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_web_rtc_server_id); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_web_rtc_server_id); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for ListenServer { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41348,6 +73345,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ListenServer { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41357,6 +73355,7 @@ mod root { } impl ::planus::WriteAsOffset for ListenServer { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41365,10 +73364,88 @@ mod root { } } + /// 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") @@ -41397,6 +73474,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ListenServerRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -41428,6 +73506,7 @@ mod root { 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) } @@ -41464,6 +73543,10 @@ mod root { } } + /// 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, @@ -41476,11 +73559,21 @@ mod root { ::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, @@ -41488,6 +73581,7 @@ mod root { ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) } + #[inline] pub fn create_listen_server( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, @@ -41497,6 +73591,7 @@ mod root { } impl ::planus::WriteAsUnion for Listen { + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { match self { Self::ListenIndividual(value) => { @@ -41508,6 +73603,7 @@ mod root { } impl ::planus::WriteAsOptionalUnion for Listen { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41516,6 +73612,105 @@ mod root { } } + /// 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>), @@ -41528,13 +73723,13 @@ mod root { fn try_from(value: ListenRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(match value { ListenRef::ListenIndividual(value) => { - Listen::ListenIndividual(::planus::alloc::boxed::Box::new( + Self::ListenIndividual(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } ListenRef::ListenServer(value) => { - Listen::ListenServer(::planus::alloc::boxed::Box::new( + Self::ListenServer(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -41562,6 +73757,10 @@ mod root { } } + /// 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, @@ -41574,11 +73773,19 @@ mod root { ::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, } 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, @@ -41586,31 +73793,29 @@ mod root { field_listen: impl ::planus::WriteAsUnion, ) -> ::planus::Offset { let prepared_base = field_base.prepare(builder); - let prepared_listen = field_listen.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<6, 9>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::(4); - table_writer.calculate_size::<::planus::Offset>(6); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_base); - table_writer.write::<_, _, 4>(2, &prepared_listen.offset()); - table_writer.write::<_, _, 1>(1, &prepared_listen.tag()); + 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()); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for WebRtcTransportOptions { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41624,6 +73829,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41634,6 +73840,7 @@ mod root { } impl ::planus::WriteAsOffset for WebRtcTransportOptions { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41642,14 +73849,116 @@ mod root { } } + /// 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)> { + /// 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, + > ::planus::WriteAs<::planus::Offset> + for WebRtcTransportOptionsBuilder<(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 WebRtcTransportOptionsBuilder<(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 WebRtcTransportOptionsBuilder<(T0, T1)> + { + #[inline] + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + let (v0, v1) = &self.0; + WebRtcTransportOptions::create(builder, v0, v1) + } + } + + /// 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") @@ -41680,6 +73989,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for WebRtcTransportOptionsRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -41711,6 +74021,7 @@ mod root { 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) } @@ -41751,6 +74062,10 @@ mod root { } } + /// The table `Fingerprint` in the namespace `FBS.WebRtcTransport` + /// + /// Generated from these locations: + /// * Table `Fingerprint` in the file `../worker/fbs/webRtcTransport.fbs:24` #[derive( Clone, Debug, @@ -41763,11 +74078,19 @@ mod root { ::serde::Deserialize, )] pub struct Fingerprint { + /// The field `algorithm` in the table `Fingerprint` pub algorithm: ::planus::alloc::string::String, + /// 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, @@ -41775,29 +74098,27 @@ mod root { field_value: impl ::planus::WriteAs<::planus::Offset>, ) -> ::planus::Offset { let prepared_algorithm = field_algorithm.prepare(builder); - let prepared_value = field_value.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<6, 8>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); - - table_writer.finish_calculating(); + 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.write::<_, _, 4>(0, &prepared_algorithm); - table_writer.write::<_, _, 4>(1, &prepared_value); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_algorithm); + object_writer.write::<_, _, 4>(&prepared_value); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for Fingerprint { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41809,6 +74130,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for Fingerprint { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41818,6 +74140,7 @@ mod root { } impl ::planus::WriteAsOffset for Fingerprint { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41826,14 +74149,114 @@ mod root { } } + /// 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::WriteAs<::planus::Offset>, + { + FingerprintBuilder((value,)) + } + } + + 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::WriteAs<::planus::Offset>, + 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::WriteAs<::planus::Offset>, + 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::WriteAs<::planus::Offset>, + 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<&'a ::core::primitive::str> { self.0.access_required(0, "Fingerprint", "algorithm") } + /// 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") } @@ -41861,6 +74284,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for FingerprintRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -41892,6 +74316,7 @@ mod root { 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) } @@ -41928,6 +74353,10 @@ mod root { } } + /// The table `DtlsParameters` in the namespace `FBS.WebRtcTransport` + /// + /// Generated from these locations: + /// * Table `DtlsParameters` in the file `../worker/fbs/webRtcTransport.fbs:29` #[derive( Clone, Debug, @@ -41940,11 +74369,19 @@ mod root { ::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: ::core::option::Option<::planus::alloc::string::String>, } 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, @@ -41954,36 +74391,32 @@ mod root { field_role: impl ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, ) -> ::planus::Offset { let prepared_fingerprints = field_fingerprints.prepare(builder); - let prepared_role = field_role.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<6, 8>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<8> = + ::core::default::Default::default(); table_writer - .calculate_size::<::planus::Offset<[::planus::Offset]>>( - 2, - ); + .write_entry::<::planus::Offset<[::planus::Offset]>>(0); if prepared_role.is_some() { - table_writer.calculate_size::<::planus::Offset>(4); + table_writer.write_entry::<::planus::Offset>(1); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_fingerprints); - if let ::core::option::Option::Some(prepared_role) = prepared_role { - table_writer.write::<_, _, 4>(1, &prepared_role); - } + 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::<_, _, 4>(&prepared_role); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for DtlsParameters { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -41995,6 +74428,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for DtlsParameters { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -42004,6 +74438,7 @@ mod root { } impl ::planus::WriteAsOffset for DtlsParameters { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -42012,10 +74447,115 @@ mod root { } } + /// 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::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + { + let (v0,) = self.0; + DtlsParametersBuilder((v0, value)) + } + + /// Sets the [`role` field](DtlsParameters#structfield.role) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn role_as_null(self) -> DtlsParametersBuilder<(T0, ())> { + self.role(()) + } + } + + 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::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + > ::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::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + > ::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::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + > ::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< @@ -42024,6 +74564,8 @@ mod root { self.0.access_required(0, "DtlsParameters", "fingerprints") } + /// Getter for the [`role` field](DtlsParameters#structfield.role). + #[inline] pub fn role( &self, ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> @@ -42060,6 +74602,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DtlsParametersRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -42091,6 +74634,7 @@ mod root { 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) } @@ -42127,6 +74671,10 @@ mod root { } } + /// The table `IceParameters` in the namespace `FBS.WebRtcTransport` + /// + /// Generated from these locations: + /// * Table `IceParameters` in the file `../worker/fbs/webRtcTransport.fbs:34` #[derive( Clone, Debug, @@ -42139,12 +74687,21 @@ mod root { ::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, @@ -42153,37 +74710,36 @@ mod root { 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::<8, 9>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); + 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.calculate_size::(6); + table_writer.write_entry::(2); } - table_writer.finish_calculating(); - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_username_fragment); - table_writer.write::<_, _, 4>(1, &prepared_password); - if let ::core::option::Option::Some(prepared_ice_lite) = prepared_ice_lite { - table_writer.write::<_, _, 1>(2, &prepared_ice_lite); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for IceParameters { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -42195,6 +74751,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for IceParameters { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -42204,6 +74761,7 @@ mod root { } impl ::planus::WriteAsOffset for IceParameters { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -42212,24 +74770,151 @@ mod root { builder, &self.username_fragment, &self.password, - &self.ice_lite, + 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 @@ -42265,6 +74950,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for IceParametersRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -42296,6 +74982,7 @@ mod root { 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) } @@ -42332,6 +75019,10 @@ mod root { } } + /// The table `IceCandidate` in the namespace `FBS.WebRtcTransport` + /// + /// Generated from these locations: + /// * Table `IceCandidate` in the file `../worker/fbs/webRtcTransport.fbs:40` #[derive( Clone, Debug, @@ -42344,16 +75035,29 @@ mod root { ::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: ::planus::alloc::string::String, + /// The field `port` in the table `IceCandidate` pub port: u16, + /// The field `type` in the table `IceCandidate` pub type_: ::core::option::Option<::planus::alloc::string::String>, + /// The field `tcp_type` in the table `IceCandidate` pub tcp_type: ::core::option::Option<::planus::alloc::string::String>, } 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, @@ -42370,65 +75074,62 @@ mod root { >, ) -> ::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); - let prepared_port = field_port.prepare(builder, &0); - let prepared_type_ = field_type_.prepare(builder); - let prepared_tcp_type = field_tcp_type.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<16, 26>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); + 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.calculate_size::(4); - } - table_writer.calculate_size::<::planus::Offset>(6); - table_writer.calculate_size::<::planus::Offset>(8); - if prepared_port.is_some() { - table_writer.calculate_size::(10); + table_writer.write_entry::(1); } + table_writer.write_entry::<::planus::Offset>(2); + table_writer.write_entry::<::planus::Offset>(3); if prepared_type_.is_some() { - table_writer.calculate_size::<::planus::Offset>(12); + table_writer.write_entry::<::planus::Offset>(5); } if prepared_tcp_type.is_some() { - table_writer.calculate_size::<::planus::Offset>(14); + table_writer.write_entry::<::planus::Offset>(6); } - - table_writer.finish_calculating(); - - unsafe { - table_writer.write::<_, _, 4>(0, &prepared_foundation); - if let ::core::option::Option::Some(prepared_priority) = prepared_priority { - table_writer.write::<_, _, 4>(1, &prepared_priority); - } - table_writer.write::<_, _, 4>(2, &prepared_ip); - table_writer.write::<_, _, 4>(3, &prepared_protocol); - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - table_writer.write::<_, _, 4>(5, &prepared_type_); - } - if let ::core::option::Option::Some(prepared_tcp_type) = prepared_tcp_type { - table_writer.write::<_, _, 4>(6, &prepared_tcp_type); - } - if let ::core::option::Option::Some(prepared_port) = prepared_port { - table_writer.write::<_, _, 2>(4, &prepared_port); - } + if prepared_port.is_some() { + table_writer.write_entry::(4); } - table_writer.finish() + 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); + object_writer.write::<_, _, 4>(&prepared_protocol); + if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { + object_writer.write::<_, _, 4>(&prepared_type_); + } + if let ::core::option::Option::Some(prepared_tcp_type) = + prepared_tcp_type + { + object_writer.write::<_, _, 4>(&prepared_tcp_type); + } + 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 IceCandidate { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -42440,6 +75141,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for IceCandidate { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -42449,6 +75151,7 @@ mod root { } impl ::planus::WriteAsOffset for IceCandidate { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -42456,44 +75159,268 @@ mod root { IceCandidate::create( builder, &self.foundation, - &self.priority, + self.priority, &self.ip, &self.protocol, - &self.port, + 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::WriteAs<::planus::Offset>, + { + let (v0, v1, v2) = self.0; + IceCandidateBuilder((v0, v1, v2, value)) + } + } + + 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::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + { + let (v0, v1, v2, v3, v4) = self.0; + IceCandidateBuilder((v0, v1, v2, v3, v4, value)) + } + + /// Sets the [`type` field](IceCandidate#structfield.type_) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn type_as_null(self) -> IceCandidateBuilder<(T0, T1, T2, T3, T4, ())> { + self.type_(()) + } + } + + 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<::planus::Offset<::core::primitive::str>>, + { + 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::WriteAs<::planus::Offset>, + T4: ::planus::WriteAsDefault, + T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T6: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + > ::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::WriteAs<::planus::Offset>, + T4: ::planus::WriteAsDefault, + T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T6: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + > ::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::WriteAs<::planus::Offset>, + T4: ::planus::WriteAsDefault, + T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T6: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + > ::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<&'a ::core::primitive::str> { self.0.access_required(3, "IceCandidate", "protocol") } + /// 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::option::Option<&'a ::core::primitive::str>> @@ -42501,6 +75428,8 @@ mod root { self.0.access(5, "IceCandidate", "type_") } + /// Getter for the [`tcp_type` field](IceCandidate#structfield.tcp_type). + #[inline] pub fn tcp_type( &self, ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> @@ -42559,6 +75488,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for IceCandidateRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -42590,6 +75520,7 @@ mod root { 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) } @@ -42626,6 +75557,10 @@ mod root { } } + /// The table `ConnectRequest` in the namespace `FBS.WebRtcTransport` + /// + /// Generated from these locations: + /// * Table `ConnectRequest` in the file `../worker/fbs/webRtcTransport.fbs:50` #[derive( Clone, Debug, @@ -42638,10 +75573,17 @@ mod root { ::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, @@ -42651,24 +75593,23 @@ mod root { ) -> ::planus::Offset { let prepared_dtls_parameters = field_dtls_parameters.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_dtls_parameters); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_dtls_parameters); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for ConnectRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -42680,6 +75621,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ConnectRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -42689,6 +75631,7 @@ mod root { } impl ::planus::WriteAsOffset for ConnectRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -42697,10 +75640,89 @@ mod root { } } + /// 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") @@ -42729,6 +75751,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ConnectRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -42760,6 +75783,7 @@ mod root { 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) } @@ -42796,6 +75820,10 @@ mod root { } } + /// The table `ConnectResponse` in the namespace `FBS.WebRtcTransport` + /// + /// Generated from these locations: + /// * Table `ConnectResponse` in the file `../worker/fbs/webRtcTransport.fbs:54` #[derive( Clone, Debug, @@ -42808,10 +75836,17 @@ mod root { ::serde::Deserialize, )] pub struct ConnectResponse { + /// The field `dtls_local_role` in the table `ConnectResponse` pub dtls_local_role: ::planus::alloc::string::String, } 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, @@ -42819,24 +75854,23 @@ mod root { ) -> ::planus::Offset { let prepared_dtls_local_role = field_dtls_local_role.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_dtls_local_role); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_dtls_local_role); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for ConnectResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -42848,6 +75882,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for ConnectResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -42857,6 +75892,7 @@ mod root { } impl ::planus::WriteAsOffset for ConnectResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -42865,10 +75901,89 @@ mod root { } } + /// 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::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 [`dtls_local_role` field](ConnectResponse#structfield.dtls_local_role). + #[inline] pub fn dtls_local_role(&self) -> ::planus::Result<&'a ::core::primitive::str> { self.0 .access_required(0, "ConnectResponse", "dtls_local_role") @@ -42897,6 +76012,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for ConnectResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -42928,6 +76044,7 @@ mod root { 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) } @@ -42964,6 +76081,10 @@ mod root { } } + /// The table `DumpResponse` in the namespace `FBS.WebRtcTransport` + /// + /// Generated from these locations: + /// * Table `DumpResponse` in the file `../worker/fbs/webRtcTransport.fbs:58` #[derive( Clone, Debug, @@ -42976,18 +76097,32 @@ mod root { ::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: ::planus::alloc::string::String, + /// 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: ::planus::alloc::string::String, + /// 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: ::planus::alloc::string::String, } 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, @@ -43007,63 +76142,52 @@ mod root { field_dtls_state: impl ::planus::WriteAs<::planus::Offset>, ) -> ::planus::Offset { let prepared_base = field_base.prepare(builder); - let prepared_ice_role = field_ice_role.prepare(builder); - 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); - 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); - let mut table_writer = - ::planus::table_writer::TableWriter::<18, 32>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); - table_writer.calculate_size::<::planus::Offset>(6); + 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); + table_writer.write_entry::<::planus::Offset>(2); table_writer - .calculate_size::<::planus::Offset<[::planus::Offset]>>( - 8, - ); - table_writer.calculate_size::<::planus::Offset>(10); + .write_entry::<::planus::Offset<[::planus::Offset]>>(3); + table_writer.write_entry::<::planus::Offset>(4); if prepared_ice_selected_tuple.is_some() { - table_writer - .calculate_size::<::planus::Offset>(12); + table_writer.write_entry::<::planus::Offset>(5); } - table_writer.calculate_size::<::planus::Offset>(14); - table_writer.calculate_size::<::planus::Offset>(16); - - table_writer.finish_calculating(); + table_writer.write_entry::<::planus::Offset>(6); + table_writer.write_entry::<::planus::Offset>(7); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_base); - table_writer.write::<_, _, 4>(1, &prepared_ice_role); - table_writer.write::<_, _, 4>(2, &prepared_ice_parameters); - table_writer.write::<_, _, 4>(3, &prepared_ice_candidates); - table_writer.write::<_, _, 4>(4, &prepared_ice_state); - if let ::core::option::Option::Some(prepared_ice_selected_tuple) = - prepared_ice_selected_tuple - { - table_writer.write::<_, _, 4>(5, &prepared_ice_selected_tuple); - } - table_writer.write::<_, _, 4>(6, &prepared_dtls_parameters); - table_writer.write::<_, _, 4>(7, &prepared_dtls_state); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_base); + object_writer.write::<_, _, 4>(&prepared_ice_role); + object_writer.write::<_, _, 4>(&prepared_ice_parameters); + object_writer.write::<_, _, 4>(&prepared_ice_candidates); + object_writer.write::<_, _, 4>(&prepared_ice_state); + 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); + object_writer.write::<_, _, 4>(&prepared_dtls_state); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -43075,6 +76199,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -43084,6 +76209,7 @@ mod root { } impl ::planus::WriteAsOffset for DumpResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -43102,22 +76228,241 @@ mod root { } } + /// 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::WriteAs<::planus::Offset>, + { + let (v0,) = self.0; + DumpResponseBuilder((v0, value)) + } + } + + 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::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 [`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::WriteAs<::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>, + T2: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T4: ::planus::WriteAs<::planus::Offset>, + T5: ::planus::WriteAsOptional<::planus::Offset>, + T6: ::planus::WriteAs<::planus::Offset>, + T7: ::planus::WriteAs<::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>, + T2: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T4: ::planus::WriteAs<::planus::Offset>, + T5: ::planus::WriteAsOptional<::planus::Offset>, + T6: ::planus::WriteAs<::planus::Offset>, + T7: ::planus::WriteAs<::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>, + T2: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T4: ::planus::WriteAs<::planus::Offset>, + T5: ::planus::WriteAsOptional<::planus::Offset>, + T6: ::planus::WriteAs<::planus::Offset>, + T7: ::planus::WriteAs<::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 [`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<&'a ::core::primitive::str> { self.0.access_required(1, "DumpResponse", "ice_role") } + /// 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< @@ -43126,10 +76471,14 @@ mod root { 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<&'a ::core::primitive::str> { self.0.access_required(4, "DumpResponse", "ice_state") } + /// Getter for the [`ice_selected_tuple` field](DumpResponse#structfield.ice_selected_tuple). + #[inline] pub fn ice_selected_tuple( &self, ) -> ::planus::Result<::core::option::Option>> @@ -43137,10 +76486,14 @@ mod root { 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<&'a ::core::primitive::str> { self.0.access_required(7, "DumpResponse", "dtls_state") } @@ -43199,6 +76552,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -43230,6 +76584,7 @@ mod root { 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) } @@ -43266,19 +76621,34 @@ mod root { } } + /// The table `GetStatsResponse` in the namespace `FBS.WebRtcTransport` + /// + /// Generated from these locations: + /// * Table `GetStatsResponse` in the file `../worker/fbs/webRtcTransport.fbs:69` #[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: ::planus::alloc::string::String, + /// The field `ice_state` in the table `GetStatsResponse` pub ice_state: ::planus::alloc::string::String, + /// 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: ::planus::alloc::string::String, } 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, @@ -43291,47 +76661,42 @@ mod root { field_dtls_state: impl ::planus::WriteAs<::planus::Offset>, ) -> ::planus::Offset { let prepared_base = field_base.prepare(builder); - let prepared_ice_role = field_ice_role.prepare(builder); - let prepared_ice_state = field_ice_state.prepare(builder); - let prepared_ice_selected_tuple = field_ice_selected_tuple.prepare(builder); - let prepared_dtls_state = field_dtls_state.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<12, 20>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - table_writer.calculate_size::<::planus::Offset>(4); - table_writer.calculate_size::<::planus::Offset>(6); + 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>(1); + table_writer.write_entry::<::planus::Offset>(2); if prepared_ice_selected_tuple.is_some() { - table_writer.calculate_size::<::planus::Offset>(8); + table_writer.write_entry::<::planus::Offset>(3); } - table_writer.calculate_size::<::planus::Offset>(10); - - table_writer.finish_calculating(); + table_writer.write_entry::<::planus::Offset>(4); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_base); - table_writer.write::<_, _, 4>(1, &prepared_ice_role); - table_writer.write::<_, _, 4>(2, &prepared_ice_state); - if let ::core::option::Option::Some(prepared_ice_selected_tuple) = - prepared_ice_selected_tuple - { - table_writer.write::<_, _, 4>(3, &prepared_ice_selected_tuple); - } - table_writer.write::<_, _, 4>(4, &prepared_dtls_state); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_base); + object_writer.write::<_, _, 4>(&prepared_ice_role); + object_writer.write::<_, _, 4>(&prepared_ice_state); + 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_state); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -43343,6 +76708,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -43352,6 +76718,7 @@ mod root { } impl ::planus::WriteAsOffset for GetStatsResponse { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -43367,22 +76734,190 @@ mod root { } } + /// 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::WriteAs<::planus::Offset>, + { + let (v0,) = self.0; + GetStatsResponseBuilder((v0, value)) + } + } + + 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::WriteAs<::planus::Offset>, + { + let (v0, v1) = self.0; + GetStatsResponseBuilder((v0, v1, value)) + } + } + + 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::WriteAs<::planus::Offset>, + { + let (v0, v1, v2, v3) = self.0; + GetStatsResponseBuilder((v0, v1, v2, v3, value)) + } + } + + 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::WriteAs<::planus::Offset>, + T2: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAsOptional<::planus::Offset>, + T4: ::planus::WriteAs<::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::WriteAs<::planus::Offset>, + T2: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAsOptional<::planus::Offset>, + T4: ::planus::WriteAs<::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::WriteAs<::planus::Offset>, + T2: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAsOptional<::planus::Offset>, + T4: ::planus::WriteAs<::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 [`ice_role` field](GetStatsResponse#structfield.ice_role). + #[inline] pub fn ice_role(&self) -> ::planus::Result<&'a ::core::primitive::str> { self.0.access_required(1, "GetStatsResponse", "ice_role") } + /// Getter for the [`ice_state` field](GetStatsResponse#structfield.ice_state). + #[inline] pub fn ice_state(&self) -> ::planus::Result<&'a ::core::primitive::str> { self.0.access_required(2, "GetStatsResponse", "ice_state") } + /// Getter for the [`ice_selected_tuple` field](GetStatsResponse#structfield.ice_selected_tuple). + #[inline] pub fn ice_selected_tuple( &self, ) -> ::planus::Result<::core::option::Option>> @@ -43390,6 +76925,8 @@ mod root { 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<&'a ::core::primitive::str> { self.0.access_required(4, "GetStatsResponse", "dtls_state") } @@ -43438,6 +76975,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -43469,6 +77007,7 @@ mod root { 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) } @@ -43505,6 +77044,10 @@ mod root { } } + /// The table `IceSelectedTupleChangeNotification` in the namespace `FBS.WebRtcTransport` + /// + /// Generated from these locations: + /// * Table `IceSelectedTupleChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:79` #[derive( Clone, Debug, @@ -43517,10 +77060,17 @@ mod root { ::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, @@ -43528,18 +77078,16 @@ mod root { ) -> ::planus::Offset { let prepared_tuple = field_tuple.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_tuple); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_tuple); + }); } - - table_writer.finish() + builder.current_offset() } } @@ -43548,6 +77096,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -43561,6 +77110,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -43573,6 +77123,7 @@ mod root { impl ::planus::WriteAsOffset for IceSelectedTupleChangeNotification { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -43581,10 +77132,94 @@ mod root { } } + /// 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") @@ -43617,6 +77252,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for IceSelectedTupleChangeNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -43650,6 +77286,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -43690,6 +77327,10 @@ mod root { } } + /// The enum `IceState` in the namespace `FBS.WebRtcTransport` + /// + /// Generated from these locations: + /// * Enum `IceState` in the file `../worker/fbs/webRtcTransport.fbs:83` #[derive( Copy, Clone, @@ -43704,15 +77345,36 @@ mod root { )] #[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, + + /// The variant `CLOSED` in the enum `IceState` Closed = 4, } + impl IceState { + /// Array containing all valid variants of IceState + pub const ENUM_VALUES: [Self; 5] = [ + Self::New, + Self::Connected, + Self::Completed, + Self::Disconnected, + Self::Closed, + ]; + } + impl ::core::convert::TryFrom for IceState { type Error = ::planus::errors::UnknownEnumTagKind; + #[inline] fn try_from( value: u8, ) -> ::core::result::Result @@ -43733,6 +77395,7 @@ mod root { } impl ::core::convert::From for u8 { + #[inline] fn from(value: IceState) -> Self { value as u8 } @@ -43793,6 +77456,7 @@ mod root { } impl<'buf> ::planus::TableRead<'buf> for IceState { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, @@ -43811,7 +77475,7 @@ mod root { offset: usize, ) -> ::core::result::Result { - let value = ::from_buffer(buffer, offset); + let value = *buffer.buffer.get_unchecked(offset); let value: ::core::result::Result = ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { @@ -43829,6 +77493,7 @@ mod root { type Value = Self; + #[inline] fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { *self } @@ -43850,6 +77515,10 @@ mod root { } } + /// The enum `DtlsState` in the namespace `FBS.WebRtcTransport` + /// + /// Generated from these locations: + /// * Enum `DtlsState` in the file `../worker/fbs/webRtcTransport.fbs:84` #[derive( Copy, Clone, @@ -43864,15 +77533,36 @@ mod root { )] #[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 @@ -43893,6 +77583,7 @@ mod root { } impl ::core::convert::From for u8 { + #[inline] fn from(value: DtlsState) -> Self { value as u8 } @@ -43953,6 +77644,7 @@ mod root { } impl<'buf> ::planus::TableRead<'buf> for DtlsState { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, @@ -43971,7 +77663,7 @@ mod root { offset: usize, ) -> ::core::result::Result { - let value = ::from_buffer(buffer, offset); + let value = *buffer.buffer.get_unchecked(offset); let value: ::core::result::Result = ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { @@ -43989,6 +77681,7 @@ mod root { type Value = Self; + #[inline] fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { *self } @@ -44010,6 +77703,10 @@ mod root { } } + /// The table `IceStateChangeNotification` in the namespace `FBS.WebRtcTransport` + /// + /// Generated from these locations: + /// * Table `IceStateChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:86` #[derive( Clone, Debug, @@ -44022,6 +77719,7 @@ mod root { ::serde::Deserialize, )] pub struct IceStateChangeNotification { + /// The field `ice_state` in the table `IceStateChangeNotification` pub ice_state: self::IceState, } @@ -44035,6 +77733,12 @@ mod root { } 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, @@ -44042,23 +77746,22 @@ mod root { ) -> ::planus::Offset { let prepared_ice_state = field_ice_state.prepare(builder, &self::IceState::New); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 1>::new(builder); - + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); if prepared_ice_state.is_some() { - table_writer.calculate_size::(2); + table_writer.write_entry::(0); } - table_writer.finish_calculating(); - unsafe { - if let ::core::option::Option::Some(prepared_ice_state) = prepared_ice_state - { - table_writer.write::<_, _, 1>(0, &prepared_ice_state); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } @@ -44067,6 +77770,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -44080,6 +77784,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -44090,18 +77795,109 @@ mod root { } 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 { - IceStateChangeNotification::create(builder, &self.ice_state) + ::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 @@ -44133,6 +77929,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for IceStateChangeNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -44166,6 +77963,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -44206,6 +78004,10 @@ mod root { } } + /// The table `DtlsStateChangeNotification` in the namespace `FBS.WebRtcTransport` + /// + /// Generated from these locations: + /// * Table `DtlsStateChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:90` #[derive( Clone, Debug, @@ -44218,7 +78020,9 @@ mod root { ::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>, } @@ -44233,6 +78037,12 @@ mod root { } 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, @@ -44243,35 +78053,32 @@ mod root { ) -> ::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::<6, 5>::new(builder); - - if prepared_dtls_state.is_some() { - table_writer.calculate_size::(2); - } + let mut table_writer: ::planus::table_writer::TableWriter<8> = + ::core::default::Default::default(); if prepared_remote_cert.is_some() { - table_writer.calculate_size::<::planus::Offset>(4); + table_writer.write_entry::<::planus::Offset>(1); + } + if prepared_dtls_state.is_some() { + table_writer.write_entry::(0); } - - table_writer.finish_calculating(); unsafe { - if let ::core::option::Option::Some(prepared_remote_cert) = - prepared_remote_cert - { - table_writer.write::<_, _, 4>(1, &prepared_remote_cert); - } - if let ::core::option::Option::Some(prepared_dtls_state) = - prepared_dtls_state - { - table_writer.write::<_, _, 1>(0, &prepared_dtls_state); - } + 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); + } + }); } - - table_writer.finish() + builder.current_offset() } } @@ -44280,6 +78087,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -44293,6 +78101,7 @@ mod root { { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -44303,22 +78112,139 @@ mod root { } impl ::planus::WriteAsOffset for DtlsStateChangeNotification { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - DtlsStateChangeNotification::create( - builder, - &self.dtls_state, - &self.remote_cert, - ) + 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 @@ -44327,6 +78253,8 @@ mod root { ) } + /// 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>> @@ -44372,6 +78300,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for DtlsStateChangeNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -44405,6 +78334,7 @@ mod root { { type Value = ::planus::Offset; const STRIDE: usize = 4; + #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { ::planus::WriteAs::prepare(self, builder) } @@ -44445,7 +78375,15 @@ mod root { } } } + /// 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:4` #[derive( Clone, Debug, @@ -44458,10 +78396,17 @@ mod root { ::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, @@ -44469,24 +78414,23 @@ mod root { ) -> ::planus::Offset { let prepared_producer_id = field_producer_id.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_producer_id); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_producer_id); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for AddProducerRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -44498,6 +78442,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for AddProducerRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -44507,6 +78452,7 @@ mod root { } impl ::planus::WriteAsOffset for AddProducerRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -44515,10 +78461,89 @@ mod root { } } + /// 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") @@ -44545,6 +78570,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for AddProducerRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -44576,6 +78602,7 @@ mod root { 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) } @@ -44612,6 +78639,10 @@ mod root { } } + /// The table `RemoveProducerRequest` in the namespace `FBS.RtpObserver` + /// + /// Generated from these locations: + /// * Table `RemoveProducerRequest` in the file `../worker/fbs/rtpObserver.fbs:8` #[derive( Clone, Debug, @@ -44624,10 +78655,17 @@ mod root { ::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, @@ -44635,24 +78673,23 @@ mod root { ) -> ::planus::Offset { let prepared_producer_id = field_producer_id.prepare(builder); - let mut table_writer = - ::planus::table_writer::TableWriter::<4, 4>::new(builder); - - table_writer.calculate_size::<::planus::Offset>(2); - - table_writer.finish_calculating(); + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); unsafe { - table_writer.write::<_, _, 4>(0, &prepared_producer_id); + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_producer_id); + }); } - - table_writer.finish() + builder.current_offset() } } impl ::planus::WriteAs<::planus::Offset> for RemoveProducerRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -44664,6 +78701,7 @@ mod root { impl ::planus::WriteAsOptional<::planus::Offset> for RemoveProducerRequest { type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -44674,6 +78712,7 @@ mod root { } impl ::planus::WriteAsOffset for RemoveProducerRequest { + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, @@ -44682,10 +78721,91 @@ mod root { } } + /// 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") @@ -44712,6 +78832,7 @@ mod root { } impl<'a> ::planus::TableRead<'a> for RemoveProducerRequestRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, @@ -44743,6 +78864,7 @@ mod root { 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) } From 340375b99246237f9c751f94ef02beb25b696bab Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Sun, 30 Jul 2023 23:58:37 +0300 Subject: [PATCH 13/73] Implement `RtpParameters::from_fbs()` and `RtpParameters::into_fbs()` --- rust/src/rtp_parameters.rs | 450 ++++++++++++++++++++++++++++++++++--- 1 file changed, 416 insertions(+), 34 deletions(-) diff --git a/rust/src/rtp_parameters.rs b/rust/src/rtp_parameters.rs index d3563f5724..a7889225af 100644 --- a/rust/src/rtp_parameters.rs +++ b/rust/src/rtp_parameters.rs @@ -4,15 +4,19 @@ #[cfg(test)] mod tests; +use crate::fbs::rtp_parameters; use crate::scalability_modes::ScalabilityMode; use serde::de::{MapAccess, Visitor}; use serde::ser::SerializeStruct; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; use std::borrow::Cow; use std::collections::BTreeMap; +use std::error::Error; use std::fmt; use std::iter::FromIterator; use std::num::{NonZeroU32, NonZeroU8}; +use std::str::FromStr; +use thiserror::Error; /// Codec specific parameters. Some parameters (such as `packetization-mode` and `profile-level-id` /// in H264 or `profile-id` in VP9) are critical for codec matching. @@ -200,6 +204,17 @@ pub enum MediaKind { Video, } +/// Error that caused [`MimeType`] parsing error. +#[derive(Debug, Error, Eq, PartialEq)] +pub enum ParseMimeTypeError { + /// Invalid input string + #[error("Invalid input string")] + InvalidInput, + /// Unknown MIME type + #[error("Unknown MIME type")] + UnknownMimeType, +} + /// Known Audio or Video MIME type. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)] #[serde(untagged)] @@ -210,6 +225,30 @@ pub enum MimeType { Video(MimeTypeVideo), } +impl FromStr for MimeType { + type Err = ParseMimeTypeError; + + fn from_str(s: &str) -> Result { + if s.starts_with("audio/") { + MimeTypeAudio::from_str(s).map(Self::Audio) + } else if s.starts_with("video/") { + MimeTypeVideo::from_str(s).map(Self::Video) + } else { + Err(ParseMimeTypeError::InvalidInput) + } + } +} + +impl MimeType { + /// String representation of MIME type. + pub fn as_str(&self) -> &'static str { + match self { + Self::Audio(mime_type) => mime_type.as_str(), + Self::Video(mime_type) => mime_type.as_str(), + } + } +} + /// Known Audio MIME types. #[allow(non_camel_case_types)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)] @@ -252,6 +291,52 @@ pub enum MimeTypeAudio { Red, } +impl FromStr for MimeTypeAudio { + type Err = ParseMimeTypeError; + + fn from_str(s: &str) -> Result { + match s { + "audio/opus" => Ok(Self::Opus), + "audio/multiopus" => Ok(Self::MultiChannelOpus), + "audio/PCMU" => Ok(Self::Pcmu), + "audio/PCMA" => Ok(Self::Pcma), + "audio/ISAC" => Ok(Self::Isac), + "audio/G722" => Ok(Self::G722), + "audio/iLBC" => Ok(Self::Ilbc), + "audio/SILK" => Ok(Self::Silk), + "audio/CN" => Ok(Self::Cn), + "audio/telephone-event" => Ok(Self::TelephoneEvent), + "audio/rtx" => Ok(Self::Rtx), + "audio/red" => Ok(Self::Red), + s => Err(if s.starts_with("audio/") { + ParseMimeTypeError::UnknownMimeType + } else { + ParseMimeTypeError::InvalidInput + }), + } + } +} + +impl MimeTypeAudio { + /// String representation of MIME type. + pub fn as_str(&self) -> &'static str { + match self { + Self::Opus => "audio/opus", + Self::MultiChannelOpus => "audio/multiopus", + Self::Pcmu => "audio/PCMU", + Self::Pcma => "audio/PCMA", + Self::Isac => "audio/ISAC", + Self::G722 => "audio/G722", + Self::Ilbc => "audio/iLBC", + Self::Silk => "audio/SILK", + Self::Cn => "audio/CN", + Self::TelephoneEvent => "audio/telephone-event", + Self::Rtx => "audio/rtx", + Self::Red => "audio/red", + } + } +} + /// Known Video MIME types. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)] pub enum MimeTypeVideo { @@ -281,6 +366,44 @@ pub enum MimeTypeVideo { Ulpfec, } +impl FromStr for MimeTypeVideo { + type Err = ParseMimeTypeError; + + fn from_str(s: &str) -> Result { + match s { + "video/VP8" => Ok(Self::Vp8), + "video/VP9" => Ok(Self::Vp9), + "video/H264" => Ok(Self::H264), + "video/H264-SVC" => Ok(Self::H264Svc), + "video/H265" => Ok(Self::H265), + "video/rtx" => Ok(Self::Rtx), + "video/red" => Ok(Self::Red), + "video/ulpfec" => Ok(Self::Ulpfec), + s => Err(if s.starts_with("video/") { + ParseMimeTypeError::UnknownMimeType + } else { + ParseMimeTypeError::InvalidInput + }), + } + } +} + +impl MimeTypeVideo { + /// String representation of MIME type. + pub fn as_str(&self) -> &'static str { + match self { + Self::Vp8 => "video/VP8", + Self::Vp9 => "video/VP9", + Self::H264 => "video/H264", + Self::H264Svc => "video/H264-SVC", + Self::H265 => "video/H265", + Self::Rtx => "video/rtx", + Self::Red => "video/red", + Self::Ulpfec => "video/ulpfec", + } + } +} + /// Provides information on the capabilities of a codec within the RTP capabilities. The list of /// media codecs supported by mediasoup and their settings is defined in the /// `supported_rtp_capabilities.rs` file. @@ -402,6 +525,14 @@ impl Default for RtpHeaderExtensionDirection { } } +/// Error that caused [`RtpHeaderExtensionUri`] parsing error. +#[derive(Debug, Error, Eq, PartialEq)] +pub enum RtpHeaderExtensionUriParseError { + /// Unsupported + #[error("Unsupported")] + Unsupported, +} + /// URI for supported RTP header extension #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)] pub enum RtpHeaderExtensionUri { @@ -443,6 +574,33 @@ pub enum RtpHeaderExtensionUri { Unsupported, } +impl FromStr for RtpHeaderExtensionUri { + type Err = RtpHeaderExtensionUriParseError; + + fn from_str(s: &str) -> Result { + match s { + "urn:ietf:params:rtp-hdrext:sdes:mid" => Ok(Self::Mid), + "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id" => Ok(Self::RtpStreamId), + "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id" => Ok(Self::RepairRtpStreamId), + "http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07" => { + Ok(Self::FrameMarkingDraft07) + } + "urn:ietf:params:rtp-hdrext:framemarking" => Ok(Self::FrameMarking), + "urn:ietf:params:rtp-hdrext:ssrc-audio-level" => Ok(Self::AudioLevel), + "urn:3gpp:video-orientation" => Ok(Self::VideoOrientation), + "urn:ietf:params:rtp-hdrext:toffset" => Ok(Self::TimeOffset), + "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01" => { + Ok(Self::TransportWideCcDraft01) + } + "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time" => Ok(Self::AbsSendTime), + "http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time" => { + Ok(Self::AbsCaptureTime) + } + _ => Err(RtpHeaderExtensionUriParseError::Unsupported), + } + } +} + impl RtpHeaderExtensionUri { /// RTP header extension as a string #[must_use] @@ -545,6 +703,216 @@ pub struct RtpParameters { pub rtcp: RtcpParameters, } +impl RtpParameters { + pub(crate) fn from_fbs( + rtp_parameters: rtp_parameters::RtpParameters, + ) -> Result> { + Ok(Self { + mid: rtp_parameters.mid, + codecs: rtp_parameters + .codecs + .into_iter() + .map(|codec| { + let parameters = codec + .parameters + .unwrap_or_default() + .into_iter() + .map(|parameters| { + Ok(( + Cow::Owned(parameters.name), + match parameters.value.ok_or("Value must always be specified")? { + rtp_parameters::Value::Boolean(_) + | rtp_parameters::Value::Double(_) + | rtp_parameters::Value::IntegerArray(_) => { + // TODO: Above value variant should not exist in the + // first place + panic!("Invalid parameter") + } + rtp_parameters::Value::Integer(n) => { + RtpCodecParametersParametersValue::Number( + n.value.try_into()?, + ) + } + rtp_parameters::Value::String(s) => { + RtpCodecParametersParametersValue::String( + s.value.unwrap_or_default().into(), + ) + } + }, + )) + }) + .collect::>>()?; + let rtcp_feedback = codec + .rtcp_feedback + .unwrap_or_default() + .into_iter() + .map(|rtcp_feedback| { + RtcpFeedback::from_type_parameter( + &rtcp_feedback.type_, + &rtcp_feedback.parameter.unwrap_or_default(), + ) + }) + .collect::>()?; + + Ok(match MimeType::from_str(&codec.mime_type)? { + MimeType::Audio(mime_type) => RtpCodecParameters::Audio { + mime_type, + payload_type: codec.payload_type, + clock_rate: codec.clock_rate.try_into()?, + channels: codec + .channels + .ok_or("Audio must have channels specified")? + .try_into()?, + parameters, + rtcp_feedback: vec![], + }, + MimeType::Video(mime_type) => RtpCodecParameters::Video { + mime_type, + payload_type: codec.payload_type, + clock_rate: codec.clock_rate.try_into()?, + parameters, + rtcp_feedback, + }, + }) + }) + .collect::>>()?, + header_extensions: rtp_parameters + .header_extensions + .unwrap_or_default() + .into_iter() + .map(|header_extension_parameters| { + Ok(RtpHeaderExtensionParameters { + uri: header_extension_parameters.uri.parse()?, + id: u16::from(header_extension_parameters.id), + encrypt: header_extension_parameters.encrypt, + }) + }) + .collect::>>()?, + encodings: rtp_parameters + .encodings + .unwrap_or_default() + .into_iter() + .map(|encoding| { + Ok(RtpEncodingParameters { + ssrc: encoding.ssrc, + rid: encoding.rid, + codec_payload_type: encoding.codec_payload_type, + rtx: encoding + .rtx + .map(|rtx| RtpEncodingParametersRtx { ssrc: rtx.ssrc }), + dtx: Some(encoding.dtx), + scalability_mode: encoding.scalability_mode.unwrap_or_default().parse()?, + scale_resolution_down_by: None, + max_bitrate: encoding.max_bitrate, + }) + }) + .collect::>>()?, + rtcp: rtp_parameters + .rtcp + .map(|rtcp| RtcpParameters { + cname: rtcp.cname, + reduced_size: rtcp.reduced_size, + mux: None, + }) + .unwrap_or_default(), + }) + } + + pub(crate) fn into_fbs(self) -> rtp_parameters::RtpParameters { + rtp_parameters::RtpParameters { + mid: self.mid, + codecs: self + .codecs + .into_iter() + .map(|codec| rtp_parameters::RtpCodecParameters { + mime_type: codec.mime_type().as_str().to_string(), + payload_type: codec.payload_type(), + clock_rate: codec.clock_rate().get(), + channels: match &codec { + RtpCodecParameters::Audio { channels, .. } => Some(channels.get()), + RtpCodecParameters::Video { .. } => None, + }, + parameters: Some( + codec + .parameters() + .iter() + .map(|(name, value)| rtp_parameters::Parameter { + name: name.to_string(), + value: Some(match value { + RtpCodecParametersParametersValue::String(s) => { + rtp_parameters::Value::String(Box::new( + rtp_parameters::String { + value: Some(s.to_string()), + }, + )) + } + RtpCodecParametersParametersValue::Number(n) => { + rtp_parameters::Value::Integer(Box::new( + rtp_parameters::Integer { value: *n as i32 }, + )) + } + }), + }) + .collect(), + ), + rtcp_feedback: match &codec { + RtpCodecParameters::Audio { .. } => None, + RtpCodecParameters::Video { rtcp_feedback, .. } => Some( + rtcp_feedback + .iter() + .map(|rtcp_feedback| { + let (r#type, parameter) = rtcp_feedback.as_type_parameter(); + rtp_parameters::RtcpFeedback { + type_: r#type.to_string(), + parameter: Some(parameter.to_string()), + } + }) + .collect(), + ), + }, + }) + .collect(), + header_extensions: Some( + self.header_extensions + .into_iter() + .map(|header_extension_parameters| { + rtp_parameters::RtpHeaderExtensionParameters { + uri: header_extension_parameters.uri.as_str().to_string(), + id: header_extension_parameters.id as u8, + encrypt: header_extension_parameters.encrypt, + parameters: None, + } + }) + .collect(), + ), + encodings: Some( + self.encodings + .into_iter() + .map(|encoding| rtp_parameters::RtpEncodingParameters { + ssrc: encoding.ssrc, + rid: encoding.rid, + codec_payload_type: encoding.codec_payload_type, + rtx: encoding + .rtx + .map(|rtx| Box::new(rtp_parameters::Rtx { ssrc: rtx.ssrc })), + dtx: encoding.dtx.unwrap_or_default(), + scalability_mode: if encoding.scalability_mode.is_none() { + None + } else { + Some(encoding.scalability_mode.as_str().to_string()) + }, + max_bitrate: encoding.max_bitrate, + }) + .collect(), + ), + rtcp: Some(Box::new(rtp_parameters::RtcpParameters { + cname: self.rtcp.cname, + reduced_size: self.rtcp.reduced_size, + })), + } + } +} + /// Single value used in RTP codec parameters. #[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)] #[serde(untagged)] @@ -654,6 +1022,11 @@ impl RtpCodecParameters { *payload_type } + pub(crate) fn clock_rate(&self) -> NonZeroU32 { + let (Self::Audio { clock_rate, .. } | Self::Video { clock_rate, .. }) = self; + *clock_rate + } + pub(crate) fn parameters(&self) -> &RtpCodecParametersParameters { let (Self::Audio { parameters, .. } | Self::Video { parameters, .. }) = self; parameters @@ -690,32 +1063,9 @@ impl Serialize for RtcpFeedback { S: Serializer, { let mut rtcp_feedback = serializer.serialize_struct("RtcpFeedback", 2)?; - match self { - RtcpFeedback::Nack => { - rtcp_feedback.serialize_field("type", "nack")?; - rtcp_feedback.serialize_field("parameter", "")?; - } - RtcpFeedback::NackPli => { - rtcp_feedback.serialize_field("type", "nack")?; - rtcp_feedback.serialize_field("parameter", "pli")?; - } - RtcpFeedback::CcmFir => { - rtcp_feedback.serialize_field("type", "ccm")?; - rtcp_feedback.serialize_field("parameter", "fir")?; - } - RtcpFeedback::GoogRemb => { - rtcp_feedback.serialize_field("type", "goog-remb")?; - rtcp_feedback.serialize_field("parameter", "")?; - } - RtcpFeedback::TransportCc => { - rtcp_feedback.serialize_field("type", "transport-cc")?; - rtcp_feedback.serialize_field("parameter", "")?; - } - RtcpFeedback::Unsupported => { - rtcp_feedback.serialize_field("type", "unknown")?; - rtcp_feedback.serialize_field("parameter", "")?; - } - } + let (r#type, parameter) = self.as_type_parameter(); + rtcp_feedback.serialize_field("type", r#type)?; + rtcp_feedback.serialize_field("parameter", parameter)?; rtcp_feedback.end() } } @@ -767,14 +1117,10 @@ impl<'de> Deserialize<'de> for RtcpFeedback { } let r#type = r#type.ok_or_else(|| de::Error::missing_field("type"))?; - Ok(match (r#type.as_ref(), parameter.as_ref()) { - ("nack", "") => RtcpFeedback::Nack, - ("nack", "pli") => RtcpFeedback::NackPli, - ("ccm", "fir") => RtcpFeedback::CcmFir, - ("goog-remb", "") => RtcpFeedback::GoogRemb, - ("transport-cc", "") => RtcpFeedback::TransportCc, - _ => RtcpFeedback::Unsupported, - }) + Ok( + RtcpFeedback::from_type_parameter(r#type.as_ref(), parameter.as_ref()) + .unwrap_or(RtcpFeedback::Unsupported), + ) } } @@ -783,6 +1129,42 @@ impl<'de> Deserialize<'de> for RtcpFeedback { } } +/// Error of failure to create [`RtcpFeedback`] from type and parameter. +#[derive(Debug, Error, Eq, PartialEq)] +pub enum RtcpFeedbackFromTypeParameterError { + /// Unsupported + #[error("Unsupported")] + Unsupported, +} + +impl RtcpFeedback { + pub(crate) fn from_type_parameter( + r#type: &str, + parameter: &str, + ) -> Result { + match (r#type, parameter) { + ("nack", "") => Ok(RtcpFeedback::Nack), + ("nack", "pli") => Ok(RtcpFeedback::NackPli), + ("ccm", "fir") => Ok(RtcpFeedback::CcmFir), + ("goog-remb", "") => Ok(RtcpFeedback::GoogRemb), + ("transport-cc", "") => Ok(RtcpFeedback::TransportCc), + ("unknown", "") => Ok(RtcpFeedback::Unsupported), + _ => Err(RtcpFeedbackFromTypeParameterError::Unsupported), + } + } + + pub(crate) fn as_type_parameter(&self) -> (&'static str, &'static str) { + match self { + RtcpFeedback::Nack => ("nack", ""), + RtcpFeedback::NackPli => ("nack", "pli"), + RtcpFeedback::CcmFir => ("ccm", "fir"), + RtcpFeedback::GoogRemb => ("goog-remb", ""), + RtcpFeedback::TransportCc => ("transport-cc", ""), + RtcpFeedback::Unsupported => ("unknown", ""), + } + } +} + /// RTX stream information. It must contain a numeric ssrc field indicating the RTX SSRC. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)] pub struct RtpEncodingParametersRtx { From b251450024ec1b9ce0a94c5f916919c78c83cb89 Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Sun, 30 Jul 2023 23:59:21 +0300 Subject: [PATCH 14/73] Commit `Cargo.lock` file like it is done for Node.js --- .gitignore | 1 - Cargo.lock | 1933 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1933 insertions(+), 1 deletion(-) create mode 100644 Cargo.lock diff --git a/.gitignore b/.gitignore index 34b636ecc8..4c488de2f1 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ /node/src/fbs ## Rust. -/Cargo.lock /rust/examples-frontend/*/node_modules /rust/examples-frontend/*/package-lock.json /target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000000..99fd4179f0 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1933 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "actix" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f728064aca1c318585bf4bb04ffcfac9e75e508ab4e8b1bd9ba5dfe04e2cbed5" +dependencies = [ + "actix-rt", + "actix_derive", + "bitflags", + "bytes", + "crossbeam-channel", + "futures-core", + "futures-sink", + "futures-task", + "futures-util", + "log", + "once_cell", + "parking_lot 0.12.1", + "pin-project-lite", + "smallvec", + "tokio", + "tokio-util 0.7.0", +] + +[[package]] +name = "actix-codec" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a7559404a7f3573127aab53c08ce37a6c6a315c374a31070f3c91cd1b4a7fe" +dependencies = [ + "bitflags", + "bytes", + "futures-core", + "futures-sink", + "log", + "memchr", + "pin-project-lite", + "tokio", + "tokio-util 0.7.0", +] + +[[package]] +name = "actix-http" +version = "3.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c83abf9903e1f0ad9973cc4f7b9767fd5a03a583f51a5b7a339e07987cd2724" +dependencies = [ + "actix-codec", + "actix-rt", + "actix-service", + "actix-utils", + "ahash 0.7.6", + "base64", + "bitflags", + "bytes", + "bytestring", + "derive_more", + "encoding_rs", + "futures-core", + "h2", + "http", + "httparse", + "httpdate", + "itoa", + "language-tags", + "local-channel", + "mime", + "percent-encoding", + "pin-project-lite", + "rand", + "sha1", + "smallvec", + "tracing", +] + +[[package]] +name = "actix-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "actix-router" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb60846b52c118f2f04a56cc90880a274271c489b2498623d58176f8ca21fa80" +dependencies = [ + "bytestring", + "firestorm", + "http", + "log", + "regex", + "serde", +] + +[[package]] +name = "actix-rt" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdf3f2183be1241ed4dd22611850b85d38de0b08a09f1f7bcccbd0809084b359" +dependencies = [ + "futures-core", + "tokio", +] + +[[package]] +name = "actix-server" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9e7472ac180abb0a8e592b653744345983a7a14f44691c8394a799d0df4dbbf" +dependencies = [ + "actix-rt", + "actix-service", + "actix-utils", + "futures-core", + "futures-util", + "log", + "mio", + "num_cpus", + "socket2", + "tokio", +] + +[[package]] +name = "actix-service" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b894941f818cfdc7ccc4b9e60fa7e53b5042a2e8567270f9147d5591893373a" +dependencies = [ + "futures-core", + "paste 1.0.6", + "pin-project-lite", +] + +[[package]] +name = "actix-utils" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e491cbaac2e7fc788dfff99ff48ef317e23b3cf63dbaf7aaab6418f40f92aa94" +dependencies = [ + "local-waker", + "pin-project-lite", +] + +[[package]] +name = "actix-web" +version = "4.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d48f7b6534e06c7bfc72ee91db7917d4af6afe23e7d223b51e68fffbb21e96b9" +dependencies = [ + "actix-codec", + "actix-http", + "actix-macros", + "actix-router", + "actix-rt", + "actix-server", + "actix-service", + "actix-utils", + "actix-web-codegen", + "ahash 0.7.6", + "bytes", + "bytestring", + "cfg-if", + "derive_more", + "encoding_rs", + "futures-core", + "futures-util", + "http", + "itoa", + "language-tags", + "log", + "mime", + "once_cell", + "pin-project-lite", + "regex", + "serde", + "serde_json", + "serde_urlencoded", + "smallvec", + "socket2", + "time", + "url", +] + +[[package]] +name = "actix-web-actors" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31efe7896f3933ce03dd4710be560254272334bb321a18fd8ff62b1a557d9d19" +dependencies = [ + "actix", + "actix-codec", + "actix-http", + "actix-web", + "bytes", + "bytestring", + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "actix-web-codegen" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa9362663c8643d67b2d5eafba49e4cb2c8a053a29ed00a0bea121f17c76b13" +dependencies = [ + "actix-router", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "actix_derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d44b8fee1ced9671ba043476deddef739dd0959bf77030b26b738cc591737a7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + +[[package]] +name = "array-init-cursor" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7d0a018de4f6aa429b9d33d69edf69072b1c5b1cb8d3e4a5f7ef898fc3eb76" + +[[package]] +name = "async-channel" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14485364214912d3b19cc3435dde4df66065127f05fa0d75c712f36f12c2f28" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + +[[package]] +name = "async-executor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "once_cell", + "slab", +] + +[[package]] +name = "async-io" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8121296a9f05be7f34aa4196b1747243b3b62e048bb7906f644f3fbfc490cf7" +dependencies = [ + "async-lock", + "autocfg", + "concurrent-queue", + "futures-lite", + "libc", + "log", + "parking", + "polling", + "slab", + "socket2", + "waker-fn", + "winapi", +] + +[[package]] +name = "async-lock" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" +dependencies = [ + "event-listener", + "futures-lite", +] + +[[package]] +name = "async-oneshot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec7c75bcbcb0139e9177f30692fd617405ca4e0c27802e128d53171f7042e2c" +dependencies = [ + "futures-micro", +] + +[[package]] +name = "async-task" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d306121baf53310a3fd342d88dc0824f6bbeace68347593658525565abee8" + +[[package]] +name = "async-trait" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atomic-take" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f65e4fb35ff6a80b3298d1f028649f3a23da141fa3951e9b24dde1d515b67e" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitpattern" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fc436c543b5fd522e5428d65c88e7bfb538ba267dad95cfb9d8fb8a465b0935" +dependencies = [ + "paste 0.1.18", + "proc-macro2", + "quote", +] + +[[package]] +name = "block-buffer" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" + +[[package]] +name = "bytes" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" + +[[package]] +name = "bytestring" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90706ba19e97b90786e19dc0d5e2abd80008d99d4c0c5d1ad0b5e72cec7c494d" +dependencies = [ + "bytes", +] + +[[package]] +name = "cache-padded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "ciborium" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c137568cc60b904a7724001b35ce2630fd00d5d84805fbb608ab89509d788f" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346de753af073cc87b52b2083a506b38ac176a44cfb05497b622e27be899b369" + +[[package]] +name = "ciborium-ll" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213030a2b5a4e0c0892b6652260cf6ccac84827b83a85a534e178e3906c4cf1b" +dependencies = [ + "ciborium-io", + "half", +] + +[[package]] +name = "clap" +version = "3.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +dependencies = [ + "bitflags", + "clap_lex", + "indexmap", + "textwrap", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "concurrent-queue" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" +dependencies = [ + "cache-padded", +] + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "cpufeatures" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" +dependencies = [ + "libc", +] + +[[package]] +name = "criterion" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c76e09c1aae2bc52b3d2f29e13c6572553b30c4aa1b8a49fd70de6412654cb" +dependencies = [ + "anes", + "atty", + "cast", + "ciborium", + "clap", + "criterion-plot", + "itertools", + "lazy_static", + "num-traits", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6" +dependencies = [ + "cfg-if", + "lazy_static", +] + +[[package]] +name = "crypto-common" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + +[[package]] +name = "digest" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "encoding_rs" +version = "0.8.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "env_logger" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c90bf5f19754d10198ccb95b70664fc925bd1fc090a0fd9a6ebc54acc8cd6272" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "event-listener" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" + +[[package]] +name = "event-listener-primitives" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5384093b4255393cc8c42f0fc3dd4f19977ad3b1025f968257854895a993028c" +dependencies = [ + "nohash-hasher", + "parking_lot 0.11.2", + "smallvec", +] + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + +[[package]] +name = "firestorm" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d3d6188b8804df28032815ea256b6955c9625c24da7525f387a7af02fbb8f01" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + +[[package]] +name = "futures-core" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" + +[[package]] +name = "futures-io" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" + +[[package]] +name = "futures-lite" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + +[[package]] +name = "futures-micro" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b460264b3593d68b16a7bc35f7bc226ddfebdf9a1c8db1ed95d5cc6b7168c826" +dependencies = [ + "pin-project-lite", +] + +[[package]] +name = "futures-sink" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" + +[[package]] +name = "futures-task" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" + +[[package]] +name = "futures-util" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "h2" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9f1f717ddc7b2ba36df7e871fd88db79326551d3d6f1fc406fbfd28b582ff8e" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util 0.6.9", + "tracing", +] + +[[package]] +name = "h264-profile-level-id" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12ebc03fc4f14b7ddc94da90cfb28ba3edee2d926798a9eef89f8a27bbdbca5" +dependencies = [ + "bitpattern", + "log", + "once_cell", + "thiserror", +] + +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + +[[package]] +name = "hash_hasher" +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" + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.3", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" +dependencies = [ + "autocfg", + "hashbrown 0.11.2", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itertools" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" + +[[package]] +name = "js-sys" +version = "0.3.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "language-tags" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" + +[[package]] +name = "local-channel" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6246c68cf195087205a0512559c97e15eaf95198bf0e206d662092cdcb03fe9f" +dependencies = [ + "futures-core", + "futures-sink", + "futures-util", + "local-waker", +] + +[[package]] +name = "local-waker" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "902eb695eb0591864543cbfbf6d742510642a605a61fc5e97fe6ceb5a30ac4fb" + +[[package]] +name = "lock_api" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" +dependencies = [ + "scopeguard", + "serde", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "lru" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" + +[[package]] +name = "matches" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" + +[[package]] +name = "mediasoup" +version = "0.11.4" +dependencies = [ + "actix", + "actix-web", + "actix-web-actors", + "async-channel", + "async-executor", + "async-io", + "async-lock", + "async-oneshot", + "async-trait", + "atomic-take", + "criterion", + "env_logger", + "event-listener-primitives", + "fastrand", + "futures-lite", + "h264-profile-level-id", + "hash_hasher", + "log", + "lru", + "mediasoup-sys", + "nohash-hasher", + "once_cell", + "parking_lot 0.12.1", + "planus", + "portpicker", + "regex", + "serde", + "serde_json", + "serde_repr", + "thiserror", + "uuid", +] + +[[package]] +name = "mediasoup-sys" +version = "0.5.4" + +[[package]] +name = "memchr" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "mio" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2" +dependencies = [ + "libc", + "log", + "miow", + "ntapi", + "winapi", +] + +[[package]] +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "ntapi" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" +dependencies = [ + "winapi", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "num_threads" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97ba99ba6393e2c3734791401b66902d981cb03bf190af674ca69949b6d5fb15" +dependencies = [ + "libc", +] + +[[package]] +name = "once_cell" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" + +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + +[[package]] +name = "os_str_bytes" +version = "6.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3baf96e39c5359d2eb0dd6ccb42c62b91d9678aa68160d261b9e0ccbf9e9dea9" + +[[package]] +name = "parking" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.5", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.1", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + +[[package]] +name = "paste" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" +dependencies = [ + "paste-impl", + "proc-macro-hack", +] + +[[package]] +name = "paste" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5" + +[[package]] +name = "paste-impl" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" +dependencies = [ + "proc-macro-hack", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pin-project-lite" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "planus" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cbec589fda965e8d0cf7dddaa87d37ae5ccaed0c43986e8faf5998f24ef82f5" +dependencies = [ + "array-init-cursor", + "hashbrown 0.13.2", +] + +[[package]] +name = "plotters" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" + +[[package]] +name = "plotters-svg" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" +dependencies = [ + "plotters-backend", +] + +[[package]] +name = "polling" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "685404d509889fade3e86fe3a5803bca2ec09b0c0778d5ada6ec8bf7a8de5259" +dependencies = [ + "cfg-if", + "libc", + "log", + "wepoll-ffi", + "winapi", +] + +[[package]] +name = "portpicker" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be97d76faf1bfab666e1375477b23fde79eccf0276e9b63b92a39d676a889ba9" +dependencies = [ + "rand", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rayon" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "lazy_static", + "num_cpus", +] + +[[package]] +name = "redox_syscall" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "semver" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a3381e03edd24287172047536f20cabde766e2cd3e65e6b00fb3af51c4f38d" + +[[package]] +name = "serde" +version = "1.0.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_repr" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fe39d9fbb0ebf5eb2c7cb7e2a47e4f462fad1379f1166b8ae49ad9eae89a7ca" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" + +[[package]] +name = "smallvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" + +[[package]] +name = "socket2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "syn" +version = "1.0.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" + +[[package]] +name = "thiserror" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "004cbc98f30fa233c61a38bc77e96a9106e65c88f2d3bef182ae952027e5753d" +dependencies = [ + "itoa", + "libc", + "num_threads", +] + +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "tinyvec" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee" +dependencies = [ + "bytes", + "libc", + "memchr", + "mio", + "once_cell", + "parking_lot 0.12.1", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "winapi", +] + +[[package]] +name = "tokio-util" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64910e1b9c1901aaf5375561e35b9c057d95ff41a44ede043a03e09279eabaf1" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tracing" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6c650a8ef0cd2dd93736f033d21cbd1224c5a967aa0c258d00fcf7dafef9b9f" +dependencies = [ + "cfg-if", + "log", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03cfcb51380632a72d3111cb8d3447a8d908e577d31beeac006f836383d29a23" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "unicode-bidi" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" + +[[package]] +name = "unicode-ident" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" + +[[package]] +name = "unicode-normalization" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "uuid" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" +dependencies = [ + "getrandom", + "serde", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "waker-fn" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" + +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "wasm-bindgen" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" + +[[package]] +name = "web-sys" +version = "0.3.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wepoll-ffi" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" +dependencies = [ + "cc", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" + +[[package]] +name = "windows_i686_gnu" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" + +[[package]] +name = "windows_i686_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" From f6c930b60fcab634196d39a53570195aee375cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Sun, 6 Aug 2023 18:21:18 +0200 Subject: [PATCH 15/73] FBS enhancements (#1134) * RtpParameters: make Parameter.value required * RtpParameters: make String Parameter required * RtpParameters: make RtcpFeedback parameter required * RtpParameters: make encodings required * RtpParameters: make RtcpParameters required * Rust: RtpEncodingParameters, remove scale_resolution_by * fix tests * Rust: RtpParameters, make headerExtensions required * Worker: consider new required RtpParameters --- rust/src/fbs.rs | 321 +++++------------- rust/src/ortc.rs | 1 - rust/src/ortc/tests.rs | 3 - rust/src/rtp_parameters.rs | 106 +++--- rust/tests/integration/consumer.rs | 2 - rust/tests/integration/producer.rs | 5 - worker/fbs/rtpParameters.fbs | 12 +- worker/include/RTC/RtpDictionaries.hpp | 1 - .../src/RTC/RtpDictionaries/RtcpFeedback.cpp | 7 +- .../src/RTC/RtpDictionaries/RtpParameters.cpp | 30 +- 10 files changed, 142 insertions(+), 346 deletions(-) diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index b7cc195bd0..fa6c05ed71 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -13389,16 +13389,7 @@ mod root { )] pub struct String { /// The field `value` in the table `String` - pub value: ::core::option::Option<::planus::alloc::string::String>, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for String { - fn default() -> Self { - Self { - value: ::core::default::Default::default(), - } - } + pub value: ::planus::alloc::string::String, } impl String { @@ -13411,23 +13402,17 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_value: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, + 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(); - if prepared_value.is_some() { - table_writer.write_entry::<::planus::Offset>(0); - } + table_writer.write_entry::<::planus::Offset>(0); unsafe { table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_value) = prepared_value { - object_writer.write::<_, _, 4>(&prepared_value); - } + object_writer.write::<_, _, 4>(&prepared_value); }); } builder.current_offset() @@ -13475,17 +13460,10 @@ mod root { #[allow(clippy::type_complexity)] pub fn value(self, value: T0) -> StringBuilder<(T0,)> where - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T0: ::planus::WriteAs<::planus::Offset>, { StringBuilder((value,)) } - - /// Sets the [`value` field](String#structfield.value) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn value_as_null(self) -> StringBuilder<((),)> { - self.value(()) - } } impl StringBuilder<(T0,)> { @@ -13499,7 +13477,7 @@ mod root { } } - impl>> + impl>> ::planus::WriteAs<::planus::Offset> for StringBuilder<(T0,)> { type Prepared = ::planus::Offset; @@ -13510,7 +13488,7 @@ mod root { } } - impl>> + impl>> ::planus::WriteAsOptional<::planus::Offset> for StringBuilder<(T0,)> { type Prepared = ::planus::Offset; @@ -13524,8 +13502,8 @@ mod root { } } - impl>> - ::planus::WriteAsOffset for StringBuilder<(T0,)> + impl>> ::planus::WriteAsOffset + for StringBuilder<(T0,)> { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { @@ -13541,20 +13519,15 @@ mod root { impl<'a> StringRef<'a> { /// Getter for the [`value` field](String#structfield.value). #[inline] - pub fn value( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(0, "String", "value") + 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"); - if let ::core::option::Option::Some(field_value) = self.value().transpose() { - f.field("value", &field_value); - } + f.field("value", &self.value()); f.finish() } } @@ -13565,11 +13538,7 @@ mod root { #[allow(unreachable_code)] fn try_from(value: StringRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - value: if let ::core::option::Option::Some(value) = value.value()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(value)?) - } else { - ::core::option::Option::None - }, + value: ::core::convert::TryInto::try_into(value.value()?)?, }) } } @@ -13999,7 +13968,7 @@ mod root { /// The field `name` in the table `Parameter` pub name: ::planus::alloc::string::String, /// The field `value` in the table `Parameter` - pub value: ::core::option::Option, + pub value: self::Value, } impl Parameter { @@ -14013,7 +13982,7 @@ mod root { pub fn create( builder: &mut ::planus::Builder, field_name: impl ::planus::WriteAs<::planus::Offset>, - field_value: impl ::planus::WriteAsOptionalUnion, + field_value: impl ::planus::WriteAsUnion, ) -> ::planus::Offset { let prepared_name = field_name.prepare(builder); let prepared_value = field_value.prepare(builder); @@ -14021,22 +13990,14 @@ mod root { let mut table_writer: ::planus::table_writer::TableWriter<10> = ::core::default::Default::default(); table_writer.write_entry::<::planus::Offset>(0); - if prepared_value.is_some() { - table_writer.write_entry::<::planus::Offset>(2); - } - if prepared_value.is_some() { - table_writer.write_entry::(1); - } + 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); - if let ::core::option::Option::Some(prepared_value) = prepared_value { - object_writer.write::<_, _, 4>(&prepared_value.offset()); - } - if let ::core::option::Option::Some(prepared_value) = prepared_value { - object_writer.write::<_, _, 1>(&prepared_value.tag()); - } + object_writer.write::<_, _, 4>(&prepared_value.offset()); + object_writer.write::<_, _, 1>(&prepared_value.tag()); }); } builder.current_offset() @@ -14096,18 +14057,11 @@ mod root { #[allow(clippy::type_complexity)] pub fn value(self, value: T1) -> ParameterBuilder<(T0, T1)> where - T1: ::planus::WriteAsOptionalUnion, + T1: ::planus::WriteAsUnion, { let (v0,) = self.0; ParameterBuilder((v0, value)) } - - /// Sets the [`value` field](Parameter#structfield.value) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn value_as_null(self) -> ParameterBuilder<(T0, ())> { - self.value(()) - } } impl ParameterBuilder<(T0, T1)> { @@ -14123,7 +14077,7 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptionalUnion, + T1: ::planus::WriteAsUnion, > ::planus::WriteAs<::planus::Offset> for ParameterBuilder<(T0, T1)> { type Prepared = ::planus::Offset; @@ -14136,7 +14090,7 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptionalUnion, + T1: ::planus::WriteAsUnion, > ::planus::WriteAsOptional<::planus::Offset> for ParameterBuilder<(T0, T1)> { @@ -14153,7 +14107,7 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptionalUnion, + T1: ::planus::WriteAsUnion, > ::planus::WriteAsOffset for ParameterBuilder<(T0, T1)> { #[inline] @@ -14176,10 +14130,8 @@ mod root { /// Getter for the [`value` field](Parameter#structfield.value). #[inline] - pub fn value( - &self, - ) -> ::planus::Result<::core::option::Option>> { - self.0.access_union(1, "Parameter", "value") + pub fn value(&self) -> ::planus::Result> { + self.0.access_union_required(1, "Parameter", "value") } } @@ -14187,9 +14139,7 @@ mod root { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut f = f.debug_struct("ParameterRef"); f.field("name", &self.name()); - if let ::core::option::Option::Some(field_value) = self.value().transpose() { - f.field("value", &field_value); - } + f.field("value", &self.value()); f.finish() } } @@ -14201,11 +14151,7 @@ mod root { fn try_from(value: ParameterRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { name: ::core::convert::TryInto::try_into(value.name()?)?, - value: if let ::core::option::Option::Some(value) = value.value()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(value)?) - } else { - ::core::option::Option::None - }, + value: ::core::convert::TryInto::try_into(value.value()?)?, }) } } @@ -14299,7 +14245,7 @@ mod root { /// 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>, + pub parameter: ::planus::alloc::string::String, } impl RtcpFeedback { @@ -14313,9 +14259,7 @@ mod root { pub fn create( builder: &mut ::planus::Builder, field_type_: impl ::planus::WriteAs<::planus::Offset>, - field_parameter: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, + field_parameter: impl ::planus::WriteAs<::planus::Offset>, ) -> ::planus::Offset { let prepared_type_ = field_type_.prepare(builder); let prepared_parameter = field_parameter.prepare(builder); @@ -14323,18 +14267,12 @@ mod root { 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); - } + 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); - } + object_writer.write::<_, _, 4>(&prepared_parameter); }); } builder.current_offset() @@ -14400,18 +14338,11 @@ mod root { #[allow(clippy::type_complexity)] pub fn parameter(self, value: T1) -> RtcpFeedbackBuilder<(T0, T1)> where - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T1: ::planus::WriteAs<::planus::Offset>, { 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)> { @@ -14430,7 +14361,7 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T1: ::planus::WriteAs<::planus::Offset>, > ::planus::WriteAs<::planus::Offset> for RtcpFeedbackBuilder<(T0, T1)> { @@ -14447,7 +14378,7 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T1: ::planus::WriteAs<::planus::Offset>, > ::planus::WriteAsOptional<::planus::Offset> for RtcpFeedbackBuilder<(T0, T1)> { @@ -14464,7 +14395,7 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T1: ::planus::WriteAs<::planus::Offset>, > ::planus::WriteAsOffset for RtcpFeedbackBuilder<(T0, T1)> { #[inline] @@ -14490,11 +14421,8 @@ mod root { /// 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") + pub fn parameter(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(1, "RtcpFeedback", "parameter") } } @@ -14502,11 +14430,7 @@ mod root { 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.field("parameter", &self.parameter()); f.finish() } } @@ -14518,15 +14442,7 @@ mod root { 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 - }, + parameter: ::core::convert::TryInto::try_into(value.parameter()?)?, }) } } @@ -16875,14 +16791,12 @@ mod root { /// The field `codecs` in the table `RtpParameters` pub codecs: ::planus::alloc::vec::Vec, /// The field `header_extensions` in the table `RtpParameters` - pub header_extensions: ::core::option::Option< + pub header_extensions: ::planus::alloc::vec::Vec, - >, /// The field `encodings` in the table `RtpParameters` - pub encodings: - ::core::option::Option<::planus::alloc::vec::Vec>, + pub encodings: ::planus::alloc::vec::Vec, /// The field `rtcp` in the table `RtpParameters` - pub rtcp: ::core::option::Option<::planus::alloc::boxed::Box>, + pub rtcp: ::planus::alloc::boxed::Box, } impl RtpParameters { @@ -16899,13 +16813,13 @@ mod root { field_codecs: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - field_header_extensions: impl ::planus::WriteAsOptional< + field_header_extensions: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - field_encodings: impl ::planus::WriteAsOptional< + field_encodings: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - field_rtcp: impl ::planus::WriteAsOptional<::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); @@ -16919,19 +16833,11 @@ mod root { table_writer.write_entry::<::planus::Offset>(0); } table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(1); - if prepared_header_extensions.is_some() { - table_writer.write_entry::<::planus::Offset< - [::planus::Offset], - >>(2); - } - if prepared_encodings.is_some() { - table_writer.write_entry::<::planus::Offset< - [::planus::Offset], - >>(3); - } - if prepared_rtcp.is_some() { - table_writer.write_entry::<::planus::Offset>(4); - } + 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| { @@ -16939,19 +16845,9 @@ mod root { object_writer.write::<_, _, 4>(&prepared_mid); } object_writer.write::<_, _, 4>(&prepared_codecs); - if let ::core::option::Option::Some(prepared_header_extensions) = - prepared_header_extensions - { - object_writer.write::<_, _, 4>(&prepared_header_extensions); - } - if let ::core::option::Option::Some(prepared_encodings) = - prepared_encodings - { - object_writer.write::<_, _, 4>(&prepared_encodings); - } - if let ::core::option::Option::Some(prepared_rtcp) = prepared_rtcp { - object_writer.write::<_, _, 4>(&prepared_rtcp); - } + object_writer.write::<_, _, 4>(&prepared_header_extensions); + object_writer.write::<_, _, 4>(&prepared_encodings); + object_writer.write::<_, _, 4>(&prepared_rtcp); }); } builder.current_offset() @@ -17046,20 +16942,13 @@ mod root { #[allow(clippy::type_complexity)] pub fn header_extensions(self, value: T2) -> RtpParametersBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAsOptional< + T2: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, { let (v0, v1) = self.0; RtpParametersBuilder((v0, v1, value)) } - - /// Sets the [`header_extensions` field](RtpParameters#structfield.header_extensions) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn header_extensions_as_null(self) -> RtpParametersBuilder<(T0, T1, ())> { - self.header_extensions(()) - } } impl RtpParametersBuilder<(T0, T1, T2)> { @@ -17068,20 +16957,13 @@ mod root { #[allow(clippy::type_complexity)] pub fn encodings(self, value: T3) -> RtpParametersBuilder<(T0, T1, T2, T3)> where - T3: ::planus::WriteAsOptional< + T3: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, { let (v0, v1, v2) = self.0; RtpParametersBuilder((v0, v1, v2, value)) } - - /// Sets the [`encodings` field](RtpParameters#structfield.encodings) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn encodings_as_null(self) -> RtpParametersBuilder<(T0, T1, T2, ())> { - self.encodings(()) - } } impl RtpParametersBuilder<(T0, T1, T2, T3)> { @@ -17090,18 +16972,11 @@ mod root { #[allow(clippy::type_complexity)] pub fn rtcp(self, value: T4) -> RtpParametersBuilder<(T0, T1, T2, T3, T4)> where - T4: ::planus::WriteAsOptional<::planus::Offset>, + T4: ::planus::WriteAs<::planus::Offset>, { let (v0, v1, v2, v3) = self.0; RtpParametersBuilder((v0, v1, v2, v3, value)) } - - /// Sets the [`rtcp` field](RtpParameters#structfield.rtcp) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_as_null(self) -> RtpParametersBuilder<(T0, T1, T2, T3, ())> { - self.rtcp(()) - } } impl RtpParametersBuilder<(T0, T1, T2, T3, T4)> { @@ -17123,13 +16998,13 @@ mod root { T1: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - T2: ::planus::WriteAsOptional< + T2: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - T3: ::planus::WriteAsOptional< + T3: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - T4: ::planus::WriteAsOptional<::planus::Offset>, + T4: ::planus::WriteAs<::planus::Offset>, > ::planus::WriteAs<::planus::Offset> for RtpParametersBuilder<(T0, T1, T2, T3, T4)> { @@ -17149,13 +17024,13 @@ mod root { T1: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - T2: ::planus::WriteAsOptional< + T2: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - T3: ::planus::WriteAsOptional< + T3: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - T4: ::planus::WriteAsOptional<::planus::Offset>, + T4: ::planus::WriteAs<::planus::Offset>, > ::planus::WriteAsOptional<::planus::Offset> for RtpParametersBuilder<(T0, T1, T2, T3, T4)> { @@ -17175,13 +17050,13 @@ mod root { T1: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - T2: ::planus::WriteAsOptional< + T2: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - T3: ::planus::WriteAsOptional< + T3: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - T4: ::planus::WriteAsOptional<::planus::Offset>, + T4: ::planus::WriteAs<::planus::Offset>, > ::planus::WriteAsOffset for RtpParametersBuilder<(T0, T1, T2, T3, T4)> { @@ -17224,14 +17099,13 @@ mod root { pub fn header_extensions( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector< - 'a, - ::planus::Result>, - >, + ::planus::Vector< + 'a, + ::planus::Result>, >, > { - self.0.access(2, "RtpParameters", "header_extensions") + self.0 + .access_required(2, "RtpParameters", "header_extensions") } /// Getter for the [`encodings` field](RtpParameters#structfield.encodings). @@ -17239,20 +17113,15 @@ mod root { pub fn encodings( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, + ::planus::Vector<'a, ::planus::Result>>, > { - self.0.access(3, "RtpParameters", "encodings") + self.0.access_required(3, "RtpParameters", "encodings") } /// Getter for the [`rtcp` field](RtpParameters#structfield.rtcp). #[inline] - pub fn rtcp( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(4, "RtpParameters", "rtcp") + pub fn rtcp(&self) -> ::planus::Result> { + self.0.access_required(4, "RtpParameters", "rtcp") } } @@ -17263,19 +17132,9 @@ mod root { f.field("mid", &field_mid); } f.field("codecs", &self.codecs()); - if let ::core::option::Option::Some(field_header_extensions) = - self.header_extensions().transpose() - { - f.field("header_extensions", &field_header_extensions); - } - if let ::core::option::Option::Some(field_encodings) = - self.encodings().transpose() - { - f.field("encodings", &field_encodings); - } - if let ::core::option::Option::Some(field_rtcp) = self.rtcp().transpose() { - f.field("rtcp", &field_rtcp); - } + f.field("header_extensions", &self.header_extensions()); + f.field("encodings", &self.encodings()); + f.field("rtcp", &self.rtcp()); f.finish() } } @@ -17292,27 +17151,11 @@ mod root { ::core::option::Option::None }, codecs: value.codecs()?.to_vec_result()?, - header_extensions: if let ::core::option::Option::Some(header_extensions) = - value.header_extensions()? - { - ::core::option::Option::Some(header_extensions.to_vec_result()?) - } else { - ::core::option::Option::None - }, - encodings: if let ::core::option::Option::Some(encodings) = - value.encodings()? - { - ::core::option::Option::Some(encodings.to_vec_result()?) - } else { - ::core::option::Option::None - }, - rtcp: if let ::core::option::Option::Some(rtcp) = value.rtcp()? { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(rtcp)?, - )) - } else { - ::core::option::Option::None - }, + 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()?, + )?), }) } } diff --git a/rust/src/ortc.rs b/rust/src/ortc.rs index 489724b6ba..0c92bfb15c 100644 --- a/rust/src/ortc.rs +++ b/rust/src/ortc.rs @@ -603,7 +603,6 @@ pub(crate) fn get_consumable_rtp_parameters( consumable_params.rtcp = RtcpParameters { cname: params.rtcp.cname.clone(), reduced_size: true, - mux: Some(true), }; consumable_params diff --git a/rust/src/ortc/tests.rs b/rust/src/ortc/tests.rs index c2be87d012..564980aa5f 100644 --- a/rust/src/ortc/tests.rs +++ b/rust/src/ortc/tests.rs @@ -368,7 +368,6 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume RtcpParameters { cname: rtp_parameters.rtcp.cname.clone(), reduced_size: true, - mux: Some(true), } ); @@ -543,7 +542,6 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume RtcpParameters { cname: rtp_parameters.rtcp.cname.clone(), reduced_size: true, - mux: Some(true), }, ); @@ -650,7 +648,6 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume RtcpParameters { cname: rtp_parameters.rtcp.cname, reduced_size: true, - mux: Some(true), }, ); } diff --git a/rust/src/rtp_parameters.rs b/rust/src/rtp_parameters.rs index a7889225af..97e6418129 100644 --- a/rust/src/rtp_parameters.rs +++ b/rust/src/rtp_parameters.rs @@ -720,7 +720,7 @@ impl RtpParameters { .map(|parameters| { Ok(( Cow::Owned(parameters.name), - match parameters.value.ok_or("Value must always be specified")? { + match parameters.value { rtp_parameters::Value::Boolean(_) | rtp_parameters::Value::Double(_) | rtp_parameters::Value::IntegerArray(_) => { @@ -734,9 +734,7 @@ impl RtpParameters { ) } rtp_parameters::Value::String(s) => { - RtpCodecParametersParametersValue::String( - s.value.unwrap_or_default().into(), - ) + RtpCodecParametersParametersValue::String(s.value.into()) } }, )) @@ -749,7 +747,7 @@ impl RtpParameters { .map(|rtcp_feedback| { RtcpFeedback::from_type_parameter( &rtcp_feedback.type_, - &rtcp_feedback.parameter.unwrap_or_default(), + &rtcp_feedback.parameter, ) }) .collect::>()?; @@ -778,7 +776,6 @@ impl RtpParameters { .collect::>>()?, header_extensions: rtp_parameters .header_extensions - .unwrap_or_default() .into_iter() .map(|header_extension_parameters| { Ok(RtpHeaderExtensionParameters { @@ -790,7 +787,6 @@ impl RtpParameters { .collect::>>()?, encodings: rtp_parameters .encodings - .unwrap_or_default() .into_iter() .map(|encoding| { Ok(RtpEncodingParameters { @@ -802,19 +798,14 @@ impl RtpParameters { .map(|rtx| RtpEncodingParametersRtx { ssrc: rtx.ssrc }), dtx: Some(encoding.dtx), scalability_mode: encoding.scalability_mode.unwrap_or_default().parse()?, - scale_resolution_down_by: None, max_bitrate: encoding.max_bitrate, }) }) .collect::>>()?, - rtcp: rtp_parameters - .rtcp - .map(|rtcp| RtcpParameters { - cname: rtcp.cname, - reduced_size: rtcp.reduced_size, - mux: None, - }) - .unwrap_or_default(), + rtcp: RtcpParameters { + cname: rtp_parameters.rtcp.cname, + reduced_size: rtp_parameters.rtcp.reduced_size, + }, }) } @@ -838,11 +829,11 @@ impl RtpParameters { .iter() .map(|(name, value)| rtp_parameters::Parameter { name: name.to_string(), - value: Some(match value { + value: match value { RtpCodecParametersParametersValue::String(s) => { rtp_parameters::Value::String(Box::new( rtp_parameters::String { - value: Some(s.to_string()), + value: s.to_string(), }, )) } @@ -851,7 +842,7 @@ impl RtpParameters { rtp_parameters::Integer { value: *n as i32 }, )) } - }), + }, }) .collect(), ), @@ -864,7 +855,7 @@ impl RtpParameters { let (r#type, parameter) = rtcp_feedback.as_type_parameter(); rtp_parameters::RtcpFeedback { type_: r#type.to_string(), - parameter: Some(parameter.to_string()), + parameter: parameter.to_string(), } }) .collect(), @@ -872,43 +863,41 @@ impl RtpParameters { }, }) .collect(), - header_extensions: Some( - self.header_extensions - .into_iter() - .map(|header_extension_parameters| { - rtp_parameters::RtpHeaderExtensionParameters { - uri: header_extension_parameters.uri.as_str().to_string(), - id: header_extension_parameters.id as u8, - encrypt: header_extension_parameters.encrypt, - parameters: None, - } - }) - .collect(), - ), - encodings: Some( - self.encodings - .into_iter() - .map(|encoding| rtp_parameters::RtpEncodingParameters { - ssrc: encoding.ssrc, - rid: encoding.rid, - codec_payload_type: encoding.codec_payload_type, - rtx: encoding - .rtx - .map(|rtx| Box::new(rtp_parameters::Rtx { ssrc: rtx.ssrc })), - dtx: encoding.dtx.unwrap_or_default(), - scalability_mode: if encoding.scalability_mode.is_none() { - None - } else { - Some(encoding.scalability_mode.as_str().to_string()) - }, - max_bitrate: encoding.max_bitrate, - }) - .collect(), - ), - rtcp: Some(Box::new(rtp_parameters::RtcpParameters { + header_extensions: self + .header_extensions + .into_iter() + .map( + |header_extension_parameters| rtp_parameters::RtpHeaderExtensionParameters { + uri: header_extension_parameters.uri.as_str().to_string(), + id: header_extension_parameters.id as u8, + encrypt: header_extension_parameters.encrypt, + parameters: None, + }, + ) + .collect(), + encodings: self + .encodings + .into_iter() + .map(|encoding| rtp_parameters::RtpEncodingParameters { + ssrc: encoding.ssrc, + rid: encoding.rid, + codec_payload_type: encoding.codec_payload_type, + rtx: encoding + .rtx + .map(|rtx| Box::new(rtp_parameters::Rtx { ssrc: rtx.ssrc })), + dtx: encoding.dtx.unwrap_or_default(), + scalability_mode: if encoding.scalability_mode.is_none() { + None + } else { + Some(encoding.scalability_mode.as_str().to_string()) + }, + max_bitrate: encoding.max_bitrate, + }) + .collect(), + rtcp: Box::new(rtp_parameters::RtcpParameters { cname: self.rtcp.cname, reduced_size: self.rtcp.reduced_size, - })), + }), } } } @@ -1198,9 +1187,6 @@ pub struct RtpEncodingParameters { /// Number of spatial and temporal layers in the RTP stream. #[serde(default, skip_serializing_if = "ScalabilityMode::is_none")] pub scalability_mode: ScalabilityMode, - /// Factor by which to reduce the size of a video track during encoding. - #[serde(skip_serializing_if = "Option::is_none")] - pub scale_resolution_down_by: Option, /// Maximum number of bits per second to allow a track encoded with this encoding to use. #[serde(skip_serializing_if = "Option::is_none")] pub max_bitrate: Option, @@ -1240,9 +1226,6 @@ pub struct RtcpParameters { /// Whether reduced size RTCP RFC 5506 is configured (if true) or compound RTCP /// as specified in RFC 3550 (if false). Default true. pub reduced_size: bool, - /// Whether RTCP-mux is used. Default true. - #[serde(skip_serializing_if = "Option::is_none")] - pub mux: Option, } impl Default for RtcpParameters { @@ -1250,7 +1233,6 @@ impl Default for RtcpParameters { Self { cname: None, reduced_size: true, - mux: None, } } } diff --git a/rust/tests/integration/consumer.rs b/rust/tests/integration/consumer.rs index b0be538762..4151e2c42b 100644 --- a/rust/tests/integration/consumer.rs +++ b/rust/tests/integration/consumer.rs @@ -976,7 +976,6 @@ fn dump_succeeds() { rtx: None, dtx: None, scalability_mode: ScalabilityMode::None, - scale_resolution_down_by: None, ssrc: audio_consumer .rtp_parameters() .encodings @@ -1104,7 +1103,6 @@ fn dump_succeeds() { .rtx, dtx: None, scalability_mode: "L4T1".parse().unwrap(), - scale_resolution_down_by: None, rid: None, max_bitrate: None, }], diff --git a/rust/tests/integration/producer.rs b/rust/tests/integration/producer.rs index 9ccf443b31..0f580aab5b 100644 --- a/rust/tests/integration/producer.rs +++ b/rust/tests/integration/producer.rs @@ -714,7 +714,6 @@ fn dump_succeeds() { rtx: None, dtx: None, scalability_mode: ScalabilityMode::None, - scale_resolution_down_by: None, max_bitrate: None }], ); @@ -752,7 +751,6 @@ fn dump_succeeds() { rtx: Some(RtpEncodingParametersRtx { ssrc: 22222223 }), dtx: None, scalability_mode: "L1T3".parse().unwrap(), - scale_resolution_down_by: None, max_bitrate: None }, RtpEncodingParameters { @@ -762,7 +760,6 @@ fn dump_succeeds() { rtx: Some(RtpEncodingParametersRtx { ssrc: 22222225 }), dtx: None, scalability_mode: ScalabilityMode::None, - scale_resolution_down_by: None, max_bitrate: None }, RtpEncodingParameters { @@ -772,7 +769,6 @@ fn dump_succeeds() { rtx: Some(RtpEncodingParametersRtx { ssrc: 22222227 }), dtx: None, scalability_mode: ScalabilityMode::None, - scale_resolution_down_by: None, max_bitrate: None }, RtpEncodingParameters { @@ -782,7 +778,6 @@ fn dump_succeeds() { rtx: Some(RtpEncodingParametersRtx { ssrc: 22222229 }), dtx: None, scalability_mode: ScalabilityMode::None, - scale_resolution_down_by: None, max_bitrate: None }, ], diff --git a/worker/fbs/rtpParameters.fbs b/worker/fbs/rtpParameters.fbs index d9c624e7c5..35a5ff84e0 100644 --- a/worker/fbs/rtpParameters.fbs +++ b/worker/fbs/rtpParameters.fbs @@ -22,7 +22,7 @@ table Double { } table String { - value:string; + value:string (required); } union Value { @@ -35,12 +35,12 @@ union Value { table Parameter { name: string (required); - value: Value; + value: Value (required); } table RtcpFeedback { type:string (required); - parameter:string; + parameter:string (required); } table RtpCodecParameters { @@ -81,9 +81,9 @@ table RtcpParameters { table RtpParameters { mid:string; codecs:[RtpCodecParameters] (required); - header_extensions:[RtpHeaderExtensionParameters]; - encodings:[RtpEncodingParameters]; - rtcp:RtcpParameters; + header_extensions:[RtpHeaderExtensionParameters] (required); + encodings:[RtpEncodingParameters] (required); + rtcp:RtcpParameters (required); } table CodecMapping { diff --git a/worker/include/RTC/RtpDictionaries.hpp b/worker/include/RTC/RtpDictionaries.hpp index 735db78a08..39a55827ea 100644 --- a/worker/include/RTC/RtpDictionaries.hpp +++ b/worker/include/RTC/RtpDictionaries.hpp @@ -295,7 +295,6 @@ namespace RTC std::vector encodings; std::vector headerExtensions; RtcpParameters rtcp; - bool hasRtcp{ false }; }; } // namespace RTC diff --git a/worker/src/RTC/RtpDictionaries/RtcpFeedback.cpp b/worker/src/RTC/RtpDictionaries/RtcpFeedback.cpp index 40a27c5614..edf2cf870d 100644 --- a/worker/src/RTC/RtpDictionaries/RtcpFeedback.cpp +++ b/worker/src/RTC/RtpDictionaries/RtcpFeedback.cpp @@ -13,11 +13,8 @@ namespace RTC { MS_TRACE(); - this->type = data->type()->str(); - - // parameter is optional. - if (flatbuffers::IsFieldPresent(data, FBS::RtpParameters::RtcpFeedback::VT_PARAMETER)) - this->parameter = data->parameter()->str(); + this->type = data->type()->str(); + this->parameter = data->parameter()->str(); } flatbuffers::Offset RtcpFeedback::FillBuffer( diff --git a/worker/src/RTC/RtpDictionaries/RtpParameters.cpp b/worker/src/RTC/RtpDictionaries/RtpParameters.cpp index a11567e89d..d1961b91fb 100644 --- a/worker/src/RTC/RtpDictionaries/RtpParameters.cpp +++ b/worker/src/RTC/RtpDictionaries/RtpParameters.cpp @@ -128,10 +128,6 @@ namespace RTC if (this->codecs.empty()) MS_THROW_TYPE_ERROR("empty codecs"); - // encodings is mandatory. - if (!flatbuffers::IsFieldPresent(data, FBS::RtpParameters::RtpParameters::VT_ENCODINGS)) - MS_THROW_TYPE_ERROR("missing encodings"); - this->encodings.reserve(data->encodings()->size()); for (const auto* entry : *data->encodings()) @@ -143,26 +139,17 @@ namespace RTC if (this->encodings.empty()) MS_THROW_TYPE_ERROR("empty encodings"); - // headerExtensions is optional. - if (flatbuffers::IsFieldPresent(data, FBS::RtpParameters::RtpParameters::VT_HEADEREXTENSIONS)) - { - this->headerExtensions.reserve(data->headerExtensions()->size()); + this->headerExtensions.reserve(data->headerExtensions()->size()); - for (const auto* entry : *data->headerExtensions()) - { - // This may throw due the constructor of RTC::RtpHeaderExtensionParameters. - this->headerExtensions.emplace_back(entry); - } - } - - // rtcp is optional. - if (flatbuffers::IsFieldPresent(data, FBS::RtpParameters::RtpParameters::VT_RTCP)) + for (const auto* entry : *data->headerExtensions()) { - // This may throw. - this->rtcp = RTC::RtcpParameters(data->rtcp()); - this->hasRtcp = true; + // This may throw due the constructor of RTC::RtpHeaderExtensionParameters. + this->headerExtensions.emplace_back(entry); } + // This may throw. + this->rtcp = RTC::RtcpParameters(data->rtcp()); + // Validate RTP parameters. ValidateCodecs(); ValidateEncodings(); @@ -203,8 +190,7 @@ namespace RTC // Add rtcp. flatbuffers::Offset rtcp; - if (this->hasRtcp) - rtcp = this->rtcp.FillBuffer(builder); + rtcp = this->rtcp.FillBuffer(builder); return FBS::RtpParameters::CreateRtpParametersDirect( builder, mid.c_str(), &codecs, &headerExtensions, &encodings, rtcp); From 2dc44f919a12ae3cd84ed8882484f561608c256a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Wed, 30 Aug 2023 18:11:53 +0200 Subject: [PATCH 16/73] rust: move PlainTransport to flatbuffers (#1135) --- node/src/PlainTransport.ts | 2 +- rust/src/data_structures.rs | 33 +++ rust/src/fbs.rs | 328 ++++++++++++---------- rust/src/messages.rs | 247 +++++++++++++--- rust/src/router.rs | 2 +- rust/src/router/direct_transport.rs | 8 +- rust/src/router/plain_transport.rs | 187 +++++++++--- rust/src/router/transport.rs | 8 +- rust/src/sctp_parameters.rs | 9 + rust/src/srtp_parameters.rs | 49 ++++ rust/src/worker/channel.rs | 1 + rust/tests/integration/plain_transport.rs | 16 +- worker/fbs/plainTransport.fbs | 4 +- worker/fbs/request.fbs | 2 +- worker/fbs/sctpParameters.fbs | 4 +- worker/fbs/transport.fbs | 2 +- worker/src/RTC/PlainTransport.cpp | 4 +- 17 files changed, 653 insertions(+), 253 deletions(-) diff --git a/node/src/PlainTransport.ts b/node/src/PlainTransport.ts index e0e44004bb..2852b30485 100644 --- a/node/src/PlainTransport.ts +++ b/node/src/PlainTransport.ts @@ -356,7 +356,7 @@ export class PlainTransport // Wait for response. const response = await this.channel.request( FbsRequest.Method.PLAINTRANSPORT_CONNECT, - FbsRequest.Body.FBS_PlainTransport_ConnectRequest, + FbsRequest.Body.PlainTransport_ConnectRequest, requestOffset, this.internal.transportId ); diff --git a/rust/src/data_structures.rs b/rust/src/data_structures.rs index a831c9e25a..3f3dc28ce5 100644 --- a/rust/src/data_structures.rs +++ b/rust/src/data_structures.rs @@ -146,6 +146,17 @@ pub enum Protocol { Udp, } +impl Protocol { + // TODO: Use the Protocol FBS type. + pub(crate) fn from_fbs(protocol: &str) -> Self { + match protocol { + "tcp" => Protocol::Tcp, + "udp" => Protocol::Udp, + _ => todo!(), + } + } +} + /// ICE candidate #[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -260,6 +271,28 @@ impl TransportTuple { None } } + + pub(crate) fn from_fbs(tuple: &transport::Tuple) -> TransportTuple { + match &tuple.remote_ip { + Some(_remote_ip) => TransportTuple::WithRemote { + local_ip: tuple.local_ip.parse().expect("Error parsing IP address"), + local_port: tuple.local_port, + remote_ip: tuple + .remote_ip + .as_ref() + .unwrap() + .parse() + .expect("Error parsing IP address"), + remote_port: tuple.remote_port, + protocol: Protocol::from_fbs(tuple.protocol.as_str()), + }, + None => TransportTuple::LocalOnly { + local_ip: tuple.local_ip.parse().expect("Error parsing IP address"), + local_port: tuple.local_port, + protocol: Protocol::from_fbs(tuple.protocol.as_str()), + }, + } + } } /// DTLS state. diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index fa6c05ed71..59a62b22ca 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -27219,9 +27219,9 @@ mod root { )] pub struct NumSctpStreams { /// The field `os` in the table `NumSctpStreams` - pub os: u32, + pub os: u16, /// The field `mis` in the table `NumSctpStreams` - pub mis: u32, + pub mis: u16, } #[allow(clippy::derivable_impls)] @@ -27244,8 +27244,8 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_os: impl ::planus::WriteAsDefault, - field_mis: impl ::planus::WriteAsDefault, + 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); @@ -27253,19 +27253,19 @@ mod root { let mut table_writer: ::planus::table_writer::TableWriter<8> = ::core::default::Default::default(); if prepared_os.is_some() { - table_writer.write_entry::(0); + table_writer.write_entry::(0); } if prepared_mis.is_some() { - table_writer.write_entry::(1); + 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::<_, _, 4>(&prepared_os); + object_writer.write::<_, _, 2>(&prepared_os); } if let ::core::option::Option::Some(prepared_mis) = prepared_mis { - object_writer.write::<_, _, 4>(&prepared_mis); + object_writer.write::<_, _, 2>(&prepared_mis); } }); } @@ -27320,7 +27320,7 @@ mod root { #[allow(clippy::type_complexity)] pub fn os(self, value: T0) -> NumSctpStreamsBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, { NumSctpStreamsBuilder((value,)) } @@ -27339,7 +27339,7 @@ mod root { #[allow(clippy::type_complexity)] pub fn mis(self, value: T1) -> NumSctpStreamsBuilder<(T0, T1)> where - T1: ::planus::WriteAsDefault, + T1: ::planus::WriteAsDefault, { let (v0,) = self.0; NumSctpStreamsBuilder((v0, value)) @@ -27368,8 +27368,8 @@ mod root { } impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsDefault, > ::planus::WriteAs<::planus::Offset> for NumSctpStreamsBuilder<(T0, T1)> { @@ -27385,8 +27385,8 @@ mod root { } impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsDefault, > ::planus::WriteAsOptional<::planus::Offset> for NumSctpStreamsBuilder<(T0, T1)> { @@ -27402,8 +27402,8 @@ mod root { } impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsDefault, > ::planus::WriteAsOffset for NumSctpStreamsBuilder<(T0, T1)> { #[inline] @@ -27423,7 +27423,7 @@ mod root { impl<'a> NumSctpStreamsRef<'a> { /// Getter for the [`os` field](NumSctpStreams#structfield.os). #[inline] - pub fn os(&self) -> ::planus::Result { + pub fn os(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0.access(0, "NumSctpStreams", "os")?.unwrap_or(1024), ) @@ -27431,7 +27431,7 @@ mod root { /// Getter for the [`mis` field](NumSctpStreams#structfield.mis). #[inline] - pub fn mis(&self) -> ::planus::Result { + pub fn mis(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0.access(1, "NumSctpStreams", "mis")?.unwrap_or(1024), ) @@ -35823,7 +35823,7 @@ mod root { /// The field `local_port` in the table `Tuple` pub local_port: u16, /// The field `remote_ip` in the table `Tuple` - pub remote_ip: ::planus::alloc::string::String, + 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` @@ -35842,7 +35842,9 @@ mod root { builder: &mut ::planus::Builder, field_local_ip: impl ::planus::WriteAs<::planus::Offset>, field_local_port: impl ::planus::WriteAsDefault, - field_remote_ip: impl ::planus::WriteAs<::planus::Offset>, + field_remote_ip: impl ::planus::WriteAsOptional< + ::planus::Offset<::core::primitive::str>, + >, field_remote_port: impl ::planus::WriteAsDefault, field_protocol: impl ::planus::WriteAs<::planus::Offset>, ) -> ::planus::Offset { @@ -35855,7 +35857,9 @@ mod root { 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>(2); + if prepared_remote_ip.is_some() { + table_writer.write_entry::<::planus::Offset>(2); + } table_writer.write_entry::<::planus::Offset>(4); if prepared_local_port.is_some() { table_writer.write_entry::(1); @@ -35867,7 +35871,11 @@ mod root { unsafe { table_writer.finish(builder, |object_writer| { object_writer.write::<_, _, 4>(&prepared_local_ip); - object_writer.write::<_, _, 4>(&prepared_remote_ip); + if let ::core::option::Option::Some(prepared_remote_ip) = + prepared_remote_ip + { + object_writer.write::<_, _, 4>(&prepared_remote_ip); + } object_writer.write::<_, _, 4>(&prepared_protocol); if let ::core::option::Option::Some(prepared_local_port) = prepared_local_port @@ -35965,11 +35973,18 @@ mod root { #[allow(clippy::type_complexity)] pub fn remote_ip(self, value: T2) -> TupleBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAs<::planus::Offset>, + 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)> { @@ -36021,7 +36036,7 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, + T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, T3: ::planus::WriteAsDefault, T4: ::planus::WriteAs<::planus::Offset>, > ::planus::WriteAs<::planus::Offset> @@ -36038,7 +36053,7 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, + T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, T3: ::planus::WriteAsDefault, T4: ::planus::WriteAs<::planus::Offset>, > ::planus::WriteAsOptional<::planus::Offset> @@ -36058,7 +36073,7 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, + T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, T3: ::planus::WriteAsDefault, T4: ::planus::WriteAs<::planus::Offset>, > ::planus::WriteAsOffset for TupleBuilder<(T0, T1, T2, T3, T4)> @@ -36091,8 +36106,11 @@ mod root { /// Getter for the [`remote_ip` field](Tuple#structfield.remote_ip). #[inline] - pub fn remote_ip(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(2, "Tuple", "remote_ip") + 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). @@ -36115,7 +36133,11 @@ mod root { let mut f = f.debug_struct("TupleRef"); f.field("local_ip", &self.local_ip()); f.field("local_port", &self.local_port()); - f.field("remote_ip", &self.remote_ip()); + 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() @@ -36130,7 +36152,15 @@ mod root { ::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: ::core::convert::TryInto::try_into(value.remote_ip()?)?, + 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()?)?, }) @@ -50411,6 +50441,11 @@ mod root { ::planus::alloc::boxed::Box, ), + /// The variant `PlainTransport_ConnectRequest` in the union `Body` + PlainTransportConnectRequest( + ::planus::alloc::boxed::Box, + ), + /// The variant of type `FBS.WebRtcTransport.ConnectRequest` in the union `Body` ConnectRequest( ::planus::alloc::boxed::Box, @@ -50656,12 +50691,20 @@ mod root { ::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_connect_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(26, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(27, value.prepare(builder).downcast()) } #[inline] @@ -50669,7 +50712,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(27, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(28, value.prepare(builder).downcast()) } #[inline] @@ -50677,7 +50720,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(28, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(29, value.prepare(builder).downcast()) } #[inline] @@ -50687,7 +50730,7 @@ mod root { super::data_consumer::SetBufferedAmountLowThresholdRequest, >, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(29, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(30, value.prepare(builder).downcast()) } #[inline] @@ -50695,7 +50738,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(30, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(31, value.prepare(builder).downcast()) } #[inline] @@ -50703,7 +50746,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(31, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(32, value.prepare(builder).downcast()) } #[inline] @@ -50711,7 +50754,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(32, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(33, value.prepare(builder).downcast()) } } @@ -50790,6 +50833,9 @@ mod root { Self::CloseDataConsumerRequest(value) => { Self::create_close_data_consumer_request(builder, value) } + Self::PlainTransportConnectRequest(value) => { + Self::create_plain_transport_connect_request(builder, value) + } Self::ConnectRequest(value) => Self::create_connect_request(builder, value), Self::SetPreferredLayersRequest(value) => { Self::create_set_preferred_layers_request(builder, value) @@ -51129,12 +51175,24 @@ mod root { 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 [`ConnectRequest` variant](Body#variant.ConnectRequest). #[inline] pub fn connect_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<26, T>> + ) -> BodyBuilder<::planus::Initialized<27, T>> where T: ::planus::WriteAsOffset, { @@ -51146,7 +51204,7 @@ mod root { pub fn set_preferred_layers_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<27, T>> + ) -> BodyBuilder<::planus::Initialized<28, T>> where T: ::planus::WriteAsOffset, { @@ -51158,7 +51216,7 @@ mod root { pub fn set_priority_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<28, T>> + ) -> BodyBuilder<::planus::Initialized<29, T>> where T: ::planus::WriteAsOffset, { @@ -51170,7 +51228,7 @@ mod root { pub fn set_buffered_amount_low_threshold_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<29, T>> + ) -> BodyBuilder<::planus::Initialized<30, T>> where T: ::planus::WriteAsOffset< super::data_consumer::SetBufferedAmountLowThresholdRequest, @@ -51181,7 +51239,7 @@ mod root { /// Creates an instance of the [`SendRequest` variant](Body#variant.SendRequest). #[inline] - pub fn send_request(self, value: T) -> BodyBuilder<::planus::Initialized<30, T>> + pub fn send_request(self, value: T) -> BodyBuilder<::planus::Initialized<31, T>> where T: ::planus::WriteAsOffset, { @@ -51193,7 +51251,7 @@ mod root { pub fn add_producer_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<31, T>> + ) -> BodyBuilder<::planus::Initialized<32, T>> where T: ::planus::WriteAsOffset, { @@ -51205,7 +51263,7 @@ mod root { pub fn remove_producer_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<32, T>> + ) -> BodyBuilder<::planus::Initialized<33, T>> where T: ::planus::WriteAsOffset, { @@ -51776,7 +51834,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<26, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -51786,7 +51844,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<26, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -51798,7 +51856,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<27, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -51808,7 +51866,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<27, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -51820,7 +51878,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<28, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -51830,7 +51888,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<28, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -51842,9 +51900,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<29, T>> where - T: ::planus::WriteAsOffset< - super::data_consumer::SetBufferedAmountLowThresholdRequest, - >, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -51854,9 +51910,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<29, T>> where - T: ::planus::WriteAsOffset< - super::data_consumer::SetBufferedAmountLowThresholdRequest, - >, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -51868,7 +51922,9 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<30, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset< + super::data_consumer::SetBufferedAmountLowThresholdRequest, + >, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -51878,7 +51934,9 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<30, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset< + super::data_consumer::SetBufferedAmountLowThresholdRequest, + >, { #[inline] fn prepare( @@ -51890,7 +51948,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<31, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -51900,7 +51958,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<31, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -51912,7 +51970,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<32, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -51921,6 +51979,28 @@ mod root { } 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, + { + #[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, { @@ -51965,6 +52045,7 @@ mod root { CloseConsumerRequest(super::transport::CloseConsumerRequestRef<'a>), CloseDataProducerRequest(super::transport::CloseDataProducerRequestRef<'a>), CloseDataConsumerRequest(super::transport::CloseDataConsumerRequestRef<'a>), + PlainTransportConnectRequest(super::plain_transport::ConnectRequestRef<'a>), ConnectRequest(super::web_rtc_transport::ConnectRequestRef<'a>), SetPreferredLayersRequest(super::consumer::SetPreferredLayersRequestRef<'a>), SetPriorityRequest(super::consumer::SetPriorityRequestRef<'a>), @@ -52133,6 +52214,12 @@ mod root { )) } + BodyRef::PlainTransportConnectRequest(value) => { + Self::PlainTransportConnectRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + BodyRef::ConnectRequest(value) => { Self::ConnectRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, @@ -52262,27 +52349,30 @@ mod root { 25 => ::core::result::Result::Ok(Self::CloseDataConsumerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 26 => ::core::result::Result::Ok(Self::ConnectRequest( + 26 => ::core::result::Result::Ok(Self::PlainTransportConnectRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 27 => ::core::result::Result::Ok(Self::ConnectRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 27 => ::core::result::Result::Ok(Self::SetPreferredLayersRequest( + 28 => ::core::result::Result::Ok(Self::SetPreferredLayersRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 28 => ::core::result::Result::Ok(Self::SetPriorityRequest( + 29 => ::core::result::Result::Ok(Self::SetPriorityRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 29 => { + 30 => { ::core::result::Result::Ok(Self::SetBufferedAmountLowThresholdRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )) } - 30 => ::core::result::Result::Ok(Self::SendRequest( + 31 => ::core::result::Result::Ok(Self::SendRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 31 => ::core::result::Result::Ok(Self::AddProducerRequest( + 32 => ::core::result::Result::Ok(Self::AddProducerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 32 => ::core::result::Result::Ok(Self::RemoveProducerRequest( + 33 => ::core::result::Result::Ok(Self::RemoveProducerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), _ => ::core::result::Result::Err( @@ -69829,8 +69919,7 @@ mod root { )] pub struct PlainTransportOptions { /// The field `base` in the table `PlainTransportOptions` - pub base: - ::core::option::Option<::planus::alloc::boxed::Box>, + 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` @@ -69857,9 +69946,7 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, + field_base: impl ::planus::WriteAs<::planus::Offset>, field_listen_info: impl ::planus::WriteAs< ::planus::Offset, >, @@ -69883,9 +69970,7 @@ mod root { let mut table_writer: ::planus::table_writer::TableWriter<18> = ::core::default::Default::default(); - if prepared_base.is_some() { - table_writer.write_entry::<::planus::Offset>(0); - } + table_writer.write_entry::<::planus::Offset>(0); table_writer.write_entry::<::planus::Offset>(1); if prepared_rtcp_listen_info.is_some() { table_writer @@ -69906,9 +69991,7 @@ mod root { unsafe { table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_base) = prepared_base { - object_writer.write::<_, _, 4>(&prepared_base); - } + 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 @@ -69997,17 +70080,10 @@ mod root { #[allow(clippy::type_complexity)] pub fn base(self, value: T0) -> PlainTransportOptionsBuilder<(T0,)> where - T0: ::planus::WriteAsOptional<::planus::Offset>, + T0: ::planus::WriteAs<::planus::Offset>, { PlainTransportOptionsBuilder((value,)) } - - /// Sets the [`base` field](PlainTransportOptions#structfield.base) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn base_as_null(self) -> PlainTransportOptionsBuilder<((),)> { - self.base(()) - } } impl PlainTransportOptionsBuilder<(T0,)> { @@ -70166,7 +70242,7 @@ mod root { } impl< - T0: ::planus::WriteAsOptional<::planus::Offset>, + T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs<::planus::Offset>, T2: ::planus::WriteAsOptional<::planus::Offset>, T3: ::planus::WriteAsDefault, @@ -70188,7 +70264,7 @@ mod root { } impl< - T0: ::planus::WriteAsOptional<::planus::Offset>, + T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs<::planus::Offset>, T2: ::planus::WriteAsOptional<::planus::Offset>, T3: ::planus::WriteAsDefault, @@ -70211,7 +70287,7 @@ mod root { } impl< - T0: ::planus::WriteAsOptional<::planus::Offset>, + T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs<::planus::Offset>, T2: ::planus::WriteAsOptional<::planus::Offset>, T3: ::planus::WriteAsDefault, @@ -70238,11 +70314,8 @@ mod root { impl<'a> PlainTransportOptionsRef<'a> { /// Getter for the [`base` field](PlainTransportOptions#structfield.base). #[inline] - pub fn base( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(0, "PlainTransportOptions", "base") + pub fn base(&self) -> ::planus::Result> { + self.0.access_required(0, "PlainTransportOptions", "base") } /// Getter for the [`listen_info` field](PlainTransportOptions#structfield.listen_info). @@ -70306,9 +70379,7 @@ mod root { 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"); - if let ::core::option::Option::Some(field_base) = self.base().transpose() { - f.field("base", &field_base); - } + 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() @@ -70333,13 +70404,9 @@ mod root { #[allow(unreachable_code)] fn try_from(value: PlainTransportOptionsRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - base: if let ::core::option::Option::Some(base) = value.base()? { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(base)?, - )) - } else { - ::core::option::Option::None - }, + 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()?)?, ), @@ -71330,8 +71397,7 @@ mod root { /// The field `comedia` in the table `DumpResponse` pub comedia: bool, /// The field `tuple` in the table `DumpResponse` - pub tuple: - ::core::option::Option<::planus::alloc::boxed::Box>, + pub tuple: ::planus::alloc::boxed::Box, /// The field `rtcp_tuple` in the table `DumpResponse` pub rtcp_tuple: ::core::option::Option<::planus::alloc::boxed::Box>, @@ -71354,9 +71420,7 @@ mod root { field_base: impl ::planus::WriteAs<::planus::Offset>, field_rtcp_mux: impl ::planus::WriteAsDefault, field_comedia: impl ::planus::WriteAsDefault, - field_tuple: impl ::planus::WriteAsOptional< - ::planus::Offset, - >, + field_tuple: impl ::planus::WriteAs<::planus::Offset>, field_rtcp_tuple: impl ::planus::WriteAsOptional< ::planus::Offset, >, @@ -71374,9 +71438,7 @@ mod root { let mut table_writer: ::planus::table_writer::TableWriter<16> = ::core::default::Default::default(); table_writer.write_entry::<::planus::Offset>(0); - if prepared_tuple.is_some() { - table_writer.write_entry::<::planus::Offset>(3); - } + table_writer.write_entry::<::planus::Offset>(3); if prepared_rtcp_tuple.is_some() { table_writer.write_entry::<::planus::Offset>(4); } @@ -71394,9 +71456,7 @@ mod root { unsafe { table_writer.finish(builder, |object_writer| { object_writer.write::<_, _, 4>(&prepared_base); - if let ::core::option::Option::Some(prepared_tuple) = prepared_tuple { - object_writer.write::<_, _, 4>(&prepared_tuple); - } + object_writer.write::<_, _, 4>(&prepared_tuple); if let ::core::option::Option::Some(prepared_rtcp_tuple) = prepared_rtcp_tuple { @@ -71533,18 +71593,11 @@ mod root { #[allow(clippy::type_complexity)] pub fn tuple(self, value: T3) -> DumpResponseBuilder<(T0, T1, T2, T3)> where - T3: ::planus::WriteAsOptional<::planus::Offset>, + T3: ::planus::WriteAs<::planus::Offset>, { let (v0, v1, v2) = self.0; DumpResponseBuilder((v0, v1, v2, value)) } - - /// Sets the [`tuple` field](DumpResponse#structfield.tuple) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn tuple_as_null(self) -> DumpResponseBuilder<(T0, T1, T2, ())> { - self.tuple(()) - } } impl DumpResponseBuilder<(T0, T1, T2, T3)> { @@ -71612,7 +71665,7 @@ mod root { T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional<::planus::Offset>, + T3: ::planus::WriteAs<::planus::Offset>, T4: ::planus::WriteAsOptional<::planus::Offset>, T5: ::planus::WriteAsOptional<::planus::Offset>, > ::planus::WriteAs<::planus::Offset> @@ -71633,7 +71686,7 @@ mod root { T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional<::planus::Offset>, + T3: ::planus::WriteAs<::planus::Offset>, T4: ::planus::WriteAsOptional<::planus::Offset>, T5: ::planus::WriteAsOptional<::planus::Offset>, > ::planus::WriteAsOptional<::planus::Offset> @@ -71654,7 +71707,7 @@ mod root { T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional<::planus::Offset>, + T3: ::planus::WriteAs<::planus::Offset>, T4: ::planus::WriteAsOptional<::planus::Offset>, T5: ::planus::WriteAsOptional<::planus::Offset>, > ::planus::WriteAsOffset @@ -71703,11 +71756,8 @@ mod root { /// Getter for the [`tuple` field](DumpResponse#structfield.tuple). #[inline] - pub fn tuple( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(3, "DumpResponse", "tuple") + pub fn tuple(&self) -> ::planus::Result> { + self.0.access_required(3, "DumpResponse", "tuple") } /// Getter for the [`rtcp_tuple` field](DumpResponse#structfield.rtcp_tuple). @@ -71735,9 +71785,7 @@ mod root { f.field("base", &self.base()); f.field("rtcp_mux", &self.rtcp_mux()); f.field("comedia", &self.comedia()); - if let ::core::option::Option::Some(field_tuple) = self.tuple().transpose() { - f.field("tuple", &field_tuple); - } + f.field("tuple", &self.tuple()); if let ::core::option::Option::Some(field_rtcp_tuple) = self.rtcp_tuple().transpose() { @@ -71763,13 +71811,9 @@ mod root { )?), rtcp_mux: ::core::convert::TryInto::try_into(value.rtcp_mux()?)?, comedia: ::core::convert::TryInto::try_into(value.comedia()?)?, - tuple: if let ::core::option::Option::Some(tuple) = value.tuple()? { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(tuple)?, - )) - } else { - ::core::option::Option::None - }, + 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()? { diff --git a/rust/src/messages.rs b/rust/src/messages.rs index 7493749162..c28e231a91 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -11,7 +11,9 @@ use crate::data_structures::{ ListenInfo, SctpState, TransportTuple, }; use crate::direct_transport::DirectTransportOptions; -use crate::fbs::{direct_transport, message, request, response, router, transport, worker}; +use crate::fbs::{ + direct_transport, message, plain_transport, request, response, router, transport, worker, +}; use crate::ortc::RtpMapping; use crate::pipe_transport::PipeTransportOptions; use crate::plain_transport::PlainTransportOptions; @@ -735,7 +737,7 @@ impl RequestFbs for RouterDumpRequest { pub(crate) struct RouterCreateDirectTransportData { transport_id: TransportId, direct: bool, - max_message_size: usize, + max_message_size: u32, } impl RouterCreateDirectTransportData { @@ -754,7 +756,7 @@ impl RouterCreateDirectTransportData { direct_transport::DirectTransportOptions { base: Box::new(transport::Options { direct: true, - max_message_size: u32::try_from(self.max_message_size).unwrap(), + max_message_size: self.max_message_size, initial_available_outgoing_bitrate: 0, enable_sctp: false, num_sctp_streams: None, @@ -896,6 +898,7 @@ impl Request for RouterCreateWebrtcTransportRequest { pub(crate) struct RouterCreatePlainTransportData { transport_id: TransportId, listen_info: ListenInfo, + rtcp_listen_info: Option, rtcp_mux: bool, comedia: bool, enable_sctp: bool, @@ -915,6 +918,7 @@ impl RouterCreatePlainTransportData { Self { transport_id, listen_info: plain_transport_options.listen_info, + rtcp_listen_info: plain_transport_options.rtcp_listen_info, rtcp_mux: plain_transport_options.rtcp_mux, comedia: plain_transport_options.comedia, enable_sctp: plain_transport_options.enable_sctp, @@ -926,26 +930,102 @@ impl RouterCreatePlainTransportData { is_data_channel: false, } } + + pub(crate) fn to_fbs(&self) -> plain_transport::PlainTransportOptions { + plain_transport::PlainTransportOptions { + base: Box::new(transport::Options { + direct: false, + initial_available_outgoing_bitrate: 0, + enable_sctp: self.enable_sctp, + num_sctp_streams: Some(Box::new(self.num_sctp_streams.to_fbs())), + max_sctp_message_size: self.max_sctp_message_size, + sctp_send_buffer_size: self.sctp_send_buffer_size, + is_data_channel: self.is_data_channel, + max_message_size: self.max_sctp_message_size, + }), + listen_info: Box::new(self.listen_info.to_fbs()), + rtcp_listen_info: self + .rtcp_listen_info + .map(|listen_info| Box::new(listen_info.to_fbs())), + rtcp_mux: self.rtcp_mux, + comedia: self.comedia, + enable_srtp: self.enable_srtp, + srtp_crypto_suite: Some(self.srtp_crypto_suite.to_string()), + } + } } -request_response!( - RouterId, - "router.createPlainTransport", - RouterCreatePlainTransportRequest { - #[serde(flatten)] - data: RouterCreatePlainTransportData, - }, - PlainTransportData { - // The following fields are present, but unused - // rtcp_mux: bool, - // comedia: bool, - tuple: Mutex, - rtcp_tuple: Mutex>, - sctp_parameters: Option, - sctp_state: Mutex>, - srtp_parameters: Mutex>, - }, -); +#[derive(Debug)] +pub(crate) struct RouterCreatePlainTransportRequest { + pub(crate) data: RouterCreatePlainTransportData, +} + +impl RequestFbs for RouterCreatePlainTransportRequest { + const METHOD: request::Method = request::Method::RouterCreatePlaintransport; + type HandlerId = RouterId; + type Response = PlainTransportData; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = router::CreatePlainTransportRequest::create( + &mut builder, + self.data.transport_id.to_string(), + self.data.to_fbs(), + ); + let request_body = request::Body::create_create_plain_transport_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::FbsPlainTransportDumpResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(PlainTransportData { + tuple: Mutex::new(TransportTuple::from_fbs(data.tuple.as_ref())), + rtcp_tuple: Mutex::new( + data.rtcp_tuple + .map(|tuple| TransportTuple::from_fbs(tuple.as_ref())), + ), + sctp_parameters: data + .base + .sctp_parameters + .map(|parameters| SctpParameters::from_fbs(parameters.as_ref())), + sctp_state: Mutex::new( + data.base + .sctp_state + .map(|state| SctpState::from_fbs(&state)), + ), + srtp_parameters: Mutex::new( + data.srtp_parameters + .map(|parameters| SrtpParameters::from_fbs(parameters.as_ref())), + ), + }) + } +} + +pub(crate) struct PlainTransportData { + // The following fields are present, but unused + // rtcp_mux: bool, + // comedia: bool, + pub(crate) tuple: Mutex, + pub(crate) rtcp_tuple: Mutex>, + pub(crate) sctp_parameters: Option, + pub(crate) sctp_state: Mutex>, + pub(crate) srtp_parameters: Mutex>, +} #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] @@ -1074,9 +1154,9 @@ request_response!( ); #[derive(Debug)] -pub(crate) struct TransportDumpRequestNew {} +pub(crate) struct TransportDumpRequestFbs {} -impl RequestFbs for TransportDumpRequestNew { +impl RequestFbs for TransportDumpRequestFbs { const METHOD: request::Method = request::Method::TransportDump; type HandlerId = TransportId; type Response = response::Body; @@ -1116,9 +1196,9 @@ request_response!( ); #[derive(Debug)] -pub(crate) struct TransportGetStatsRequestNew {} +pub(crate) struct TransportGetStatsRequestFbs {} -impl RequestFbs for TransportGetStatsRequestNew { +impl RequestFbs for TransportGetStatsRequestFbs { const METHOD: request::Method = request::Method::TransportGetStats; type HandlerId = TransportId; type Response = response::Body; @@ -1151,6 +1231,42 @@ impl RequestFbs for TransportGetStatsRequestNew { } } +#[derive(Debug)] +pub(crate) struct TransportCloseRequestFbs { + pub(crate) transport_id: TransportId, +} + +impl RequestFbs for TransportCloseRequestFbs { + const METHOD: request::Method = request::Method::RouterCloseTransport; + type HandlerId = RouterId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = + router::CloseTransportRequest::create(&mut builder, self.transport_id.to_string()); + let request_body = request::Body::create_close_transport_request(&mut builder, data); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + request_response!( TransportId, "transport.connect", @@ -1176,25 +1292,68 @@ request_response!( }, ); -request_response!( - TransportId, - "transport.connect", - TransportConnectPlainRequest { - #[serde(skip_serializing_if = "Option::is_none")] - ip: Option, - #[serde(skip_serializing_if = "Option::is_none")] - port: Option, - #[serde(skip_serializing_if = "Option::is_none")] - rtcp_port: Option, - #[serde(skip_serializing_if = "Option::is_none")] - srtp_parameters: Option, - }, - TransportConnectResponsePlain { - tuple: Option, - rtcp_tuple: Option, - srtp_parameters: Option, - }, -); +#[derive(Debug)] +pub(crate) struct PlainTransportConnectResponse { + pub(crate) tuple: TransportTuple, + pub(crate) rtcp_tuple: Option, + pub(crate) srtp_parameters: Option, +} + +#[derive(Debug)] +pub(crate) struct TransportConnectPlainRequest { + pub(crate) ip: Option, + pub(crate) port: Option, + pub(crate) rtcp_port: Option, + pub(crate) srtp_parameters: Option, +} + +impl RequestFbs for TransportConnectPlainRequest { + const METHOD: request::Method = request::Method::PlaintransportConnect; + type HandlerId = TransportId; + type Response = PlainTransportConnectResponse; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = plain_transport::ConnectRequest::create( + &mut builder, + self.ip.map(|ip| ip.to_string()), + self.port, + self.rtcp_port, + self.srtp_parameters.map(|parameters| parameters.to_fbs()), + ); + let request_body = + request::Body::create_plain_transport_connect_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::FbsPlainTransportConnectResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(PlainTransportConnectResponse { + tuple: TransportTuple::from_fbs(data.tuple.as_ref()), + rtcp_tuple: data + .rtcp_tuple + .map(|tuple| TransportTuple::from_fbs(tuple.as_ref())), + srtp_parameters: data + .srtp_parameters + .map(|parameters| SrtpParameters::from_fbs(parameters.as_ref())), + }) + } +} request_response!( TransportId, diff --git a/rust/src/router.rs b/rust/src/router.rs index d843c3fd31..a5e2b632c1 100644 --- a/rust/src/router.rs +++ b/rust/src/router.rs @@ -760,7 +760,7 @@ impl Router { let data = self .inner .channel - .request( + .request_fbs( self.inner.id, RouterCreatePlainTransportRequest { data: RouterCreatePlainTransportData::from_options( diff --git a/rust/src/router/direct_transport.rs b/rust/src/router/direct_transport.rs index 7c724bf4ad..6530268986 100644 --- a/rust/src/router/direct_transport.rs +++ b/rust/src/router/direct_transport.rs @@ -6,7 +6,7 @@ use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, Da use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, DataProducerType}; use crate::data_structures::{AppData, SctpState}; use crate::fbs::{direct_transport, response}; -use crate::messages::{TransportCloseRequest, TransportSendRtcpNotification}; +use crate::messages::{TransportCloseRequestFbs, TransportSendRtcpNotification}; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; use crate::router::Router; @@ -35,7 +35,7 @@ use std::sync::{Arc, Weak}; pub struct DirectTransportOptions { /// Maximum allowed size for direct messages sent from DataProducers. /// Default 262_144. - pub max_message_size: usize, + pub max_message_size: u32, /// Custom application data. pub app_data: AppData, } @@ -266,13 +266,13 @@ impl Inner { if close_request { let channel = self.channel.clone(); let router_id = self.router.id(); - let request = TransportCloseRequest { + let request = TransportCloseRequestFbs { transport_id: self.id, }; self.executor .spawn(async move { - if let Err(error) = channel.request(router_id, request).await { + if let Err(error) = channel.request_fbs(router_id, request).await { error!("transport closing failed on drop: {}", error); } }) diff --git a/rust/src/router/plain_transport.rs b/rust/src/router/plain_transport.rs index 2c99b6d327..933f12d2da 100644 --- a/rust/src/router/plain_transport.rs +++ b/rust/src/router/plain_transport.rs @@ -5,7 +5,8 @@ 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::messages::{PlainTransportData, TransportCloseRequest, TransportConnectPlainRequest}; +use crate::fbs::{plain_transport, response}; +use crate::messages::{PlainTransportData, TransportCloseRequestFbs, TransportConnectPlainRequest}; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; use crate::router::Router; @@ -24,6 +25,7 @@ use log::{debug, error}; use nohash_hasher::IntMap; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; +use std::error::Error; use std::fmt; use std::net::IpAddr; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; @@ -111,7 +113,7 @@ pub struct PlainTransportDump { pub data_consumer_ids: Vec, pub recv_rtp_header_extensions: RecvRtpHeaderExtensions, pub rtp_listener: RtpListener, - pub max_message_size: usize, + pub max_message_size: u32, pub sctp_parameters: Option, pub sctp_state: Option, pub sctp_listener: Option, @@ -124,6 +126,85 @@ pub struct PlainTransportDump { pub srtp_parameters: Option, } +impl PlainTransportDump { + pub(crate) fn from_fbs(dump: plain_transport::DumpResponse) -> Result> { + Ok(Self { + // Common to all Transports. + id: dump.base.id.parse()?, + direct: false, + producer_ids: dump + .base + .producer_ids + .iter() + .map(|producer_id| Ok(producer_id.parse()?)) + .collect::>>()?, + consumer_ids: dump + .base + .consumer_ids + .iter() + .map(|consumer_id| Ok(consumer_id.parse()?)) + .collect::>>()?, + map_ssrc_consumer_id: dump + .base + .map_ssrc_consumer_id + .iter() + .map(|key_value| Ok((key_value.key, key_value.value.parse()?))) + .collect::>>()?, + map_rtx_ssrc_consumer_id: dump + .base + .map_rtx_ssrc_consumer_id + .iter() + .map(|key_value| Ok((key_value.key, key_value.value.parse()?))) + .collect::>>()?, + data_producer_ids: dump + .base + .data_producer_ids + .iter() + .map(|data_producer_id| Ok(data_producer_id.parse()?)) + .collect::>>()?, + data_consumer_ids: dump + .base + .data_consumer_ids + .iter() + .map(|data_consumer_id| Ok(data_consumer_id.parse()?)) + .collect::>>()?, + recv_rtp_header_extensions: RecvRtpHeaderExtensions::from_fbs( + dump.base.recv_rtp_header_extensions.as_ref(), + ), + rtp_listener: RtpListener::from_fbs(dump.base.rtp_listener.as_ref())?, + max_message_size: dump.base.max_message_size, + sctp_parameters: dump + .base + .sctp_parameters + .as_ref() + .map(|parameters| SctpParameters::from_fbs(parameters.as_ref())), + sctp_state: dump + .base + .sctp_state + .map(|state| SctpState::from_fbs(&state)), + sctp_listener: dump.base.sctp_listener.as_ref().map(|listener| { + SctpListener::from_fbs(listener.as_ref()).expect("Error parsing SctpListner") + }), + trace_event_types: dump + .base + .trace_event_types + .iter() + .map(|event| event.to_string()) + .collect(), + // PlainTransport specific. + rtcp_mux: dump.rtcp_mux, + comedia: dump.comedia, + tuple: TransportTuple::from_fbs(dump.tuple.as_ref()), + rtcp_tuple: dump + .rtcp_tuple + .map(|tuple| TransportTuple::from_fbs(tuple.as_ref())), + srtp_parameters: dump + .srtp_parameters + .map(|parameters| SrtpParameters::from_fbs(parameters.as_ref())), + }) + } +} + /// RTC statistics of the plain transport. #[derive(Debug, Clone, PartialOrd, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -135,26 +216,27 @@ pub struct PlainTransportStat { pub transport_id: TransportId, pub timestamp: u64, pub sctp_state: Option, - pub bytes_received: usize, + pub bytes_received: u64, pub recv_bitrate: u32, - pub bytes_sent: usize, + pub bytes_sent: u64, pub send_bitrate: u32, - pub rtp_bytes_received: usize, + pub rtp_bytes_received: u64, pub rtp_recv_bitrate: u32, - pub rtp_bytes_sent: usize, + pub rtp_bytes_sent: u64, pub rtp_send_bitrate: u32, - pub rtx_bytes_received: usize, + pub rtx_bytes_received: u64, pub rtx_recv_bitrate: u32, - pub rtx_bytes_sent: usize, + pub rtx_bytes_sent: u64, pub rtx_send_bitrate: u32, - pub probation_bytes_sent: usize, + pub probation_bytes_sent: u64, pub probation_send_bitrate: u32, #[serde(skip_serializing_if = "Option::is_none")] pub available_outgoing_bitrate: Option, #[serde(skip_serializing_if = "Option::is_none")] pub available_incoming_bitrate: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub max_incoming_bitrate: Option, + pub max_incoming_bitrate: u32, + pub max_outgoing_bitrate: u32, + pub min_outgoing_bitrate: u32, #[serde(skip_serializing_if = "Option::is_none")] pub rtp_packet_loss_received: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -162,10 +244,50 @@ pub struct PlainTransportStat { // PlainTransport specific. pub rtcp_mux: bool, pub comedia: bool, - pub tuple: Option, + pub tuple: TransportTuple, pub rtcp_tuple: Option, } +impl PlainTransportStat { + pub(crate) fn from_fbs( + stats: plain_transport::GetStatsResponse, + ) -> Result> { + Ok(Self { + transport_id: stats.base.transport_id.parse()?, + timestamp: stats.base.timestamp, + sctp_state: stats.base.sctp_state.as_ref().map(SctpState::from_fbs), + bytes_received: stats.base.bytes_received, + recv_bitrate: stats.base.recv_bitrate, + bytes_sent: stats.base.bytes_sent, + send_bitrate: stats.base.send_bitrate, + rtp_bytes_received: stats.base.rtp_bytes_received, + rtp_recv_bitrate: stats.base.rtp_recv_bitrate, + rtp_bytes_sent: stats.base.rtp_bytes_sent, + rtp_send_bitrate: stats.base.rtp_send_bitrate, + rtx_bytes_received: stats.base.rtx_bytes_received, + rtx_recv_bitrate: stats.base.rtx_recv_bitrate, + rtx_bytes_sent: stats.base.rtx_bytes_sent, + rtx_send_bitrate: stats.base.rtx_send_bitrate, + probation_bytes_sent: stats.base.probation_bytes_sent, + probation_send_bitrate: stats.base.probation_send_bitrate, + available_outgoing_bitrate: stats.base.available_outgoing_bitrate, + available_incoming_bitrate: stats.base.available_incoming_bitrate, + max_incoming_bitrate: stats.base.max_incoming_bitrate, + max_outgoing_bitrate: stats.base.max_outgoing_bitrate, + min_outgoing_bitrate: stats.base.min_outgoing_bitrate, + rtp_packet_loss_received: stats.base.rtp_packet_loss_received, + rtp_packet_loss_sent: stats.base.rtp_packet_loss_sent, + // PlainTransport specific. + rtcp_mux: stats.rtcp_mux, + comedia: stats.comedia, + tuple: TransportTuple::from_fbs(stats.tuple.as_ref()), + rtcp_tuple: stats + .rtcp_tuple + .map(|tuple| TransportTuple::from_fbs(tuple.as_ref())), + }) + } +} + /// Remote parameters for plain transport. #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -254,13 +376,13 @@ impl Inner { if close_request { let channel = self.channel.clone(); let router_id = self.router.id(); - let request = TransportCloseRequest { + let request = TransportCloseRequestFbs { transport_id: self.id, }; self.executor .spawn(async move { - if let Err(error) = channel.request(router_id, request).await { + if let Err(error) = channel.request_fbs(router_id, request).await { error!("transport closing failed on drop: {}", error); } }) @@ -443,28 +565,25 @@ impl TransportGeneric for PlainTransport { async fn dump(&self) -> Result { debug!("dump()"); - todo!(); - /* - serde_json::from_value(self.dump_impl().await?).map_err(|error| { - RequestError::FailedToParse { - error: error.to_string(), - } - }) - */ + if let response::Body::FbsPlainTransportDumpResponse(data) = self.dump_impl().await? { + Ok(PlainTransportDump::from_fbs(*data).expect("Error parsing dump response")) + } else { + panic!("Wrong message from worker"); + } } async fn get_stats(&self) -> Result, RequestError> { debug!("get_stats()"); - todo!(); - - /* - serde_json::from_value(self.get_stats_impl().await?).map_err(|error| { - RequestError::FailedToParse { - error: error.to_string(), - } - }) - */ + if let response::Body::FbsPlainTransportGetStatsResponse(data) = + self.get_stats_impl().await? + { + Ok(vec![ + PlainTransportStat::from_fbs(*data).expect("Error parsing dump response") + ]) + } else { + panic!("Wrong message from worker"); + } } } @@ -688,7 +807,7 @@ impl PlainTransport { let response = self .inner .channel - .request( + .request_fbs( self.inner.id, TransportConnectPlainRequest { ip: remote_parameters.ip, @@ -699,9 +818,7 @@ impl PlainTransport { ) .await?; - if let Some(tuple) = response.tuple { - *self.inner.data.tuple.lock() = tuple; - } + *self.inner.data.tuple.lock() = response.tuple; if let Some(rtcp_tuple) = response.rtcp_tuple { self.inner.data.rtcp_tuple.lock().replace(rtcp_tuple); diff --git a/rust/src/router/transport.rs b/rust/src/router/transport.rs index c75078f348..bbae2096cf 100644 --- a/rust/src/router/transport.rs +++ b/rust/src/router/transport.rs @@ -4,8 +4,8 @@ use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, Da use crate::data_structures::{AppData, BweTraceInfo, RtpPacketTraceInfo, TraceEventDirection}; use crate::fbs::{response, transport}; use crate::messages::{ - TransportConsumeDataRequest, TransportConsumeRequest, TransportDumpRequestNew, - TransportEnableTraceEventRequest, TransportGetStatsRequestNew, TransportProduceDataRequest, + TransportConsumeDataRequest, TransportConsumeRequest, TransportDumpRequestFbs, + TransportEnableTraceEventRequest, TransportGetStatsRequestFbs, TransportProduceDataRequest, TransportProduceRequest, TransportSetMaxIncomingBitrateRequest, TransportSetMaxOutgoingBitrateRequest, TransportSetMinOutgoingBitrateRequest, }; @@ -408,13 +408,13 @@ pub(super) trait TransportImpl: TransportGeneric { async fn dump_impl(&self) -> Result { self.channel() - .request_fbs(self.id(), TransportDumpRequestNew {}) + .request_fbs(self.id(), TransportDumpRequestFbs {}) .await } async fn get_stats_impl(&self) -> Result { self.channel() - .request_fbs(self.id(), TransportGetStatsRequestNew {}) + .request_fbs(self.id(), TransportGetStatsRequestFbs {}) .await } diff --git a/rust/src/sctp_parameters.rs b/rust/src/sctp_parameters.rs index c81f3e6c6a..ce1167bbdf 100644 --- a/rust/src/sctp_parameters.rs +++ b/rust/src/sctp_parameters.rs @@ -43,6 +43,15 @@ impl Default for NumSctpStreams { } } +impl NumSctpStreams { + pub(crate) fn to_fbs(self) -> sctp_parameters::NumSctpStreams { + sctp_parameters::NumSctpStreams { + os: self.os, + mis: self.mis, + } + } +} + /// Parameters of the SCTP association. #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] diff --git a/rust/src/srtp_parameters.rs b/rust/src/srtp_parameters.rs index 3d5d48389c..464b9e2779 100644 --- a/rust/src/srtp_parameters.rs +++ b/rust/src/srtp_parameters.rs @@ -1,7 +1,9 @@ //! Collection of SRTP-related data structures that are used to specify SRTP encryption/decryption //! parameters. +use crate::fbs::transport; use serde::{Deserialize, Serialize}; +use std::str::FromStr; /// SRTP parameters. #[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)] @@ -13,6 +15,22 @@ pub struct SrtpParameters { pub key_base64: String, } +impl SrtpParameters { + pub(crate) fn from_fbs(tuple: &transport::SrtpParameters) -> Self { + Self { + crypto_suite: tuple.crypto_suite.parse().unwrap(), + key_base64: String::from(tuple.key_base64.as_str()), + } + } + + pub(crate) fn to_fbs(&self) -> transport::SrtpParameters { + transport::SrtpParameters { + crypto_suite: self.crypto_suite.to_string(), + key_base64: String::from(self.key_base64.as_str()), + } + } +} + /// SRTP crypto suite. #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)] pub enum SrtpCryptoSuite { @@ -35,3 +53,34 @@ impl Default for SrtpCryptoSuite { Self::AesCm128HmacSha180 } } + +// TODO: Remove once SrtpCryptoSuite is defined in fbs. +impl ToString for SrtpCryptoSuite { + fn to_string(&self) -> String { + match self { + Self::AeadAes256Gcm => String::from("AEAD_AES_256_GCM"), + Self::AeadAes128Gcm => String::from("AEAD_AES_128_GCM"), + Self::AesCm128HmacSha180 => String::from("AES_CM_128_HMAC_SHA1_80"), + Self::AesCm128HmacSha132 => String::from("AES_CM_128_HMAC_SHA1_32"), + } + } +} + +/// Error that caused [`SrtpCryptoSuite`] parsing error. +#[derive(Debug, Eq, PartialEq)] +pub struct ParseCryptoSuiteError; + +// TODO: Remove once SrtpCryptoSuite is defined in fbs. +impl FromStr for SrtpCryptoSuite { + type Err = ParseCryptoSuiteError; + + fn from_str(s: &str) -> Result { + match s { + "AEAD_AES_256_GCM" => Ok(Self::AeadAes256Gcm), + "AEAD_AES_128_GCM" => Ok(Self::AeadAes128Gcm), + "AES_CM_128_HMAC_SHA1_80" => Ok(Self::AesCm128HmacSha180), + "AES_CM_128_HMAC_SHA1_32" => Ok(Self::AesCm128HmacSha132), + _ => Err(ParseCryptoSuiteError), + } + } +} diff --git a/rust/src/worker/channel.rs b/rust/src/worker/channel.rs index 5cf485bf24..328ca0eca9 100644 --- a/rust/src/worker/channel.rs +++ b/rust/src/worker/channel.rs @@ -602,6 +602,7 @@ impl Channel { match response_result { Ok(data) => { debug!("request succeeded [method:{:?}, id:{}]", R::METHOD, id); + trace!("{data:?}"); Ok(R::convert_response(data).map_err(RequestError::ResponseConversion)?) } diff --git a/rust/tests/integration/plain_transport.rs b/rust/tests/integration/plain_transport.rs index 3ac40d9bf8..c968c395b5 100644 --- a/rust/tests/integration/plain_transport.rs +++ b/rust/tests/integration/plain_transport.rs @@ -82,7 +82,6 @@ async fn init() -> (Worker, Router) { } #[test] -#[ignore] fn create_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -270,7 +269,6 @@ fn create_succeeds() { } #[test] -#[ignore] fn create_with_fixed_port_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -296,7 +294,6 @@ fn create_with_fixed_port_succeeds() { } #[test] -#[ignore] fn weak() { future::block_on(async move { let (_worker, router) = init().await; @@ -329,7 +326,6 @@ fn weak() { } #[test] -#[ignore] fn create_enable_srtp_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -396,7 +392,6 @@ fn create_enable_srtp_succeeds() { } #[test] -#[ignore] fn create_non_bindable_ip() { future::block_on(async move { let (_worker, router) = init().await; @@ -418,7 +413,6 @@ fn create_non_bindable_ip() { } #[test] -#[ignore] fn get_stats_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -463,13 +457,10 @@ fn get_stats_succeeds() { assert_eq!(stats[0].probation_send_bitrate, 0); assert_eq!(stats[0].rtp_packet_loss_received, None); assert_eq!(stats[0].rtp_packet_loss_sent, None); - assert!(matches!( - stats[0].tuple, - Some(TransportTuple::LocalOnly { .. }), - )); + assert!(matches!(stats[0].tuple, TransportTuple::LocalOnly { .. },)); if let TransportTuple::LocalOnly { local_ip, protocol, .. - } = stats[0].tuple.unwrap() + } = stats[0].tuple { assert_eq!(local_ip, "4.4.4.4".parse::().unwrap()); assert_eq!(protocol, Protocol::Udp); @@ -479,7 +470,6 @@ fn get_stats_succeeds() { } #[test] -#[ignore] fn connect_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -555,7 +545,6 @@ fn connect_succeeds() { } #[test] -#[ignore] fn connect_wrong_arguments() { future::block_on(async move { let (_worker, router) = init().await; @@ -596,7 +585,6 @@ fn connect_wrong_arguments() { } #[test] -#[ignore] fn close_event() { future::block_on(async move { let (_worker, router) = init().await; diff --git a/worker/fbs/plainTransport.fbs b/worker/fbs/plainTransport.fbs index 20a1baec18..4470d2eace 100644 --- a/worker/fbs/plainTransport.fbs +++ b/worker/fbs/plainTransport.fbs @@ -4,7 +4,7 @@ include "sctpParameters.fbs"; namespace FBS.PlainTransport; table PlainTransportOptions { - base:FBS.Transport.Options; + base:FBS.Transport.Options (required); listen_info:FBS.Transport.ListenInfo (required); rtcp_listen_info:FBS.Transport.ListenInfo; rtcp_mux:bool; @@ -30,7 +30,7 @@ table DumpResponse { base:FBS.Transport.Dump (required); rtcp_mux:bool; comedia:bool; - tuple:FBS.Transport.Tuple; + tuple:FBS.Transport.Tuple (required); rtcp_tuple:FBS.Transport.Tuple; srtp_parameters:FBS.Transport.SrtpParameters; } diff --git a/worker/fbs/request.fbs b/worker/fbs/request.fbs index c2c3e1f4f0..3c76e99ddc 100644 --- a/worker/fbs/request.fbs +++ b/worker/fbs/request.fbs @@ -103,7 +103,7 @@ union Body { FBS.Transport.CloseConsumerRequest, FBS.Transport.CloseDataProducerRequest, FBS.Transport.CloseDataConsumerRequest, - FBS.PlainTransport.ConnectRequest, + PlainTransport_ConnectRequest: FBS.PlainTransport.ConnectRequest, FBS.PipeTransport.ConnectRequest, FBS.WebRtcTransport.ConnectRequest, FBS.Producer.EnableTraceEventRequest, diff --git a/worker/fbs/sctpParameters.fbs b/worker/fbs/sctpParameters.fbs index ffbd8b7181..5727fcf22a 100644 --- a/worker/fbs/sctpParameters.fbs +++ b/worker/fbs/sctpParameters.fbs @@ -2,8 +2,8 @@ namespace FBS.SctpParameters; table NumSctpStreams { - os:uint32 = 1024; - mis:uint32 = 1024; + os:uint16 = 1024; + mis:uint16 = 1024; } table SctpParameters { diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs index b61f317460..1c291876cf 100644 --- a/worker/fbs/transport.fbs +++ b/worker/fbs/transport.fbs @@ -77,7 +77,7 @@ table ConsumeDataRequest { table Tuple { local_ip:string (required); local_port:uint16; - remote_ip:string (required); + remote_ip:string; remote_port:uint16; protocol:string (required); } diff --git a/worker/src/RTC/PlainTransport.cpp b/worker/src/RTC/PlainTransport.cpp index df0e91c774..b3a6b6b184 100644 --- a/worker/src/RTC/PlainTransport.cpp +++ b/worker/src/RTC/PlainTransport.cpp @@ -296,7 +296,7 @@ namespace RTC } tuple = FBS::Transport::CreateTupleDirect( - builder, localIp.c_str(), this->udpSocket->GetLocalPort(), "", 0, "udp"); + builder, localIp.c_str(), this->udpSocket->GetLocalPort(), nullptr, 0, "udp"); } // Add rtcpTuple. @@ -322,7 +322,7 @@ namespace RTC } rtcpTuple = FBS::Transport::CreateTupleDirect( - builder, localIp.c_str(), this->rtcpUdpSocket->GetLocalPort(), "", 0, "udp"); + builder, localIp.c_str(), this->rtcpUdpSocket->GetLocalPort(), nullptr, 0, "udp"); } } From a23fd0e97392d631ae96edf5ba90bdd8c2ffe36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Fri, 1 Sep 2023 10:16:32 +0200 Subject: [PATCH 17/73] Use FBS Transport::Tuple everywhere (#1148) --- node/src/Transport.ts | 26 ++++++- node/src/WebRtcTransport.ts | 3 +- node/src/tests/test-WebRtcTransport.ts | 5 +- rust/src/data_structures.rs | 12 ++- rust/src/fbs.rs | 102 +++++++++++++++++++------ worker/fbs/transport.fbs | 2 +- worker/fbs/webRtcTransport.fbs | 2 +- worker/include/RTC/IceCandidate.hpp | 8 +- worker/include/RTC/TransportTuple.hpp | 3 + worker/src/RTC/IceCandidate.cpp | 15 +--- worker/src/RTC/PipeTransport.cpp | 4 +- worker/src/RTC/PlainTransport.cpp | 6 +- worker/src/RTC/TransportTuple.cpp | 42 ++++++---- 13 files changed, 155 insertions(+), 75 deletions(-) diff --git a/node/src/Transport.ts b/node/src/Transport.ts index f041359574..0d4b237dd6 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -1310,6 +1310,30 @@ export function parseSctpState(fbsSctpState: FbsSctpState): SctpState } } +export function parseProtocol(protocol: FbsTransport.Protocol): TransportProtocol +{ + switch (protocol) + { + case FbsTransport.Protocol.UDP: + return 'udp'; + + case FbsTransport.Protocol.TCP: + return 'tcp'; + } +} + +export function serializeProtocol(protocol: TransportProtocol): FbsTransport.Protocol +{ + switch (protocol) + { + case 'udp': + return FbsTransport.Protocol.UDP; + + case 'tcp': + return FbsTransport.Protocol.TCP; + } +} + export function parseTuple(binary: FbsTransport.Tuple): TransportTuple { return { @@ -1317,7 +1341,7 @@ export function parseTuple(binary: FbsTransport.Tuple): TransportTuple localPort : binary.localPort(), remoteIp : binary.remoteIp() ?? undefined, remotePort : binary.remotePort(), - protocol : binary.protocol()! as TransportProtocol + protocol : parseProtocol(binary.protocol()) }; } diff --git a/node/src/WebRtcTransport.ts b/node/src/WebRtcTransport.ts index 019a7cba2e..3b619c0c3c 100644 --- a/node/src/WebRtcTransport.ts +++ b/node/src/WebRtcTransport.ts @@ -4,6 +4,7 @@ import { parseSctpState, parseBaseTransportDump, parseBaseTransportStats, + parseProtocol, parseTransportTraceEventData, parseTuple, BaseTransportDump, @@ -741,7 +742,7 @@ function parseIceCandidate(binary: FbsWebRtcTransport.IceCandidate): IceCandidat foundation : binary.foundation()!, priority : binary.priority(), ip : binary.ip()!, - protocol : binary.protocol() as TransportProtocol, + protocol : parseProtocol(binary.protocol()), port : binary.port(), type : 'host', tcpType : binary.tcpType() === 'passive' ? 'passive' : undefined diff --git a/node/src/tests/test-WebRtcTransport.ts b/node/src/tests/test-WebRtcTransport.ts index 2cc379b826..fd4df0dae8 100644 --- a/node/src/tests/test-WebRtcTransport.ts +++ b/node/src/tests/test-WebRtcTransport.ts @@ -5,6 +5,7 @@ import * as mediasoup from '../'; import { Notification, Body as NotificationBody, Event } from '../fbs/notification'; import * as FbsTransport from '../fbs/transport'; import * as FbsWebRtcTransport from '../fbs/web-rtc-transport'; +import { serializeProtocol, TransportTuple } from '../Transport'; const { createWorker } = mediasoup; @@ -517,7 +518,7 @@ test('WebRtcTransport events succeed', async () => builder.clear(); const onIceSelectedTuple = jest.fn(); - const iceSelectedTuple = + const iceSelectedTuple: TransportTuple = { localIp : '1.1.1.1', localPort : 1111, @@ -536,7 +537,7 @@ test('WebRtcTransport events succeed', async () => iceSelectedTuple.localPort, iceSelectedTuple.remoteIp, iceSelectedTuple.remotePort, - iceSelectedTuple.protocol) + serializeProtocol(iceSelectedTuple.protocol)) ); notificationOffset = Notification.createNotification( diff --git a/rust/src/data_structures.rs b/rust/src/data_structures.rs index 3f3dc28ce5..eafd39039a 100644 --- a/rust/src/data_structures.rs +++ b/rust/src/data_structures.rs @@ -147,12 +147,10 @@ pub enum Protocol { } impl Protocol { - // TODO: Use the Protocol FBS type. - pub(crate) fn from_fbs(protocol: &str) -> Self { + pub(crate) fn from_fbs(protocol: transport::Protocol) -> Self { match protocol { - "tcp" => Protocol::Tcp, - "udp" => Protocol::Udp, - _ => todo!(), + transport::Protocol::Tcp => Protocol::Tcp, + transport::Protocol::Udp => Protocol::Udp, } } } @@ -284,12 +282,12 @@ impl TransportTuple { .parse() .expect("Error parsing IP address"), remote_port: tuple.remote_port, - protocol: Protocol::from_fbs(tuple.protocol.as_str()), + protocol: Protocol::from_fbs(tuple.protocol), }, None => TransportTuple::LocalOnly { local_ip: tuple.local_ip.parse().expect("Error parsing IP address"), local_port: tuple.local_port, - protocol: Protocol::from_fbs(tuple.protocol.as_str()), + protocol: Protocol::from_fbs(tuple.protocol), }, } } diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index 59a62b22ca..3094851590 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -35827,7 +35827,7 @@ mod root { /// The field `remote_port` in the table `Tuple` pub remote_port: u16, /// The field `protocol` in the table `Tuple` - pub protocol: ::planus::alloc::string::String, + pub protocol: self::Protocol, } impl Tuple { @@ -35846,13 +35846,13 @@ mod root { ::planus::Offset<::core::primitive::str>, >, field_remote_port: impl ::planus::WriteAsDefault, - field_protocol: impl ::planus::WriteAs<::planus::Offset>, + 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); + let prepared_protocol = field_protocol.prepare(builder, &self::Protocol::Udp); let mut table_writer: ::planus::table_writer::TableWriter<14> = ::core::default::Default::default(); @@ -35860,13 +35860,15 @@ mod root { if prepared_remote_ip.is_some() { table_writer.write_entry::<::planus::Offset>(2); } - table_writer.write_entry::<::planus::Offset>(4); 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| { @@ -35876,7 +35878,6 @@ mod root { { object_writer.write::<_, _, 4>(&prepared_remote_ip); } - object_writer.write::<_, _, 4>(&prepared_protocol); if let ::core::option::Option::Some(prepared_local_port) = prepared_local_port { @@ -35887,6 +35888,11 @@ mod root { { 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() @@ -35923,7 +35929,7 @@ mod root { self.local_port, &self.remote_ip, self.remote_port, - &self.protocol, + self.protocol, ) } } @@ -36015,11 +36021,20 @@ mod root { #[allow(clippy::type_complexity)] pub fn protocol(self, value: T4) -> TupleBuilder<(T0, T1, T2, T3, T4)> where - T4: ::planus::WriteAs<::planus::Offset>, + 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)> { @@ -36038,7 +36053,7 @@ mod root { T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAsDefault, > ::planus::WriteAs<::planus::Offset> for TupleBuilder<(T0, T1, T2, T3, T4)> { @@ -36055,7 +36070,7 @@ mod root { T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAsDefault, > ::planus::WriteAsOptional<::planus::Offset> for TupleBuilder<(T0, T1, T2, T3, T4)> { @@ -36075,7 +36090,7 @@ mod root { T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAsDefault, > ::planus::WriteAsOffset for TupleBuilder<(T0, T1, T2, T3, T4)> { #[inline] @@ -36123,8 +36138,12 @@ mod root { /// Getter for the [`protocol` field](Tuple#structfield.protocol). #[inline] - pub fn protocol(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(4, "Tuple", "protocol") + pub fn protocol(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(4, "Tuple", "protocol")? + .unwrap_or(self::Protocol::Udp), + ) } } @@ -74929,7 +74948,7 @@ mod root { /// The field `ip` in the table `IceCandidate` pub ip: ::planus::alloc::string::String, /// The field `protocol` in the table `IceCandidate` - pub protocol: ::planus::alloc::string::String, + pub protocol: super::transport::Protocol, /// The field `port` in the table `IceCandidate` pub port: u16, /// The field `type` in the table `IceCandidate` @@ -74951,7 +74970,10 @@ mod root { field_foundation: impl ::planus::WriteAs<::planus::Offset>, field_priority: impl ::planus::WriteAsDefault, field_ip: impl ::planus::WriteAs<::planus::Offset>, - field_protocol: 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::WriteAsOptional< ::planus::Offset<::core::primitive::str>, @@ -74963,7 +74985,8 @@ mod root { 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); + 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); let prepared_tcp_type = field_tcp_type.prepare(builder); @@ -74975,7 +74998,6 @@ mod root { table_writer.write_entry::(1); } table_writer.write_entry::<::planus::Offset>(2); - table_writer.write_entry::<::planus::Offset>(3); if prepared_type_.is_some() { table_writer.write_entry::<::planus::Offset>(5); } @@ -74985,6 +75007,9 @@ mod root { if prepared_port.is_some() { table_writer.write_entry::(4); } + if prepared_protocol.is_some() { + table_writer.write_entry::(3); + } unsafe { table_writer.finish(builder, |object_writer| { @@ -74995,7 +75020,6 @@ mod root { object_writer.write::<_, _, 4>(&prepared_priority); } object_writer.write::<_, _, 4>(&prepared_ip); - object_writer.write::<_, _, 4>(&prepared_protocol); if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { object_writer.write::<_, _, 4>(&prepared_type_); } @@ -75007,6 +75031,11 @@ mod root { 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() @@ -75048,7 +75077,7 @@ mod root { &self.foundation, self.priority, &self.ip, - &self.protocol, + self.protocol, self.port, &self.type_, &self.tcp_type, @@ -75116,11 +75145,23 @@ mod root { #[allow(clippy::type_complexity)] pub fn protocol(self, value: T3) -> IceCandidateBuilder<(T0, T1, T2, T3)> where - T3: ::planus::WriteAs<::planus::Offset>, + 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)> { @@ -75206,7 +75247,10 @@ mod root { T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAsDefault< + super::transport::Protocol, + super::transport::Protocol, + >, T4: ::planus::WriteAsDefault, T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, T6: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, @@ -75228,7 +75272,10 @@ mod root { T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAsDefault< + super::transport::Protocol, + super::transport::Protocol, + >, T4: ::planus::WriteAsDefault, T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, T6: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, @@ -75250,7 +75297,10 @@ mod root { T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAsDefault< + super::transport::Protocol, + super::transport::Protocol, + >, T4: ::planus::WriteAsDefault, T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, T6: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, @@ -75294,8 +75344,12 @@ mod root { /// Getter for the [`protocol` field](IceCandidate#structfield.protocol). #[inline] - pub fn protocol(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(3, "IceCandidate", "protocol") + 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). diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs index 1c291876cf..6e5914f366 100644 --- a/worker/fbs/transport.fbs +++ b/worker/fbs/transport.fbs @@ -79,7 +79,7 @@ table Tuple { local_port:uint16; remote_ip:string; remote_port:uint16; - protocol:string (required); + protocol:FBS.Transport.Protocol=UDP; } table SrtpParameters { diff --git a/worker/fbs/webRtcTransport.fbs b/worker/fbs/webRtcTransport.fbs index f3551139e2..6a77106c35 100644 --- a/worker/fbs/webRtcTransport.fbs +++ b/worker/fbs/webRtcTransport.fbs @@ -41,7 +41,7 @@ table IceCandidate { foundation:string (required); priority:uint32; ip:string (required); - protocol:string (required); + protocol:FBS.Transport.Protocol=UDP; port:uint16; type:string; tcp_type:string; diff --git a/worker/include/RTC/IceCandidate.hpp b/worker/include/RTC/IceCandidate.hpp index 448dc390b9..0fef17b75d 100644 --- a/worker/include/RTC/IceCandidate.hpp +++ b/worker/include/RTC/IceCandidate.hpp @@ -4,6 +4,7 @@ #include "common.hpp" #include "FBS/webRtcTransport_generated.h" #include "RTC/TcpServer.hpp" +#include "RTC/TransportTuple.hpp" #include "RTC/UdpSocket.hpp" #include #include @@ -12,12 +13,7 @@ namespace RTC { class IceCandidate { - public: - enum class Protocol - { - UDP = 1, - TCP - }; + using Protocol = TransportTuple::Protocol; public: enum class CandidateType diff --git a/worker/include/RTC/TransportTuple.hpp b/worker/include/RTC/TransportTuple.hpp index 3fc01bca78..efc37ad2bf 100644 --- a/worker/include/RTC/TransportTuple.hpp +++ b/worker/include/RTC/TransportTuple.hpp @@ -23,6 +23,9 @@ namespace RTC TCP }; + static Protocol ProtocolFromFbs(FBS::Transport::Protocol protocol); + static FBS::Transport::Protocol ProtocolToFbs(Protocol protocol); + public: TransportTuple(RTC::UdpSocket* udpSocket, const struct sockaddr* udpRemoteAddr) : udpSocket(udpSocket), udpRemoteAddr((struct sockaddr*)udpRemoteAddr), protocol(Protocol::UDP) diff --git a/worker/src/RTC/IceCandidate.cpp b/worker/src/RTC/IceCandidate.cpp index 67af1a18e4..f04aa10c21 100644 --- a/worker/src/RTC/IceCandidate.cpp +++ b/worker/src/RTC/IceCandidate.cpp @@ -13,18 +13,7 @@ namespace RTC { MS_TRACE(); - std::string protocol; - - switch (this->protocol) - { - case Protocol::UDP: - protocol = "udp"; - break; - - case Protocol::TCP: - protocol = "tcp"; - break; - } + auto protocol = TransportTuple::ProtocolToFbs(this->protocol); std::string type; @@ -56,7 +45,7 @@ namespace RTC // ip. this->ip.c_str(), // protocol. - protocol.c_str(), + protocol, // port. this->port, // type. diff --git a/worker/src/RTC/PipeTransport.cpp b/worker/src/RTC/PipeTransport.cpp index d75b396c09..bfdf7d5585 100644 --- a/worker/src/RTC/PipeTransport.cpp +++ b/worker/src/RTC/PipeTransport.cpp @@ -169,7 +169,7 @@ namespace RTC } tuple = FBS::Transport::CreateTupleDirect( - builder, localIp.c_str(), this->udpSocket->GetLocalPort(), "", 0, "udp"); + builder, localIp.c_str(), this->udpSocket->GetLocalPort(), "", 0, FBS::Transport::Protocol::UDP); } // Add srtpParameters. @@ -223,7 +223,7 @@ namespace RTC // remotePort. 0, // protocol. - "udp"); + FBS::Transport::Protocol::UDP); } // Base Transport stats. diff --git a/worker/src/RTC/PlainTransport.cpp b/worker/src/RTC/PlainTransport.cpp index b3a6b6b184..9310674bff 100644 --- a/worker/src/RTC/PlainTransport.cpp +++ b/worker/src/RTC/PlainTransport.cpp @@ -296,7 +296,7 @@ namespace RTC } tuple = FBS::Transport::CreateTupleDirect( - builder, localIp.c_str(), this->udpSocket->GetLocalPort(), nullptr, 0, "udp"); + builder, localIp.c_str(), this->udpSocket->GetLocalPort(), nullptr, 0, FBS::Transport::Protocol::UDP); } // Add rtcpTuple. @@ -322,7 +322,7 @@ namespace RTC } rtcpTuple = FBS::Transport::CreateTupleDirect( - builder, localIp.c_str(), this->rtcpUdpSocket->GetLocalPort(), nullptr, 0, "udp"); + builder, localIp.c_str(), this->rtcpUdpSocket->GetLocalPort(), nullptr, 0, FBS::Transport::Protocol::UDP); } } @@ -381,7 +381,7 @@ namespace RTC // remotePort. 0, // protocol. - "udp" + FBS::Transport::Protocol::UDP ); } diff --git a/worker/src/RTC/TransportTuple.cpp b/worker/src/RTC/TransportTuple.cpp index 4150b2f7e0..12f045e49c 100644 --- a/worker/src/RTC/TransportTuple.cpp +++ b/worker/src/RTC/TransportTuple.cpp @@ -7,6 +7,32 @@ namespace RTC { + /* Static methods. */ + + TransportTuple::Protocol TransportTuple::ProtocolFromFbs(FBS::Transport::Protocol protocol) + { + switch (protocol) + { + case FBS::Transport::Protocol::UDP: + return TransportTuple::Protocol::UDP; + + case FBS::Transport::Protocol::TCP: + return TransportTuple::Protocol::TCP; + } + } + + FBS::Transport::Protocol TransportTuple::ProtocolToFbs(TransportTuple::Protocol protocol) + { + switch (protocol) + { + case TransportTuple::Protocol::UDP: + return FBS::Transport::Protocol::UDP; + + case TransportTuple::Protocol::TCP: + return FBS::Transport::Protocol::TCP; + } + } + /* Instance methods. */ flatbuffers::Offset TransportTuple::FillBuffer( @@ -27,22 +53,10 @@ namespace RTC Utils::IP::GetAddressInfo(GetRemoteAddress(), family, remoteIp, remotePort); - std::string protocol; - - // Add protocol. - switch (GetProtocol()) - { - case Protocol::UDP: - protocol = "udp"; - break; - - case Protocol::TCP: - protocol = "tcp"; - break; - } + auto protocol = TransportTuple::ProtocolToFbs(GetProtocol()); return FBS::Transport::CreateTupleDirect( - builder, localIp.c_str(), localPort, remoteIp.c_str(), remotePort, protocol.c_str()); + builder, localIp.c_str(), localPort, remoteIp.c_str(), remotePort, protocol); } void TransportTuple::Dump() const From 258c17c9906e230d87de6ca902ae6c18ba953991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Mon, 4 Sep 2023 10:19:12 +0200 Subject: [PATCH 18/73] rust: move PipeTransport to flatbuffers (#1149) --- node/src/PipeTransport.ts | 2 +- rust/src/fbs.rs | 136 ++++++++++++++++------- rust/src/messages.rs | 67 ++++++++--- rust/src/router/pipe_transport.rs | 178 ++++++++++++++++++++++++------ worker/fbs/request.fbs | 2 +- 5 files changed, 297 insertions(+), 88 deletions(-) diff --git a/node/src/PipeTransport.ts b/node/src/PipeTransport.ts index 5f6b5d927d..4782182777 100644 --- a/node/src/PipeTransport.ts +++ b/node/src/PipeTransport.ts @@ -313,7 +313,7 @@ export class PipeTransport // Wait for response. const response = await this.channel.request( FbsRequest.Method.PIPETRANSPORT_CONNECT, - FbsRequest.Body.FBS_PipeTransport_ConnectRequest, + FbsRequest.Body.PipeTransport_ConnectRequest, requestOffset, this.internal.transportId ); diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index 3094851590..655c846729 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -50465,6 +50465,11 @@ mod root { ::planus::alloc::boxed::Box, ), + /// The variant `PipeTransport_ConnectRequest` in the union `Body` + PipeTransportConnectRequest( + ::planus::alloc::boxed::Box, + ), + /// The variant of type `FBS.WebRtcTransport.ConnectRequest` in the union `Body` ConnectRequest( ::planus::alloc::boxed::Box, @@ -50718,12 +50723,20 @@ mod root { ::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_connect_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(27, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(28, value.prepare(builder).downcast()) } #[inline] @@ -50731,7 +50744,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(28, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(29, value.prepare(builder).downcast()) } #[inline] @@ -50739,7 +50752,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(29, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(30, value.prepare(builder).downcast()) } #[inline] @@ -50749,7 +50762,7 @@ mod root { super::data_consumer::SetBufferedAmountLowThresholdRequest, >, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(30, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(31, value.prepare(builder).downcast()) } #[inline] @@ -50757,7 +50770,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(31, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(32, value.prepare(builder).downcast()) } #[inline] @@ -50765,7 +50778,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(32, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(33, value.prepare(builder).downcast()) } #[inline] @@ -50773,7 +50786,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(33, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(34, value.prepare(builder).downcast()) } } @@ -50855,6 +50868,9 @@ mod root { Self::PlainTransportConnectRequest(value) => { Self::create_plain_transport_connect_request(builder, value) } + Self::PipeTransportConnectRequest(value) => { + Self::create_pipe_transport_connect_request(builder, value) + } Self::ConnectRequest(value) => Self::create_connect_request(builder, value), Self::SetPreferredLayersRequest(value) => { Self::create_set_preferred_layers_request(builder, value) @@ -51206,12 +51222,24 @@ mod root { 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 [`ConnectRequest` variant](Body#variant.ConnectRequest). #[inline] pub fn connect_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<27, T>> + ) -> BodyBuilder<::planus::Initialized<28, T>> where T: ::planus::WriteAsOffset, { @@ -51223,7 +51251,7 @@ mod root { pub fn set_preferred_layers_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<28, T>> + ) -> BodyBuilder<::planus::Initialized<29, T>> where T: ::planus::WriteAsOffset, { @@ -51235,7 +51263,7 @@ mod root { pub fn set_priority_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<29, T>> + ) -> BodyBuilder<::planus::Initialized<30, T>> where T: ::planus::WriteAsOffset, { @@ -51247,7 +51275,7 @@ mod root { pub fn set_buffered_amount_low_threshold_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<30, T>> + ) -> BodyBuilder<::planus::Initialized<31, T>> where T: ::planus::WriteAsOffset< super::data_consumer::SetBufferedAmountLowThresholdRequest, @@ -51258,7 +51286,7 @@ mod root { /// Creates an instance of the [`SendRequest` variant](Body#variant.SendRequest). #[inline] - pub fn send_request(self, value: T) -> BodyBuilder<::planus::Initialized<31, T>> + pub fn send_request(self, value: T) -> BodyBuilder<::planus::Initialized<32, T>> where T: ::planus::WriteAsOffset, { @@ -51270,7 +51298,7 @@ mod root { pub fn add_producer_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<32, T>> + ) -> BodyBuilder<::planus::Initialized<33, T>> where T: ::planus::WriteAsOffset, { @@ -51282,7 +51310,7 @@ mod root { pub fn remove_producer_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<33, T>> + ) -> BodyBuilder<::planus::Initialized<34, T>> where T: ::planus::WriteAsOffset, { @@ -51875,7 +51903,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<27, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -51885,7 +51913,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<27, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -51897,7 +51925,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<28, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -51907,7 +51935,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<28, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -51919,7 +51947,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<29, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -51929,7 +51957,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<29, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -51941,9 +51969,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<30, T>> where - T: ::planus::WriteAsOffset< - super::data_consumer::SetBufferedAmountLowThresholdRequest, - >, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -51953,9 +51979,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<30, T>> where - T: ::planus::WriteAsOffset< - super::data_consumer::SetBufferedAmountLowThresholdRequest, - >, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -51967,7 +51991,9 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<31, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset< + super::data_consumer::SetBufferedAmountLowThresholdRequest, + >, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -51977,7 +52003,9 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<31, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset< + super::data_consumer::SetBufferedAmountLowThresholdRequest, + >, { #[inline] fn prepare( @@ -51989,7 +52017,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<32, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -51999,7 +52027,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<32, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -52011,7 +52039,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<33, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -52020,6 +52048,28 @@ mod root { } impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<33, 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<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, { @@ -52065,6 +52115,7 @@ mod root { CloseDataProducerRequest(super::transport::CloseDataProducerRequestRef<'a>), CloseDataConsumerRequest(super::transport::CloseDataConsumerRequestRef<'a>), PlainTransportConnectRequest(super::plain_transport::ConnectRequestRef<'a>), + PipeTransportConnectRequest(super::pipe_transport::ConnectRequestRef<'a>), ConnectRequest(super::web_rtc_transport::ConnectRequestRef<'a>), SetPreferredLayersRequest(super::consumer::SetPreferredLayersRequestRef<'a>), SetPriorityRequest(super::consumer::SetPriorityRequestRef<'a>), @@ -52239,6 +52290,12 @@ mod root { )) } + BodyRef::PipeTransportConnectRequest(value) => { + Self::PipeTransportConnectRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + BodyRef::ConnectRequest(value) => { Self::ConnectRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, @@ -52371,27 +52428,30 @@ mod root { 26 => ::core::result::Result::Ok(Self::PlainTransportConnectRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 27 => ::core::result::Result::Ok(Self::ConnectRequest( + 27 => ::core::result::Result::Ok(Self::PipeTransportConnectRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 28 => ::core::result::Result::Ok(Self::ConnectRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 28 => ::core::result::Result::Ok(Self::SetPreferredLayersRequest( + 29 => ::core::result::Result::Ok(Self::SetPreferredLayersRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 29 => ::core::result::Result::Ok(Self::SetPriorityRequest( + 30 => ::core::result::Result::Ok(Self::SetPriorityRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 30 => { + 31 => { ::core::result::Result::Ok(Self::SetBufferedAmountLowThresholdRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )) } - 31 => ::core::result::Result::Ok(Self::SendRequest( + 32 => ::core::result::Result::Ok(Self::SendRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 32 => ::core::result::Result::Ok(Self::AddProducerRequest( + 33 => ::core::result::Result::Ok(Self::AddProducerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 33 => ::core::result::Result::Ok(Self::RemoveProducerRequest( + 34 => ::core::result::Result::Ok(Self::RemoveProducerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), _ => ::core::result::Result::Err( diff --git a/rust/src/messages.rs b/rust/src/messages.rs index c28e231a91..0e9124b824 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -12,7 +12,8 @@ use crate::data_structures::{ }; use crate::direct_transport::DirectTransportOptions; use crate::fbs::{ - direct_transport, message, plain_transport, request, response, router, transport, worker, + direct_transport, message, pipe_transport, plain_transport, request, response, router, + transport, worker, }; use crate::ortc::RtpMapping; use crate::pipe_transport::PipeTransportOptions; @@ -1278,19 +1279,57 @@ request_response!( }, ); -request_response!( - TransportId, - "transport.connect", - TransportConnectPipeRequest { - ip: IpAddr, - port: u16, - #[serde(skip_serializing_if = "Option::is_none")] - srtp_parameters: Option, - }, - TransportConnectResponsePipe { - tuple: TransportTuple, - }, -); +#[derive(Debug)] +pub(crate) struct PipeTransportConnectResponse { + pub(crate) tuple: TransportTuple, +} + +#[derive(Debug)] +pub(crate) struct PipeTransportConnectRequest { + pub(crate) ip: IpAddr, + pub(crate) port: u16, + pub(crate) srtp_parameters: Option, +} + +impl RequestFbs for PipeTransportConnectRequest { + const METHOD: request::Method = request::Method::PipetransportConnect; + type HandlerId = TransportId; + type Response = PipeTransportConnectResponse; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = pipe_transport::ConnectRequest::create( + &mut builder, + self.ip.to_string(), + self.port, + self.srtp_parameters.map(|parameters| parameters.to_fbs()), + ); + let request_body = request::Body::create_pipe_transport_connect_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::FbsPlainTransportConnectResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(PipeTransportConnectResponse { + tuple: TransportTuple::from_fbs(data.tuple.as_ref()), + }) + } +} #[derive(Debug)] pub(crate) struct PlainTransportConnectResponse { diff --git a/rust/src/router/pipe_transport.rs b/rust/src/router/pipe_transport.rs index b4b94c6ea8..7e37e767b2 100644 --- a/rust/src/router/pipe_transport.rs +++ b/rust/src/router/pipe_transport.rs @@ -5,7 +5,8 @@ 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::messages::{PipeTransportData, TransportCloseRequest, TransportConnectPipeRequest}; +use crate::fbs::{pipe_transport, response}; +use crate::messages::{PipeTransportConnectRequest, PipeTransportData, TransportCloseRequestFbs}; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; use crate::router::Router; @@ -24,6 +25,7 @@ use log::{debug, error}; use nohash_hasher::IntMap; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; +use std::error::Error; use std::fmt; use std::net::IpAddr; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; @@ -92,17 +94,92 @@ pub struct PipeTransportDump { pub data_consumer_ids: Vec, pub recv_rtp_header_extensions: RecvRtpHeaderExtensions, pub rtp_listener: RtpListener, - pub max_message_size: usize, + pub max_message_size: u32, pub sctp_parameters: Option, pub sctp_state: Option, pub sctp_listener: Option, pub trace_event_types: String, // PipeTransport specific. - pub tuple: Option, + pub tuple: TransportTuple, pub rtx: bool, pub srtp_parameters: Option, } +impl PipeTransportDump { + pub(crate) fn from_fbs(dump: pipe_transport::DumpResponse) -> Result> { + Ok(Self { + // Common to all Transports. + id: dump.base.id.parse()?, + direct: false, + producer_ids: dump + .base + .producer_ids + .iter() + .map(|producer_id| Ok(producer_id.parse()?)) + .collect::>>()?, + consumer_ids: dump + .base + .consumer_ids + .iter() + .map(|consumer_id| Ok(consumer_id.parse()?)) + .collect::>>()?, + map_ssrc_consumer_id: dump + .base + .map_ssrc_consumer_id + .iter() + .map(|key_value| Ok((key_value.key, key_value.value.parse()?))) + .collect::>>()?, + map_rtx_ssrc_consumer_id: dump + .base + .map_rtx_ssrc_consumer_id + .iter() + .map(|key_value| Ok((key_value.key, key_value.value.parse()?))) + .collect::>>()?, + data_producer_ids: dump + .base + .data_producer_ids + .iter() + .map(|data_producer_id| Ok(data_producer_id.parse()?)) + .collect::>>()?, + data_consumer_ids: dump + .base + .data_consumer_ids + .iter() + .map(|data_consumer_id| Ok(data_consumer_id.parse()?)) + .collect::>>()?, + recv_rtp_header_extensions: RecvRtpHeaderExtensions::from_fbs( + dump.base.recv_rtp_header_extensions.as_ref(), + ), + rtp_listener: RtpListener::from_fbs(dump.base.rtp_listener.as_ref())?, + max_message_size: dump.base.max_message_size, + sctp_parameters: dump + .base + .sctp_parameters + .as_ref() + .map(|parameters| SctpParameters::from_fbs(parameters.as_ref())), + sctp_state: dump + .base + .sctp_state + .map(|state| SctpState::from_fbs(&state)), + sctp_listener: dump.base.sctp_listener.as_ref().map(|listener| { + SctpListener::from_fbs(listener.as_ref()).expect("Error parsing SctpListner") + }), + trace_event_types: dump + .base + .trace_event_types + .iter() + .map(|event| event.to_string()) + .collect(), + // PlainTransport specific. + tuple: TransportTuple::from_fbs(dump.tuple.as_ref()), + rtx: dump.rtx, + srtp_parameters: dump + .srtp_parameters + .map(|parameters| SrtpParameters::from_fbs(parameters.as_ref())), + }) + } +} + /// RTC statistics of the pipe transport. #[derive(Debug, Clone, PartialOrd, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -114,32 +191,68 @@ pub struct PipeTransportStat { pub transport_id: TransportId, pub timestamp: u64, pub sctp_state: Option, - pub bytes_received: usize, + pub bytes_received: u64, pub recv_bitrate: u32, - pub bytes_sent: usize, + pub bytes_sent: u64, pub send_bitrate: u32, - pub rtp_bytes_received: usize, + pub rtp_bytes_received: u64, pub rtp_recv_bitrate: u32, - pub rtp_bytes_sent: usize, + pub rtp_bytes_sent: u64, pub rtp_send_bitrate: u32, - pub rtx_bytes_received: usize, + pub rtx_bytes_received: u64, pub rtx_recv_bitrate: u32, - pub rtx_bytes_sent: usize, + pub rtx_bytes_sent: u64, pub rtx_send_bitrate: u32, - pub probation_bytes_sent: usize, + pub probation_bytes_sent: u64, pub probation_send_bitrate: u32, #[serde(skip_serializing_if = "Option::is_none")] pub available_outgoing_bitrate: Option, #[serde(skip_serializing_if = "Option::is_none")] pub available_incoming_bitrate: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub max_incoming_bitrate: Option, + pub max_incoming_bitrate: u32, + pub max_outgoing_bitrate: u32, + pub min_outgoing_bitrate: u32, #[serde(skip_serializing_if = "Option::is_none")] pub rtp_packet_loss_received: Option, #[serde(skip_serializing_if = "Option::is_none")] pub rtp_packet_loss_sent: Option, // PipeTransport specific. - pub tuple: Option, + pub tuple: TransportTuple, +} + +impl PipeTransportStat { + pub(crate) fn from_fbs( + stats: pipe_transport::GetStatsResponse, + ) -> Result> { + Ok(Self { + transport_id: stats.base.transport_id.parse()?, + timestamp: stats.base.timestamp, + sctp_state: stats.base.sctp_state.as_ref().map(SctpState::from_fbs), + bytes_received: stats.base.bytes_received, + recv_bitrate: stats.base.recv_bitrate, + bytes_sent: stats.base.bytes_sent, + send_bitrate: stats.base.send_bitrate, + rtp_bytes_received: stats.base.rtp_bytes_received, + rtp_recv_bitrate: stats.base.rtp_recv_bitrate, + rtp_bytes_sent: stats.base.rtp_bytes_sent, + rtp_send_bitrate: stats.base.rtp_send_bitrate, + rtx_bytes_received: stats.base.rtx_bytes_received, + rtx_recv_bitrate: stats.base.rtx_recv_bitrate, + rtx_bytes_sent: stats.base.rtx_bytes_sent, + rtx_send_bitrate: stats.base.rtx_send_bitrate, + probation_bytes_sent: stats.base.probation_bytes_sent, + probation_send_bitrate: stats.base.probation_send_bitrate, + available_outgoing_bitrate: stats.base.available_outgoing_bitrate, + available_incoming_bitrate: stats.base.available_incoming_bitrate, + max_incoming_bitrate: stats.base.max_incoming_bitrate, + max_outgoing_bitrate: stats.base.max_outgoing_bitrate, + min_outgoing_bitrate: stats.base.min_outgoing_bitrate, + rtp_packet_loss_received: stats.base.rtp_packet_loss_received, + rtp_packet_loss_sent: stats.base.rtp_packet_loss_sent, + // PlainTransport specific. + tuple: TransportTuple::from_fbs(stats.tuple.as_ref()), + }) + } } /// Remote parameters for pipe transport. @@ -214,13 +327,13 @@ impl Inner { if close_request { let channel = self.channel.clone(); let router_id = self.router.id(); - let request = TransportCloseRequest { + let request = TransportCloseRequestFbs { transport_id: self.id, }; self.executor .spawn(async move { - if let Err(error) = channel.request(router_id, request).await { + if let Err(error) = channel.request_fbs(router_id, request).await { error!("transport closing failed on drop: {}", error); } }) @@ -410,28 +523,25 @@ impl TransportGeneric for PipeTransport { async fn dump(&self) -> Result { debug!("dump()"); - todo!(); - /* - serde_json::from_value(self.dump_impl().await?).map_err(|error| { - RequestError::FailedToParse { - error: error.to_string(), - } - }) - */ + if let response::Body::FbsPipeTransportDumpResponse(data) = self.dump_impl().await? { + Ok(PipeTransportDump::from_fbs(*data).expect("Error parsing dump response")) + } else { + panic!("Wrong message from worker"); + } } async fn get_stats(&self) -> Result, RequestError> { debug!("get_stats()"); - todo!(); - - /* - serde_json::from_value(self.get_stats_impl().await?).map_err(|error| { - RequestError::FailedToParse { - error: error.to_string(), - } - }) - */ + if let response::Body::FbsPipeTransportGetStatsResponse(data) = + self.get_stats_impl().await? + { + Ok(vec![ + PipeTransportStat::from_fbs(*data).expect("Error parsing dump response") + ]) + } else { + panic!("Wrong message from worker"); + } } } @@ -550,9 +660,9 @@ impl PipeTransport { let response = self .inner .channel - .request( + .request_fbs( self.id(), - TransportConnectPipeRequest { + PipeTransportConnectRequest { ip: remote_parameters.ip, port: remote_parameters.port, srtp_parameters: remote_parameters.srtp_parameters, diff --git a/worker/fbs/request.fbs b/worker/fbs/request.fbs index 3c76e99ddc..7948723a00 100644 --- a/worker/fbs/request.fbs +++ b/worker/fbs/request.fbs @@ -104,7 +104,7 @@ union Body { FBS.Transport.CloseDataProducerRequest, FBS.Transport.CloseDataConsumerRequest, PlainTransport_ConnectRequest: FBS.PlainTransport.ConnectRequest, - FBS.PipeTransport.ConnectRequest, + PipeTransport_ConnectRequest: FBS.PipeTransport.ConnectRequest, FBS.WebRtcTransport.ConnectRequest, FBS.Producer.EnableTraceEventRequest, FBS.Consumer.SetPreferredLayersRequest, From 27983552f463d8d7e980c7c23a9b30076bdd2533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Mon, 11 Sep 2023 12:34:05 +0200 Subject: [PATCH 19/73] DataChannel subchannels (#1152) --- node/src/DataConsumer.ts | 57 ++++++- node/src/DataProducer.ts | 15 +- node/src/RtpParameters.ts | 24 ++- node/src/Transport.ts | 16 +- node/src/tests/test-DataConsumer.ts | 11 ++ node/src/tests/test-DirectTransport.ts | 147 ++++++++++++++++++ node/src/utils.ts | 23 ++- worker/fbs/dataConsumer.fbs | 9 ++ worker/fbs/dataProducer.fbs | 2 + worker/fbs/request.fbs | 2 + worker/fbs/response.fbs | 1 + worker/fbs/rtpParameters.fbs | 8 +- worker/fbs/transport.fbs | 1 + worker/include/RTC/DataConsumer.hpp | 12 +- worker/include/RTC/DataProducer.hpp | 19 ++- worker/include/RTC/DirectTransport.hpp | 2 +- worker/include/RTC/PipeTransport.hpp | 2 +- worker/include/RTC/PlainTransport.hpp | 2 +- worker/include/RTC/Router.hpp | 9 +- worker/include/RTC/SctpAssociation.hpp | 6 +- worker/include/RTC/Transport.hpp | 22 ++- worker/include/RTC/WebRtcTransport.hpp | 2 +- worker/include/common.hpp | 1 + worker/src/Channel/ChannelRequest.cpp | 1 + worker/src/RTC/DataConsumer.cpp | 97 +++++++++++- worker/src/RTC/DataProducer.cpp | 29 +++- worker/src/RTC/DirectTransport.cpp | 2 +- worker/src/RTC/PipeTransport.cpp | 4 +- worker/src/RTC/PlainTransport.cpp | 4 +- worker/src/RTC/Router.cpp | 8 +- worker/src/RTC/RtpDictionaries/Parameters.cpp | 16 +- worker/src/RTC/SctpAssociation.cpp | 6 +- worker/src/RTC/Transport.cpp | 23 ++- worker/src/RTC/WebRtcTransport.cpp | 4 +- 34 files changed, 494 insertions(+), 93 deletions(-) diff --git a/node/src/DataConsumer.ts b/node/src/DataConsumer.ts index 92dee2141d..87d856e823 100644 --- a/node/src/DataConsumer.ts +++ b/node/src/DataConsumer.ts @@ -8,6 +8,7 @@ import { Event, Notification } from './fbs/notification'; import * as FbsTransport from './fbs/transport'; import * as FbsRequest from './fbs/request'; import * as FbsDataConsumer from './fbs/data-consumer'; +import * as utils from './utils'; export type DataConsumerOptions = { @@ -45,6 +46,13 @@ export type DataConsumerOptions = */ paused?: boolean; + /** + * Subchannels this data consumer initially subscribes to. + * Only used in case this data consumer receives messages from a local data + * producer that specifies subchannel(s) when calling send(). + */ + subchannels?: number[]; + /** * Custom application data. */ @@ -93,6 +101,7 @@ type DataConsumerDump = DataConsumerData & id: string; paused: boolean; dataProducerPaused: boolean; + subchannels: number[]; }; type DataConsumerInternal = TransportInternal & @@ -132,6 +141,9 @@ export class DataConsumer // Associated DataProducer paused flag. #dataProducerPaused = false; + // Subchannels subscribed to. + #subchannels: number[]; + // Custom app data. #appData: DataConsumerAppData; @@ -148,6 +160,7 @@ export class DataConsumer channel, paused, dataProducerPaused, + subchannels, appData }: { @@ -156,6 +169,7 @@ export class DataConsumer channel: Channel; paused: boolean; dataProducerPaused: boolean; + subchannels: number[]; appData?: DataConsumerAppData; } ) @@ -169,6 +183,7 @@ export class DataConsumer this.#channel = channel; this.#paused = paused; this.#dataProducerPaused = dataProducerPaused; + this.#subchannels = subchannels; this.#appData = appData || {} as DataConsumerAppData; this.handleWorkerNotifications(); @@ -246,6 +261,14 @@ export class DataConsumer return this.#dataProducerPaused; } + /** + * Get current subchannels this data consumer is subscribed to. + */ + get subchannels(): number[] + { + return Array.from(this.#subchannels); + } + /** * App custom data. */ @@ -541,6 +564,34 @@ export class DataConsumer return data.bufferedAmount(); } + /** + * Set subchannels. + */ + async setSubchannels(subchannels: number[]): Promise + { + logger.debug('setSubchannels()'); + + /* Build Request. */ + const requestOffset = new FbsDataConsumer.SetSubchannelsRequestT( + subchannels + ).pack(this.#channel.bufferBuilder); + + const response = await this.#channel.request( + FbsRequest.Method.DATACONSUMER_SET_SUBCHANNELS, + FbsRequest.Body.FBS_DataConsumer_SetSubchannelsRequest, + requestOffset, + this.#internal.dataConsumerId + ); + + /* Decode Response. */ + const data = new FbsDataConsumer.SetSubchannelsResponse(); + + response.body(data); + + // Update subchannels. + this.#subchannels = utils.parseVector(data, 'subchannels'); + } + private handleWorkerNotifications(): void { this.#channel.on(this.#internal.dataConsumerId, (event: Event, data?: Notification) => @@ -675,14 +726,14 @@ export function parseDataConsumerDumpResponse( label : data.label()!, protocol : data.protocol()!, paused : data.paused(), - dataProducerPaused : data.dataProducerPaused() - + dataProducerPaused : data.dataProducerPaused(), + subchannels : utils.parseVector(data, 'subchannels') }; } function parseDataConsumerStats( binary: FbsDataConsumer.GetStatsResponse -):DataConsumerStat +): DataConsumerStat { return { type : 'data-consumer', diff --git a/node/src/DataProducer.ts b/node/src/DataProducer.ts index 929856ad1d..467d9ae130 100644 --- a/node/src/DataProducer.ts +++ b/node/src/DataProducer.ts @@ -387,7 +387,12 @@ export class DataProducer /** * Send data (just valid for DataProducers created on a DirectTransport). */ - send(message: string | Buffer, ppid?: number): void + send( + message: string | Buffer, + ppid?: number, + subchannels?: number[], + requiredSubchannel?: number + ): void { if (typeof message !== 'string' && !Buffer.isBuffer(message)) { @@ -431,6 +436,10 @@ export class DataProducer let dataOffset = 0; + const subchannelsOffset = FbsDataProducer.SendNotification.createSubchannelsVector( + builder, subchannels ?? [] + ); + if (typeof message === 'string') { const messageOffset = builder.createString(message); @@ -450,7 +459,9 @@ export class DataProducer typeof message === 'string' ? FbsDataProducer.Data.String : FbsDataProducer.Data.Binary, - dataOffset + dataOffset, + subchannelsOffset, + requiredSubchannel ?? null ); this.#channel.notify( diff --git a/node/src/RtpParameters.ts b/node/src/RtpParameters.ts index f7b7b94554..af9a976da6 100644 --- a/node/src/RtpParameters.ts +++ b/node/src/RtpParameters.ts @@ -2,8 +2,8 @@ import * as flatbuffers from 'flatbuffers'; import { Boolean as FbsBoolean, Double as FbsDouble, - Integer as FbsInteger, - IntegerArray as FbsIntegerArray, + Integer32 as FbsInteger32, + Integer32Array as FbsInteger32Array, String as FbsString, Parameter as FbsParameter, RtcpFeedback as FbsRtcpFeedback, @@ -564,16 +564,15 @@ export function serializeParameters( builder, keyOffset, FbsValue.Boolean, value === true ? 1:0 ); } - else if (typeof value === 'number') { // Integer. if (value % 1 === 0) { - const valueOffset = FbsInteger.createInteger(builder, value); + const valueOffset = FbsInteger32.createInteger32(builder, value); parameterOffset = FbsParameter.createParameter( - builder, keyOffset, FbsValue.Integer, valueOffset + builder, keyOffset, FbsValue.Integer32, valueOffset ); } // Float. @@ -586,7 +585,6 @@ export function serializeParameters( ); } } - else if (typeof value === 'string') { const valueOffset = FbsString.createString(builder, builder.createString(value)); @@ -595,16 +593,14 @@ export function serializeParameters( builder, keyOffset, FbsValue.String, valueOffset ); } - else if (Array.isArray(value)) { - const valueOffset = FbsIntegerArray.createValueVector(builder, value); + const valueOffset = FbsInteger32Array.createValueVector(builder, value); parameterOffset = FbsParameter.createParameter( - builder, keyOffset, FbsValue.IntegerArray, valueOffset + builder, keyOffset, FbsValue.Integer32Array, valueOffset ); } - else { throw new Error(`invalid parameter type [key:'${key}', value:${value}]`); @@ -645,9 +641,9 @@ export function parseParameters(data: any): any break; } - case FbsValue.Integer: + case FbsValue.Integer32: { - const value = new FbsInteger(); + const value = new FbsInteger32(); fbsParameter.value(value); @@ -678,9 +674,9 @@ export function parseParameters(data: any): any break; } - case FbsValue.IntegerArray: + case FbsValue.Integer32Array: { - const value = new FbsIntegerArray(); + const value = new FbsInteger32Array(); fbsParameter.value(value); diff --git a/node/src/Transport.ts b/node/src/Transport.ts index 0d4b237dd6..50e53f1594 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -1080,6 +1080,7 @@ export class Transport maxPacketLifeTime, maxRetransmits, paused = false, + subchannels, appData }: DataConsumerOptions ): Promise> @@ -1163,7 +1164,8 @@ export class Transport sctpStreamParameters, label, protocol, - paused + paused, + subchannels }); const response = await this.channel.request( @@ -1197,6 +1199,7 @@ export class Transport }, channel : this.channel, paused : dump.paused, + subchannels : dump.subchannels, dataProducerPaused : dump.dataProducerPaused, appData }); @@ -1680,9 +1683,10 @@ function createConsumeDataRequest({ sctpStreamParameters, label, protocol, - paused + paused, + subchannels = [] } : { - builder : flatbuffers.Builder; + builder: flatbuffers.Builder; dataConsumerId: string; dataProducerId: string; type: DataConsumerType; @@ -1690,6 +1694,7 @@ function createConsumeDataRequest({ label: string; protocol: string; paused: boolean; + subchannels?: number[]; }): number { const dataConsumerIdOffset = builder.createString(dataConsumerId); @@ -1707,6 +1712,10 @@ function createConsumeDataRequest({ ); } + const subchannelsOffset = FbsTransport.ConsumeDataRequest.createSubchannelsVector( + builder, subchannels + ); + FbsTransport.ConsumeDataRequest.startConsumeDataRequest(builder); FbsTransport.ConsumeDataRequest.addDataConsumerId(builder, dataConsumerIdOffset); FbsTransport.ConsumeDataRequest.addDataProducerId(builder, dataProducerIdOffset); @@ -1722,6 +1731,7 @@ function createConsumeDataRequest({ FbsTransport.ConsumeDataRequest.addLabel(builder, labelOffset); FbsTransport.ConsumeDataRequest.addProtocol(builder, protocolOffset); FbsTransport.ConsumeDataRequest.addPaused(builder, paused); + FbsTransport.ConsumeDataRequest.addSubchannels(builder, subchannelsOffset); return FbsTransport.ConsumeDataRequest.endConsumeDataRequest(builder); } diff --git a/node/src/tests/test-DataConsumer.ts b/node/src/tests/test-DataConsumer.ts index 45973919bd..7f13b1aab8 100644 --- a/node/src/tests/test-DataConsumer.ts +++ b/node/src/tests/test-DataConsumer.ts @@ -53,6 +53,9 @@ test('transport.consumeData() succeeds', async () => { dataProducerId : dataProducer.id, maxPacketLifeTime : 4000, + // Valid values are 0...65535 so others and duplicated ones will be + // discarded. + subchannels : [ 0, 1, 1, 1, 2, 65535, 65536, 65537, 100 ], appData : { baz: 'LOL' } }); @@ -70,6 +73,7 @@ test('transport.consumeData() succeeds', async () => expect(dataConsumer1.label).toBe('foo'); expect(dataConsumer1.protocol).toBe('bar'); expect(dataConsumer1.paused).toBe(false); + expect(dataConsumer1.subchannels.sort((a, b) => a - b)).toEqual([ 0, 1, 2, 100, 65535 ]); expect(dataConsumer1.appData).toEqual({ baz: 'LOL' }); const dump = await router.dump(); @@ -128,6 +132,13 @@ test('dataConsumer.getStats() succeeds', async () => ]); }, 2000); +test('dataConsumer.setSubchannels() succeeds', async () => +{ + await dataConsumer1.setSubchannels([ 999, 999, 998, 65536 ]); + + expect(dataConsumer1.subchannels.sort((a, b) => a - b)).toEqual([ 0, 998, 999 ]); +}, 2000); + test('transport.consumeData() on a DirectTransport succeeds', async () => { const onObserverNewDataConsumer = jest.fn(); diff --git a/node/src/tests/test-DirectTransport.ts b/node/src/tests/test-DirectTransport.ts index f495b4004f..580185d96d 100644 --- a/node/src/tests/test-DirectTransport.ts +++ b/node/src/tests/test-DirectTransport.ts @@ -246,6 +246,153 @@ test('dataProducer.send() succeeds', async () => ]); }, 5000); +test('dataProducer.send() with subchannels succeeds', async () => +{ + const transport2 = await router.createDirectTransport(); + const dataProducer = await transport2.produceData(); + const dataConsumer1 = await transport2.consumeData( + { + dataProducerId : dataProducer.id, + subchannels : [ 1, 11, 666 ] + }); + const dataConsumer2 = await transport2.consumeData( + { + dataProducerId : dataProducer.id, + subchannels : [ 2, 22, 666 ] + }); + const expectedReceivedNumMessages1 = 7; + const expectedReceivedNumMessages2 = 5; + const receivedMessages1: string[] = []; + const receivedMessages2: string[] = []; + + // eslint-disable-next-line no-async-promise-executor + await new Promise(async (resolve) => + { + // Must be received by dataConsumer1 and dataConsumer2. + dataProducer.send( + 'both', + /* ppid */ undefined, + /* subchannels */ undefined, + /* requiredSubchannel */ undefined + ); + + // Must be received by dataConsumer1 and dataConsumer2. + dataProducer.send( + 'both', + /* ppid */ undefined, + /* subchannels */ [ 1, 2 ], + /* requiredSubchannel */ undefined + ); + + // Must be received by dataConsumer1 and dataConsumer2. + dataProducer.send( + 'both', + /* ppid */ undefined, + /* subchannels */ [ 11, 22, 33 ], + /* requiredSubchannel */ 666 + ); + + // Must not be received by neither dataConsumer1 nor dataConsumer2. + dataProducer.send( + 'none', + /* ppid */ undefined, + /* subchannels */ [ 3 ], + /* requiredSubchannel */ 666 + ); + + // Must not be received by neither dataConsumer1 nor dataConsumer2. + dataProducer.send( + 'none', + /* ppid */ undefined, + /* subchannels */ [ 666 ], + /* requiredSubchannel */ 3 + ); + + // Must be received by dataConsumer1. + dataProducer.send( + 'dc1', + /* ppid */ undefined, + /* subchannels */ [ 1 ], + /* requiredSubchannel */ undefined + ); + + // Must be received by dataConsumer1. + dataProducer.send( + 'dc1', + /* ppid */ undefined, + /* subchannels */ [ 11 ], + /* requiredSubchannel */ 1 + ); + + // Must be received by dataConsumer1. + dataProducer.send( + 'dc1', + /* ppid */ undefined, + /* subchannels */ [ 666 ], + /* requiredSubchannel */ 11 + ); + + // Must be received by dataConsumer2. + dataProducer.send( + 'dc2', + /* ppid */ undefined, + /* subchannels */ [ 666 ], + /* requiredSubchannel */ 2 + ); + + // Make dataConsumer2 also subscribe to subchannel 1. + // NOTE: No need to await for this call. + void dataConsumer2.setSubchannels([ ...dataConsumer2.subchannels, 1 ]); + + // Must be received by dataConsumer1 and dataConsumer2. + dataProducer.send( + 'both', + /* ppid */ undefined, + /* subchannels */ [ 1 ], + /* requiredSubchannel */ 666 + ); + + dataConsumer1.on('message', (message) => + { + receivedMessages1.push(message.toString('utf8')); + + if ( + receivedMessages1.length === expectedReceivedNumMessages1 && + receivedMessages2.length === expectedReceivedNumMessages2 + ) + { + resolve(); + } + }); + + dataConsumer2.on('message', (message) => + { + receivedMessages2.push(message.toString('utf8')); + + if ( + receivedMessages1.length === expectedReceivedNumMessages1 && + receivedMessages2.length === expectedReceivedNumMessages2 + ) + { + resolve(); + } + }); + }); + + expect(receivedMessages1.length).toBe(expectedReceivedNumMessages1); + expect(receivedMessages2.length).toBe(expectedReceivedNumMessages2); + + for (const message of receivedMessages1) + { + expect([ 'both', 'dc1' ].includes(message)).toBe(true); + } + + for (const message of receivedMessages2) + { + expect([ 'both', 'dc2' ].includes(message)).toBe(true); + } +}, 5000); + test('DirectTransport methods reject if closed', async () => { const onObserverClose = jest.fn(); diff --git a/node/src/utils.ts b/node/src/utils.ts index 77da462bc3..b67e382acd 100644 --- a/node/src/utils.ts +++ b/node/src/utils.ts @@ -3,16 +3,27 @@ import { ProducerType } from './Producer'; import { Type as FbsRtpParametersType } from './fbs/rtp-parameters'; /** - * Clones the given object/array. + * Clones the given value. */ -export function clone(data: any): any +export function clone(value: T): T { - if (typeof data !== 'object') + if (value === undefined) { - return {}; + return undefined as unknown as T; + } + else if (Number.isNaN(value)) + { + return NaN as unknown as T; + } + else if (typeof structuredClone === 'function') + { + // Available in Node >= 18. + return structuredClone(value); + } + else + { + return JSON.parse(JSON.stringify(value)); } - - return JSON.parse(JSON.stringify(data)); } /** diff --git a/worker/fbs/dataConsumer.fbs b/worker/fbs/dataConsumer.fbs index 54aa7a0904..89e29c6ad2 100644 --- a/worker/fbs/dataConsumer.fbs +++ b/worker/fbs/dataConsumer.fbs @@ -20,6 +20,7 @@ table DumpResponse { protocol:string (required); paused:bool; data_producer_paused:bool; + subchannels:[uint16]; } table GetStatsResponse { @@ -49,6 +50,14 @@ table SendRequest { data:Data (required); } +table SetSubchannelsRequest { + subchannels:[uint16]; +} + +table SetSubchannelsResponse { + subchannels:[uint16]; +} + // Notifications from Worker. table BufferedAmountLowNotification { diff --git a/worker/fbs/dataProducer.fbs b/worker/fbs/dataProducer.fbs index 969939cac9..5815733f28 100644 --- a/worker/fbs/dataProducer.fbs +++ b/worker/fbs/dataProducer.fbs @@ -36,4 +36,6 @@ union Data { table SendNotification { ppid:uint8; data:Data (required); + subchannels:[uint16]; + required_subchannel:uint16 = null; } diff --git a/worker/fbs/request.fbs b/worker/fbs/request.fbs index 7948723a00..ac1ad5fd99 100644 --- a/worker/fbs/request.fbs +++ b/worker/fbs/request.fbs @@ -71,6 +71,7 @@ enum Method: uint8 { DATACONSUMER_GET_BUFFERED_AMOUNT, DATACONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, DATACONSUMER_SEND, + DATACONSUMER_SET_SUBCHANNELS, RTPOBSERVER_PAUSE, RTPOBSERVER_RESUME, RTPOBSERVER_ADD_PRODUCER, @@ -112,6 +113,7 @@ union Body { FBS.Consumer.EnableTraceEventRequest, FBS.DataConsumer.SetBufferedAmountLowThresholdRequest, FBS.DataConsumer.SendRequest, + FBS.DataConsumer.SetSubchannelsRequest, FBS.RtpObserver.AddProducerRequest, FBS.RtpObserver.RemoveProducerRequest, } diff --git a/worker/fbs/response.fbs b/worker/fbs/response.fbs index bd94fbe2db..41e8cbe422 100644 --- a/worker/fbs/response.fbs +++ b/worker/fbs/response.fbs @@ -39,6 +39,7 @@ union Body { FBS_DataConsumer_GetBufferedAmountResponse: FBS.DataConsumer.GetBufferedAmountResponse, FBS_DataConsumer_DumpResponse: FBS.DataConsumer.DumpResponse, FBS_DataConsumer_GetStatsResponse: FBS.DataConsumer.GetStatsResponse, + FBS_DataConsumer_SetSubchannelsResponse: FBS.DataConsumer.SetSubchannelsResponse, } table Response { diff --git a/worker/fbs/rtpParameters.fbs b/worker/fbs/rtpParameters.fbs index 35a5ff84e0..e5e34fca6b 100644 --- a/worker/fbs/rtpParameters.fbs +++ b/worker/fbs/rtpParameters.fbs @@ -9,11 +9,11 @@ table Boolean { value:uint8; } -table Integer { +table Integer32 { value:int32; } -table IntegerArray { +table Integer32Array { value:[int32]; } @@ -27,10 +27,10 @@ table String { union Value { Boolean, - Integer, + Integer32, Double, String, - IntegerArray, + Integer32Array, } table Parameter { diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs index 6e5914f366..5b7af3ef61 100644 --- a/worker/fbs/transport.fbs +++ b/worker/fbs/transport.fbs @@ -72,6 +72,7 @@ table ConsumeDataRequest { label:string; protocol:string; paused:bool = false; + subchannels:[uint16]; } table Tuple { diff --git a/worker/include/RTC/DataConsumer.hpp b/worker/include/RTC/DataConsumer.hpp index 17e0e2c3e5..c7737dbd12 100644 --- a/worker/include/RTC/DataConsumer.hpp +++ b/worker/include/RTC/DataConsumer.hpp @@ -6,6 +6,7 @@ #include "Channel/ChannelSocket.hpp" #include "RTC/SctpDictionaries.hpp" #include "RTC/Shared.hpp" +#include #include namespace RTC @@ -28,9 +29,9 @@ namespace RTC public: virtual void OnDataConsumerSendMessage( RTC::DataConsumer* dataConsumer, - uint32_t ppid, const uint8_t* msg, size_t len, + uint32_t ppid, onQueuedCallback* cb) = 0; virtual void OnDataConsumerDataProducerClosed(RTC::DataConsumer* dataConsumer) = 0; }; @@ -97,7 +98,13 @@ namespace RTC void SctpAssociationBufferedAmount(uint32_t bufferedAmount); void SctpAssociationSendBufferFull(); void DataProducerClosed(); - void SendMessage(uint32_t ppid, const uint8_t* msg, size_t len, onQueuedCallback* = nullptr); + void SendMessage( + const uint8_t* msg, + size_t len, + uint32_t ppid, + std::vector& subchannels, + std::optional requiredSubchannel, + onQueuedCallback* = nullptr); /* Methods inherited from Channel::ChannelSocket::RequestHandler. */ public: @@ -120,6 +127,7 @@ namespace RTC RTC::SctpStreamParameters sctpStreamParameters; std::string label; std::string protocol; + absl::flat_hash_set subchannels; bool transportConnected{ false }; bool sctpAssociationConnected{ false }; bool paused{ false }; diff --git a/worker/include/RTC/DataProducer.hpp b/worker/include/RTC/DataProducer.hpp index cdff1842d5..e024c6b4d3 100644 --- a/worker/include/RTC/DataProducer.hpp +++ b/worker/include/RTC/DataProducer.hpp @@ -8,6 +8,7 @@ #include "RTC/SctpDictionaries.hpp" #include "RTC/Shared.hpp" #include +#include namespace RTC { @@ -23,9 +24,14 @@ namespace RTC public: virtual void OnDataProducerReceiveData(RTC::DataProducer* producer, size_t len) = 0; virtual void OnDataProducerMessageReceived( - RTC::DataProducer* dataProducer, uint32_t ppid, const uint8_t* msg, size_t len) = 0; - virtual void OnDataProducerPaused(RTC::DataProducer* dataProducer) = 0; - virtual void OnDataProducerResumed(RTC::DataProducer* dataProducer) = 0; + RTC::DataProducer* dataProducer, + const uint8_t* msg, + size_t len, + uint32_t ppid, + std::vector& subchannels, + std::optional requiredSubchannel) = 0; + virtual void OnDataProducerPaused(RTC::DataProducer* dataProducer) = 0; + virtual void OnDataProducerResumed(RTC::DataProducer* dataProducer) = 0; }; public: @@ -61,7 +67,12 @@ namespace RTC { return this->paused; } - void ReceiveMessage(uint32_t ppid, const uint8_t* msg, size_t len); + void ReceiveMessage( + const uint8_t* msg, + size_t len, + uint32_t ppid, + std::vector& subchannels, + std::optional requiredSubchannel); /* Methods inherited from Channel::ChannelSocket::RequestHandler. */ public: diff --git a/worker/include/RTC/DirectTransport.hpp b/worker/include/RTC/DirectTransport.hpp index 9b687c6086..7352f0ad75 100644 --- a/worker/include/RTC/DirectTransport.hpp +++ b/worker/include/RTC/DirectTransport.hpp @@ -32,9 +32,9 @@ namespace RTC void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet) override; void SendMessage( RTC::DataConsumer* dataConsumer, - uint32_t ppid, const uint8_t* msg, size_t len, + uint32_t ppid, onQueuedCallback* cb = nullptr) override; void SendSctpData(const uint8_t* data, size_t len) override; void RecvStreamClosed(uint32_t ssrc) override; diff --git a/worker/include/RTC/PipeTransport.hpp b/worker/include/RTC/PipeTransport.hpp index 07ccbc10d5..6a2d803648 100644 --- a/worker/include/RTC/PipeTransport.hpp +++ b/worker/include/RTC/PipeTransport.hpp @@ -50,9 +50,9 @@ namespace RTC void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet) override; void SendMessage( RTC::DataConsumer* dataConsumer, - uint32_t ppid, const uint8_t* msg, size_t len, + uint32_t ppid, onQueuedCallback* cb = nullptr) override; void SendSctpData(const uint8_t* data, size_t len) override; void RecvStreamClosed(uint32_t ssrc) override; diff --git a/worker/include/RTC/PlainTransport.hpp b/worker/include/RTC/PlainTransport.hpp index 202dcc6a21..c0cd6f5901 100644 --- a/worker/include/RTC/PlainTransport.hpp +++ b/worker/include/RTC/PlainTransport.hpp @@ -48,9 +48,9 @@ namespace RTC void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet) override; void SendMessage( RTC::DataConsumer* dataConsumer, - uint32_t ppid, const uint8_t* msg, size_t len, + uint32_t ppid, onQueuedCallback* cb = nullptr) override; void SendSctpData(const uint8_t* data, size_t len) override; void RecvStreamClosed(uint32_t ssrc) override; diff --git a/worker/include/RTC/Router.hpp b/worker/include/RTC/Router.hpp index f74b735aca..46b96f7d65 100644 --- a/worker/include/RTC/Router.hpp +++ b/worker/include/RTC/Router.hpp @@ -15,8 +15,9 @@ #include "RTC/Transport.hpp" #include "RTC/WebRtcServer.hpp" #include +#include #include -#include +#include namespace RTC { @@ -96,9 +97,11 @@ namespace RTC void OnTransportDataProducerMessageReceived( RTC::Transport* transport, RTC::DataProducer* dataProducer, - uint32_t ppid, const uint8_t* msg, - size_t len) override; + size_t len, + uint32_t ppid, + std::vector& subchannels, + std::optional requiredSubchannel) override; void OnTransportNewDataConsumer( RTC::Transport* transport, RTC::DataConsumer* dataConsumer, std::string& dataProducerId) override; void OnTransportDataConsumerClosed(RTC::Transport* transport, RTC::DataConsumer* dataConsumer) override; diff --git a/worker/include/RTC/SctpAssociation.hpp b/worker/include/RTC/SctpAssociation.hpp index 0b52a05ebe..146aca32bd 100644 --- a/worker/include/RTC/SctpAssociation.hpp +++ b/worker/include/RTC/SctpAssociation.hpp @@ -47,9 +47,9 @@ namespace RTC virtual void OnSctpAssociationMessageReceived( RTC::SctpAssociation* sctpAssociation, uint16_t streamId, - uint32_t ppid, const uint8_t* msg, - size_t len) = 0; + size_t len, + uint32_t ppid) = 0; virtual void OnSctpAssociationBufferedAmount( RTC::SctpAssociation* sctpAssociation, uint32_t len) = 0; }; @@ -92,9 +92,9 @@ namespace RTC void ProcessSctpData(const uint8_t* data, size_t len); void SendSctpMessage( RTC::DataConsumer* dataConsumer, - uint32_t ppid, const uint8_t* msg, size_t len, + uint32_t ppid, onQueuedCallback* cb = nullptr); void HandleDataConsumer(RTC::DataConsumer* dataConsumer); void DataProducerClosed(RTC::DataProducer* dataProducer); diff --git a/worker/include/RTC/Transport.hpp b/worker/include/RTC/Transport.hpp index 54c4f95dfe..eb0013677b 100644 --- a/worker/include/RTC/Transport.hpp +++ b/worker/include/RTC/Transport.hpp @@ -30,6 +30,7 @@ #include "handles/TimerHandle.hpp" #include #include +#include namespace RTC { @@ -103,9 +104,11 @@ namespace RTC virtual void OnTransportDataProducerMessageReceived( RTC::Transport* transport, RTC::DataProducer* dataProducer, - uint32_t ppid, const uint8_t* msg, - size_t len) = 0; + size_t len, + uint32_t ppid, + std::vector& subchannels, + std::optional requiredSubchannel) = 0; virtual void OnTransportNewDataConsumer( RTC::Transport* transport, RTC::DataConsumer* dataConsumer, std::string& dataProducerId) = 0; virtual void OnTransportDataConsumerClosed( @@ -188,9 +191,9 @@ namespace RTC virtual void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet) = 0; virtual void SendMessage( RTC::DataConsumer* dataConsumer, - uint32_t ppid, const uint8_t* msg, size_t len, + uint32_t ppid, onQueuedCallback* = nullptr) = 0; virtual void SendSctpData(const uint8_t* data, size_t len) = 0; virtual void RecvStreamClosed(uint32_t ssrc) = 0; @@ -245,7 +248,12 @@ namespace RTC this->DataReceived(len); } void OnDataProducerMessageReceived( - RTC::DataProducer* dataProducer, uint32_t ppid, const uint8_t* msg, size_t len) override; + RTC::DataProducer* dataProducer, + const uint8_t* msg, + size_t len, + uint32_t ppid, + std::vector& subchannels, + std::optional requiredSubchannel) override; void OnDataProducerPaused(RTC::DataProducer* dataProducer) override; void OnDataProducerResumed(RTC::DataProducer* dataProducer) override; @@ -253,9 +261,9 @@ namespace RTC public: void OnDataConsumerSendMessage( RTC::DataConsumer* dataConsumer, - uint32_t ppid, const uint8_t* msg, size_t len, + uint32_t ppid, onQueuedCallback* = nullptr) override; void OnDataConsumerDataProducerClosed(RTC::DataConsumer* dataConsumer) override; @@ -270,9 +278,9 @@ namespace RTC void OnSctpAssociationMessageReceived( RTC::SctpAssociation* sctpAssociation, uint16_t streamId, - uint32_t ppid, const uint8_t* msg, - size_t len) override; + size_t len, + uint32_t ppid) override; void OnSctpAssociationBufferedAmount( RTC::SctpAssociation* sctpAssociation, uint32_t bufferedAmount) override; diff --git a/worker/include/RTC/WebRtcTransport.hpp b/worker/include/RTC/WebRtcTransport.hpp index 2687c4c2d6..e88047980c 100644 --- a/worker/include/RTC/WebRtcTransport.hpp +++ b/worker/include/RTC/WebRtcTransport.hpp @@ -86,9 +86,9 @@ namespace RTC void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet) override; void SendMessage( RTC::DataConsumer* dataConsumer, - uint32_t ppid, const uint8_t* msg, size_t len, + uint32_t ppid, onQueuedCallback* cb = nullptr) override; void SendSctpData(const uint8_t* data, size_t len) override; void RecvStreamClosed(uint32_t ssrc) override; diff --git a/worker/include/common.hpp b/worker/include/common.hpp index 5b1ba0dedd..3934db04b8 100644 --- a/worker/include/common.hpp +++ b/worker/include/common.hpp @@ -7,6 +7,7 @@ #include // uint8_t, etc #include // std::function #include // std::addressof() +#include #ifdef _WIN32 #include // Avoid uv/win.h: error C2628 'intptr_t' followed by 'int' is illegal. diff --git a/worker/src/Channel/ChannelRequest.cpp b/worker/src/Channel/ChannelRequest.cpp index 22ec2d04c9..e69bbb3da7 100644 --- a/worker/src/Channel/ChannelRequest.cpp +++ b/worker/src/Channel/ChannelRequest.cpp @@ -74,6 +74,7 @@ namespace Channel { FBS::Request::Method::DATACONSUMER_GET_BUFFERED_AMOUNT, "dataConsumer.getBufferedAmount" }, { FBS::Request::Method::DATACONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, "dataConsumer.setBufferedAmountLowThreshold" }, { FBS::Request::Method::DATACONSUMER_SEND, "dataConsumer.send" }, + { FBS::Request::Method::DATACONSUMER_SET_SUBCHANNELS, "dataConsumer.setSubchannels" }, { FBS::Request::Method::RTPOBSERVER_PAUSE, "rtpObserver.pause" }, { FBS::Request::Method::RTPOBSERVER_RESUME, "rtpObserver.resume" }, { FBS::Request::Method::RTPOBSERVER_ADD_PRODUCER, "rtpObserver.addProducer" }, diff --git a/worker/src/RTC/DataConsumer.cpp b/worker/src/RTC/DataConsumer.cpp index 6ee9176c25..26e2c2bd70 100644 --- a/worker/src/RTC/DataConsumer.cpp +++ b/worker/src/RTC/DataConsumer.cpp @@ -66,6 +66,11 @@ namespace RTC // paused is set to false by default. this->paused = data->paused(); + for (const auto subchannel : *data->subchannels()) + { + this->subchannels.insert(subchannel); + } + // NOTE: This may throw. this->shared->channelMessageRegistrator->RegisterHandler( this->id, @@ -85,12 +90,21 @@ namespace RTC { MS_TRACE(); - flatbuffers::Offset sctpStreamParametersOffset; + flatbuffers::Offset sctpStreamParameters; // Add sctpStreamParameters. if (this->type == DataConsumer::Type::SCTP) { - sctpStreamParametersOffset = this->sctpStreamParameters.FillBuffer(builder); + sctpStreamParameters = this->sctpStreamParameters.FillBuffer(builder); + } + + std::vector subchannels; + + subchannels.reserve(this->subchannels.size()); + + for (auto subchannel : this->subchannels) + { + subchannels.emplace_back(subchannel); } return FBS::DataConsumer::CreateDumpResponseDirect( @@ -98,11 +112,12 @@ namespace RTC this->id.c_str(), this->dataProducerId.c_str(), this->typeString.c_str(), - sctpStreamParametersOffset, + sctpStreamParameters, this->label.c_str(), this->protocol.c_str(), this->paused, - this->dataProducerPaused); + this->dataProducerPaused, + std::addressof(subchannels)); } flatbuffers::Offset DataConsumer::FillBufferStats( @@ -296,7 +311,38 @@ namespace RTC } }); - SendMessage(ppid, data, len, cb); + static std::vector EmptySubchannels; + + SendMessage(data, len, ppid, EmptySubchannels, std::nullopt, cb); + + break; + } + + case Channel::ChannelRequest::Method::DATACONSUMER_SET_SUBCHANNELS: + { + const auto* body = request->data->body_as(); + + this->subchannels.clear(); + + for (const auto subchannel : *body->subchannels()) + { + this->subchannels.insert(subchannel); + } + + std::vector subchannels; + + subchannels.reserve(this->subchannels.size()); + + for (auto subchannel : this->subchannels) + { + subchannels.emplace_back(subchannel); + } + + // Create response. + auto responseOffset = FBS::DataConsumer::CreateSetSubchannelsResponseDirect( + request->GetBufferBuilder(), std::addressof(subchannels)); + + request->Accept(FBS::Response::Body::FBS_DataConsumer_SetSubchannelsResponse, responseOffset); break; } @@ -431,7 +477,13 @@ namespace RTC this->listener->OnDataConsumerDataProducerClosed(this); } - void DataConsumer::SendMessage(uint32_t ppid, const uint8_t* msg, size_t len, onQueuedCallback* cb) + void DataConsumer::SendMessage( + const uint8_t* msg, + size_t len, + uint32_t ppid, + std::vector& subchannels, + std::optional requiredSubchannel, + onQueuedCallback* cb) { MS_TRACE(); @@ -440,6 +492,37 @@ namespace RTC return; } + // If a required subchannel is given, verify that this data consumer is + // subscribed to it. + if ( + requiredSubchannel.has_value() && + this->subchannels.find(requiredSubchannel.value()) == this->subchannels.end()) + { + return; + } + + // If subchannels are given, verify that this data consumer is subscribed + // to at least one of them. + if (subchannels.size() > 0) + { + bool subchannelMatched{ false }; + + for (const auto subchannel : subchannels) + { + if (this->subchannels.find(subchannel) != this->subchannels.end()) + { + subchannelMatched = true; + + break; + } + } + + if (!subchannelMatched) + { + return; + } + } + if (len > this->maxMessageSize) { MS_WARN_TAG( @@ -454,6 +537,6 @@ namespace RTC this->messagesSent++; this->bytesSent += len; - this->listener->OnDataConsumerSendMessage(this, ppid, msg, len, cb); + this->listener->OnDataConsumerSendMessage(this, msg, len, ppid, cb); } } // namespace RTC diff --git a/worker/src/RTC/DataProducer.cpp b/worker/src/RTC/DataProducer.cpp index 7cae8497c9..dc084ed25a 100644 --- a/worker/src/RTC/DataProducer.cpp +++ b/worker/src/RTC/DataProducer.cpp @@ -7,6 +7,7 @@ #include "MediaSoupErrors.hpp" #include "Utils.hpp" #include +#include namespace RTC { @@ -219,7 +220,23 @@ namespace RTC len); } - this->ReceiveMessage(body->ppid(), data, len); + std::vector subchannels; + + subchannels.reserve(body->subchannels()->size()); + + for (const auto subchannel : *body->subchannels()) + { + subchannels.emplace_back(subchannel); + } + + std::optional requiredSubchannel{ std::nullopt }; + + if (body->requiredSubchannel().has_value()) + { + requiredSubchannel = body->requiredSubchannel().value(); + } + + ReceiveMessage(data, len, body->ppid(), subchannels, requiredSubchannel); // Increase receive transmission. this->listener->OnDataProducerReceiveData(this, len); @@ -234,7 +251,12 @@ namespace RTC } } - void DataProducer::ReceiveMessage(uint32_t ppid, const uint8_t* msg, size_t len) + void DataProducer::ReceiveMessage( + const uint8_t* msg, + size_t len, + uint32_t ppid, + std::vector& subchannels, + std::optional requiredSubchannel) { MS_TRACE(); @@ -247,6 +269,7 @@ namespace RTC return; } - this->listener->OnDataProducerMessageReceived(this, ppid, msg, len); + this->listener->OnDataProducerMessageReceived( + this, msg, len, ppid, subchannels, requiredSubchannel); } } // namespace RTC diff --git a/worker/src/RTC/DirectTransport.cpp b/worker/src/RTC/DirectTransport.cpp index 9078f87daa..4c3f4e108a 100644 --- a/worker/src/RTC/DirectTransport.cpp +++ b/worker/src/RTC/DirectTransport.cpp @@ -213,7 +213,7 @@ namespace RTC } void DirectTransport::SendMessage( - RTC::DataConsumer* dataConsumer, uint32_t ppid, const uint8_t* msg, size_t len, onQueuedCallback* cb) + RTC::DataConsumer* dataConsumer, const uint8_t* msg, size_t len, uint32_t ppid, onQueuedCallback* cb) { MS_TRACE(); diff --git a/worker/src/RTC/PipeTransport.cpp b/worker/src/RTC/PipeTransport.cpp index bfdf7d5585..ea17fe8b3f 100644 --- a/worker/src/RTC/PipeTransport.cpp +++ b/worker/src/RTC/PipeTransport.cpp @@ -541,11 +541,11 @@ namespace RTC } void PipeTransport::SendMessage( - RTC::DataConsumer* dataConsumer, uint32_t ppid, const uint8_t* msg, size_t len, onQueuedCallback* cb) + RTC::DataConsumer* dataConsumer, const uint8_t* msg, size_t len, uint32_t ppid, onQueuedCallback* cb) { MS_TRACE(); - this->sctpAssociation->SendSctpMessage(dataConsumer, ppid, msg, len, cb); + this->sctpAssociation->SendSctpMessage(dataConsumer, msg, len, ppid, cb); } void PipeTransport::SendSctpData(const uint8_t* data, size_t len) diff --git a/worker/src/RTC/PlainTransport.cpp b/worker/src/RTC/PlainTransport.cpp index 9310674bff..224efc4fd2 100644 --- a/worker/src/RTC/PlainTransport.cpp +++ b/worker/src/RTC/PlainTransport.cpp @@ -893,11 +893,11 @@ namespace RTC } void PlainTransport::SendMessage( - RTC::DataConsumer* dataConsumer, uint32_t ppid, const uint8_t* msg, size_t len, onQueuedCallback* cb) + RTC::DataConsumer* dataConsumer, const uint8_t* msg, size_t len, uint32_t ppid, onQueuedCallback* cb) { MS_TRACE(); - this->sctpAssociation->SendSctpMessage(dataConsumer, ppid, msg, len, cb); + this->sctpAssociation->SendSctpMessage(dataConsumer, msg, len,ppid, cb); } void PlainTransport::SendSctpData(const uint8_t* data, size_t len) diff --git a/worker/src/RTC/Router.cpp b/worker/src/RTC/Router.cpp index 117c79b0db..364f9a5393 100644 --- a/worker/src/RTC/Router.cpp +++ b/worker/src/RTC/Router.cpp @@ -883,9 +883,11 @@ namespace RTC inline void Router::OnTransportDataProducerMessageReceived( RTC::Transport* /*transport*/, RTC::DataProducer* dataProducer, - uint32_t ppid, const uint8_t* msg, - size_t len) + size_t len, + uint32_t ppid, + std::vector& subchannels, + std::optional requiredSubchannel) { MS_TRACE(); @@ -893,7 +895,7 @@ namespace RTC for (auto* dataConsumer : dataConsumers) { - dataConsumer->SendMessage(ppid, msg, len); + dataConsumer->SendMessage(msg, len, ppid, subchannels, requiredSubchannel); } } diff --git a/worker/src/RTC/RtpDictionaries/Parameters.cpp b/worker/src/RTC/RtpDictionaries/Parameters.cpp index ab3ee0b776..c6ce8df665 100644 --- a/worker/src/RTC/RtpDictionaries/Parameters.cpp +++ b/worker/src/RTC/RtpDictionaries/Parameters.cpp @@ -36,10 +36,10 @@ namespace RTC case Value::Type::INTEGER: { - auto valueOffset = FBS::RtpParameters::CreateInteger(builder, value.integerValue); + auto valueOffset = FBS::RtpParameters::CreateInteger32(builder, value.integerValue); parameters.emplace_back(FBS::RtpParameters::CreateParameterDirect( - builder, key.c_str(), FBS::RtpParameters::Value::Integer, valueOffset.Union())); + builder, key.c_str(), FBS::RtpParameters::Value::Integer32, valueOffset.Union())); break; } @@ -68,10 +68,10 @@ namespace RTC case Value::Type::ARRAY_OF_INTEGERS: { auto valueOffset = - FBS::RtpParameters::CreateIntegerArrayDirect(builder, &value.arrayOfIntegers); + FBS::RtpParameters::CreateInteger32ArrayDirect(builder, &value.arrayOfIntegers); parameters.emplace_back(FBS::RtpParameters::CreateParameterDirect( - builder, key.c_str(), FBS::RtpParameters::Value::IntegerArray, valueOffset.Union())); + builder, key.c_str(), FBS::RtpParameters::Value::Integer32Array, valueOffset.Union())); break; } @@ -99,9 +99,9 @@ namespace RTC break; } - case FBS::RtpParameters::Value::Integer: + case FBS::RtpParameters::Value::Integer32: { - this->mapKeyValues.emplace(key, Value(parameter->value_as_Integer()->value())); + this->mapKeyValues.emplace(key, Value(parameter->value_as_Integer32()->value())); break; } @@ -120,9 +120,9 @@ namespace RTC break; } - case FBS::RtpParameters::Value::IntegerArray: + case FBS::RtpParameters::Value::Integer32Array: { - this->mapKeyValues.emplace(key, Value(parameter->value_as_IntegerArray()->value())); + this->mapKeyValues.emplace(key, Value(parameter->value_as_Integer32Array()->value())); break; } diff --git a/worker/src/RTC/SctpAssociation.cpp b/worker/src/RTC/SctpAssociation.cpp index 89f9bf525f..13922f00c8 100644 --- a/worker/src/RTC/SctpAssociation.cpp +++ b/worker/src/RTC/SctpAssociation.cpp @@ -376,7 +376,7 @@ namespace RTC } void SctpAssociation::SendSctpMessage( - RTC::DataConsumer* dataConsumer, uint32_t ppid, const uint8_t* msg, size_t len, onQueuedCallback* cb) + RTC::DataConsumer* dataConsumer, const uint8_t* msg, size_t len, uint32_t ppid, onQueuedCallback* cb) { MS_TRACE(); @@ -688,7 +688,7 @@ namespace RTC { MS_DEBUG_DEV("directly notifying listener [eor:1, buffer len:0]"); - this->listener->OnSctpAssociationMessageReceived(this, streamId, ppid, data, len); + this->listener->OnSctpAssociationMessageReceived(this, streamId, data, len, ppid); } // If end of message and there is buffered data, append data and notify buffer. else if (eor && this->messageBufferLen != 0) @@ -699,7 +699,7 @@ namespace RTC MS_DEBUG_DEV("notifying listener [eor:1, buffer len:%zu]", this->messageBufferLen); this->listener->OnSctpAssociationMessageReceived( - this, streamId, ppid, this->messageBuffer, this->messageBufferLen); + this, streamId, this->messageBuffer, this->messageBufferLen, ppid); this->messageBufferLen = 0; } diff --git a/worker/src/RTC/Transport.cpp b/worker/src/RTC/Transport.cpp index 78a4bb42ff..1393ddf15a 100644 --- a/worker/src/RTC/Transport.cpp +++ b/worker/src/RTC/Transport.cpp @@ -2646,11 +2646,17 @@ namespace RTC } inline void Transport::OnDataProducerMessageReceived( - RTC::DataProducer* dataProducer, uint32_t ppid, const uint8_t* msg, size_t len) + RTC::DataProducer* dataProducer, + const uint8_t* msg, + size_t len, + uint32_t ppid, + std::vector& subchannels, + std::optional requiredSubchannel) { MS_TRACE(); - this->listener->OnTransportDataProducerMessageReceived(this, dataProducer, ppid, msg, len); + this->listener->OnTransportDataProducerMessageReceived( + this, dataProducer, msg, len, ppid, subchannels, requiredSubchannel); } inline void Transport::OnDataProducerPaused(RTC::DataProducer* dataProducer) @@ -2668,11 +2674,11 @@ namespace RTC } inline void Transport::OnDataConsumerSendMessage( - RTC::DataConsumer* dataConsumer, uint32_t ppid, const uint8_t* msg, size_t len, onQueuedCallback* cb) + RTC::DataConsumer* dataConsumer, const uint8_t* msg, size_t len, uint32_t ppid, onQueuedCallback* cb) { MS_TRACE(); - SendMessage(dataConsumer, ppid, msg, len, cb); + SendMessage(dataConsumer, msg, len, ppid, cb); } inline void Transport::OnDataConsumerDataProducerClosed(RTC::DataConsumer* dataConsumer) @@ -2811,9 +2817,9 @@ namespace RTC inline void Transport::OnSctpAssociationMessageReceived( RTC::SctpAssociation* /*sctpAssociation*/, uint16_t streamId, - uint32_t ppid, const uint8_t* msg, - size_t len) + size_t len, + uint32_t ppid) { MS_TRACE(); @@ -2830,7 +2836,10 @@ namespace RTC // Pass the SCTP message to the corresponding DataProducer. try { - dataProducer->ReceiveMessage(ppid, msg, len); + static std::vector EmptySubchannels; + + dataProducer->ReceiveMessage( + msg, len, ppid, EmptySubchannels, /*requiredSubchannel*/ std::nullopt); } catch (std::exception& error) { diff --git a/worker/src/RTC/WebRtcTransport.cpp b/worker/src/RTC/WebRtcTransport.cpp index 6491ed6458..f1f083f9d2 100644 --- a/worker/src/RTC/WebRtcTransport.cpp +++ b/worker/src/RTC/WebRtcTransport.cpp @@ -899,11 +899,11 @@ namespace RTC } void WebRtcTransport::SendMessage( - RTC::DataConsumer* dataConsumer, uint32_t ppid, const uint8_t* msg, size_t len, onQueuedCallback* cb) + RTC::DataConsumer* dataConsumer, const uint8_t* msg, size_t len, uint32_t ppid, onQueuedCallback* cb) { MS_TRACE(); - this->sctpAssociation->SendSctpMessage(dataConsumer, ppid, msg, len, cb); + this->sctpAssociation->SendSctpMessage(dataConsumer, msg, len, ppid, cb); } void WebRtcTransport::SendSctpData(const uint8_t* data, size_t len) From 1bebb87d4f8f2e47751db837d132543fa4f4325c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Mon, 11 Sep 2023 12:37:07 +0200 Subject: [PATCH 20/73] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5978d01ad..2619eedf3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Add `ListenInfo` in all transports and send/recv buffer size options ([PR #1084](https://github.com/versatica/mediasoup/pull/1084)). * Add optional `rtcpListenInfo` in `PlainTransportOptions` ([PR #1099](https://github.com/versatica/mediasoup/pull/1099)). * Add pause/resume API in `DataProducer` and `DataConsumer` ([PR #1104](https://github.com/versatica/mediasoup/pull/1104)). +* DataChannel subchannels feature ([PR #1152](https://github.com/versatica/mediasoup/pull/1152)). ### 3.12.12 From 8435d1c68cbe0e61b56c3a1820ffecdd84e48001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Mon, 11 Sep 2023 18:12:04 +0200 Subject: [PATCH 21/73] [flatbuffers] Update rust deps (#1155) --- Cargo.lock | 961 +++++++++++++++++++++---------------- Cargo.toml | 1 + rust/src/rtp_parameters.rs | 9 + 3 files changed, 546 insertions(+), 425 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 99fd4179f0..f2d3f71493 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,13 +4,14 @@ version = 3 [[package]] name = "actix" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f728064aca1c318585bf4bb04ffcfac9e75e508ab4e8b1bd9ba5dfe04e2cbed5" +checksum = "cba56612922b907719d4a01cf11c8d5b458e7d3dba946d0435f20f58d6795ed2" dependencies = [ + "actix-macros", "actix-rt", "actix_derive", - "bitflags", + "bitflags 2.4.0", "bytes", "crossbeam-channel", "futures-core", @@ -23,45 +24,44 @@ dependencies = [ "pin-project-lite", "smallvec", "tokio", - "tokio-util 0.7.0", + "tokio-util", ] [[package]] name = "actix-codec" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a7559404a7f3573127aab53c08ce37a6c6a315c374a31070f3c91cd1b4a7fe" +checksum = "617a8268e3537fe1d8c9ead925fca49ef6400927ee7bc26750e90ecee14ce4b8" dependencies = [ - "bitflags", + "bitflags 1.3.2", "bytes", "futures-core", "futures-sink", - "log", "memchr", "pin-project-lite", "tokio", - "tokio-util 0.7.0", + "tokio-util", + "tracing", ] [[package]] name = "actix-http" -version = "3.2.2" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c83abf9903e1f0ad9973cc4f7b9767fd5a03a583f51a5b7a339e07987cd2724" +checksum = "a92ef85799cba03f76e4f7c10f533e66d87c9a7e7055f3391f09000ad8351bc9" dependencies = [ "actix-codec", "actix-rt", "actix-service", "actix-utils", - "ahash 0.7.6", + "ahash", "base64", - "bitflags", + "bitflags 2.4.0", "bytes", "bytestring", "derive_more", "encoding_rs", "futures-core", - "h2", "http", "httparse", "httpdate", @@ -74,38 +74,39 @@ dependencies = [ "rand", "sha1", "smallvec", + "tokio", + "tokio-util", "tracing", ] [[package]] name = "actix-macros" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" +checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn", + "syn 2.0.32", ] [[package]] name = "actix-router" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb60846b52c118f2f04a56cc90880a274271c489b2498623d58176f8ca21fa80" +checksum = "d66ff4d247d2b160861fa2866457e85706833527840e4133f8f49aa423a38799" dependencies = [ "bytestring", - "firestorm", "http", - "log", "regex", "serde", + "tracing", ] [[package]] name = "actix-rt" -version = "2.6.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf3f2183be1241ed4dd22611850b85d38de0b08a09f1f7bcccbd0809084b359" +checksum = "28f32d40287d3f402ae0028a9d54bef51af15c8769492826a69d28f81893151d" dependencies = [ "futures-core", "tokio", @@ -113,20 +114,19 @@ dependencies = [ [[package]] name = "actix-server" -version = "2.0.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9e7472ac180abb0a8e592b653744345983a7a14f44691c8394a799d0df4dbbf" +checksum = "3eb13e7eef0423ea6eab0e59f6c72e7cb46d33691ad56a726b3cd07ddec2c2d4" dependencies = [ "actix-rt", "actix-service", "actix-utils", "futures-core", "futures-util", - "log", "mio", - "num_cpus", - "socket2", + "socket2 0.5.3", "tokio", + "tracing", ] [[package]] @@ -136,15 +136,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b894941f818cfdc7ccc4b9e60fa7e53b5042a2e8567270f9147d5591893373a" dependencies = [ "futures-core", - "paste 1.0.6", + "paste 1.0.14", "pin-project-lite", ] [[package]] name = "actix-utils" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e491cbaac2e7fc788dfff99ff48ef317e23b3cf63dbaf7aaab6418f40f92aa94" +checksum = "88a1dcdff1466e3c2488e1cb5c36a71822750ad43839937f85d2f4d9f8b705d8" dependencies = [ "local-waker", "pin-project-lite", @@ -152,9 +152,9 @@ dependencies = [ [[package]] name = "actix-web" -version = "4.2.1" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d48f7b6534e06c7bfc72ee91db7917d4af6afe23e7d223b51e68fffbb21e96b9" +checksum = "0e4a5b5e29603ca8c94a77c65cf874718ceb60292c5a5c3e5f4ace041af462b9" dependencies = [ "actix-codec", "actix-http", @@ -165,7 +165,7 @@ dependencies = [ "actix-service", "actix-utils", "actix-web-codegen", - "ahash 0.7.6", + "ahash", "bytes", "bytestring", "cfg-if", @@ -173,7 +173,6 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "http", "itoa", "language-tags", "log", @@ -185,16 +184,16 @@ dependencies = [ "serde_json", "serde_urlencoded", "smallvec", - "socket2", + "socket2 0.5.3", "time", "url", ] [[package]] name = "actix-web-actors" -version = "4.1.0" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31efe7896f3933ce03dd4710be560254272334bb321a18fd8ff62b1a557d9d19" +checksum = "bf6e9ccc371cfddbed7aa842256a4abc7a6dcac9f3fce392fe1d0f68cfd136b2" dependencies = [ "actix", "actix-codec", @@ -205,42 +204,47 @@ dependencies = [ "futures-core", "pin-project-lite", "tokio", + "tokio-util", ] [[package]] name = "actix-web-codegen" -version = "4.1.0" +version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fa9362663c8643d67b2d5eafba49e4cb2c8a053a29ed00a0bea121f17c76b13" +checksum = "eb1f50ebbb30eca122b188319a4398b3f7bb4a8cdf50ecfb73bfc6a3c3ce54f5" dependencies = [ "actix-router", "proc-macro2", "quote", - "syn", + "syn 2.0.32", ] [[package]] name = "actix_derive" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d44b8fee1ced9671ba043476deddef739dd0959bf77030b26b738cc591737a7" +checksum = "7c7db3d5a9718568e4cf4a537cfd7070e6e6ff7481510d0237fb529ac850f6d3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.32", ] [[package]] -name = "ahash" -version = "0.7.6" +name = "addr2line" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ - "getrandom", - "once_cell", - "version_check", + "gimli", ] +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" version = "0.8.3" @@ -248,15 +252,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", + "getrandom", "once_cell", "version_check", ] [[package]] name = "aho-corasick" -version = "0.7.18" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" dependencies = [ "memchr", ] @@ -275,9 +280,9 @@ checksum = "bf7d0a018de4f6aa429b9d33d69edf69072b1c5b1cb8d3e4a5f7ef898fc3eb76" [[package]] name = "async-channel" -version = "1.7.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14485364214912d3b19cc3435dde4df66065127f05fa0d75c712f36f12c2f28" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", "event-listener", @@ -286,46 +291,45 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.4.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" +checksum = "6fa3dc5f2a8564f07759c008b9109dc0d39de92a88d5588b8a5036d286383afb" dependencies = [ + "async-lock", "async-task", "concurrent-queue", "fastrand", "futures-lite", - "once_cell", "slab", ] [[package]] name = "async-io" -version = "1.10.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8121296a9f05be7f34aa4196b1747243b3b62e048bb7906f644f3fbfc490cf7" +checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ "async-lock", "autocfg", + "cfg-if", "concurrent-queue", "futures-lite", - "libc", "log", "parking", "polling", + "rustix", "slab", - "socket2", + "socket2 0.4.9", "waker-fn", - "winapi", ] [[package]] name = "async-lock" -version = "2.6.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ "event-listener", - "futures-lite", ] [[package]] @@ -339,26 +343,26 @@ dependencies = [ [[package]] name = "async-task" -version = "4.1.0" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d306121baf53310a3fd342d88dc0824f6bbeace68347593658525565abee8" +checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae" [[package]] name = "async-trait" -version = "0.1.58" +version = "0.1.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.32", ] [[package]] name = "atomic-take" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9f65e4fb35ff6a80b3298d1f028649f3a23da141fa3951e9b24dde1d515b67e" +checksum = "a8ab6b55fe97976e46f91ddbed8d147d966475dc29b2032757ba47e02376fbc3" [[package]] name = "atty" @@ -366,7 +370,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] @@ -377,11 +381,26 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" -version = "0.13.0" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "bitflags" @@ -389,6 +408,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + [[package]] name = "bitpattern" version = "0.1.0" @@ -402,40 +427,34 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.2" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] [[package]] name = "bumpalo" -version = "3.9.1" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "bytes" -version = "1.1.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "bytestring" -version = "1.0.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90706ba19e97b90786e19dc0d5e2abd80008d99d4c0c5d1ad0b5e72cec7c494d" +checksum = "238e4886760d98c4f899360c834fa93e62cf7f721ac3c2da375cbdf4b8679aae" dependencies = [ "bytes", ] -[[package]] -name = "cache-padded" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" - [[package]] name = "cast" version = "0.3.0" @@ -444,9 +463,12 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.73" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -456,9 +478,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "ciborium" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c137568cc60b904a7724001b35ce2630fd00d5d84805fbb608ab89509d788f" +checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" dependencies = [ "ciborium-io", "ciborium-ll", @@ -467,15 +489,15 @@ dependencies = [ [[package]] name = "ciborium-io" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346de753af073cc87b52b2083a506b38ac176a44cfb05497b622e27be899b369" +checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" [[package]] name = "ciborium-ll" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213030a2b5a4e0c0892b6652260cf6ccac84827b83a85a534e178e3906c4cf1b" +checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" dependencies = [ "ciborium-io", "half", @@ -483,11 +505,11 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.23" +version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ - "bitflags", + "bitflags 1.3.2", "clap_lex", "indexmap", "textwrap", @@ -504,11 +526,11 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "1.2.2" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" +checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" dependencies = [ - "cache-padded", + "crossbeam-utils", ] [[package]] @@ -519,9 +541,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "cpufeatures" -version = "0.2.1" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" dependencies = [ "libc", ] @@ -564,9 +586,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.2" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if", "crossbeam-utils", @@ -574,9 +596,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -585,37 +607,42 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.7" +version = "0.9.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" dependencies = [ + "autocfg", "cfg-if", "crossbeam-utils", - "lazy_static", "memoffset", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.7" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ "cfg-if", - "lazy_static", ] [[package]] name = "crypto-common" -version = "0.1.3" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", "typenum", ] +[[package]] +name = "deranged" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" + [[package]] name = "derive_more" version = "0.99.17" @@ -626,14 +653,14 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn", + "syn 1.0.109", ] [[package]] name = "digest" -version = "0.10.5" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", @@ -641,24 +668,24 @@ dependencies = [ [[package]] name = "either" -version = "1.6.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "encoding_rs" -version = "0.8.30" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" dependencies = [ "cfg-if", ] [[package]] name = "env_logger" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c90bf5f19754d10198ccb95b70664fc925bd1fc090a0fd9a6ebc54acc8cd6272" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" dependencies = [ "atty", "humantime", @@ -667,11 +694,32 @@ dependencies = [ "termcolor", ] +[[package]] +name = "errno" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "event-listener" -version = "2.5.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener-primitives" @@ -686,19 +734,13 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] -[[package]] -name = "firestorm" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d3d6188b8804df28032815ea256b6955c9625c24da7525f387a7af02fbb8f01" - [[package]] name = "fnv" version = "1.0.7" @@ -707,31 +749,30 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.0.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ - "matches", "percent-encoding", ] [[package]] name = "futures-core" -version = "0.3.21" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-io" -version = "0.3.21" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-lite" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" dependencies = [ "fastrand", "futures-core", @@ -753,21 +794,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.21" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.21" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-util" -version = "0.3.21" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-core", "futures-task", @@ -777,9 +818,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.5" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -787,9 +828,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.5" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", @@ -797,23 +838,10 @@ dependencies = [ ] [[package]] -name = "h2" -version = "0.3.11" +name = "gimli" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9f1f717ddc7b2ba36df7e871fd88db79326551d3d6f1fc406fbfd28b582ff8e" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util 0.6.9", - "tracing", -] +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "h264-profile-level-id" @@ -841,9 +869,9 @@ checksum = "74721d007512d0cb3338cd20f0654ac913920061a4c4d0d8708edb3f2a698c0c" [[package]] name = "hashbrown" -version = "0.11.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" @@ -851,7 +879,7 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.3", + "ahash", ] [[package]] @@ -863,11 +891,17 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" + [[package]] name = "http" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", @@ -876,15 +910,15 @@ dependencies = [ [[package]] name = "httparse" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "humantime" @@ -894,23 +928,22 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "idna" -version = "0.2.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ - "matches", "unicode-bidi", "unicode-normalization", ] [[package]] name = "indexmap" -version = "1.8.0" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown 0.11.2", + "hashbrown 0.12.3", ] [[package]] @@ -922,26 +955,37 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi 0.3.2", + "libc", + "windows-sys", +] + [[package]] name = "itertools" -version = "0.10.3" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ "either", ] [[package]] name = "itoa" -version = "1.0.1" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "js-sys" -version = "0.3.56" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" dependencies = [ "wasm-bindgen", ] @@ -960,15 +1004,21 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.119" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "linux-raw-sys" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "local-channel" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6246c68cf195087205a0512559c97e15eaf95198bf0e206d662092cdcb03fe9f" +checksum = "7f303ec0e94c6c54447f84f3b0ef7af769858a9c4ef56ef2a986d3dcd4c3fc9c" dependencies = [ "futures-core", "futures-sink", @@ -978,28 +1028,26 @@ dependencies = [ [[package]] name = "local-waker" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "902eb695eb0591864543cbfbf6d742510642a605a61fc5e97fe6ceb5a30ac4fb" +checksum = "e34f76eb3611940e0e7d53a9aaa4e6a3151f69541a282fd0dad5571420c53ff1" [[package]] name = "lock_api" -version = "0.4.6" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ + "autocfg", "scopeguard", "serde", ] [[package]] name = "log" -version = "0.4.17" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru" @@ -1007,12 +1055,6 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" -[[package]] -name = "matches" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" - [[package]] name = "mediasoup" version = "0.11.4" @@ -1056,45 +1098,44 @@ version = "0.5.4" [[package]] name = "memchr" -version = "2.4.1" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" [[package]] name = "memoffset" -version = "0.6.5" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ "autocfg", ] [[package]] name = "mime" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] -name = "mio" -version = "0.8.0" +name = "miniz_oxide" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ - "libc", - "log", - "miow", - "ntapi", - "winapi", + "adler", ] [[package]] -name = "miow" -version = "0.3.7" +name = "mio" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ - "winapi", + "libc", + "log", + "wasi", + "windows-sys", ] [[package]] @@ -1103,48 +1144,39 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" -[[package]] -name = "ntapi" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" -dependencies = [ - "winapi", -] - [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] [[package]] name = "num_cpus" -version = "1.13.1" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.2", "libc", ] [[package]] -name = "num_threads" -version = "0.1.3" +name = "object" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ba99ba6393e2c3734791401b66902d981cb03bf190af674ca69949b6d5fb15" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ - "libc", + "memchr", ] [[package]] name = "once_cell" -version = "1.16.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "oorandom" @@ -1154,15 +1186,15 @@ checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] name = "os_str_bytes" -version = "6.3.1" +version = "6.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3baf96e39c5359d2eb0dd6ccb42c62b91d9678aa68160d261b9e0ccbf9e9dea9" +checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac" [[package]] name = "parking" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" +checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" [[package]] name = "parking_lot" @@ -1172,7 +1204,7 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core 0.8.5", + "parking_lot_core 0.8.6", ] [[package]] @@ -1182,34 +1214,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.1", + "parking_lot_core 0.9.8", ] [[package]] name = "parking_lot_core" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" dependencies = [ "cfg-if", "instant", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", "winapi", ] [[package]] name = "parking_lot_core" -version = "0.9.1" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.3.5", "smallvec", - "windows-sys", + "windows-targets", ] [[package]] @@ -1224,9 +1256,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.6" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "paste-impl" @@ -1239,15 +1271,15 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.1.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" -version = "0.2.8" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -1267,9 +1299,9 @@ dependencies = [ [[package]] name = "plotters" -version = "0.3.1" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" +checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" dependencies = [ "num-traits", "plotters-backend", @@ -1280,30 +1312,33 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.2" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" +checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" [[package]] name = "plotters-svg" -version = "0.3.1" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" +checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" dependencies = [ "plotters-backend", ] [[package]] name = "polling" -version = "2.2.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685404d509889fade3e86fe3a5803bca2ec09b0c0778d5ada6ec8bf7a8de5259" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ + "autocfg", + "bitflags 1.3.2", "cfg-if", + "concurrent-queue", "libc", "log", - "wepoll-ffi", - "winapi", + "pin-project-lite", + "windows-sys", ] [[package]] @@ -1317,30 +1352,30 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro-hack" -version = "0.5.19" +version = "0.5.20+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" +checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.43" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.15" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -1368,52 +1403,70 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom", ] [[package]] name = "rayon" -version = "1.5.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" dependencies = [ - "autocfg", - "crossbeam-deque", "either", "rayon-core", ] [[package]] name = "rayon-core" -version = "1.9.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" dependencies = [ "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "lazy_static", "num_cpus", ] [[package]] name = "redox_syscall" -version = "0.2.11" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.6.0" +version = "1.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" dependencies = [ "aho-corasick", "memchr", @@ -1422,9 +1475,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc_version" @@ -1435,11 +1494,25 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.37.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", +] + [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "same-file" @@ -1452,41 +1525,41 @@ dependencies = [ [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.6" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a3381e03edd24287172047536f20cabde766e2cd3e65e6b00fb3af51c4f38d" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" [[package]] name = "serde" -version = "1.0.147" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.147" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.32", ] [[package]] name = "serde_json" -version = "1.0.87" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2" dependencies = [ "itoa", "ryu", @@ -1495,13 +1568,13 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.9" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fe39d9fbb0ebf5eb2c7cb7e2a47e4f462fad1379f1166b8ae49ad9eae89a7ca" +checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.32", ] [[package]] @@ -1529,40 +1602,64 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ "libc", ] [[package]] name = "slab" -version = "0.4.5" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] [[package]] name = "smallvec" -version = "1.8.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "socket2" -version = "0.4.4" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi", ] +[[package]] +name = "socket2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +dependencies = [ + "libc", + "windows-sys", +] + [[package]] name = "syn" -version = "1.0.99" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" dependencies = [ "proc-macro2", "quote", @@ -1571,9 +1668,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.3" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ "winapi-util", ] @@ -1586,33 +1683,50 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.32", ] [[package]] name = "time" -version = "0.3.7" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "004cbc98f30fa233c61a38bc77e96a9106e65c88f2d3bef182ae952027e5753d" +checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" dependencies = [ + "deranged", "itoa", - "libc", - "num_threads", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" + +[[package]] +name = "time-macros" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" +dependencies = [ + "time-core", ] [[package]] @@ -1627,70 +1741,55 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" dependencies = [ "tinyvec_macros", ] [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.17.0" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ + "backtrace", "bytes", "libc", - "memchr", "mio", - "once_cell", "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", - "socket2", - "winapi", -] - -[[package]] -name = "tokio-util" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "log", - "pin-project-lite", - "tokio", + "socket2 0.5.3", + "windows-sys", ] [[package]] name = "tokio-util" -version = "0.7.0" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64910e1b9c1901aaf5375561e35b9c057d95ff41a44ede043a03e09279eabaf1" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", "futures-sink", - "log", "pin-project-lite", "tokio", + "tracing", ] [[package]] name = "tracing" -version = "0.1.31" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6c650a8ef0cd2dd93736f033d21cbd1224c5a967aa0c258d00fcf7dafef9b9f" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", @@ -1700,57 +1799,56 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.22" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03cfcb51380632a72d3111cb8d3447a8d908e577d31beeac006f836383d29a23" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] name = "typenum" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "unicode-bidi" -version = "0.3.7" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.3" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-normalization" -version = "0.1.19" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" dependencies = [ "tinyvec", ] [[package]] name = "url" -version = "2.2.2" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna", - "matches", "percent-encoding", ] [[package]] name = "uuid" -version = "1.2.1" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" +checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" dependencies = [ "getrandom", "serde", @@ -1770,26 +1868,25 @@ checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", - "winapi", "winapi-util", ] [[package]] name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.79" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1797,24 +1894,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.79" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", - "lazy_static", "log", + "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.32", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.79" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1822,42 +1919,33 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.79" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.32", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.79" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "web-sys" -version = "0.3.56" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" dependencies = [ "js-sys", "wasm-bindgen", ] -[[package]] -name = "wepoll-ffi" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" -dependencies = [ - "cc", -] - [[package]] name = "winapi" version = "0.3.9" @@ -1891,43 +1979,66 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.32.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", "windows_i686_msvc", "windows_x86_64_gnu", + "windows_x86_64_gnullvm", "windows_x86_64_msvc", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_msvc" -version = "0.32.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" -version = "0.32.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" -version = "0.32.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" -version = "0.32.0" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" -version = "0.32.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" diff --git a/Cargo.toml b/Cargo.toml index efb0f433ee..fac71da63a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" members = [ "rust", "worker" diff --git a/rust/src/rtp_parameters.rs b/rust/src/rtp_parameters.rs index 97e6418129..58eb7ba27b 100644 --- a/rust/src/rtp_parameters.rs +++ b/rust/src/rtp_parameters.rs @@ -704,6 +704,9 @@ pub struct RtpParameters { } impl RtpParameters { + /// TODO: This is not yet used but will be once flatbuffers is fully + /// implemented in mediasoup-rust. + #[allow(dead_code)] pub(crate) fn from_fbs( rtp_parameters: rtp_parameters::RtpParameters, ) -> Result> { @@ -809,6 +812,9 @@ impl RtpParameters { }) } + /// TODO: This is not yet used but will be once flatbuffers is fully + /// implemented in mediasoup-rust. + #[allow(dead_code)] pub(crate) fn into_fbs(self) -> rtp_parameters::RtpParameters { rtp_parameters::RtpParameters { mid: self.mid, @@ -1011,6 +1017,9 @@ impl RtpCodecParameters { *payload_type } + /// NOTE: This is not used in mediasoup code. However there is no reason to + /// not expose it as public API since it could be used by the user. + #[allow(dead_code)] pub(crate) fn clock_rate(&self) -> NonZeroU32 { let (Self::Audio { clock_rate, .. } | Self::Video { clock_rate, .. }) = self; *clock_rate From c680b06addc450a1f4ea70f2562d1c727152b9d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Mon, 11 Sep 2023 18:59:24 +0200 Subject: [PATCH 22/73] Update FBS for Rust As Nazar said, for now the process is manual: 1. In `rust` directory run this: `planus rust -o src/fbs.rs ../worker/fbs/*` 2. Then revert some of the changes at the top of the file to make sure it re-exports things the same way and suppresses clippy warnings in there. 3. For ^ to work you might need to install it first with `cargo install planus-cli` (this will download, compile and install binary in Cargo's directory). --- rust/src/fbs.rs | 1423 ++++++++++++++++++++++++++++++------ rust/src/rtp_parameters.rs | 8 +- 2 files changed, 1211 insertions(+), 220 deletions(-) diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index 655c846729..11b655b8f8 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -12576,10 +12576,10 @@ mod root { } } - /// The table `Integer` in the namespace `FBS.RtpParameters` + /// The table `Integer32` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `Integer` in the file `../worker/fbs/rtpParameters.fbs:12` + /// * Table `Integer32` in the file `../worker/fbs/rtpParameters.fbs:12` #[derive( Clone, Debug, @@ -12591,23 +12591,23 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct Integer { - /// The field `value` in the table `Integer` + pub struct Integer32 { + /// The field `value` in the table `Integer32` pub value: i32, } #[allow(clippy::derivable_impls)] - impl ::core::default::Default for Integer { + impl ::core::default::Default for Integer32 { fn default() -> Self { Self { value: 0 } } } - impl Integer { - /// Creates a [IntegerBuilder] for serializing an instance of this table. + impl Integer32 { + /// Creates a [Integer32Builder] for serializing an instance of this table. #[inline] - pub fn builder() -> IntegerBuilder<()> { - IntegerBuilder(()) + pub fn builder() -> Integer32Builder<()> { + Integer32Builder(()) } #[allow(clippy::too_many_arguments)] @@ -12634,138 +12634,138 @@ mod root { } } - impl ::planus::WriteAs<::planus::Offset> for Integer { + impl ::planus::WriteAs<::planus::Offset> for Integer32 { type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for Integer { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for Integer { + impl ::planus::WriteAsOffset for Integer32 { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Integer::create(builder, self.value) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Integer32::create(builder, self.value) } } - /// Builder for serializing an instance of the [Integer] type. + /// Builder for serializing an instance of the [Integer32] type. /// - /// Can be created using the [Integer::builder] method. + /// Can be created using the [Integer32::builder] method. #[derive(Debug)] #[must_use] - pub struct IntegerBuilder(State); + pub struct Integer32Builder(State); - impl IntegerBuilder<()> { - /// Setter for the [`value` field](Integer#structfield.value). + impl Integer32Builder<()> { + /// Setter for the [`value` field](Integer32#structfield.value). #[inline] #[allow(clippy::type_complexity)] - pub fn value(self, value: T0) -> IntegerBuilder<(T0,)> + pub fn value(self, value: T0) -> Integer32Builder<(T0,)> where T0: ::planus::WriteAsDefault, { - IntegerBuilder((value,)) + Integer32Builder((value,)) } - /// Sets the [`value` field](Integer#structfield.value) to the default value. + /// Sets the [`value` field](Integer32#structfield.value) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn value_as_default(self) -> IntegerBuilder<(::planus::DefaultValue,)> { + pub fn value_as_default(self) -> Integer32Builder<(::planus::DefaultValue,)> { self.value(::planus::DefaultValue) } } - impl IntegerBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Integer]. + 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 + pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } impl> - ::planus::WriteAs<::planus::Offset> for IntegerBuilder<(T0,)> + ::planus::WriteAs<::planus::Offset> for Integer32Builder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } impl> - ::planus::WriteAsOptional<::planus::Offset> for IntegerBuilder<(T0,)> + ::planus::WriteAsOptional<::planus::Offset> for Integer32Builder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl> ::planus::WriteAsOffset - for IntegerBuilder<(T0,)> + impl> ::planus::WriteAsOffset + for Integer32Builder<(T0,)> { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { let (v0,) = &self.0; - Integer::create(builder, v0) + Integer32::create(builder, v0) } } - /// Reference to a deserialized [Integer]. + /// Reference to a deserialized [Integer32]. #[derive(Copy, Clone)] - pub struct IntegerRef<'a>(::planus::table_reader::Table<'a>); + pub struct Integer32Ref<'a>(::planus::table_reader::Table<'a>); - impl<'a> IntegerRef<'a> { - /// Getter for the [`value` field](Integer#structfield.value). + 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, "Integer", "value")?.unwrap_or(0)) + ::core::result::Result::Ok(self.0.access(0, "Integer32", "value")?.unwrap_or(0)) } } - impl<'a> ::core::fmt::Debug for IntegerRef<'a> { + 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("IntegerRef"); + let mut f = f.debug_struct("Integer32Ref"); f.field("value", &self.value()); f.finish() } } - impl<'a> ::core::convert::TryFrom> for Integer { + impl<'a> ::core::convert::TryFrom> for Integer32 { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: IntegerRef<'a>) -> ::planus::Result { + 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 IntegerRef<'a> { + impl<'a> ::planus::TableRead<'a> for Integer32Ref<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -12777,7 +12777,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for IntegerRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for Integer32Ref<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -12787,7 +12787,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[IntegerRef]", + "[Integer32Ref]", "get", buffer.offset_from_start, ) @@ -12795,8 +12795,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for Integer { - type Value = ::planus::Offset; + 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 { @@ -12805,7 +12805,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -12820,7 +12820,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for IntegerRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for Integer32Ref<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -12830,15 +12830,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[IntegerRef]", "read_as_root", 0) + error_kind.with_error_location("[Integer32Ref]", "read_as_root", 0) }) } } - /// The table `IntegerArray` in the namespace `FBS.RtpParameters` + /// The table `Integer32Array` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `IntegerArray` in the file `../worker/fbs/rtpParameters.fbs:16` + /// * Table `Integer32Array` in the file `../worker/fbs/rtpParameters.fbs:16` #[derive( Clone, Debug, @@ -12850,13 +12850,13 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct IntegerArray { - /// The field `value` in the table `IntegerArray` + 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 IntegerArray { + impl ::core::default::Default for Integer32Array { fn default() -> Self { Self { value: ::core::default::Default::default(), @@ -12864,11 +12864,11 @@ mod root { } } - impl IntegerArray { - /// Creates a [IntegerArrayBuilder] for serializing an instance of this table. + impl Integer32Array { + /// Creates a [Integer32ArrayBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> IntegerArrayBuilder<()> { - IntegerArrayBuilder(()) + pub fn builder() -> Integer32ArrayBuilder<()> { + Integer32ArrayBuilder(()) } #[allow(clippy::too_many_arguments)] @@ -12895,140 +12895,141 @@ mod root { } } - impl ::planus::WriteAs<::planus::Offset> for IntegerArray { + impl ::planus::WriteAs<::planus::Offset> for Integer32Array { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for IntegerArray { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for IntegerArray { + impl ::planus::WriteAsOffset for Integer32Array { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - IntegerArray::create(builder, &self.value) + ) -> ::planus::Offset { + Integer32Array::create(builder, &self.value) } } - /// Builder for serializing an instance of the [IntegerArray] type. + /// Builder for serializing an instance of the [Integer32Array] type. /// - /// Can be created using the [IntegerArray::builder] method. + /// Can be created using the [Integer32Array::builder] method. #[derive(Debug)] #[must_use] - pub struct IntegerArrayBuilder(State); + pub struct Integer32ArrayBuilder(State); - impl IntegerArrayBuilder<()> { - /// Setter for the [`value` field](IntegerArray#structfield.value). + impl Integer32ArrayBuilder<()> { + /// Setter for the [`value` field](Integer32Array#structfield.value). #[inline] #[allow(clippy::type_complexity)] - pub fn value(self, value: T0) -> IntegerArrayBuilder<(T0,)> + pub fn value(self, value: T0) -> Integer32ArrayBuilder<(T0,)> where T0: ::planus::WriteAsOptional<::planus::Offset<[i32]>>, { - IntegerArrayBuilder((value,)) + Integer32ArrayBuilder((value,)) } - /// Sets the [`value` field](IntegerArray#structfield.value) to null. + /// Sets the [`value` field](Integer32Array#structfield.value) to null. #[inline] #[allow(clippy::type_complexity)] - pub fn value_as_null(self) -> IntegerArrayBuilder<((),)> { + pub fn value_as_null(self) -> Integer32ArrayBuilder<((),)> { self.value(()) } } - impl IntegerArrayBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [IntegerArray]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } impl>> - ::planus::WriteAs<::planus::Offset> for IntegerArrayBuilder<(T0,)> + ::planus::WriteAs<::planus::Offset> + for Integer32ArrayBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } impl>> - ::planus::WriteAsOptional<::planus::Offset> - for IntegerArrayBuilder<(T0,)> + ::planus::WriteAsOptional<::planus::Offset> + for Integer32ArrayBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } impl>> - ::planus::WriteAsOffset for IntegerArrayBuilder<(T0,)> + ::planus::WriteAsOffset for Integer32ArrayBuilder<(T0,)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { let (v0,) = &self.0; - IntegerArray::create(builder, v0) + Integer32Array::create(builder, v0) } } - /// Reference to a deserialized [IntegerArray]. + /// Reference to a deserialized [Integer32Array]. #[derive(Copy, Clone)] - pub struct IntegerArrayRef<'a>(::planus::table_reader::Table<'a>); + pub struct Integer32ArrayRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> IntegerArrayRef<'a> { - /// Getter for the [`value` field](IntegerArray#structfield.value). + 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, "IntegerArray", "value") + self.0.access(0, "Integer32Array", "value") } } - impl<'a> ::core::fmt::Debug for IntegerArrayRef<'a> { + 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("IntegerArrayRef"); + let mut f = f.debug_struct("Integer32ArrayRef"); if let ::core::option::Option::Some(field_value) = self.value().transpose() { f.field("value", &field_value); } @@ -13036,11 +13037,11 @@ mod root { } } - impl<'a> ::core::convert::TryFrom> for IntegerArray { + impl<'a> ::core::convert::TryFrom> for Integer32Array { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: IntegerArrayRef<'a>) -> ::planus::Result { + 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()?) @@ -13051,7 +13052,7 @@ mod root { } } - impl<'a> ::planus::TableRead<'a> for IntegerArrayRef<'a> { + impl<'a> ::planus::TableRead<'a> for Integer32ArrayRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -13063,7 +13064,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for IntegerArrayRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for Integer32ArrayRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -13073,7 +13074,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[IntegerArrayRef]", + "[Integer32ArrayRef]", "get", buffer.offset_from_start, ) @@ -13081,8 +13082,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for IntegerArray { - type Value = ::planus::Offset; + 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 { @@ -13091,7 +13092,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -13106,7 +13107,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for IntegerArrayRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for Integer32ArrayRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -13116,7 +13117,7 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[IntegerArrayRef]", "read_as_root", 0) + error_kind.with_error_location("[Integer32ArrayRef]", "read_as_root", 0) }) } } @@ -13624,8 +13625,8 @@ mod root { /// The variant of type `Boolean` in the union `Value` Boolean(::planus::alloc::boxed::Box), - /// The variant of type `Integer` in the union `Value` - Integer(::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), @@ -13633,8 +13634,8 @@ mod root { /// The variant of type `String` in the union `Value` String(::planus::alloc::boxed::Box), - /// The variant of type `IntegerArray` in the union `Value` - IntegerArray(::planus::alloc::boxed::Box), + /// The variant of type `Integer32Array` in the union `Value` + Integer32Array(::planus::alloc::boxed::Box), } impl Value { @@ -13653,9 +13654,9 @@ mod root { } #[inline] - pub fn create_integer( + pub fn create_integer32( builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, + value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) } @@ -13677,9 +13678,9 @@ mod root { } #[inline] - pub fn create_integer_array( + pub fn create_integer32_array( builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, + value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) } @@ -13690,10 +13691,10 @@ mod root { fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { match self { Self::Boolean(value) => Self::create_boolean(builder, value), - Self::Integer(value) => Self::create_integer(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::IntegerArray(value) => Self::create_integer_array(builder, value), + Self::Integer32Array(value) => Self::create_integer32_array(builder, value), } } } @@ -13725,11 +13726,11 @@ mod root { ValueBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`Integer` variant](Value#variant.Integer). + /// Creates an instance of the [`Integer32` variant](Value#variant.Integer32). #[inline] - pub fn integer(self, value: T) -> ValueBuilder<::planus::Initialized<2, T>> + pub fn integer32(self, value: T) -> ValueBuilder<::planus::Initialized<2, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { ValueBuilder(::planus::Initialized(value)) } @@ -13752,11 +13753,14 @@ mod root { ValueBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`IntegerArray` variant](Value#variant.IntegerArray). + /// Creates an instance of the [`Integer32Array` variant](Value#variant.Integer32Array). #[inline] - pub fn integer_array(self, value: T) -> ValueBuilder<::planus::Initialized<5, T>> + pub fn integer32_array( + self, + value: T, + ) -> ValueBuilder<::planus::Initialized<5, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { ValueBuilder(::planus::Initialized(value)) } @@ -13797,7 +13801,7 @@ mod root { } impl ::planus::WriteAsUnion for ValueBuilder<::planus::Initialized<2, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -13807,7 +13811,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for ValueBuilder<::planus::Initialized<2, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -13863,7 +13867,7 @@ mod root { } impl ::planus::WriteAsUnion for ValueBuilder<::planus::Initialized<5, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -13873,7 +13877,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for ValueBuilder<::planus::Initialized<5, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -13888,10 +13892,10 @@ mod root { #[derive(Copy, Clone, Debug)] pub enum ValueRef<'a> { Boolean(self::BooleanRef<'a>), - Integer(self::IntegerRef<'a>), + Integer32(self::Integer32Ref<'a>), Double(self::DoubleRef<'a>), String(self::StringRef<'a>), - IntegerArray(self::IntegerArrayRef<'a>), + Integer32Array(self::Integer32ArrayRef<'a>), } impl<'a> ::core::convert::TryFrom> for Value { @@ -13905,8 +13909,8 @@ mod root { )) } - ValueRef::Integer(value) => { - Self::Integer(::planus::alloc::boxed::Box::new( + ValueRef::Integer32(value) => { + Self::Integer32(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -13919,8 +13923,8 @@ mod root { ::core::convert::TryFrom::try_from(value)?, )), - ValueRef::IntegerArray(value) => { - Self::IntegerArray(::planus::alloc::boxed::Box::new( + ValueRef::Integer32Array(value) => { + Self::Integer32Array(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -13938,7 +13942,7 @@ mod root { 1 => ::core::result::Result::Ok(Self::Boolean( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 2 => ::core::result::Result::Ok(Self::Integer( + 2 => ::core::result::Result::Ok(Self::Integer32( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), 3 => ::core::result::Result::Ok(Self::Double( @@ -13947,7 +13951,7 @@ mod root { 4 => ::core::result::Result::Ok(Self::String( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 5 => ::core::result::Result::Ok(Self::IntegerArray( + 5 => ::core::result::Result::Ok(Self::Integer32Array( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), _ => ::core::result::Result::Err( @@ -24549,6 +24553,8 @@ mod root { 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: ::core::option::Option<::planus::alloc::vec::Vec>, } impl DumpResponse { @@ -24571,6 +24577,7 @@ mod root { field_protocol: impl ::planus::WriteAs<::planus::Offset>, field_paused: impl ::planus::WriteAsDefault, field_data_producer_paused: impl ::planus::WriteAsDefault, + field_subchannels: impl ::planus::WriteAsOptional<::planus::Offset<[u16]>>, ) -> ::planus::Offset { let prepared_id = field_id.prepare(builder); let prepared_data_producer_id = field_data_producer_id.prepare(builder); @@ -24582,8 +24589,9 @@ mod root { 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<20> = + 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); @@ -24593,6 +24601,9 @@ mod root { } table_writer.write_entry::<::planus::Offset>(4); table_writer.write_entry::<::planus::Offset>(5); + if prepared_subchannels.is_some() { + table_writer.write_entry::<::planus::Offset<[u16]>>(8); + } if prepared_paused.is_some() { table_writer.write_entry::(6); } @@ -24612,6 +24623,11 @@ mod root { } object_writer.write::<_, _, 4>(&prepared_label); 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_paused) = prepared_paused { object_writer.write::<_, _, 1>(&prepared_paused); } @@ -24666,6 +24682,7 @@ mod root { &self.protocol, self.paused, self.data_producer_paused, + &self.subchannels, ) } } @@ -24824,6 +24841,31 @@ mod root { } impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { + /// Setter for the [`subchannels` field](DumpResponse#structfield.subchannels). + #[inline] + #[allow(clippy::type_complexity)] + pub fn subchannels( + self, + value: T8, + ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> + where + T8: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, + { + let (v0, v1, v2, v3, v4, v5, v6, v7) = self.0; + DumpResponseBuilder((v0, v1, v2, v3, v4, v5, v6, v7, value)) + } + + /// Sets the [`subchannels` field](DumpResponse#structfield.subchannels) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn subchannels_as_null( + self, + ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, ())> { + self.subchannels(()) + } + } + + impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> { /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. #[inline] pub fn finish( @@ -24848,8 +24890,9 @@ mod root { T5: ::planus::WriteAs<::planus::Offset>, T6: ::planus::WriteAsDefault, T7: ::planus::WriteAsDefault, + T8: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, > ::planus::WriteAs<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> { type Prepared = ::planus::Offset; @@ -24873,8 +24916,9 @@ mod root { T5: ::planus::WriteAs<::planus::Offset>, T6: ::planus::WriteAsDefault, T7: ::planus::WriteAsDefault, + T8: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, > ::planus::WriteAsOptional<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> { type Prepared = ::planus::Offset; @@ -24898,16 +24942,17 @@ mod root { T5: ::planus::WriteAs<::planus::Offset>, T6: ::planus::WriteAsDefault, T7: ::planus::WriteAsDefault, + T8: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, > ::planus::WriteAsOffset - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + for DumpResponseBuilder<(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) = &self.0; - DumpResponse::create(builder, v0, v1, v2, v3, v4, v5, v6, v7) + let (v0, v1, v2, v3, v4, v5, v6, v7, v8) = &self.0; + DumpResponse::create(builder, v0, v1, v2, v3, v4, v5, v6, v7, v8) } } @@ -24974,6 +25019,15 @@ mod root { .unwrap_or(false), ) } + + /// Getter for the [`subchannels` field](DumpResponse#structfield.subchannels). + #[inline] + pub fn subchannels( + &self, + ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, u16>>> + { + self.0.access(8, "DumpResponse", "subchannels") + } } impl<'a> ::core::fmt::Debug for DumpResponseRef<'a> { @@ -24991,6 +25045,11 @@ mod root { f.field("protocol", &self.protocol()); f.field("paused", &self.paused()); f.field("data_producer_paused", &self.data_producer_paused()); + if let ::core::option::Option::Some(field_subchannels) = + self.subchannels().transpose() + { + f.field("subchannels", &field_subchannels); + } f.finish() } } @@ -25022,6 +25081,13 @@ mod root { data_producer_paused: ::core::convert::TryInto::try_into( value.data_producer_paused()?, )?, + subchannels: if let ::core::option::Option::Some(subchannels) = + value.subchannels()? + { + ::core::option::Option::Some(subchannels.to_vec()?) + } else { + ::core::option::Option::None + }, }) } } @@ -25099,7 +25165,7 @@ mod root { /// The table `GetStatsResponse` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/dataConsumer.fbs:25` + /// * Table `GetStatsResponse` in the file `../worker/fbs/dataConsumer.fbs:26` #[derive( Clone, Debug, @@ -25608,7 +25674,7 @@ mod root { /// The table `String` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `String` in the file `../worker/fbs/dataConsumer.fbs:34` + /// * Table `String` in the file `../worker/fbs/dataConsumer.fbs:35` #[derive( Clone, Debug, @@ -25849,7 +25915,7 @@ mod root { /// The table `Binary` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `Binary` in the file `../worker/fbs/dataConsumer.fbs:38` + /// * Table `Binary` in the file `../worker/fbs/dataConsumer.fbs:39` #[derive( Clone, Debug, @@ -26090,7 +26156,7 @@ mod root { /// The union `Data` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Union `Data` in the file `../worker/fbs/dataConsumer.fbs:42` + /// * Union `Data` in the file `../worker/fbs/dataConsumer.fbs:43` #[derive( Clone, Debug, @@ -26283,7 +26349,7 @@ mod root { /// The table `SendRequest` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `SendRequest` in the file `../worker/fbs/dataConsumer.fbs:47` + /// * Table `SendRequest` in the file `../worker/fbs/dataConsumer.fbs:48` #[derive( Clone, Debug, @@ -26579,10 +26645,612 @@ mod root { } } + /// The table `SetSubchannelsRequest` in the namespace `FBS.DataConsumer` + /// + /// Generated from these locations: + /// * Table `SetSubchannelsRequest` in the file `../worker/fbs/dataConsumer.fbs:53` + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct SetSubchannelsRequest { + /// The field `subchannels` in the table `SetSubchannelsRequest` + pub subchannels: ::core::option::Option<::planus::alloc::vec::Vec>, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for SetSubchannelsRequest { + fn default() -> Self { + Self { + subchannels: ::core::default::Default::default(), + } + } + } + + 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::WriteAsOptional<::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(); + if prepared_subchannels.is_some() { + table_writer.write_entry::<::planus::Offset<[u16]>>(0); + } + + unsafe { + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_subchannels) = + prepared_subchannels + { + 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::WriteAsOptional<::planus::Offset<[u16]>>, + { + SetSubchannelsRequestBuilder((value,)) + } + + /// Sets the [`subchannels` field](SetSubchannelsRequest#structfield.subchannels) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn subchannels_as_null(self) -> SetSubchannelsRequestBuilder<((),)> { + self.subchannels(()) + } + } + + 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<::core::option::Option<::planus::Vector<'a, u16>>> + { + self.0.access(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"); + if let ::core::option::Option::Some(field_subchannels) = + self.subchannels().transpose() + { + f.field("subchannels", &field_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: 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 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:57` + #[derive( + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, + )] + pub struct SetSubchannelsResponse { + /// The field `subchannels` in the table `SetSubchannelsResponse` + pub subchannels: ::core::option::Option<::planus::alloc::vec::Vec>, + } + + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for SetSubchannelsResponse { + fn default() -> Self { + Self { + subchannels: ::core::default::Default::default(), + } + } + } + + 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::WriteAsOptional<::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(); + if prepared_subchannels.is_some() { + table_writer.write_entry::<::planus::Offset<[u16]>>(0); + } + + unsafe { + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_subchannels) = + prepared_subchannels + { + 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::WriteAsOptional<::planus::Offset<[u16]>>, + { + SetSubchannelsResponseBuilder((value,)) + } + + /// Sets the [`subchannels` field](SetSubchannelsResponse#structfield.subchannels) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn subchannels_as_null(self) -> SetSubchannelsResponseBuilder<((),)> { + self.subchannels(()) + } + } + + 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<::core::option::Option<::planus::Vector<'a, u16>>> + { + self.0.access(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"); + if let ::core::option::Option::Some(field_subchannels) = + self.subchannels().transpose() + { + f.field("subchannels", &field_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: 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 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:54` + /// * Table `BufferedAmountLowNotification` in the file `../worker/fbs/dataConsumer.fbs:63` #[derive( Clone, Debug, @@ -26887,7 +27555,7 @@ mod root { /// The table `MessageNotification` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `MessageNotification` in the file `../worker/fbs/dataConsumer.fbs:58` + /// * Table `MessageNotification` in the file `../worker/fbs/dataConsumer.fbs:67` #[derive( Clone, Debug, @@ -30311,6 +30979,10 @@ mod root { pub ppid: u8, /// The field `data` in the table `SendNotification` pub data: self::Data, + /// 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 { @@ -30325,13 +30997,23 @@ mod root { builder: &mut ::planus::Builder, field_ppid: impl ::planus::WriteAsDefault, field_data: impl ::planus::WriteAsUnion, + 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<10> = + let mut table_writer: ::planus::table_writer::TableWriter<14> = ::core::default::Default::default(); table_writer.write_entry::<::planus::Offset>(2); + if prepared_subchannels.is_some() { + table_writer.write_entry::<::planus::Offset<[u16]>>(3); + } + if prepared_required_subchannel.is_some() { + table_writer.write_entry::(4); + } if prepared_ppid.is_some() { table_writer.write_entry::(0); } @@ -30340,6 +31022,16 @@ mod root { unsafe { table_writer.finish(builder, |object_writer| { object_writer.write::<_, _, 4>(&prepared_data.offset()); + 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); + } if let ::core::option::Option::Some(prepared_ppid) = prepared_ppid { object_writer.write::<_, _, 1>(&prepared_ppid); } @@ -30380,7 +31072,13 @@ mod root { &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - SendNotification::create(builder, self.ppid, &self.data) + SendNotification::create( + builder, + self.ppid, + &self.data, + &self.subchannels, + self.required_subchannel, + ) } } @@ -30424,6 +31122,51 @@ mod root { } 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( @@ -30437,9 +31180,13 @@ mod root { } } - impl, T1: ::planus::WriteAsUnion> - ::planus::WriteAs<::planus::Offset> - for SendNotificationBuilder<(T0, T1)> + impl< + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsUnion, + T2: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, + T3: ::planus::WriteAsOptional, + > ::planus::WriteAs<::planus::Offset> + for SendNotificationBuilder<(T0, T1, T2, T3)> { type Prepared = ::planus::Offset; @@ -30452,9 +31199,13 @@ mod root { } } - impl, T1: ::planus::WriteAsUnion> - ::planus::WriteAsOptional<::planus::Offset> - for SendNotificationBuilder<(T0, T1)> + impl< + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsUnion, + T2: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, + T3: ::planus::WriteAsOptional, + > ::planus::WriteAsOptional<::planus::Offset> + for SendNotificationBuilder<(T0, T1, T2, T3)> { type Prepared = ::planus::Offset; @@ -30467,16 +31218,21 @@ mod root { } } - impl, T1: ::planus::WriteAsUnion> - ::planus::WriteAsOffset for SendNotificationBuilder<(T0, T1)> + impl< + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsUnion, + 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) = &self.0; - SendNotification::create(builder, v0, v1) + let (v0, v1, v2, v3) = &self.0; + SendNotification::create(builder, v0, v1, v2, v3) } } @@ -30498,6 +31254,21 @@ mod root { pub fn data(&self) -> ::planus::Result> { self.0.access_union_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(3, "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(4, "SendNotification", "required_subchannel") + } } impl<'a> ::core::fmt::Debug for SendNotificationRef<'a> { @@ -30505,6 +31276,16 @@ mod root { 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() } } @@ -30517,6 +31298,23 @@ mod root { ::core::result::Result::Ok(Self { ppid: ::core::convert::TryInto::try_into(value.ppid()?)?, data: ::core::convert::TryInto::try_into(value.data()?)?, + 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 + }, }) } } @@ -35250,6 +36048,8 @@ mod root { 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 { @@ -35275,6 +36075,7 @@ mod root { ::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); @@ -35284,8 +36085,9 @@ mod root { 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<18> = + 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); @@ -35299,6 +36101,9 @@ mod root { 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_paused.is_some() { table_writer.write_entry::(6); } @@ -35321,6 +36126,11 @@ mod root { { 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_paused) = prepared_paused { object_writer.write::<_, _, 1>(&prepared_paused); } @@ -35369,6 +36179,7 @@ mod root { &self.label, &self.protocol, self.paused, + &self.subchannels, ) } } @@ -35517,6 +36328,31 @@ mod root { } 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( @@ -35540,8 +36376,9 @@ mod root { 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)> + for ConsumeDataRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { type Prepared = ::planus::Offset; @@ -35564,8 +36401,9 @@ mod root { 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)> + for ConsumeDataRequestBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { type Prepared = ::planus::Offset; @@ -35588,16 +36426,17 @@ mod root { 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)> + 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) = &self.0; - ConsumeDataRequest::create(builder, v0, v1, v2, v3, v4, v5, v6) + let (v0, v1, v2, v3, v4, v5, v6, v7) = &self.0; + ConsumeDataRequest::create(builder, v0, v1, v2, v3, v4, v5, v6, v7) } } @@ -35664,6 +36503,15 @@ mod root { .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> { @@ -35686,6 +36534,11 @@ mod root { 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() } } @@ -35728,6 +36581,13 @@ mod root { ::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 + }, }) } } @@ -35805,7 +36665,7 @@ mod root { /// The table `Tuple` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Tuple` in the file `../worker/fbs/transport.fbs:77` + /// * Table `Tuple` in the file `../worker/fbs/transport.fbs:78` #[derive( Clone, Debug, @@ -36259,7 +37119,7 @@ mod root { /// The table `SrtpParameters` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SrtpParameters` in the file `../worker/fbs/transport.fbs:85` + /// * Table `SrtpParameters` in the file `../worker/fbs/transport.fbs:86` #[derive( Clone, Debug, @@ -36550,7 +37410,7 @@ mod root { /// The table `RtpListener` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `RtpListener` in the file `../worker/fbs/transport.fbs:90` + /// * Table `RtpListener` in the file `../worker/fbs/transport.fbs:91` #[derive( Clone, Debug, @@ -36913,7 +37773,7 @@ mod root { /// The table `SctpListener` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SctpListener` in the file `../worker/fbs/transport.fbs:96` + /// * Table `SctpListener` in the file `../worker/fbs/transport.fbs:97` #[derive( Clone, Debug, @@ -37187,7 +38047,7 @@ mod root { /// The table `RecvRtpHeaderExtensions` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `RecvRtpHeaderExtensions` in the file `../worker/fbs/transport.fbs:100` + /// * Table `RecvRtpHeaderExtensions` in the file `../worker/fbs/transport.fbs:101` #[derive( Clone, Debug, @@ -37710,7 +38570,7 @@ mod root { /// The table `Options` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Options` in the file `../worker/fbs/transport.fbs:108` + /// * Table `Options` in the file `../worker/fbs/transport.fbs:109` #[derive( Clone, Debug, @@ -38391,7 +39251,7 @@ mod root { /// The table `Dump` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Dump` in the file `../worker/fbs/transport.fbs:119` + /// * Table `Dump` in the file `../worker/fbs/transport.fbs:120` #[derive( Clone, Debug, @@ -39428,7 +40288,7 @@ mod root { /// The table `Stats` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Stats` in the file `../worker/fbs/transport.fbs:137` + /// * Table `Stats` in the file `../worker/fbs/transport.fbs:138` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -42065,7 +42925,7 @@ mod root { /// The table `SetMaxIncomingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMaxIncomingBitrateRequest` in the file `../worker/fbs/transport.fbs:164` + /// * Table `SetMaxIncomingBitrateRequest` in the file `../worker/fbs/transport.fbs:165` #[derive( Clone, Debug, @@ -42373,7 +43233,7 @@ mod root { /// The table `SetMaxOutgoingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMaxOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:168` + /// * Table `SetMaxOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:169` #[derive( Clone, Debug, @@ -42681,7 +43541,7 @@ mod root { /// The table `SetMinOutgoingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMinOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:172` + /// * Table `SetMinOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:173` #[derive( Clone, Debug, @@ -42989,7 +43849,7 @@ mod root { /// The table `EnableTraceEventRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/transport.fbs:176` + /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/transport.fbs:177` #[derive( Clone, Debug, @@ -43261,7 +44121,7 @@ mod root { /// The table `CloseProducerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseProducerRequest` in the file `../worker/fbs/transport.fbs:180` + /// * Table `CloseProducerRequest` in the file `../worker/fbs/transport.fbs:181` #[derive( Clone, Debug, @@ -43527,7 +44387,7 @@ mod root { /// The table `CloseConsumerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseConsumerRequest` in the file `../worker/fbs/transport.fbs:184` + /// * Table `CloseConsumerRequest` in the file `../worker/fbs/transport.fbs:185` #[derive( Clone, Debug, @@ -43793,7 +44653,7 @@ mod root { /// The table `CloseDataProducerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseDataProducerRequest` in the file `../worker/fbs/transport.fbs:188` + /// * Table `CloseDataProducerRequest` in the file `../worker/fbs/transport.fbs:189` #[derive( Clone, Debug, @@ -44068,7 +44928,7 @@ mod root { /// The table `CloseDataConsumerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseDataConsumerRequest` in the file `../worker/fbs/transport.fbs:192` + /// * Table `CloseDataConsumerRequest` in the file `../worker/fbs/transport.fbs:193` #[derive( Clone, Debug, @@ -44343,7 +45203,7 @@ mod root { /// The table `SendRtcpNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SendRtcpNotification` in the file `../worker/fbs/transport.fbs:198` + /// * Table `SendRtcpNotification` in the file `../worker/fbs/transport.fbs:199` #[derive( Clone, Debug, @@ -44608,7 +45468,7 @@ mod root { /// The table `SctpStateChangeNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SctpStateChangeNotification` in the file `../worker/fbs/transport.fbs:204` + /// * Table `SctpStateChangeNotification` in the file `../worker/fbs/transport.fbs:205` #[derive( Clone, Debug, @@ -44929,7 +45789,7 @@ mod root { /// The enum `TraceType` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `TraceType` in the file `../worker/fbs/transport.fbs:208` + /// * Enum `TraceType` in the file `../worker/fbs/transport.fbs:209` #[derive( Copy, Clone, @@ -45099,7 +45959,7 @@ mod root { /// The enum `TraceDirection` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `TraceDirection` in the file `../worker/fbs/transport.fbs:210` + /// * Enum `TraceDirection` in the file `../worker/fbs/transport.fbs:211` #[derive( Copy, Clone, @@ -45269,7 +46129,7 @@ mod root { /// The union `TraceInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:212` + /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:213` #[derive( Clone, Debug, @@ -45422,7 +46282,7 @@ mod root { /// The enum `BweType` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:216` + /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:217` #[derive( Copy, Clone, @@ -45592,7 +46452,7 @@ mod root { /// The table `BweTraceInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:218` + /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:219` #[derive( Clone, Debug, @@ -46275,7 +47135,7 @@ mod root { /// The table `TraceNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:229` + /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:230` #[derive( Clone, Debug, @@ -50040,22 +50900,25 @@ mod root { /// 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 = 62, + RtpobserverPause = 63, /// The variant `RTPOBSERVER_RESUME` in the enum `Method` - RtpobserverResume = 63, + RtpobserverResume = 64, /// The variant `RTPOBSERVER_ADD_PRODUCER` in the enum `Method` - RtpobserverAddProducer = 64, + RtpobserverAddProducer = 65, /// The variant `RTPOBSERVER_REMOVE_PRODUCER` in the enum `Method` - RtpobserverRemoveProducer = 65, + RtpobserverRemoveProducer = 66, } impl Method { /// Array containing all valid variants of Method - pub const ENUM_VALUES: [Self; 66] = [ + pub const ENUM_VALUES: [Self; 67] = [ Self::WorkerClose, Self::WorkerDump, Self::WorkerGetResourceUsage, @@ -50118,6 +50981,7 @@ mod root { Self::DataconsumerGetBufferedAmount, Self::DataconsumerSetBufferedAmountLowThreshold, Self::DataconsumerSend, + Self::DataconsumerSetSubchannels, Self::RtpobserverPause, Self::RtpobserverResume, Self::RtpobserverAddProducer, @@ -50200,10 +51064,11 @@ mod root { Method::DataconsumerSetBufferedAmountLowThreshold, ), 61 => ::core::result::Result::Ok(Method::DataconsumerSend), - 62 => ::core::result::Result::Ok(Method::RtpobserverPause), - 63 => ::core::result::Result::Ok(Method::RtpobserverResume), - 64 => ::core::result::Result::Ok(Method::RtpobserverAddProducer), - 65 => ::core::result::Result::Ok(Method::RtpobserverRemoveProducer), + 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, @@ -50336,7 +51201,7 @@ mod root { /// The union `Body` in the namespace `FBS.Request` /// /// Generated from these locations: - /// * Union `Body` in the file `../worker/fbs/request.fbs:80` + /// * Union `Body` in the file `../worker/fbs/request.fbs:81` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -50495,6 +51360,11 @@ mod root { /// The variant of type `FBS.DataConsumer.SendRequest` in the union `Body` SendRequest(::planus::alloc::boxed::Box), + /// The variant of type `FBS.DataConsumer.SetSubchannelsRequest` in the union `Body` + SetSubchannelsRequest( + ::planus::alloc::boxed::Box, + ), + /// The variant of type `FBS.RtpObserver.AddProducerRequest` in the union `Body` AddProducerRequest( ::planus::alloc::boxed::Box, @@ -50773,12 +51643,20 @@ mod root { ::planus::UnionOffset::new(32, value.prepare(builder).downcast()) } + #[inline] + pub fn create_set_subchannels_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(33, value.prepare(builder).downcast()) + } + #[inline] pub fn create_add_producer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(33, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(34, value.prepare(builder).downcast()) } #[inline] @@ -50786,7 +51664,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(34, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(35, value.prepare(builder).downcast()) } } @@ -50882,6 +51760,9 @@ mod root { Self::create_set_buffered_amount_low_threshold_request(builder, value) } Self::SendRequest(value) => Self::create_send_request(builder, value), + Self::SetSubchannelsRequest(value) => { + Self::create_set_subchannels_request(builder, value) + } Self::AddProducerRequest(value) => { Self::create_add_producer_request(builder, value) } @@ -51293,12 +52174,24 @@ mod root { BodyBuilder(::planus::Initialized(value)) } + /// Creates an instance of the [`SetSubchannelsRequest` variant](Body#variant.SetSubchannelsRequest). + #[inline] + pub fn set_subchannels_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<33, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + /// Creates an instance of the [`AddProducerRequest` variant](Body#variant.AddProducerRequest). #[inline] pub fn add_producer_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<33, T>> + ) -> BodyBuilder<::planus::Initialized<34, T>> where T: ::planus::WriteAsOffset, { @@ -51310,7 +52203,7 @@ mod root { pub fn remove_producer_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<34, T>> + ) -> BodyBuilder<::planus::Initialized<35, T>> where T: ::planus::WriteAsOffset, { @@ -52039,7 +52932,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<33, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -52049,7 +52942,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<33, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -52061,7 +52954,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<34, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -52070,6 +52963,28 @@ mod root { } 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, { @@ -52123,6 +53038,7 @@ mod root { super::data_consumer::SetBufferedAmountLowThresholdRequestRef<'a>, ), SendRequest(super::data_consumer::SendRequestRef<'a>), + SetSubchannelsRequest(super::data_consumer::SetSubchannelsRequestRef<'a>), AddProducerRequest(super::rtp_observer::AddProducerRequestRef<'a>), RemoveProducerRequest(super::rtp_observer::RemoveProducerRequestRef<'a>), } @@ -52328,6 +53244,12 @@ mod root { )) } + BodyRef::SetSubchannelsRequest(value) => { + Self::SetSubchannelsRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + BodyRef::AddProducerRequest(value) => { Self::AddProducerRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, @@ -52448,10 +53370,13 @@ mod root { 32 => ::core::result::Result::Ok(Self::SendRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 33 => ::core::result::Result::Ok(Self::AddProducerRequest( + 33 => ::core::result::Result::Ok(Self::SetSubchannelsRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 34 => ::core::result::Result::Ok(Self::AddProducerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 34 => ::core::result::Result::Ok(Self::RemoveProducerRequest( + 35 => ::core::result::Result::Ok(Self::RemoveProducerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), _ => ::core::result::Result::Err( @@ -52464,7 +53389,7 @@ mod root { /// The table `Request` in the namespace `FBS.Request` /// /// Generated from these locations: - /// * Table `Request` in the file `../worker/fbs/request.fbs:119` + /// * Table `Request` in the file `../worker/fbs/request.fbs:121` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -52987,6 +53912,11 @@ mod root { FbsDataConsumerGetStatsResponse( ::planus::alloc::boxed::Box, ), + + /// The variant `FBS_DataConsumer_SetSubchannelsResponse` in the union `Body` + FbsDataConsumerSetSubchannelsResponse( + ::planus::alloc::boxed::Box, + ), } impl Body { @@ -53227,6 +54157,14 @@ mod root { ) -> ::planus::UnionOffset { ::planus::UnionOffset::new(29, value.prepare(builder).downcast()) } + + #[inline] + pub fn create_fbs_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 { @@ -53322,6 +54260,9 @@ mod root { Self::FbsDataConsumerGetStatsResponse(value) => { Self::create_fbs_data_consumer_get_stats_response(builder, value) } + Self::FbsDataConsumerSetSubchannelsResponse(value) => { + Self::create_fbs_data_consumer_set_subchannels_response(builder, value) + } } } } @@ -53691,6 +54632,18 @@ mod root { { BodyBuilder(::planus::Initialized(value)) } + + /// Creates an instance of the [`FBS_DataConsumer_SetSubchannelsResponse` variant](Body#variant.FbsDataConsumerSetSubchannelsResponse). + #[inline] + pub fn fbs_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> { @@ -54342,6 +55295,28 @@ mod root { ::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)] @@ -54383,6 +55358,9 @@ mod root { ), FbsDataConsumerDumpResponse(super::data_consumer::DumpResponseRef<'a>), FbsDataConsumerGetStatsResponse(super::data_consumer::GetStatsResponseRef<'a>), + FbsDataConsumerSetSubchannelsResponse( + super::data_consumer::SetSubchannelsResponseRef<'a>, + ), } impl<'a> ::core::convert::TryFrom> for Body { @@ -54579,6 +55557,14 @@ mod root { ::core::convert::TryFrom::try_from(value)?, )) } + + BodyRef::FbsDataConsumerSetSubchannelsResponse(value) => { + Self::FbsDataConsumerSetSubchannelsResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } }) } } @@ -54681,6 +55667,11 @@ mod root { 29 => ::core::result::Result::Ok(Self::FbsDataConsumerGetStatsResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), + 30 => { + ::core::result::Result::Ok(Self::FbsDataConsumerSetSubchannelsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )) + } _ => ::core::result::Result::Err( ::planus::errors::ErrorKind::UnknownUnionTag { tag }, ), @@ -54691,7 +55682,7 @@ mod root { /// The table `Response` in the namespace `FBS.Response` /// /// Generated from these locations: - /// * Table `Response` in the file `../worker/fbs/response.fbs:44` + /// * Table `Response` in the file `../worker/fbs/response.fbs:45` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] diff --git a/rust/src/rtp_parameters.rs b/rust/src/rtp_parameters.rs index 58eb7ba27b..db0f6a8dc4 100644 --- a/rust/src/rtp_parameters.rs +++ b/rust/src/rtp_parameters.rs @@ -726,12 +726,12 @@ impl RtpParameters { match parameters.value { rtp_parameters::Value::Boolean(_) | rtp_parameters::Value::Double(_) - | rtp_parameters::Value::IntegerArray(_) => { + | rtp_parameters::Value::Integer32Array(_) => { // TODO: Above value variant should not exist in the // first place panic!("Invalid parameter") } - rtp_parameters::Value::Integer(n) => { + rtp_parameters::Value::Integer32(n) => { RtpCodecParametersParametersValue::Number( n.value.try_into()?, ) @@ -844,8 +844,8 @@ impl RtpParameters { )) } RtpCodecParametersParametersValue::Number(n) => { - rtp_parameters::Value::Integer(Box::new( - rtp_parameters::Integer { value: *n as i32 }, + rtp_parameters::Value::Integer32(Box::new( + rtp_parameters::Integer32 { value: *n as i32 }, )) } }, From 6f128215a91ecfc8d272f199d7c81b4ae7c18eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Tue, 12 Sep 2023 14:07:44 +0200 Subject: [PATCH 23/73] cosmetic: add blank line --- rust/src/router/webrtc_transport.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rust/src/router/webrtc_transport.rs b/rust/src/router/webrtc_transport.rs index 928647f2d0..954b24ef81 100644 --- a/rust/src/router/webrtc_transport.rs +++ b/rust/src/router/webrtc_transport.rs @@ -518,6 +518,7 @@ impl TransportGeneric for WebRtcTransport { debug!("dump()"); todo!(); + /* serde_json::from_value(self.dump_impl().await?).map_err(|error| { RequestError::FailedToParse { From 0f137a747361f3490a28f542acadc0c8fe53e96b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Wed, 13 Sep 2023 13:20:02 +0200 Subject: [PATCH 24/73] fbs: FBS WebRtcTransport (#1153) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fbs: FBS WebRtcTransport --------- Co-authored-by: Iñaki Baz Castillo --- node/src/Router.ts | 3 +- node/src/SrtpParameters.ts | 51 +- node/src/Transport.ts | 2 +- node/src/WebRtcTransport.ts | 170 +- node/src/ortc.ts | 11 +- node/src/tests/test-WebRtcTransport.ts | 6 + rust/crypto_suite_fbs.patch | 53 + rust/src/data_structures.rs | 203 +- rust/src/fbs.rs | 35036 ++++++++++--------- rust/src/messages.rs | 226 +- rust/src/router.rs | 15 +- rust/src/router/direct_transport.rs | 6 +- rust/src/router/pipe_transport.rs | 6 +- rust/src/router/plain_transport.rs | 6 +- rust/src/router/webrtc_transport.rs | 194 +- rust/src/srtp_parameters.rs | 56 +- rust/tests/integration/webrtc_transport.rs | 49 +- worker/fbs/pipeTransport.fbs | 7 +- worker/fbs/plainTransport.fbs | 9 +- worker/fbs/request.fbs | 2 +- worker/fbs/srtpParameters.fbs | 15 + worker/fbs/transport.fbs | 17 +- worker/fbs/webRtcTransport.fbs | 57 +- worker/include/RTC/DtlsTransport.hpp | 42 +- worker/include/RTC/IceCandidate.hpp | 6 + worker/include/RTC/IceServer.hpp | 7 +- worker/include/RTC/PlainTransport.hpp | 4 - worker/include/RTC/SrtpSession.hpp | 6 +- worker/src/Channel/ChannelSocket.cpp | 16 +- worker/src/RTC/DtlsTransport.cpp | 173 +- worker/src/RTC/IceCandidate.cpp | 65 +- worker/src/RTC/IceServer.cpp | 37 + worker/src/RTC/PipeTransport.cpp | 11 +- worker/src/RTC/PlainTransport.cpp | 161 +- worker/src/RTC/SrtpSession.cpp | 36 + worker/src/RTC/Transport.cpp | 22 +- worker/src/RTC/WebRtcTransport.cpp | 169 +- 37 files changed, 19479 insertions(+), 17476 deletions(-) create mode 100644 rust/crypto_suite_fbs.patch create mode 100644 worker/fbs/srtpParameters.fbs diff --git a/node/src/Router.ts b/node/src/Router.ts index 2aca8a0c7d..7c3ceff247 100644 --- a/node/src/Router.ts +++ b/node/src/Router.ts @@ -24,6 +24,7 @@ import { AudioLevelObserver, AudioLevelObserverOptions } from './AudioLevelObser import { RtpCapabilities, RtpCodecCapability } from './RtpParameters'; import { NumSctpStreams } from './SctpParameters'; import { AppData, Either } from './types'; +import { cryptoSuiteToFbs } from './SrtpParameters'; import * as FbsActiveSpeakerObserver from './fbs/active-speaker-observer'; import * as FbsAudioLevelObserver from './fbs/audio-level-observer'; import * as FbsRequest from './fbs/request'; @@ -710,7 +711,7 @@ export class Router rtcpMux, comedia, enableSrtp, - srtpCryptoSuite + cryptoSuiteToFbs(srtpCryptoSuite) ); const requestOffset = new FbsRouter.CreatePlainTransportRequestT( diff --git a/node/src/SrtpParameters.ts b/node/src/SrtpParameters.ts index 412c4c6ec9..8049964512 100644 --- a/node/src/SrtpParameters.ts +++ b/node/src/SrtpParameters.ts @@ -1,5 +1,5 @@ import * as flatbuffers from 'flatbuffers'; -import * as FbsTransport from './fbs/transport'; +import * as FbsSrtpParameters from './fbs/srtp-parameters'; /** * SRTP parameters. @@ -26,10 +26,50 @@ export type SrtpCryptoSuite = | 'AES_CM_128_HMAC_SHA1_80' | 'AES_CM_128_HMAC_SHA1_32'; -export function parseSrtpParameters(binary: FbsTransport.SrtpParameters): SrtpParameters +export function cryptoSuiteFromFbs(binary: FbsSrtpParameters.SrtpCryptoSuite): SrtpCryptoSuite +{ + switch (binary) + { + case FbsSrtpParameters.SrtpCryptoSuite.AEAD_AES_256_GCM: + return 'AEAD_AES_256_GCM'; + + case FbsSrtpParameters.SrtpCryptoSuite.AEAD_AES_128_GCM: + return 'AEAD_AES_128_GCM'; + + case FbsSrtpParameters.SrtpCryptoSuite.AES_CM_128_HMAC_SHA1_80: + return 'AES_CM_128_HMAC_SHA1_80'; + + case FbsSrtpParameters.SrtpCryptoSuite.AES_CM_128_HMAC_SHA1_32: + return 'AES_CM_128_HMAC_SHA1_32'; + } +} + +export function cryptoSuiteToFbs(cryptoSuite: SrtpCryptoSuite) + : FbsSrtpParameters.SrtpCryptoSuite +{ + switch (cryptoSuite) + { + case 'AEAD_AES_256_GCM': + return FbsSrtpParameters.SrtpCryptoSuite.AEAD_AES_256_GCM; + + case 'AEAD_AES_128_GCM': + return FbsSrtpParameters.SrtpCryptoSuite.AEAD_AES_128_GCM; + + case 'AES_CM_128_HMAC_SHA1_80': + return FbsSrtpParameters.SrtpCryptoSuite.AES_CM_128_HMAC_SHA1_80; + + case 'AES_CM_128_HMAC_SHA1_32': + return FbsSrtpParameters.SrtpCryptoSuite.AES_CM_128_HMAC_SHA1_32; + + default: + throw new TypeError(`invalid srtp crypto suite: ${cryptoSuite}`); + } +} + +export function parseSrtpParameters(binary: FbsSrtpParameters.SrtpParameters): SrtpParameters { return { - cryptoSuite : binary.cryptoSuite()! as SrtpCryptoSuite, + cryptoSuite : cryptoSuiteFromFbs(binary.cryptoSuite()), keyBase64 : binary.keyBase64()! }; } @@ -38,10 +78,9 @@ export function serializeSrtpParameters( builder:flatbuffers.Builder, srtpParameters:SrtpParameters ): number { - const cryptoSuiteOffset = builder.createString(srtpParameters.cryptoSuite); const keyBase64Offset = builder.createString(srtpParameters.keyBase64); - return FbsTransport.SrtpParameters.createSrtpParameters( - builder, cryptoSuiteOffset, keyBase64Offset + return FbsSrtpParameters.SrtpParameters.createSrtpParameters( + builder, cryptoSuiteToFbs(srtpParameters.cryptoSuite), keyBase64Offset ); } diff --git a/node/src/Transport.ts b/node/src/Transport.ts index 50e53f1594..39e5686d85 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -1113,7 +1113,7 @@ export class Transport { type = 'sctp'; sctpStreamParameters = - utils.clone(dataProducer.sctpStreamParameters) as SctpStreamParameters; + (utils.clone(dataProducer.sctpStreamParameters) ?? {}) as SctpStreamParameters; // Override if given. if (ordered !== undefined) diff --git a/node/src/WebRtcTransport.ts b/node/src/WebRtcTransport.ts index 3b619c0c3c..719e657026 100644 --- a/node/src/WebRtcTransport.ts +++ b/node/src/WebRtcTransport.ts @@ -28,7 +28,12 @@ import * as FbsRequest from './fbs/request'; import * as FbsTransport from './fbs/transport'; import * as FbsWebRtcTransport from './fbs/web-rtc-transport'; import { DtlsState as FbsDtlsState } from './fbs/web-rtc-transport/dtls-state'; +import { DtlsRole as FbsDtlsRole } from './fbs/web-rtc-transport/dtls-role'; +import { FingerprintAlgorithm as FbsFingerprintAlgorithm } from './fbs/web-rtc-transport/fingerprint-algorithm'; import { IceState as FbsIceState } from './fbs/web-rtc-transport/ice-state'; +import { IceRole as FbsIceRole } from './fbs/web-rtc-transport/ice-role'; +import { IceCandidateType as FbsIceCandidateType } from './fbs/web-rtc-transport/ice-candidate-type'; +import { IceCandidateTcpType as FbsIceCandidateTcpType } from './fbs/web-rtc-transport/ice-candidate-tcp-type'; export type WebRtcTransportOptions = WebRtcTransportOptionsBase & WebRtcTransportListen; @@ -142,8 +147,8 @@ export type IceCandidate = ip: string; protocol: TransportProtocol; port: number; - type: 'host'; - tcpType: 'passive' | undefined; + type: IceCandidateType; + tcpType?: IceCandidateTcpType; }; export type DtlsParameters = @@ -154,18 +159,29 @@ export type DtlsParameters = /** * The hash function algorithm (as defined in the "Hash function Textual Names" - * registry initially specified in RFC 4572 Section 8) and its corresponding - * certificate fingerprint value (in lowercase hex string as expressed utilizing - * the syntax of "fingerprint" in RFC 4572 Section 5). + * registry initially specified in RFC 4572 Section 8). + */ +export type FingerprintAlgorithm = 'sha-1'| 'sha-224'| 'sha-256'| 'sha-384'| 'sha-512'; + +/** + * The hash function algorithm and its corresponding certificate fingerprint + * value (in lowercase hex string as expressed utilizing the syntax of + * "fingerprint" in RFC 4572 Section 5). */ export type DtlsFingerprint = { - algorithm: string; + algorithm: FingerprintAlgorithm; value: string; }; +export type IceRole = 'controlled' | 'controlling'; + export type IceState = 'new' | 'connected' | 'completed' | 'disconnected' | 'closed'; +export type IceCandidateType = 'host'; + +export type IceCandidateTcpType = 'passive'; + export type DtlsRole = 'auto' | 'client' | 'server'; export type DtlsState = 'new' | 'connecting' | 'connected' | 'failed' | 'closed'; @@ -479,7 +495,7 @@ export class WebRtcTransport // Wait for response. const response = await this.channel.request( FbsRequest.Method.WEBRTCTRANSPORT_CONNECT, - FbsRequest.Body.FBS_WebRtcTransport_ConnectRequest, + FbsRequest.Body.WebRtcTransport_ConnectRequest, requestOffset, this.internal.transportId ); @@ -490,8 +506,7 @@ export class WebRtcTransport response.body(data); // Update data. - this.#data.dtlsParameters.role = - data.dtlsLocalRole()! as DtlsRole; + this.#data.dtlsParameters.role = dtlsRoleFromFbs(data.dtlsLocalRole()); } /** @@ -537,7 +552,7 @@ export class WebRtcTransport data!.body(notification); - const iceState = fbsIceState2IceState(notification.iceState()); + const iceState = iceStateFromFbs(notification.iceState()); this.#data.iceState = iceState; @@ -574,7 +589,7 @@ export class WebRtcTransport data!.body(notification); - const dtlsState = fbsDtlsState2DtlsState(notification.dtlsState()); + const dtlsState = dtlsStateFromFbs(notification.dtlsState()); this.#data.dtlsState = dtlsState; @@ -634,7 +649,7 @@ export class WebRtcTransport } } -export function fbsIceState2IceState(fbsIceState: FbsIceState): IceState +function iceStateFromFbs(fbsIceState: FbsIceState): IceState { switch (fbsIceState) { @@ -646,14 +661,39 @@ export function fbsIceState2IceState(fbsIceState: FbsIceState): IceState return 'completed'; case FbsIceState.DISCONNECTED: return 'disconnected'; - case FbsIceState.CLOSED: - return 'closed'; - default: - throw new TypeError(`invalid SctpState: ${fbsIceState}`); } } -export function fbsDtlsState2DtlsState(fbsDtlsState: FbsDtlsState): DtlsState +function iceRoleFromFbs(role: FbsIceRole): IceRole +{ + switch (role) + { + case FbsIceRole.CONTROLLED: + return 'controlled'; + case FbsIceRole.CONTROLLING: + return 'controlling'; + } +} + +function iceCandidateTypeFromFbs(type: FbsIceCandidateType): IceCandidateType +{ + switch (type) + { + case FbsIceCandidateType.HOST: + return 'host'; + } +} + +function iceCandidateTcpTypeFromFbs(type: FbsIceCandidateTcpType): IceCandidateTcpType +{ + switch (type) + { + case FbsIceCandidateTcpType.PASSIVE: + return 'passive'; + } +} + +function dtlsStateFromFbs(fbsDtlsState: FbsDtlsState): DtlsState { switch (fbsDtlsState) { @@ -667,8 +707,72 @@ export function fbsDtlsState2DtlsState(fbsDtlsState: FbsDtlsState): DtlsState return 'failed'; case FbsDtlsState.CLOSED: return 'closed'; + } +} + +function dtlsRoleFromFbs(role: FbsDtlsRole): DtlsRole +{ + switch (role) + { + case FbsDtlsRole.AUTO: + return 'auto'; + case FbsDtlsRole.CLIENT: + return 'client'; + case FbsDtlsRole.SERVER: + return 'server'; + } +} + +function fingerprintAlgorithmsFromFbs(algorithm: FbsFingerprintAlgorithm) + : FingerprintAlgorithm +{ + switch (algorithm) + { + case FbsFingerprintAlgorithm.SHA1: + return 'sha-1'; + case FbsFingerprintAlgorithm.SHA224: + return 'sha-224'; + case FbsFingerprintAlgorithm.SHA256: + return 'sha-256'; + case FbsFingerprintAlgorithm.SHA384: + return 'sha-384'; + case FbsFingerprintAlgorithm.SHA512: + return 'sha-512'; + } +} + +function fingerprintAlgorithmToFbs(algorithm: FingerprintAlgorithm) + : FbsFingerprintAlgorithm +{ + switch (algorithm) + { + case 'sha-1': + return FbsFingerprintAlgorithm.SHA1; + case 'sha-224': + return FbsFingerprintAlgorithm.SHA224; + case 'sha-256': + return FbsFingerprintAlgorithm.SHA256; + case 'sha-384': + return FbsFingerprintAlgorithm.SHA384; + case 'sha-512': + return FbsFingerprintAlgorithm.SHA512; + default: + throw new TypeError(`invalid fingerprint algorithm: ${algorithm}`); + } +} + +function dtlsRoleToFbs(role: DtlsRole): FbsDtlsRole +{ + switch (role) + { + case 'auto': + return FbsDtlsRole.AUTO; + case 'client': + return FbsDtlsRole.CLIENT; + case 'server': + return FbsDtlsRole.SERVER; default: - throw new TypeError(`invalid SctpState: ${fbsDtlsState}`); + throw new TypeError(`invalid dtls role: ${role}`); } } @@ -692,9 +796,9 @@ export function parseWebRtcTransportDumpResponse( iceRole : 'controlled', iceParameters : iceParameters, iceCandidates : iceCandidates, - iceState : binary.iceState() as IceState, + iceState : iceStateFromFbs(binary.iceState()), dtlsParameters : dtlsParameters, - dtlsState : binary.dtlsState() as DtlsState + dtlsState : dtlsStateFromFbs(binary.dtlsState()) }; } @@ -727,12 +831,12 @@ function parseGetStatsResponse( return { ...base, type : 'webrtc-transport', - iceRole : binary.iceRole()!, - iceState : binary.iceState() as IceState, + iceRole : iceRoleFromFbs(binary.iceRole()), + iceState : iceStateFromFbs(binary.iceState()), iceSelectedTuple : binary.iceSelectedTuple() ? parseTuple(binary.iceSelectedTuple()!) : undefined, - dtlsState : binary.dtlsState() as DtlsState + dtlsState : dtlsStateFromFbs(binary.dtlsState()) }; } @@ -744,8 +848,10 @@ function parseIceCandidate(binary: FbsWebRtcTransport.IceCandidate): IceCandidat ip : binary.ip()!, protocol : parseProtocol(binary.protocol()), port : binary.port(), - type : 'host', - tcpType : binary.tcpType() === 'passive' ? 'passive' : undefined + type : iceCandidateTypeFromFbs(binary.type()), + tcpType : binary.tcpType() === null ? + undefined : + iceCandidateTcpTypeFromFbs(binary.tcpType()!) }; } @@ -767,7 +873,7 @@ function parseDtlsParameters(binary: FbsWebRtcTransport.DtlsParameters): DtlsPar const fbsFingerprint = binary.fingerprints(i)!; const fingerPrint : DtlsFingerprint = { - algorithm : fbsFingerprint.algorithm()!, + algorithm : fingerprintAlgorithmsFromFbs(fbsFingerprint.algorithm()), value : fbsFingerprint.value()! }; @@ -776,7 +882,7 @@ function parseDtlsParameters(binary: FbsWebRtcTransport.DtlsParameters): DtlsPar return { fingerprints : fingerprints, - role : binary.role()! as DtlsRole + role : binary.role() === null? undefined : dtlsRoleFromFbs(binary.role()!) }; } @@ -788,20 +894,22 @@ function serializeDtlsParameters( for (const fingerprint of dtlsParameters.fingerprints) { - const algorithmOffset = builder.createString(fingerprint.algorithm); + const algorithm = fingerprintAlgorithmToFbs(fingerprint.algorithm); const valueOffset = builder.createString(fingerprint.value); const fingerprintOffset = FbsWebRtcTransport.Fingerprint.createFingerprint( - builder, algorithmOffset, valueOffset); + builder, algorithm, valueOffset); fingerprints.push(fingerprintOffset); } const fingerprintsOffset = FbsWebRtcTransport.DtlsParameters.createFingerprintsVector( builder, fingerprints); - const roleOffset = builder.createString(dtlsParameters.role); + const role = dtlsParameters.role !== undefined ? + dtlsRoleToFbs(dtlsParameters.role) : + FbsWebRtcTransport.DtlsRole.AUTO; return FbsWebRtcTransport.DtlsParameters.createDtlsParameters( builder, fingerprintsOffset, - roleOffset); + role); } diff --git a/node/src/ortc.ts b/node/src/ortc.ts index b12b8c4e1b..ee0ef59324 100644 --- a/node/src/ortc.ts +++ b/node/src/ortc.ts @@ -1042,7 +1042,8 @@ export function getConsumableRtpParameters( } // Clone Producer encodings since we'll mangle them. - const consumableEncodings = utils.clone(params.encodings) as RtpEncodingParameters[]; + const consumableEncodings = + (utils.clone(params.encodings) ?? []) as RtpEncodingParameters[]; for (let i = 0; i < consumableEncodings.length; ++i) { @@ -1140,7 +1141,7 @@ export function getConsumerRtpParameters( } const consumableCodecs = - utils.clone(consumableRtpParameters.codecs) as RtpCodecParameters[]; + (utils.clone(consumableRtpParameters.codecs) ?? []) as RtpCodecParameters[]; let rtxSupported = false; @@ -1295,7 +1296,7 @@ export function getConsumerRtpParameters( else { const consumableEncodings = - utils.clone(consumableRtpParameters.encodings) as RtpEncodingParameters[]; + (utils.clone(consumableRtpParameters.encodings) ?? []) as RtpEncodingParameters[]; const baseSsrc = utils.generateRandomNumber(); const baseRtxSsrc = utils.generateRandomNumber(); @@ -1347,7 +1348,7 @@ export function getPipeConsumerRtpParameters( }; const consumableCodecs = - utils.clone(consumableRtpParameters.codecs) as RtpCodecParameters[]; + (utils.clone(consumableRtpParameters.codecs) ?? []) as RtpCodecParameters[]; for (const codec of consumableCodecs) { @@ -1375,7 +1376,7 @@ export function getPipeConsumerRtpParameters( )); const consumableEncodings = - utils.clone(consumableRtpParameters.encodings) as RtpEncodingParameters[]; + (utils.clone(consumableRtpParameters.encodings) ?? []) as RtpEncodingParameters[]; const baseSsrc = utils.generateRandomNumber(); const baseRtxSsrc = utils.generateRandomNumber(); diff --git a/node/src/tests/test-WebRtcTransport.ts b/node/src/tests/test-WebRtcTransport.ts index fd4df0dae8..7381610d32 100644 --- a/node/src/tests/test-WebRtcTransport.ts +++ b/node/src/tests/test-WebRtcTransport.ts @@ -292,6 +292,11 @@ test('webRtcTransport.connect() succeeds', async () => expect(transport.dtlsParameters.role).toBe('server'); }, 2000); +/** + * When are we going to rely on the type system in the API? + * We are testing invalid type values which adds extra checks in the code that should be + * simply guarded by the type system. + */ test('webRtcTransport.connect() with wrong arguments rejects with TypeError', async () => { let dtlsRemoteParameters: mediasoup.types.DtlsParameters; @@ -306,6 +311,7 @@ test('webRtcTransport.connect() with wrong arguments rejects with TypeError', as fingerprints : [ { + // @ts-ignore. algorithm : 'sha-256000', value : '82:5A:68:3D:36:C3:0A:DE:AF:E7:32:43:D2:88:83:57:AC:2D:65:E5:80:C4:B6:FB:AF:1A:A0:21:9F:6D:0C:AD' } diff --git a/rust/crypto_suite_fbs.patch b/rust/crypto_suite_fbs.patch new file mode 100644 index 0000000000..0fe4a70870 --- /dev/null +++ b/rust/crypto_suite_fbs.patch @@ -0,0 +1,53 @@ +diff --git a/worker/src/RTC/SrtpSession.cpp b/worker/src/RTC/SrtpSession.cpp +index 97051e0cf..d87f03ae4 100644 +--- a/worker/src/RTC/SrtpSession.cpp ++++ b/worker/src/RTC/SrtpSession.cpp +@@ -1,3 +1,4 @@ ++#include "FBS/srtpParameters_generated.h" + #define MS_CLASS "RTC::SrtpSession" + // #define MS_LOG_DEV_LEVEL 3 + +@@ -28,6 +29,43 @@ namespace RTC + } + } + ++ FBS::SrtpParameters::SrtpCryptoSuite SrtpSession::CryptoSuiteToFbs(CryptoSuite cryptoSuite) ++ { ++ switch (cryptoSuite) ++ { ++ case SrtpSession::CryptoSuite::AEAD_AES_256_GCM: ++ return FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_256_GCM; ++ ++ case SrtpSession::CryptoSuite::AEAD_AES_128_GCM: ++ return FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_128_GCM; ++ ++ case SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_80: ++ return FBS::SrtpParameters::SrtpCryptoSuite::AES_CM_128_HMAC_SHA1_80; ++ ++ case SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_32: ++ return FBS::SrtpParameters::SrtpCryptoSuite::AES_CM_128_HMAC_SHA1_32; ++ } ++ } ++ ++ SrtpSession::CryptoSuite SrtpSession::CryptoSuiteFromFbs(FBS::SrtpParameters::SrtpCryptoSuite cryptoSuite) ++ { ++ switch (cryptoSuite) ++ { ++ case FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_256_GCM: ++ return SrtpSession::CryptoSuite::AEAD_AES_256_GCM; ++ ++ case FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_128_GCM: ++ return SrtpSession::CryptoSuite::AEAD_AES_128_GCM; ++ ++ case FBS::SrtpParameters::SrtpCryptoSuite::AES_CM_128_HMAC_SHA1_80: ++ return SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_80; ++ ++ case FBS::SrtpParameters::SrtpCryptoSuite::AES_CM_128_HMAC_SHA1_32: ++ return SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_32; ++ } ++ ++ } ++ + void SrtpSession::OnSrtpEvent(srtp_event_data_t* data) + { + MS_TRACE(); diff --git a/rust/src/data_structures.rs b/rust/src/data_structures.rs index eafd39039a..375f233964 100644 --- a/rust/src/data_structures.rs +++ b/rust/src/data_structures.rs @@ -3,7 +3,7 @@ #[cfg(test)] mod tests; -use crate::fbs::{sctp_association, transport}; +use crate::fbs::{sctp_association, transport, web_rtc_transport}; use serde::de::{MapAccess, Visitor}; use serde::ser::SerializeStruct; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; @@ -96,6 +96,15 @@ pub enum IceRole { Controlling, } +impl IceRole { + pub(crate) fn from_fbs(role: web_rtc_transport::IceRole) -> Self { + match role { + web_rtc_transport::IceRole::Controlled => IceRole::Controlled, + web_rtc_transport::IceRole::Controlling => IceRole::Controlling, + } + } +} + /// ICE parameters. #[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -108,6 +117,16 @@ pub struct IceParameters { pub ice_lite: Option, } +impl IceParameters { + pub(crate) fn from_fbs(parameters: web_rtc_transport::IceParameters) -> Self { + Self { + username_fragment: parameters.username_fragment.to_string(), + password: parameters.password.to_string(), + ice_lite: Some(parameters.ice_lite), + } + } +} + /// ICE candidate type. #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] @@ -128,6 +147,14 @@ pub enum IceCandidateType { Relay, } +impl IceCandidateType { + pub(crate) fn from_fbs(candidate_type: web_rtc_transport::IceCandidateType) -> Self { + match candidate_type { + web_rtc_transport::IceCandidateType::Host => IceCandidateType::Host, + } + } +} + /// ICE candidate TCP type (always `Passive`). #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] @@ -136,6 +163,14 @@ pub enum IceCandidateTcpType { Passive, } +impl IceCandidateTcpType { + pub(crate) fn from_fbs(candidate_type: web_rtc_transport::IceCandidateTcpType) -> Self { + match candidate_type { + web_rtc_transport::IceCandidateTcpType::Passive => IceCandidateTcpType::Passive, + } + } +} + /// Transport protocol. #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] @@ -177,6 +212,20 @@ pub struct IceCandidate { pub tcp_type: Option, } +impl IceCandidate { + pub(crate) fn from_fbs(candidate: &web_rtc_transport::IceCandidate) -> Self { + Self { + foundation: candidate.foundation.clone(), + priority: candidate.priority, + ip: candidate.ip.parse().expect("Error parsing IP address"), + protocol: Protocol::from_fbs(candidate.protocol), + port: candidate.port, + r#type: IceCandidateType::from_fbs(candidate.type_), + tcp_type: candidate.tcp_type.map(IceCandidateTcpType::from_fbs), + } + } +} + /// ICE state. #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -192,8 +241,17 @@ pub enum IceState { /// ICE was `Connected` or `Completed` but it has suddenly failed (this can just happen if the /// selected tuple has `Tcp` protocol). Disconnected, - /// ICE state when the transport has been closed. - Closed, +} + +impl IceState { + pub(crate) fn from_fbs(state: web_rtc_transport::IceState) -> Self { + match state { + web_rtc_transport::IceState::New => IceState::New, + web_rtc_transport::IceState::Connected => IceState::Connected, + web_rtc_transport::IceState::Completed => IceState::Completed, + web_rtc_transport::IceState::Disconnected => IceState::Disconnected, + } + } } /// Tuple of local IP/port/protocol + optional remote IP/port. @@ -309,6 +367,18 @@ pub enum DtlsState { Closed, } +impl DtlsState { + pub(crate) fn from_fbs(state: web_rtc_transport::DtlsState) -> Self { + match state { + web_rtc_transport::DtlsState::New => DtlsState::New, + web_rtc_transport::DtlsState::Connecting => DtlsState::Connecting, + web_rtc_transport::DtlsState::Connected => DtlsState::Connected, + web_rtc_transport::DtlsState::Failed => DtlsState::Failed, + web_rtc_transport::DtlsState::Closed => DtlsState::Closed, + } + } +} + /// SCTP state. #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -351,6 +421,24 @@ pub enum DtlsRole { Server, } +impl DtlsRole { + pub(crate) fn to_fbs(self) -> web_rtc_transport::DtlsRole { + match self { + DtlsRole::Auto => web_rtc_transport::DtlsRole::Auto, + DtlsRole::Client => web_rtc_transport::DtlsRole::Client, + DtlsRole::Server => web_rtc_transport::DtlsRole::Server, + } + } + + pub(crate) fn from_fbs(role: web_rtc_transport::DtlsRole) -> Self { + match role { + web_rtc_transport::DtlsRole::Auto => DtlsRole::Auto, + web_rtc_transport::DtlsRole::Client => DtlsRole::Client, + web_rtc_transport::DtlsRole::Server => DtlsRole::Server, + } + } +} + impl Default for DtlsRole { fn default() -> Self { Self::Auto @@ -389,6 +477,91 @@ pub enum DtlsFingerprint { }, } +fn hex_as_bytes(input: &str, output: &mut [u8]) { + for (i, o) in input.split(':').zip(&mut output.iter_mut()) { + *o = u8::from_str_radix(i, 16).unwrap_or_else(|error| { + panic!("Failed to parse value {i} as series of hex bytes: {error}") + }); + } +} + +impl DtlsFingerprint { + pub(crate) fn to_fbs(self) -> web_rtc_transport::Fingerprint { + match self { + DtlsFingerprint::Sha1 { .. } => web_rtc_transport::Fingerprint { + algorithm: web_rtc_transport::FingerprintAlgorithm::Sha1, + value: self.value_string(), + }, + DtlsFingerprint::Sha224 { .. } => web_rtc_transport::Fingerprint { + algorithm: web_rtc_transport::FingerprintAlgorithm::Sha224, + value: self.value_string(), + }, + DtlsFingerprint::Sha256 { .. } => web_rtc_transport::Fingerprint { + algorithm: web_rtc_transport::FingerprintAlgorithm::Sha256, + value: self.value_string(), + }, + DtlsFingerprint::Sha384 { .. } => web_rtc_transport::Fingerprint { + algorithm: web_rtc_transport::FingerprintAlgorithm::Sha384, + value: self.value_string(), + }, + DtlsFingerprint::Sha512 { .. } => web_rtc_transport::Fingerprint { + algorithm: web_rtc_transport::FingerprintAlgorithm::Sha512, + value: self.value_string(), + }, + } + } + + pub(crate) fn from_fbs(fingerprint: &web_rtc_transport::Fingerprint) -> DtlsFingerprint { + match fingerprint.algorithm { + web_rtc_transport::FingerprintAlgorithm::Sha1 => { + let mut value_result = [0_u8; 20]; + + hex_as_bytes(fingerprint.value.as_str(), &mut value_result); + + DtlsFingerprint::Sha1 { + value: value_result, + } + } + web_rtc_transport::FingerprintAlgorithm::Sha224 => { + let mut value_result = [0_u8; 28]; + + hex_as_bytes(fingerprint.value.as_str(), &mut value_result); + + DtlsFingerprint::Sha224 { + value: value_result, + } + } + web_rtc_transport::FingerprintAlgorithm::Sha256 => { + let mut value_result = [0_u8; 32]; + + hex_as_bytes(fingerprint.value.as_str(), &mut value_result); + + DtlsFingerprint::Sha256 { + value: value_result, + } + } + web_rtc_transport::FingerprintAlgorithm::Sha384 => { + let mut value_result = [0_u8; 48]; + + hex_as_bytes(fingerprint.value.as_str(), &mut value_result); + + DtlsFingerprint::Sha384 { + value: value_result, + } + } + web_rtc_transport::FingerprintAlgorithm::Sha512 => { + let mut value_result = [0_u8; 64]; + + hex_as_bytes(fingerprint.value.as_str(), &mut value_result); + + DtlsFingerprint::Sha512 { + value: value_result, + } + } + } + } +} + impl fmt::Debug for DtlsFingerprint { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let name = match self { @@ -826,6 +999,30 @@ pub struct DtlsParameters { pub fingerprints: Vec, } +impl DtlsParameters { + pub(crate) fn to_fbs(&self) -> web_rtc_transport::DtlsParameters { + web_rtc_transport::DtlsParameters { + role: self.role.to_fbs(), + fingerprints: self + .fingerprints + .iter() + .map(|fingerprint| fingerprint.to_fbs()) + .collect(), + } + } + + pub(crate) fn from_fbs(parameters: web_rtc_transport::DtlsParameters) -> DtlsParameters { + DtlsParameters { + role: DtlsRole::from_fbs(parameters.role), + fingerprints: parameters + .fingerprints + .iter() + .map(DtlsFingerprint::from_fbs) + .collect(), + } + } +} + /// Trace event direction #[derive(Debug, Copy, Clone, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index 11b655b8f8..0089f8c6a6 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -32449,7 +32449,7 @@ mod root { /// The enum `Protocol` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `Protocol` in the file `../worker/fbs/transport.fbs:9` + /// * Enum `Protocol` in the file `../worker/fbs/transport.fbs:10` #[derive( Copy, Clone, @@ -32619,7 +32619,7 @@ mod root { /// The table `ListenInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ListenInfo` in the file `../worker/fbs/transport.fbs:11` + /// * Table `ListenInfo` in the file `../worker/fbs/transport.fbs:12` #[derive( Clone, Debug, @@ -33133,7 +33133,7 @@ mod root { /// The table `RestartIceResponse` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `RestartIceResponse` in the file `../worker/fbs/transport.fbs:20` + /// * Table `RestartIceResponse` in the file `../worker/fbs/transport.fbs:21` #[derive( Clone, Debug, @@ -33482,7 +33482,7 @@ mod root { /// The table `ProduceRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ProduceRequest` in the file `../worker/fbs/transport.fbs:26` + /// * Table `ProduceRequest` in the file `../worker/fbs/transport.fbs:27` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -33990,7 +33990,7 @@ mod root { /// The table `ProduceResponse` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ProduceResponse` in the file `../worker/fbs/transport.fbs:35` + /// * Table `ProduceResponse` in the file `../worker/fbs/transport.fbs:36` #[derive( Clone, Debug, @@ -34291,7 +34291,7 @@ mod root { /// The table `ConsumeRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ConsumeRequest` in the file `../worker/fbs/transport.fbs:39` + /// * Table `ConsumeRequest` in the file `../worker/fbs/transport.fbs:40` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -34998,7 +34998,7 @@ mod root { /// The table `ConsumeResponse` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ConsumeResponse` in the file `../worker/fbs/transport.fbs:51` + /// * Table `ConsumeResponse` in the file `../worker/fbs/transport.fbs:52` #[derive( Clone, Debug, @@ -35471,7 +35471,7 @@ mod root { /// The table `ProduceDataRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ProduceDataRequest` in the file `../worker/fbs/transport.fbs:58` + /// * Table `ProduceDataRequest` in the file `../worker/fbs/transport.fbs:59` #[derive( Clone, Debug, @@ -36019,7 +36019,7 @@ mod root { /// The table `ConsumeDataRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ConsumeDataRequest` in the file `../worker/fbs/transport.fbs:67` + /// * Table `ConsumeDataRequest` in the file `../worker/fbs/transport.fbs:68` #[derive( Clone, Debug, @@ -36665,7 +36665,7 @@ mod root { /// The table `Tuple` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Tuple` in the file `../worker/fbs/transport.fbs:78` + /// * Table `Tuple` in the file `../worker/fbs/transport.fbs:79` #[derive( Clone, Debug, @@ -37116,301 +37116,10 @@ mod root { } } - /// The table `SrtpParameters` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Table `SrtpParameters` in the file `../worker/fbs/transport.fbs:86` - #[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: ::planus::alloc::string::String, - /// 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::WriteAs<::planus::Offset>, - field_key_base64: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_crypto_suite = field_crypto_suite.prepare(builder); - 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>(0); - table_writer.write_entry::<::planus::Offset>(1); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_crypto_suite); - object_writer.write::<_, _, 4>(&prepared_key_base64); - }); - } - 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::WriteAs<::planus::Offset>, - { - SrtpParametersBuilder((value,)) - } - } - - 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::WriteAs<::planus::Offset>, - 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::WriteAs<::planus::Offset>, - 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::WriteAs<::planus::Offset>, - 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<&'a ::core::primitive::str> { - self.0.access_required(0, "SrtpParameters", "crypto_suite") - } - - /// 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 table `RtpListener` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `RtpListener` in the file `../worker/fbs/transport.fbs:91` + /// * Table `RtpListener` in the file `../worker/fbs/transport.fbs:87` #[derive( Clone, Debug, @@ -37773,7 +37482,7 @@ mod root { /// The table `SctpListener` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SctpListener` in the file `../worker/fbs/transport.fbs:97` + /// * Table `SctpListener` in the file `../worker/fbs/transport.fbs:93` #[derive( Clone, Debug, @@ -38047,7 +37756,7 @@ mod root { /// The table `RecvRtpHeaderExtensions` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `RecvRtpHeaderExtensions` in the file `../worker/fbs/transport.fbs:101` + /// * Table `RecvRtpHeaderExtensions` in the file `../worker/fbs/transport.fbs:97` #[derive( Clone, Debug, @@ -38570,7 +38279,7 @@ mod root { /// The table `Options` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Options` in the file `../worker/fbs/transport.fbs:109` + /// * Table `Options` in the file `../worker/fbs/transport.fbs:105` #[derive( Clone, Debug, @@ -38585,10 +38294,10 @@ mod root { pub struct Options { /// The field `direct` in the table `Options` pub direct: bool, - /// The field `max_message_size` in the table `Options` - pub max_message_size: u32, + /// 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: u32, + 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` @@ -38608,8 +38317,8 @@ mod root { fn default() -> Self { Self { direct: false, - max_message_size: 0, - initial_available_outgoing_bitrate: 0, + 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, @@ -38630,8 +38339,8 @@ mod root { pub fn create( builder: &mut ::planus::Builder, field_direct: impl ::planus::WriteAsDefault, - field_max_message_size: impl ::planus::WriteAsDefault, - field_initial_available_outgoing_bitrate: 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, @@ -38641,9 +38350,9 @@ mod root { 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, &0); + let prepared_max_message_size = field_max_message_size.prepare(builder); let prepared_initial_available_outgoing_bitrate = - field_initial_available_outgoing_bitrate.prepare(builder, &0); + 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 = @@ -38797,19 +38506,17 @@ mod root { #[allow(clippy::type_complexity)] pub fn max_message_size(self, value: T1) -> OptionsBuilder<(T0, T1)> where - T1: ::planus::WriteAsDefault, + T1: ::planus::WriteAsOptional, { let (v0,) = self.0; OptionsBuilder((v0, value)) } - /// Sets the [`max_message_size` field](Options#structfield.max_message_size) to the default 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_default( - self, - ) -> OptionsBuilder<(T0, ::planus::DefaultValue)> { - self.max_message_size(::planus::DefaultValue) + pub fn max_message_size_as_null(self) -> OptionsBuilder<(T0, ())> { + self.max_message_size(()) } } @@ -38822,19 +38529,19 @@ mod root { value: T2, ) -> OptionsBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAsDefault, + 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 the default 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_default( + pub fn initial_available_outgoing_bitrate_as_null( self, - ) -> OptionsBuilder<(T0, T1, ::planus::DefaultValue)> { - self.initial_available_outgoing_bitrate(::planus::DefaultValue) + ) -> OptionsBuilder<(T0, T1, ())> { + self.initial_available_outgoing_bitrate(()) } } @@ -38972,8 +38679,8 @@ mod root { impl< T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, + T1: ::planus::WriteAsOptional, + T2: ::planus::WriteAsOptional, T3: ::planus::WriteAsDefault, T4: ::planus::WriteAsOptional< ::planus::Offset, @@ -38994,8 +38701,8 @@ mod root { impl< T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, + T1: ::planus::WriteAsOptional, + T2: ::planus::WriteAsOptional, T3: ::planus::WriteAsDefault, T4: ::planus::WriteAsOptional< ::planus::Offset, @@ -39019,8 +38726,8 @@ mod root { impl< T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, + T1: ::planus::WriteAsOptional, + T2: ::planus::WriteAsOptional, T3: ::planus::WriteAsDefault, T4: ::planus::WriteAsOptional< ::planus::Offset, @@ -39053,22 +38760,17 @@ mod root { /// Getter for the [`max_message_size` field](Options#structfield.max_message_size). #[inline] - pub fn max_message_size(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "Options", "max_message_size")? - .unwrap_or(0), - ) + 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::result::Result::Ok( - self.0 - .access(2, "Options", "initial_available_outgoing_bitrate")? - .unwrap_or(0), - ) + 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). @@ -39124,11 +38826,19 @@ mod root { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut f = f.debug_struct("OptionsRef"); f.field("direct", &self.direct()); - f.field("max_message_size", &self.max_message_size()); - f.field( - "initial_available_outgoing_bitrate", - &self.initial_available_outgoing_bitrate(), - ); + 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() @@ -39149,12 +38859,26 @@ mod root { fn try_from(value: OptionsRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { direct: ::core::convert::TryInto::try_into(value.direct()?)?, - max_message_size: ::core::convert::TryInto::try_into( - value.max_message_size()?, - )?, - initial_available_outgoing_bitrate: ::core::convert::TryInto::try_into( - value.initial_available_outgoing_bitrate()?, - )?, + 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()? @@ -39251,7 +38975,7 @@ mod root { /// The table `Dump` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Dump` in the file `../worker/fbs/transport.fbs:120` + /// * Table `Dump` in the file `../worker/fbs/transport.fbs:117` #[derive( Clone, Debug, @@ -40288,7 +40012,7 @@ mod root { /// The table `Stats` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Stats` in the file `../worker/fbs/transport.fbs:138` + /// * Table `Stats` in the file `../worker/fbs/transport.fbs:135` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -40332,11 +40056,11 @@ mod root { /// 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: u32, + pub max_incoming_bitrate: ::core::option::Option, /// The field `max_outgoing_bitrate` in the table `Stats` - pub max_outgoing_bitrate: u32, + pub max_outgoing_bitrate: ::core::option::Option, /// The field `min_outgoing_bitrate` in the table `Stats` - pub min_outgoing_bitrate: u32, + 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` @@ -40372,9 +40096,9 @@ mod root { 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::WriteAsDefault, - field_max_outgoing_bitrate: impl ::planus::WriteAsDefault, - field_min_outgoing_bitrate: impl ::planus::WriteAsDefault, + 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 { @@ -40401,12 +40125,9 @@ mod root { 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, &0); - let prepared_max_outgoing_bitrate = - field_max_outgoing_bitrate.prepare(builder, &0); - let prepared_min_outgoing_bitrate = - field_min_outgoing_bitrate.prepare(builder, &0); + 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); @@ -41566,7 +41287,7 @@ mod root { T19, )> where - T19: ::planus::WriteAsDefault, + T19: ::planus::WriteAsOptional, { let ( v0, @@ -41595,10 +41316,10 @@ mod root { )) } - /// Sets the [`max_incoming_bitrate` field](Stats#structfield.max_incoming_bitrate) to the default 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_default( + pub fn max_incoming_bitrate_as_null( self, ) -> StatsBuilder<( T0, @@ -41620,9 +41341,9 @@ mod root { T16, T17, T18, - ::planus::DefaultValue, + (), )> { - self.max_incoming_bitrate(::planus::DefaultValue) + self.max_incoming_bitrate(()) } } @@ -41701,7 +41422,7 @@ mod root { T20, )> where - T20: ::planus::WriteAsDefault, + T20: ::planus::WriteAsOptional, { let ( v0, @@ -41731,10 +41452,10 @@ mod root { )) } - /// Sets the [`max_outgoing_bitrate` field](Stats#structfield.max_outgoing_bitrate) to the default 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_default( + pub fn max_outgoing_bitrate_as_null( self, ) -> StatsBuilder<( T0, @@ -41757,298 +41478,298 @@ mod root { T17, T18, T19, - ::planus::DefaultValue, - )> { - self.max_outgoing_bitrate(::planus::DefaultValue) - } - } - - 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::WriteAsDefault, - { - 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 the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn min_outgoing_bitrate_as_default( - self, - ) -> StatsBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - ::planus::DefaultValue, - )> { - self.min_outgoing_bitrate(::planus::DefaultValue) - } - } - - 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(()) + 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(()) } } @@ -42287,9 +42008,9 @@ mod root { T16: ::planus::WriteAsDefault, T17: ::planus::WriteAsOptional, T18: ::planus::WriteAsOptional, - T19: ::planus::WriteAsDefault, - T20: ::planus::WriteAsDefault, - T21: ::planus::WriteAsDefault, + T19: ::planus::WriteAsOptional, + T20: ::planus::WriteAsOptional, + T21: ::planus::WriteAsOptional, T22: ::planus::WriteAsOptional, T23: ::planus::WriteAsOptional, > ::planus::WriteAs<::planus::Offset> @@ -42348,9 +42069,9 @@ mod root { T16: ::planus::WriteAsDefault, T17: ::planus::WriteAsOptional, T18: ::planus::WriteAsOptional, - T19: ::planus::WriteAsDefault, - T20: ::planus::WriteAsDefault, - T21: ::planus::WriteAsDefault, + T19: ::planus::WriteAsOptional, + T20: ::planus::WriteAsOptional, + T21: ::planus::WriteAsOptional, T22: ::planus::WriteAsOptional, T23: ::planus::WriteAsOptional, > ::planus::WriteAsOptional<::planus::Offset> @@ -42412,9 +42133,9 @@ mod root { T16: ::planus::WriteAsDefault, T17: ::planus::WriteAsOptional, T18: ::planus::WriteAsOptional, - T19: ::planus::WriteAsDefault, - T20: ::planus::WriteAsDefault, - T21: ::planus::WriteAsDefault, + T19: ::planus::WriteAsOptional, + T20: ::planus::WriteAsOptional, + T21: ::planus::WriteAsOptional, T22: ::planus::WriteAsOptional, T23: ::planus::WriteAsOptional, > ::planus::WriteAsOffset @@ -42644,32 +42365,26 @@ mod root { /// Getter for the [`max_incoming_bitrate` field](Stats#structfield.max_incoming_bitrate). #[inline] - pub fn max_incoming_bitrate(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(19, "Stats", "max_incoming_bitrate")? - .unwrap_or(0), - ) + 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::result::Result::Ok( - self.0 - .access(20, "Stats", "max_outgoing_bitrate")? - .unwrap_or(0), - ) + 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::result::Result::Ok( - self.0 - .access(21, "Stats", "min_outgoing_bitrate")? - .unwrap_or(0), - ) + 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). @@ -42729,9 +42444,21 @@ mod root { &field_available_incoming_bitrate, ); } - f.field("max_incoming_bitrate", &self.max_incoming_bitrate()); - f.field("max_outgoing_bitrate", &self.max_outgoing_bitrate()); - f.field("min_outgoing_bitrate", &self.min_outgoing_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() { @@ -42819,15 +42546,36 @@ mod root { } else { ::core::option::Option::None }, - max_incoming_bitrate: ::core::convert::TryInto::try_into( - value.max_incoming_bitrate()?, - )?, - max_outgoing_bitrate: ::core::convert::TryInto::try_into( - value.max_outgoing_bitrate()?, - )?, - min_outgoing_bitrate: ::core::convert::TryInto::try_into( - value.min_outgoing_bitrate()?, - )?, + 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()? @@ -42925,7 +42673,7 @@ mod root { /// The table `SetMaxIncomingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMaxIncomingBitrateRequest` in the file `../worker/fbs/transport.fbs:165` + /// * Table `SetMaxIncomingBitrateRequest` in the file `../worker/fbs/transport.fbs:162` #[derive( Clone, Debug, @@ -43233,7 +42981,7 @@ mod root { /// The table `SetMaxOutgoingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMaxOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:169` + /// * Table `SetMaxOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:166` #[derive( Clone, Debug, @@ -43541,7 +43289,7 @@ mod root { /// The table `SetMinOutgoingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMinOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:173` + /// * Table `SetMinOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:170` #[derive( Clone, Debug, @@ -43849,7 +43597,7 @@ mod root { /// The table `EnableTraceEventRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/transport.fbs:177` + /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/transport.fbs:174` #[derive( Clone, Debug, @@ -44121,7 +43869,7 @@ mod root { /// The table `CloseProducerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseProducerRequest` in the file `../worker/fbs/transport.fbs:181` + /// * Table `CloseProducerRequest` in the file `../worker/fbs/transport.fbs:178` #[derive( Clone, Debug, @@ -44387,7 +44135,7 @@ mod root { /// The table `CloseConsumerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseConsumerRequest` in the file `../worker/fbs/transport.fbs:185` + /// * Table `CloseConsumerRequest` in the file `../worker/fbs/transport.fbs:182` #[derive( Clone, Debug, @@ -44653,7 +44401,7 @@ mod root { /// The table `CloseDataProducerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseDataProducerRequest` in the file `../worker/fbs/transport.fbs:189` + /// * Table `CloseDataProducerRequest` in the file `../worker/fbs/transport.fbs:186` #[derive( Clone, Debug, @@ -44928,7 +44676,7 @@ mod root { /// The table `CloseDataConsumerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseDataConsumerRequest` in the file `../worker/fbs/transport.fbs:193` + /// * Table `CloseDataConsumerRequest` in the file `../worker/fbs/transport.fbs:190` #[derive( Clone, Debug, @@ -45203,7 +44951,7 @@ mod root { /// The table `SendRtcpNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SendRtcpNotification` in the file `../worker/fbs/transport.fbs:199` + /// * Table `SendRtcpNotification` in the file `../worker/fbs/transport.fbs:196` #[derive( Clone, Debug, @@ -45468,7 +45216,7 @@ mod root { /// The table `SctpStateChangeNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SctpStateChangeNotification` in the file `../worker/fbs/transport.fbs:205` + /// * Table `SctpStateChangeNotification` in the file `../worker/fbs/transport.fbs:202` #[derive( Clone, Debug, @@ -45789,7 +45537,7 @@ mod root { /// The enum `TraceType` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `TraceType` in the file `../worker/fbs/transport.fbs:209` + /// * Enum `TraceType` in the file `../worker/fbs/transport.fbs:206` #[derive( Copy, Clone, @@ -45959,7 +45707,7 @@ mod root { /// The enum `TraceDirection` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `TraceDirection` in the file `../worker/fbs/transport.fbs:211` + /// * Enum `TraceDirection` in the file `../worker/fbs/transport.fbs:208` #[derive( Copy, Clone, @@ -46129,7 +45877,7 @@ mod root { /// The union `TraceInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:213` + /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:210` #[derive( Clone, Debug, @@ -46282,7 +46030,7 @@ mod root { /// The enum `BweType` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:217` + /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:214` #[derive( Copy, Clone, @@ -46452,7 +46200,7 @@ mod root { /// The table `BweTraceInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:219` + /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:216` #[derive( Clone, Debug, @@ -47135,7 +46883,7 @@ mod root { /// The table `TraceNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:230` + /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:227` #[derive( Clone, Debug, @@ -47780,257 +47528,15 @@ mod root { } } } - /// The namespace `FBS.Log` + /// The namespace `FBS.SrtpParameters` /// /// Generated from these locations: - /// * File `../worker/fbs/log.fbs` - pub mod log { - /// The table `Log` in the namespace `FBS.Log` + /// * File `../worker/fbs/srtpParameters.fbs` + pub mod srtp_parameters { + /// The enum `SrtpCryptoSuite` in the namespace `FBS.SrtpParameters` /// /// Generated from these locations: - /// * Table `Log` in the file `../worker/fbs/log.fbs:4` - #[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` + /// * Enum `SrtpCryptoSuite` in the file `../worker/fbs/srtpParameters.fbs:4` #[derive( Copy, Clone, @@ -48044,27 +47550,31 @@ mod root { ::serde::Deserialize, )] #[repr(u8)] - pub enum Type { - /// The variant `REQUEST` in the enum `Type` - Request = 0, + pub enum SrtpCryptoSuite { + /// The variant `AEAD_AES_256_GCM` in the enum `SrtpCryptoSuite` + AeadAes256Gcm = 0, - /// The variant `RESPONSE` in the enum `Type` - Response = 1, + /// The variant `AEAD_AES_128_GCM` in the enum `SrtpCryptoSuite` + AeadAes128Gcm = 1, - /// The variant `NOTIFICATION` in the enum `Type` - Notification = 2, + /// The variant `AES_CM_128_HMAC_SHA1_80` in the enum `SrtpCryptoSuite` + AesCm128HmacSha180 = 2, - /// The variant `LOG` in the enum `Type` - Log = 3, + /// The variant `AES_CM_128_HMAC_SHA1_32` in the enum `SrtpCryptoSuite` + AesCm128HmacSha132 = 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 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 Type { + impl ::core::convert::TryFrom for SrtpCryptoSuite { type Error = ::planus::errors::UnknownEnumTagKind; #[inline] fn try_from( @@ -48073,10 +47583,10 @@ mod root { { #[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), + 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, @@ -48085,19 +47595,19 @@ mod root { } } - impl ::core::convert::From for u8 { + impl ::core::convert::From for u8 { #[inline] - fn from(value: Type) -> Self { + fn from(value: SrtpCryptoSuite) -> Self { value as u8 } } - impl ::planus::Primitive for Type { + impl ::planus::Primitive for SrtpCryptoSuite { const ALIGNMENT: usize = 1; const SIZE: usize = 1; } - impl ::planus::WriteAsPrimitive for Type { + impl ::planus::WriteAsPrimitive for SrtpCryptoSuite { #[inline] fn write( &self, @@ -48108,24 +47618,24 @@ mod root { } } - impl ::planus::WriteAs for Type { + impl ::planus::WriteAs for SrtpCryptoSuite { type Prepared = Self; #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Type { + fn prepare(&self, _builder: &mut ::planus::Builder) -> SrtpCryptoSuite { *self } } - impl ::planus::WriteAsDefault for Type { + impl ::planus::WriteAsDefault for SrtpCryptoSuite { type Prepared = Self; #[inline] fn prepare( &self, _builder: &mut ::planus::Builder, - default: &Type, - ) -> ::core::option::Option { + default: &SrtpCryptoSuite, + ) -> ::core::option::Option { if self == default { ::core::option::Option::None } else { @@ -48134,19 +47644,19 @@ mod root { } } - impl ::planus::WriteAsOptional for Type { + impl ::planus::WriteAsOptional for SrtpCryptoSuite { type Prepared = Self; #[inline] fn prepare( &self, _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { + ) -> ::core::option::Option { ::core::option::Option::Some(*self) } } - impl<'buf> ::planus::TableRead<'buf> for Type { + impl<'buf> ::planus::TableRead<'buf> for SrtpCryptoSuite { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, @@ -48157,7 +47667,7 @@ mod root { } } - impl<'buf> ::planus::VectorReadInner<'buf> for Type { + impl<'buf> ::planus::VectorReadInner<'buf> for SrtpCryptoSuite { type Error = ::planus::errors::UnknownEnumTag; const STRIDE: usize = 1; #[inline] @@ -48171,7 +47681,7 @@ mod root { ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { error_kind.with_error_location( - "Type", + "SrtpCryptoSuite", "VectorRead::from_buffer", buffer.offset_from_start, ) @@ -48179,7 +47689,7 @@ mod root { } } - impl ::planus::VectorWrite for Type { + impl ::planus::VectorWrite for SrtpCryptoSuite { const STRIDE: usize = 1; type Value = Self; @@ -48206,512 +47716,251 @@ mod root { } } - /// 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 of type `FBS.Request.Request` in the union `Body` - Request(::planus::alloc::boxed::Box), - - /// The variant of type `FBS.Response.Response` in the union `Body` - Response(::planus::alloc::boxed::Box), - - /// The variant of type `FBS.Notification.Notification` in the union `Body` - Notification(::planus::alloc::boxed::Box), - - /// The variant of type `FBS.Log.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` + /// The table `SrtpParameters` in the namespace `FBS.SrtpParameters` /// /// Generated from these locations: - /// * Table `Message` in the file `../worker/fbs/message.fbs:22` + /// * Table `SrtpParameters` in the file `../worker/fbs/srtpParameters.fbs:11` #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::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, + 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 Message { - /// Creates a [MessageBuilder] for serializing an instance of this table. + impl SrtpParameters { + /// Creates a [SrtpParametersBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> MessageBuilder<()> { - MessageBuilder(()) + pub fn builder() -> SrtpParametersBuilder<()> { + SrtpParametersBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_type_: impl ::planus::WriteAsDefault, - field_data: impl ::planus::WriteAsUnion, + field_crypto_suite: impl ::planus::WriteAsDefault< + self::SrtpCryptoSuite, + self::SrtpCryptoSuite, + >, + field_key_base64: impl ::planus::WriteAs<::planus::Offset>, ) -> ::planus::Offset { - let prepared_type_ = field_type_.prepare(builder, &self::Type::Request); - let prepared_data = field_data.prepare(builder); + 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<10> = + let mut table_writer: ::planus::table_writer::TableWriter<8> = ::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::<::planus::Offset>(1); + if prepared_crypto_suite.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::<_, _, 4>(&prepared_key_base64); + if let ::core::option::Option::Some(prepared_crypto_suite) = + prepared_crypto_suite + { + object_writer.write::<_, _, 1>(&prepared_crypto_suite); } - object_writer.write::<_, _, 1>(&prepared_data.tag()); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for Message { + impl ::planus::WriteAs<::planus::Offset> for SrtpParameters { type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for Message { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for Message { + impl ::planus::WriteAsOffset for SrtpParameters { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Message::create(builder, self.type_, &self.data) + 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 [Message] type. + /// Builder for serializing an instance of the [SrtpParameters] type. /// - /// Can be created using the [Message::builder] method. + /// Can be created using the [SrtpParameters::builder] method. #[derive(Debug)] #[must_use] - pub struct MessageBuilder(State); + pub struct SrtpParametersBuilder(State); - impl MessageBuilder<()> { - /// Setter for the [`type` field](Message#structfield.type_). + impl SrtpParametersBuilder<()> { + /// Setter for the [`crypto_suite` field](SrtpParameters#structfield.crypto_suite). #[inline] #[allow(clippy::type_complexity)] - pub fn type_(self, value: T0) -> MessageBuilder<(T0,)> + pub fn crypto_suite(self, value: T0) -> SrtpParametersBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, { - MessageBuilder((value,)) + SrtpParametersBuilder((value,)) } - /// Sets the [`type` field](Message#structfield.type_) to the default value. + /// Sets the [`crypto_suite` field](SrtpParameters#structfield.crypto_suite) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn type_as_default(self) -> MessageBuilder<(::planus::DefaultValue,)> { - self.type_(::planus::DefaultValue) + pub fn crypto_suite_as_default( + self, + ) -> SrtpParametersBuilder<(::planus::DefaultValue,)> { + self.crypto_suite(::planus::DefaultValue) } } - impl MessageBuilder<(T0,)> { - /// Setter for the [`data` field](Message#structfield.data). + impl SrtpParametersBuilder<(T0,)> { + /// Setter for the [`key_base64` field](SrtpParameters#structfield.key_base64). #[inline] #[allow(clippy::type_complexity)] - pub fn data(self, value: T1) -> MessageBuilder<(T0, T1)> + pub fn key_base64(self, value: T1) -> SrtpParametersBuilder<(T0, T1)> where - T1: ::planus::WriteAsUnion, + T1: ::planus::WriteAs<::planus::Offset>, { let (v0,) = self.0; - MessageBuilder((v0, value)) + SrtpParametersBuilder((v0, value)) } } - impl MessageBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Message]. + 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 + pub fn finish( + self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsUnion, - > ::planus::WriteAs<::planus::Offset> for MessageBuilder<(T0, T1)> + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAs<::planus::Offset>, + > ::planus::WriteAs<::planus::Offset> + for SrtpParametersBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + 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)> + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAs<::planus::Offset>, + > ::planus::WriteAsOptional<::planus::Offset> + for SrtpParametersBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::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)> + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAs<::planus::Offset>, + > ::planus::WriteAsOffset for SrtpParametersBuilder<(T0, T1)> { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { let (v0, v1) = &self.0; - Message::create(builder, v0, v1) + SrtpParameters::create(builder, v0, v1) } } - /// Reference to a deserialized [Message]. + /// Reference to a deserialized [SrtpParameters]. #[derive(Copy, Clone)] - pub struct MessageRef<'a>(::planus::table_reader::Table<'a>); + pub struct SrtpParametersRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> MessageRef<'a> { - /// Getter for the [`type` field](Message#structfield.type_). + impl<'a> SrtpParametersRef<'a> { + /// Getter for the [`crypto_suite` field](SrtpParameters#structfield.crypto_suite). #[inline] - pub fn type_(&self) -> ::planus::Result { + pub fn crypto_suite(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 - .access(0, "Message", "type_")? - .unwrap_or(self::Type::Request), + .access(0, "SrtpParameters", "crypto_suite")? + .unwrap_or(self::SrtpCryptoSuite::AeadAes256Gcm), ) } - /// Getter for the [`data` field](Message#structfield.data). + /// Getter for the [`key_base64` field](SrtpParameters#structfield.key_base64). #[inline] - pub fn data(&self) -> ::planus::Result> { - self.0.access_union_required(1, "Message", "data") + 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 MessageRef<'a> { + 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("MessageRef"); - f.field("type_", &self.type_()); - f.field("data", &self.data()); + 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 Message { + impl<'a> ::core::convert::TryFrom> for SrtpParameters { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: MessageRef<'a>) -> ::planus::Result { + fn try_from(value: SrtpParametersRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - type_: ::core::convert::TryInto::try_into(value.type_()?)?, - data: ::core::convert::TryInto::try_into(value.data()?)?, + 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 MessageRef<'a> { + impl<'a> ::planus::TableRead<'a> for SrtpParametersRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -48723,7 +47972,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for MessageRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for SrtpParametersRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -48733,7 +47982,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[MessageRef]", + "[SrtpParametersRef]", "get", buffer.offset_from_start, ) @@ -48741,8 +47990,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for Message { - type Value = ::planus::Offset; + 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 { @@ -48751,7 +48000,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -48766,7 +48015,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for MessageRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for SrtpParametersRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -48776,166 +48025,296 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[MessageRef]", "read_as_root", 0) + error_kind.with_error_location("[SrtpParametersRef]", "read_as_root", 0) }) } } } - /// The namespace `FBS.Notification` + /// The namespace `FBS.Log` /// /// Generated from these locations: - /// * File `../worker/fbs/notification.fbs` - pub mod notification { - /// The enum `Event` in the namespace `FBS.Notification` + /// * File `../worker/fbs/log.fbs` + pub mod log { + /// The table `Log` in the namespace `FBS.Log` /// /// Generated from these locations: - /// * Enum `Event` in the file `../worker/fbs/notification.fbs:13` + /// * Table `Log` in the file `../worker/fbs/log.fbs:4` #[derive( - Copy, Clone, Debug, PartialEq, - Eq, PartialOrd, + Eq, 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, + pub struct Log { + /// The field `data` in the table `Log` + pub data: ::planus::alloc::string::String, + } - /// The variant `WORKER_RUNNING` in the enum `Event` - WorkerRunning = 3, + impl Log { + /// Creates a [LogBuilder] for serializing an instance of this table. + #[inline] + pub fn builder() -> LogBuilder<()> { + LogBuilder(()) + } - /// The variant `TRANSPORT_SCTP_STATE_CHANGE` in the enum `Event` - TransportSctpStateChange = 4, + #[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); - /// The variant `TRANSPORT_TRACE` in the enum `Event` - TransportTrace = 5, + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + table_writer.write_entry::<::planus::Offset>(0); - /// The variant `WEBRTCTRANSPORT_ICE_SELECTED_TUPLE_CHANGE` in the enum `Event` - WebrtctransportIceSelectedTupleChange = 6, + unsafe { + table_writer.finish(builder, |object_writer| { + object_writer.write::<_, _, 4>(&prepared_data); + }); + } + builder.current_offset() + } + } - /// The variant `WEBRTCTRANSPORT_ICE_STATE_CHANGE` in the enum `Event` - WebrtctransportIceStateChange = 7, + impl ::planus::WriteAs<::planus::Offset> for Log { + type Prepared = ::planus::Offset; - /// The variant `WEBRTCTRANSPORT_DTLS_STATE_CHANGE` in the enum `Event` - WebrtctransportDtlsStateChange = 8, + #[inline] + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) + } + } - /// The variant `PLAINTRANSPORT_TUPLE` in the enum `Event` - PlaintransportTuple = 9, + impl ::planus::WriteAsOptional<::planus::Offset> for Log { + type Prepared = ::planus::Offset; - /// The variant `PLAINTRANSPORT_RTCP_TUPLE` in the enum `Event` - PlaintransportRtcpTuple = 10, + #[inline] + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + } + } - /// The variant `DIRECTTRANSPORT_RTCP` in the enum `Event` - DirecttransportRtcp = 11, + impl ::planus::WriteAsOffset for Log { + #[inline] + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Log::create(builder, &self.data) + } + } - /// The variant `PRODUCER_SCORE` in the enum `Event` - ProducerScore = 12, + /// 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); - /// The variant `PRODUCER_TRACE` in the enum `Event` - ProducerTrace = 13, + 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,)) + } + } - /// The variant `PRODUCER_VIDEO_ORIENTATION_CHANGE` in the enum `Event` - ProducerVideoOrientationChange = 14, + 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) + } + } - /// The variant `CONSUMER_PRODUCER_PAUSE` in the enum `Event` - ConsumerProducerPause = 15, + impl>> + ::planus::WriteAs<::planus::Offset> for LogBuilder<(T0,)> + { + type Prepared = ::planus::Offset; - /// The variant `CONSUMER_PRODUCER_RESUME` in the enum `Event` - ConsumerProducerResume = 16, + #[inline] + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) + } + } - /// The variant `CONSUMER_PRODUCER_CLOSE` in the enum `Event` - ConsumerProducerClose = 17, + impl>> + ::planus::WriteAsOptional<::planus::Offset> for LogBuilder<(T0,)> + { + type Prepared = ::planus::Offset; - /// The variant `CONSUMER_LAYERS_CHANGE` in the enum `Event` - ConsumerLayersChange = 18, + #[inline] + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + } + } - /// The variant `CONSUMER_RTP` in the enum `Event` - ConsumerRtp = 19, + impl>> ::planus::WriteAsOffset + for LogBuilder<(T0,)> + { + #[inline] + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + let (v0,) = &self.0; + Log::create(builder, v0) + } + } - /// The variant `CONSUMER_SCORE` in the enum `Event` - ConsumerScore = 20, + /// Reference to a deserialized [Log]. + #[derive(Copy, Clone)] + pub struct LogRef<'a>(::planus::table_reader::Table<'a>); - /// The variant `CONSUMER_TRACE` in the enum `Event` - ConsumerTrace = 21, + 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") + } + } - /// The variant `DATACONSUMER_BUFFERED_AMOUNT_LOW` in the enum `Event` - DataconsumerBufferedAmountLow = 22, + 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() + } + } - /// The variant `DATACONSUMER_SCTP_SENDBUFFER_FULL` in the enum `Event` - DataconsumerSctpSendbufferFull = 23, + impl<'a> ::core::convert::TryFrom> for Log { + type Error = ::planus::Error; - /// The variant `DATACONSUMER_DATAPRODUCER_PAUSE` in the enum `Event` - DataconsumerDataproducerPause = 24, + #[allow(unreachable_code)] + fn try_from(value: LogRef<'a>) -> ::planus::Result { + ::core::result::Result::Ok(Self { + data: ::core::convert::TryInto::try_into(value.data()?)?, + }) + } + } - /// The variant `DATACONSUMER_DATAPRODUCER_RESUME` in the enum `Event` - DataconsumerDataproducerResume = 25, + 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, + )?)) + } + } - /// The variant `DATACONSUMER_DATAPRODUCER_CLOSE` in the enum `Event` - DataconsumerDataproducerClose = 26, + impl<'a> ::planus::VectorReadInner<'a> for LogRef<'a> { + type Error = ::planus::Error; + const STRIDE: usize = 4; - /// The variant `DATACONSUMER_MESSAGE` in the enum `Event` - DataconsumerMessage = 27, + 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) + }) + } + } - /// The variant `ACTIVESPEAKEROBSERVER_DOMINANT_SPEAKER` in the enum `Event` - ActivespeakerobserverDominantSpeaker = 28, + 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) + } - /// The variant `AUDIOLEVELOBSERVER_SILENCE` in the enum `Event` - AudiolevelobserverSilence = 29, + #[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, + ); + } + } + } - /// The variant `AUDIOLEVELOBSERVER_VOLUMES` in the enum `Event` - AudiolevelobserverVolumes = 30, + 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 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 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 Event { + impl ::core::convert::TryFrom for Type { type Error = ::planus::errors::UnknownEnumTagKind; #[inline] fn try_from( @@ -48944,41 +48323,10 @@ mod root { { #[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), + 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, @@ -48987,19 +48335,19 @@ mod root { } } - impl ::core::convert::From for u8 { + impl ::core::convert::From for u8 { #[inline] - fn from(value: Event) -> Self { + fn from(value: Type) -> Self { value as u8 } } - impl ::planus::Primitive for Event { + impl ::planus::Primitive for Type { const ALIGNMENT: usize = 1; const SIZE: usize = 1; } - impl ::planus::WriteAsPrimitive for Event { + impl ::planus::WriteAsPrimitive for Type { #[inline] fn write( &self, @@ -49010,24 +48358,24 @@ mod root { } } - impl ::planus::WriteAs for Event { + impl ::planus::WriteAs for Type { type Prepared = Self; #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Event { + fn prepare(&self, _builder: &mut ::planus::Builder) -> Type { *self } } - impl ::planus::WriteAsDefault for Event { + impl ::planus::WriteAsDefault for Type { type Prepared = Self; #[inline] fn prepare( &self, _builder: &mut ::planus::Builder, - default: &Event, - ) -> ::core::option::Option { + default: &Type, + ) -> ::core::option::Option { if self == default { ::core::option::Option::None } else { @@ -49036,19 +48384,19 @@ mod root { } } - impl ::planus::WriteAsOptional for Event { + impl ::planus::WriteAsOptional for Type { type Prepared = Self; #[inline] fn prepare( &self, _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { + ) -> ::core::option::Option { ::core::option::Option::Some(*self) } } - impl<'buf> ::planus::TableRead<'buf> for Event { + impl<'buf> ::planus::TableRead<'buf> for Type { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'buf>, @@ -49059,7 +48407,7 @@ mod root { } } - impl<'buf> ::planus::VectorReadInner<'buf> for Event { + impl<'buf> ::planus::VectorReadInner<'buf> for Type { type Error = ::planus::errors::UnknownEnumTag; const STRIDE: usize = 1; #[inline] @@ -49073,7 +48421,7 @@ mod root { ::core::convert::TryInto::try_into(value); value.map_err(|error_kind| { error_kind.with_error_location( - "Event", + "Type", "VectorRead::from_buffer", buffer.offset_from_start, ) @@ -49081,7 +48429,7 @@ mod root { } } - impl ::planus::VectorWrite for Event { + impl ::planus::VectorWrite for Type { const STRIDE: usize = 1; type Value = Self; @@ -49108,117 +48456,25 @@ mod root { } } - /// The union `Body` in the namespace `FBS.Notification` + /// The union `Body` in the namespace `FBS.Message` /// /// Generated from these locations: - /// * Union `Body` in the file `../worker/fbs/notification.fbs:49` + /// * Union `Body` in the file `../worker/fbs/message.fbs:15` #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub enum Body { - /// The variant of type `FBS.Transport.SendRtcpNotification` in the union `Body` - SendRtcpNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Transport.SctpStateChangeNotification` in the union `Body` - SctpStateChangeNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.DataProducer.SendNotification` in the union `Body` - SendNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Consumer.TraceNotification` in the union `Body` - TraceNotification(::planus::alloc::boxed::Box), - - /// The variant of type `FBS.WebRtcTransport.IceSelectedTupleChangeNotification` in the union `Body` - IceSelectedTupleChangeNotification( - ::planus::alloc::boxed::Box< - super::web_rtc_transport::IceSelectedTupleChangeNotification, - >, - ), - - /// The variant of type `FBS.WebRtcTransport.IceStateChangeNotification` in the union `Body` - IceStateChangeNotification( - ::planus::alloc::boxed::Box< - super::web_rtc_transport::IceStateChangeNotification, - >, - ), - - /// The variant of type `FBS.WebRtcTransport.DtlsStateChangeNotification` in the union `Body` - DtlsStateChangeNotification( - ::planus::alloc::boxed::Box< - super::web_rtc_transport::DtlsStateChangeNotification, - >, - ), - - /// The variant of type `FBS.PlainTransport.TupleNotification` in the union `Body` - TupleNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.PlainTransport.RtcpTupleNotification` in the union `Body` - RtcpTupleNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.DirectTransport.RtcpNotification` in the union `Body` - RtcpNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Consumer.ScoreNotification` in the union `Body` - ScoreNotification(::planus::alloc::boxed::Box), - - /// The variant of type `FBS.Producer.VideoOrientationChangeNotification` in the union `Body` - VideoOrientationChangeNotification( - ::planus::alloc::boxed::Box< - super::producer::VideoOrientationChangeNotification, - >, - ), - - /// The variant of type `FBS.Consumer.LayersChangeNotification` in the union `Body` - LayersChangeNotification( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Consumer.RtpNotification` in the union `Body` - RtpNotification(::planus::alloc::boxed::Box), - - /// The variant of type `FBS.DataConsumer.MessageNotification` in the union `Body` - MessageNotification( - ::planus::alloc::boxed::Box, - ), + /// The variant of type `FBS.Request.Request` in the union `Body` + Request(::planus::alloc::boxed::Box), - /// The variant of type `FBS.DataConsumer.BufferedAmountLowNotification` in the union `Body` - BufferedAmountLowNotification( - ::planus::alloc::boxed::Box< - super::data_consumer::BufferedAmountLowNotification, - >, - ), + /// The variant of type `FBS.Response.Response` in the union `Body` + Response(::planus::alloc::boxed::Box), - /// The variant of type `FBS.ActiveSpeakerObserver.DominantSpeakerNotification` in the union `Body` - DominantSpeakerNotification( - ::planus::alloc::boxed::Box< - super::active_speaker_observer::DominantSpeakerNotification, - >, - ), + /// The variant of type `FBS.Notification.Notification` in the union `Body` + Notification(::planus::alloc::boxed::Box), - /// The variant of type `FBS.AudioLevelObserver.VolumesNotification` in the union `Body` - VolumesNotification( - ::planus::alloc::boxed::Box, - ), + /// The variant of type `FBS.Log.Log` in the union `Body` + Log(::planus::alloc::boxed::Box), } impl Body { @@ -49229,222 +48485,46 @@ mod root { } #[inline] - pub fn create_send_rtcp_notification( + pub fn create_request( builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, + value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) } #[inline] - pub fn create_sctp_state_change_notification( + pub fn create_response( builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, + value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) } #[inline] - pub fn create_send_notification( + pub fn create_notification( builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, + value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) } #[inline] - pub fn create_trace_notification( + pub fn create_log( builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, + value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) } - - #[inline] - pub fn create_ice_selected_tuple_change_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::web_rtc_transport::IceSelectedTupleChangeNotification, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_ice_state_change_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::web_rtc_transport::IceStateChangeNotification, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(6, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_dtls_state_change_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::web_rtc_transport::DtlsStateChangeNotification, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(7, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_tuple_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(8, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_rtcp_tuple_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(9, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_rtcp_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(10, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_score_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_video_orientation_change_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::producer::VideoOrientationChangeNotification, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_layers_change_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_rtp_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_message_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_buffered_amount_low_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::data_consumer::BufferedAmountLowNotification, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_dominant_speaker_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::active_speaker_observer::DominantSpeakerNotification, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_volumes_notification( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::audio_level_observer::VolumesNotification, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(18, value.prepare(builder).downcast()) - } } impl ::planus::WriteAsUnion for Body { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { match self { - Self::SendRtcpNotification(value) => { - Self::create_send_rtcp_notification(builder, value) - } - Self::SctpStateChangeNotification(value) => { - Self::create_sctp_state_change_notification(builder, value) - } - Self::SendNotification(value) => { - Self::create_send_notification(builder, value) - } - Self::TraceNotification(value) => { - Self::create_trace_notification(builder, value) - } - Self::IceSelectedTupleChangeNotification(value) => { - Self::create_ice_selected_tuple_change_notification(builder, value) - } - Self::IceStateChangeNotification(value) => { - Self::create_ice_state_change_notification(builder, value) - } - Self::DtlsStateChangeNotification(value) => { - Self::create_dtls_state_change_notification(builder, value) - } - Self::TupleNotification(value) => { - Self::create_tuple_notification(builder, value) - } - Self::RtcpTupleNotification(value) => { - Self::create_rtcp_tuple_notification(builder, value) - } - Self::RtcpNotification(value) => { - Self::create_rtcp_notification(builder, value) - } - Self::ScoreNotification(value) => { - Self::create_score_notification(builder, value) - } - Self::VideoOrientationChangeNotification(value) => { - Self::create_video_orientation_change_notification(builder, value) - } - Self::LayersChangeNotification(value) => { - Self::create_layers_change_notification(builder, value) - } - Self::RtpNotification(value) => { - Self::create_rtp_notification(builder, value) - } - Self::MessageNotification(value) => { - Self::create_message_notification(builder, value) - } - Self::BufferedAmountLowNotification(value) => { - Self::create_buffered_amount_low_notification(builder, value) - } - Self::DominantSpeakerNotification(value) => { - Self::create_dominant_speaker_notification(builder, value) - } - Self::VolumesNotification(value) => { - Self::create_volumes_notification(builder, value) - } + 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), } } } @@ -49467,226 +48547,38 @@ mod root { pub struct BodyBuilder(T); impl BodyBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`SendRtcpNotification` variant](Body#variant.SendRtcpNotification). - #[inline] - pub fn send_rtcp_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`SctpStateChangeNotification` variant](Body#variant.SctpStateChangeNotification). - #[inline] - pub fn 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 [`SendNotification` variant](Body#variant.SendNotification). - #[inline] - pub fn send_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`TraceNotification` variant](Body#variant.TraceNotification). - #[inline] - pub fn trace_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`IceSelectedTupleChangeNotification` variant](Body#variant.IceSelectedTupleChangeNotification). - #[inline] - pub fn ice_selected_tuple_change_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset< - super::web_rtc_transport::IceSelectedTupleChangeNotification, - >, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`IceStateChangeNotification` variant](Body#variant.IceStateChangeNotification). - #[inline] - pub fn ice_state_change_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<6, T>> - where - T: ::planus::WriteAsOffset< - super::web_rtc_transport::IceStateChangeNotification, - >, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`DtlsStateChangeNotification` variant](Body#variant.DtlsStateChangeNotification). - #[inline] - pub fn dtls_state_change_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<7, T>> - where - T: ::planus::WriteAsOffset< - super::web_rtc_transport::DtlsStateChangeNotification, - >, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`TupleNotification` variant](Body#variant.TupleNotification). - #[inline] - pub fn tuple_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<8, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`RtcpTupleNotification` variant](Body#variant.RtcpTupleNotification). - #[inline] - pub fn rtcp_tuple_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<9, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`RtcpNotification` variant](Body#variant.RtcpNotification). - #[inline] - pub fn rtcp_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<10, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`ScoreNotification` variant](Body#variant.ScoreNotification). - #[inline] - pub fn score_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<11, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`VideoOrientationChangeNotification` variant](Body#variant.VideoOrientationChangeNotification). - #[inline] - pub fn video_orientation_change_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<12, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`LayersChangeNotification` variant](Body#variant.LayersChangeNotification). - #[inline] - pub fn layers_change_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<13, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`RtpNotification` variant](Body#variant.RtpNotification). - #[inline] - pub fn rtp_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<14, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`MessageNotification` variant](Body#variant.MessageNotification). + /// Creates an instance of the [`Request` variant](Body#variant.Request). #[inline] - pub fn message_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<15, T>> + pub fn request(self, value: T) -> BodyBuilder<::planus::Initialized<1, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`BufferedAmountLowNotification` variant](Body#variant.BufferedAmountLowNotification). + /// Creates an instance of the [`Response` variant](Body#variant.Response). #[inline] - pub fn buffered_amount_low_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<16, T>> + pub fn response(self, value: T) -> BodyBuilder<::planus::Initialized<2, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`DominantSpeakerNotification` variant](Body#variant.DominantSpeakerNotification). + /// Creates an instance of the [`Notification` variant](Body#variant.Notification). #[inline] - pub fn dominant_speaker_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<17, T>> + pub fn notification(self, value: T) -> BodyBuilder<::planus::Initialized<3, T>> where - T: ::planus::WriteAsOffset< - super::active_speaker_observer::DominantSpeakerNotification, - >, + T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`VolumesNotification` variant](Body#variant.VolumesNotification). + /// Creates an instance of the [`Log` variant](Body#variant.Log). #[inline] - pub fn volumes_notification( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<18, T>> + pub fn log(self, value: T) -> BodyBuilder<::planus::Initialized<4, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } @@ -49705,7 +48597,7 @@ mod root { impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<1, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -49715,7 +48607,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<1, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -49727,7 +48619,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<2, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -49737,7 +48629,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<2, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -49749,7 +48641,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<3, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -49759,7 +48651,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<3, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -49771,7 +48663,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<4, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -49781,7 +48673,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<4, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -49791,3088 +48683,3832 @@ mod root { ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset< - super::web_rtc_transport::IceSelectedTupleChangeNotification, - >, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(5, (self.0).0.prepare(builder).downcast()) - } + + /// 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 ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<5, 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<'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 ::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<'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 }, + ), + } } } - 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()) - } + /// 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 ::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, - { + impl Message { + /// Creates a [MessageBuilder] for serializing an instance of this table. #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(8, (self.0).0.prepare(builder).downcast()) + pub fn builder() -> MessageBuilder<()> { + MessageBuilder(()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<8, T>> - where - T: ::planus::WriteAsOffset, - { - #[inline] - fn prepare( - &self, + #[allow(clippy::too_many_arguments)] + pub fn create( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, 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::WriteAsUnion for BodyBuilder<::planus::Initialized<9, T>> - where - T: ::planus::WriteAsOffset, - { + + impl ::planus::WriteAs<::planus::Offset> for Message { + type Prepared = ::planus::Offset; + #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(9, (self.0).0.prepare(builder).downcast()) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<9, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::planus::WriteAsOptional<::planus::Offset> for Message { + type Prepared = ::planus::Offset; + #[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()) + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<10, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::planus::WriteAsOffset for Message { #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Message::create(builder, self.type_, &self.data) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<11, T>> - where - T: ::planus::WriteAsOffset, - { + + /// 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] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(11, (self.0).0.prepare(builder).downcast()) + #[allow(clippy::type_complexity)] + pub fn type_(self, value: T0) -> MessageBuilder<(T0,)> + where + T0: ::planus::WriteAsDefault, + { + MessageBuilder((value,)) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<11, T>> - where - T: ::planus::WriteAsOffset, - { + /// Sets the [`type` field](Message#structfield.type_) to the default value. #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + #[allow(clippy::type_complexity)] + pub fn type_as_default(self) -> MessageBuilder<(::planus::DefaultValue,)> { + self.type_(::planus::DefaultValue) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<12, T>> - where - T: ::planus::WriteAsOffset, - { + + impl MessageBuilder<(T0,)> { + /// Setter for the [`data` field](Message#structfield.data). #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(12, (self.0).0.prepare(builder).downcast()) + #[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 ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<12, T>> - where - T: ::planus::WriteAsOffset, - { + impl MessageBuilder<(T0, T1)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Message]. #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset + where + Self: ::planus::WriteAsOffset, + { + ::planus::WriteAsOffset::prepare(&self, builder) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<13, T>> - where - T: ::planus::WriteAsOffset, + + 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::UnionOffset { - ::planus::UnionOffset::new(13, (self.0).0.prepare(builder).downcast()) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<13, T>> - where - T: ::planus::WriteAsOffset, + 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::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<14, T>> - where - T: ::planus::WriteAsOffset, + + impl< + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsUnion, + > ::planus::WriteAsOffset for MessageBuilder<(T0, T1)> { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(14, (self.0).0.prepare(builder).downcast()) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + let (v0, v1) = &self.0; + Message::create(builder, v0, v1) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<14, T>> - where - T: ::planus::WriteAsOffset, - { + /// 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] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + pub fn type_(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "Message", "type_")? + .unwrap_or(self::Type::Request), + ) } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<15, T>> - where - T: ::planus::WriteAsOffset, - { + + /// Getter for the [`data` field](Message#structfield.data). #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(15, (self.0).0.prepare(builder).downcast()) + pub fn data(&self) -> ::planus::Result> { + self.0.access_union_required(1, "Message", "data") } } - 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<'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 ::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<'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 ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<16, T>> - where - T: ::planus::WriteAsOffset, - { + impl<'a> ::planus::TableRead<'a> for MessageRef<'a> { #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + 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 ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<17, T>> - where - T: ::planus::WriteAsOffset< - super::active_speaker_observer::DominantSpeakerNotification, - >, - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(17, (self.0).0.prepare(builder).downcast()) + + 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::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<17, T>> - where - T: ::planus::WriteAsOffset< - super::active_speaker_observer::DominantSpeakerNotification, - >, - { + impl ::planus::VectorWrite<::planus::Offset> for Message { + type Value = ::planus::Offset; + const STRIDE: usize = 4; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { + ::planus::WriteAs::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()) + 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 ::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<'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, - /// Reference to a deserialized [Body]. - #[derive(Copy, Clone, Debug)] - pub enum BodyRef<'a> { - SendRtcpNotification(super::transport::SendRtcpNotificationRef<'a>), - SctpStateChangeNotification(super::transport::SctpStateChangeNotificationRef<'a>), - SendNotification(super::data_producer::SendNotificationRef<'a>), - TraceNotification(super::consumer::TraceNotificationRef<'a>), - IceSelectedTupleChangeNotification( - super::web_rtc_transport::IceSelectedTupleChangeNotificationRef<'a>, - ), - IceStateChangeNotification( - super::web_rtc_transport::IceStateChangeNotificationRef<'a>, - ), - DtlsStateChangeNotification( - super::web_rtc_transport::DtlsStateChangeNotificationRef<'a>, - ), - TupleNotification(super::plain_transport::TupleNotificationRef<'a>), - RtcpTupleNotification(super::plain_transport::RtcpTupleNotificationRef<'a>), - RtcpNotification(super::direct_transport::RtcpNotificationRef<'a>), - ScoreNotification(super::consumer::ScoreNotificationRef<'a>), - VideoOrientationChangeNotification( - super::producer::VideoOrientationChangeNotificationRef<'a>, - ), - LayersChangeNotification(super::consumer::LayersChangeNotificationRef<'a>), - RtpNotification(super::consumer::RtpNotificationRef<'a>), - MessageNotification(super::data_consumer::MessageNotificationRef<'a>), - BufferedAmountLowNotification( - super::data_consumer::BufferedAmountLowNotificationRef<'a>, - ), - DominantSpeakerNotification( - super::active_speaker_observer::DominantSpeakerNotificationRef<'a>, - ), - VolumesNotification(super::audio_level_observer::VolumesNotificationRef<'a>), - } + /// The variant `PRODUCER_SEND` in the enum `Event` + ProducerSend = 1, - impl<'a> ::core::convert::TryFrom> for Body { - type Error = ::planus::Error; + /// The variant `DATAPRODUCER_SEND` in the enum `Event` + DataproducerSend = 2, - fn try_from(value: BodyRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - BodyRef::SendRtcpNotification(value) => { - Self::SendRtcpNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// The variant `WORKER_RUNNING` in the enum `Event` + WorkerRunning = 3, - BodyRef::SctpStateChangeNotification(value) => { - Self::SctpStateChangeNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// The variant `TRANSPORT_SCTP_STATE_CHANGE` in the enum `Event` + TransportSctpStateChange = 4, - BodyRef::SendNotification(value) => { - Self::SendNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// The variant `TRANSPORT_TRACE` in the enum `Event` + TransportTrace = 5, - BodyRef::TraceNotification(value) => { - Self::TraceNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// The variant `WEBRTCTRANSPORT_ICE_SELECTED_TUPLE_CHANGE` in the enum `Event` + WebrtctransportIceSelectedTupleChange = 6, - BodyRef::IceSelectedTupleChangeNotification(value) => { - Self::IceSelectedTupleChangeNotification( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } + /// The variant `WEBRTCTRANSPORT_ICE_STATE_CHANGE` in the enum `Event` + WebrtctransportIceStateChange = 7, - BodyRef::IceStateChangeNotification(value) => { - Self::IceStateChangeNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// The variant `WEBRTCTRANSPORT_DTLS_STATE_CHANGE` in the enum `Event` + WebrtctransportDtlsStateChange = 8, - BodyRef::DtlsStateChangeNotification(value) => { - Self::DtlsStateChangeNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// The variant `PLAINTRANSPORT_TUPLE` in the enum `Event` + PlaintransportTuple = 9, - BodyRef::TupleNotification(value) => { - Self::TupleNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// The variant `PLAINTRANSPORT_RTCP_TUPLE` in the enum `Event` + PlaintransportRtcpTuple = 10, - BodyRef::RtcpTupleNotification(value) => { - Self::RtcpTupleNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// The variant `DIRECTTRANSPORT_RTCP` in the enum `Event` + DirecttransportRtcp = 11, - BodyRef::RtcpNotification(value) => { - Self::RtcpNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// The variant `PRODUCER_SCORE` in the enum `Event` + ProducerScore = 12, - BodyRef::ScoreNotification(value) => { - Self::ScoreNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// The variant `PRODUCER_TRACE` in the enum `Event` + ProducerTrace = 13, - BodyRef::VideoOrientationChangeNotification(value) => { - Self::VideoOrientationChangeNotification( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } + /// The variant `PRODUCER_VIDEO_ORIENTATION_CHANGE` in the enum `Event` + ProducerVideoOrientationChange = 14, - BodyRef::LayersChangeNotification(value) => { - Self::LayersChangeNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// The variant `CONSUMER_PRODUCER_PAUSE` in the enum `Event` + ConsumerProducerPause = 15, - BodyRef::RtpNotification(value) => { - Self::RtpNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// The variant `CONSUMER_PRODUCER_RESUME` in the enum `Event` + ConsumerProducerResume = 16, - BodyRef::MessageNotification(value) => { - Self::MessageNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// The variant `CONSUMER_PRODUCER_CLOSE` in the enum `Event` + ConsumerProducerClose = 17, - BodyRef::BufferedAmountLowNotification(value) => { - Self::BufferedAmountLowNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// The variant `CONSUMER_LAYERS_CHANGE` in the enum `Event` + ConsumerLayersChange = 18, - BodyRef::DominantSpeakerNotification(value) => { - Self::DominantSpeakerNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// The variant `CONSUMER_RTP` in the enum `Event` + ConsumerRtp = 19, - BodyRef::VolumesNotification(value) => { - Self::VolumesNotification(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - }) - } - } + /// The variant `CONSUMER_SCORE` in the enum `Event` + ConsumerScore = 20, - 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::SendRtcpNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::SctpStateChangeNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 3 => ::core::result::Result::Ok(Self::SendNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 4 => ::core::result::Result::Ok(Self::TraceNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 5 => ::core::result::Result::Ok(Self::IceSelectedTupleChangeNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 6 => ::core::result::Result::Ok(Self::IceStateChangeNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 7 => ::core::result::Result::Ok(Self::DtlsStateChangeNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 8 => ::core::result::Result::Ok(Self::TupleNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 9 => ::core::result::Result::Ok(Self::RtcpTupleNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 10 => ::core::result::Result::Ok(Self::RtcpNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 11 => ::core::result::Result::Ok(Self::ScoreNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 12 => ::core::result::Result::Ok(Self::VideoOrientationChangeNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 13 => ::core::result::Result::Ok(Self::LayersChangeNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 14 => ::core::result::Result::Ok(Self::RtpNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 15 => ::core::result::Result::Ok(Self::MessageNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 16 => ::core::result::Result::Ok(Self::BufferedAmountLowNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 17 => ::core::result::Result::Ok(Self::DominantSpeakerNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 18 => ::core::result::Result::Ok(Self::VolumesNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), - } - } - } + /// The variant `CONSUMER_TRACE` in the enum `Event` + ConsumerTrace = 21, - /// The table `Notification` in the namespace `FBS.Notification` - /// - /// Generated from these locations: - /// * Table `Notification` in the file `../worker/fbs/notification.fbs:76` - #[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, - } + /// The variant `DATACONSUMER_BUFFERED_AMOUNT_LOW` in the enum `Event` + DataconsumerBufferedAmountLow = 22, - impl Notification { - /// Creates a [NotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> NotificationBuilder<()> { - NotificationBuilder(()) - } + /// The variant `DATACONSUMER_SCTP_SENDBUFFER_FULL` in the enum `Event` + DataconsumerSctpSendbufferFull = 23, - #[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); + /// The variant `DATACONSUMER_DATAPRODUCER_PAUSE` in the enum `Event` + DataconsumerDataproducerPause = 24, - 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); - } + /// The variant `DATACONSUMER_DATAPRODUCER_RESUME` in the enum `Event` + DataconsumerDataproducerResume = 25, - 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() - } - } + /// The variant `DATACONSUMER_DATAPRODUCER_CLOSE` in the enum `Event` + DataconsumerDataproducerClose = 26, - impl ::planus::WriteAs<::planus::Offset> for Notification { - type Prepared = ::planus::Offset; + /// The variant `DATACONSUMER_MESSAGE` in the enum `Event` + DataconsumerMessage = 27, - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } - } + /// The variant `ACTIVESPEAKEROBSERVER_DOMINANT_SPEAKER` in the enum `Event` + ActivespeakerobserverDominantSpeaker = 28, - impl ::planus::WriteAsOptional<::planus::Offset> for Notification { - type Prepared = ::planus::Offset; + /// The variant `AUDIOLEVELOBSERVER_SILENCE` in the enum `Event` + AudiolevelobserverSilence = 29, - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } + /// The variant `AUDIOLEVELOBSERVER_VOLUMES` in the enum `Event` + AudiolevelobserverVolumes = 30, } - 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) - } + 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, + ]; } - /// 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). + impl ::core::convert::TryFrom for Event { + type Error = ::planus::errors::UnknownEnumTagKind; #[inline] - #[allow(clippy::type_complexity)] - pub fn handler_id(self, value: T0) -> NotificationBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, + fn try_from( + value: u8, + ) -> ::core::result::Result { - NotificationBuilder((value,)) - } - } + #[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), - 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)) + _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { + tag: value as i128, + }), + } } + } - /// Sets the [`event` field](Notification#structfield.event) to the default value. + impl ::core::convert::From for u8 { #[inline] - #[allow(clippy::type_complexity)] - pub fn event_as_default(self) -> NotificationBuilder<(T0, ::planus::DefaultValue)> { - self.event(::planus::DefaultValue) + fn from(value: Event) -> Self { + value as u8 } } - 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)) - } + impl ::planus::Primitive for Event { + const ALIGNMENT: usize = 1; + const SIZE: usize = 1; + } - /// Sets the [`body` field](Notification#structfield.body) to null. + impl ::planus::WriteAsPrimitive for Event { #[inline] - #[allow(clippy::type_complexity)] - pub fn body_as_null(self) -> NotificationBuilder<(T0, T1, ())> { - self.body(()) + fn write( + &self, + cursor: ::planus::Cursor<'_, N>, + buffer_position: u32, + ) { + (*self as u8).write(cursor, buffer_position); } } - impl NotificationBuilder<(T0, T1, T2)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Notification]. + impl ::planus::WriteAs for Event { + type Prepared = Self; + #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) + fn prepare(&self, _builder: &mut ::planus::Builder) -> Event { + *self } } - 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; + impl ::planus::WriteAsDefault for Event { + type Prepared = Self; #[inline] fn prepare( &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + _builder: &mut ::planus::Builder, + default: &Event, + ) -> ::core::option::Option { + if self == default { + ::core::option::Option::None + } else { + ::core::option::Option::Some(*self) + } } } - 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; + impl ::planus::WriteAsOptional for Event { + type Prepared = Self; #[inline] fn prepare( &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + _builder: &mut ::planus::Builder, + ) -> ::core::option::Option { + ::core::option::Option::Some(*self) } } - impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAsOffset for NotificationBuilder<(T0, T1, T2)> - { + impl<'buf> ::planus::TableRead<'buf> for Event { #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2) = &self.0; - Notification::create(builder, v0, v1, v2) + 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)?) } } - /// 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). + impl<'buf> ::planus::VectorReadInner<'buf> for Event { + type Error = ::planus::errors::UnknownEnumTag; + const STRIDE: usize = 1; #[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, - )?)) + 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<'a> ::planus::VectorReadInner<'a> for NotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; + impl ::planus::VectorWrite for Event { + const STRIDE: usize = 1; - 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, - ) - }) - } - } + type Value = Self; - 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) + fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { + *self } #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[Self], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; + 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 - (Self::STRIDE * i) as u32, + buffer_position - 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` + /// The union `Body` in the namespace `FBS.Notification` /// /// Generated from these locations: - /// * Enum `Method` in the file `../worker/fbs/request.fbs:11` + /// * Union `Body` in the file `../worker/fbs/notification.fbs:49` #[derive( - Copy, Clone, Debug, PartialEq, - Eq, PartialOrd, + Eq, 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, + pub enum Body { + /// The variant of type `FBS.Transport.SendRtcpNotification` in the union `Body` + SendRtcpNotification( + ::planus::alloc::boxed::Box, + ), - /// The variant `WORKER_CREATE_WEBRTCSERVER` in the enum `Method` - WorkerCreateWebrtcserver = 4, + /// The variant of type `FBS.Transport.SctpStateChangeNotification` in the union `Body` + SctpStateChangeNotification( + ::planus::alloc::boxed::Box, + ), - /// The variant `WORKER_CREATE_ROUTER` in the enum `Method` - WorkerCreateRouter = 5, + /// The variant of type `FBS.DataProducer.SendNotification` in the union `Body` + SendNotification( + ::planus::alloc::boxed::Box, + ), - /// The variant `WORKER_WEBRTCSERVER_CLOSE` in the enum `Method` - WorkerWebrtcserverClose = 6, + /// The variant of type `FBS.Consumer.TraceNotification` in the union `Body` + TraceNotification(::planus::alloc::boxed::Box), - /// The variant `WORKER_CLOSE_ROUTER` in the enum `Method` - WorkerCloseRouter = 7, + /// The variant of type `FBS.WebRtcTransport.IceSelectedTupleChangeNotification` in the union `Body` + IceSelectedTupleChangeNotification( + ::planus::alloc::boxed::Box< + super::web_rtc_transport::IceSelectedTupleChangeNotification, + >, + ), - /// The variant `WEBRTCSERVER_DUMP` in the enum `Method` - WebrtcserverDump = 8, + /// The variant of type `FBS.WebRtcTransport.IceStateChangeNotification` in the union `Body` + IceStateChangeNotification( + ::planus::alloc::boxed::Box< + super::web_rtc_transport::IceStateChangeNotification, + >, + ), - /// The variant `ROUTER_DUMP` in the enum `Method` - RouterDump = 9, + /// The variant of type `FBS.WebRtcTransport.DtlsStateChangeNotification` in the union `Body` + DtlsStateChangeNotification( + ::planus::alloc::boxed::Box< + super::web_rtc_transport::DtlsStateChangeNotification, + >, + ), - /// The variant `ROUTER_CREATE_WEBRTCTRANSPORT` in the enum `Method` - RouterCreateWebrtctransport = 10, + /// The variant of type `FBS.PlainTransport.TupleNotification` in the union `Body` + TupleNotification( + ::planus::alloc::boxed::Box, + ), - /// The variant `ROUTER_CREATE_WEBRTCTRANSPORT_WITH_SERVER` in the enum `Method` - RouterCreateWebrtctransportWithServer = 11, + /// The variant of type `FBS.PlainTransport.RtcpTupleNotification` in the union `Body` + RtcpTupleNotification( + ::planus::alloc::boxed::Box, + ), - /// The variant `ROUTER_CREATE_PLAINTRANSPORT` in the enum `Method` - RouterCreatePlaintransport = 12, + /// The variant of type `FBS.DirectTransport.RtcpNotification` in the union `Body` + RtcpNotification( + ::planus::alloc::boxed::Box, + ), - /// The variant `ROUTER_CREATE_PIPETRANSPORT` in the enum `Method` - RouterCreatePipetransport = 13, + /// The variant of type `FBS.Consumer.ScoreNotification` in the union `Body` + ScoreNotification(::planus::alloc::boxed::Box), - /// The variant `ROUTER_CREATE_DIRECTTRANSPORT` in the enum `Method` - RouterCreateDirecttransport = 14, + /// The variant of type `FBS.Producer.VideoOrientationChangeNotification` in the union `Body` + VideoOrientationChangeNotification( + ::planus::alloc::boxed::Box< + super::producer::VideoOrientationChangeNotification, + >, + ), - /// The variant `ROUTER_CLOSE_TRANSPORT` in the enum `Method` - RouterCloseTransport = 15, + /// The variant of type `FBS.Consumer.LayersChangeNotification` in the union `Body` + LayersChangeNotification( + ::planus::alloc::boxed::Box, + ), - /// The variant `ROUTER_CREATE_ACTIVESPEAKEROBSERVER` in the enum `Method` - RouterCreateActivespeakerobserver = 16, + /// The variant of type `FBS.Consumer.RtpNotification` in the union `Body` + RtpNotification(::planus::alloc::boxed::Box), - /// The variant `ROUTER_CREATE_AUDIOLEVELOBSERVER` in the enum `Method` - RouterCreateAudiolevelobserver = 17, + /// The variant of type `FBS.DataConsumer.MessageNotification` in the union `Body` + MessageNotification( + ::planus::alloc::boxed::Box, + ), - /// The variant `ROUTER_CLOSE_RTPOBSERVER` in the enum `Method` - RouterCloseRtpobserver = 18, + /// The variant of type `FBS.DataConsumer.BufferedAmountLowNotification` in the union `Body` + BufferedAmountLowNotification( + ::planus::alloc::boxed::Box< + super::data_consumer::BufferedAmountLowNotification, + >, + ), - /// The variant `TRANSPORT_DUMP` in the enum `Method` - TransportDump = 19, + /// The variant of type `FBS.ActiveSpeakerObserver.DominantSpeakerNotification` in the union `Body` + DominantSpeakerNotification( + ::planus::alloc::boxed::Box< + super::active_speaker_observer::DominantSpeakerNotification, + >, + ), - /// The variant `TRANSPORT_GET_STATS` in the enum `Method` - TransportGetStats = 20, + /// The variant of type `FBS.AudioLevelObserver.VolumesNotification` in the union `Body` + VolumesNotification( + ::planus::alloc::boxed::Box, + ), + } - /// The variant `TRANSPORT_CONNECT` in the enum `Method` - TransportConnect = 21, + impl Body { + /// Creates a [BodyBuilder] for serializing an instance of this table. + #[inline] + pub fn builder() -> BodyBuilder<::planus::Uninitialized> { + BodyBuilder(::planus::Uninitialized) + } - /// The variant `TRANSPORT_SET_MAX_INCOMING_BITRATE` in the enum `Method` - TransportSetMaxIncomingBitrate = 22, + #[inline] + pub fn create_send_rtcp_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + } - /// The variant `TRANSPORT_SET_MAX_OUTGOING_BITRATE` in the enum `Method` - TransportSetMaxOutgoingBitrate = 23, + #[inline] + pub fn create_sctp_state_change_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + } - /// The variant `TRANSPORT_SET_MIN_OUTGOING_BITRATE` in the enum `Method` - TransportSetMinOutgoingBitrate = 24, + #[inline] + pub fn create_send_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) + } - /// The variant `TRANSPORT_RESTART_ICE` in the enum `Method` - TransportRestartIce = 25, + #[inline] + pub fn create_trace_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) + } - /// The variant `TRANSPORT_PRODUCE` in the enum `Method` - TransportProduce = 26, + #[inline] + pub fn create_ice_selected_tuple_change_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset< + super::web_rtc_transport::IceSelectedTupleChangeNotification, + >, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) + } - /// The variant `TRANSPORT_PRODUCE_DATA` in the enum `Method` - TransportProduceData = 27, + #[inline] + pub fn create_ice_state_change_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset< + super::web_rtc_transport::IceStateChangeNotification, + >, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(6, value.prepare(builder).downcast()) + } - /// The variant `TRANSPORT_CONSUME` in the enum `Method` - TransportConsume = 28, + #[inline] + pub fn create_dtls_state_change_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset< + super::web_rtc_transport::DtlsStateChangeNotification, + >, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(7, value.prepare(builder).downcast()) + } - /// The variant `TRANSPORT_CONSUME_DATA` in the enum `Method` - TransportConsumeData = 29, + #[inline] + pub fn create_tuple_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(8, value.prepare(builder).downcast()) + } - /// The variant `TRANSPORT_ENABLE_TRACE_EVENT` in the enum `Method` - TransportEnableTraceEvent = 30, + #[inline] + pub fn create_rtcp_tuple_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(9, value.prepare(builder).downcast()) + } - /// The variant `TRANSPORT_CLOSE_PRODUCER` in the enum `Method` - TransportCloseProducer = 31, + #[inline] + pub fn create_rtcp_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(10, value.prepare(builder).downcast()) + } - /// The variant `TRANSPORT_CLOSE_CONSUMER` in the enum `Method` - TransportCloseConsumer = 32, + #[inline] + pub fn create_score_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) + } - /// The variant `TRANSPORT_CLOSE_DATAPRODUCER` in the enum `Method` - TransportCloseDataproducer = 33, + #[inline] + pub fn create_video_orientation_change_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset< + super::producer::VideoOrientationChangeNotification, + >, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) + } - /// The variant `TRANSPORT_CLOSE_DATACONSUMER` in the enum `Method` - TransportCloseDataconsumer = 34, + #[inline] + pub fn create_layers_change_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) + } - /// The variant `PLAINTRANSPORT_CONNECT` in the enum `Method` - PlaintransportConnect = 35, + #[inline] + pub fn create_rtp_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) + } - /// The variant `PIPETRANSPORT_CONNECT` in the enum `Method` - PipetransportConnect = 36, + #[inline] + pub fn create_message_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) + } - /// The variant `WEBRTCTRANSPORT_CONNECT` in the enum `Method` - WebrtctransportConnect = 37, + #[inline] + pub fn create_buffered_amount_low_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset< + super::data_consumer::BufferedAmountLowNotification, + >, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) + } - /// The variant `PRODUCER_DUMP` in the enum `Method` - ProducerDump = 38, + #[inline] + pub fn create_dominant_speaker_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset< + super::active_speaker_observer::DominantSpeakerNotification, + >, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) + } - /// The variant `PRODUCER_GET_STATS` in the enum `Method` - ProducerGetStats = 39, + #[inline] + pub fn create_volumes_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset< + super::audio_level_observer::VolumesNotification, + >, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(18, value.prepare(builder).downcast()) + } + } - /// The variant `PRODUCER_PAUSE` in the enum `Method` - ProducerPause = 40, + impl ::planus::WriteAsUnion for Body { + #[inline] + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + match self { + Self::SendRtcpNotification(value) => { + Self::create_send_rtcp_notification(builder, value) + } + Self::SctpStateChangeNotification(value) => { + Self::create_sctp_state_change_notification(builder, value) + } + Self::SendNotification(value) => { + Self::create_send_notification(builder, value) + } + Self::TraceNotification(value) => { + Self::create_trace_notification(builder, value) + } + Self::IceSelectedTupleChangeNotification(value) => { + Self::create_ice_selected_tuple_change_notification(builder, value) + } + Self::IceStateChangeNotification(value) => { + Self::create_ice_state_change_notification(builder, value) + } + Self::DtlsStateChangeNotification(value) => { + Self::create_dtls_state_change_notification(builder, value) + } + Self::TupleNotification(value) => { + Self::create_tuple_notification(builder, value) + } + Self::RtcpTupleNotification(value) => { + Self::create_rtcp_tuple_notification(builder, value) + } + Self::RtcpNotification(value) => { + Self::create_rtcp_notification(builder, value) + } + Self::ScoreNotification(value) => { + Self::create_score_notification(builder, value) + } + Self::VideoOrientationChangeNotification(value) => { + Self::create_video_orientation_change_notification(builder, value) + } + Self::LayersChangeNotification(value) => { + Self::create_layers_change_notification(builder, value) + } + Self::RtpNotification(value) => { + Self::create_rtp_notification(builder, value) + } + Self::MessageNotification(value) => { + Self::create_message_notification(builder, value) + } + Self::BufferedAmountLowNotification(value) => { + Self::create_buffered_amount_low_notification(builder, value) + } + Self::DominantSpeakerNotification(value) => { + Self::create_dominant_speaker_notification(builder, value) + } + Self::VolumesNotification(value) => { + Self::create_volumes_notification(builder, value) + } + } + } + } - /// The variant `PRODUCER_RESUME` in the enum `Method` - ProducerResume = 41, + 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)) + } + } - /// The variant `PRODUCER_ENABLE_TRACE_EVENT` in the enum `Method` - ProducerEnableTraceEvent = 42, + /// 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); - /// 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, + impl BodyBuilder<::planus::Uninitialized> { + /// Creates an instance of the [`SendRtcpNotification` variant](Body#variant.SendRtcpNotification). + #[inline] + pub fn send_rtcp_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - /// The variant `DATACONSUMER_DUMP` in the enum `Method` - DataconsumerDump = 55, + /// Creates an instance of the [`SctpStateChangeNotification` variant](Body#variant.SctpStateChangeNotification). + #[inline] + pub fn sctp_state_change_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<2, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - /// The variant `DATACONSUMER_GET_STATS` in the enum `Method` - DataconsumerGetStats = 56, + /// Creates an instance of the [`SendNotification` variant](Body#variant.SendNotification). + #[inline] + pub fn send_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<3, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - /// The variant `DATACONSUMER_PAUSE` in the enum `Method` - DataconsumerPause = 57, + /// Creates an instance of the [`TraceNotification` variant](Body#variant.TraceNotification). + #[inline] + pub fn trace_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<4, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - /// The variant `DATACONSUMER_RESUME` in the enum `Method` - DataconsumerResume = 58, + /// Creates an instance of the [`IceSelectedTupleChangeNotification` variant](Body#variant.IceSelectedTupleChangeNotification). + #[inline] + pub fn ice_selected_tuple_change_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<5, T>> + where + T: ::planus::WriteAsOffset< + super::web_rtc_transport::IceSelectedTupleChangeNotification, + >, + { + BodyBuilder(::planus::Initialized(value)) + } - /// The variant `DATACONSUMER_GET_BUFFERED_AMOUNT` in the enum `Method` - DataconsumerGetBufferedAmount = 59, + /// Creates an instance of the [`IceStateChangeNotification` variant](Body#variant.IceStateChangeNotification). + #[inline] + pub fn ice_state_change_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<6, T>> + where + T: ::planus::WriteAsOffset< + super::web_rtc_transport::IceStateChangeNotification, + >, + { + BodyBuilder(::planus::Initialized(value)) + } - /// The variant `DATACONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD` in the enum `Method` - DataconsumerSetBufferedAmountLowThreshold = 60, + /// Creates an instance of the [`DtlsStateChangeNotification` variant](Body#variant.DtlsStateChangeNotification). + #[inline] + pub fn dtls_state_change_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<7, T>> + where + T: ::planus::WriteAsOffset< + super::web_rtc_transport::DtlsStateChangeNotification, + >, + { + BodyBuilder(::planus::Initialized(value)) + } - /// The variant `DATACONSUMER_SEND` in the enum `Method` - DataconsumerSend = 61, + /// Creates an instance of the [`TupleNotification` variant](Body#variant.TupleNotification). + #[inline] + pub fn tuple_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<8, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - /// The variant `DATACONSUMER_SET_SUBCHANNELS` in the enum `Method` - DataconsumerSetSubchannels = 62, + /// Creates an instance of the [`RtcpTupleNotification` variant](Body#variant.RtcpTupleNotification). + #[inline] + pub fn rtcp_tuple_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<9, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - /// The variant `RTPOBSERVER_PAUSE` in the enum `Method` - RtpobserverPause = 63, + /// Creates an instance of the [`RtcpNotification` variant](Body#variant.RtcpNotification). + #[inline] + pub fn rtcp_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<10, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - /// The variant `RTPOBSERVER_RESUME` in the enum `Method` - RtpobserverResume = 64, + /// Creates an instance of the [`ScoreNotification` variant](Body#variant.ScoreNotification). + #[inline] + pub fn score_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<11, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - /// The variant `RTPOBSERVER_ADD_PRODUCER` in the enum `Method` - RtpobserverAddProducer = 65, + /// Creates an instance of the [`VideoOrientationChangeNotification` variant](Body#variant.VideoOrientationChangeNotification). + #[inline] + pub fn video_orientation_change_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<12, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - /// The variant `RTPOBSERVER_REMOVE_PRODUCER` in the enum `Method` - RtpobserverRemoveProducer = 66, - } + /// Creates an instance of the [`LayersChangeNotification` variant](Body#variant.LayersChangeNotification). + #[inline] + pub fn layers_change_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<13, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - 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, - ]; - } + /// Creates an instance of the [`RtpNotification` variant](Body#variant.RtpNotification). + #[inline] + pub fn rtp_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<14, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - impl ::core::convert::TryFrom for Method { - type Error = ::planus::errors::UnknownEnumTagKind; + /// Creates an instance of the [`MessageNotification` variant](Body#variant.MessageNotification). #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result + pub fn message_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<15, T>> + where + T: ::planus::WriteAsOffset, { - #[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), + BodyBuilder(::planus::Initialized(value)) + } - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } + /// Creates an instance of the [`BufferedAmountLowNotification` variant](Body#variant.BufferedAmountLowNotification). + #[inline] + pub fn buffered_amount_low_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<16, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - } - impl ::core::convert::From for u8 { + /// Creates an instance of the [`DominantSpeakerNotification` variant](Body#variant.DominantSpeakerNotification). #[inline] - fn from(value: Method) -> Self { - value as u8 + pub fn dominant_speaker_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<17, T>> + where + T: ::planus::WriteAsOffset< + super::active_speaker_observer::DominantSpeakerNotification, + >, + { + BodyBuilder(::planus::Initialized(value)) } - } - impl ::planus::Primitive for Method { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; + /// Creates an instance of the [`VolumesNotification` variant](Body#variant.VolumesNotification). + #[inline] + pub fn volumes_notification( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<18, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } } - impl ::planus::WriteAsPrimitive for Method { + impl BodyBuilder<::planus::Initialized> { + /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Body]. #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); + pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset + where + Self: ::planus::WriteAsUnion, + { + ::planus::WriteAsUnion::prepare(&self, builder) } } - impl ::planus::WriteAs for Method { - type Prepared = Self; - + impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, + { #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Method { - *self + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) } } - impl ::planus::WriteAsDefault for Method { - type Prepared = Self; - + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, + { #[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) - } + 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::WriteAsOptional for Method { - type Prepared = Self; - + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<2, T>> + where + T: ::planus::WriteAsOffset, + { #[inline] fn prepare( &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - - impl<'buf> ::planus::TableRead<'buf> for Method { + impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<3, T>> + where + T: ::planus::WriteAsOffset, + { #[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)?) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(3, (self.0).0.prepare(builder).downcast()) } } - impl<'buf> ::planus::VectorReadInner<'buf> for Method { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<3, T>> + where + T: ::planus::WriteAsOffset, + { #[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, - ) - }) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - - impl ::planus::VectorWrite for Method { - const STRIDE: usize = 1; - - type Value = Self; - + impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<4, T>> + where + T: ::planus::WriteAsOffset, + { #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self + 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] - 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, - ); - } + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - - /// 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 of type `FBS.Worker.UpdateSettingsRequest` in the union `Body` - UpdateSettingsRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Worker.CreateWebRtcServerRequest` in the union `Body` - CreateWebRtcServerRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Worker.CloseWebRtcServerRequest` in the union `Body` - CloseWebRtcServerRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Worker.CreateRouterRequest` in the union `Body` - CreateRouterRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Worker.CloseRouterRequest` in the union `Body` - CloseRouterRequest(::planus::alloc::boxed::Box), - - /// The variant of type `FBS.Router.CreateWebRtcTransportRequest` in the union `Body` - CreateWebRtcTransportRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Router.CreatePlainTransportRequest` in the union `Body` - CreatePlainTransportRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Router.CreatePipeTransportRequest` in the union `Body` - CreatePipeTransportRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Router.CreateDirectTransportRequest` in the union `Body` - CreateDirectTransportRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Router.CreateActiveSpeakerObserverRequest` in the union `Body` - CreateActiveSpeakerObserverRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Router.CreateAudioLevelObserverRequest` in the union `Body` - CreateAudioLevelObserverRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Router.CloseTransportRequest` in the union `Body` - CloseTransportRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Router.CloseRtpObserverRequest` in the union `Body` - CloseRtpObserverRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Transport.SetMaxIncomingBitrateRequest` in the union `Body` - SetMaxIncomingBitrateRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Transport.SetMaxOutgoingBitrateRequest` in the union `Body` - SetMaxOutgoingBitrateRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Transport.SetMinOutgoingBitrateRequest` in the union `Body` - SetMinOutgoingBitrateRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Transport.ProduceRequest` in the union `Body` - ProduceRequest(::planus::alloc::boxed::Box), - - /// The variant of type `FBS.Transport.ConsumeRequest` in the union `Body` - ConsumeRequest(::planus::alloc::boxed::Box), - - /// The variant of type `FBS.Transport.ProduceDataRequest` in the union `Body` - ProduceDataRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Transport.ConsumeDataRequest` in the union `Body` - ConsumeDataRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Consumer.EnableTraceEventRequest` in the union `Body` - EnableTraceEventRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Transport.CloseProducerRequest` in the union `Body` - CloseProducerRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Transport.CloseConsumerRequest` in the union `Body` - CloseConsumerRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Transport.CloseDataProducerRequest` in the union `Body` - CloseDataProducerRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Transport.CloseDataConsumerRequest` in the union `Body` - CloseDataConsumerRequest( - ::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 of type `FBS.WebRtcTransport.ConnectRequest` in the union `Body` - ConnectRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Consumer.SetPreferredLayersRequest` in the union `Body` - SetPreferredLayersRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.Consumer.SetPriorityRequest` in the union `Body` - SetPriorityRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.DataConsumer.SetBufferedAmountLowThresholdRequest` in the union `Body` - SetBufferedAmountLowThresholdRequest( - ::planus::alloc::boxed::Box< - super::data_consumer::SetBufferedAmountLowThresholdRequest, - >, - ), - - /// The variant of type `FBS.DataConsumer.SendRequest` in the union `Body` - SendRequest(::planus::alloc::boxed::Box), - - /// The variant of type `FBS.DataConsumer.SetSubchannelsRequest` in the union `Body` - SetSubchannelsRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.RtpObserver.AddProducerRequest` in the union `Body` - AddProducerRequest( - ::planus::alloc::boxed::Box, - ), - - /// The variant of type `FBS.RtpObserver.RemoveProducerRequest` in the union `Body` - RemoveProducerRequest( - ::planus::alloc::boxed::Box, - ), - } - - impl Body { - /// Creates a [BodyBuilder] for serializing an instance of this table. + impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<5, T>> + where + T: ::planus::WriteAsOffset< + super::web_rtc_transport::IceSelectedTupleChangeNotification, + >, + { #[inline] - pub fn builder() -> BodyBuilder<::planus::Uninitialized> { - BodyBuilder(::planus::Uninitialized) + 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< + super::web_rtc_transport::IceSelectedTupleChangeNotification, + >, + { #[inline] - pub fn create_update_settings_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_create_web_rtc_server_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + 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] - pub fn create_close_web_rtc_server_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_create_router_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) + 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] - pub fn create_close_router_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_create_web_rtc_transport_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(6, value.prepare(builder).downcast()) + 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] - pub fn create_create_plain_transport_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(7, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_create_pipe_transport_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(8, value.prepare(builder).downcast()) + 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] - pub fn create_create_direct_transport_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(9, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_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()) + 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] - pub fn create_create_audio_level_observer_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_close_transport_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) + 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] - pub fn create_close_rtp_observer_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_set_max_incoming_bitrate_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) + 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] - pub fn create_set_max_outgoing_bitrate_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_set_min_outgoing_bitrate_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) + 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] - pub fn create_produce_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_consume_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(18, value.prepare(builder).downcast()) + 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] - pub fn create_produce_data_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(19, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_consume_data_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(20, value.prepare(builder).downcast()) + 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] - pub fn create_enable_trace_event_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(21, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_close_producer_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(22, value.prepare(builder).downcast()) + ) -> ::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< + super::active_speaker_observer::DominantSpeakerNotification, + >, + { + #[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< + super::active_speaker_observer::DominantSpeakerNotification, + >, + { #[inline] - pub fn create_close_consumer_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(23, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_close_data_producer_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(24, value.prepare(builder).downcast()) + ) -> ::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> { + SendRtcpNotification(super::transport::SendRtcpNotificationRef<'a>), + SctpStateChangeNotification(super::transport::SctpStateChangeNotificationRef<'a>), + SendNotification(super::data_producer::SendNotificationRef<'a>), + TraceNotification(super::consumer::TraceNotificationRef<'a>), + IceSelectedTupleChangeNotification( + super::web_rtc_transport::IceSelectedTupleChangeNotificationRef<'a>, + ), + IceStateChangeNotification( + super::web_rtc_transport::IceStateChangeNotificationRef<'a>, + ), + DtlsStateChangeNotification( + super::web_rtc_transport::DtlsStateChangeNotificationRef<'a>, + ), + TupleNotification(super::plain_transport::TupleNotificationRef<'a>), + RtcpTupleNotification(super::plain_transport::RtcpTupleNotificationRef<'a>), + RtcpNotification(super::direct_transport::RtcpNotificationRef<'a>), + ScoreNotification(super::consumer::ScoreNotificationRef<'a>), + VideoOrientationChangeNotification( + super::producer::VideoOrientationChangeNotificationRef<'a>, + ), + LayersChangeNotification(super::consumer::LayersChangeNotificationRef<'a>), + RtpNotification(super::consumer::RtpNotificationRef<'a>), + MessageNotification(super::data_consumer::MessageNotificationRef<'a>), + BufferedAmountLowNotification( + super::data_consumer::BufferedAmountLowNotificationRef<'a>, + ), + DominantSpeakerNotification( + super::active_speaker_observer::DominantSpeakerNotificationRef<'a>, + ), + VolumesNotification(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::SendRtcpNotification(value) => { + Self::SendRtcpNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SctpStateChangeNotification(value) => { + Self::SctpStateChangeNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SendNotification(value) => { + Self::SendNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::TraceNotification(value) => { + Self::TraceNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::IceSelectedTupleChangeNotification(value) => { + Self::IceSelectedTupleChangeNotification( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::IceStateChangeNotification(value) => { + Self::IceStateChangeNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::DtlsStateChangeNotification(value) => { + Self::DtlsStateChangeNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::TupleNotification(value) => { + Self::TupleNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::RtcpTupleNotification(value) => { + Self::RtcpTupleNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::RtcpNotification(value) => { + Self::RtcpNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::ScoreNotification(value) => { + Self::ScoreNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::VideoOrientationChangeNotification(value) => { + Self::VideoOrientationChangeNotification( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::LayersChangeNotification(value) => { + Self::LayersChangeNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::RtpNotification(value) => { + Self::RtpNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::MessageNotification(value) => { + Self::MessageNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::BufferedAmountLowNotification(value) => { + Self::BufferedAmountLowNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::DominantSpeakerNotification(value) => { + Self::DominantSpeakerNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::VolumesNotification(value) => { + Self::VolumesNotification(::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::SendRtcpNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 2 => ::core::result::Result::Ok(Self::SctpStateChangeNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 3 => ::core::result::Result::Ok(Self::SendNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 4 => ::core::result::Result::Ok(Self::TraceNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 5 => ::core::result::Result::Ok(Self::IceSelectedTupleChangeNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 6 => ::core::result::Result::Ok(Self::IceStateChangeNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 7 => ::core::result::Result::Ok(Self::DtlsStateChangeNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 8 => ::core::result::Result::Ok(Self::TupleNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 9 => ::core::result::Result::Ok(Self::RtcpTupleNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 10 => ::core::result::Result::Ok(Self::RtcpNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 11 => ::core::result::Result::Ok(Self::ScoreNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 12 => ::core::result::Result::Ok(Self::VideoOrientationChangeNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 13 => ::core::result::Result::Ok(Self::LayersChangeNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 14 => ::core::result::Result::Ok(Self::RtpNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 15 => ::core::result::Result::Ok(Self::MessageNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 16 => ::core::result::Result::Ok(Self::BufferedAmountLowNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 17 => ::core::result::Result::Ok(Self::DominantSpeakerNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 18 => ::core::result::Result::Ok(Self::VolumesNotification( + ::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:76` + #[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 create_close_data_consumer_request( + pub fn builder() -> NotificationBuilder<()> { + NotificationBuilder(()) + } + + #[allow(clippy::too_many_arguments)] + pub fn create( builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(25, value.prepare(builder).downcast()) + 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] - pub fn create_plain_transport_connect_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(26, value.prepare(builder).downcast()) + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } + } + + impl ::planus::WriteAsOptional<::planus::Offset> for Notification { + type Prepared = ::planus::Offset; #[inline] - pub fn create_pipe_transport_connect_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(27, value.prepare(builder).downcast()) + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } + } + impl ::planus::WriteAsOffset for Notification { #[inline] - pub fn create_connect_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(28, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_set_preferred_layers_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(29, value.prepare(builder).downcast()) + #[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] - pub fn create_set_priority_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(30, value.prepare(builder).downcast()) + #[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] - pub fn create_set_buffered_amount_low_threshold_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset< - super::data_consumer::SetBufferedAmountLowThresholdRequest, - >, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(31, value.prepare(builder).downcast()) + #[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] - pub fn create_send_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(32, value.prepare(builder).downcast()) + #[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] - pub fn create_set_subchannels_request( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(33, value.prepare(builder).downcast()) + #[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 create_add_producer_request( + pub fn finish( + self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(34, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_remove_producer_request( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(35, value.prepare(builder).downcast()) + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsUnion for Body { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - match self { - Self::UpdateSettingsRequest(value) => { - Self::create_update_settings_request(builder, value) - } - Self::CreateWebRtcServerRequest(value) => { - Self::create_create_web_rtc_server_request(builder, value) - } - Self::CloseWebRtcServerRequest(value) => { - Self::create_close_web_rtc_server_request(builder, value) - } - Self::CreateRouterRequest(value) => { - Self::create_create_router_request(builder, value) - } - Self::CloseRouterRequest(value) => { - Self::create_close_router_request(builder, value) - } - Self::CreateWebRtcTransportRequest(value) => { - Self::create_create_web_rtc_transport_request(builder, value) - } - Self::CreatePlainTransportRequest(value) => { - Self::create_create_plain_transport_request(builder, value) - } - Self::CreatePipeTransportRequest(value) => { - Self::create_create_pipe_transport_request(builder, value) - } - Self::CreateDirectTransportRequest(value) => { - Self::create_create_direct_transport_request(builder, value) - } - Self::CreateActiveSpeakerObserverRequest(value) => { - Self::create_create_active_speaker_observer_request(builder, value) - } - Self::CreateAudioLevelObserverRequest(value) => { - Self::create_create_audio_level_observer_request(builder, value) - } - Self::CloseTransportRequest(value) => { - Self::create_close_transport_request(builder, value) - } - Self::CloseRtpObserverRequest(value) => { - Self::create_close_rtp_observer_request(builder, value) - } - Self::SetMaxIncomingBitrateRequest(value) => { - Self::create_set_max_incoming_bitrate_request(builder, value) - } - Self::SetMaxOutgoingBitrateRequest(value) => { - Self::create_set_max_outgoing_bitrate_request(builder, value) - } - Self::SetMinOutgoingBitrateRequest(value) => { - Self::create_set_min_outgoing_bitrate_request(builder, value) - } - Self::ProduceRequest(value) => Self::create_produce_request(builder, value), - Self::ConsumeRequest(value) => Self::create_consume_request(builder, value), - Self::ProduceDataRequest(value) => { - Self::create_produce_data_request(builder, value) - } - Self::ConsumeDataRequest(value) => { - Self::create_consume_data_request(builder, value) - } - Self::EnableTraceEventRequest(value) => { - Self::create_enable_trace_event_request(builder, value) - } - Self::CloseProducerRequest(value) => { - Self::create_close_producer_request(builder, value) - } - Self::CloseConsumerRequest(value) => { - Self::create_close_consumer_request(builder, value) - } - Self::CloseDataProducerRequest(value) => { - Self::create_close_data_producer_request(builder, value) - } - Self::CloseDataConsumerRequest(value) => { - Self::create_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::ConnectRequest(value) => Self::create_connect_request(builder, value), - Self::SetPreferredLayersRequest(value) => { - Self::create_set_preferred_layers_request(builder, value) - } - Self::SetPriorityRequest(value) => { - Self::create_set_priority_request(builder, value) - } - Self::SetBufferedAmountLowThresholdRequest(value) => { - Self::create_set_buffered_amount_low_threshold_request(builder, value) - } - Self::SendRequest(value) => Self::create_send_request(builder, value), - Self::SetSubchannelsRequest(value) => { - Self::create_set_subchannels_request(builder, value) - } - Self::AddProducerRequest(value) => { - Self::create_add_producer_request(builder, value) - } - Self::RemoveProducerRequest(value) => { - Self::create_remove_producer_request(builder, value) - } - } - } - } + 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; - 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)) + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::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 [`UpdateSettingsRequest` variant](Body#variant.UpdateSettingsRequest). + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, + T2: ::planus::WriteAsOptionalUnion, + > ::planus::WriteAsOffset for NotificationBuilder<(T0, T1, T2)> + { #[inline] - pub fn update_settings_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + let (v0, v1, v2) = &self.0; + Notification::create(builder, v0, v1, v2) } + } - /// Creates an instance of the [`CreateWebRtcServerRequest` variant](Body#variant.CreateWebRtcServerRequest). - #[inline] - pub fn create_web_rtc_server_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// Reference to a deserialized [Notification]. + #[derive(Copy, Clone)] + pub struct NotificationRef<'a>(::planus::table_reader::Table<'a>); - /// Creates an instance of the [`CloseWebRtcServerRequest` variant](Body#variant.CloseWebRtcServerRequest). + impl<'a> NotificationRef<'a> { + /// Getter for the [`handler_id` field](Notification#structfield.handler_id). #[inline] - pub fn close_web_rtc_server_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + pub fn handler_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "Notification", "handler_id") } - /// Creates an instance of the [`CreateRouterRequest` variant](Body#variant.CreateRouterRequest). + /// Getter for the [`event` field](Notification#structfield.event). #[inline] - pub fn create_router_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + pub fn event(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "Notification", "event")? + .unwrap_or(self::Event::TransportSendRtcp), + ) } - /// Creates an instance of the [`CloseRouterRequest` variant](Body#variant.CloseRouterRequest). + /// Getter for the [`body` field](Notification#structfield.body). #[inline] - pub fn close_router_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + pub fn body(&self) -> ::planus::Result<::core::option::Option>> { + self.0.access_union(2, "Notification", "body") } + } - /// Creates an instance of the [`CreateWebRtcTransportRequest` variant](Body#variant.CreateWebRtcTransportRequest). - #[inline] - pub fn create_web_rtc_transport_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<6, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + 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() } + } - /// Creates an instance of the [`CreatePlainTransportRequest` variant](Body#variant.CreatePlainTransportRequest). - #[inline] - pub fn create_plain_transport_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<7, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + impl<'a> ::core::convert::TryFrom> for Notification { + type Error = ::planus::Error; - /// Creates an instance of the [`CreatePipeTransportRequest` variant](Body#variant.CreatePipeTransportRequest). - #[inline] - pub fn create_pipe_transport_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<8, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + #[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 + }, + }) } + } - /// Creates an instance of the [`CreateDirectTransportRequest` variant](Body#variant.CreateDirectTransportRequest). + impl<'a> ::planus::TableRead<'a> for NotificationRef<'a> { #[inline] - pub fn create_direct_transport_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<9, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + 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, + )?)) } + } - /// Creates an instance of the [`CreateActiveSpeakerObserverRequest` variant](Body#variant.CreateActiveSpeakerObserverRequest). - #[inline] - pub fn create_active_speaker_observer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<10, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + impl<'a> ::planus::VectorReadInner<'a> for NotificationRef<'a> { + type Error = ::planus::Error; + const STRIDE: usize = 4; - /// Creates an instance of the [`CreateAudioLevelObserverRequest` variant](Body#variant.CreateAudioLevelObserverRequest). - #[inline] - pub fn create_audio_level_observer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<11, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + 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, + ) + }) } + } - /// Creates an instance of the [`CloseTransportRequest` variant](Body#variant.CloseTransportRequest). + impl ::planus::VectorWrite<::planus::Offset> for Notification { + type Value = ::planus::Offset; + const STRIDE: usize = 4; #[inline] - pub fn close_transport_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<12, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { + ::planus::WriteAs::prepare(self, builder) } - /// Creates an instance of the [`CloseRtpObserverRequest` variant](Body#variant.CloseRtpObserverRequest). #[inline] - pub fn close_rtp_observer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<13, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + 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, + ); + } } + } - /// Creates an instance of the [`SetMaxIncomingBitrateRequest` variant](Body#variant.SetMaxIncomingBitrateRequest). - #[inline] - pub fn set_max_incoming_bitrate_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<14, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + 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, - /// Creates an instance of the [`SetMaxOutgoingBitrateRequest` variant](Body#variant.SetMaxOutgoingBitrateRequest). - #[inline] - pub fn set_max_outgoing_bitrate_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<15, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `WORKER_DUMP` in the enum `Method` + WorkerDump = 1, - /// Creates an instance of the [`SetMinOutgoingBitrateRequest` variant](Body#variant.SetMinOutgoingBitrateRequest). - #[inline] - pub fn set_min_outgoing_bitrate_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<16, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `WORKER_GET_RESOURCE_USAGE` in the enum `Method` + WorkerGetResourceUsage = 2, - /// Creates an instance of the [`ProduceRequest` variant](Body#variant.ProduceRequest). - #[inline] - pub fn produce_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<17, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `WORKER_UPDATE_SETTINGS` in the enum `Method` + WorkerUpdateSettings = 3, - /// Creates an instance of the [`ConsumeRequest` variant](Body#variant.ConsumeRequest). - #[inline] - pub fn consume_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<18, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `WORKER_CREATE_WEBRTCSERVER` in the enum `Method` + WorkerCreateWebrtcserver = 4, - /// Creates an instance of the [`ProduceDataRequest` variant](Body#variant.ProduceDataRequest). - #[inline] - pub fn produce_data_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<19, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `WORKER_CREATE_ROUTER` in the enum `Method` + WorkerCreateRouter = 5, - /// Creates an instance of the [`ConsumeDataRequest` variant](Body#variant.ConsumeDataRequest). - #[inline] - pub fn consume_data_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<20, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `WORKER_WEBRTCSERVER_CLOSE` in the enum `Method` + WorkerWebrtcserverClose = 6, - /// Creates an instance of the [`EnableTraceEventRequest` variant](Body#variant.EnableTraceEventRequest). - #[inline] - pub fn enable_trace_event_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<21, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `WORKER_CLOSE_ROUTER` in the enum `Method` + WorkerCloseRouter = 7, - /// Creates an instance of the [`CloseProducerRequest` variant](Body#variant.CloseProducerRequest). - #[inline] - pub fn close_producer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<22, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `WEBRTCSERVER_DUMP` in the enum `Method` + WebrtcserverDump = 8, - /// Creates an instance of the [`CloseConsumerRequest` variant](Body#variant.CloseConsumerRequest). - #[inline] - pub fn close_consumer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<23, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `ROUTER_DUMP` in the enum `Method` + RouterDump = 9, - /// Creates an instance of the [`CloseDataProducerRequest` variant](Body#variant.CloseDataProducerRequest). - #[inline] - pub fn close_data_producer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<24, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `ROUTER_CREATE_WEBRTCTRANSPORT` in the enum `Method` + RouterCreateWebrtctransport = 10, - /// Creates an instance of the [`CloseDataConsumerRequest` variant](Body#variant.CloseDataConsumerRequest). - #[inline] - pub fn close_data_consumer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<25, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `ROUTER_CREATE_WEBRTCTRANSPORT_WITH_SERVER` in the enum `Method` + RouterCreateWebrtctransportWithServer = 11, - /// 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)) - } + /// The variant `ROUTER_CREATE_PLAINTRANSPORT` in the enum `Method` + RouterCreatePlaintransport = 12, - /// 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)) - } + /// The variant `ROUTER_CREATE_PIPETRANSPORT` in the enum `Method` + RouterCreatePipetransport = 13, - /// Creates an instance of the [`ConnectRequest` variant](Body#variant.ConnectRequest). - #[inline] - pub fn connect_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<28, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `ROUTER_CREATE_DIRECTTRANSPORT` in the enum `Method` + RouterCreateDirecttransport = 14, - /// Creates an instance of the [`SetPreferredLayersRequest` variant](Body#variant.SetPreferredLayersRequest). - #[inline] - pub fn set_preferred_layers_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<29, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `ROUTER_CLOSE_TRANSPORT` in the enum `Method` + RouterCloseTransport = 15, - /// Creates an instance of the [`SetPriorityRequest` variant](Body#variant.SetPriorityRequest). - #[inline] - pub fn set_priority_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<30, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `ROUTER_CREATE_ACTIVESPEAKEROBSERVER` in the enum `Method` + RouterCreateActivespeakerobserver = 16, - /// Creates an instance of the [`SetBufferedAmountLowThresholdRequest` variant](Body#variant.SetBufferedAmountLowThresholdRequest). - #[inline] - pub fn set_buffered_amount_low_threshold_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<31, T>> - where - T: ::planus::WriteAsOffset< - super::data_consumer::SetBufferedAmountLowThresholdRequest, - >, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `ROUTER_CREATE_AUDIOLEVELOBSERVER` in the enum `Method` + RouterCreateAudiolevelobserver = 17, - /// Creates an instance of the [`SendRequest` variant](Body#variant.SendRequest). - #[inline] - pub fn send_request(self, value: T) -> BodyBuilder<::planus::Initialized<32, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `ROUTER_CLOSE_RTPOBSERVER` in the enum `Method` + RouterCloseRtpobserver = 18, - /// Creates an instance of the [`SetSubchannelsRequest` variant](Body#variant.SetSubchannelsRequest). - #[inline] - pub fn set_subchannels_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<33, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `TRANSPORT_DUMP` in the enum `Method` + TransportDump = 19, - /// Creates an instance of the [`AddProducerRequest` variant](Body#variant.AddProducerRequest). - #[inline] - pub fn add_producer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<34, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// The variant `TRANSPORT_GET_STATS` in the enum `Method` + TransportGetStats = 20, - /// Creates an instance of the [`RemoveProducerRequest` variant](Body#variant.RemoveProducerRequest). - #[inline] - pub fn remove_producer_request( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<35, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// 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 BodyBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Body]. + 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] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset - where - Self: ::planus::WriteAsUnion, + fn try_from( + value: u8, + ) -> ::core::result::Result { - ::planus::WriteAsUnion::prepare(&self, builder) + #[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 ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::core::convert::From for u8 { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) + fn from(value: Method) -> Self { + value as u8 } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::planus::Primitive for Method { + const ALIGNMENT: usize = 1; + const SIZE: usize = 1; + } + + impl ::planus::WriteAsPrimitive for Method { #[inline] - fn prepare( + fn write( &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + cursor: ::planus::Cursor<'_, N>, + buffer_position: u32, + ) { + (*self as u8).write(cursor, buffer_position); } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { + + impl ::planus::WriteAs for Method { + type Prepared = Self; + #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) + fn prepare(&self, _builder: &mut ::planus::Builder) -> Method { + *self } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::planus::WriteAsDefault for Method { + type Prepared = Self; + #[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()) + _builder: &mut ::planus::Builder, + default: &Method, + ) -> ::core::option::Option { + if self == default { + ::core::option::Option::None + } else { + ::core::option::Option::Some(*self) + } } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::planus::WriteAsOptional for Method { + type Prepared = Self; + #[inline] fn prepare( &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + _builder: &mut ::planus::Builder, + ) -> ::core::option::Option { + ::core::option::Option::Some(*self) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { + + impl<'buf> ::planus::TableRead<'buf> for Method { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, (self.0).0.prepare(builder).downcast()) + 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 ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { + impl<'buf> ::planus::VectorReadInner<'buf> for Method { + type Error = ::planus::errors::UnknownEnumTag; + const STRIDE: usize = 1; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + 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::WriteAsUnion for BodyBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, - { + + impl ::planus::VectorWrite for Method { + const STRIDE: usize = 1; + + type Value = Self; + #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(5, (self.0).0.prepare(builder).downcast()) + fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { + *self } - } - 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)) + 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, + ); + } } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<6, T>> - where - T: ::planus::WriteAsOffset, - { + + /// 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 of type `FBS.Worker.UpdateSettingsRequest` in the union `Body` + UpdateSettingsRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Worker.CreateWebRtcServerRequest` in the union `Body` + CreateWebRtcServerRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Worker.CloseWebRtcServerRequest` in the union `Body` + CloseWebRtcServerRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Worker.CreateRouterRequest` in the union `Body` + CreateRouterRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Worker.CloseRouterRequest` in the union `Body` + CloseRouterRequest(::planus::alloc::boxed::Box), + + /// The variant of type `FBS.Router.CreateWebRtcTransportRequest` in the union `Body` + CreateWebRtcTransportRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Router.CreatePlainTransportRequest` in the union `Body` + CreatePlainTransportRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Router.CreatePipeTransportRequest` in the union `Body` + CreatePipeTransportRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Router.CreateDirectTransportRequest` in the union `Body` + CreateDirectTransportRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Router.CreateActiveSpeakerObserverRequest` in the union `Body` + CreateActiveSpeakerObserverRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Router.CreateAudioLevelObserverRequest` in the union `Body` + CreateAudioLevelObserverRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Router.CloseTransportRequest` in the union `Body` + CloseTransportRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Router.CloseRtpObserverRequest` in the union `Body` + CloseRtpObserverRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Transport.SetMaxIncomingBitrateRequest` in the union `Body` + SetMaxIncomingBitrateRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Transport.SetMaxOutgoingBitrateRequest` in the union `Body` + SetMaxOutgoingBitrateRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Transport.SetMinOutgoingBitrateRequest` in the union `Body` + SetMinOutgoingBitrateRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Transport.ProduceRequest` in the union `Body` + ProduceRequest(::planus::alloc::boxed::Box), + + /// The variant of type `FBS.Transport.ConsumeRequest` in the union `Body` + ConsumeRequest(::planus::alloc::boxed::Box), + + /// The variant of type `FBS.Transport.ProduceDataRequest` in the union `Body` + ProduceDataRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Transport.ConsumeDataRequest` in the union `Body` + ConsumeDataRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Consumer.EnableTraceEventRequest` in the union `Body` + EnableTraceEventRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Transport.CloseProducerRequest` in the union `Body` + CloseProducerRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Transport.CloseConsumerRequest` in the union `Body` + CloseConsumerRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Transport.CloseDataProducerRequest` in the union `Body` + CloseDataProducerRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Transport.CloseDataConsumerRequest` in the union `Body` + CloseDataConsumerRequest( + ::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 of type `FBS.Consumer.SetPreferredLayersRequest` in the union `Body` + SetPreferredLayersRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.Consumer.SetPriorityRequest` in the union `Body` + SetPriorityRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.DataConsumer.SetBufferedAmountLowThresholdRequest` in the union `Body` + SetBufferedAmountLowThresholdRequest( + ::planus::alloc::boxed::Box< + super::data_consumer::SetBufferedAmountLowThresholdRequest, + >, + ), + + /// The variant of type `FBS.DataConsumer.SendRequest` in the union `Body` + SendRequest(::planus::alloc::boxed::Box), + + /// The variant of type `FBS.DataConsumer.SetSubchannelsRequest` in the union `Body` + SetSubchannelsRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.RtpObserver.AddProducerRequest` in the union `Body` + AddProducerRequest( + ::planus::alloc::boxed::Box, + ), + + /// The variant of type `FBS.RtpObserver.RemoveProducerRequest` in the union `Body` + RemoveProducerRequest( + ::planus::alloc::boxed::Box, + ), + } + + impl Body { + /// Creates a [BodyBuilder] for serializing an instance of this table. #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(6, (self.0).0.prepare(builder).downcast()) + pub fn builder() -> BodyBuilder<::planus::Uninitialized> { + BodyBuilder(::planus::Uninitialized) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<6, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_update_settings_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) } - } - 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()) + pub fn create_create_web_rtc_server_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<7, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_close_web_rtc_server_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) } - } - 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()) + pub fn create_create_router_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<8, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_close_router_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) } - } - 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()) + pub fn create_create_web_rtc_transport_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(6, value.prepare(builder).downcast()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<9, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_create_plain_transport_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(7, value.prepare(builder).downcast()) } - } - 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()) + pub fn create_create_pipe_transport_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(8, value.prepare(builder).downcast()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<10, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_create_direct_transport_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(9, value.prepare(builder).downcast()) } - } - 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()) + pub fn create_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()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<11, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_create_audio_level_observer_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) } - } - 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()) + pub fn create_close_transport_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<12, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_close_rtp_observer_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) } - } - 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()) + pub fn create_set_max_incoming_bitrate_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<13, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_set_max_outgoing_bitrate_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) } - } - 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()) + pub fn create_set_min_outgoing_bitrate_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<14, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_produce_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) } - } - 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()) + pub fn create_consume_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(18, value.prepare(builder).downcast()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<15, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_produce_data_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(19, value.prepare(builder).downcast()) } - } - 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()) + pub fn create_consume_data_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(20, value.prepare(builder).downcast()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<16, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_enable_trace_event_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(21, value.prepare(builder).downcast()) } - } - 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()) + pub fn create_close_producer_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(22, value.prepare(builder).downcast()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<17, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_close_consumer_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(23, value.prepare(builder).downcast()) } - } - 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()) + pub fn create_close_data_producer_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(24, value.prepare(builder).downcast()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<18, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_close_data_consumer_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(25, value.prepare(builder).downcast()) } - } - 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()) + 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()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<19, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_pipe_transport_connect_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(27, value.prepare(builder).downcast()) } - } - 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()) + 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()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<20, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_set_preferred_layers_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(29, value.prepare(builder).downcast()) } - } - 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()) + pub fn create_set_priority_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(30, value.prepare(builder).downcast()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<21, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_set_buffered_amount_low_threshold_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset< + super::data_consumer::SetBufferedAmountLowThresholdRequest, + >, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(31, value.prepare(builder).downcast()) } - } - 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()) + pub fn create_send_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(32, value.prepare(builder).downcast()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<22, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_set_subchannels_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(33, value.prepare(builder).downcast()) } - } - 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()) + pub fn create_add_producer_request( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(34, value.prepare(builder).downcast()) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<23, T>> - where - T: ::planus::WriteAsOffset, - { #[inline] - fn prepare( - &self, + pub fn create_remove_producer_request( builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(35, value.prepare(builder).downcast()) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<24, T>> - where - T: ::planus::WriteAsOffset, - { + + impl ::planus::WriteAsUnion for Body { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(24, (self.0).0.prepare(builder).downcast()) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + match self { + Self::UpdateSettingsRequest(value) => { + Self::create_update_settings_request(builder, value) + } + Self::CreateWebRtcServerRequest(value) => { + Self::create_create_web_rtc_server_request(builder, value) + } + Self::CloseWebRtcServerRequest(value) => { + Self::create_close_web_rtc_server_request(builder, value) + } + Self::CreateRouterRequest(value) => { + Self::create_create_router_request(builder, value) + } + Self::CloseRouterRequest(value) => { + Self::create_close_router_request(builder, value) + } + Self::CreateWebRtcTransportRequest(value) => { + Self::create_create_web_rtc_transport_request(builder, value) + } + Self::CreatePlainTransportRequest(value) => { + Self::create_create_plain_transport_request(builder, value) + } + Self::CreatePipeTransportRequest(value) => { + Self::create_create_pipe_transport_request(builder, value) + } + Self::CreateDirectTransportRequest(value) => { + Self::create_create_direct_transport_request(builder, value) + } + Self::CreateActiveSpeakerObserverRequest(value) => { + Self::create_create_active_speaker_observer_request(builder, value) + } + Self::CreateAudioLevelObserverRequest(value) => { + Self::create_create_audio_level_observer_request(builder, value) + } + Self::CloseTransportRequest(value) => { + Self::create_close_transport_request(builder, value) + } + Self::CloseRtpObserverRequest(value) => { + Self::create_close_rtp_observer_request(builder, value) + } + Self::SetMaxIncomingBitrateRequest(value) => { + Self::create_set_max_incoming_bitrate_request(builder, value) + } + Self::SetMaxOutgoingBitrateRequest(value) => { + Self::create_set_max_outgoing_bitrate_request(builder, value) + } + Self::SetMinOutgoingBitrateRequest(value) => { + Self::create_set_min_outgoing_bitrate_request(builder, value) + } + Self::ProduceRequest(value) => Self::create_produce_request(builder, value), + Self::ConsumeRequest(value) => Self::create_consume_request(builder, value), + Self::ProduceDataRequest(value) => { + Self::create_produce_data_request(builder, value) + } + Self::ConsumeDataRequest(value) => { + Self::create_consume_data_request(builder, value) + } + Self::EnableTraceEventRequest(value) => { + Self::create_enable_trace_event_request(builder, value) + } + Self::CloseProducerRequest(value) => { + Self::create_close_producer_request(builder, value) + } + Self::CloseConsumerRequest(value) => { + Self::create_close_consumer_request(builder, value) + } + Self::CloseDataProducerRequest(value) => { + Self::create_close_data_producer_request(builder, value) + } + Self::CloseDataConsumerRequest(value) => { + Self::create_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::SetPreferredLayersRequest(value) => { + Self::create_set_preferred_layers_request(builder, value) + } + Self::SetPriorityRequest(value) => { + Self::create_set_priority_request(builder, value) + } + Self::SetBufferedAmountLowThresholdRequest(value) => { + Self::create_set_buffered_amount_low_threshold_request(builder, value) + } + Self::SendRequest(value) => Self::create_send_request(builder, value), + Self::SetSubchannelsRequest(value) => { + Self::create_set_subchannels_request(builder, value) + } + Self::AddProducerRequest(value) => { + Self::create_add_producer_request(builder, value) + } + Self::RemoveProducerRequest(value) => { + Self::create_remove_producer_request(builder, value) + } + } } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<24, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::planus::WriteAsOptionalUnion for Body { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { + ) -> ::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, - { + /// 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 [`UpdateSettingsRequest` variant](Body#variant.UpdateSettingsRequest). #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + pub fn update_settings_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<26, T>> - where - T: ::planus::WriteAsOffset, - { + + /// Creates an instance of the [`CreateWebRtcServerRequest` variant](Body#variant.CreateWebRtcServerRequest). #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(26, (self.0).0.prepare(builder).downcast()) + pub fn create_web_rtc_server_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<2, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<26, T>> - where - T: ::planus::WriteAsOffset, - { + /// Creates an instance of the [`CloseWebRtcServerRequest` variant](Body#variant.CloseWebRtcServerRequest). #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + pub fn close_web_rtc_server_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<3, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<27, T>> - where - T: ::planus::WriteAsOffset, - { + + /// Creates an instance of the [`CreateRouterRequest` variant](Body#variant.CreateRouterRequest). #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(27, (self.0).0.prepare(builder).downcast()) + pub fn create_router_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<4, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<27, T>> - where - T: ::planus::WriteAsOffset, - { + /// Creates an instance of the [`CloseRouterRequest` variant](Body#variant.CloseRouterRequest). #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + pub fn close_router_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<5, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<28, T>> - where - T: ::planus::WriteAsOffset, - { + + /// Creates an instance of the [`CreateWebRtcTransportRequest` variant](Body#variant.CreateWebRtcTransportRequest). #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(28, (self.0).0.prepare(builder).downcast()) + pub fn create_web_rtc_transport_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<6, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<28, T>> - where - T: ::planus::WriteAsOffset, - { + /// Creates an instance of the [`CreatePlainTransportRequest` variant](Body#variant.CreatePlainTransportRequest). #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + pub fn create_plain_transport_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<7, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<29, T>> - where - T: ::planus::WriteAsOffset, - { + + /// Creates an instance of the [`CreatePipeTransportRequest` variant](Body#variant.CreatePipeTransportRequest). #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(29, (self.0).0.prepare(builder).downcast()) + pub fn create_pipe_transport_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<8, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<29, T>> - where - T: ::planus::WriteAsOffset, - { + /// Creates an instance of the [`CreateDirectTransportRequest` variant](Body#variant.CreateDirectTransportRequest). #[inline] - fn prepare( - &self, + pub fn 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 [`CreateActiveSpeakerObserverRequest` variant](Body#variant.CreateActiveSpeakerObserverRequest). + #[inline] + pub fn 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 [`CreateAudioLevelObserverRequest` variant](Body#variant.CreateAudioLevelObserverRequest). + #[inline] + pub fn 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 [`CloseTransportRequest` variant](Body#variant.CloseTransportRequest). + #[inline] + pub fn close_transport_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<12, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`CloseRtpObserverRequest` variant](Body#variant.CloseRtpObserverRequest). + #[inline] + pub fn 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 [`SetMaxIncomingBitrateRequest` variant](Body#variant.SetMaxIncomingBitrateRequest). + #[inline] + pub fn 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 [`SetMaxOutgoingBitrateRequest` variant](Body#variant.SetMaxOutgoingBitrateRequest). + #[inline] + pub fn 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 [`SetMinOutgoingBitrateRequest` variant](Body#variant.SetMinOutgoingBitrateRequest). + #[inline] + pub fn 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 [`ProduceRequest` variant](Body#variant.ProduceRequest). + #[inline] + pub fn produce_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<17, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`ConsumeRequest` variant](Body#variant.ConsumeRequest). + #[inline] + pub fn consume_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<18, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`ProduceDataRequest` variant](Body#variant.ProduceDataRequest). + #[inline] + pub fn produce_data_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<19, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`ConsumeDataRequest` variant](Body#variant.ConsumeDataRequest). + #[inline] + pub fn consume_data_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<20, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`EnableTraceEventRequest` variant](Body#variant.EnableTraceEventRequest). + #[inline] + pub fn 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 [`CloseProducerRequest` variant](Body#variant.CloseProducerRequest). + #[inline] + pub fn close_producer_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<22, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`CloseConsumerRequest` variant](Body#variant.CloseConsumerRequest). + #[inline] + pub fn close_consumer_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<23, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`CloseDataProducerRequest` variant](Body#variant.CloseDataProducerRequest). + #[inline] + pub fn 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 [`CloseDataConsumerRequest` variant](Body#variant.CloseDataConsumerRequest). + #[inline] + pub fn 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 [`SetPreferredLayersRequest` variant](Body#variant.SetPreferredLayersRequest). + #[inline] + pub fn set_preferred_layers_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<29, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`SetPriorityRequest` variant](Body#variant.SetPriorityRequest). + #[inline] + pub fn set_priority_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<30, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`SetBufferedAmountLowThresholdRequest` variant](Body#variant.SetBufferedAmountLowThresholdRequest). + #[inline] + pub fn set_buffered_amount_low_threshold_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<31, T>> + where + T: ::planus::WriteAsOffset< + super::data_consumer::SetBufferedAmountLowThresholdRequest, + >, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`SendRequest` variant](Body#variant.SendRequest). + #[inline] + pub fn send_request(self, value: T) -> BodyBuilder<::planus::Initialized<32, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`SetSubchannelsRequest` variant](Body#variant.SetSubchannelsRequest). + #[inline] + pub fn set_subchannels_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<33, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`AddProducerRequest` variant](Body#variant.AddProducerRequest). + #[inline] + pub fn add_producer_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<34, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`RemoveProducerRequest` variant](Body#variant.RemoveProducerRequest). + #[inline] + pub fn remove_producer_request( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<35, 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<30, T>> + impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<2, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(30, (self.0).0.prepare(builder).downcast()) + ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<30, T>> + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<2, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -52882,23 +52518,19 @@ mod root { ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<31, T>> + impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<3, T>> where - T: ::planus::WriteAsOffset< - super::data_consumer::SetBufferedAmountLowThresholdRequest, - >, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(31, (self.0).0.prepare(builder).downcast()) + ::planus::UnionOffset::new(3, (self.0).0.prepare(builder).downcast()) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<31, T>> + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<3, T>> where - T: ::planus::WriteAsOffset< - super::data_consumer::SetBufferedAmountLowThresholdRequest, - >, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -52908,19 +52540,19 @@ mod root { ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<32, T>> + impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<4, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(32, (self.0).0.prepare(builder).downcast()) + ::planus::UnionOffset::new(4, (self.0).0.prepare(builder).downcast()) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<32, T>> + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<4, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -52930,19 +52562,19 @@ mod root { ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<33, T>> + impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<5, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(33, (self.0).0.prepare(builder).downcast()) + ::planus::UnionOffset::new(5, (self.0).0.prepare(builder).downcast()) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<33, T>> + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<5, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -52952,19 +52584,19 @@ mod root { ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<34, T>> + impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<6, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(34, (self.0).0.prepare(builder).downcast()) + ::planus::UnionOffset::new(6, (self.0).0.prepare(builder).downcast()) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<34, T>> + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<6, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -52974,19 +52606,19 @@ mod root { ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<35, T>> + impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<7, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(35, (self.0).0.prepare(builder).downcast()) + ::planus::UnionOffset::new(7, (self.0).0.prepare(builder).downcast()) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<35, T>> + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<7, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -52996,3432 +52628,5877 @@ mod root { ::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()) + } + } - /// Reference to a deserialized [Body]. - #[derive(Copy, Clone, Debug)] - pub enum BodyRef<'a> { - UpdateSettingsRequest(super::worker::UpdateSettingsRequestRef<'a>), - CreateWebRtcServerRequest(super::worker::CreateWebRtcServerRequestRef<'a>), - CloseWebRtcServerRequest(super::worker::CloseWebRtcServerRequestRef<'a>), - CreateRouterRequest(super::worker::CreateRouterRequestRef<'a>), - CloseRouterRequest(super::worker::CloseRouterRequestRef<'a>), - CreateWebRtcTransportRequest(super::router::CreateWebRtcTransportRequestRef<'a>), - CreatePlainTransportRequest(super::router::CreatePlainTransportRequestRef<'a>), - CreatePipeTransportRequest(super::router::CreatePipeTransportRequestRef<'a>), - CreateDirectTransportRequest(super::router::CreateDirectTransportRequestRef<'a>), - CreateActiveSpeakerObserverRequest( - super::router::CreateActiveSpeakerObserverRequestRef<'a>, - ), - CreateAudioLevelObserverRequest( - super::router::CreateAudioLevelObserverRequestRef<'a>, - ), - CloseTransportRequest(super::router::CloseTransportRequestRef<'a>), - CloseRtpObserverRequest(super::router::CloseRtpObserverRequestRef<'a>), - SetMaxIncomingBitrateRequest(super::transport::SetMaxIncomingBitrateRequestRef<'a>), - SetMaxOutgoingBitrateRequest(super::transport::SetMaxOutgoingBitrateRequestRef<'a>), - SetMinOutgoingBitrateRequest(super::transport::SetMinOutgoingBitrateRequestRef<'a>), - ProduceRequest(super::transport::ProduceRequestRef<'a>), - ConsumeRequest(super::transport::ConsumeRequestRef<'a>), - ProduceDataRequest(super::transport::ProduceDataRequestRef<'a>), - ConsumeDataRequest(super::transport::ConsumeDataRequestRef<'a>), - EnableTraceEventRequest(super::consumer::EnableTraceEventRequestRef<'a>), - CloseProducerRequest(super::transport::CloseProducerRequestRef<'a>), - CloseConsumerRequest(super::transport::CloseConsumerRequestRef<'a>), - CloseDataProducerRequest(super::transport::CloseDataProducerRequestRef<'a>), - CloseDataConsumerRequest(super::transport::CloseDataConsumerRequestRef<'a>), - PlainTransportConnectRequest(super::plain_transport::ConnectRequestRef<'a>), - PipeTransportConnectRequest(super::pipe_transport::ConnectRequestRef<'a>), - ConnectRequest(super::web_rtc_transport::ConnectRequestRef<'a>), - SetPreferredLayersRequest(super::consumer::SetPreferredLayersRequestRef<'a>), - SetPriorityRequest(super::consumer::SetPriorityRequestRef<'a>), - SetBufferedAmountLowThresholdRequest( - super::data_consumer::SetBufferedAmountLowThresholdRequestRef<'a>, - ), - SendRequest(super::data_consumer::SendRequestRef<'a>), - SetSubchannelsRequest(super::data_consumer::SetSubchannelsRequestRef<'a>), - AddProducerRequest(super::rtp_observer::AddProducerRequestRef<'a>), - RemoveProducerRequest(super::rtp_observer::RemoveProducerRequestRef<'a>), + 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<'a> ::core::convert::TryFrom> for Body { - type Error = ::planus::Error; + 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()) + } + } - fn try_from(value: BodyRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - BodyRef::UpdateSettingsRequest(value) => { - Self::UpdateSettingsRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, + 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< + super::data_consumer::SetBufferedAmountLowThresholdRequest, + >, + { + #[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< + 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<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, + { + #[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, + { + #[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)) + } + } + + /// Reference to a deserialized [Body]. + #[derive(Copy, Clone, Debug)] + pub enum BodyRef<'a> { + UpdateSettingsRequest(super::worker::UpdateSettingsRequestRef<'a>), + CreateWebRtcServerRequest(super::worker::CreateWebRtcServerRequestRef<'a>), + CloseWebRtcServerRequest(super::worker::CloseWebRtcServerRequestRef<'a>), + CreateRouterRequest(super::worker::CreateRouterRequestRef<'a>), + CloseRouterRequest(super::worker::CloseRouterRequestRef<'a>), + CreateWebRtcTransportRequest(super::router::CreateWebRtcTransportRequestRef<'a>), + CreatePlainTransportRequest(super::router::CreatePlainTransportRequestRef<'a>), + CreatePipeTransportRequest(super::router::CreatePipeTransportRequestRef<'a>), + CreateDirectTransportRequest(super::router::CreateDirectTransportRequestRef<'a>), + CreateActiveSpeakerObserverRequest( + super::router::CreateActiveSpeakerObserverRequestRef<'a>, + ), + CreateAudioLevelObserverRequest( + super::router::CreateAudioLevelObserverRequestRef<'a>, + ), + CloseTransportRequest(super::router::CloseTransportRequestRef<'a>), + CloseRtpObserverRequest(super::router::CloseRtpObserverRequestRef<'a>), + SetMaxIncomingBitrateRequest(super::transport::SetMaxIncomingBitrateRequestRef<'a>), + SetMaxOutgoingBitrateRequest(super::transport::SetMaxOutgoingBitrateRequestRef<'a>), + SetMinOutgoingBitrateRequest(super::transport::SetMinOutgoingBitrateRequestRef<'a>), + ProduceRequest(super::transport::ProduceRequestRef<'a>), + ConsumeRequest(super::transport::ConsumeRequestRef<'a>), + ProduceDataRequest(super::transport::ProduceDataRequestRef<'a>), + ConsumeDataRequest(super::transport::ConsumeDataRequestRef<'a>), + EnableTraceEventRequest(super::consumer::EnableTraceEventRequestRef<'a>), + CloseProducerRequest(super::transport::CloseProducerRequestRef<'a>), + CloseConsumerRequest(super::transport::CloseConsumerRequestRef<'a>), + CloseDataProducerRequest(super::transport::CloseDataProducerRequestRef<'a>), + CloseDataConsumerRequest(super::transport::CloseDataConsumerRequestRef<'a>), + PlainTransportConnectRequest(super::plain_transport::ConnectRequestRef<'a>), + PipeTransportConnectRequest(super::pipe_transport::ConnectRequestRef<'a>), + WebRtcTransportConnectRequest(super::web_rtc_transport::ConnectRequestRef<'a>), + SetPreferredLayersRequest(super::consumer::SetPreferredLayersRequestRef<'a>), + SetPriorityRequest(super::consumer::SetPriorityRequestRef<'a>), + SetBufferedAmountLowThresholdRequest( + super::data_consumer::SetBufferedAmountLowThresholdRequestRef<'a>, + ), + SendRequest(super::data_consumer::SendRequestRef<'a>), + SetSubchannelsRequest(super::data_consumer::SetSubchannelsRequestRef<'a>), + AddProducerRequest(super::rtp_observer::AddProducerRequestRef<'a>), + RemoveProducerRequest(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::UpdateSettingsRequest(value) => { + Self::UpdateSettingsRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreateWebRtcServerRequest(value) => { + Self::CreateWebRtcServerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseWebRtcServerRequest(value) => { + Self::CloseWebRtcServerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreateRouterRequest(value) => { + Self::CreateRouterRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseRouterRequest(value) => { + Self::CloseRouterRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreateWebRtcTransportRequest(value) => { + Self::CreateWebRtcTransportRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreatePlainTransportRequest(value) => { + Self::CreatePlainTransportRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreatePipeTransportRequest(value) => { + Self::CreatePipeTransportRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreateDirectTransportRequest(value) => { + Self::CreateDirectTransportRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CreateActiveSpeakerObserverRequest(value) => { + Self::CreateActiveSpeakerObserverRequest( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::CreateAudioLevelObserverRequest(value) => { + Self::CreateAudioLevelObserverRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseTransportRequest(value) => { + Self::CloseTransportRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseRtpObserverRequest(value) => { + Self::CloseRtpObserverRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetMaxIncomingBitrateRequest(value) => { + Self::SetMaxIncomingBitrateRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetMaxOutgoingBitrateRequest(value) => { + Self::SetMaxOutgoingBitrateRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetMinOutgoingBitrateRequest(value) => { + Self::SetMinOutgoingBitrateRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::ProduceRequest(value) => { + Self::ProduceRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::ConsumeRequest(value) => { + Self::ConsumeRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::ProduceDataRequest(value) => { + Self::ProduceDataRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::ConsumeDataRequest(value) => { + Self::ConsumeDataRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::EnableTraceEventRequest(value) => { + Self::EnableTraceEventRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseProducerRequest(value) => { + Self::CloseProducerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseConsumerRequest(value) => { + Self::CloseConsumerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseDataProducerRequest(value) => { + Self::CloseDataProducerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::CloseDataConsumerRequest(value) => { + Self::CloseDataConsumerRequest(::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::SetPreferredLayersRequest(value) => { + Self::SetPreferredLayersRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetPriorityRequest(value) => { + Self::SetPriorityRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetBufferedAmountLowThresholdRequest(value) => { + Self::SetBufferedAmountLowThresholdRequest( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) + } + + BodyRef::SendRequest(value) => { + Self::SendRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::SetSubchannelsRequest(value) => { + Self::SetSubchannelsRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + + BodyRef::AddProducerRequest(value) => { + Self::AddProducerRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::CreateWebRtcServerRequest(value) => { - Self::CreateWebRtcServerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + BodyRef::RemoveProducerRequest(value) => { + Self::RemoveProducerRequest(::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::UpdateSettingsRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 2 => ::core::result::Result::Ok(Self::CreateWebRtcServerRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 3 => ::core::result::Result::Ok(Self::CloseWebRtcServerRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 4 => ::core::result::Result::Ok(Self::CreateRouterRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 5 => ::core::result::Result::Ok(Self::CloseRouterRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 6 => ::core::result::Result::Ok(Self::CreateWebRtcTransportRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 7 => ::core::result::Result::Ok(Self::CreatePlainTransportRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 8 => ::core::result::Result::Ok(Self::CreatePipeTransportRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 9 => ::core::result::Result::Ok(Self::CreateDirectTransportRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 10 => ::core::result::Result::Ok(Self::CreateActiveSpeakerObserverRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 11 => ::core::result::Result::Ok(Self::CreateAudioLevelObserverRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 12 => ::core::result::Result::Ok(Self::CloseTransportRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 13 => ::core::result::Result::Ok(Self::CloseRtpObserverRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 14 => ::core::result::Result::Ok(Self::SetMaxIncomingBitrateRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 15 => ::core::result::Result::Ok(Self::SetMaxOutgoingBitrateRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 16 => ::core::result::Result::Ok(Self::SetMinOutgoingBitrateRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 17 => ::core::result::Result::Ok(Self::ProduceRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 18 => ::core::result::Result::Ok(Self::ConsumeRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 19 => ::core::result::Result::Ok(Self::ProduceDataRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 20 => ::core::result::Result::Ok(Self::ConsumeDataRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 21 => ::core::result::Result::Ok(Self::EnableTraceEventRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 22 => ::core::result::Result::Ok(Self::CloseProducerRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 23 => ::core::result::Result::Ok(Self::CloseConsumerRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 24 => ::core::result::Result::Ok(Self::CloseDataProducerRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 25 => ::core::result::Result::Ok(Self::CloseDataConsumerRequest( + ::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::SetPreferredLayersRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 30 => ::core::result::Result::Ok(Self::SetPriorityRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 31 => { + ::core::result::Result::Ok(Self::SetBufferedAmountLowThresholdRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )) + } + 32 => ::core::result::Result::Ok(Self::SendRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 33 => ::core::result::Result::Ok(Self::SetSubchannelsRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 34 => ::core::result::Result::Ok(Self::AddProducerRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 35 => ::core::result::Result::Ok(Self::RemoveProducerRequest( + ::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 `FBS_Worker_DumpResponse` in the union `Body` + FbsWorkerDumpResponse(::planus::alloc::boxed::Box), + + /// The variant `FBS_Worker_ResourceUsageResponse` in the union `Body` + FbsWorkerResourceUsageResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_WebRtcServer_DumpResponse` in the union `Body` + FbsWebRtcServerDumpResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_Router_DumpResponse` in the union `Body` + FbsRouterDumpResponse(::planus::alloc::boxed::Box), + + /// The variant `FBS_Transport_ProduceResponse` in the union `Body` + FbsTransportProduceResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_Transport_ConsumeResponse` in the union `Body` + FbsTransportConsumeResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_Transport_RestartIceResponse` in the union `Body` + FbsTransportRestartIceResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_PlainTransport_ConnectResponse` in the union `Body` + FbsPlainTransportConnectResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_PlainTransport_DumpResponse` in the union `Body` + FbsPlainTransportDumpResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_PlainTransport_GetStatsResponse` in the union `Body` + FbsPlainTransportGetStatsResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_PipeTransport_ConnectResponse` in the union `Body` + FbsPipeTransportConnectResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_PipeTransport_DumpResponse` in the union `Body` + FbsPipeTransportDumpResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_PipeTransport_GetStatsResponse` in the union `Body` + FbsPipeTransportGetStatsResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_DirectTransport_DumpResponse` in the union `Body` + FbsDirectTransportDumpResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_DirectTransport_GetStatsResponse` in the union `Body` + FbsDirectTransportGetStatsResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_WebRtcTransport_ConnectResponse` in the union `Body` + FbsWebRtcTransportConnectResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_WebRtcTransport_DumpResponse` in the union `Body` + FbsWebRtcTransportDumpResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_WebRtcTransport_GetStatsResponse` in the union `Body` + FbsWebRtcTransportGetStatsResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_Producer_DumpResponse` in the union `Body` + FbsProducerDumpResponse(::planus::alloc::boxed::Box), + + /// The variant `FBS_Producer_GetStatsResponse` in the union `Body` + FbsProducerGetStatsResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_Consumer_DumpResponse` in the union `Body` + FbsConsumerDumpResponse(::planus::alloc::boxed::Box), + + /// The variant `FBS_Consumer_GetStatsResponse` in the union `Body` + FbsConsumerGetStatsResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_Consumer_SetPreferredLayersResponse` in the union `Body` + FbsConsumerSetPreferredLayersResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_Consumer_SetPriorityResponse` in the union `Body` + FbsConsumerSetPriorityResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_DataProducer_DumpResponse` in the union `Body` + FbsDataProducerDumpResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_DataProducer_GetStatsResponse` in the union `Body` + FbsDataProducerGetStatsResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_DataConsumer_GetBufferedAmountResponse` in the union `Body` + FbsDataConsumerGetBufferedAmountResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_DataConsumer_DumpResponse` in the union `Body` + FbsDataConsumerDumpResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_DataConsumer_GetStatsResponse` in the union `Body` + FbsDataConsumerGetStatsResponse( + ::planus::alloc::boxed::Box, + ), + + /// The variant `FBS_DataConsumer_SetSubchannelsResponse` in the union `Body` + FbsDataConsumerSetSubchannelsResponse( + ::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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_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_fbs_data_consumer_dump_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(28, value.prepare(builder).downcast()) + } - BodyRef::CloseWebRtcServerRequest(value) => { - Self::CloseWebRtcServerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + #[inline] + pub fn create_fbs_data_consumer_get_stats_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(29, value.prepare(builder).downcast()) + } - BodyRef::CreateRouterRequest(value) => { - Self::CreateRouterRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + #[inline] + pub fn create_fbs_data_consumer_set_subchannels_response( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(30, value.prepare(builder).downcast()) + } + } - BodyRef::CloseRouterRequest(value) => { - Self::CloseRouterRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + impl ::planus::WriteAsUnion for Body { + #[inline] + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + match self { + Self::FbsWorkerDumpResponse(value) => { + Self::create_fbs_worker_dump_response(builder, value) } - - BodyRef::CreateWebRtcTransportRequest(value) => { - Self::CreateWebRtcTransportRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsWorkerResourceUsageResponse(value) => { + Self::create_fbs_worker_resource_usage_response(builder, value) } - - BodyRef::CreatePlainTransportRequest(value) => { - Self::CreatePlainTransportRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsWebRtcServerDumpResponse(value) => { + Self::create_fbs_web_rtc_server_dump_response(builder, value) } - - BodyRef::CreatePipeTransportRequest(value) => { - Self::CreatePipeTransportRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsRouterDumpResponse(value) => { + Self::create_fbs_router_dump_response(builder, value) } - - BodyRef::CreateDirectTransportRequest(value) => { - Self::CreateDirectTransportRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsTransportProduceResponse(value) => { + Self::create_fbs_transport_produce_response(builder, value) } - - BodyRef::CreateActiveSpeakerObserverRequest(value) => { - Self::CreateActiveSpeakerObserverRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) + Self::FbsTransportConsumeResponse(value) => { + Self::create_fbs_transport_consume_response(builder, value) } - - BodyRef::CreateAudioLevelObserverRequest(value) => { - Self::CreateAudioLevelObserverRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsTransportRestartIceResponse(value) => { + Self::create_fbs_transport_restart_ice_response(builder, value) } - - BodyRef::CloseTransportRequest(value) => { - Self::CloseTransportRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsPlainTransportConnectResponse(value) => { + Self::create_fbs_plain_transport_connect_response(builder, value) } - - BodyRef::CloseRtpObserverRequest(value) => { - Self::CloseRtpObserverRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsPlainTransportDumpResponse(value) => { + Self::create_fbs_plain_transport_dump_response(builder, value) } - - BodyRef::SetMaxIncomingBitrateRequest(value) => { - Self::SetMaxIncomingBitrateRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsPlainTransportGetStatsResponse(value) => { + Self::create_fbs_plain_transport_get_stats_response(builder, value) } - - BodyRef::SetMaxOutgoingBitrateRequest(value) => { - Self::SetMaxOutgoingBitrateRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsPipeTransportConnectResponse(value) => { + Self::create_fbs_pipe_transport_connect_response(builder, value) } - - BodyRef::SetMinOutgoingBitrateRequest(value) => { - Self::SetMinOutgoingBitrateRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsPipeTransportDumpResponse(value) => { + Self::create_fbs_pipe_transport_dump_response(builder, value) } - - BodyRef::ProduceRequest(value) => { - Self::ProduceRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsPipeTransportGetStatsResponse(value) => { + Self::create_fbs_pipe_transport_get_stats_response(builder, value) } - - BodyRef::ConsumeRequest(value) => { - Self::ConsumeRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsDirectTransportDumpResponse(value) => { + Self::create_fbs_direct_transport_dump_response(builder, value) } - - BodyRef::ProduceDataRequest(value) => { - Self::ProduceDataRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsDirectTransportGetStatsResponse(value) => { + Self::create_fbs_direct_transport_get_stats_response(builder, value) } - - BodyRef::ConsumeDataRequest(value) => { - Self::ConsumeDataRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsWebRtcTransportConnectResponse(value) => { + Self::create_fbs_web_rtc_transport_connect_response(builder, value) } - - BodyRef::EnableTraceEventRequest(value) => { - Self::EnableTraceEventRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsWebRtcTransportDumpResponse(value) => { + Self::create_fbs_web_rtc_transport_dump_response(builder, value) } - - BodyRef::CloseProducerRequest(value) => { - Self::CloseProducerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsWebRtcTransportGetStatsResponse(value) => { + Self::create_fbs_web_rtc_transport_get_stats_response(builder, value) } - - BodyRef::CloseConsumerRequest(value) => { - Self::CloseConsumerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsProducerDumpResponse(value) => { + Self::create_fbs_producer_dump_response(builder, value) } - - BodyRef::CloseDataProducerRequest(value) => { - Self::CloseDataProducerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsProducerGetStatsResponse(value) => { + Self::create_fbs_producer_get_stats_response(builder, value) } - - BodyRef::CloseDataConsumerRequest(value) => { - Self::CloseDataConsumerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsConsumerDumpResponse(value) => { + Self::create_fbs_consumer_dump_response(builder, value) } - - BodyRef::PlainTransportConnectRequest(value) => { - Self::PlainTransportConnectRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsConsumerGetStatsResponse(value) => { + Self::create_fbs_consumer_get_stats_response(builder, value) } - - BodyRef::PipeTransportConnectRequest(value) => { - Self::PipeTransportConnectRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsConsumerSetPreferredLayersResponse(value) => { + Self::create_fbs_consumer_set_preferred_layers_response(builder, value) } - - BodyRef::ConnectRequest(value) => { - Self::ConnectRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsConsumerSetPriorityResponse(value) => { + Self::create_fbs_consumer_set_priority_response(builder, value) } - - BodyRef::SetPreferredLayersRequest(value) => { - Self::SetPreferredLayersRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsDataProducerDumpResponse(value) => { + Self::create_fbs_data_producer_dump_response(builder, value) } - - BodyRef::SetPriorityRequest(value) => { - Self::SetPriorityRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsDataProducerGetStatsResponse(value) => { + Self::create_fbs_data_producer_get_stats_response(builder, value) } - - BodyRef::SetBufferedAmountLowThresholdRequest(value) => { - Self::SetBufferedAmountLowThresholdRequest( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), + Self::FbsDataConsumerGetBufferedAmountResponse(value) => { + Self::create_fbs_data_consumer_get_buffered_amount_response( + builder, value, ) } - - BodyRef::SendRequest(value) => { - Self::SendRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsDataConsumerDumpResponse(value) => { + Self::create_fbs_data_consumer_dump_response(builder, value) } - - BodyRef::SetSubchannelsRequest(value) => { - Self::SetSubchannelsRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsDataConsumerGetStatsResponse(value) => { + Self::create_fbs_data_consumer_get_stats_response(builder, value) } - - BodyRef::AddProducerRequest(value) => { - Self::AddProducerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) + Self::FbsDataConsumerSetSubchannelsResponse(value) => { + Self::create_fbs_data_consumer_set_subchannels_response(builder, value) } + } + } + } - BodyRef::RemoveProducerRequest(value) => { - Self::RemoveProducerRequest(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(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)) } } - 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::UpdateSettingsRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::CreateWebRtcServerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 3 => ::core::result::Result::Ok(Self::CloseWebRtcServerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 4 => ::core::result::Result::Ok(Self::CreateRouterRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 5 => ::core::result::Result::Ok(Self::CloseRouterRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 6 => ::core::result::Result::Ok(Self::CreateWebRtcTransportRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 7 => ::core::result::Result::Ok(Self::CreatePlainTransportRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 8 => ::core::result::Result::Ok(Self::CreatePipeTransportRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 9 => ::core::result::Result::Ok(Self::CreateDirectTransportRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 10 => ::core::result::Result::Ok(Self::CreateActiveSpeakerObserverRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 11 => ::core::result::Result::Ok(Self::CreateAudioLevelObserverRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 12 => ::core::result::Result::Ok(Self::CloseTransportRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 13 => ::core::result::Result::Ok(Self::CloseRtpObserverRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 14 => ::core::result::Result::Ok(Self::SetMaxIncomingBitrateRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 15 => ::core::result::Result::Ok(Self::SetMaxOutgoingBitrateRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 16 => ::core::result::Result::Ok(Self::SetMinOutgoingBitrateRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 17 => ::core::result::Result::Ok(Self::ProduceRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 18 => ::core::result::Result::Ok(Self::ConsumeRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 19 => ::core::result::Result::Ok(Self::ProduceDataRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 20 => ::core::result::Result::Ok(Self::ConsumeDataRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 21 => ::core::result::Result::Ok(Self::EnableTraceEventRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 22 => ::core::result::Result::Ok(Self::CloseProducerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 23 => ::core::result::Result::Ok(Self::CloseConsumerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 24 => ::core::result::Result::Ok(Self::CloseDataProducerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 25 => ::core::result::Result::Ok(Self::CloseDataConsumerRequest( - ::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::ConnectRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 29 => ::core::result::Result::Ok(Self::SetPreferredLayersRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 30 => ::core::result::Result::Ok(Self::SetPriorityRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 31 => { - ::core::result::Result::Ok(Self::SetBufferedAmountLowThresholdRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )) - } - 32 => ::core::result::Result::Ok(Self::SendRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 33 => ::core::result::Result::Ok(Self::SetSubchannelsRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 34 => ::core::result::Result::Ok(Self::AddProducerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 35 => ::core::result::Result::Ok(Self::RemoveProducerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), - } + /// 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 [`FBS_Worker_DumpResponse` variant](Body#variant.FbsWorkerDumpResponse). + #[inline] + pub fn fbs_worker_dump_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`FBS_Worker_ResourceUsageResponse` variant](Body#variant.FbsWorkerResourceUsageResponse). + #[inline] + pub fn fbs_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 [`FBS_WebRtcServer_DumpResponse` variant](Body#variant.FbsWebRtcServerDumpResponse). + #[inline] + pub fn fbs_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 [`FBS_Router_DumpResponse` variant](Body#variant.FbsRouterDumpResponse). + #[inline] + pub fn fbs_router_dump_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<4, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`FBS_Transport_ProduceResponse` variant](Body#variant.FbsTransportProduceResponse). + #[inline] + pub fn fbs_transport_produce_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<5, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`FBS_Transport_ConsumeResponse` variant](Body#variant.FbsTransportConsumeResponse). + #[inline] + pub fn fbs_transport_consume_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<6, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`FBS_Transport_RestartIceResponse` variant](Body#variant.FbsTransportRestartIceResponse). + #[inline] + pub fn fbs_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 [`FBS_PlainTransport_ConnectResponse` variant](Body#variant.FbsPlainTransportConnectResponse). + #[inline] + pub fn fbs_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 [`FBS_PlainTransport_DumpResponse` variant](Body#variant.FbsPlainTransportDumpResponse). + #[inline] + pub fn fbs_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 [`FBS_PlainTransport_GetStatsResponse` variant](Body#variant.FbsPlainTransportGetStatsResponse). + #[inline] + pub fn fbs_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 [`FBS_PipeTransport_ConnectResponse` variant](Body#variant.FbsPipeTransportConnectResponse). + #[inline] + pub fn fbs_pipe_transport_connect_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<11, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - } - /// 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, - } + /// Creates an instance of the [`FBS_PipeTransport_DumpResponse` variant](Body#variant.FbsPipeTransportDumpResponse). + #[inline] + pub fn fbs_pipe_transport_dump_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<12, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - impl Request { - /// Creates a [RequestBuilder] for serializing an instance of this table. + /// Creates an instance of the [`FBS_PipeTransport_GetStatsResponse` variant](Body#variant.FbsPipeTransportGetStatsResponse). #[inline] - pub fn builder() -> RequestBuilder<()> { - RequestBuilder(()) + pub fn fbs_pipe_transport_get_stats_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<13, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - #[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); + /// Creates an instance of the [`FBS_DirectTransport_DumpResponse` variant](Body#variant.FbsDirectTransportDumpResponse). + #[inline] + pub fn fbs_direct_transport_dump_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<14, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - 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); - } + /// Creates an instance of the [`FBS_DirectTransport_GetStatsResponse` variant](Body#variant.FbsDirectTransportGetStatsResponse). + #[inline] + pub fn fbs_direct_transport_get_stats_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<15, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - 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() + /// Creates an instance of the [`FBS_WebRtcTransport_ConnectResponse` variant](Body#variant.FbsWebRtcTransportConnectResponse). + #[inline] + pub fn fbs_web_rtc_transport_connect_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<16, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - } - impl ::planus::WriteAs<::planus::Offset> for Request { - type Prepared = ::planus::Offset; + /// Creates an instance of the [`FBS_WebRtcTransport_DumpResponse` variant](Body#variant.FbsWebRtcTransportDumpResponse). + #[inline] + pub fn fbs_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 [`FBS_WebRtcTransport_GetStatsResponse` variant](Body#variant.FbsWebRtcTransportGetStatsResponse). #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + pub fn fbs_web_rtc_transport_get_stats_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<18, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - } - impl ::planus::WriteAsOptional<::planus::Offset> for Request { - type Prepared = ::planus::Offset; + /// Creates an instance of the [`FBS_Producer_DumpResponse` variant](Body#variant.FbsProducerDumpResponse). + #[inline] + pub fn fbs_producer_dump_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<19, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + /// Creates an instance of the [`FBS_Producer_GetStatsResponse` variant](Body#variant.FbsProducerGetStatsResponse). #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + pub fn fbs_producer_get_stats_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<20, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - } - impl ::planus::WriteAsOffset for Request { + /// Creates an instance of the [`FBS_Consumer_DumpResponse` variant](Body#variant.FbsConsumerDumpResponse). #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Request::create(builder, self.id, self.method, &self.handler_id, &self.body) + pub fn fbs_consumer_dump_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<21, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - } - /// 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); + /// Creates an instance of the [`FBS_Consumer_GetStatsResponse` variant](Body#variant.FbsConsumerGetStatsResponse). + #[inline] + pub fn fbs_consumer_get_stats_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<22, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } - impl RequestBuilder<()> { - /// Setter for the [`id` field](Request#structfield.id). + /// Creates an instance of the [`FBS_Consumer_SetPreferredLayersResponse` variant](Body#variant.FbsConsumerSetPreferredLayersResponse). #[inline] - #[allow(clippy::type_complexity)] - pub fn id(self, value: T0) -> RequestBuilder<(T0,)> + pub fn fbs_consumer_set_preferred_layers_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<23, T>> where - T0: ::planus::WriteAsDefault, + T: ::planus::WriteAsOffset, { - RequestBuilder((value,)) + BodyBuilder(::planus::Initialized(value)) } - /// Sets the [`id` field](Request#structfield.id) to the default value. + /// Creates an instance of the [`FBS_Consumer_SetPriorityResponse` variant](Body#variant.FbsConsumerSetPriorityResponse). #[inline] - #[allow(clippy::type_complexity)] - pub fn id_as_default(self) -> RequestBuilder<(::planus::DefaultValue,)> { - self.id(::planus::DefaultValue) + pub fn fbs_consumer_set_priority_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<24, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - } - impl RequestBuilder<(T0,)> { - /// Setter for the [`method` field](Request#structfield.method). + /// Creates an instance of the [`FBS_DataProducer_DumpResponse` variant](Body#variant.FbsDataProducerDumpResponse). #[inline] - #[allow(clippy::type_complexity)] - pub fn method(self, value: T1) -> RequestBuilder<(T0, T1)> + pub fn fbs_data_producer_dump_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<25, T>> where - T1: ::planus::WriteAsDefault, + T: ::planus::WriteAsOffset, { - let (v0,) = self.0; - RequestBuilder((v0, value)) + BodyBuilder(::planus::Initialized(value)) } - /// Sets the [`method` field](Request#structfield.method) to the default value. + /// Creates an instance of the [`FBS_DataProducer_GetStatsResponse` variant](Body#variant.FbsDataProducerGetStatsResponse). #[inline] - #[allow(clippy::type_complexity)] - pub fn method_as_default(self) -> RequestBuilder<(T0, ::planus::DefaultValue)> { - self.method(::planus::DefaultValue) + pub fn fbs_data_producer_get_stats_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<26, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } - } - impl RequestBuilder<(T0, T1)> { - /// Setter for the [`handler_id` field](Request#structfield.handler_id). + /// Creates an instance of the [`FBS_DataConsumer_GetBufferedAmountResponse` variant](Body#variant.FbsDataConsumerGetBufferedAmountResponse). #[inline] - #[allow(clippy::type_complexity)] - pub fn handler_id(self, value: T2) -> RequestBuilder<(T0, T1, T2)> + pub fn fbs_data_consumer_get_buffered_amount_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<27, T>> where - T2: ::planus::WriteAs<::planus::Offset>, + T: ::planus::WriteAsOffset, { - let (v0, v1) = self.0; - RequestBuilder((v0, v1, value)) + BodyBuilder(::planus::Initialized(value)) } - } - impl RequestBuilder<(T0, T1, T2)> { - /// Setter for the [`body` field](Request#structfield.body). + /// Creates an instance of the [`FBS_DataConsumer_DumpResponse` variant](Body#variant.FbsDataConsumerDumpResponse). #[inline] - #[allow(clippy::type_complexity)] - pub fn body(self, value: T3) -> RequestBuilder<(T0, T1, T2, T3)> + pub fn fbs_data_consumer_dump_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<28, T>> where - T3: ::planus::WriteAsOptionalUnion, + T: ::planus::WriteAsOffset, { - let (v0, v1, v2) = self.0; - RequestBuilder((v0, v1, v2, value)) + BodyBuilder(::planus::Initialized(value)) } - /// Sets the [`body` field](Request#structfield.body) to null. + /// Creates an instance of the [`FBS_DataConsumer_GetStatsResponse` variant](Body#variant.FbsDataConsumerGetStatsResponse). #[inline] - #[allow(clippy::type_complexity)] - pub fn body_as_null(self) -> RequestBuilder<(T0, T1, T2, ())> { - self.body(()) + pub fn fbs_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 [`FBS_DataConsumer_SetSubchannelsResponse` variant](Body#variant.FbsDataConsumerSetSubchannelsResponse). + #[inline] + pub fn fbs_data_consumer_set_subchannels_response( + self, + value: T, + ) -> BodyBuilder<::planus::Initialized<30, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) } } - impl RequestBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Request]. + 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::Offset + pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsUnion, { - ::planus::WriteAsOffset::prepare(&self, builder) + ::planus::WriteAsUnion::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)> + impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, { - type Prepared = ::planus::Offset; + #[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) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + 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< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAs<::planus::Offset>, - T3: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAsOptional<::planus::Offset> - for RequestBuilder<(T0, T1, T2, T3)> + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<9, T>> + where + T: ::planus::WriteAsOffset, { - type Prepared = ::planus::Offset; - #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::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)> + impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<10, T>> + where + T: ::planus::WriteAsOffset, { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - Request::create(builder, v0, v1, v2, v3) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(10, (self.0).0.prepare(builder).downcast()) } } - /// 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). + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<10, T>> + where + T: ::planus::WriteAsOffset, + { #[inline] - pub fn method(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(1, "Request", "method")? - .unwrap_or(self::Method::WorkerClose), - ) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } - - /// Getter for the [`handler_id` field](Request#structfield.handler_id). + } + impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<11, T>> + where + T: ::planus::WriteAsOffset, + { #[inline] - pub fn handler_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(2, "Request", "handler_id") + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(11, (self.0).0.prepare(builder).downcast()) } + } - /// Getter for the [`body` field](Request#structfield.body). + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<11, T>> + where + T: ::planus::WriteAsOffset, + { #[inline] - pub fn body(&self) -> ::planus::Result<::core::option::Option>> { - self.0.access_union(3, "Request", "body") + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - - 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 ::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<'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 ::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<'a> ::planus::TableRead<'a> for RequestRef<'a> { + impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<13, T>> + where + T: ::planus::WriteAsOffset, + { #[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, - )?)) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(13, (self.0).0.prepare(builder).downcast()) } } - 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::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::VectorWrite<::planus::Offset> for Request { - type Value = ::planus::Offset; - const STRIDE: usize = 4; + impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<14, T>> + where + T: ::planus::WriteAsOffset, + { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) + 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] - 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, - ); - } + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - - 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) - }) + 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()) } } - } - /// 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 `FBS_Worker_DumpResponse` in the union `Body` - FbsWorkerDumpResponse(::planus::alloc::boxed::Box), - - /// The variant `FBS_Worker_ResourceUsageResponse` in the union `Body` - FbsWorkerResourceUsageResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_WebRtcServer_DumpResponse` in the union `Body` - FbsWebRtcServerDumpResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_Router_DumpResponse` in the union `Body` - FbsRouterDumpResponse(::planus::alloc::boxed::Box), - - /// The variant `FBS_Transport_ProduceResponse` in the union `Body` - FbsTransportProduceResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_Transport_ConsumeResponse` in the union `Body` - FbsTransportConsumeResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_Transport_RestartIceResponse` in the union `Body` - FbsTransportRestartIceResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_PlainTransport_ConnectResponse` in the union `Body` - FbsPlainTransportConnectResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_PlainTransport_DumpResponse` in the union `Body` - FbsPlainTransportDumpResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_PlainTransport_GetStatsResponse` in the union `Body` - FbsPlainTransportGetStatsResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_PipeTransport_ConnectResponse` in the union `Body` - FbsPipeTransportConnectResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_PipeTransport_DumpResponse` in the union `Body` - FbsPipeTransportDumpResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_PipeTransport_GetStatsResponse` in the union `Body` - FbsPipeTransportGetStatsResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_DirectTransport_DumpResponse` in the union `Body` - FbsDirectTransportDumpResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_DirectTransport_GetStatsResponse` in the union `Body` - FbsDirectTransportGetStatsResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_WebRtcTransport_ConnectResponse` in the union `Body` - FbsWebRtcTransportConnectResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_WebRtcTransport_DumpResponse` in the union `Body` - FbsWebRtcTransportDumpResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_WebRtcTransport_GetStatsResponse` in the union `Body` - FbsWebRtcTransportGetStatsResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_Producer_DumpResponse` in the union `Body` - FbsProducerDumpResponse(::planus::alloc::boxed::Box), - - /// The variant `FBS_Producer_GetStatsResponse` in the union `Body` - FbsProducerGetStatsResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_Consumer_DumpResponse` in the union `Body` - FbsConsumerDumpResponse(::planus::alloc::boxed::Box), - - /// The variant `FBS_Consumer_GetStatsResponse` in the union `Body` - FbsConsumerGetStatsResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_Consumer_SetPreferredLayersResponse` in the union `Body` - FbsConsumerSetPreferredLayersResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_Consumer_SetPriorityResponse` in the union `Body` - FbsConsumerSetPriorityResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_DataProducer_DumpResponse` in the union `Body` - FbsDataProducerDumpResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_DataProducer_GetStatsResponse` in the union `Body` - FbsDataProducerGetStatsResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_DataConsumer_GetBufferedAmountResponse` in the union `Body` - FbsDataConsumerGetBufferedAmountResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_DataConsumer_DumpResponse` in the union `Body` - FbsDataConsumerDumpResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_DataConsumer_GetStatsResponse` in the union `Body` - FbsDataConsumerGetStatsResponse( - ::planus::alloc::boxed::Box, - ), - - /// The variant `FBS_DataConsumer_SetSubchannelsResponse` in the union `Body` - FbsDataConsumerSetSubchannelsResponse( - ::planus::alloc::boxed::Box, - ), - } - impl Body { - /// Creates a [BodyBuilder] for serializing an instance of this table. + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<15, T>> + where + T: ::planus::WriteAsOffset, + { #[inline] - pub fn builder() -> BodyBuilder<::planus::Uninitialized> { - BodyBuilder(::planus::Uninitialized) + 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] - pub fn create_fbs_worker_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + 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] - pub fn create_fbs_worker_resource_usage_response( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_fbs_web_rtc_server_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) + 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] - pub fn create_fbs_router_dump_response( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_fbs_transport_produce_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) + 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] - pub fn create_fbs_transport_consume_response( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(6, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_fbs_transport_restart_ice_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(7, value.prepare(builder).downcast()) + 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] - pub fn create_fbs_plain_transport_connect_response( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(8, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_fbs_plain_transport_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(9, value.prepare(builder).downcast()) + 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] - pub fn create_fbs_plain_transport_get_stats_response( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(10, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_fbs_pipe_transport_connect_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) + 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] - pub fn create_fbs_pipe_transport_dump_response( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_fbs_pipe_transport_get_stats_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) + 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] - pub fn create_fbs_direct_transport_dump_response( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_fbs_direct_transport_get_stats_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) + 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] - pub fn create_fbs_web_rtc_transport_connect_response( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_fbs_web_rtc_transport_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) + 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] - pub fn create_fbs_web_rtc_transport_get_stats_response( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(18, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_fbs_producer_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(19, value.prepare(builder).downcast()) + 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] - pub fn create_fbs_producer_get_stats_response( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(20, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_fbs_consumer_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(21, value.prepare(builder).downcast()) + 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] - pub fn create_fbs_consumer_get_stats_response( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(22, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_fbs_consumer_set_preferred_layers_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(23, value.prepare(builder).downcast()) + 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] - pub fn create_fbs_consumer_set_priority_response( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(24, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_fbs_data_producer_dump_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(25, value.prepare(builder).downcast()) + 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] - pub fn create_fbs_data_producer_get_stats_response( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(26, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_fbs_data_consumer_get_buffered_amount_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(27, value.prepare(builder).downcast()) + 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] - pub fn create_fbs_data_consumer_dump_response( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(28, value.prepare(builder).downcast()) + ) -> ::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] - pub fn create_fbs_data_consumer_get_stats_response( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(29, value.prepare(builder).downcast()) + 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] - pub fn create_fbs_data_consumer_set_subchannels_response( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(30, value.prepare(builder).downcast()) + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - impl ::planus::WriteAsUnion for Body { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - match self { - Self::FbsWorkerDumpResponse(value) => { - Self::create_fbs_worker_dump_response(builder, value) + /// Reference to a deserialized [Body]. + #[derive(Copy, Clone, Debug)] + pub enum BodyRef<'a> { + FbsWorkerDumpResponse(super::worker::DumpResponseRef<'a>), + FbsWorkerResourceUsageResponse(super::worker::ResourceUsageResponseRef<'a>), + FbsWebRtcServerDumpResponse(super::web_rtc_server::DumpResponseRef<'a>), + FbsRouterDumpResponse(super::router::DumpResponseRef<'a>), + FbsTransportProduceResponse(super::transport::ProduceResponseRef<'a>), + FbsTransportConsumeResponse(super::transport::ConsumeResponseRef<'a>), + FbsTransportRestartIceResponse(super::transport::RestartIceResponseRef<'a>), + FbsPlainTransportConnectResponse(super::plain_transport::ConnectResponseRef<'a>), + FbsPlainTransportDumpResponse(super::plain_transport::DumpResponseRef<'a>), + FbsPlainTransportGetStatsResponse(super::plain_transport::GetStatsResponseRef<'a>), + FbsPipeTransportConnectResponse(super::pipe_transport::ConnectResponseRef<'a>), + FbsPipeTransportDumpResponse(super::pipe_transport::DumpResponseRef<'a>), + FbsPipeTransportGetStatsResponse(super::pipe_transport::GetStatsResponseRef<'a>), + FbsDirectTransportDumpResponse(super::direct_transport::DumpResponseRef<'a>), + FbsDirectTransportGetStatsResponse( + super::direct_transport::GetStatsResponseRef<'a>, + ), + FbsWebRtcTransportConnectResponse(super::web_rtc_transport::ConnectResponseRef<'a>), + FbsWebRtcTransportDumpResponse(super::web_rtc_transport::DumpResponseRef<'a>), + FbsWebRtcTransportGetStatsResponse( + super::web_rtc_transport::GetStatsResponseRef<'a>, + ), + FbsProducerDumpResponse(super::producer::DumpResponseRef<'a>), + FbsProducerGetStatsResponse(super::producer::GetStatsResponseRef<'a>), + FbsConsumerDumpResponse(super::consumer::DumpResponseRef<'a>), + FbsConsumerGetStatsResponse(super::consumer::GetStatsResponseRef<'a>), + FbsConsumerSetPreferredLayersResponse( + super::consumer::SetPreferredLayersResponseRef<'a>, + ), + FbsConsumerSetPriorityResponse(super::consumer::SetPriorityResponseRef<'a>), + FbsDataProducerDumpResponse(super::data_producer::DumpResponseRef<'a>), + FbsDataProducerGetStatsResponse(super::data_producer::GetStatsResponseRef<'a>), + FbsDataConsumerGetBufferedAmountResponse( + super::data_consumer::GetBufferedAmountResponseRef<'a>, + ), + FbsDataConsumerDumpResponse(super::data_consumer::DumpResponseRef<'a>), + FbsDataConsumerGetStatsResponse(super::data_consumer::GetStatsResponseRef<'a>), + FbsDataConsumerSetSubchannelsResponse( + 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::FbsWorkerDumpResponse(value) => { + Self::FbsWorkerDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsWorkerResourceUsageResponse(value) => { - Self::create_fbs_worker_resource_usage_response(builder, value) + + BodyRef::FbsWorkerResourceUsageResponse(value) => { + Self::FbsWorkerResourceUsageResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsWebRtcServerDumpResponse(value) => { - Self::create_fbs_web_rtc_server_dump_response(builder, value) + + BodyRef::FbsWebRtcServerDumpResponse(value) => { + Self::FbsWebRtcServerDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsRouterDumpResponse(value) => { - Self::create_fbs_router_dump_response(builder, value) + + BodyRef::FbsRouterDumpResponse(value) => { + Self::FbsRouterDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsTransportProduceResponse(value) => { - Self::create_fbs_transport_produce_response(builder, value) + + BodyRef::FbsTransportProduceResponse(value) => { + Self::FbsTransportProduceResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsTransportConsumeResponse(value) => { - Self::create_fbs_transport_consume_response(builder, value) + + BodyRef::FbsTransportConsumeResponse(value) => { + Self::FbsTransportConsumeResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsTransportRestartIceResponse(value) => { - Self::create_fbs_transport_restart_ice_response(builder, value) + + BodyRef::FbsTransportRestartIceResponse(value) => { + Self::FbsTransportRestartIceResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsPlainTransportConnectResponse(value) => { - Self::create_fbs_plain_transport_connect_response(builder, value) + + BodyRef::FbsPlainTransportConnectResponse(value) => { + Self::FbsPlainTransportConnectResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) } - Self::FbsPlainTransportDumpResponse(value) => { - Self::create_fbs_plain_transport_dump_response(builder, value) + + BodyRef::FbsPlainTransportDumpResponse(value) => { + Self::FbsPlainTransportDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsPlainTransportGetStatsResponse(value) => { - Self::create_fbs_plain_transport_get_stats_response(builder, value) + + BodyRef::FbsPlainTransportGetStatsResponse(value) => { + Self::FbsPlainTransportGetStatsResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) } - Self::FbsPipeTransportConnectResponse(value) => { - Self::create_fbs_pipe_transport_connect_response(builder, value) + + BodyRef::FbsPipeTransportConnectResponse(value) => { + Self::FbsPipeTransportConnectResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsPipeTransportDumpResponse(value) => { - Self::create_fbs_pipe_transport_dump_response(builder, value) + + BodyRef::FbsPipeTransportDumpResponse(value) => { + Self::FbsPipeTransportDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsPipeTransportGetStatsResponse(value) => { - Self::create_fbs_pipe_transport_get_stats_response(builder, value) + + BodyRef::FbsPipeTransportGetStatsResponse(value) => { + Self::FbsPipeTransportGetStatsResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) } - Self::FbsDirectTransportDumpResponse(value) => { - Self::create_fbs_direct_transport_dump_response(builder, value) + + BodyRef::FbsDirectTransportDumpResponse(value) => { + Self::FbsDirectTransportDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsDirectTransportGetStatsResponse(value) => { - Self::create_fbs_direct_transport_get_stats_response(builder, value) + + BodyRef::FbsDirectTransportGetStatsResponse(value) => { + Self::FbsDirectTransportGetStatsResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) } - Self::FbsWebRtcTransportConnectResponse(value) => { - Self::create_fbs_web_rtc_transport_connect_response(builder, value) + + BodyRef::FbsWebRtcTransportConnectResponse(value) => { + Self::FbsWebRtcTransportConnectResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) } - Self::FbsWebRtcTransportDumpResponse(value) => { - Self::create_fbs_web_rtc_transport_dump_response(builder, value) + + BodyRef::FbsWebRtcTransportDumpResponse(value) => { + Self::FbsWebRtcTransportDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsWebRtcTransportGetStatsResponse(value) => { - Self::create_fbs_web_rtc_transport_get_stats_response(builder, value) + + BodyRef::FbsWebRtcTransportGetStatsResponse(value) => { + Self::FbsWebRtcTransportGetStatsResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) } - Self::FbsProducerDumpResponse(value) => { - Self::create_fbs_producer_dump_response(builder, value) + + BodyRef::FbsProducerDumpResponse(value) => { + Self::FbsProducerDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsProducerGetStatsResponse(value) => { - Self::create_fbs_producer_get_stats_response(builder, value) + + BodyRef::FbsProducerGetStatsResponse(value) => { + Self::FbsProducerGetStatsResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsConsumerDumpResponse(value) => { - Self::create_fbs_consumer_dump_response(builder, value) + + BodyRef::FbsConsumerDumpResponse(value) => { + Self::FbsConsumerDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsConsumerGetStatsResponse(value) => { - Self::create_fbs_consumer_get_stats_response(builder, value) + + BodyRef::FbsConsumerGetStatsResponse(value) => { + Self::FbsConsumerGetStatsResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsConsumerSetPreferredLayersResponse(value) => { - Self::create_fbs_consumer_set_preferred_layers_response(builder, value) + + BodyRef::FbsConsumerSetPreferredLayersResponse(value) => { + Self::FbsConsumerSetPreferredLayersResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), + ) } - Self::FbsConsumerSetPriorityResponse(value) => { - Self::create_fbs_consumer_set_priority_response(builder, value) + + BodyRef::FbsConsumerSetPriorityResponse(value) => { + Self::FbsConsumerSetPriorityResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsDataProducerDumpResponse(value) => { - Self::create_fbs_data_producer_dump_response(builder, value) + + BodyRef::FbsDataProducerDumpResponse(value) => { + Self::FbsDataProducerDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsDataProducerGetStatsResponse(value) => { - Self::create_fbs_data_producer_get_stats_response(builder, value) + + BodyRef::FbsDataProducerGetStatsResponse(value) => { + Self::FbsDataProducerGetStatsResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsDataConsumerGetBufferedAmountResponse(value) => { - Self::create_fbs_data_consumer_get_buffered_amount_response( - builder, value, + + BodyRef::FbsDataConsumerGetBufferedAmountResponse(value) => { + Self::FbsDataConsumerGetBufferedAmountResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + ), ) } - Self::FbsDataConsumerDumpResponse(value) => { - Self::create_fbs_data_consumer_dump_response(builder, value) + + BodyRef::FbsDataConsumerDumpResponse(value) => { + Self::FbsDataConsumerDumpResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsDataConsumerGetStatsResponse(value) => { - Self::create_fbs_data_consumer_get_stats_response(builder, value) + + BodyRef::FbsDataConsumerGetStatsResponse(value) => { + Self::FbsDataConsumerGetStatsResponse(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) } - Self::FbsDataConsumerSetSubchannelsResponse(value) => { - Self::create_fbs_data_consumer_set_subchannels_response(builder, value) + + BodyRef::FbsDataConsumerSetSubchannelsResponse(value) => { + Self::FbsDataConsumerSetSubchannelsResponse( + ::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(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)) + 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::FbsWorkerDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 2 => ::core::result::Result::Ok(Self::FbsWorkerResourceUsageResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 3 => ::core::result::Result::Ok(Self::FbsWebRtcServerDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 4 => ::core::result::Result::Ok(Self::FbsRouterDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 5 => ::core::result::Result::Ok(Self::FbsTransportProduceResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 6 => ::core::result::Result::Ok(Self::FbsTransportConsumeResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 7 => ::core::result::Result::Ok(Self::FbsTransportRestartIceResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 8 => ::core::result::Result::Ok(Self::FbsPlainTransportConnectResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 9 => ::core::result::Result::Ok(Self::FbsPlainTransportDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 10 => ::core::result::Result::Ok(Self::FbsPlainTransportGetStatsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 11 => ::core::result::Result::Ok(Self::FbsPipeTransportConnectResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 12 => ::core::result::Result::Ok(Self::FbsPipeTransportDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 13 => ::core::result::Result::Ok(Self::FbsPipeTransportGetStatsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 14 => ::core::result::Result::Ok(Self::FbsDirectTransportDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 15 => ::core::result::Result::Ok(Self::FbsDirectTransportGetStatsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 16 => ::core::result::Result::Ok(Self::FbsWebRtcTransportConnectResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 17 => ::core::result::Result::Ok(Self::FbsWebRtcTransportDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 18 => ::core::result::Result::Ok(Self::FbsWebRtcTransportGetStatsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 19 => ::core::result::Result::Ok(Self::FbsProducerDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 20 => ::core::result::Result::Ok(Self::FbsProducerGetStatsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 21 => ::core::result::Result::Ok(Self::FbsConsumerDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 22 => ::core::result::Result::Ok(Self::FbsConsumerGetStatsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 23 => { + ::core::result::Result::Ok(Self::FbsConsumerSetPreferredLayersResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )) + } + 24 => ::core::result::Result::Ok(Self::FbsConsumerSetPriorityResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 25 => ::core::result::Result::Ok(Self::FbsDataProducerDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 26 => ::core::result::Result::Ok(Self::FbsDataProducerGetStatsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 27 => ::core::result::Result::Ok( + Self::FbsDataConsumerGetBufferedAmountResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + ), + ), + 28 => ::core::result::Result::Ok(Self::FbsDataConsumerDumpResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 29 => ::core::result::Result::Ok(Self::FbsDataConsumerGetStatsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 30 => { + ::core::result::Result::Ok(Self::FbsDataConsumerSetSubchannelsResponse( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )) + } + _ => ::core::result::Result::Err( + ::planus::errors::ErrorKind::UnknownUnionTag { tag }, + ), + } } } - /// Builder for serializing an instance of the [Body] type. + /// The table `Response` in the namespace `FBS.Response` /// - /// 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 [`FBS_Worker_DumpResponse` variant](Body#variant.FbsWorkerDumpResponse). - #[inline] - pub fn fbs_worker_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`FBS_Worker_ResourceUsageResponse` variant](Body#variant.FbsWorkerResourceUsageResponse). - #[inline] - pub fn fbs_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 [`FBS_WebRtcServer_DumpResponse` variant](Body#variant.FbsWebRtcServerDumpResponse). - #[inline] - pub fn fbs_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 [`FBS_Router_DumpResponse` variant](Body#variant.FbsRouterDumpResponse). - #[inline] - pub fn fbs_router_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`FBS_Transport_ProduceResponse` variant](Body#variant.FbsTransportProduceResponse). - #[inline] - pub fn fbs_transport_produce_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`FBS_Transport_ConsumeResponse` variant](Body#variant.FbsTransportConsumeResponse). - #[inline] - pub fn fbs_transport_consume_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<6, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`FBS_Transport_RestartIceResponse` variant](Body#variant.FbsTransportRestartIceResponse). - #[inline] - pub fn fbs_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 [`FBS_PlainTransport_ConnectResponse` variant](Body#variant.FbsPlainTransportConnectResponse). - #[inline] - pub fn fbs_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 [`FBS_PlainTransport_DumpResponse` variant](Body#variant.FbsPlainTransportDumpResponse). - #[inline] - pub fn fbs_plain_transport_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<9, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// 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>, + } - /// Creates an instance of the [`FBS_PlainTransport_GetStatsResponse` variant](Body#variant.FbsPlainTransportGetStatsResponse). - #[inline] - pub fn fbs_plain_transport_get_stats_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<10, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + #[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(), + } } + } - /// Creates an instance of the [`FBS_PipeTransport_ConnectResponse` variant](Body#variant.FbsPipeTransportConnectResponse). + impl Response { + /// Creates a [ResponseBuilder] for serializing an instance of this table. #[inline] - pub fn fbs_pipe_transport_connect_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<11, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + pub fn builder() -> ResponseBuilder<()> { + ResponseBuilder(()) } - /// Creates an instance of the [`FBS_PipeTransport_DumpResponse` variant](Body#variant.FbsPipeTransportDumpResponse). - #[inline] - pub fn fbs_pipe_transport_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<12, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + #[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); - /// Creates an instance of the [`FBS_PipeTransport_GetStatsResponse` variant](Body#variant.FbsPipeTransportGetStatsResponse). - #[inline] - pub fn fbs_pipe_transport_get_stats_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<13, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + 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); + } - /// Creates an instance of the [`FBS_DirectTransport_DumpResponse` variant](Body#variant.FbsDirectTransportDumpResponse). - #[inline] - pub fn fbs_direct_transport_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<14, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + 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() } + } - /// Creates an instance of the [`FBS_DirectTransport_GetStatsResponse` variant](Body#variant.FbsDirectTransportGetStatsResponse). - #[inline] - pub fn fbs_direct_transport_get_stats_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<15, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + impl ::planus::WriteAs<::planus::Offset> for Response { + type Prepared = ::planus::Offset; - /// Creates an instance of the [`FBS_WebRtcTransport_ConnectResponse` variant](Body#variant.FbsWebRtcTransportConnectResponse). #[inline] - pub fn fbs_web_rtc_transport_connect_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<16, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } + } - /// Creates an instance of the [`FBS_WebRtcTransport_DumpResponse` variant](Body#variant.FbsWebRtcTransportDumpResponse). - #[inline] - pub fn fbs_web_rtc_transport_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<17, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + impl ::planus::WriteAsOptional<::planus::Offset> for Response { + type Prepared = ::planus::Offset; - /// Creates an instance of the [`FBS_WebRtcTransport_GetStatsResponse` variant](Body#variant.FbsWebRtcTransportGetStatsResponse). #[inline] - pub fn fbs_web_rtc_transport_get_stats_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<18, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } + } - /// Creates an instance of the [`FBS_Producer_DumpResponse` variant](Body#variant.FbsProducerDumpResponse). + impl ::planus::WriteAsOffset for Response { #[inline] - pub fn fbs_producer_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<19, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Response::create( + builder, + self.id, + self.accepted, + &self.body, + &self.error, + &self.reason, + ) } + } - /// Creates an instance of the [`FBS_Producer_GetStatsResponse` variant](Body#variant.FbsProducerGetStatsResponse). - #[inline] - pub fn fbs_producer_get_stats_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<20, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) - } + /// 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); - /// Creates an instance of the [`FBS_Consumer_DumpResponse` variant](Body#variant.FbsConsumerDumpResponse). + impl ResponseBuilder<()> { + /// Setter for the [`id` field](Response#structfield.id). #[inline] - pub fn fbs_consumer_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<21, T>> + #[allow(clippy::type_complexity)] + pub fn id(self, value: T0) -> ResponseBuilder<(T0,)> where - T: ::planus::WriteAsOffset, + T0: ::planus::WriteAsDefault, { - BodyBuilder(::planus::Initialized(value)) + ResponseBuilder((value,)) } - /// Creates an instance of the [`FBS_Consumer_GetStatsResponse` variant](Body#variant.FbsConsumerGetStatsResponse). + /// Sets the [`id` field](Response#structfield.id) to the default value. #[inline] - pub fn fbs_consumer_get_stats_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<22, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + #[allow(clippy::type_complexity)] + pub fn id_as_default(self) -> ResponseBuilder<(::planus::DefaultValue,)> { + self.id(::planus::DefaultValue) } + } - /// Creates an instance of the [`FBS_Consumer_SetPreferredLayersResponse` variant](Body#variant.FbsConsumerSetPreferredLayersResponse). + impl ResponseBuilder<(T0,)> { + /// Setter for the [`accepted` field](Response#structfield.accepted). #[inline] - pub fn fbs_consumer_set_preferred_layers_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<23, T>> + #[allow(clippy::type_complexity)] + pub fn accepted(self, value: T1) -> ResponseBuilder<(T0, T1)> where - T: ::planus::WriteAsOffset, + T1: ::planus::WriteAsDefault, { - BodyBuilder(::planus::Initialized(value)) + let (v0,) = self.0; + ResponseBuilder((v0, value)) } - /// Creates an instance of the [`FBS_Consumer_SetPriorityResponse` variant](Body#variant.FbsConsumerSetPriorityResponse). + /// Sets the [`accepted` field](Response#structfield.accepted) to the default value. #[inline] - pub fn fbs_consumer_set_priority_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<24, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + #[allow(clippy::type_complexity)] + pub fn accepted_as_default(self) -> ResponseBuilder<(T0, ::planus::DefaultValue)> { + self.accepted(::planus::DefaultValue) } + } - /// Creates an instance of the [`FBS_DataProducer_DumpResponse` variant](Body#variant.FbsDataProducerDumpResponse). + impl ResponseBuilder<(T0, T1)> { + /// Setter for the [`body` field](Response#structfield.body). #[inline] - pub fn fbs_data_producer_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<25, T>> + #[allow(clippy::type_complexity)] + pub fn body(self, value: T2) -> ResponseBuilder<(T0, T1, T2)> where - T: ::planus::WriteAsOffset, + T2: ::planus::WriteAsOptionalUnion, { - BodyBuilder(::planus::Initialized(value)) + let (v0, v1) = self.0; + ResponseBuilder((v0, v1, value)) } - /// Creates an instance of the [`FBS_DataProducer_GetStatsResponse` variant](Body#variant.FbsDataProducerGetStatsResponse). + /// Sets the [`body` field](Response#structfield.body) to null. #[inline] - pub fn fbs_data_producer_get_stats_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<26, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + #[allow(clippy::type_complexity)] + pub fn body_as_null(self) -> ResponseBuilder<(T0, T1, ())> { + self.body(()) } + } - /// Creates an instance of the [`FBS_DataConsumer_GetBufferedAmountResponse` variant](Body#variant.FbsDataConsumerGetBufferedAmountResponse). + impl ResponseBuilder<(T0, T1, T2)> { + /// Setter for the [`error` field](Response#structfield.error). #[inline] - pub fn fbs_data_consumer_get_buffered_amount_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<27, T>> + #[allow(clippy::type_complexity)] + pub fn error(self, value: T3) -> ResponseBuilder<(T0, T1, T2, T3)> where - T: ::planus::WriteAsOffset, + T3: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, { - BodyBuilder(::planus::Initialized(value)) + let (v0, v1, v2) = self.0; + ResponseBuilder((v0, v1, v2, value)) } - /// Creates an instance of the [`FBS_DataConsumer_DumpResponse` variant](Body#variant.FbsDataConsumerDumpResponse). + /// Sets the [`error` field](Response#structfield.error) to null. #[inline] - pub fn fbs_data_consumer_dump_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<28, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + #[allow(clippy::type_complexity)] + pub fn error_as_null(self) -> ResponseBuilder<(T0, T1, T2, ())> { + self.error(()) } + } - /// Creates an instance of the [`FBS_DataConsumer_GetStatsResponse` variant](Body#variant.FbsDataConsumerGetStatsResponse). + impl ResponseBuilder<(T0, T1, T2, T3)> { + /// Setter for the [`reason` field](Response#structfield.reason). #[inline] - pub fn fbs_data_consumer_get_stats_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<29, T>> + #[allow(clippy::type_complexity)] + pub fn reason(self, value: T4) -> ResponseBuilder<(T0, T1, T2, T3, T4)> where - T: ::planus::WriteAsOffset, + T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, { - BodyBuilder(::planus::Initialized(value)) + let (v0, v1, v2, v3) = self.0; + ResponseBuilder((v0, v1, v2, v3, value)) } - /// Creates an instance of the [`FBS_DataConsumer_SetSubchannelsResponse` variant](Body#variant.FbsDataConsumerSetSubchannelsResponse). + /// Sets the [`reason` field](Response#structfield.reason) to null. #[inline] - pub fn fbs_data_consumer_set_subchannels_response( - self, - value: T, - ) -> BodyBuilder<::planus::Initialized<30, T>> - where - T: ::planus::WriteAsOffset, - { - BodyBuilder(::planus::Initialized(value)) + #[allow(clippy::type_complexity)] + pub fn reason_as_null(self) -> ResponseBuilder<(T0, T1, T2, T3, ())> { + self.reason(()) } } - impl BodyBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Body]. + 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::UnionOffset + pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset where - Self: ::planus::WriteAsUnion, + Self: ::planus::WriteAsOffset, { - ::planus::WriteAsUnion::prepare(&self, builder) + ::planus::WriteAsOffset::prepare(&self, builder) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, + 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::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, + 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::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, + + 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::UnionOffset { - ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) + 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) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { + /// 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] - fn prepare( + 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, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::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 ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { + + 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 prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, (self.0).0.prepare(builder).downcast()) + 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 ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { + 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, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + 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 ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { + + 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] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, (self.0).0.prepare(builder).downcast()) + 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::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::planus::WriteAs<::planus::Offset> for ChannelMessageHandlers { + type Prepared = ::planus::Offset; + #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, + + impl ::planus::WriteAsOptional<::planus::Offset> + for ChannelMessageHandlers { + type Prepared = ::planus::Offset; + #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(5, (self.0).0.prepare(builder).downcast()) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> + { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<5, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::planus::WriteAsOffset for ChannelMessageHandlers { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Offset { + ChannelMessageHandlers::create( + builder, + &self.channel_request_handlers, + &self.channel_notification_handlers, + ) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<6, T>> - where - T: ::planus::WriteAsOffset, - { + + /// 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] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(6, (self.0).0.prepare(builder).downcast()) + #[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 ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<6, T>> - where - T: ::planus::WriteAsOffset, - { + impl ChannelMessageHandlersBuilder<(T0, T1)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ChannelMessageHandlers]. #[inline] - fn prepare( - &self, + pub fn finish( + 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()) + ) -> ::planus::Offset + where + Self: ::planus::WriteAsOffset, + { + ::planus::WriteAsOffset::prepare(&self, builder) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<7, T>> - where - T: ::planus::WriteAsOffset, + 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, - ) -> ::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()) + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<8, T>> - where - T: ::planus::WriteAsOffset, + 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::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()) + ) -> ::core::option::Option<::planus::Offset> + { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<9, T>> - where - T: ::planus::WriteAsOffset, + 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, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Offset { + let (v0, v1) = &self.0; + ChannelMessageHandlers::create(builder, v0, v1) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<10, T>> - where - T: ::planus::WriteAsOffset, - { + + /// 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] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(10, (self.0).0.prepare(builder).downcast()) + 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") } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<10, T>> - where - T: ::planus::WriteAsOffset, - { + /// Getter for the [`channel_notification_handlers` field](ChannelMessageHandlers#structfield.channel_notification_handlers). #[inline] - fn prepare( + pub fn channel_notification_handlers( &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + > { + self.0.access_required( + 1, + "ChannelMessageHandlers", + "channel_notification_handlers", + ) } } - 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<'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 ::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<'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 ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<12, T>> - where - T: ::planus::WriteAsOffset, - { + + impl<'a> ::planus::TableRead<'a> for ChannelMessageHandlersRef<'a> { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(12, (self.0).0.prepare(builder).downcast()) + 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 ::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<'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::WriteAsUnion for BodyBuilder<::planus::Initialized<13, T>> - where - T: ::planus::WriteAsOffset, - { + + impl ::planus::VectorWrite<::planus::Offset> for ChannelMessageHandlers { + type Value = ::planus::Offset; + const STRIDE: usize = 4; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(13, (self.0).0.prepare(builder).downcast()) + fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { + ::planus::WriteAs::prepare(self, builder) } - } - 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)) + 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 ::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<'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, + ) + }) } } - 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)) - } + /// 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 ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<15, T>> - where - T: ::planus::WriteAsOffset, - { + + impl DumpResponse { + /// Creates a [DumpResponseBuilder] for serializing an instance of this table. #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(15, (self.0).0.prepare(builder).downcast()) + 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::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<15, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { + type Prepared = ::planus::Offset; + #[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()) + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<16, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { + type Prepared = ::planus::Offset; + #[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()) + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<17, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::planus::WriteAsOffset for DumpResponse { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Offset { + DumpResponse::create( + builder, + self.pid, + &self.web_rtc_server_ids, + &self.router_ids, + &self.channel_message_handlers, + ) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<18, T>> - where - T: ::planus::WriteAsOffset, - { + + /// 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] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(18, (self.0).0.prepare(builder).downcast()) + #[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 ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<18, T>> - where - T: ::planus::WriteAsOffset, - { + impl DumpResponseBuilder<(T0,)> { + /// Setter for the [`web_rtc_server_ids` field](DumpResponse#structfield.web_rtc_server_ids). #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + #[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 ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<19, T>> - where - T: ::planus::WriteAsOffset, - { + + impl DumpResponseBuilder<(T0, T1)> { + /// Setter for the [`router_ids` field](DumpResponse#structfield.router_ids). #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(19, (self.0).0.prepare(builder).downcast()) + #[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 ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<19, T>> - where - T: ::planus::WriteAsOffset, - { + impl DumpResponseBuilder<(T0, T1, T2)> { + /// Setter for the [`channel_message_handlers` field](DumpResponse#structfield.channel_message_handlers). #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + #[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 ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<20, T>> - where - T: ::planus::WriteAsOffset, - { + + impl DumpResponseBuilder<(T0, T1, T2, T3)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(20, (self.0).0.prepare(builder).downcast()) + pub fn finish( + self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset + where + Self: ::planus::WriteAsOffset, + { + ::planus::WriteAsOffset::prepare(&self, builder) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<20, T>> - where - T: ::planus::WriteAsOffset, + 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, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<21, T>> - where - T: ::planus::WriteAsOffset, + + 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) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(21, (self.0).0.prepare(builder).downcast()) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<21, T>> - where - T: ::planus::WriteAsOffset, + 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, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Offset { + let (v0, v1, v2, v3) = &self.0; + DumpResponse::create(builder, v0, v1, v2, v3) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<22, T>> - where - T: ::planus::WriteAsOffset, - { + + /// 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] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(22, (self.0).0.prepare(builder).downcast()) + pub fn pid(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(0, "DumpResponse", "pid")?.unwrap_or(0), + ) } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<22, T>> - where - T: ::planus::WriteAsOffset, - { + /// Getter for the [`web_rtc_server_ids` field](DumpResponse#structfield.web_rtc_server_ids). #[inline] - fn prepare( + pub fn web_rtc_server_ids( &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + > { + self.0 + .access_required(1, "DumpResponse", "web_rtc_server_ids") } - } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<23, T>> - where - T: ::planus::WriteAsOffset, - { + + /// Getter for the [`router_ids` field](DumpResponse#structfield.router_ids). #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(23, (self.0).0.prepare(builder).downcast()) + pub fn router_ids( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + > { + self.0.access_required(2, "DumpResponse", "router_ids") } - } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<23, T>> - where - T: ::planus::WriteAsOffset, - { + /// Getter for the [`channel_message_handlers` field](DumpResponse#structfield.channel_message_handlers). #[inline] - fn prepare( + pub fn channel_message_handlers( &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Result> { + self.0 + .access_required(3, "DumpResponse", "channel_message_handlers") } } - 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<'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 ::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<'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 ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<25, T>> - where - T: ::planus::WriteAsOffset, - { + + impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(25, (self.0).0.prepare(builder).downcast()) + 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 ::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<'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::WriteAsUnion for BodyBuilder<::planus::Initialized<26, T>> - where - T: ::planus::WriteAsOffset, - { + + impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { + type Value = ::planus::Offset; + const STRIDE: usize = 4; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(26, (self.0).0.prepare(builder).downcast()) + fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { + ::planus::WriteAs::prepare(self, builder) } - } - 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)) + 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 ::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<'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) + }) } } - 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)) + /// 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 ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<28, T>> - where - T: ::planus::WriteAsOffset, - { + + impl ResourceUsageResponse { + /// Creates a [ResourceUsageResponseBuilder] for serializing an instance of this table. #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(28, (self.0).0.prepare(builder).downcast()) + 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::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<28, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::planus::WriteAs<::planus::Offset> for ResourceUsageResponse { + type Prepared = ::planus::Offset; + #[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()) + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<29, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::planus::WriteAsOptional<::planus::Offset> for ResourceUsageResponse { + type Prepared = ::planus::Offset; + #[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()) + ) -> ::core::option::Option<::planus::Offset> + { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<30, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::planus::WriteAsOffset for ResourceUsageResponse { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, 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, + ) } } - /// Reference to a deserialized [Body]. - #[derive(Copy, Clone, Debug)] - pub enum BodyRef<'a> { - FbsWorkerDumpResponse(super::worker::DumpResponseRef<'a>), - FbsWorkerResourceUsageResponse(super::worker::ResourceUsageResponseRef<'a>), - FbsWebRtcServerDumpResponse(super::web_rtc_server::DumpResponseRef<'a>), - FbsRouterDumpResponse(super::router::DumpResponseRef<'a>), - FbsTransportProduceResponse(super::transport::ProduceResponseRef<'a>), - FbsTransportConsumeResponse(super::transport::ConsumeResponseRef<'a>), - FbsTransportRestartIceResponse(super::transport::RestartIceResponseRef<'a>), - FbsPlainTransportConnectResponse(super::plain_transport::ConnectResponseRef<'a>), - FbsPlainTransportDumpResponse(super::plain_transport::DumpResponseRef<'a>), - FbsPlainTransportGetStatsResponse(super::plain_transport::GetStatsResponseRef<'a>), - FbsPipeTransportConnectResponse(super::pipe_transport::ConnectResponseRef<'a>), - FbsPipeTransportDumpResponse(super::pipe_transport::DumpResponseRef<'a>), - FbsPipeTransportGetStatsResponse(super::pipe_transport::GetStatsResponseRef<'a>), - FbsDirectTransportDumpResponse(super::direct_transport::DumpResponseRef<'a>), - FbsDirectTransportGetStatsResponse( - super::direct_transport::GetStatsResponseRef<'a>, - ), - FbsWebRtcTransportConnectResponse(super::web_rtc_transport::ConnectResponseRef<'a>), - FbsWebRtcTransportDumpResponse(super::web_rtc_transport::DumpResponseRef<'a>), - FbsWebRtcTransportGetStatsResponse( - super::web_rtc_transport::GetStatsResponseRef<'a>, - ), - FbsProducerDumpResponse(super::producer::DumpResponseRef<'a>), - FbsProducerGetStatsResponse(super::producer::GetStatsResponseRef<'a>), - FbsConsumerDumpResponse(super::consumer::DumpResponseRef<'a>), - FbsConsumerGetStatsResponse(super::consumer::GetStatsResponseRef<'a>), - FbsConsumerSetPreferredLayersResponse( - super::consumer::SetPreferredLayersResponseRef<'a>, - ), - FbsConsumerSetPriorityResponse(super::consumer::SetPriorityResponseRef<'a>), - FbsDataProducerDumpResponse(super::data_producer::DumpResponseRef<'a>), - FbsDataProducerGetStatsResponse(super::data_producer::GetStatsResponseRef<'a>), - FbsDataConsumerGetBufferedAmountResponse( - super::data_consumer::GetBufferedAmountResponseRef<'a>, - ), - FbsDataConsumerDumpResponse(super::data_consumer::DumpResponseRef<'a>), - FbsDataConsumerGetStatsResponse(super::data_consumer::GetStatsResponseRef<'a>), - FbsDataConsumerSetSubchannelsResponse( - 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::FbsWorkerDumpResponse(value) => { - Self::FbsWorkerDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::FbsWorkerResourceUsageResponse(value) => { - Self::FbsWorkerResourceUsageResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::FbsWebRtcServerDumpResponse(value) => { - Self::FbsWebRtcServerDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::FbsRouterDumpResponse(value) => { - Self::FbsRouterDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::FbsTransportProduceResponse(value) => { - Self::FbsTransportProduceResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::FbsTransportConsumeResponse(value) => { - Self::FbsTransportConsumeResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::FbsTransportRestartIceResponse(value) => { - Self::FbsTransportRestartIceResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::FbsPlainTransportConnectResponse(value) => { - Self::FbsPlainTransportConnectResponse( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::FbsPlainTransportDumpResponse(value) => { - Self::FbsPlainTransportDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::FbsPlainTransportGetStatsResponse(value) => { - Self::FbsPlainTransportGetStatsResponse( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::FbsPipeTransportConnectResponse(value) => { - Self::FbsPipeTransportConnectResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::FbsPipeTransportDumpResponse(value) => { - Self::FbsPipeTransportDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::FbsPipeTransportGetStatsResponse(value) => { - Self::FbsPipeTransportGetStatsResponse( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::FbsDirectTransportDumpResponse(value) => { - Self::FbsDirectTransportDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::FbsDirectTransportGetStatsResponse(value) => { - Self::FbsDirectTransportGetStatsResponse( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::FbsWebRtcTransportConnectResponse(value) => { - Self::FbsWebRtcTransportConnectResponse( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::FbsWebRtcTransportDumpResponse(value) => { - Self::FbsWebRtcTransportDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::FbsWebRtcTransportGetStatsResponse(value) => { - Self::FbsWebRtcTransportGetStatsResponse( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } - - BodyRef::FbsProducerDumpResponse(value) => { - Self::FbsProducerDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::FbsProducerGetStatsResponse(value) => { - Self::FbsProducerGetStatsResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::FbsConsumerDumpResponse(value) => { - Self::FbsConsumerDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - BodyRef::FbsConsumerGetStatsResponse(value) => { - Self::FbsConsumerGetStatsResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + /// 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); - BodyRef::FbsConsumerSetPreferredLayersResponse(value) => { - Self::FbsConsumerSetPreferredLayersResponse( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } + 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,)) + } - BodyRef::FbsConsumerSetPriorityResponse(value) => { - Self::FbsConsumerSetPriorityResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(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) + } + } - BodyRef::FbsDataProducerDumpResponse(value) => { - Self::FbsDataProducerDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + 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)) + } - BodyRef::FbsDataProducerGetStatsResponse(value) => { - Self::FbsDataProducerGetStatsResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(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) + } + } - BodyRef::FbsDataConsumerGetBufferedAmountResponse(value) => { - Self::FbsDataConsumerGetBufferedAmountResponse( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - ), - ) - } + 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)) + } - BodyRef::FbsDataConsumerDumpResponse(value) => { - Self::FbsDataConsumerDumpResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(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) + } + } - BodyRef::FbsDataConsumerGetStatsResponse(value) => { - Self::FbsDataConsumerGetStatsResponse(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } + 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)) + } - BodyRef::FbsDataConsumerSetSubchannelsResponse(value) => { - Self::FbsDataConsumerSetSubchannelsResponse( - ::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(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<'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::FbsWorkerDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::FbsWorkerResourceUsageResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 3 => ::core::result::Result::Ok(Self::FbsWebRtcServerDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 4 => ::core::result::Result::Ok(Self::FbsRouterDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 5 => ::core::result::Result::Ok(Self::FbsTransportProduceResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 6 => ::core::result::Result::Ok(Self::FbsTransportConsumeResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 7 => ::core::result::Result::Ok(Self::FbsTransportRestartIceResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 8 => ::core::result::Result::Ok(Self::FbsPlainTransportConnectResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 9 => ::core::result::Result::Ok(Self::FbsPlainTransportDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 10 => ::core::result::Result::Ok(Self::FbsPlainTransportGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 11 => ::core::result::Result::Ok(Self::FbsPipeTransportConnectResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 12 => ::core::result::Result::Ok(Self::FbsPipeTransportDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 13 => ::core::result::Result::Ok(Self::FbsPipeTransportGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 14 => ::core::result::Result::Ok(Self::FbsDirectTransportDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 15 => ::core::result::Result::Ok(Self::FbsDirectTransportGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 16 => ::core::result::Result::Ok(Self::FbsWebRtcTransportConnectResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 17 => ::core::result::Result::Ok(Self::FbsWebRtcTransportDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 18 => ::core::result::Result::Ok(Self::FbsWebRtcTransportGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 19 => ::core::result::Result::Ok(Self::FbsProducerDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 20 => ::core::result::Result::Ok(Self::FbsProducerGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 21 => ::core::result::Result::Ok(Self::FbsConsumerDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 22 => ::core::result::Result::Ok(Self::FbsConsumerGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 23 => { - ::core::result::Result::Ok(Self::FbsConsumerSetPreferredLayersResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )) - } - 24 => ::core::result::Result::Ok(Self::FbsConsumerSetPriorityResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 25 => ::core::result::Result::Ok(Self::FbsDataProducerDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 26 => ::core::result::Result::Ok(Self::FbsDataProducerGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 27 => ::core::result::Result::Ok( - Self::FbsDataConsumerGetBufferedAmountResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - ), - ), - 28 => ::core::result::Result::Ok(Self::FbsDataConsumerDumpResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 29 => ::core::result::Result::Ok(Self::FbsDataConsumerGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 30 => { - ::core::result::Result::Ok(Self::FbsDataConsumerSetSubchannelsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )) - } - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), - } + 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)) } - } - /// 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>, + /// 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) + } } - #[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 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 Response { - /// Creates a [ResponseBuilder] for serializing an instance of this table. + impl ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5)> { + /// Setter for the [`ru_minflt` field](ResourceUsageResponse#structfield.ru_minflt). #[inline] - pub fn builder() -> ResponseBuilder<()> { - ResponseBuilder(()) + #[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)) } - #[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); + /// 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) + } + } - 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); - } + 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)) + } - 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() + /// 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 ::planus::WriteAs<::planus::Offset> for Response { - type Prepared = ::planus::Offset; + 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] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + #[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 ::planus::WriteAsOptional<::planus::Offset> for Response { - type Prepared = ::planus::Offset; + 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] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + #[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 ::planus::WriteAsOffset for Response { + impl + ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> + { + /// Setter for the [`ru_oublock` field](ResourceUsageResponse#structfield.ru_oublock). #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Response::create( - builder, - self.id, - self.accepted, - &self.body, - &self.error, - &self.reason, - ) + #[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)) } - } - /// 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); + /// 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 ResponseBuilder<()> { - /// Setter for the [`id` field](Response#structfield.id). + 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 id(self, value: T0) -> ResponseBuilder<(T0,)> + pub fn ru_msgsnd( + self, + value: T11, + ) -> ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> where - T0: ::planus::WriteAsDefault, + T11: ::planus::WriteAsDefault, { - ResponseBuilder((value,)) + 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 [`id` field](Response#structfield.id) to the default value. + /// Sets the [`ru_msgsnd` field](ResourceUsageResponse#structfield.ru_msgsnd) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn id_as_default(self) -> ResponseBuilder<(::planus::DefaultValue,)> { - self.id(::planus::DefaultValue) + 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 ResponseBuilder<(T0,)> { - /// Setter for the [`accepted` field](Response#structfield.accepted). + 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 accepted(self, value: T1) -> ResponseBuilder<(T0, T1)> + pub fn ru_msgrcv( + self, + value: T12, + ) -> ResourceUsageResponseBuilder<( + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + )> where - T1: ::planus::WriteAsDefault, + T12: ::planus::WriteAsDefault, { - let (v0,) = self.0; - ResponseBuilder((v0, value)) + 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 [`accepted` field](Response#structfield.accepted) to the default value. + /// Sets the [`ru_msgrcv` field](ResourceUsageResponse#structfield.ru_msgrcv) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn accepted_as_default(self) -> ResponseBuilder<(T0, ::planus::DefaultValue)> { - self.accepted(::planus::DefaultValue) + 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 ResponseBuilder<(T0, T1)> { - /// Setter for the [`body` field](Response#structfield.body). + 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 body(self, value: T2) -> ResponseBuilder<(T0, T1, T2)> + pub fn ru_nsignals( + self, + value: T13, + ) -> ResourceUsageResponseBuilder<( + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + )> where - T2: ::planus::WriteAsOptionalUnion, + T13: ::planus::WriteAsDefault, { - let (v0, v1) = self.0; - ResponseBuilder((v0, v1, value)) + 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 [`body` field](Response#structfield.body) to null. + /// Sets the [`ru_nsignals` field](ResourceUsageResponse#structfield.ru_nsignals) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn body_as_null(self) -> ResponseBuilder<(T0, T1, ())> { - self.body(()) + 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 ResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`error` field](Response#structfield.error). + 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 error(self, value: T3) -> ResponseBuilder<(T0, T1, T2, T3)> + pub fn ru_nvcsw( + self, + value: T14, + ) -> ResourceUsageResponseBuilder<( + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + )> where - T3: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T14: ::planus::WriteAsDefault, { - let (v0, v1, v2) = self.0; - ResponseBuilder((v0, v1, v2, value)) + 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 [`error` field](Response#structfield.error) to null. + /// Sets the [`ru_nvcsw` field](ResourceUsageResponse#structfield.ru_nvcsw) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn error_as_null(self) -> ResponseBuilder<(T0, T1, T2, ())> { - self.error(()) + 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 ResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`reason` field](Response#structfield.reason). + 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 reason(self, value: T4) -> ResponseBuilder<(T0, T1, T2, T3, T4)> + 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 - T4: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T15: ::planus::WriteAsDefault, { - let (v0, v1, v2, v3) = self.0; - ResponseBuilder((v0, v1, v2, v3, value)) + 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 [`reason` field](Response#structfield.reason) to null. + /// Sets the [`ru_nivcsw` field](ResourceUsageResponse#structfield.ru_nivcsw) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn reason_as_null(self) -> ResponseBuilder<(T0, T1, T2, T3, ())> { - self.reason(()) + 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 ResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Response]. + 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 + pub fn finish( + self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + 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)> + 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; + type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + 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)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::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)> + 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) = &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( + fn prepare( &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() + ) -> ::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, + ) } } - impl ::planus::WriteAs<::planus::Offset> for ChannelMessageHandlers { - type Prepared = ::planus::Offset; + /// 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] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + pub fn ru_utime(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "ResourceUsageResponse", "ru_utime")? + .unwrap_or(0), + ) } - } - impl ::planus::WriteAsOptional<::planus::Offset> - for ChannelMessageHandlers - { - type Prepared = ::planus::Offset; + /// 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] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + pub fn ru_maxrss(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "ResourceUsageResponse", "ru_maxrss")? + .unwrap_or(0), + ) } - } - impl ::planus::WriteAsOffset for ChannelMessageHandlers { + /// Getter for the [`ru_ixrss` field](ResourceUsageResponse#structfield.ru_ixrss). #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ChannelMessageHandlers::create( - builder, - &self.channel_request_handlers, - &self.channel_notification_handlers, + pub fn ru_ixrss(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(3, "ResourceUsageResponse", "ru_ixrss")? + .unwrap_or(0), ) } - } - /// 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); + /// 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), + ) + } - impl ChannelMessageHandlersBuilder<()> { - /// Setter for the [`channel_request_handlers` field](ChannelMessageHandlers#structfield.channel_request_handlers). + /// Getter for the [`ru_isrss` field](ResourceUsageResponse#structfield.ru_isrss). #[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,)) + pub fn ru_isrss(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(5, "ResourceUsageResponse", "ru_isrss")? + .unwrap_or(0), + ) } - } - impl ChannelMessageHandlersBuilder<(T0,)> { - /// Setter for the [`channel_notification_handlers` field](ChannelMessageHandlers#structfield.channel_notification_handlers). + /// Getter for the [`ru_minflt` field](ResourceUsageResponse#structfield.ru_minflt). #[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)) + pub fn ru_minflt(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(6, "ResourceUsageResponse", "ru_minflt")? + .unwrap_or(0), + ) } - } - impl ChannelMessageHandlersBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ChannelMessageHandlers]. + /// Getter for the [`ru_majflt` field](ResourceUsageResponse#structfield.ru_majflt). #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) + pub fn ru_majflt(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(7, "ResourceUsageResponse", "ru_majflt")? + .unwrap_or(0), + ) } - } - 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; + /// 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] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + pub fn ru_inblock(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(9, "ResourceUsageResponse", "ru_inblock")? + .unwrap_or(0), + ) } - } - 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; + /// 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] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + pub fn ru_msgsnd(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(11, "ResourceUsageResponse", "ru_msgsnd")? + .unwrap_or(0), + ) } - } - impl< - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOffset - for ChannelMessageHandlersBuilder<(T0, T1)> - { + /// Getter for the [`ru_msgrcv` field](ResourceUsageResponse#structfield.ru_msgrcv). #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - ChannelMessageHandlers::create(builder, v0, v1) + pub fn ru_msgrcv(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(12, "ResourceUsageResponse", "ru_msgrcv")? + .unwrap_or(0), + ) } - } - /// Reference to a deserialized [ChannelMessageHandlers]. - #[derive(Copy, Clone)] - pub struct ChannelMessageHandlersRef<'a>(::planus::table_reader::Table<'a>); + /// 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), + ) + } - impl<'a> ChannelMessageHandlersRef<'a> { - /// Getter for the [`channel_request_handlers` field](ChannelMessageHandlers#structfield.channel_request_handlers). + /// Getter for the [`ru_nvcsw` field](ResourceUsageResponse#structfield.ru_nvcsw). #[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") + pub fn ru_nvcsw(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(14, "ResourceUsageResponse", "ru_nvcsw")? + .unwrap_or(0), + ) } - /// Getter for the [`channel_notification_handlers` field](ChannelMessageHandlers#structfield.channel_notification_handlers). + /// Getter for the [`ru_nivcsw` field](ResourceUsageResponse#structfield.ru_nivcsw). #[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", + 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 ChannelMessageHandlersRef<'a> { + 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("ChannelMessageHandlersRef"); - f.field("channel_request_handlers", &self.channel_request_handlers()); - f.field( - "channel_notification_handlers", - &self.channel_notification_handlers(), - ); + 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 ChannelMessageHandlers { + impl<'a> ::core::convert::TryFrom> for ResourceUsageResponse { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: ChannelMessageHandlersRef<'a>) -> ::planus::Result { + fn try_from(value: ResourceUsageResponseRef<'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()?, + 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 ChannelMessageHandlersRef<'a> { + impl<'a> ::planus::TableRead<'a> for ResourceUsageResponseRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -56433,7 +58510,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for ChannelMessageHandlersRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for ResourceUsageResponseRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -56443,7 +58520,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[ChannelMessageHandlersRef]", + "[ResourceUsageResponseRef]", "get", buffer.offset_from_start, ) @@ -56451,8 +58528,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for ChannelMessageHandlers { - type Value = ::planus::Offset; + 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 { @@ -56461,7 +58538,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -56476,7 +58553,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for ChannelMessageHandlersRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for ResourceUsageResponseRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -56487,7 +58564,7 @@ mod root { ) .map_err(|error_kind| { error_kind.with_error_location( - "[ChannelMessageHandlersRef]", + "[ResourceUsageResponseRef]", "read_as_root", 0, ) @@ -56495,10 +58572,10 @@ mod root { } } - /// The table `DumpResponse` in the namespace `FBS.Worker` + /// The table `UpdateSettingsRequest` in the namespace `FBS.Worker` /// /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/worker.fbs:10` + /// * Table `UpdateSettingsRequest` in the file `../worker/fbs/worker.fbs:36` #[derive( Clone, Debug, @@ -56510,315 +58587,289 @@ mod root { ::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, + 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>, + >, } - impl DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. + #[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() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) + pub fn builder() -> UpdateSettingsRequestBuilder<()> { + UpdateSettingsRequestBuilder(()) } #[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_log_level: impl ::planus::WriteAsOptional< + ::planus::Offset<::core::primitive::str>, >, - field_router_ids: impl ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - field_channel_message_handlers: impl ::planus::WriteAs< - ::planus::Offset, + field_log_tags: impl ::planus::WriteAsOptional< + ::planus::Offset<[::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 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<12> = + let mut table_writer: ::planus::table_writer::TableWriter<8> = ::core::default::Default::default(); - if prepared_pid.is_some() { - table_writer.write_entry::(0); + 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); } - 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); + 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); } - 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 { + impl ::planus::WriteAs<::planus::Offset> for UpdateSettingsRequest { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { + 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<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for DumpResponse { + impl ::planus::WriteAsOffset for UpdateSettingsRequest { #[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, - ) + ) -> ::planus::Offset { + UpdateSettingsRequest::create(builder, &self.log_level, &self.log_tags) } } - /// Builder for serializing an instance of the [DumpResponse] type. + /// Builder for serializing an instance of the [UpdateSettingsRequest] type. /// - /// Can be created using the [DumpResponse::builder] method. + /// Can be created using the [UpdateSettingsRequest::builder] method. #[derive(Debug)] #[must_use] - pub struct DumpResponseBuilder(State); + pub struct UpdateSettingsRequestBuilder(State); - impl DumpResponseBuilder<()> { - /// Setter for the [`pid` field](DumpResponse#structfield.pid). + impl UpdateSettingsRequestBuilder<()> { + /// Setter for the [`log_level` field](UpdateSettingsRequest#structfield.log_level). #[inline] #[allow(clippy::type_complexity)] - pub fn pid(self, value: T0) -> DumpResponseBuilder<(T0,)> + pub fn log_level(self, value: T0) -> UpdateSettingsRequestBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, { - DumpResponseBuilder((value,)) + UpdateSettingsRequestBuilder((value,)) } - /// Sets the [`pid` field](DumpResponse#structfield.pid) to the default value. + /// Sets the [`log_level` field](UpdateSettingsRequest#structfield.log_level) to null. #[inline] #[allow(clippy::type_complexity)] - pub fn pid_as_default(self) -> DumpResponseBuilder<(::planus::DefaultValue,)> { - self.pid(::planus::DefaultValue) + pub fn log_level_as_null(self) -> UpdateSettingsRequestBuilder<((),)> { + self.log_level(()) } } - impl DumpResponseBuilder<(T0,)> { - /// Setter for the [`web_rtc_server_ids` field](DumpResponse#structfield.web_rtc_server_ids). + impl UpdateSettingsRequestBuilder<(T0,)> { + /// Setter for the [`log_tags` field](UpdateSettingsRequest#structfield.log_tags). #[inline] #[allow(clippy::type_complexity)] - pub fn web_rtc_server_ids(self, value: T1) -> DumpResponseBuilder<(T0, T1)> + pub fn log_tags(self, value: T1) -> UpdateSettingsRequestBuilder<(T0, T1)> where - T1: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T1: ::planus::WriteAsOptional<::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)) + UpdateSettingsRequestBuilder((v0, value)) } - } - impl DumpResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`channel_message_handlers` field](DumpResponse#structfield.channel_message_handlers). + /// Sets the [`log_tags` field](UpdateSettingsRequest#structfield.log_tags) to null. #[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)) + pub fn log_tags_as_null(self) -> UpdateSettingsRequestBuilder<(T0, ())> { + self.log_tags(()) } } - impl DumpResponseBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + 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)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::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)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::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)> + 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, v2, v3) = &self.0; - DumpResponse::create(builder, v0, v1, v2, v3) + ) -> ::planus::Offset { + let (v0, v1) = &self.0; + UpdateSettingsRequest::create(builder, v0, v1) } } - /// Reference to a deserialized [DumpResponse]. + /// Reference to a deserialized [UpdateSettingsRequest]. #[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), - ) - } + pub struct UpdateSettingsRequestRef<'a>(::planus::table_reader::Table<'a>); - /// Getter for the [`web_rtc_server_ids` field](DumpResponse#structfield.web_rtc_server_ids). + impl<'a> UpdateSettingsRequestRef<'a> { + /// Getter for the [`log_level` field](UpdateSettingsRequest#structfield.log_level). #[inline] - pub fn web_rtc_server_ids( + pub fn log_level( &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - > { - self.0 - .access_required(1, "DumpResponse", "web_rtc_server_ids") + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(0, "UpdateSettingsRequest", "log_level") } - /// Getter for the [`router_ids` field](DumpResponse#structfield.router_ids). + /// Getter for the [`log_tags` field](UpdateSettingsRequest#structfield.log_tags). #[inline] - pub fn router_ids( + pub fn log_tags( &self, ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + ::core::option::Option< + ::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") + self.0.access(1, "UpdateSettingsRequest", "log_tags") } } - impl<'a> ::core::fmt::Debug for DumpResponseRef<'a> { + 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("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()); + 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 DumpResponse { + impl<'a> ::core::convert::TryFrom> for UpdateSettingsRequest { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { + fn try_from(value: UpdateSettingsRequestRef<'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()?)?, - ), + 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 DumpResponseRef<'a> { + impl<'a> ::planus::TableRead<'a> for UpdateSettingsRequestRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -56830,7 +58881,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for UpdateSettingsRequestRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -56840,7 +58891,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[DumpResponseRef]", + "[UpdateSettingsRequestRef]", "get", buffer.offset_from_start, ) @@ -56848,8 +58899,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; + 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 { @@ -56858,7 +58909,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -56873,7 +58924,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for UpdateSettingsRequestRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -56883,15 +58934,19 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) + error_kind.with_error_location( + "[UpdateSettingsRequestRef]", + "read_as_root", + 0, + ) }) } } - /// The table `ResourceUsageResponse` in the namespace `FBS.Worker` + /// The table `CreateWebRtcServerRequest` in the namespace `FBS.Worker` /// /// Generated from these locations: - /// * Table `ResourceUsageResponse` in the file `../worker/fbs/worker.fbs:17` + /// * Table `CreateWebRtcServerRequest` in the file `../worker/fbs/worker.fbs:41` #[derive( Clone, Debug, @@ -56903,241 +58958,48 @@ mod root { ::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, - } - } + 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 ResourceUsageResponse { - /// Creates a [ResourceUsageResponseBuilder] for serializing an instance of this table. + impl CreateWebRtcServerRequest { + /// Creates a [CreateWebRtcServerRequestBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> ResourceUsageResponseBuilder<()> { - ResourceUsageResponseBuilder(()) + pub fn builder() -> CreateWebRtcServerRequestBuilder<()> { + CreateWebRtcServerRequestBuilder(()) } #[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, + field_web_rtc_server_id: impl ::planus::WriteAs<::planus::Offset>, + field_listen_infos: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, ) -> ::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 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<36> = + let mut table_writer: ::planus::table_writer::TableWriter<8> = ::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); + 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| { - 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::<_, _, 4>(&prepared_web_rtc_server_id); + if let ::core::option::Option::Some(prepared_listen_infos) = + prepared_listen_infos { - object_writer.write::<_, _, 8>(&prepared_ru_nivcsw); + object_writer.write::<_, _, 4>(&prepared_listen_infos); } }); } @@ -57145,1108 +59007,1027 @@ mod root { } } - impl ::planus::WriteAs<::planus::Offset> for ResourceUsageResponse { + impl ::planus::WriteAs<::planus::Offset> for CreateWebRtcServerRequest { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for ResourceUsageResponse { + 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<::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 ::planus::WriteAsOffset for ResourceUsageResponse { + 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 { - 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, - ) + ) -> ::planus::Offset { + let (v0, v1) = &self.0; + CreateWebRtcServerRequest::create(builder, v0, v1) } } - /// 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); + /// Reference to a deserialized [CreateWebRtcServerRequest]. + #[derive(Copy, Clone)] + pub struct CreateWebRtcServerRequestRef<'a>(::planus::table_reader::Table<'a>); - impl ResourceUsageResponseBuilder<()> { - /// Setter for the [`ru_utime` field](ResourceUsageResponse#structfield.ru_utime). + impl<'a> CreateWebRtcServerRequestRef<'a> { + /// Getter for the [`web_rtc_server_id` field](CreateWebRtcServerRequest#structfield.web_rtc_server_id). #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_utime(self, value: T0) -> ResourceUsageResponseBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - ResourceUsageResponseBuilder((value,)) + pub fn web_rtc_server_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(0, "CreateWebRtcServerRequest", "web_rtc_server_id") } - /// Sets the [`ru_utime` field](ResourceUsageResponse#structfield.ru_utime) to the default value. + /// Getter for the [`listen_infos` field](CreateWebRtcServerRequest#structfield.listen_infos). #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_utime_as_default( - self, - ) -> ResourceUsageResponseBuilder<(::planus::DefaultValue,)> { - self.ru_utime(::planus::DefaultValue) + pub fn listen_infos( + &self, + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, + > { + self.0 + .access(1, "CreateWebRtcServerRequest", "listen_infos") } } - 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)) + 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() } + } - /// 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<'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 ResourceUsageResponseBuilder<(T0, T1)> { - /// Setter for the [`ru_maxrss` field](ResourceUsageResponse#structfield.ru_maxrss). + impl<'a> ::planus::TableRead<'a> for CreateWebRtcServerRequestRef<'a> { #[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)) + 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, + )?)) } + } - /// 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<'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 ResourceUsageResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`ru_ixrss` field](ResourceUsageResponse#structfield.ru_ixrss). + impl ::planus::VectorWrite<::planus::Offset> + for CreateWebRtcServerRequest + { + type Value = ::planus::Offset; + const STRIDE: usize = 4; #[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)) + fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { + ::planus::WriteAs::prepare(self, builder) } - /// 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) + 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 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)) + 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, + ) + }) } + } - /// 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) - } + /// 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 ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`ru_isrss` field](ResourceUsageResponse#structfield.ru_isrss). + impl CloseWebRtcServerRequest { + /// Creates a [CloseWebRtcServerRequestBuilder] for serializing an instance of this table. #[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)) + pub fn builder() -> CloseWebRtcServerRequestBuilder<()> { + CloseWebRtcServerRequestBuilder(()) } - /// 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) + #[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 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)) - } + impl ::planus::WriteAs<::planus::Offset> for CloseWebRtcServerRequest { + type Prepared = ::planus::Offset; - /// 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) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`ru_majflt` field](ResourceUsageResponse#structfield.ru_majflt). + impl ::planus::WriteAsOptional<::planus::Offset> + for CloseWebRtcServerRequest + { + type Prepared = ::planus::Offset; + #[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, + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - ResourceUsageResponseBuilder((v0, v1, v2, v3, v4, v5, v6, value)) + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } + } - /// Sets the [`ru_majflt` field](ResourceUsageResponse#structfield.ru_majflt) to the default value. + impl ::planus::WriteAsOffset for CloseWebRtcServerRequest { #[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) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CloseWebRtcServerRequest::create(builder, &self.web_rtc_server_id) } } - impl - ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - /// Setter for the [`ru_nswap` field](ResourceUsageResponse#structfield.ru_nswap). + /// 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 ru_nswap( + pub fn web_rtc_server_id( self, - value: T8, - ) -> ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> + value: T0, + ) -> CloseWebRtcServerRequestBuilder<(T0,)> where - T8: ::planus::WriteAsDefault, + T0: ::planus::WriteAs<::planus::Offset>, { - 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) + CloseWebRtcServerRequestBuilder((value,)) } } - impl - ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> - { - /// Setter for the [`ru_inblock` field](ResourceUsageResponse#structfield.ru_inblock). + impl CloseWebRtcServerRequestBuilder<(T0,)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CloseWebRtcServerRequest]. #[inline] - #[allow(clippy::type_complexity)] - pub fn ru_inblock( + pub fn finish( self, - value: T9, - ) -> ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> + builder: &mut ::planus::Builder, + ) -> ::planus::Offset where - T9: ::planus::WriteAsDefault, + Self: ::planus::WriteAsOffset, { - let (v0, v1, v2, v3, v4, v5, v6, v7, v8) = self.0; - ResourceUsageResponseBuilder((v0, v1, v2, v3, v4, v5, v6, v7, v8, value)) + ::planus::WriteAsOffset::prepare(&self, builder) } + } + + impl>> + ::planus::WriteAs<::planus::Offset> + for CloseWebRtcServerRequestBuilder<(T0,)> + { + type Prepared = ::planus::Offset; - /// 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) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl - ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> + impl>> + ::planus::WriteAsOptional<::planus::Offset> + for CloseWebRtcServerRequestBuilder<(T0,)> { - /// Setter for the [`ru_oublock` field](ResourceUsageResponse#structfield.ru_oublock). + type Prepared = ::planus::Offset; + #[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, + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { - 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)) + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } + } - /// Sets the [`ru_oublock` field](ResourceUsageResponse#structfield.ru_oublock) to the default value. + impl>> + ::planus::WriteAsOffset + for CloseWebRtcServerRequestBuilder<(T0,)> + { #[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) + 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 - 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, - )) + 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() } + } - /// 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<'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 - ResourceUsageResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> - { - /// Setter for the [`ru_msgrcv` field](ResourceUsageResponse#structfield.ru_msgrcv). + impl<'a> ::planus::TableRead<'a> for CloseWebRtcServerRequestRef<'a> { #[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, - )) + 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, + )?)) } + } - /// 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<'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 - ResourceUsageResponseBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - )> + impl ::planus::VectorWrite<::planus::Offset> + for CloseWebRtcServerRequest { - /// Setter for the [`ru_nsignals` field](ResourceUsageResponse#structfield.ru_nsignals). + type Value = ::planus::Offset; + const STRIDE: usize = 4; #[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, - )) + fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { + ::planus::WriteAs::prepare(self, builder) } - /// 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) + 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 - 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, - )) + 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, + ) + }) } + } - /// Sets the [`ru_nvcsw` field](ResourceUsageResponse#structfield.ru_nvcsw) to the default value. + /// 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] - #[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) + 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 - 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). + impl ::planus::WriteAs<::planus::Offset> for CreateRouterRequest { + type Prepared = ::planus::Offset; + #[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, - )) + 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; - /// 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) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - 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]. + impl ::planus::WriteAsOffset for CreateRouterRequest { #[inline] - pub fn finish( - self, + fn prepare( + &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, - { - ::planus::WriteAsOffset::prepare(&self, builder) + ) -> ::planus::Offset { + CreateRouterRequest::create(builder, &self.router_id) } } - 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, - )> + /// 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::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, - )> + impl>> + ::planus::WriteAsOptional<::planus::Offset> + for CreateRouterRequestBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { + ) -> ::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, - )> + impl>> + ::planus::WriteAsOffset for CreateRouterRequestBuilder<(T0,)> { #[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, - ) + ) -> ::planus::Offset { + let (v0,) = &self.0; + CreateRouterRequest::create(builder, v0) } } - /// Reference to a deserialized [ResourceUsageResponse]. + /// Reference to a deserialized [CreateRouterRequest]. #[derive(Copy, Clone)] - pub struct ResourceUsageResponseRef<'a>(::planus::table_reader::Table<'a>); + pub struct CreateRouterRequestRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> ResourceUsageResponseRef<'a> { - /// Getter for the [`ru_utime` field](ResourceUsageResponse#structfield.ru_utime). + impl<'a> CreateRouterRequestRef<'a> { + /// Getter for the [`router_id` field](CreateRouterRequest#structfield.router_id). #[inline] - pub fn ru_utime(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "ResourceUsageResponse", "ru_utime")? - .unwrap_or(0), - ) + pub fn router_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(0, "CreateRouterRequest", "router_id") } + } - /// 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), - ) + 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() } + } - /// 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), - ) + 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()?)?, + }) } + } - /// Getter for the [`ru_ixrss` field](ResourceUsageResponse#structfield.ru_ixrss). + impl<'a> ::planus::TableRead<'a> for CreateRouterRequestRef<'a> { #[inline] - pub fn ru_ixrss(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(3, "ResourceUsageResponse", "ru_ixrss")? - .unwrap_or(0), - ) + 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, + )?)) } + } - /// Getter for the [`ru_idrss` field](ResourceUsageResponse#structfield.ru_idrss). + 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] - pub fn ru_idrss(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "ResourceUsageResponse", "ru_idrss")? - .unwrap_or(0), - ) + fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { + ::planus::WriteAs::prepare(self, builder) } - /// 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), + 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, + ) + }) } + } - /// Getter for the [`ru_minflt` field](ResourceUsageResponse#structfield.ru_minflt). + /// 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 ru_minflt(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(6, "ResourceUsageResponse", "ru_minflt")? - .unwrap_or(0), - ) + pub fn builder() -> CloseRouterRequestBuilder<()> { + CloseRouterRequestBuilder(()) } - /// Getter for the [`ru_majflt` field](ResourceUsageResponse#structfield.ru_majflt). + #[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] - pub fn ru_majflt(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(7, "ResourceUsageResponse", "ru_majflt")? - .unwrap_or(0), - ) + 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; - /// 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), - ) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } + } - /// Getter for the [`ru_inblock` field](ResourceUsageResponse#structfield.ru_inblock). + impl ::planus::WriteAsOffset for CloseRouterRequest { #[inline] - pub fn ru_inblock(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(9, "ResourceUsageResponse", "ru_inblock")? - .unwrap_or(0), - ) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + CloseRouterRequest::create(builder, &self.router_id) } + } - /// Getter for the [`ru_oublock` field](ResourceUsageResponse#structfield.ru_oublock). + /// 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] - pub fn ru_oublock(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(10, "ResourceUsageResponse", "ru_oublock")? - .unwrap_or(0), - ) + #[allow(clippy::type_complexity)] + pub fn router_id(self, value: T0) -> CloseRouterRequestBuilder<(T0,)> + where + T0: ::planus::WriteAs<::planus::Offset>, + { + CloseRouterRequestBuilder((value,)) } + } - /// Getter for the [`ru_msgsnd` field](ResourceUsageResponse#structfield.ru_msgsnd). + impl CloseRouterRequestBuilder<(T0,)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CloseRouterRequest]. #[inline] - pub fn ru_msgsnd(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(11, "ResourceUsageResponse", "ru_msgsnd")? - .unwrap_or(0), - ) + 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; - /// 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), - ) + 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; - /// 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), - ) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } + } - /// Getter for the [`ru_nvcsw` field](ResourceUsageResponse#structfield.ru_nvcsw). + impl>> + ::planus::WriteAsOffset for CloseRouterRequestBuilder<(T0,)> + { #[inline] - pub fn ru_nvcsw(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(14, "ResourceUsageResponse", "ru_nvcsw")? - .unwrap_or(0), - ) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + let (v0,) = &self.0; + CloseRouterRequest::create(builder, v0) } + } - /// Getter for the [`ru_nivcsw` field](ResourceUsageResponse#structfield.ru_nivcsw). + /// 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 ru_nivcsw(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(15, "ResourceUsageResponse", "ru_nivcsw")? - .unwrap_or(0), - ) + 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 ResourceUsageResponseRef<'a> { + 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("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()); + let mut f = f.debug_struct("CloseRouterRequestRef"); + f.field("router_id", &self.router_id()); f.finish() } } - impl<'a> ::core::convert::TryFrom> for ResourceUsageResponse { + impl<'a> ::core::convert::TryFrom> for CloseRouterRequest { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: ResourceUsageResponseRef<'a>) -> ::planus::Result { + fn try_from(value: CloseRouterRequestRef<'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()?)?, + router_id: ::core::convert::TryInto::try_into(value.router_id()?)?, }) } } - impl<'a> ::planus::TableRead<'a> for ResourceUsageResponseRef<'a> { + impl<'a> ::planus::TableRead<'a> for CloseRouterRequestRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -58258,7 +60039,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for ResourceUsageResponseRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for CloseRouterRequestRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -58268,7 +60049,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[ResourceUsageResponseRef]", + "[CloseRouterRequestRef]", "get", buffer.offset_from_start, ) @@ -58276,8 +60057,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for ResourceUsageResponse { - type Value = ::planus::Offset; + 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 { @@ -58286,7 +60067,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -58301,7 +60082,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for ResourceUsageResponseRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for CloseRouterRequestRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -58311,19 +60092,20 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location( - "[ResourceUsageResponseRef]", - "read_as_root", - 0, - ) + error_kind.with_error_location("[CloseRouterRequestRef]", "read_as_root", 0) }) } } - - /// The table `UpdateSettingsRequest` in the namespace `FBS.Worker` + } + /// 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 `UpdateSettingsRequest` in the file `../worker/fbs/worker.fbs:36` + /// * Table `DumpResponse` in the file `../worker/fbs/router.fbs:12` #[derive( Clone, Debug, @@ -58335,289 +60117,556 @@ mod root { ::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(), - } - } + 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 UpdateSettingsRequest { - /// Creates a [UpdateSettingsRequestBuilder] for serializing an instance of this table. + impl DumpResponse { + /// Creates a [DumpResponseBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> UpdateSettingsRequestBuilder<()> { - UpdateSettingsRequestBuilder(()) + pub fn builder() -> DumpResponseBuilder<()> { + DumpResponseBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_log_level: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, + field_id: impl ::planus::WriteAs<::planus::Offset>, + field_transport_ids: impl ::planus::WriteAs< + ::planus::Offset<[::planus::Offset]>, >, - field_log_tags: impl ::planus::WriteAsOptional< + 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_log_level = field_log_level.prepare(builder); - let prepared_log_tags = field_log_tags.prepare(builder); + 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<8> = + let mut table_writer: ::planus::table_writer::TableWriter<20> = ::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); - } + 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| { - 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); - } + 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 UpdateSettingsRequest { + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for UpdateSettingsRequest { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for UpdateSettingsRequest { + impl ::planus::WriteAsOffset for DumpResponse { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - UpdateSettingsRequest::create(builder, &self.log_level, &self.log_tags) + ) -> ::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 [UpdateSettingsRequest] type. + /// Builder for serializing an instance of the [DumpResponse] type. /// - /// Can be created using the [UpdateSettingsRequest::builder] method. + /// Can be created using the [DumpResponse::builder] method. #[derive(Debug)] #[must_use] - pub struct UpdateSettingsRequestBuilder(State); + pub struct DumpResponseBuilder(State); - impl UpdateSettingsRequestBuilder<()> { - /// Setter for the [`log_level` field](UpdateSettingsRequest#structfield.log_level). + impl DumpResponseBuilder<()> { + /// Setter for the [`id` field](DumpResponse#structfield.id). #[inline] #[allow(clippy::type_complexity)] - pub fn log_level(self, value: T0) -> UpdateSettingsRequestBuilder<(T0,)> + pub fn id(self, value: T0) -> DumpResponseBuilder<(T0,)> where - T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T0: ::planus::WriteAs<::planus::Offset>, { - UpdateSettingsRequestBuilder((value,)) + DumpResponseBuilder((value,)) } + } - /// Sets the [`log_level` field](UpdateSettingsRequest#structfield.log_level) to null. + impl DumpResponseBuilder<(T0,)> { + /// Setter for the [`transport_ids` field](DumpResponse#structfield.transport_ids). #[inline] #[allow(clippy::type_complexity)] - pub fn log_level_as_null(self) -> UpdateSettingsRequestBuilder<((),)> { - self.log_level(()) + 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 UpdateSettingsRequestBuilder<(T0,)> { - /// Setter for the [`log_tags` field](UpdateSettingsRequest#structfield.log_tags). + impl DumpResponseBuilder<(T0, T1)> { + /// Setter for the [`rtp_observer_ids` field](DumpResponse#structfield.rtp_observer_ids). #[inline] #[allow(clippy::type_complexity)] - pub fn log_tags(self, value: T1) -> UpdateSettingsRequestBuilder<(T0, T1)> + pub fn rtp_observer_ids(self, value: T2) -> DumpResponseBuilder<(T0, T1, T2)> where - T1: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, + T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, { - let (v0,) = self.0; - UpdateSettingsRequestBuilder((v0, value)) + let (v0, v1) = self.0; + DumpResponseBuilder((v0, v1, value)) } + } - /// Sets the [`log_tags` field](UpdateSettingsRequest#structfield.log_tags) to null. + 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 log_tags_as_null(self) -> UpdateSettingsRequestBuilder<(T0, ())> { - self.log_tags(()) + 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 UpdateSettingsRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [UpdateSettingsRequest]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + 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)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::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)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { + ) -> ::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)> + 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) = &self.0; - UpdateSettingsRequest::create(builder, v0, v1) + ) -> ::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 [UpdateSettingsRequest]. + /// Reference to a deserialized [DumpResponse]. #[derive(Copy, Clone)] - pub struct UpdateSettingsRequestRef<'a>(::planus::table_reader::Table<'a>); + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> UpdateSettingsRequestRef<'a> { - /// Getter for the [`log_level` field](UpdateSettingsRequest#structfield.log_level). + impl<'a> DumpResponseRef<'a> { + /// Getter for the [`id` field](DumpResponse#structfield.id). #[inline] - pub fn log_level( + 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<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(0, "UpdateSettingsRequest", "log_level") + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + > { + self.0.access_required(1, "DumpResponse", "transport_ids") } - /// Getter for the [`log_tags` field](UpdateSettingsRequest#structfield.log_tags). + /// Getter for the [`rtp_observer_ids` field](DumpResponse#structfield.rtp_observer_ids). #[inline] - pub fn log_tags( + pub fn rtp_observer_ids( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - >, + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, > { - self.0.access(1, "UpdateSettingsRequest", "log_tags") + 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 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); - } + 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 UpdateSettingsRequest { + impl<'a> ::core::convert::TryFrom> for DumpResponse { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: UpdateSettingsRequestRef<'a>) -> ::planus::Result { + fn try_from(value: DumpResponseRef<'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 - }, + 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 UpdateSettingsRequestRef<'a> { + impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -58629,7 +60678,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for UpdateSettingsRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -58639,7 +60688,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[UpdateSettingsRequestRef]", + "[DumpResponseRef]", "get", buffer.offset_from_start, ) @@ -58647,8 +60696,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for UpdateSettingsRequest { - type Value = ::planus::Offset; + 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 { @@ -58657,7 +60706,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -58672,7 +60721,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for UpdateSettingsRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -58682,19 +60731,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location( - "[UpdateSettingsRequestRef]", - "read_as_root", - 0, - ) + error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) }) } } - /// The table `CreateWebRtcServerRequest` in the namespace `FBS.Worker` + /// The table `CreatePipeTransportRequest` in the namespace `FBS.Router` /// /// Generated from these locations: - /// * Table `CreateWebRtcServerRequest` in the file `../worker/fbs/worker.fbs:41` + /// * Table `CreatePipeTransportRequest` in the file `../worker/fbs/router.fbs:23` #[derive( Clone, Debug, @@ -58706,69 +60751,63 @@ mod root { ::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>, + 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 CreateWebRtcServerRequest { - /// Creates a [CreateWebRtcServerRequestBuilder] for serializing an instance of this table. + impl CreatePipeTransportRequest { + /// Creates a [CreatePipeTransportRequestBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> CreateWebRtcServerRequestBuilder<()> { - CreateWebRtcServerRequestBuilder(()) + pub fn builder() -> CreatePipeTransportRequestBuilder<()> { + CreatePipeTransportRequestBuilder(()) } #[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]>, + field_transport_id: impl ::planus::WriteAs<::planus::Offset>, + field_options: impl ::planus::WriteAs< + ::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 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); - if prepared_listen_infos.is_some() { - table_writer.write_entry::<::planus::Offset< - [::planus::Offset], - >>(1); - } + table_writer.write_entry::<::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); - } + object_writer.write::<_, _, 4>(&prepared_transport_id); + object_writer.write::<_, _, 4>(&prepared_options); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for CreateWebRtcServerRequest { + impl ::planus::WriteAs<::planus::Offset> + for CreatePipeTransportRequest + { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> - for CreateWebRtcServerRequest + impl ::planus::WriteAsOptional<::planus::Offset> + for CreatePipeTransportRequest { type Prepared = ::planus::Offset; @@ -58776,82 +60815,65 @@ mod root { fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for CreateWebRtcServerRequest { + impl ::planus::WriteAsOffset for CreatePipeTransportRequest { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CreateWebRtcServerRequest::create( - builder, - &self.web_rtc_server_id, - &self.listen_infos, - ) + ) -> ::planus::Offset { + CreatePipeTransportRequest::create(builder, &self.transport_id, &self.options) } } - /// Builder for serializing an instance of the [CreateWebRtcServerRequest] type. + /// Builder for serializing an instance of the [CreatePipeTransportRequest] type. /// - /// Can be created using the [CreateWebRtcServerRequest::builder] method. + /// Can be created using the [CreatePipeTransportRequest::builder] method. #[derive(Debug)] #[must_use] - pub struct CreateWebRtcServerRequestBuilder(State); + pub struct CreatePipeTransportRequestBuilder(State); - impl CreateWebRtcServerRequestBuilder<()> { - /// Setter for the [`web_rtc_server_id` field](CreateWebRtcServerRequest#structfield.web_rtc_server_id). + impl CreatePipeTransportRequestBuilder<()> { + /// Setter for the [`transport_id` field](CreatePipeTransportRequest#structfield.transport_id). #[inline] #[allow(clippy::type_complexity)] - pub fn web_rtc_server_id( - self, - value: T0, - ) -> CreateWebRtcServerRequestBuilder<(T0,)> + pub fn transport_id(self, value: T0) -> CreatePipeTransportRequestBuilder<(T0,)> where T0: ::planus::WriteAs<::planus::Offset>, { - CreateWebRtcServerRequestBuilder((value,)) + CreatePipeTransportRequestBuilder((value,)) } } - impl CreateWebRtcServerRequestBuilder<(T0,)> { - /// Setter for the [`listen_infos` field](CreateWebRtcServerRequest#structfield.listen_infos). + impl CreatePipeTransportRequestBuilder<(T0,)> { + /// Setter for the [`options` field](CreatePipeTransportRequest#structfield.options). #[inline] #[allow(clippy::type_complexity)] - pub fn listen_infos( - self, - value: T1, - ) -> CreateWebRtcServerRequestBuilder<(T0, T1)> + pub fn options(self, value: T1) -> CreatePipeTransportRequestBuilder<(T0, T1)> where - T1: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, + T1: ::planus::WriteAs< + ::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(()) + CreatePipeTransportRequestBuilder((v0, value)) } } - impl CreateWebRtcServerRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CreateWebRtcServerRequest]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } @@ -58859,38 +60881,39 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, + T1: ::planus::WriteAs< + ::planus::Offset, >, - > ::planus::WriteAs<::planus::Offset> - for CreateWebRtcServerRequestBuilder<(T0, T1)> + > ::planus::WriteAs<::planus::Offset> + for CreatePipeTransportRequestBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, + T1: ::planus::WriteAs< + ::planus::Offset, >, - > ::planus::WriteAsOptional<::planus::Offset> - for CreateWebRtcServerRequestBuilder<(T0, T1)> + > + ::planus::WriteAsOptional<::planus::Offset> + for CreatePipeTransportRequestBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } @@ -58898,82 +60921,71 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, + T1: ::planus::WriteAs< + ::planus::Offset, >, - > ::planus::WriteAsOffset - for CreateWebRtcServerRequestBuilder<(T0, T1)> + > ::planus::WriteAsOffset + for CreatePipeTransportRequestBuilder<(T0, T1)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { let (v0, v1) = &self.0; - CreateWebRtcServerRequest::create(builder, v0, v1) + CreatePipeTransportRequest::create(builder, v0, v1) } } - /// Reference to a deserialized [CreateWebRtcServerRequest]. + /// Reference to a deserialized [CreatePipeTransportRequest]. #[derive(Copy, Clone)] - pub struct CreateWebRtcServerRequestRef<'a>(::planus::table_reader::Table<'a>); + pub struct CreatePipeTransportRequestRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> CreateWebRtcServerRequestRef<'a> { - /// Getter for the [`web_rtc_server_id` field](CreateWebRtcServerRequest#structfield.web_rtc_server_id). + impl<'a> CreatePipeTransportRequestRef<'a> { + /// Getter for the [`transport_id` field](CreatePipeTransportRequest#structfield.transport_id). #[inline] - pub fn web_rtc_server_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { self.0 - .access_required(0, "CreateWebRtcServerRequest", "web_rtc_server_id") + .access_required(0, "CreatePipeTransportRequest", "transport_id") } - /// Getter for the [`listen_infos` field](CreateWebRtcServerRequest#structfield.listen_infos). + /// Getter for the [`options` field](CreatePipeTransportRequest#structfield.options). #[inline] - pub fn listen_infos( + pub fn options( &self, - ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, - > { + ) -> ::planus::Result> + { self.0 - .access(1, "CreateWebRtcServerRequest", "listen_infos") + .access_required(1, "CreatePipeTransportRequest", "options") } } - impl<'a> ::core::fmt::Debug for CreateWebRtcServerRequestRef<'a> { + 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("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); - } + 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 CreateWebRtcServerRequest { + impl<'a> ::core::convert::TryFrom> + for CreatePipeTransportRequest + { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: CreateWebRtcServerRequestRef<'a>) -> ::planus::Result { + fn try_from(value: CreatePipeTransportRequestRef<'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 - }, + 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 CreateWebRtcServerRequestRef<'a> { + impl<'a> ::planus::TableRead<'a> for CreatePipeTransportRequestRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -58985,7 +60997,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for CreateWebRtcServerRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for CreatePipeTransportRequestRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -58995,7 +61007,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[CreateWebRtcServerRequestRef]", + "[CreatePipeTransportRequestRef]", "get", buffer.offset_from_start, ) @@ -59003,10 +61015,10 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> - for CreateWebRtcServerRequest + impl ::planus::VectorWrite<::planus::Offset> + for CreatePipeTransportRequest { - type Value = ::planus::Offset; + type Value = ::planus::Offset; const STRIDE: usize = 4; #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { @@ -59015,7 +61027,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -59030,7 +61042,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for CreateWebRtcServerRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for CreatePipeTransportRequestRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -59041,7 +61053,7 @@ mod root { ) .map_err(|error_kind| { error_kind.with_error_location( - "[CreateWebRtcServerRequestRef]", + "[CreatePipeTransportRequestRef]", "read_as_root", 0, ) @@ -59049,10 +61061,10 @@ mod root { } } - /// The table `CloseWebRtcServerRequest` in the namespace `FBS.Worker` + /// The table `CreatePlainTransportRequest` in the namespace `FBS.Router` /// /// Generated from these locations: - /// * Table `CloseWebRtcServerRequest` in the file `../worker/fbs/worker.fbs:46` + /// * Table `CreatePlainTransportRequest` in the file `../worker/fbs/router.fbs:28` #[derive( Clone, Debug, @@ -59064,52 +61076,63 @@ mod root { ::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, + 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 CloseWebRtcServerRequest { - /// Creates a [CloseWebRtcServerRequestBuilder] for serializing an instance of this table. + impl CreatePlainTransportRequest { + /// Creates a [CreatePlainTransportRequestBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> CloseWebRtcServerRequestBuilder<()> { - CloseWebRtcServerRequestBuilder(()) + pub fn builder() -> CreatePlainTransportRequestBuilder<()> { + CreatePlainTransportRequestBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_web_rtc_server_id: impl ::planus::WriteAs<::planus::Offset>, + field_transport_id: impl ::planus::WriteAs<::planus::Offset>, + field_options: impl ::planus::WriteAs< + ::planus::Offset, + >, ) -> ::planus::Offset { - let prepared_web_rtc_server_id = field_web_rtc_server_id.prepare(builder); + let prepared_transport_id = field_transport_id.prepare(builder); + let prepared_options = field_options.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<6> = + 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_web_rtc_server_id); + object_writer.write::<_, _, 4>(&prepared_transport_id); + object_writer.write::<_, _, 4>(&prepared_options); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for CloseWebRtcServerRequest { + impl ::planus::WriteAs<::planus::Offset> + for CreatePlainTransportRequest + { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> - for CloseWebRtcServerRequest + impl ::planus::WriteAsOptional<::planus::Offset> + for CreatePlainTransportRequest { type Prepared = ::planus::Offset; @@ -59117,138 +61140,180 @@ mod root { fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for CloseWebRtcServerRequest { + impl ::planus::WriteAsOffset for CreatePlainTransportRequest { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CloseWebRtcServerRequest::create(builder, &self.web_rtc_server_id) + ) -> ::planus::Offset { + CreatePlainTransportRequest::create(builder, &self.transport_id, &self.options) } } - /// Builder for serializing an instance of the [CloseWebRtcServerRequest] type. + /// Builder for serializing an instance of the [CreatePlainTransportRequest] type. /// - /// Can be created using the [CloseWebRtcServerRequest::builder] method. + /// Can be created using the [CreatePlainTransportRequest::builder] method. #[derive(Debug)] #[must_use] - pub struct CloseWebRtcServerRequestBuilder(State); + pub struct CreatePlainTransportRequestBuilder(State); - impl CloseWebRtcServerRequestBuilder<()> { - /// Setter for the [`web_rtc_server_id` field](CloseWebRtcServerRequest#structfield.web_rtc_server_id). + impl CreatePlainTransportRequestBuilder<()> { + /// Setter for the [`transport_id` field](CreatePlainTransportRequest#structfield.transport_id). #[inline] #[allow(clippy::type_complexity)] - pub fn web_rtc_server_id( + pub fn transport_id( self, value: T0, - ) -> CloseWebRtcServerRequestBuilder<(T0,)> + ) -> CreatePlainTransportRequestBuilder<(T0,)> where T0: ::planus::WriteAs<::planus::Offset>, { - CloseWebRtcServerRequestBuilder((value,)) + CreatePlainTransportRequestBuilder((value,)) } } - impl CloseWebRtcServerRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CloseWebRtcServerRequest]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl>> - ::planus::WriteAs<::planus::Offset> - for CloseWebRtcServerRequestBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAs< + ::planus::Offset, + >, + > ::planus::WriteAs<::planus::Offset> + for CreatePlainTransportRequestBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for CloseWebRtcServerRequestBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAs< + ::planus::Offset, + >, + > + ::planus::WriteAsOptional<::planus::Offset> + for CreatePlainTransportRequestBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl>> - ::planus::WriteAsOffset - for CloseWebRtcServerRequestBuilder<(T0,)> + 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,) = &self.0; - CloseWebRtcServerRequest::create(builder, v0) + ) -> ::planus::Offset { + let (v0, v1) = &self.0; + CreatePlainTransportRequest::create(builder, v0, v1) } } - /// Reference to a deserialized [CloseWebRtcServerRequest]. + /// Reference to a deserialized [CreatePlainTransportRequest]. #[derive(Copy, Clone)] - pub struct CloseWebRtcServerRequestRef<'a>(::planus::table_reader::Table<'a>); + pub struct CreatePlainTransportRequestRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> CloseWebRtcServerRequestRef<'a> { - /// Getter for the [`web_rtc_server_id` field](CloseWebRtcServerRequest#structfield.web_rtc_server_id). + impl<'a> CreatePlainTransportRequestRef<'a> { + /// Getter for the [`transport_id` field](CreatePlainTransportRequest#structfield.transport_id). #[inline] - pub fn web_rtc_server_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { self.0 - .access_required(0, "CloseWebRtcServerRequest", "web_rtc_server_id") + .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 CloseWebRtcServerRequestRef<'a> { + 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("CloseWebRtcServerRequestRef"); - f.field("web_rtc_server_id", &self.web_rtc_server_id()); + 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 CloseWebRtcServerRequest { + impl<'a> ::core::convert::TryFrom> + for CreatePlainTransportRequest + { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: CloseWebRtcServerRequestRef<'a>) -> ::planus::Result { + fn try_from(value: CreatePlainTransportRequestRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - web_rtc_server_id: ::core::convert::TryInto::try_into( - value.web_rtc_server_id()?, - )?, + 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 CloseWebRtcServerRequestRef<'a> { + impl<'a> ::planus::TableRead<'a> for CreatePlainTransportRequestRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -59260,7 +61325,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for CloseWebRtcServerRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for CreatePlainTransportRequestRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -59270,7 +61335,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[CloseWebRtcServerRequestRef]", + "[CreatePlainTransportRequestRef]", "get", buffer.offset_from_start, ) @@ -59278,10 +61343,10 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> - for CloseWebRtcServerRequest + impl ::planus::VectorWrite<::planus::Offset> + for CreatePlainTransportRequest { - type Value = ::planus::Offset; + type Value = ::planus::Offset; const STRIDE: usize = 4; #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { @@ -59290,7 +61355,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -59305,7 +61370,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for CloseWebRtcServerRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for CreatePlainTransportRequestRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -59316,7 +61381,7 @@ mod root { ) .map_err(|error_kind| { error_kind.with_error_location( - "[CloseWebRtcServerRequestRef]", + "[CreatePlainTransportRequestRef]", "read_as_root", 0, ) @@ -59324,10 +61389,10 @@ mod root { } } - /// The table `CreateRouterRequest` in the namespace `FBS.Worker` + /// The table `CreateWebRtcTransportRequest` in the namespace `FBS.Router` /// /// Generated from these locations: - /// * Table `CreateRouterRequest` in the file `../worker/fbs/worker.fbs:50` + /// * Table `CreateWebRtcTransportRequest` in the file `../worker/fbs/router.fbs:33` #[derive( Clone, Debug, @@ -59339,181 +61404,244 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct CreateRouterRequest { - /// The field `router_id` in the table `CreateRouterRequest` - pub router_id: ::planus::alloc::string::String, + 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 CreateRouterRequest { - /// Creates a [CreateRouterRequestBuilder] for serializing an instance of this table. + impl CreateWebRtcTransportRequest { + /// Creates a [CreateWebRtcTransportRequestBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> CreateRouterRequestBuilder<()> { - CreateRouterRequestBuilder(()) + pub fn builder() -> CreateWebRtcTransportRequestBuilder<()> { + CreateWebRtcTransportRequestBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_router_id: impl ::planus::WriteAs<::planus::Offset>, + field_transport_id: impl ::planus::WriteAs<::planus::Offset>, + field_options: impl ::planus::WriteAs< + ::planus::Offset, + >, ) -> ::planus::Offset { - let prepared_router_id = field_router_id.prepare(builder); + let prepared_transport_id = field_transport_id.prepare(builder); + let prepared_options = field_options.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<6> = + 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_router_id); + object_writer.write::<_, _, 4>(&prepared_transport_id); + object_writer.write::<_, _, 4>(&prepared_options); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for CreateRouterRequest { + impl ::planus::WriteAs<::planus::Offset> + for CreateWebRtcTransportRequest + { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for CreateRouterRequest { + 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<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for CreateRouterRequest { + impl ::planus::WriteAsOffset for CreateWebRtcTransportRequest { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CreateRouterRequest::create(builder, &self.router_id) + ) -> ::planus::Offset { + CreateWebRtcTransportRequest::create(builder, &self.transport_id, &self.options) } } - /// Builder for serializing an instance of the [CreateRouterRequest] type. + /// Builder for serializing an instance of the [CreateWebRtcTransportRequest] type. /// - /// Can be created using the [CreateRouterRequest::builder] method. + /// Can be created using the [CreateWebRtcTransportRequest::builder] method. #[derive(Debug)] #[must_use] - pub struct CreateRouterRequestBuilder(State); + pub struct CreateWebRtcTransportRequestBuilder(State); - impl CreateRouterRequestBuilder<()> { - /// Setter for the [`router_id` field](CreateRouterRequest#structfield.router_id). + impl CreateWebRtcTransportRequestBuilder<()> { + /// Setter for the [`transport_id` field](CreateWebRtcTransportRequest#structfield.transport_id). #[inline] #[allow(clippy::type_complexity)] - pub fn router_id(self, value: T0) -> CreateRouterRequestBuilder<(T0,)> + pub fn transport_id( + self, + value: T0, + ) -> CreateWebRtcTransportRequestBuilder<(T0,)> where T0: ::planus::WriteAs<::planus::Offset>, { - CreateRouterRequestBuilder((value,)) + CreateWebRtcTransportRequestBuilder((value,)) } } - impl CreateRouterRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CreateRouterRequest]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl>> - ::planus::WriteAs<::planus::Offset> - for CreateRouterRequestBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAs< + ::planus::Offset, + >, + > ::planus::WriteAs<::planus::Offset> + for CreateWebRtcTransportRequestBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for CreateRouterRequestBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAs< + ::planus::Offset, + >, + > + ::planus::WriteAsOptional<::planus::Offset> + for CreateWebRtcTransportRequestBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl>> - ::planus::WriteAsOffset for CreateRouterRequestBuilder<(T0,)> + 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,) = &self.0; - CreateRouterRequest::create(builder, v0) + ) -> ::planus::Offset { + let (v0, v1) = &self.0; + CreateWebRtcTransportRequest::create(builder, v0, v1) } } - /// Reference to a deserialized [CreateRouterRequest]. + /// Reference to a deserialized [CreateWebRtcTransportRequest]. #[derive(Copy, Clone)] - pub struct CreateRouterRequestRef<'a>(::planus::table_reader::Table<'a>); + pub struct CreateWebRtcTransportRequestRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> CreateRouterRequestRef<'a> { - /// Getter for the [`router_id` field](CreateRouterRequest#structfield.router_id). + impl<'a> CreateWebRtcTransportRequestRef<'a> { + /// Getter for the [`transport_id` field](CreateWebRtcTransportRequest#structfield.transport_id). #[inline] - pub fn router_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { self.0 - .access_required(0, "CreateRouterRequest", "router_id") + .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 CreateRouterRequestRef<'a> { + 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("CreateRouterRequestRef"); - f.field("router_id", &self.router_id()); + 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 CreateRouterRequest { + impl<'a> ::core::convert::TryFrom> + for CreateWebRtcTransportRequest + { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: CreateRouterRequestRef<'a>) -> ::planus::Result { + fn try_from(value: CreateWebRtcTransportRequestRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - router_id: ::core::convert::TryInto::try_into(value.router_id()?)?, + 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 CreateRouterRequestRef<'a> { + impl<'a> ::planus::TableRead<'a> for CreateWebRtcTransportRequestRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -59525,7 +61653,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for CreateRouterRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for CreateWebRtcTransportRequestRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -59535,7 +61663,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[CreateRouterRequestRef]", + "[CreateWebRtcTransportRequestRef]", "get", buffer.offset_from_start, ) @@ -59543,8 +61671,10 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for CreateRouterRequest { - type Value = ::planus::Offset; + 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 { @@ -59553,7 +61683,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -59568,7 +61698,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for CreateRouterRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for CreateWebRtcTransportRequestRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -59579,7 +61709,7 @@ mod root { ) .map_err(|error_kind| { error_kind.with_error_location( - "[CreateRouterRequestRef]", + "[CreateWebRtcTransportRequestRef]", "read_as_root", 0, ) @@ -59587,10 +61717,10 @@ mod root { } } - /// The table `CloseRouterRequest` in the namespace `FBS.Worker` + /// The table `CreateDirectTransportRequest` in the namespace `FBS.Router` /// /// Generated from these locations: - /// * Table `CloseRouterRequest` in the file `../worker/fbs/worker.fbs:54` + /// * Table `CreateDirectTransportRequest` in the file `../worker/fbs/router.fbs:38` #[derive( Clone, Debug, @@ -59602,180 +61732,244 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct CloseRouterRequest { - /// The field `router_id` in the table `CloseRouterRequest` - pub router_id: ::planus::alloc::string::String, + 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 CloseRouterRequest { - /// Creates a [CloseRouterRequestBuilder] for serializing an instance of this table. + impl CreateDirectTransportRequest { + /// Creates a [CreateDirectTransportRequestBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> CloseRouterRequestBuilder<()> { - CloseRouterRequestBuilder(()) + pub fn builder() -> CreateDirectTransportRequestBuilder<()> { + CreateDirectTransportRequestBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_router_id: impl ::planus::WriteAs<::planus::Offset>, + field_transport_id: impl ::planus::WriteAs<::planus::Offset>, + field_options: impl ::planus::WriteAs< + ::planus::Offset, + >, ) -> ::planus::Offset { - let prepared_router_id = field_router_id.prepare(builder); + let prepared_transport_id = field_transport_id.prepare(builder); + let prepared_options = field_options.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<6> = + 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_router_id); + object_writer.write::<_, _, 4>(&prepared_transport_id); + object_writer.write::<_, _, 4>(&prepared_options); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for CloseRouterRequest { + impl ::planus::WriteAs<::planus::Offset> + for CreateDirectTransportRequest + { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for CloseRouterRequest { + 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<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for CloseRouterRequest { + impl ::planus::WriteAsOffset for CreateDirectTransportRequest { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CloseRouterRequest::create(builder, &self.router_id) + ) -> ::planus::Offset { + CreateDirectTransportRequest::create(builder, &self.transport_id, &self.options) } } - /// Builder for serializing an instance of the [CloseRouterRequest] type. + /// Builder for serializing an instance of the [CreateDirectTransportRequest] type. /// - /// Can be created using the [CloseRouterRequest::builder] method. + /// Can be created using the [CreateDirectTransportRequest::builder] method. #[derive(Debug)] #[must_use] - pub struct CloseRouterRequestBuilder(State); + pub struct CreateDirectTransportRequestBuilder(State); - impl CloseRouterRequestBuilder<()> { - /// Setter for the [`router_id` field](CloseRouterRequest#structfield.router_id). + impl CreateDirectTransportRequestBuilder<()> { + /// Setter for the [`transport_id` field](CreateDirectTransportRequest#structfield.transport_id). #[inline] #[allow(clippy::type_complexity)] - pub fn router_id(self, value: T0) -> CloseRouterRequestBuilder<(T0,)> + pub fn transport_id( + self, + value: T0, + ) -> CreateDirectTransportRequestBuilder<(T0,)> where T0: ::planus::WriteAs<::planus::Offset>, { - CloseRouterRequestBuilder((value,)) + CreateDirectTransportRequestBuilder((value,)) } } - impl CloseRouterRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CloseRouterRequest]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl>> - ::planus::WriteAs<::planus::Offset> - for CloseRouterRequestBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAs< + ::planus::Offset, + >, + > ::planus::WriteAs<::planus::Offset> + for CreateDirectTransportRequestBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for CloseRouterRequestBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAs< + ::planus::Offset, + >, + > + ::planus::WriteAsOptional<::planus::Offset> + for CreateDirectTransportRequestBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl>> - ::planus::WriteAsOffset for CloseRouterRequestBuilder<(T0,)> + 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,) = &self.0; - CloseRouterRequest::create(builder, v0) + ) -> ::planus::Offset { + let (v0, v1) = &self.0; + CreateDirectTransportRequest::create(builder, v0, v1) } } - /// Reference to a deserialized [CloseRouterRequest]. + /// Reference to a deserialized [CreateDirectTransportRequest]. #[derive(Copy, Clone)] - pub struct CloseRouterRequestRef<'a>(::planus::table_reader::Table<'a>); + pub struct CreateDirectTransportRequestRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> CloseRouterRequestRef<'a> { - /// Getter for the [`router_id` field](CloseRouterRequest#structfield.router_id). + impl<'a> CreateDirectTransportRequestRef<'a> { + /// Getter for the [`transport_id` field](CreateDirectTransportRequest#structfield.transport_id). #[inline] - pub fn router_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "CloseRouterRequest", "router_id") + 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 CloseRouterRequestRef<'a> { + 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("CloseRouterRequestRef"); - f.field("router_id", &self.router_id()); + 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 CloseRouterRequest { + impl<'a> ::core::convert::TryFrom> + for CreateDirectTransportRequest + { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: CloseRouterRequestRef<'a>) -> ::planus::Result { + fn try_from(value: CreateDirectTransportRequestRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - router_id: ::core::convert::TryInto::try_into(value.router_id()?)?, + 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 CloseRouterRequestRef<'a> { + impl<'a> ::planus::TableRead<'a> for CreateDirectTransportRequestRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -59787,7 +61981,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for CloseRouterRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for CreateDirectTransportRequestRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -59797,7 +61991,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[CloseRouterRequestRef]", + "[CreateDirectTransportRequestRef]", "get", buffer.offset_from_start, ) @@ -59805,8 +61999,10 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for CloseRouterRequest { - type Value = ::planus::Offset; + 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 { @@ -59815,7 +62011,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -59830,7 +62026,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for CloseRouterRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for CreateDirectTransportRequestRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -59840,20 +62036,19 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[CloseRouterRequestRef]", "read_as_root", 0) + error_kind.with_error_location( + "[CreateDirectTransportRequestRef]", + "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` + + /// The table `CreateAudioLevelObserverRequest` in the namespace `FBS.Router` /// /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/router.fbs:12` + /// * Table `CreateAudioLevelObserverRequest` in the file `../worker/fbs/router.fbs:43` #[derive( Clone, Debug, @@ -59865,300 +62060,142 @@ mod root { ::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, + 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 DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. + impl CreateAudioLevelObserverRequest { + /// Creates a [CreateAudioLevelObserverRequestBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) + pub fn builder() -> CreateAudioLevelObserverRequestBuilder<()> { + CreateAudioLevelObserverRequestBuilder(()) } #[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]>, + field_rtp_observer_id: impl ::planus::WriteAs<::planus::Offset>, + field_options: impl ::planus::WriteAs< + ::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 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<20> = + 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); - 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); + super::audio_level_observer::AudioLevelObserverOptions, + >>(1); 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); + object_writer.write::<_, _, 4>(&prepared_rtp_observer_id); + object_writer.write::<_, _, 4>(&prepared_options); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for DumpResponse { + impl ::planus::WriteAs<::planus::Offset> + for CreateAudioLevelObserverRequest + { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { + 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<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for DumpResponse { + impl ::planus::WriteAsOffset for CreateAudioLevelObserverRequest { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DumpResponse::create( + ) -> ::planus::Offset { + CreateAudioLevelObserverRequest::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, + &self.rtp_observer_id, + &self.options, ) } } - /// Builder for serializing an instance of the [DumpResponse] type. + /// Builder for serializing an instance of the [CreateAudioLevelObserverRequest] type. /// - /// Can be created using the [DumpResponse::builder] method. + /// Can be created using the [CreateAudioLevelObserverRequest::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)) - } - } + pub struct CreateAudioLevelObserverRequestBuilder(State); - 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). + impl CreateAudioLevelObserverRequestBuilder<()> { + /// Setter for the [`rtp_observer_id` field](CreateAudioLevelObserverRequest#structfield.rtp_observer_id). #[inline] #[allow(clippy::type_complexity)] - pub fn map_data_producer_id_data_consumer_ids( + pub fn rtp_observer_id( self, - value: T6, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> + value: T0, + ) -> CreateAudioLevelObserverRequestBuilder<(T0,)> where - T6: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, + T0: ::planus::WriteAs<::planus::Offset>, { - let (v0, v1, v2, v3, v4, v5) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, v5, value)) + CreateAudioLevelObserverRequestBuilder((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). + impl CreateAudioLevelObserverRequestBuilder<(T0,)> { + /// Setter for the [`options` field](CreateAudioLevelObserverRequest#structfield.options). #[inline] #[allow(clippy::type_complexity)] - pub fn map_data_consumer_id_data_producer_id( + pub fn options( self, - value: T7, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + value: T1, + ) -> CreateAudioLevelObserverRequestBuilder<(T0, T1)> where - T7: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, + T1: ::planus::WriteAs< + ::planus::Offset, >, { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, v5, v6, value)) + let (v0,) = self.0; + CreateAudioLevelObserverRequestBuilder((v0, 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]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } @@ -60166,255 +62203,115 @@ mod root { 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]>, + T1: ::planus::WriteAs< + ::planus::Offset, >, - > ::planus::WriteAs<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + > ::planus::WriteAs<::planus::Offset> + for CreateAudioLevelObserverRequestBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::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]>, + T1: ::planus::WriteAs< + ::planus::Offset, >, - > ::planus::WriteAsOptional<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + > + ::planus::WriteAsOptional<::planus::Offset> + for CreateAudioLevelObserverRequestBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::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]>, + T1: ::planus::WriteAs< + ::planus::Offset, >, - > ::planus::WriteAsOffset - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + > ::planus::WriteAsOffset + for CreateAudioLevelObserverRequestBuilder<(T0, T1)> { #[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) + ) -> ::planus::Offset { + let (v0, v1) = &self.0; + CreateAudioLevelObserverRequest::create(builder, v0, v1) } } - /// Reference to a deserialized [DumpResponse]. + /// Reference to a deserialized [CreateAudioLevelObserverRequest]. #[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") - } + pub struct CreateAudioLevelObserverRequestRef<'a>(::planus::table_reader::Table<'a>); - /// Getter for the [`map_consumer_id_producer_id` field](DumpResponse#structfield.map_consumer_id_producer_id). + impl<'a> CreateAudioLevelObserverRequestRef<'a> { + /// Getter for the [`rtp_observer_id` field](CreateAudioLevelObserverRequest#structfield.rtp_observer_id). #[inline] - pub fn map_consumer_id_producer_id( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { + pub fn rtp_observer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { self.0 - .access_required(4, "DumpResponse", "map_consumer_id_producer_id") + .access_required(0, "CreateAudioLevelObserverRequest", "rtp_observer_id") } - /// Getter for the [`map_producer_id_observer_ids` field](DumpResponse#structfield.map_producer_id_observer_ids). + /// Getter for the [`options` field](CreateAudioLevelObserverRequest#structfield.options). #[inline] - pub fn map_producer_id_observer_ids( + pub fn options( &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { + ) -> ::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", - ) + .access_required(1, "CreateAudioLevelObserverRequest", "options") } } - impl<'a> ::core::fmt::Debug for DumpResponseRef<'a> { + 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("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(), - ); + 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 DumpResponse { + impl<'a> ::core::convert::TryFrom> + for CreateAudioLevelObserverRequest + { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { + fn try_from( + value: CreateAudioLevelObserverRequestRef<'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()?, + 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 DumpResponseRef<'a> { + impl<'a> ::planus::TableRead<'a> for CreateAudioLevelObserverRequestRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -60426,7 +62323,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for CreateAudioLevelObserverRequestRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -60436,7 +62333,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[DumpResponseRef]", + "[CreateAudioLevelObserverRequestRef]", "get", buffer.offset_from_start, ) @@ -60444,8 +62341,10 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; + 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 { @@ -60454,7 +62353,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -60469,7 +62368,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for CreateAudioLevelObserverRequestRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -60479,15 +62378,19 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) + error_kind.with_error_location( + "[CreateAudioLevelObserverRequestRef]", + "read_as_root", + 0, + ) }) } } - /// The table `CreatePipeTransportRequest` in the namespace `FBS.Router` + /// The table `CreateActiveSpeakerObserverRequest` in the namespace `FBS.Router` /// /// Generated from these locations: - /// * Table `CreatePipeTransportRequest` in the file `../worker/fbs/router.fbs:23` + /// * Table `CreateActiveSpeakerObserverRequest` in the file `../worker/fbs/router.fbs:48` #[derive( Clone, Debug, @@ -60499,40 +62402,46 @@ mod root { ::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, + pub struct CreateActiveSpeakerObserverRequest { + /// The field `active_speaker_observer_id` in the table `CreateActiveSpeakerObserverRequest` + pub active_speaker_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 CreatePipeTransportRequest { - /// Creates a [CreatePipeTransportRequestBuilder] for serializing an instance of this table. + impl CreateActiveSpeakerObserverRequest { + /// Creates a [CreateActiveSpeakerObserverRequestBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> CreatePipeTransportRequestBuilder<()> { - CreatePipeTransportRequestBuilder(()) + pub fn builder() -> CreateActiveSpeakerObserverRequestBuilder<()> { + CreateActiveSpeakerObserverRequestBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_transport_id: impl ::planus::WriteAs<::planus::Offset>, + field_active_speaker_observer_id: impl ::planus::WriteAs<::planus::Offset>, field_options: impl ::planus::WriteAs< - ::planus::Offset, + ::planus::Offset< + super::active_speaker_observer::ActiveSpeakerObserverOptions, + >, >, ) -> ::planus::Offset { - let prepared_transport_id = field_transport_id.prepare(builder); + let prepared_active_speaker_observer_id = + field_active_speaker_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>(1); + table_writer.write_entry::<::planus::Offset< + super::active_speaker_observer::ActiveSpeakerObserverOptions, + >>(1); unsafe { table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_transport_id); + object_writer.write::<_, _, 4>(&prepared_active_speaker_observer_id); object_writer.write::<_, _, 4>(&prepared_options); }); } @@ -60540,8 +62449,8 @@ mod root { } } - impl ::planus::WriteAs<::planus::Offset> - for CreatePipeTransportRequest + impl ::planus::WriteAs<::planus::Offset> + for CreateActiveSpeakerObserverRequest { type Prepared = ::planus::Offset; @@ -60549,13 +62458,13 @@ mod root { fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> - for CreatePipeTransportRequest + impl ::planus::WriteAsOptional<::planus::Offset> + for CreateActiveSpeakerObserverRequest { type Prepared = ::planus::Offset; @@ -60563,65 +62472,79 @@ mod root { fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for CreatePipeTransportRequest { + impl ::planus::WriteAsOffset + for CreateActiveSpeakerObserverRequest + { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CreatePipeTransportRequest::create(builder, &self.transport_id, &self.options) + ) -> ::planus::Offset { + CreateActiveSpeakerObserverRequest::create( + builder, + &self.active_speaker_observer_id, + &self.options, + ) } } - /// Builder for serializing an instance of the [CreatePipeTransportRequest] type. + /// Builder for serializing an instance of the [CreateActiveSpeakerObserverRequest] type. /// - /// Can be created using the [CreatePipeTransportRequest::builder] method. + /// Can be created using the [CreateActiveSpeakerObserverRequest::builder] method. #[derive(Debug)] #[must_use] - pub struct CreatePipeTransportRequestBuilder(State); + pub struct CreateActiveSpeakerObserverRequestBuilder(State); - impl CreatePipeTransportRequestBuilder<()> { - /// Setter for the [`transport_id` field](CreatePipeTransportRequest#structfield.transport_id). + impl CreateActiveSpeakerObserverRequestBuilder<()> { + /// Setter for the [`active_speaker_observer_id` field](CreateActiveSpeakerObserverRequest#structfield.active_speaker_observer_id). #[inline] #[allow(clippy::type_complexity)] - pub fn transport_id(self, value: T0) -> CreatePipeTransportRequestBuilder<(T0,)> + pub fn active_speaker_observer_id( + self, + value: T0, + ) -> CreateActiveSpeakerObserverRequestBuilder<(T0,)> where T0: ::planus::WriteAs<::planus::Offset>, { - CreatePipeTransportRequestBuilder((value,)) + CreateActiveSpeakerObserverRequestBuilder((value,)) } } - impl CreatePipeTransportRequestBuilder<(T0,)> { - /// Setter for the [`options` field](CreatePipeTransportRequest#structfield.options). + impl CreateActiveSpeakerObserverRequestBuilder<(T0,)> { + /// Setter for the [`options` field](CreateActiveSpeakerObserverRequest#structfield.options). #[inline] #[allow(clippy::type_complexity)] - pub fn options(self, value: T1) -> CreatePipeTransportRequestBuilder<(T0, T1)> + pub fn options( + self, + value: T1, + ) -> CreateActiveSpeakerObserverRequestBuilder<(T0, T1)> where T1: ::planus::WriteAs< - ::planus::Offset, + ::planus::Offset< + super::active_speaker_observer::ActiveSpeakerObserverOptions, + >, >, { let (v0,) = self.0; - CreatePipeTransportRequestBuilder((v0, value)) + CreateActiveSpeakerObserverRequestBuilder((v0, value)) } } - impl CreatePipeTransportRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CreatePipeTransportRequest]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } @@ -60630,18 +62553,21 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs< - ::planus::Offset, + ::planus::Offset< + super::active_speaker_observer::ActiveSpeakerObserverOptions, + >, >, - > ::planus::WriteAs<::planus::Offset> - for CreatePipeTransportRequestBuilder<(T0, T1)> + > + ::planus::WriteAs<::planus::Offset> + for CreateActiveSpeakerObserverRequestBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } @@ -60649,19 +62575,21 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs< - ::planus::Offset, + ::planus::Offset< + super::active_speaker_observer::ActiveSpeakerObserverOptions, + >, >, > - ::planus::WriteAsOptional<::planus::Offset> - for CreatePipeTransportRequestBuilder<(T0, T1)> + ::planus::WriteAsOptional<::planus::Offset> + for CreateActiveSpeakerObserverRequestBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } @@ -60670,62 +62598,77 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs< - ::planus::Offset, + ::planus::Offset< + super::active_speaker_observer::ActiveSpeakerObserverOptions, + >, >, - > ::planus::WriteAsOffset - for CreatePipeTransportRequestBuilder<(T0, T1)> + > ::planus::WriteAsOffset + for CreateActiveSpeakerObserverRequestBuilder<(T0, T1)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { let (v0, v1) = &self.0; - CreatePipeTransportRequest::create(builder, v0, v1) + CreateActiveSpeakerObserverRequest::create(builder, v0, v1) } } - /// Reference to a deserialized [CreatePipeTransportRequest]. + /// Reference to a deserialized [CreateActiveSpeakerObserverRequest]. #[derive(Copy, Clone)] - pub struct CreatePipeTransportRequestRef<'a>(::planus::table_reader::Table<'a>); + pub struct CreateActiveSpeakerObserverRequestRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> CreatePipeTransportRequestRef<'a> { - /// Getter for the [`transport_id` field](CreatePipeTransportRequest#structfield.transport_id). + impl<'a> CreateActiveSpeakerObserverRequestRef<'a> { + /// Getter for the [`active_speaker_observer_id` field](CreateActiveSpeakerObserverRequest#structfield.active_speaker_observer_id). #[inline] - pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "CreatePipeTransportRequest", "transport_id") + pub fn active_speaker_observer_id( + &self, + ) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required( + 0, + "CreateActiveSpeakerObserverRequest", + "active_speaker_observer_id", + ) } - /// Getter for the [`options` field](CreatePipeTransportRequest#structfield.options). + /// Getter for the [`options` field](CreateActiveSpeakerObserverRequest#structfield.options). #[inline] pub fn options( &self, - ) -> ::planus::Result> - { + ) -> ::planus::Result< + super::active_speaker_observer::ActiveSpeakerObserverOptionsRef<'a>, + > { self.0 - .access_required(1, "CreatePipeTransportRequest", "options") + .access_required(1, "CreateActiveSpeakerObserverRequest", "options") } } - impl<'a> ::core::fmt::Debug for CreatePipeTransportRequestRef<'a> { + 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("CreatePipeTransportRequestRef"); - f.field("transport_id", &self.transport_id()); + let mut f = f.debug_struct("CreateActiveSpeakerObserverRequestRef"); + f.field( + "active_speaker_observer_id", + &self.active_speaker_observer_id(), + ); f.field("options", &self.options()); f.finish() } } - impl<'a> ::core::convert::TryFrom> - for CreatePipeTransportRequest + impl<'a> ::core::convert::TryFrom> + for CreateActiveSpeakerObserverRequest { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: CreatePipeTransportRequestRef<'a>) -> ::planus::Result { + fn try_from( + value: CreateActiveSpeakerObserverRequestRef<'a>, + ) -> ::planus::Result { ::core::result::Result::Ok(Self { - transport_id: ::core::convert::TryInto::try_into(value.transport_id()?)?, + active_speaker_observer_id: ::core::convert::TryInto::try_into( + value.active_speaker_observer_id()?, + )?, options: ::planus::alloc::boxed::Box::new( ::core::convert::TryInto::try_into(value.options()?)?, ), @@ -60733,7 +62676,7 @@ mod root { } } - impl<'a> ::planus::TableRead<'a> for CreatePipeTransportRequestRef<'a> { + impl<'a> ::planus::TableRead<'a> for CreateActiveSpeakerObserverRequestRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -60745,7 +62688,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for CreatePipeTransportRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for CreateActiveSpeakerObserverRequestRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -60755,7 +62698,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[CreatePipeTransportRequestRef]", + "[CreateActiveSpeakerObserverRequestRef]", "get", buffer.offset_from_start, ) @@ -60763,10 +62706,10 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> - for CreatePipeTransportRequest + impl ::planus::VectorWrite<::planus::Offset> + for CreateActiveSpeakerObserverRequest { - type Value = ::planus::Offset; + type Value = ::planus::Offset; const STRIDE: usize = 4; #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { @@ -60775,7 +62718,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -60790,7 +62733,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for CreatePipeTransportRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for CreateActiveSpeakerObserverRequestRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -60801,7 +62744,7 @@ mod root { ) .map_err(|error_kind| { error_kind.with_error_location( - "[CreatePipeTransportRequestRef]", + "[CreateActiveSpeakerObserverRequestRef]", "read_as_root", 0, ) @@ -60809,10 +62752,10 @@ mod root { } } - /// The table `CreatePlainTransportRequest` in the namespace `FBS.Router` + /// The table `CloseTransportRequest` in the namespace `FBS.Router` /// /// Generated from these locations: - /// * Table `CreatePlainTransportRequest` in the file `../worker/fbs/router.fbs:28` + /// * Table `CloseTransportRequest` in the file `../worker/fbs/router.fbs:53` #[derive( Clone, Debug, @@ -60824,244 +62767,184 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct CreatePlainTransportRequest { - /// The field `transport_id` in the table `CreatePlainTransportRequest` + pub struct CloseTransportRequest { + /// The field `transport_id` in the table `CloseTransportRequest` 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. + impl CloseTransportRequest { + /// Creates a [CloseTransportRequestBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> CreatePlainTransportRequestBuilder<()> { - CreatePlainTransportRequestBuilder(()) + 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>, - 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> = + let mut table_writer: ::planus::table_writer::TableWriter<6> = ::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 - { + impl ::planus::WriteAs<::planus::Offset> for CloseTransportRequest { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> - for CreatePlainTransportRequest - { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for CreatePlainTransportRequest { + impl ::planus::WriteAsOffset for CloseTransportRequest { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CreatePlainTransportRequest::create(builder, &self.transport_id, &self.options) + ) -> ::planus::Offset { + CloseTransportRequest::create(builder, &self.transport_id) } } - /// Builder for serializing an instance of the [CreatePlainTransportRequest] type. + /// Builder for serializing an instance of the [CloseTransportRequest] type. /// - /// Can be created using the [CreatePlainTransportRequest::builder] method. + /// Can be created using the [CloseTransportRequest::builder] method. #[derive(Debug)] #[must_use] - pub struct CreatePlainTransportRequestBuilder(State); + pub struct CloseTransportRequestBuilder(State); - impl CreatePlainTransportRequestBuilder<()> { - /// Setter for the [`transport_id` field](CreatePlainTransportRequest#structfield.transport_id). + impl CloseTransportRequestBuilder<()> { + /// Setter for the [`transport_id` field](CloseTransportRequest#structfield.transport_id). #[inline] #[allow(clippy::type_complexity)] - pub fn transport_id( - self, - value: T0, - ) -> CreatePlainTransportRequestBuilder<(T0,)> + pub fn transport_id(self, value: T0) -> CloseTransportRequestBuilder<(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)) + CloseTransportRequestBuilder((value,)) } } - impl CreatePlainTransportRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CreatePlainTransportRequest]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + 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)> + impl>> + ::planus::WriteAs<::planus::Offset> + for CloseTransportRequestBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::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)> + impl>> + ::planus::WriteAsOptional<::planus::Offset> + for CloseTransportRequestBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> + ) -> ::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)> + impl>> + ::planus::WriteAsOffset + for CloseTransportRequestBuilder<(T0,)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - CreatePlainTransportRequest::create(builder, v0, v1) + ) -> ::planus::Offset { + let (v0,) = &self.0; + CloseTransportRequest::create(builder, v0) } } - /// Reference to a deserialized [CreatePlainTransportRequest]. + /// Reference to a deserialized [CloseTransportRequest]. #[derive(Copy, Clone)] - pub struct CreatePlainTransportRequestRef<'a>(::planus::table_reader::Table<'a>); + pub struct CloseTransportRequestRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> CreatePlainTransportRequestRef<'a> { - /// Getter for the [`transport_id` field](CreatePlainTransportRequest#structfield.transport_id). + 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, "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") + .access_required(0, "CloseTransportRequest", "transport_id") } } - impl<'a> ::core::fmt::Debug for CreatePlainTransportRequestRef<'a> { + 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("CreatePlainTransportRequestRef"); + let mut f = f.debug_struct("CloseTransportRequestRef"); f.field("transport_id", &self.transport_id()); - f.field("options", &self.options()); f.finish() } } - impl<'a> ::core::convert::TryFrom> - for CreatePlainTransportRequest - { + impl<'a> ::core::convert::TryFrom> for CloseTransportRequest { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: CreatePlainTransportRequestRef<'a>) -> ::planus::Result { + fn try_from(value: CloseTransportRequestRef<'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> { + impl<'a> ::planus::TableRead<'a> for CloseTransportRequestRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -61073,7 +62956,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for CreatePlainTransportRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for CloseTransportRequestRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -61083,7 +62966,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[CreatePlainTransportRequestRef]", + "[CloseTransportRequestRef]", "get", buffer.offset_from_start, ) @@ -61091,10 +62974,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> - for CreatePlainTransportRequest - { - type Value = ::planus::Offset; + 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 { @@ -61103,7 +62984,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -61118,7 +62999,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for CreatePlainTransportRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for CloseTransportRequestRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -61129,7 +63010,7 @@ mod root { ) .map_err(|error_kind| { error_kind.with_error_location( - "[CreatePlainTransportRequestRef]", + "[CloseTransportRequestRef]", "read_as_root", 0, ) @@ -61137,10 +63018,10 @@ mod root { } } - /// The table `CreateWebRtcTransportRequest` in the namespace `FBS.Router` + /// The table `CloseRtpObserverRequest` in the namespace `FBS.Router` /// /// Generated from these locations: - /// * Table `CreateWebRtcTransportRequest` in the file `../worker/fbs/router.fbs:33` + /// * Table `CloseRtpObserverRequest` in the file `../worker/fbs/router.fbs:57` #[derive( Clone, Debug, @@ -61152,63 +63033,52 @@ mod root { ::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, + pub struct CloseRtpObserverRequest { + /// The field `rtp_observer_id` in the table `CloseRtpObserverRequest` + pub rtp_observer_id: ::planus::alloc::string::String, } - impl CreateWebRtcTransportRequest { - /// Creates a [CreateWebRtcTransportRequestBuilder] for serializing an instance of this table. + impl CloseRtpObserverRequest { + /// Creates a [CloseRtpObserverRequestBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> CreateWebRtcTransportRequestBuilder<()> { - CreateWebRtcTransportRequestBuilder(()) + pub fn builder() -> CloseRtpObserverRequestBuilder<()> { + CloseRtpObserverRequestBuilder(()) } #[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, - >, + field_rtp_observer_id: impl ::planus::WriteAs<::planus::Offset>, ) -> ::planus::Offset { - let prepared_transport_id = field_transport_id.prepare(builder); - let prepared_options = field_options.prepare(builder); + let prepared_rtp_observer_id = field_rtp_observer_id.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<8> = + let mut table_writer: ::planus::table_writer::TableWriter<6> = ::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); + object_writer.write::<_, _, 4>(&prepared_rtp_observer_id); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> - for CreateWebRtcTransportRequest - { + impl ::planus::WriteAs<::planus::Offset> for CloseRtpObserverRequest { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> - for CreateWebRtcTransportRequest + impl ::planus::WriteAsOptional<::planus::Offset> + for CloseRtpObserverRequest { type Prepared = ::planus::Offset; @@ -61216,180 +63086,135 @@ mod root { fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for CreateWebRtcTransportRequest { + impl ::planus::WriteAsOffset for CloseRtpObserverRequest { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CreateWebRtcTransportRequest::create(builder, &self.transport_id, &self.options) + ) -> ::planus::Offset { + CloseRtpObserverRequest::create(builder, &self.rtp_observer_id) } } - /// Builder for serializing an instance of the [CreateWebRtcTransportRequest] type. + /// Builder for serializing an instance of the [CloseRtpObserverRequest] type. /// - /// Can be created using the [CreateWebRtcTransportRequest::builder] method. + /// Can be created using the [CloseRtpObserverRequest::builder] method. #[derive(Debug)] #[must_use] - pub struct CreateWebRtcTransportRequestBuilder(State); + pub struct CloseRtpObserverRequestBuilder(State); - impl CreateWebRtcTransportRequestBuilder<()> { - /// Setter for the [`transport_id` field](CreateWebRtcTransportRequest#structfield.transport_id). + impl CloseRtpObserverRequestBuilder<()> { + /// Setter for the [`rtp_observer_id` field](CloseRtpObserverRequest#structfield.rtp_observer_id). #[inline] #[allow(clippy::type_complexity)] - pub fn transport_id( - self, - value: T0, - ) -> CreateWebRtcTransportRequestBuilder<(T0,)> + pub fn rtp_observer_id(self, value: T0) -> CloseRtpObserverRequestBuilder<(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)) + CloseRtpObserverRequestBuilder((value,)) } } - impl CreateWebRtcTransportRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CreateWebRtcTransportRequest]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + 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)> + impl>> + ::planus::WriteAs<::planus::Offset> + for CloseRtpObserverRequestBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::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)> + impl>> + ::planus::WriteAsOptional<::planus::Offset> + for CloseRtpObserverRequestBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> + ) -> ::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)> + impl>> + ::planus::WriteAsOffset + for CloseRtpObserverRequestBuilder<(T0,)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - CreateWebRtcTransportRequest::create(builder, v0, v1) + ) -> ::planus::Offset { + let (v0,) = &self.0; + CloseRtpObserverRequest::create(builder, v0) } } - /// Reference to a deserialized [CreateWebRtcTransportRequest]. + /// Reference to a deserialized [CloseRtpObserverRequest]. #[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") - } + pub struct CloseRtpObserverRequestRef<'a>(::planus::table_reader::Table<'a>); - /// Getter for the [`options` field](CreateWebRtcTransportRequest#structfield.options). + impl<'a> CloseRtpObserverRequestRef<'a> { + /// Getter for the [`rtp_observer_id` field](CloseRtpObserverRequest#structfield.rtp_observer_id). #[inline] - pub fn options( - &self, - ) -> ::planus::Result> - { + pub fn rtp_observer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { self.0 - .access_required(1, "CreateWebRtcTransportRequest", "options") + .access_required(0, "CloseRtpObserverRequest", "rtp_observer_id") } } - impl<'a> ::core::fmt::Debug for CreateWebRtcTransportRequestRef<'a> { + 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("CreateWebRtcTransportRequestRef"); - f.field("transport_id", &self.transport_id()); - f.field("options", &self.options()); + let mut f = f.debug_struct("CloseRtpObserverRequestRef"); + f.field("rtp_observer_id", &self.rtp_observer_id()); f.finish() } } - impl<'a> ::core::convert::TryFrom> - for CreateWebRtcTransportRequest - { + impl<'a> ::core::convert::TryFrom> for CloseRtpObserverRequest { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: CreateWebRtcTransportRequestRef<'a>) -> ::planus::Result { + fn try_from(value: CloseRtpObserverRequestRef<'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()?)?, - ), + rtp_observer_id: ::core::convert::TryInto::try_into( + value.rtp_observer_id()?, + )?, }) } } - impl<'a> ::planus::TableRead<'a> for CreateWebRtcTransportRequestRef<'a> { + impl<'a> ::planus::TableRead<'a> for CloseRtpObserverRequestRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -61401,7 +63226,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for CreateWebRtcTransportRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for CloseRtpObserverRequestRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -61411,7 +63236,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[CreateWebRtcTransportRequestRef]", + "[CloseRtpObserverRequestRef]", "get", buffer.offset_from_start, ) @@ -61419,10 +63244,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> - for CreateWebRtcTransportRequest - { - type Value = ::planus::Offset; + 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 { @@ -61431,7 +63254,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -61446,7 +63269,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for CreateWebRtcTransportRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for CloseRtpObserverRequestRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -61457,18 +63280,23 @@ mod root { ) .map_err(|error_kind| { error_kind.with_error_location( - "[CreateWebRtcTransportRequestRef]", + "[CloseRtpObserverRequestRef]", "read_as_root", 0, ) }) } } - - /// The table `CreateDirectTransportRequest` in the namespace `FBS.Router` + } + /// 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 `CreateDirectTransportRequest` in the file `../worker/fbs/router.fbs:38` + /// * Table `IpPort` in the file `../worker/fbs/webRtcServer.fbs:5` #[derive( Clone, Debug, @@ -61480,132 +63308,121 @@ mod root { ::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, + 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 CreateDirectTransportRequest { - /// Creates a [CreateDirectTransportRequestBuilder] for serializing an instance of this table. + impl IpPort { + /// Creates a [IpPortBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> CreateDirectTransportRequestBuilder<()> { - CreateDirectTransportRequestBuilder(()) + pub fn builder() -> IpPortBuilder<()> { + IpPortBuilder(()) } #[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, - >, + field_ip: impl ::planus::WriteAs<::planus::Offset>, + field_port: impl ::planus::WriteAsDefault, ) -> ::planus::Offset { - let prepared_transport_id = field_transport_id.prepare(builder); - let prepared_options = field_options.prepare(builder); + 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); - table_writer.write_entry::<::planus::Offset>(1); + if prepared_port.is_some() { + table_writer.write_entry::(1); + } unsafe { table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_transport_id); - object_writer.write::<_, _, 4>(&prepared_options); + 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 CreateDirectTransportRequest - { + impl ::planus::WriteAs<::planus::Offset> for IpPort { type Prepared = ::planus::Offset; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> - for CreateDirectTransportRequest - { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for CreateDirectTransportRequest { + impl ::planus::WriteAsOffset for IpPort { #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CreateDirectTransportRequest::create(builder, &self.transport_id, &self.options) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + IpPort::create(builder, &self.ip, self.port) } } - /// Builder for serializing an instance of the [CreateDirectTransportRequest] type. + /// Builder for serializing an instance of the [IpPort] type. /// - /// Can be created using the [CreateDirectTransportRequest::builder] method. + /// Can be created using the [IpPort::builder] method. #[derive(Debug)] #[must_use] - pub struct CreateDirectTransportRequestBuilder(State); + pub struct IpPortBuilder(State); - impl CreateDirectTransportRequestBuilder<()> { - /// Setter for the [`transport_id` field](CreateDirectTransportRequest#structfield.transport_id). + impl IpPortBuilder<()> { + /// Setter for the [`ip` field](IpPort#structfield.ip). #[inline] #[allow(clippy::type_complexity)] - pub fn transport_id( - self, - value: T0, - ) -> CreateDirectTransportRequestBuilder<(T0,)> + pub fn ip(self, value: T0) -> IpPortBuilder<(T0,)> where T0: ::planus::WriteAs<::planus::Offset>, { - CreateDirectTransportRequestBuilder((value,)) + IpPortBuilder((value,)) } } - impl CreateDirectTransportRequestBuilder<(T0,)> { - /// Setter for the [`options` field](CreateDirectTransportRequest#structfield.options). + impl IpPortBuilder<(T0,)> { + /// Setter for the [`port` field](IpPort#structfield.port). #[inline] #[allow(clippy::type_complexity)] - pub fn options(self, value: T1) -> CreateDirectTransportRequestBuilder<(T0, T1)> + pub fn port(self, value: T1) -> IpPortBuilder<(T0, T1)> where - T1: ::planus::WriteAs< - ::planus::Offset, - >, + T1: ::planus::WriteAsDefault, { let (v0,) = self.0; - CreateDirectTransportRequestBuilder((v0, value)) + 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 CreateDirectTransportRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CreateDirectTransportRequest]. + 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 + pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } @@ -61613,111 +63430,85 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > ::planus::WriteAs<::planus::Offset> - for CreateDirectTransportRequestBuilder<(T0, T1)> + T1: ::planus::WriteAsDefault, + > ::planus::WriteAs<::planus::Offset> for IpPortBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + 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)> + T1: ::planus::WriteAsDefault, + > ::planus::WriteAsOptional<::planus::Offset> for IpPortBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { + ) -> ::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)> + T1: ::planus::WriteAsDefault, + > ::planus::WriteAsOffset for IpPortBuilder<(T0, T1)> { #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { let (v0, v1) = &self.0; - CreateDirectTransportRequest::create(builder, v0, v1) + IpPort::create(builder, v0, v1) } } - /// Reference to a deserialized [CreateDirectTransportRequest]. + /// Reference to a deserialized [IpPort]. #[derive(Copy, Clone)] - pub struct CreateDirectTransportRequestRef<'a>(::planus::table_reader::Table<'a>); + pub struct IpPortRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> CreateDirectTransportRequestRef<'a> { - /// Getter for the [`transport_id` field](CreateDirectTransportRequest#structfield.transport_id). + impl<'a> IpPortRef<'a> { + /// Getter for the [`ip` field](IpPort#structfield.ip). #[inline] - pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "CreateDirectTransportRequest", "transport_id") + pub fn ip(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "IpPort", "ip") } - /// Getter for the [`options` field](CreateDirectTransportRequest#structfield.options). + /// Getter for the [`port` field](IpPort#structfield.port). #[inline] - pub fn options( - &self, - ) -> ::planus::Result> - { - self.0 - .access_required(1, "CreateDirectTransportRequest", "options") + 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 CreateDirectTransportRequestRef<'a> { + 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("CreateDirectTransportRequestRef"); - f.field("transport_id", &self.transport_id()); - f.field("options", &self.options()); + 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 CreateDirectTransportRequest - { + impl<'a> ::core::convert::TryFrom> for IpPort { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: CreateDirectTransportRequestRef<'a>) -> ::planus::Result { + fn try_from(value: IpPortRef<'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()?)?, - ), + ip: ::core::convert::TryInto::try_into(value.ip()?)?, + port: ::core::convert::TryInto::try_into(value.port()?)?, }) } } - impl<'a> ::planus::TableRead<'a> for CreateDirectTransportRequestRef<'a> { + impl<'a> ::planus::TableRead<'a> for IpPortRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -61729,7 +63520,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for CreateDirectTransportRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for IpPortRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -61739,7 +63530,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[CreateDirectTransportRequestRef]", + "[IpPortRef]", "get", buffer.offset_from_start, ) @@ -61747,10 +63538,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> - for CreateDirectTransportRequest - { - type Value = ::planus::Offset; + 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 { @@ -61759,7 +63548,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -61774,7 +63563,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for CreateDirectTransportRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for IpPortRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -61784,19 +63573,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location( - "[CreateDirectTransportRequestRef]", - "read_as_root", - 0, - ) + error_kind.with_error_location("[IpPortRef]", "read_as_root", 0) }) } } - /// The table `CreateAudioLevelObserverRequest` in the namespace `FBS.Router` + /// The table `IceUserNameFragment` in the namespace `FBS.WebRtcServer` /// /// Generated from these locations: - /// * Table `CreateAudioLevelObserverRequest` in the file `../worker/fbs/router.fbs:43` + /// * Table `IceUserNameFragment` in the file `../worker/fbs/webRtcServer.fbs:10` #[derive( Clone, Debug, @@ -61808,142 +63593,130 @@ mod root { ::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, - >, + 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 CreateAudioLevelObserverRequest { - /// Creates a [CreateAudioLevelObserverRequestBuilder] for serializing an instance of this table. + impl IceUserNameFragment { + /// Creates a [IceUserNameFragmentBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> CreateAudioLevelObserverRequestBuilder<()> { - CreateAudioLevelObserverRequestBuilder(()) + pub fn builder() -> IceUserNameFragmentBuilder<()> { + IceUserNameFragmentBuilder(()) } #[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, - >, + field_local_ice_username_fragment: impl ::planus::WriteAs<::planus::Offset>, + field_web_rtc_transport_id: 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 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< - super::audio_level_observer::AudioLevelObserverOptions, - >>(1); + table_writer.write_entry::<::planus::Offset>(1); unsafe { table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_rtp_observer_id); - object_writer.write::<_, _, 4>(&prepared_options); + 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 CreateAudioLevelObserverRequest - { + impl ::planus::WriteAs<::planus::Offset> for IceUserNameFragment { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> - for CreateAudioLevelObserverRequest - { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for CreateAudioLevelObserverRequest { + impl ::planus::WriteAsOffset for IceUserNameFragment { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CreateAudioLevelObserverRequest::create( + ) -> ::planus::Offset { + IceUserNameFragment::create( builder, - &self.rtp_observer_id, - &self.options, + &self.local_ice_username_fragment, + &self.web_rtc_transport_id, ) } } - /// Builder for serializing an instance of the [CreateAudioLevelObserverRequest] type. + /// Builder for serializing an instance of the [IceUserNameFragment] type. /// - /// Can be created using the [CreateAudioLevelObserverRequest::builder] method. + /// Can be created using the [IceUserNameFragment::builder] method. #[derive(Debug)] #[must_use] - pub struct CreateAudioLevelObserverRequestBuilder(State); + pub struct IceUserNameFragmentBuilder(State); - impl CreateAudioLevelObserverRequestBuilder<()> { - /// Setter for the [`rtp_observer_id` field](CreateAudioLevelObserverRequest#structfield.rtp_observer_id). + impl IceUserNameFragmentBuilder<()> { + /// Setter for the [`local_ice_username_fragment` field](IceUserNameFragment#structfield.local_ice_username_fragment). #[inline] #[allow(clippy::type_complexity)] - pub fn rtp_observer_id( + pub fn local_ice_username_fragment( self, value: T0, - ) -> CreateAudioLevelObserverRequestBuilder<(T0,)> + ) -> IceUserNameFragmentBuilder<(T0,)> where T0: ::planus::WriteAs<::planus::Offset>, { - CreateAudioLevelObserverRequestBuilder((value,)) + IceUserNameFragmentBuilder((value,)) } } - impl CreateAudioLevelObserverRequestBuilder<(T0,)> { - /// Setter for the [`options` field](CreateAudioLevelObserverRequest#structfield.options). + impl IceUserNameFragmentBuilder<(T0,)> { + /// Setter for the [`web_rtc_transport_id` field](IceUserNameFragment#structfield.web_rtc_transport_id). #[inline] #[allow(clippy::type_complexity)] - pub fn options( + pub fn web_rtc_transport_id( self, value: T1, - ) -> CreateAudioLevelObserverRequestBuilder<(T0, T1)> + ) -> IceUserNameFragmentBuilder<(T0, T1)> where - T1: ::planus::WriteAs< - ::planus::Offset, - >, + T1: ::planus::WriteAs<::planus::Offset>, { let (v0,) = self.0; - CreateAudioLevelObserverRequestBuilder((v0, value)) + IceUserNameFragmentBuilder((v0, value)) } } - impl CreateAudioLevelObserverRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CreateAudioLevelObserverRequest]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } @@ -61951,115 +63724,105 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs< - ::planus::Offset, - >, - > ::planus::WriteAs<::planus::Offset> - for CreateAudioLevelObserverRequestBuilder<(T0, T1)> + T1: ::planus::WriteAs<::planus::Offset>, + > ::planus::WriteAs<::planus::Offset> + for IceUserNameFragmentBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::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)> + T1: ::planus::WriteAs<::planus::Offset>, + > ::planus::WriteAsOptional<::planus::Offset> + for IceUserNameFragmentBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { + ) -> ::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)> + T1: ::planus::WriteAs<::planus::Offset>, + > ::planus::WriteAsOffset + for IceUserNameFragmentBuilder<(T0, T1)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { let (v0, v1) = &self.0; - CreateAudioLevelObserverRequest::create(builder, v0, v1) + IceUserNameFragment::create(builder, v0, v1) } } - /// Reference to a deserialized [CreateAudioLevelObserverRequest]. + /// Reference to a deserialized [IceUserNameFragment]. #[derive(Copy, Clone)] - pub struct CreateAudioLevelObserverRequestRef<'a>(::planus::table_reader::Table<'a>); + pub struct IceUserNameFragmentRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> CreateAudioLevelObserverRequestRef<'a> { - /// Getter for the [`rtp_observer_id` field](CreateAudioLevelObserverRequest#structfield.rtp_observer_id). + impl<'a> IceUserNameFragmentRef<'a> { + /// Getter for the [`local_ice_username_fragment` field](IceUserNameFragment#structfield.local_ice_username_fragment). #[inline] - pub fn rtp_observer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + pub fn local_ice_username_fragment( + &self, + ) -> ::planus::Result<&'a ::core::primitive::str> { self.0 - .access_required(0, "CreateAudioLevelObserverRequest", "rtp_observer_id") + .access_required(0, "IceUserNameFragment", "local_ice_username_fragment") } - /// Getter for the [`options` field](CreateAudioLevelObserverRequest#structfield.options). + /// Getter for the [`web_rtc_transport_id` field](IceUserNameFragment#structfield.web_rtc_transport_id). #[inline] - pub fn options( - &self, - ) -> ::planus::Result> - { + pub fn web_rtc_transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { self.0 - .access_required(1, "CreateAudioLevelObserverRequest", "options") + .access_required(1, "IceUserNameFragment", "web_rtc_transport_id") } } - impl<'a> ::core::fmt::Debug for CreateAudioLevelObserverRequestRef<'a> { + 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("CreateAudioLevelObserverRequestRef"); - f.field("rtp_observer_id", &self.rtp_observer_id()); - f.field("options", &self.options()); + 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 CreateAudioLevelObserverRequest - { + impl<'a> ::core::convert::TryFrom> for IceUserNameFragment { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from( - value: CreateAudioLevelObserverRequestRef<'a>, - ) -> ::planus::Result { + fn try_from(value: IceUserNameFragmentRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - rtp_observer_id: ::core::convert::TryInto::try_into( - value.rtp_observer_id()?, + 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()?, )?, - options: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.options()?)?, - ), }) } } - impl<'a> ::planus::TableRead<'a> for CreateAudioLevelObserverRequestRef<'a> { + impl<'a> ::planus::TableRead<'a> for IceUserNameFragmentRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -62071,7 +63834,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for CreateAudioLevelObserverRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for IceUserNameFragmentRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -62081,7 +63844,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[CreateAudioLevelObserverRequestRef]", + "[IceUserNameFragmentRef]", "get", buffer.offset_from_start, ) @@ -62089,10 +63852,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> - for CreateAudioLevelObserverRequest - { - type Value = ::planus::Offset; + 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 { @@ -62101,7 +63862,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -62116,7 +63877,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for CreateAudioLevelObserverRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for IceUserNameFragmentRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -62127,7 +63888,7 @@ mod root { ) .map_err(|error_kind| { error_kind.with_error_location( - "[CreateAudioLevelObserverRequestRef]", + "[IceUserNameFragmentRef]", "read_as_root", 0, ) @@ -62135,10 +63896,10 @@ mod root { } } - /// The table `CreateActiveSpeakerObserverRequest` in the namespace `FBS.Router` + /// The table `TupleHash` in the namespace `FBS.WebRtcServer` /// /// Generated from these locations: - /// * Table `CreateActiveSpeakerObserverRequest` in the file `../worker/fbs/router.fbs:48` + /// * Table `TupleHash` in the file `../worker/fbs/webRtcServer.fbs:15` #[derive( Clone, Debug, @@ -62150,281 +63911,231 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct CreateActiveSpeakerObserverRequest { - /// The field `active_speaker_observer_id` in the table `CreateActiveSpeakerObserverRequest` - pub active_speaker_observer_id: ::planus::alloc::string::String, - /// The field `options` in the table `CreateActiveSpeakerObserverRequest` - pub options: ::planus::alloc::boxed::Box< - super::active_speaker_observer::ActiveSpeakerObserverOptions, - >, + pub struct TupleHash { + /// The field `local_ice_username_fragment` in the table `TupleHash` + pub local_ice_username_fragment: u64, + /// The field `web_rtc_transport_id` in the table `TupleHash` + pub web_rtc_transport_id: ::planus::alloc::string::String, } - impl CreateActiveSpeakerObserverRequest { - /// Creates a [CreateActiveSpeakerObserverRequestBuilder] for serializing an instance of this table. + impl TupleHash { + /// Creates a [TupleHashBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> CreateActiveSpeakerObserverRequestBuilder<()> { - CreateActiveSpeakerObserverRequestBuilder(()) + pub fn builder() -> TupleHashBuilder<()> { + TupleHashBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_active_speaker_observer_id: impl ::planus::WriteAs<::planus::Offset>, - field_options: impl ::planus::WriteAs< - ::planus::Offset< - super::active_speaker_observer::ActiveSpeakerObserverOptions, - >, - >, + field_local_ice_username_fragment: impl ::planus::WriteAsDefault, + field_web_rtc_transport_id: impl ::planus::WriteAs<::planus::Offset>, ) -> ::planus::Offset { - let prepared_active_speaker_observer_id = - field_active_speaker_observer_id.prepare(builder); - let prepared_options = field_options.prepare(builder); + let prepared_local_ice_username_fragment = + field_local_ice_username_fragment.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(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset< - super::active_speaker_observer::ActiveSpeakerObserverOptions, - >>(1); + if prepared_local_ice_username_fragment.is_some() { + table_writer.write_entry::(0); + } + table_writer.write_entry::<::planus::Offset>(1); unsafe { table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_active_speaker_observer_id); - object_writer.write::<_, _, 4>(&prepared_options); + if let ::core::option::Option::Some( + prepared_local_ice_username_fragment, + ) = prepared_local_ice_username_fragment + { + object_writer + .write::<_, _, 8>(&prepared_local_ice_username_fragment); + } + object_writer.write::<_, _, 4>(&prepared_web_rtc_transport_id); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> - for CreateActiveSpeakerObserverRequest - { + impl ::planus::WriteAs<::planus::Offset> for TupleHash { type Prepared = ::planus::Offset; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> - for CreateActiveSpeakerObserverRequest - { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset - for CreateActiveSpeakerObserverRequest - { + impl ::planus::WriteAsOffset for TupleHash { #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CreateActiveSpeakerObserverRequest::create( + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + TupleHash::create( builder, - &self.active_speaker_observer_id, - &self.options, + self.local_ice_username_fragment, + &self.web_rtc_transport_id, ) } } - /// Builder for serializing an instance of the [CreateActiveSpeakerObserverRequest] type. + /// Builder for serializing an instance of the [TupleHash] type. /// - /// Can be created using the [CreateActiveSpeakerObserverRequest::builder] method. + /// Can be created using the [TupleHash::builder] method. #[derive(Debug)] #[must_use] - pub struct CreateActiveSpeakerObserverRequestBuilder(State); + pub struct TupleHashBuilder(State); - impl CreateActiveSpeakerObserverRequestBuilder<()> { - /// Setter for the [`active_speaker_observer_id` field](CreateActiveSpeakerObserverRequest#structfield.active_speaker_observer_id). + impl TupleHashBuilder<()> { + /// Setter for the [`local_ice_username_fragment` field](TupleHash#structfield.local_ice_username_fragment). #[inline] #[allow(clippy::type_complexity)] - pub fn active_speaker_observer_id( - self, - value: T0, - ) -> CreateActiveSpeakerObserverRequestBuilder<(T0,)> + pub fn local_ice_username_fragment(self, value: T0) -> TupleHashBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset>, + T0: ::planus::WriteAsDefault, { - CreateActiveSpeakerObserverRequestBuilder((value,)) + TupleHashBuilder((value,)) } - } - impl CreateActiveSpeakerObserverRequestBuilder<(T0,)> { - /// Setter for the [`options` field](CreateActiveSpeakerObserverRequest#structfield.options). + /// Sets the [`local_ice_username_fragment` field](TupleHash#structfield.local_ice_username_fragment) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn options( + pub fn local_ice_username_fragment_as_default( self, - value: T1, - ) -> CreateActiveSpeakerObserverRequestBuilder<(T0, T1)> + ) -> TupleHashBuilder<(::planus::DefaultValue,)> { + self.local_ice_username_fragment(::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< - super::active_speaker_observer::ActiveSpeakerObserverOptions, - >, - >, + T1: ::planus::WriteAs<::planus::Offset>, { let (v0,) = self.0; - CreateActiveSpeakerObserverRequestBuilder((v0, value)) + TupleHashBuilder((v0, value)) } } - impl CreateActiveSpeakerObserverRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CreateActiveSpeakerObserverRequest]. + 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 + pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + 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)> + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAs<::planus::Offset>, + > ::planus::WriteAs<::planus::Offset> for TupleHashBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + 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)> + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAs<::planus::Offset>, + > ::planus::WriteAsOptional<::planus::Offset> + for TupleHashBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { + ) -> ::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)> + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAs<::planus::Offset>, + > ::planus::WriteAsOffset for TupleHashBuilder<(T0, T1)> { #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { let (v0, v1) = &self.0; - CreateActiveSpeakerObserverRequest::create(builder, v0, v1) + TupleHash::create(builder, v0, v1) } } - /// Reference to a deserialized [CreateActiveSpeakerObserverRequest]. + /// Reference to a deserialized [TupleHash]. #[derive(Copy, Clone)] - pub struct CreateActiveSpeakerObserverRequestRef<'a>(::planus::table_reader::Table<'a>); + pub struct TupleHashRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> CreateActiveSpeakerObserverRequestRef<'a> { - /// Getter for the [`active_speaker_observer_id` field](CreateActiveSpeakerObserverRequest#structfield.active_speaker_observer_id). + impl<'a> TupleHashRef<'a> { + /// Getter for the [`local_ice_username_fragment` field](TupleHash#structfield.local_ice_username_fragment). #[inline] - pub fn active_speaker_observer_id( - &self, - ) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required( - 0, - "CreateActiveSpeakerObserverRequest", - "active_speaker_observer_id", + pub fn local_ice_username_fragment(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "TupleHash", "local_ice_username_fragment")? + .unwrap_or(0), ) } - /// Getter for the [`options` field](CreateActiveSpeakerObserverRequest#structfield.options). + /// Getter for the [`web_rtc_transport_id` field](TupleHash#structfield.web_rtc_transport_id). #[inline] - pub fn options( - &self, - ) -> ::planus::Result< - super::active_speaker_observer::ActiveSpeakerObserverOptionsRef<'a>, - > { + pub fn web_rtc_transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { self.0 - .access_required(1, "CreateActiveSpeakerObserverRequest", "options") + .access_required(1, "TupleHash", "web_rtc_transport_id") } } - impl<'a> ::core::fmt::Debug for CreateActiveSpeakerObserverRequestRef<'a> { + 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("CreateActiveSpeakerObserverRequestRef"); + let mut f = f.debug_struct("TupleHashRef"); f.field( - "active_speaker_observer_id", - &self.active_speaker_observer_id(), + "local_ice_username_fragment", + &self.local_ice_username_fragment(), ); - f.field("options", &self.options()); + f.field("web_rtc_transport_id", &self.web_rtc_transport_id()); f.finish() } } - impl<'a> ::core::convert::TryFrom> - for CreateActiveSpeakerObserverRequest - { + impl<'a> ::core::convert::TryFrom> for TupleHash { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from( - value: CreateActiveSpeakerObserverRequestRef<'a>, - ) -> ::planus::Result { + fn try_from(value: TupleHashRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - active_speaker_observer_id: ::core::convert::TryInto::try_into( - value.active_speaker_observer_id()?, + 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()?, )?, - options: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.options()?)?, - ), }) } } - impl<'a> ::planus::TableRead<'a> for CreateActiveSpeakerObserverRequestRef<'a> { + impl<'a> ::planus::TableRead<'a> for TupleHashRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -62436,7 +64147,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for CreateActiveSpeakerObserverRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for TupleHashRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -62446,7 +64157,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[CreateActiveSpeakerObserverRequestRef]", + "[TupleHashRef]", "get", buffer.offset_from_start, ) @@ -62454,10 +64165,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> - for CreateActiveSpeakerObserverRequest - { - type Value = ::planus::Offset; + 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 { @@ -62466,7 +64175,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -62481,7 +64190,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for CreateActiveSpeakerObserverRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for TupleHashRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -62491,19 +64200,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location( - "[CreateActiveSpeakerObserverRequestRef]", - "read_as_root", - 0, - ) + error_kind.with_error_location("[TupleHashRef]", "read_as_root", 0) }) } } - /// The table `CloseTransportRequest` in the namespace `FBS.Router` + /// The table `DumpResponse` in the namespace `FBS.WebRtcServer` /// /// Generated from these locations: - /// * Table `CloseTransportRequest` in the file `../worker/fbs/router.fbs:53` + /// * Table `DumpResponse` in the file `../worker/fbs/webRtcServer.fbs:20` #[derive( Clone, Debug, @@ -62515,184 +64220,400 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct CloseTransportRequest { - /// The field `transport_id` in the table `CloseTransportRequest` - pub transport_id: ::planus::alloc::string::String, + 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 CloseTransportRequest { - /// Creates a [CloseTransportRequestBuilder] for serializing an instance of this table. + impl DumpResponse { + /// Creates a [DumpResponseBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> CloseTransportRequestBuilder<()> { - CloseTransportRequestBuilder(()) + pub fn builder() -> DumpResponseBuilder<()> { + DumpResponseBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_transport_id: impl ::planus::WriteAs<::planus::Offset>, + 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_transport_id = field_transport_id.prepare(builder); + 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<6> = + 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_transport_id); + 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 CloseTransportRequest { + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for CloseTransportRequest { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for CloseTransportRequest { + impl ::planus::WriteAsOffset for DumpResponse { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CloseTransportRequest::create(builder, &self.transport_id) + ) -> ::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 [CloseTransportRequest] type. + /// Builder for serializing an instance of the [DumpResponse] type. /// - /// Can be created using the [CloseTransportRequest::builder] method. + /// Can be created using the [DumpResponse::builder] method. #[derive(Debug)] #[must_use] - pub struct CloseTransportRequestBuilder(State); + pub struct DumpResponseBuilder(State); - impl CloseTransportRequestBuilder<()> { - /// Setter for the [`transport_id` field](CloseTransportRequest#structfield.transport_id). + impl DumpResponseBuilder<()> { + /// Setter for the [`id` field](DumpResponse#structfield.id). #[inline] #[allow(clippy::type_complexity)] - pub fn transport_id(self, value: T0) -> CloseTransportRequestBuilder<(T0,)> + pub fn id(self, value: T0) -> DumpResponseBuilder<(T0,)> where T0: ::planus::WriteAs<::planus::Offset>, { - CloseTransportRequestBuilder((value,)) + DumpResponseBuilder((value,)) } } - impl CloseTransportRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CloseTransportRequest]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl>> - ::planus::WriteAs<::planus::Offset> - for CloseTransportRequestBuilder<(T0,)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for CloseTransportRequestBuilder<(T0,)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl>> - ::planus::WriteAsOffset - for CloseTransportRequestBuilder<(T0,)> + 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,) = &self.0; - CloseTransportRequest::create(builder, v0) + ) -> ::planus::Offset { + let (v0, v1, v2, v3, v4, v5) = &self.0; + DumpResponse::create(builder, v0, v1, v2, v3, v4, v5) } } - /// Reference to a deserialized [CloseTransportRequest]. + /// Reference to a deserialized [DumpResponse]. #[derive(Copy, Clone)] - pub struct CloseTransportRequestRef<'a>(::planus::table_reader::Table<'a>); + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> CloseTransportRequestRef<'a> { - /// Getter for the [`transport_id` field](CloseTransportRequest#structfield.transport_id). + impl<'a> DumpResponseRef<'a> { + /// Getter for the [`id` field](DumpResponse#structfield.id). #[inline] - pub fn transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + 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(0, "CloseTransportRequest", "transport_id") + .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 CloseTransportRequestRef<'a> { + 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("CloseTransportRequestRef"); - f.field("transport_id", &self.transport_id()); + 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 CloseTransportRequest { + impl<'a> ::core::convert::TryFrom> for DumpResponse { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: CloseTransportRequestRef<'a>) -> ::planus::Result { + fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - transport_id: ::core::convert::TryInto::try_into(value.transport_id()?)?, + 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 CloseTransportRequestRef<'a> { + impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -62704,7 +64625,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for CloseTransportRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -62714,7 +64635,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[CloseTransportRequestRef]", + "[DumpResponseRef]", "get", buffer.offset_from_start, ) @@ -62722,8 +64643,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for CloseTransportRequest { - type Value = ::planus::Offset; + 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 { @@ -62732,7 +64653,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -62747,7 +64668,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for CloseTransportRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -62757,19 +64678,20 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location( - "[CloseTransportRequestRef]", - "read_as_root", - 0, - ) + error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) }) } } - - /// The table `CloseRtpObserverRequest` in the namespace `FBS.Router` + } + /// The namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * File `../worker/fbs/producer.fbs` + pub mod producer { + /// The table `EnableTraceEventRequest` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `CloseRtpObserverRequest` in the file `../worker/fbs/router.fbs:57` + /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/producer.fbs:6` #[derive( Clone, Debug, @@ -62781,52 +64703,52 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct CloseRtpObserverRequest { - /// The field `rtp_observer_id` in the table `CloseRtpObserverRequest` - pub rtp_observer_id: ::planus::alloc::string::String, + pub struct EnableTraceEventRequest { + /// The field `events` in the table `EnableTraceEventRequest` + pub events: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, } - impl CloseRtpObserverRequest { - /// Creates a [CloseRtpObserverRequestBuilder] for serializing an instance of this table. + impl EnableTraceEventRequest { + /// Creates a [EnableTraceEventRequestBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> CloseRtpObserverRequestBuilder<()> { - CloseRtpObserverRequestBuilder(()) + pub fn builder() -> EnableTraceEventRequestBuilder<()> { + EnableTraceEventRequestBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_rtp_observer_id: impl ::planus::WriteAs<::planus::Offset>, + field_events: impl ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, ) -> ::planus::Offset { - let prepared_rtp_observer_id = field_rtp_observer_id.prepare(builder); + 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>(0); + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(0); unsafe { table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_rtp_observer_id); + object_writer.write::<_, _, 4>(&prepared_events); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for CloseRtpObserverRequest { + impl ::planus::WriteAs<::planus::Offset> for EnableTraceEventRequest { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> - for CloseRtpObserverRequest + impl ::planus::WriteAsOptional<::planus::Offset> + for EnableTraceEventRequest { type Prepared = ::planus::Offset; @@ -62834,135 +64756,137 @@ mod root { fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for CloseRtpObserverRequest { + impl ::planus::WriteAsOffset for EnableTraceEventRequest { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - CloseRtpObserverRequest::create(builder, &self.rtp_observer_id) + ) -> ::planus::Offset { + EnableTraceEventRequest::create(builder, &self.events) } } - /// Builder for serializing an instance of the [CloseRtpObserverRequest] type. + /// Builder for serializing an instance of the [EnableTraceEventRequest] type. /// - /// Can be created using the [CloseRtpObserverRequest::builder] method. + /// Can be created using the [EnableTraceEventRequest::builder] method. #[derive(Debug)] #[must_use] - pub struct CloseRtpObserverRequestBuilder(State); + pub struct EnableTraceEventRequestBuilder(State); - impl CloseRtpObserverRequestBuilder<()> { - /// Setter for the [`rtp_observer_id` field](CloseRtpObserverRequest#structfield.rtp_observer_id). + impl EnableTraceEventRequestBuilder<()> { + /// Setter for the [`events` field](EnableTraceEventRequest#structfield.events). #[inline] #[allow(clippy::type_complexity)] - pub fn rtp_observer_id(self, value: T0) -> CloseRtpObserverRequestBuilder<(T0,)> + pub fn events(self, value: T0) -> EnableTraceEventRequestBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset>, + T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, { - CloseRtpObserverRequestBuilder((value,)) + EnableTraceEventRequestBuilder((value,)) } } - impl CloseRtpObserverRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [CloseRtpObserverRequest]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl>> - ::planus::WriteAs<::planus::Offset> - for CloseRtpObserverRequestBuilder<(T0,)> + impl]>>> + ::planus::WriteAs<::planus::Offset> + for EnableTraceEventRequestBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for CloseRtpObserverRequestBuilder<(T0,)> + impl]>>> + ::planus::WriteAsOptional<::planus::Offset> + for EnableTraceEventRequestBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl>> - ::planus::WriteAsOffset - for CloseRtpObserverRequestBuilder<(T0,)> + impl]>>> + ::planus::WriteAsOffset + for EnableTraceEventRequestBuilder<(T0,)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { let (v0,) = &self.0; - CloseRtpObserverRequest::create(builder, v0) + EnableTraceEventRequest::create(builder, v0) } } - /// Reference to a deserialized [CloseRtpObserverRequest]. + /// Reference to a deserialized [EnableTraceEventRequest]. #[derive(Copy, Clone)] - pub struct CloseRtpObserverRequestRef<'a>(::planus::table_reader::Table<'a>); + pub struct EnableTraceEventRequestRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> CloseRtpObserverRequestRef<'a> { - /// Getter for the [`rtp_observer_id` field](CloseRtpObserverRequest#structfield.rtp_observer_id). + impl<'a> EnableTraceEventRequestRef<'a> { + /// Getter for the [`events` field](EnableTraceEventRequest#structfield.events). #[inline] - pub fn rtp_observer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + pub fn events( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + > { self.0 - .access_required(0, "CloseRtpObserverRequest", "rtp_observer_id") + .access_required(0, "EnableTraceEventRequest", "events") } } - impl<'a> ::core::fmt::Debug for CloseRtpObserverRequestRef<'a> { + 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("CloseRtpObserverRequestRef"); - f.field("rtp_observer_id", &self.rtp_observer_id()); + let mut f = f.debug_struct("EnableTraceEventRequestRef"); + f.field("events", &self.events()); f.finish() } } - impl<'a> ::core::convert::TryFrom> for CloseRtpObserverRequest { + impl<'a> ::core::convert::TryFrom> for EnableTraceEventRequest { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: CloseRtpObserverRequestRef<'a>) -> ::planus::Result { + fn try_from(value: EnableTraceEventRequestRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - rtp_observer_id: ::core::convert::TryInto::try_into( - value.rtp_observer_id()?, - )?, + events: value.events()?.to_vec_result()?, }) } } - impl<'a> ::planus::TableRead<'a> for CloseRtpObserverRequestRef<'a> { + impl<'a> ::planus::TableRead<'a> for EnableTraceEventRequestRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -62974,7 +64898,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for CloseRtpObserverRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for EnableTraceEventRequestRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -62984,7 +64908,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[CloseRtpObserverRequestRef]", + "[EnableTraceEventRequestRef]", "get", buffer.offset_from_start, ) @@ -62992,8 +64916,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for CloseRtpObserverRequest { - type Value = ::planus::Offset; + 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 { @@ -63002,7 +64926,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -63017,7 +64941,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for CloseRtpObserverRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for EnableTraceEventRequestRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -63028,69 +64952,118 @@ mod root { ) .map_err(|error_kind| { error_kind.with_error_location( - "[CloseRtpObserverRequestRef]", + "[EnableTraceEventRequestRef]", "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` + + /// The table `DumpResponse` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `IpPort` in the file `../worker/fbs/webRtcServer.fbs:5` + /// * Table `DumpResponse` in the file `../worker/fbs/producer.fbs:10` #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, + Clone, Debug, PartialEq, PartialOrd, ::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, + 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_: ::planus::alloc::string::String, + /// 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: + ::core::option::Option<::planus::alloc::vec::Vec>, + /// The field `trace_event_types` in the table `DumpResponse` + pub trace_event_types: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + /// The field `paused` in the table `DumpResponse` + pub paused: bool, } - impl IpPort { - /// Creates a [IpPortBuilder] for serializing an instance of this table. + impl DumpResponse { + /// Creates a [DumpResponseBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> IpPortBuilder<()> { - IpPortBuilder(()) + pub fn builder() -> DumpResponseBuilder<()> { + DumpResponseBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_ip: impl ::planus::WriteAs<::planus::Offset>, - field_port: impl ::planus::WriteAsDefault, + field_id: impl ::planus::WriteAs<::planus::Offset>, + field_kind: impl ::planus::WriteAsDefault< + super::rtp_parameters::MediaKind, + super::rtp_parameters::MediaKind, + >, + field_type_: impl ::planus::WriteAs<::planus::Offset>, + field_rtp_parameters: impl ::planus::WriteAs< + ::planus::Offset, + >, + field_rtp_mapping: impl ::planus::WriteAs< + ::planus::Offset, + >, + field_rtp_streams: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + field_trace_event_types: impl ::planus::WriteAs< + ::planus::Offset<[::planus::Offset]>, + >, + field_paused: impl ::planus::WriteAsDefault, ) -> ::planus::Offset { - let prepared_ip = field_ip.prepare(builder); - let prepared_port = field_port.prepare(builder, &0); + let prepared_id = field_id.prepare(builder); + let prepared_kind = + field_kind.prepare(builder, &super::rtp_parameters::MediaKind::All); + let prepared_type_ = field_type_.prepare(builder); + 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<8> = + let mut table_writer: ::planus::table_writer::TableWriter<20> = ::core::default::Default::default(); table_writer.write_entry::<::planus::Offset>(0); - if prepared_port.is_some() { - table_writer.write_entry::(1); + table_writer.write_entry::<::planus::Offset>(2); + table_writer + .write_entry::<::planus::Offset>(3); + table_writer + .write_entry::<::planus::Offset>(4); + if prepared_rtp_streams.is_some() { + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(5); + } + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(6); + if prepared_kind.is_some() { + table_writer.write_entry::(1); + } + if prepared_paused.is_some() { + table_writer.write_entry::(7); } 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); + object_writer.write::<_, _, 4>(&prepared_id); + object_writer.write::<_, _, 4>(&prepared_type_); + object_writer.write::<_, _, 4>(&prepared_rtp_parameters); + object_writer.write::<_, _, 4>(&prepared_rtp_mapping); + if let ::core::option::Option::Some(prepared_rtp_streams) = + prepared_rtp_streams + { + 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_paused) = prepared_paused { + object_writer.write::<_, _, 1>(&prepared_paused); } }); } @@ -63098,79 +65071,207 @@ mod root { } } - impl ::planus::WriteAs<::planus::Offset> for IpPort { + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for IpPort { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for IpPort { + impl ::planus::WriteAsOffset for DumpResponse { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - IpPort::create(builder, &self.ip, self.port) + 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 [IpPort] type. + /// Builder for serializing an instance of the [DumpResponse] type. /// - /// Can be created using the [IpPort::builder] method. + /// Can be created using the [DumpResponse::builder] method. #[derive(Debug)] #[must_use] - pub struct IpPortBuilder(State); + pub struct DumpResponseBuilder(State); - impl IpPortBuilder<()> { - /// Setter for the [`ip` field](IpPort#structfield.ip). + impl DumpResponseBuilder<()> { + /// Setter for the [`id` field](DumpResponse#structfield.id). #[inline] #[allow(clippy::type_complexity)] - pub fn ip(self, value: T0) -> IpPortBuilder<(T0,)> + pub fn id(self, value: T0) -> DumpResponseBuilder<(T0,)> where T0: ::planus::WriteAs<::planus::Offset>, { - IpPortBuilder((value,)) + DumpResponseBuilder((value,)) } } - impl IpPortBuilder<(T0,)> { - /// Setter for the [`port` field](IpPort#structfield.port). + impl DumpResponseBuilder<(T0,)> { + /// Setter for the [`kind` field](DumpResponse#structfield.kind). #[inline] #[allow(clippy::type_complexity)] - pub fn port(self, value: T1) -> IpPortBuilder<(T0, T1)> + pub fn kind(self, value: T1) -> DumpResponseBuilder<(T0, T1)> where - T1: ::planus::WriteAsDefault, + T1: ::planus::WriteAsDefault< + super::rtp_parameters::MediaKind, + super::rtp_parameters::MediaKind, + >, { let (v0,) = self.0; - IpPortBuilder((v0, value)) + DumpResponseBuilder((v0, value)) } - /// Sets the [`port` field](IpPort#structfield.port) to the default value. + /// Sets the [`kind` field](DumpResponse#structfield.kind) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn port_as_default(self) -> IpPortBuilder<(T0, ::planus::DefaultValue)> { - self.port(::planus::DefaultValue) + pub fn kind_as_default(self) -> DumpResponseBuilder<(T0, ::planus::DefaultValue)> { + self.kind(::planus::DefaultValue) } } - impl IpPortBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [IpPort]. + impl DumpResponseBuilder<(T0, T1)> { + /// Setter for the [`type` field](DumpResponse#structfield.type_). #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset + #[allow(clippy::type_complexity)] + pub fn type_(self, value: T2) -> DumpResponseBuilder<(T0, T1, T2)> where - Self: ::planus::WriteAsOffset, + T2: ::planus::WriteAs<::planus::Offset>, + { + let (v0, v1) = self.0; + DumpResponseBuilder((v0, v1, value)) + } + } + + 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::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + { + let (v0, v1, v2, v3, v4) = self.0; + DumpResponseBuilder((v0, v1, v2, v3, v4, value)) + } + + /// Sets the [`rtp_streams` field](DumpResponse#structfield.rtp_streams) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn rtp_streams_as_null(self) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, ())> { + self.rtp_streams(()) + } + } + + 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<[::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 [`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) } @@ -63178,85 +65279,210 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> for IpPortBuilder<(T0, T1)> + T1: ::planus::WriteAsDefault< + super::rtp_parameters::MediaKind, + super::rtp_parameters::MediaKind, + >, + T2: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAs<::planus::Offset>, + T5: ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T7: ::planus::WriteAsDefault, + > ::planus::WriteAs<::planus::Offset> + for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + 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)> + T1: ::planus::WriteAsDefault< + super::rtp_parameters::MediaKind, + super::rtp_parameters::MediaKind, + >, + T2: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAs<::planus::Offset>, + T5: ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T7: ::planus::WriteAsDefault, + > ::planus::WriteAsOptional<::planus::Offset> + for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::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)> + T1: ::planus::WriteAsDefault< + super::rtp_parameters::MediaKind, + super::rtp_parameters::MediaKind, + >, + T2: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAs<::planus::Offset>, + T5: ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + T6: ::planus::WriteAs<::planus::Offset<[::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) = &self.0; - IpPort::create(builder, v0, v1) + 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 [IpPort]. + /// Reference to a deserialized [DumpResponse]. #[derive(Copy, Clone)] - pub struct IpPortRef<'a>(::planus::table_reader::Table<'a>); + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> IpPortRef<'a> { - /// Getter for the [`ip` field](IpPort#structfield.ip). + impl<'a> DumpResponseRef<'a> { + /// Getter for the [`id` field](DumpResponse#structfield.id). #[inline] - pub fn ip(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "IpPort", "ip") + pub fn id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "DumpResponse", "id") } - /// Getter for the [`port` field](IpPort#structfield.port). + /// Getter for the [`kind` field](DumpResponse#structfield.kind). #[inline] - pub fn port(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(1, "IpPort", "port")?.unwrap_or(0)) + pub fn kind(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "DumpResponse", "kind")? + .unwrap_or(super::rtp_parameters::MediaKind::All), + ) + } + + /// Getter for the [`type` field](DumpResponse#structfield.type_). + #[inline] + pub fn type_(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(2, "DumpResponse", "type_") + } + + /// 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< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, + > { + self.0.access(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, ::planus::Result<&'a ::core::primitive::str>>, + > { + 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 IpPortRef<'a> { + 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("IpPortRef"); - f.field("ip", &self.ip()); - f.field("port", &self.port()); + 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()); + if let ::core::option::Option::Some(field_rtp_streams) = + self.rtp_streams().transpose() + { + f.field("rtp_streams", &field_rtp_streams); + } + f.field("trace_event_types", &self.trace_event_types()); + f.field("paused", &self.paused()); f.finish() } } - impl<'a> ::core::convert::TryFrom> for IpPort { + impl<'a> ::core::convert::TryFrom> for DumpResponse { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: IpPortRef<'a>) -> ::planus::Result { + fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - ip: ::core::convert::TryInto::try_into(value.ip()?)?, - port: ::core::convert::TryInto::try_into(value.port()?)?, + 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: if let ::core::option::Option::Some(rtp_streams) = + value.rtp_streams()? + { + ::core::option::Option::Some(rtp_streams.to_vec_result()?) + } else { + ::core::option::Option::None + }, + trace_event_types: value.trace_event_types()?.to_vec_result()?, + paused: ::core::convert::TryInto::try_into(value.paused()?)?, }) } } - impl<'a> ::planus::TableRead<'a> for IpPortRef<'a> { + impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -63268,7 +65494,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for IpPortRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -63278,7 +65504,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[IpPortRef]", + "[DumpResponseRef]", "get", buffer.offset_from_start, ) @@ -63286,8 +65512,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for IpPort { - type Value = ::planus::Offset; + 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 { @@ -63296,7 +65522,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -63311,7 +65537,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for IpPortRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -63321,256 +65547,238 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[IpPortRef]", "read_as_root", 0) + error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) }) } } - /// The table `IceUserNameFragment` in the namespace `FBS.WebRtcServer` + /// The table `GetStatsResponse` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `IceUserNameFragment` in the file `../worker/fbs/webRtcServer.fbs:10` + /// * Table `GetStatsResponse` in the file `../worker/fbs/producer.fbs:21` #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, + Clone, Debug, PartialEq, PartialOrd, ::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, + pub struct GetStatsResponse { + /// The field `stats` in the table `GetStatsResponse` + pub stats: + ::core::option::Option<::planus::alloc::vec::Vec>, } - impl IceUserNameFragment { - /// Creates a [IceUserNameFragmentBuilder] for serializing an instance of this table. + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for GetStatsResponse { + fn default() -> Self { + Self { + stats: ::core::default::Default::default(), + } + } + } + + impl GetStatsResponse { + /// Creates a [GetStatsResponseBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> IceUserNameFragmentBuilder<()> { - IceUserNameFragmentBuilder(()) + pub fn builder() -> GetStatsResponseBuilder<()> { + GetStatsResponseBuilder(()) } #[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>, + field_stats: impl ::planus::WriteAsOptional< + ::planus::Offset<[::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 prepared_stats = field_stats.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<8> = + let mut table_writer: ::planus::table_writer::TableWriter<6> = ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::planus::Offset>(1); + if prepared_stats.is_some() { + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(0); + } 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); + if let ::core::option::Option::Some(prepared_stats) = prepared_stats { + object_writer.write::<_, _, 4>(&prepared_stats); + } }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for IceUserNameFragment { + impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for IceUserNameFragment { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for IceUserNameFragment { + impl ::planus::WriteAsOffset for GetStatsResponse { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - IceUserNameFragment::create( - builder, - &self.local_ice_username_fragment, - &self.web_rtc_transport_id, - ) + ) -> ::planus::Offset { + GetStatsResponse::create(builder, &self.stats) } } - /// Builder for serializing an instance of the [IceUserNameFragment] type. + /// Builder for serializing an instance of the [GetStatsResponse] type. /// - /// Can be created using the [IceUserNameFragment::builder] method. + /// Can be created using the [GetStatsResponse::builder] method. #[derive(Debug)] #[must_use] - pub struct IceUserNameFragmentBuilder(State); + pub struct GetStatsResponseBuilder(State); - impl IceUserNameFragmentBuilder<()> { - /// Setter for the [`local_ice_username_fragment` field](IceUserNameFragment#structfield.local_ice_username_fragment). + impl GetStatsResponseBuilder<()> { + /// Setter for the [`stats` field](GetStatsResponse#structfield.stats). #[inline] #[allow(clippy::type_complexity)] - pub fn local_ice_username_fragment( - self, - value: T0, - ) -> IceUserNameFragmentBuilder<(T0,)> + pub fn stats(self, value: T0) -> GetStatsResponseBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset>, + T0: ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, { - IceUserNameFragmentBuilder((value,)) + GetStatsResponseBuilder((value,)) } - } - impl IceUserNameFragmentBuilder<(T0,)> { - /// Setter for the [`web_rtc_transport_id` field](IceUserNameFragment#structfield.web_rtc_transport_id). + /// Sets the [`stats` field](GetStatsResponse#structfield.stats) to null. #[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)) + pub fn stats_as_null(self) -> GetStatsResponseBuilder<((),)> { + self.stats(()) } } - impl IceUserNameFragmentBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [IceUserNameFragment]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + 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)> + T0: ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + > ::planus::WriteAs<::planus::Offset> + for GetStatsResponseBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::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)> + T0: ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + > ::planus::WriteAsOptional<::planus::Offset> + for GetStatsResponseBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::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)> + T0: ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, + > ::planus::WriteAsOffset for GetStatsResponseBuilder<(T0,)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - IceUserNameFragment::create(builder, v0, v1) + ) -> ::planus::Offset { + let (v0,) = &self.0; + GetStatsResponse::create(builder, v0) } } - /// Reference to a deserialized [IceUserNameFragment]. + /// Reference to a deserialized [GetStatsResponse]. #[derive(Copy, Clone)] - pub struct IceUserNameFragmentRef<'a>(::planus::table_reader::Table<'a>); + pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> IceUserNameFragmentRef<'a> { - /// Getter for the [`local_ice_username_fragment` field](IceUserNameFragment#structfield.local_ice_username_fragment). + impl<'a> GetStatsResponseRef<'a> { + /// Getter for the [`stats` field](GetStatsResponse#structfield.stats). #[inline] - pub fn local_ice_username_fragment( + pub fn stats( &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") + ) -> ::planus::Result< + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, + > { + self.0.access(0, "GetStatsResponse", "stats") } } - impl<'a> ::core::fmt::Debug for IceUserNameFragmentRef<'a> { + 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("IceUserNameFragmentRef"); - f.field( - "local_ice_username_fragment", - &self.local_ice_username_fragment(), - ); - f.field("web_rtc_transport_id", &self.web_rtc_transport_id()); + let mut f = f.debug_struct("GetStatsResponseRef"); + if let ::core::option::Option::Some(field_stats) = self.stats().transpose() { + f.field("stats", &field_stats); + } f.finish() } } - impl<'a> ::core::convert::TryFrom> for IceUserNameFragment { + impl<'a> ::core::convert::TryFrom> for GetStatsResponse { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: IceUserNameFragmentRef<'a>) -> ::planus::Result { + fn try_from(value: GetStatsResponseRef<'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()?, - )?, + stats: if let ::core::option::Option::Some(stats) = value.stats()? { + ::core::option::Option::Some(stats.to_vec_result()?) + } else { + ::core::option::Option::None + }, }) } } - impl<'a> ::planus::TableRead<'a> for IceUserNameFragmentRef<'a> { + impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -63582,7 +65790,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for IceUserNameFragmentRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for GetStatsResponseRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -63592,7 +65800,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[IceUserNameFragmentRef]", + "[GetStatsResponseRef]", "get", buffer.offset_from_start, ) @@ -63600,8 +65808,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for IceUserNameFragment { - type Value = ::planus::Offset; + 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 { @@ -63610,7 +65818,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -63625,7 +65833,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for IceUserNameFragmentRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for GetStatsResponseRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -63635,19 +65843,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location( - "[IceUserNameFragmentRef]", - "read_as_root", - 0, - ) + error_kind.with_error_location("[GetStatsResponseRef]", "read_as_root", 0) }) } } - /// The table `TupleHash` in the namespace `FBS.WebRtcServer` + /// The table `SendNotification` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `TupleHash` in the file `../worker/fbs/webRtcServer.fbs:15` + /// * Table `SendNotification` in the file `../worker/fbs/producer.fbs:25` #[derive( Clone, Debug, @@ -63659,231 +65863,180 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct TupleHash { - /// The field `local_ice_username_fragment` in the table `TupleHash` - pub local_ice_username_fragment: u64, - /// The field `web_rtc_transport_id` in the table `TupleHash` - pub web_rtc_transport_id: ::planus::alloc::string::String, + pub struct SendNotification { + /// The field `data` in the table `SendNotification` + pub data: ::planus::alloc::vec::Vec, } - impl TupleHash { - /// Creates a [TupleHashBuilder] for serializing an instance of this table. + impl SendNotification { + /// Creates a [SendNotificationBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> TupleHashBuilder<()> { - TupleHashBuilder(()) + pub fn builder() -> SendNotificationBuilder<()> { + SendNotificationBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_local_ice_username_fragment: impl ::planus::WriteAsDefault, - field_web_rtc_transport_id: impl ::planus::WriteAs<::planus::Offset>, + field_data: impl ::planus::WriteAs<::planus::Offset<[u8]>>, ) -> ::planus::Offset { - let prepared_local_ice_username_fragment = - field_local_ice_username_fragment.prepare(builder, &0); - let prepared_web_rtc_transport_id = field_web_rtc_transport_id.prepare(builder); + let prepared_data = field_data.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<8> = + let mut table_writer: ::planus::table_writer::TableWriter<6> = ::core::default::Default::default(); - if prepared_local_ice_username_fragment.is_some() { - table_writer.write_entry::(0); - } - table_writer.write_entry::<::planus::Offset>(1); + table_writer.write_entry::<::planus::Offset<[u8]>>(0); unsafe { table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some( - prepared_local_ice_username_fragment, - ) = prepared_local_ice_username_fragment - { - object_writer - .write::<_, _, 8>(&prepared_local_ice_username_fragment); - } - object_writer.write::<_, _, 4>(&prepared_web_rtc_transport_id); + object_writer.write::<_, _, 4>(&prepared_data); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for TupleHash { + impl ::planus::WriteAs<::planus::Offset> for SendNotification { type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for TupleHash { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for TupleHash { + impl ::planus::WriteAsOffset for SendNotification { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - TupleHash::create( - builder, - self.local_ice_username_fragment, - &self.web_rtc_transport_id, - ) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SendNotification::create(builder, &self.data) } } - /// Builder for serializing an instance of the [TupleHash] type. + /// Builder for serializing an instance of the [SendNotification] type. /// - /// Can be created using the [TupleHash::builder] method. + /// Can be created using the [SendNotification::builder] method. #[derive(Debug)] #[must_use] - pub struct TupleHashBuilder(State); - - impl TupleHashBuilder<()> { - /// Setter for the [`local_ice_username_fragment` field](TupleHash#structfield.local_ice_username_fragment). - #[inline] - #[allow(clippy::type_complexity)] - pub fn local_ice_username_fragment(self, value: T0) -> TupleHashBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - TupleHashBuilder((value,)) - } - - /// Sets the [`local_ice_username_fragment` field](TupleHash#structfield.local_ice_username_fragment) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn local_ice_username_fragment_as_default( - self, - ) -> TupleHashBuilder<(::planus::DefaultValue,)> { - self.local_ice_username_fragment(::planus::DefaultValue) - } - } + pub struct SendNotificationBuilder(State); - impl TupleHashBuilder<(T0,)> { - /// Setter for the [`web_rtc_transport_id` field](TupleHash#structfield.web_rtc_transport_id). + impl SendNotificationBuilder<()> { + /// Setter for the [`data` field](SendNotification#structfield.data). #[inline] #[allow(clippy::type_complexity)] - pub fn web_rtc_transport_id(self, value: T1) -> TupleHashBuilder<(T0, T1)> + pub fn data(self, value: T0) -> SendNotificationBuilder<(T0,)> where - T1: ::planus::WriteAs<::planus::Offset>, + T0: ::planus::WriteAs<::planus::Offset<[u8]>>, { - let (v0,) = self.0; - TupleHashBuilder((v0, value)) + SendNotificationBuilder((value,)) } } - impl TupleHashBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [TupleHash]. + 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 + pub fn finish( + self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + 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)> + impl>> + ::planus::WriteAs<::planus::Offset> + for SendNotificationBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + 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)> + impl>> + ::planus::WriteAsOptional<::planus::Offset> + for SendNotificationBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::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)> + impl>> + ::planus::WriteAsOffset for SendNotificationBuilder<(T0,)> { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1) = &self.0; - TupleHash::create(builder, v0, v1) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + let (v0,) = &self.0; + SendNotification::create(builder, v0) } } - /// Reference to a deserialized [TupleHash]. + /// Reference to a deserialized [SendNotification]. #[derive(Copy, Clone)] - pub struct TupleHashRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> TupleHashRef<'a> { - /// Getter for the [`local_ice_username_fragment` field](TupleHash#structfield.local_ice_username_fragment). - #[inline] - pub fn local_ice_username_fragment(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(0, "TupleHash", "local_ice_username_fragment")? - .unwrap_or(0), - ) - } + pub struct SendNotificationRef<'a>(::planus::table_reader::Table<'a>); - /// Getter for the [`web_rtc_transport_id` field](TupleHash#structfield.web_rtc_transport_id). + impl<'a> SendNotificationRef<'a> { + /// Getter for the [`data` field](SendNotification#structfield.data). #[inline] - pub fn web_rtc_transport_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(1, "TupleHash", "web_rtc_transport_id") + pub fn data(&self) -> ::planus::Result<&'a [u8]> { + self.0.access_required(0, "SendNotification", "data") } } - impl<'a> ::core::fmt::Debug for TupleHashRef<'a> { + 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("TupleHashRef"); - f.field( - "local_ice_username_fragment", - &self.local_ice_username_fragment(), - ); - f.field("web_rtc_transport_id", &self.web_rtc_transport_id()); + let mut f = f.debug_struct("SendNotificationRef"); + f.field("data", &self.data()); f.finish() } } - impl<'a> ::core::convert::TryFrom> for TupleHash { + impl<'a> ::core::convert::TryFrom> for SendNotification { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: TupleHashRef<'a>) -> ::planus::Result { + fn try_from(value: SendNotificationRef<'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()?, - )?, + data: value.data()?.to_vec(), }) } } - impl<'a> ::planus::TableRead<'a> for TupleHashRef<'a> { + impl<'a> ::planus::TableRead<'a> for SendNotificationRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -63895,7 +66048,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for TupleHashRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for SendNotificationRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -63905,7 +66058,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[TupleHashRef]", + "[SendNotificationRef]", "get", buffer.offset_from_start, ) @@ -63913,8 +66066,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for TupleHash { - type Value = ::planus::Offset; + 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 { @@ -63923,7 +66076,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -63938,7 +66091,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for TupleHashRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for SendNotificationRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -63948,15 +66101,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[TupleHashRef]", "read_as_root", 0) + error_kind.with_error_location("[SendNotificationRef]", "read_as_root", 0) }) } } - /// The table `DumpResponse` in the namespace `FBS.WebRtcServer` + /// The table `Score` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/webRtcServer.fbs:20` + /// * Table `Score` in the file `../worker/fbs/producer.fbs:31` #[derive( Clone, Debug, @@ -63968,400 +66121,280 @@ mod root { ::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, + pub struct Score { + /// 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, } - impl DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for Score { + fn default() -> Self { + Self { + 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() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) + pub fn builder() -> ScoreBuilder<()> { + ScoreBuilder(()) } #[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]>, - >, + field_ssrc: impl ::planus::WriteAsDefault, + field_rid: impl ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + field_score: impl ::planus::WriteAsDefault, ) -> ::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 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<16> = + 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<[::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); + if prepared_ssrc.is_some() { + table_writer.write_entry::(0); + } + if prepared_rid.is_some() { + table_writer.write_entry::<::planus::Offset>(1); + } + if prepared_score.is_some() { + table_writer.write_entry::(2); + } 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); + 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 DumpResponse { + impl ::planus::WriteAs<::planus::Offset> for Score { type Prepared = ::planus::Offset; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for DumpResponse { + impl ::planus::WriteAsOffset for Score { #[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, - ) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Score::create(builder, self.ssrc, &self.rid, self.score) } } - /// Builder for serializing an instance of the [DumpResponse] type. + /// Builder for serializing an instance of the [Score] type. /// - /// Can be created using the [DumpResponse::builder] method. + /// Can be created using the [Score::builder] method. #[derive(Debug)] #[must_use] - pub struct DumpResponseBuilder(State); + pub struct ScoreBuilder(State); - impl DumpResponseBuilder<()> { - /// Setter for the [`id` field](DumpResponse#structfield.id). + impl ScoreBuilder<()> { + /// Setter for the [`ssrc` field](Score#structfield.ssrc). #[inline] #[allow(clippy::type_complexity)] - pub fn id(self, value: T0) -> DumpResponseBuilder<(T0,)> + pub fn ssrc(self, value: T0) -> ScoreBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset>, + T0: ::planus::WriteAsDefault, { - DumpResponseBuilder((value,)) + ScoreBuilder((value,)) } - } - impl DumpResponseBuilder<(T0,)> { - /// Setter for the [`udp_sockets` field](DumpResponse#structfield.udp_sockets). + /// Sets the [`ssrc` field](Score#structfield.ssrc) to the default value. #[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)) + pub fn ssrc_as_default(self) -> ScoreBuilder<(::planus::DefaultValue,)> { + self.ssrc(::planus::DefaultValue) } } - impl DumpResponseBuilder<(T0, T1)> { - /// Setter for the [`tcp_servers` field](DumpResponse#structfield.tcp_servers). + impl ScoreBuilder<(T0,)> { + /// Setter for the [`rid` field](Score#structfield.rid). #[inline] #[allow(clippy::type_complexity)] - pub fn tcp_servers(self, value: T2) -> DumpResponseBuilder<(T0, T1, T2)> + pub fn rid(self, value: T1) -> ScoreBuilder<(T0, T1)> where - T2: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, { - let (v0, v1) = self.0; - DumpResponseBuilder((v0, v1, value)) + let (v0,) = self.0; + ScoreBuilder((v0, value)) } - } - impl DumpResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`web_rtc_transport_ids` field](DumpResponse#structfield.web_rtc_transport_ids). + /// Sets the [`rid` field](Score#structfield.rid) to null. #[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)) + pub fn rid_as_null(self) -> ScoreBuilder<(T0, ())> { + self.rid(()) } } - impl DumpResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`local_ice_username_fragments` field](DumpResponse#structfield.local_ice_username_fragments). + impl ScoreBuilder<(T0, T1)> { + /// Setter for the [`score` field](Score#structfield.score). #[inline] #[allow(clippy::type_complexity)] - pub fn local_ice_username_fragments( - self, - value: T4, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4)> + pub fn score(self, value: T2) -> ScoreBuilder<(T0, T1, T2)> where - T4: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, + T2: ::planus::WriteAsDefault, { - let (v0, v1, v2, v3) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, value)) + let (v0, v1) = self.0; + ScoreBuilder((v0, v1, value)) } - } - impl DumpResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`tuple_hashes` field](DumpResponse#structfield.tuple_hashes). + /// Sets the [`score` field](Score#structfield.score) to the default value. #[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)) + pub fn score_as_default(self) -> ScoreBuilder<(T0, T1, ::planus::DefaultValue)> { + self.score(::planus::DefaultValue) } } - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. + impl ScoreBuilder<(T0, T1, T2)> { + /// 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 + pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + 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)> + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T2: ::planus::WriteAsDefault, + > ::planus::WriteAs<::planus::Offset> for ScoreBuilder<(T0, T1, T2)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + 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)> + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T2: ::planus::WriteAsDefault, + > ::planus::WriteAsOptional<::planus::Offset> + for ScoreBuilder<(T0, T1, T2)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::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)> + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T2: ::planus::WriteAsDefault, + > ::planus::WriteAsOffset for ScoreBuilder<(T0, T1, T2)> { #[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) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + let (v0, v1, v2) = &self.0; + Score::create(builder, v0, v1, v2) } } - /// Reference to a deserialized [DumpResponse]. + /// Reference to a deserialized [Score]. #[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") - } + pub struct ScoreRef<'a>(::planus::table_reader::Table<'a>); - /// Getter for the [`udp_sockets` field](DumpResponse#structfield.udp_sockets). + impl<'a> ScoreRef<'a> { + /// Getter for the [`ssrc` field](Score#structfield.ssrc). #[inline] - pub fn udp_sockets( - &self, - ) -> ::planus::Result<::planus::Vector<'a, ::planus::Result>>> - { - self.0.access_required(1, "DumpResponse", "udp_sockets") + pub fn ssrc(&self) -> ::planus::Result { + ::core::result::Result::Ok(self.0.access(0, "Score", "ssrc")?.unwrap_or(0)) } - /// Getter for the [`tcp_servers` field](DumpResponse#structfield.tcp_servers). + /// Getter for the [`rid` field](Score#structfield.rid). #[inline] - pub fn tcp_servers( + pub fn rid( &self, - ) -> ::planus::Result<::planus::Vector<'a, ::planus::Result>>> + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> { - 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") + self.0.access(1, "Score", "rid") } - /// Getter for the [`tuple_hashes` field](DumpResponse#structfield.tuple_hashes). + /// Getter for the [`score` field](Score#structfield.score). #[inline] - pub fn tuple_hashes( - &self, - ) -> ::planus::Result<::planus::Vector<'a, ::planus::Result>>> - { - self.0.access_required(5, "DumpResponse", "tuple_hashes") + pub fn score(&self) -> ::planus::Result { + ::core::result::Result::Ok(self.0.access(2, "Score", "score")?.unwrap_or(0)) } } - impl<'a> ::core::fmt::Debug for DumpResponseRef<'a> { + 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("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()); + let mut f = f.debug_struct("ScoreRef"); + 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 DumpResponse { + impl<'a> ::core::convert::TryFrom> for Score { 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()?, + fn try_from(value: ScoreRef<'a>) -> ::planus::Result { + ::core::result::Result::Ok(Self { + 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 DumpResponseRef<'a> { + impl<'a> ::planus::TableRead<'a> for ScoreRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -64373,7 +66406,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for ScoreRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -64383,7 +66416,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[DumpResponseRef]", + "[ScoreRef]", "get", buffer.offset_from_start, ) @@ -64391,8 +66424,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; + 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 { @@ -64401,7 +66434,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -64416,7 +66449,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for ScoreRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -64426,20 +66459,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) + error_kind.with_error_location("[ScoreRef]", "read_as_root", 0) }) } } - } - /// The namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * File `../worker/fbs/producer.fbs` - pub mod producer { - /// The table `EnableTraceEventRequest` in the namespace `FBS.Producer` + + /// The table `ScoreNotification` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/producer.fbs:6` + /// * Table `ScoreNotification` in the file `../worker/fbs/producer.fbs:37` #[derive( Clone, Debug, @@ -64451,190 +66479,220 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct EnableTraceEventRequest { - /// The field `events` in the table `EnableTraceEventRequest` - pub events: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + pub struct ScoreNotification { + /// The field `scores` in the table `ScoreNotification` + pub scores: ::core::option::Option<::planus::alloc::vec::Vec>, } - impl EnableTraceEventRequest { - /// Creates a [EnableTraceEventRequestBuilder] for serializing an instance of this table. + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for ScoreNotification { + fn default() -> Self { + Self { + scores: ::core::default::Default::default(), + } + } + } + + impl ScoreNotification { + /// Creates a [ScoreNotificationBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> EnableTraceEventRequestBuilder<()> { - EnableTraceEventRequestBuilder(()) + pub fn builder() -> ScoreNotificationBuilder<()> { + ScoreNotificationBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_events: impl ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + field_scores: impl ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, ) -> ::planus::Offset { - let prepared_events = field_events.prepare(builder); + 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); + if prepared_scores.is_some() { + table_writer + .write_entry::<::planus::Offset<[::planus::Offset]>>(0); + } unsafe { table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_events); + if let ::core::option::Option::Some(prepared_scores) = prepared_scores { + object_writer.write::<_, _, 4>(&prepared_scores); + } }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for EnableTraceEventRequest { + impl ::planus::WriteAs<::planus::Offset> for ScoreNotification { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> - for EnableTraceEventRequest - { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for EnableTraceEventRequest { + impl ::planus::WriteAsOffset for ScoreNotification { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - EnableTraceEventRequest::create(builder, &self.events) + ) -> ::planus::Offset { + ScoreNotification::create(builder, &self.scores) } } - /// Builder for serializing an instance of the [EnableTraceEventRequest] type. + /// Builder for serializing an instance of the [ScoreNotification] type. /// - /// Can be created using the [EnableTraceEventRequest::builder] method. + /// Can be created using the [ScoreNotification::builder] method. #[derive(Debug)] #[must_use] - pub struct EnableTraceEventRequestBuilder(State); + pub struct ScoreNotificationBuilder(State); - impl EnableTraceEventRequestBuilder<()> { - /// Setter for the [`events` field](EnableTraceEventRequest#structfield.events). + impl ScoreNotificationBuilder<()> { + /// Setter for the [`scores` field](ScoreNotification#structfield.scores). #[inline] #[allow(clippy::type_complexity)] - pub fn events(self, value: T0) -> EnableTraceEventRequestBuilder<(T0,)> + pub fn scores(self, value: T0) -> ScoreNotificationBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T0: ::planus::WriteAsOptional< + ::planus::Offset<[::planus::Offset]>, + >, { - EnableTraceEventRequestBuilder((value,)) + ScoreNotificationBuilder((value,)) + } + + /// Sets the [`scores` field](ScoreNotification#structfield.scores) to null. + #[inline] + #[allow(clippy::type_complexity)] + pub fn scores_as_null(self) -> ScoreNotificationBuilder<((),)> { + self.scores(()) } } - impl EnableTraceEventRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [EnableTraceEventRequest]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl]>>> - ::planus::WriteAs<::planus::Offset> - for EnableTraceEventRequestBuilder<(T0,)> + impl< + T0: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, + > ::planus::WriteAs<::planus::Offset> + for ScoreNotificationBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl]>>> - ::planus::WriteAsOptional<::planus::Offset> - for EnableTraceEventRequestBuilder<(T0,)> + impl< + T0: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, + > ::planus::WriteAsOptional<::planus::Offset> + for ScoreNotificationBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl]>>> - ::planus::WriteAsOffset - for EnableTraceEventRequestBuilder<(T0,)> + impl< + T0: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, + > ::planus::WriteAsOffset for ScoreNotificationBuilder<(T0,)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { let (v0,) = &self.0; - EnableTraceEventRequest::create(builder, v0) + ScoreNotification::create(builder, v0) } } - /// Reference to a deserialized [EnableTraceEventRequest]. + /// Reference to a deserialized [ScoreNotification]. #[derive(Copy, Clone)] - pub struct EnableTraceEventRequestRef<'a>(::planus::table_reader::Table<'a>); + pub struct ScoreNotificationRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> EnableTraceEventRequestRef<'a> { - /// Getter for the [`events` field](EnableTraceEventRequest#structfield.events). + impl<'a> ScoreNotificationRef<'a> { + /// Getter for the [`scores` field](ScoreNotification#structfield.scores). #[inline] - pub fn events( + pub fn scores( &self, ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + ::core::option::Option< + ::planus::Vector<'a, ::planus::Result>>, + >, > { - self.0 - .access_required(0, "EnableTraceEventRequest", "events") + self.0.access(0, "ScoreNotification", "scores") } } - impl<'a> ::core::fmt::Debug for EnableTraceEventRequestRef<'a> { + 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("EnableTraceEventRequestRef"); - f.field("events", &self.events()); + let mut f = f.debug_struct("ScoreNotificationRef"); + if let ::core::option::Option::Some(field_scores) = self.scores().transpose() { + f.field("scores", &field_scores); + } f.finish() } } - impl<'a> ::core::convert::TryFrom> for EnableTraceEventRequest { + impl<'a> ::core::convert::TryFrom> for ScoreNotification { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: EnableTraceEventRequestRef<'a>) -> ::planus::Result { + fn try_from(value: ScoreNotificationRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - events: value.events()?.to_vec_result()?, + scores: if let ::core::option::Option::Some(scores) = value.scores()? { + ::core::option::Option::Some(scores.to_vec_result()?) + } else { + ::core::option::Option::None + }, }) } } - impl<'a> ::planus::TableRead<'a> for EnableTraceEventRequestRef<'a> { + impl<'a> ::planus::TableRead<'a> for ScoreNotificationRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -64646,7 +66704,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for EnableTraceEventRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for ScoreNotificationRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -64656,7 +66714,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[EnableTraceEventRequestRef]", + "[ScoreNotificationRef]", "get", buffer.offset_from_start, ) @@ -64664,8 +66722,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for EnableTraceEventRequest { - type Value = ::planus::Offset; + 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 { @@ -64674,7 +66732,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -64689,7 +66747,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for EnableTraceEventRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for ScoreNotificationRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -64699,119 +66757,88 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location( - "[EnableTraceEventRequestRef]", - "read_as_root", - 0, - ) + error_kind.with_error_location("[ScoreNotificationRef]", "read_as_root", 0) }) } } - /// The table `DumpResponse` in the namespace `FBS.Producer` + /// The table `VideoOrientationChangeNotification` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/producer.fbs:10` + /// * Table `VideoOrientationChangeNotification` in the file `../worker/fbs/producer.fbs:41` #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + 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 `kind` in the table `DumpResponse` - pub kind: super::rtp_parameters::MediaKind, - /// The field `type` in the table `DumpResponse` - pub type_: ::planus::alloc::string::String, - /// 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: - ::core::option::Option<::planus::alloc::vec::Vec>, - /// The field `trace_event_types` in the table `DumpResponse` - pub trace_event_types: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, - /// The field `paused` in the table `DumpResponse` - pub paused: bool, + 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, } - impl DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. + #[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() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) + pub fn builder() -> VideoOrientationChangeNotificationBuilder<()> { + VideoOrientationChangeNotificationBuilder(()) } #[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::WriteAs<::planus::Offset>, - field_rtp_parameters: impl ::planus::WriteAs< - ::planus::Offset, - >, - field_rtp_mapping: impl ::planus::WriteAs< - ::planus::Offset, - >, - field_rtp_streams: impl ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - field_trace_event_types: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - field_paused: impl ::planus::WriteAsDefault, + field_camera: impl ::planus::WriteAsDefault, + field_flip: impl ::planus::WriteAsDefault, + field_rotation: impl ::planus::WriteAsDefault, ) -> ::planus::Offset { - let prepared_id = field_id.prepare(builder); - let prepared_kind = - field_kind.prepare(builder, &super::rtp_parameters::MediaKind::All); - let prepared_type_ = field_type_.prepare(builder); - 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 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<20> = + 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::<::planus::Offset>(3); - table_writer - .write_entry::<::planus::Offset>(4); - if prepared_rtp_streams.is_some() { - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(5); + if prepared_rotation.is_some() { + table_writer.write_entry::(2); } - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(6); - if prepared_kind.is_some() { - table_writer.write_entry::(1); + if prepared_camera.is_some() { + table_writer.write_entry::(0); } - if prepared_paused.is_some() { - table_writer.write_entry::(7); + if prepared_flip.is_some() { + table_writer.write_entry::(1); } unsafe { table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_id); - object_writer.write::<_, _, 4>(&prepared_type_); - object_writer.write::<_, _, 4>(&prepared_rtp_parameters); - object_writer.write::<_, _, 4>(&prepared_rtp_mapping); - if let ::core::option::Option::Some(prepared_rtp_streams) = - prepared_rtp_streams + if let ::core::option::Option::Some(prepared_rotation) = + prepared_rotation { - object_writer.write::<_, _, 4>(&prepared_rtp_streams); + object_writer.write::<_, _, 2>(&prepared_rotation); } - 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_camera) = prepared_camera { + object_writer.write::<_, _, 1>(&prepared_camera); } - if let ::core::option::Option::Some(prepared_paused) = prepared_paused { - object_writer.write::<_, _, 1>(&prepared_paused); + if let ::core::option::Option::Some(prepared_flip) = prepared_flip { + object_writer.write::<_, _, 1>(&prepared_flip); } }); } @@ -64819,418 +66846,270 @@ mod root { } } - impl ::planus::WriteAs<::planus::Offset> for DumpResponse { + impl ::planus::WriteAs<::planus::Offset> + for VideoOrientationChangeNotification + { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { + 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<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for DumpResponse { + impl ::planus::WriteAsOffset + for VideoOrientationChangeNotification + { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DumpResponse::create( + ) -> ::planus::Offset { + VideoOrientationChangeNotification::create( builder, - &self.id, - self.kind, - &self.type_, - &self.rtp_parameters, - &self.rtp_mapping, - &self.rtp_streams, - &self.trace_event_types, - self.paused, + self.camera, + self.flip, + self.rotation, ) } } - /// Builder for serializing an instance of the [DumpResponse] type. + /// Builder for serializing an instance of the [VideoOrientationChangeNotification] type. /// - /// Can be created using the [DumpResponse::builder] method. + /// Can be created using the [VideoOrientationChangeNotification::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::WriteAs<::planus::Offset>, - { - let (v0, v1) = self.0; - DumpResponseBuilder((v0, v1, value)) - } - } + pub struct VideoOrientationChangeNotificationBuilder(State); - impl DumpResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`rtp_parameters` field](DumpResponse#structfield.rtp_parameters). + impl VideoOrientationChangeNotificationBuilder<()> { + /// Setter for the [`camera` field](VideoOrientationChangeNotification#structfield.camera). #[inline] #[allow(clippy::type_complexity)] - pub fn rtp_parameters(self, value: T3) -> DumpResponseBuilder<(T0, T1, T2, T3)> + pub fn camera( + self, + value: T0, + ) -> VideoOrientationChangeNotificationBuilder<(T0,)> where - T3: ::planus::WriteAs<::planus::Offset>, + T0: ::planus::WriteAsDefault, { - let (v0, v1, v2) = self.0; - DumpResponseBuilder((v0, v1, v2, value)) + VideoOrientationChangeNotificationBuilder((value,)) } - } - impl DumpResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`rtp_mapping` field](DumpResponse#structfield.rtp_mapping). + /// Sets the [`camera` field](VideoOrientationChangeNotification#structfield.camera) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn rtp_mapping(self, value: T4) -> DumpResponseBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAs<::planus::Offset>, + pub fn camera_as_default( + self, + ) -> VideoOrientationChangeNotificationBuilder<(::planus::DefaultValue,)> { - let (v0, v1, v2, v3) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, value)) + self.camera(::planus::DefaultValue) } } - impl DumpResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`rtp_streams` field](DumpResponse#structfield.rtp_streams). + impl VideoOrientationChangeNotificationBuilder<(T0,)> { + /// Setter for the [`flip` field](VideoOrientationChangeNotification#structfield.flip). #[inline] #[allow(clippy::type_complexity)] - pub fn rtp_streams( + pub fn flip( self, - value: T5, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> + value: T1, + ) -> VideoOrientationChangeNotificationBuilder<(T0, T1)> where - T5: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, + T1: ::planus::WriteAsDefault, { - let (v0, v1, v2, v3, v4) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`rtp_streams` field](DumpResponse#structfield.rtp_streams) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_streams_as_null(self) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, ())> { - self.rtp_streams(()) + let (v0,) = self.0; + VideoOrientationChangeNotificationBuilder((v0, value)) } - } - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`trace_event_types` field](DumpResponse#structfield.trace_event_types). + /// Sets the [`flip` field](VideoOrientationChangeNotification#structfield.flip) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn trace_event_types( + pub fn flip_as_default( self, - value: T6, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + ) -> VideoOrientationChangeNotificationBuilder<(T0, ::planus::DefaultValue)> { - let (v0, v1, v2, v3, v4, v5) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, v5, value)) + self.flip(::planus::DefaultValue) } } - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`paused` field](DumpResponse#structfield.paused). + impl VideoOrientationChangeNotificationBuilder<(T0, T1)> { + /// Setter for the [`rotation` field](VideoOrientationChangeNotification#structfield.rotation). #[inline] #[allow(clippy::type_complexity)] - pub fn paused( + pub fn rotation( self, - value: T7, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + value: T2, + ) -> VideoOrientationChangeNotificationBuilder<(T0, T1, T2)> where - T7: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault, { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - DumpResponseBuilder((v0, v1, v2, v3, v4, v5, v6, value)) + let (v0, v1) = self.0; + VideoOrientationChangeNotificationBuilder((v0, v1, value)) } - /// Sets the [`paused` field](DumpResponse#structfield.paused) to the default value. + /// Sets the [`rotation` field](VideoOrientationChangeNotification#structfield.rotation) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn paused_as_default( + pub fn rotation_as_default( self, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, ::planus::DefaultValue)> + ) -> VideoOrientationChangeNotificationBuilder<(T0, T1, ::planus::DefaultValue)> { - self.paused(::planus::DefaultValue) + self.rotation(::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]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + 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::WriteAs<::planus::Offset>, - T5: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault, + > + ::planus::WriteAs<::planus::Offset> + for VideoOrientationChangeNotificationBuilder<(T0, T1, T2)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::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::WriteAs<::planus::Offset>, - T5: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault, + > + ::planus::WriteAsOptional<::planus::Offset> + for VideoOrientationChangeNotificationBuilder<(T0, T1, T2)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::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::WriteAs<::planus::Offset>, - T5: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + 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, v3, v4, v5, v6, v7) = &self.0; - DumpResponse::create(builder, v0, v1, v2, v3, v4, v5, v6, v7) + ) -> ::planus::Offset { + let (v0, v1, v2) = &self.0; + VideoOrientationChangeNotification::create(builder, v0, v1, v2) } } - /// Reference to a deserialized [DumpResponse]. + /// Reference to a deserialized [VideoOrientationChangeNotification]. #[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") - } + pub struct VideoOrientationChangeNotificationRef<'a>(::planus::table_reader::Table<'a>); - /// Getter for the [`kind` field](DumpResponse#structfield.kind). + impl<'a> VideoOrientationChangeNotificationRef<'a> { + /// Getter for the [`camera` field](VideoOrientationChangeNotification#structfield.camera). #[inline] - pub fn kind(&self) -> ::planus::Result { + pub fn camera(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 - .access(1, "DumpResponse", "kind")? - .unwrap_or(super::rtp_parameters::MediaKind::All), + .access(0, "VideoOrientationChangeNotification", "camera")? + .unwrap_or(false), ) } - /// Getter for the [`type` field](DumpResponse#structfield.type_). - #[inline] - pub fn type_(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(2, "DumpResponse", "type_") - } - - /// 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< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, - > { - self.0.access(5, "DumpResponse", "rtp_streams") - } - - /// Getter for the [`trace_event_types` field](DumpResponse#structfield.trace_event_types). + /// Getter for the [`flip` field](VideoOrientationChangeNotification#structfield.flip). #[inline] - pub fn trace_event_types( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, - > { - self.0 - .access_required(6, "DumpResponse", "trace_event_types") + pub fn flip(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "VideoOrientationChangeNotification", "flip")? + .unwrap_or(false), + ) } - /// Getter for the [`paused` field](DumpResponse#structfield.paused). + /// Getter for the [`rotation` field](VideoOrientationChangeNotification#structfield.rotation). #[inline] - pub fn paused(&self) -> ::planus::Result { + pub fn rotation(&self) -> ::planus::Result { ::core::result::Result::Ok( - self.0.access(7, "DumpResponse", "paused")?.unwrap_or(false), + self.0 + .access(2, "VideoOrientationChangeNotification", "rotation")? + .unwrap_or(0), ) } } - impl<'a> ::core::fmt::Debug for DumpResponseRef<'a> { + 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("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()); - if let ::core::option::Option::Some(field_rtp_streams) = - self.rtp_streams().transpose() - { - f.field("rtp_streams", &field_rtp_streams); - } - f.field("trace_event_types", &self.trace_event_types()); - f.field("paused", &self.paused()); + 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 DumpResponse { + impl<'a> ::core::convert::TryFrom> + for VideoOrientationChangeNotification + { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { + fn try_from( + value: VideoOrientationChangeNotificationRef<'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: if let ::core::option::Option::Some(rtp_streams) = - value.rtp_streams()? - { - ::core::option::Option::Some(rtp_streams.to_vec_result()?) - } else { - ::core::option::Option::None - }, - trace_event_types: value.trace_event_types()?.to_vec_result()?, - paused: ::core::convert::TryInto::try_into(value.paused()?)?, + 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 DumpResponseRef<'a> { + impl<'a> ::planus::TableRead<'a> for VideoOrientationChangeNotificationRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -65242,7 +67121,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for VideoOrientationChangeNotificationRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -65252,7 +67131,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[DumpResponseRef]", + "[VideoOrientationChangeNotificationRef]", "get", buffer.offset_from_start, ) @@ -65260,8 +67139,10 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; + 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 { @@ -65270,7 +67151,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -65285,7 +67166,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for VideoOrientationChangeNotificationRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -65295,311 +67176,372 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) + error_kind.with_error_location( + "[VideoOrientationChangeNotificationRef]", + "read_as_root", + 0, + ) }) } } - /// The table `GetStatsResponse` in the namespace `FBS.Producer` + /// The enum `TraceType` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/producer.fbs:21` + /// * Enum `TraceType` in the file `../worker/fbs/producer.fbs:47` #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + ::serde::Serialize, + ::serde::Deserialize, )] - pub struct GetStatsResponse { - /// The field `stats` in the table `GetStatsResponse` - pub stats: - ::core::option::Option<::planus::alloc::vec::Vec>, + #[repr(u8)] + pub enum TraceType { + /// The variant `KEYFRAME` in the enum `TraceType` + Keyframe = 0, + + /// The variant `FIR` in the enum `TraceType` + Fir = 1, + + /// The variant `NACK` in the enum `TraceType` + Nack = 2, + + /// The variant `PLI` in the enum `TraceType` + Pli = 3, + + /// The variant `RTP` in the enum `TraceType` + Rtp = 4, } - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for GetStatsResponse { - fn default() -> Self { - Self { - stats: ::core::default::Default::default(), + impl TraceType { + /// Array containing all valid variants of TraceType + pub const ENUM_VALUES: [Self; 5] = + [Self::Keyframe, Self::Fir, Self::Nack, Self::Pli, Self::Rtp]; + } + + impl ::core::convert::TryFrom for TraceType { + 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(TraceType::Keyframe), + 1 => ::core::result::Result::Ok(TraceType::Fir), + 2 => ::core::result::Result::Ok(TraceType::Nack), + 3 => ::core::result::Result::Ok(TraceType::Pli), + 4 => ::core::result::Result::Ok(TraceType::Rtp), + + _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { + tag: value as i128, + }), } } } - impl GetStatsResponse { - /// Creates a [GetStatsResponseBuilder] for serializing an instance of this table. + impl ::core::convert::From for u8 { #[inline] - pub fn builder() -> GetStatsResponseBuilder<()> { - GetStatsResponseBuilder(()) + fn from(value: TraceType) -> Self { + value as u8 } + } - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_stats: impl ::planus::WriteAsOptional< - ::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(); - if prepared_stats.is_some() { - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(0); - } + impl ::planus::Primitive for TraceType { + const ALIGNMENT: usize = 1; + const SIZE: usize = 1; + } - unsafe { - table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_stats) = prepared_stats { - object_writer.write::<_, _, 4>(&prepared_stats); - } - }); - } - builder.current_offset() + impl ::planus::WriteAsPrimitive for TraceType { + #[inline] + fn write( + &self, + cursor: ::planus::Cursor<'_, N>, + buffer_position: u32, + ) { + (*self as u8).write(cursor, buffer_position); } } - impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; + impl ::planus::WriteAs for TraceType { + type Prepared = Self; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + fn prepare(&self, _builder: &mut ::planus::Builder) -> TraceType { + *self } } - impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; + impl ::planus::WriteAsDefault for TraceType { + type Prepared = Self; #[inline] fn prepare( &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + _builder: &mut ::planus::Builder, + default: &TraceType, + ) -> ::core::option::Option { + if self == default { + ::core::option::Option::None + } else { + ::core::option::Option::Some(*self) + } } } - impl ::planus::WriteAsOffset for GetStatsResponse { + impl ::planus::WriteAsOptional for TraceType { + type Prepared = Self; + #[inline] fn prepare( &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - GetStatsResponse::create(builder, &self.stats) + _builder: &mut ::planus::Builder, + ) -> ::core::option::Option { + ::core::option::Option::Some(*self) } } - /// 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<'buf> ::planus::TableRead<'buf> for TraceType { + #[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 GetStatsResponseBuilder<()> { - /// Setter for the [`stats` field](GetStatsResponse#structfield.stats). + impl<'buf> ::planus::VectorReadInner<'buf> for TraceType { + type Error = ::planus::errors::UnknownEnumTag; + const STRIDE: usize = 1; #[inline] - #[allow(clippy::type_complexity)] - pub fn stats(self, value: T0) -> GetStatsResponseBuilder<(T0,)> - where - T0: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, + unsafe fn from_buffer( + buffer: ::planus::SliceWithStartOffset<'buf>, + offset: usize, + ) -> ::core::result::Result { - GetStatsResponseBuilder((value,)) + 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( + "TraceType", + "VectorRead::from_buffer", + buffer.offset_from_start, + ) + }) } + } + + impl ::planus::VectorWrite for TraceType { + const STRIDE: usize = 1; + + type Value = Self; - /// Sets the [`stats` field](GetStatsResponse#structfield.stats) to null. #[inline] - #[allow(clippy::type_complexity)] - pub fn stats_as_null(self) -> GetStatsResponseBuilder<((),)> { - self.stats(()) + fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { + *self } - } - 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) + 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, + ); + } } } - impl< - T0: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAs<::planus::Offset> - for GetStatsResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; + /// The enum `TraceDirection` in the namespace `FBS.Producer` + /// + /// Generated from these locations: + /// * Enum `TraceDirection` in the file `../worker/fbs/producer.fbs:49` + #[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 prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + fn from(value: TraceDirection) -> Self { + value as u8 } } - impl< - T0: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOptional<::planus::Offset> - for GetStatsResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; + impl ::planus::Primitive for TraceDirection { + const ALIGNMENT: usize = 1; + const SIZE: usize = 1; + } + impl ::planus::WriteAsPrimitive for TraceDirection { #[inline] - fn prepare( + fn write( &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + cursor: ::planus::Cursor<'_, N>, + buffer_position: u32, + ) { + (*self as u8).write(cursor, buffer_position); } } - impl< - T0: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, - > ::planus::WriteAsOffset for GetStatsResponseBuilder<(T0,)> - { + impl ::planus::WriteAs for TraceDirection { + type Prepared = Self; + #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - GetStatsResponse::create(builder, v0) + fn prepare(&self, _builder: &mut ::planus::Builder) -> TraceDirection { + *self } } - /// Reference to a deserialized [GetStatsResponse]. - #[derive(Copy, Clone)] - pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); + impl ::planus::WriteAsDefault for TraceDirection { + type Prepared = Self; - impl<'a> GetStatsResponseRef<'a> { - /// Getter for the [`stats` field](GetStatsResponse#structfield.stats). #[inline] - pub fn stats( + fn prepare( &self, - ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, - > { - self.0.access(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"); - if let ::core::option::Option::Some(field_stats) = self.stats().transpose() { - f.field("stats", &field_stats); + _builder: &mut ::planus::Builder, + default: &TraceDirection, + ) -> ::core::option::Option { + if self == default { + ::core::option::Option::None + } else { + ::core::option::Option::Some(*self) } - f.finish() } } - impl<'a> ::core::convert::TryFrom> for GetStatsResponse { - type Error = ::planus::Error; + impl ::planus::WriteAsOptional for TraceDirection { + type Prepared = Self; - #[allow(unreachable_code)] - fn try_from(value: GetStatsResponseRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - stats: if let ::core::option::Option::Some(stats) = value.stats()? { - ::core::option::Option::Some(stats.to_vec_result()?) - } else { - ::core::option::Option::None - }, - }) + #[inline] + fn prepare( + &self, + _builder: &mut ::planus::Builder, + ) -> ::core::option::Option { + ::core::option::Option::Some(*self) } } - impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { + impl<'buf> ::planus::TableRead<'buf> for TraceDirection { #[inline] fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, + buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) + let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; + ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) } } - impl<'a> ::planus::VectorReadInner<'a> for GetStatsResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - + impl<'buf> ::planus::VectorReadInner<'buf> for TraceDirection { + type Error = ::planus::errors::UnknownEnumTag; + const STRIDE: usize = 1; + #[inline] unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, + buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { + ) -> ::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( - "[GetStatsResponseRef]", - "get", + "TraceDirection", + "VectorRead::from_buffer", buffer.offset_from_start, ) }) } } - impl ::planus::VectorWrite<::planus::Offset> for GetStatsResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; + impl ::planus::VectorWrite for TraceDirection { + const STRIDE: usize = 1; + + type Value = Self; + #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) + fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { + *self } #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[Self], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; + 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 - (Self::STRIDE * i) as u32, + buffer_position - 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` + /// The union `TraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `SendNotification` in the file `../worker/fbs/producer.fbs:25` + /// * Union `TraceInfo` in the file `../worker/fbs/producer.fbs:51` #[derive( Clone, Debug, @@ -65611,253 +67553,327 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct SendNotification { - /// The field `data` in the table `SendNotification` - pub data: ::planus::alloc::vec::Vec, + 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 SendNotification { - /// Creates a [SendNotificationBuilder] for serializing an instance of this table. + impl TraceInfo { + /// Creates a [TraceInfoBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> SendNotificationBuilder<()> { - SendNotificationBuilder(()) + pub fn builder() -> TraceInfoBuilder<::planus::Uninitialized> { + TraceInfoBuilder(::planus::Uninitialized) } - #[allow(clippy::too_many_arguments)] - pub fn create( + #[inline] + pub fn create_key_frame_trace_info( 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); + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + } - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_data); - }); - } - builder.current_offset() + #[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()) } - } - impl ::planus::WriteAs<::planus::Offset> for SendNotification { - type Prepared = ::planus::Offset; + #[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] - fn prepare( - &self, + pub fn create_rtp_trace_info( builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) } } - impl ::planus::WriteAsOptional<::planus::Offset> for SendNotification { - type Prepared = ::planus::Offset; - + impl ::planus::WriteAsUnion for TraceInfo { #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + 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::WriteAsOffset for SendNotification { + impl ::planus::WriteAsOptionalUnion for TraceInfo { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SendNotification::create(builder, &self.data) + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - /// Builder for serializing an instance of the [SendNotification] type. + /// Builder for serializing an instance of the [TraceInfo] type. /// - /// Can be created using the [SendNotification::builder] method. + /// Can be created using the [TraceInfo::builder] method. #[derive(Debug)] #[must_use] - pub struct SendNotificationBuilder(State); + pub struct TraceInfoBuilder(T); - impl SendNotificationBuilder<()> { - /// Setter for the [`data` field](SendNotification#structfield.data). + impl TraceInfoBuilder<::planus::Uninitialized> { + /// Creates an instance of the [`KeyFrameTraceInfo` variant](TraceInfo#variant.KeyFrameTraceInfo). #[inline] - #[allow(clippy::type_complexity)] - pub fn data(self, value: T0) -> SendNotificationBuilder<(T0,)> + pub fn key_frame_trace_info( + self, + value: T, + ) -> TraceInfoBuilder<::planus::Initialized<1, T>> where - T0: ::planus::WriteAs<::planus::Offset<[u8]>>, + T: ::planus::WriteAsOffset, { - SendNotificationBuilder((value,)) + 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 SendNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SendNotification]. + 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::Offset + ) -> ::planus::UnionOffset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsUnion, { - ::planus::WriteAsOffset::prepare(&self, builder) + ::planus::WriteAsUnion::prepare(&self, builder) } } - impl>> - ::planus::WriteAs<::planus::Offset> - for SendNotificationBuilder<(T0,)> + impl ::planus::WriteAsUnion for TraceInfoBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, { - type Prepared = ::planus::Offset; - #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) } } - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for SendNotificationBuilder<(T0,)> + impl ::planus::WriteAsOptionalUnion for TraceInfoBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, { - type Prepared = ::planus::Offset; - #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - - impl>> - ::planus::WriteAsOffset for SendNotificationBuilder<(T0,)> + impl ::planus::WriteAsUnion for TraceInfoBuilder<::planus::Initialized<2, T>> + where + T: ::planus::WriteAsOffset, { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - SendNotification::create(builder, v0) + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) } } - /// 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). + impl ::planus::WriteAsOptionalUnion for TraceInfoBuilder<::planus::Initialized<2, T>> + where + T: ::planus::WriteAsOffset, + { #[inline] - pub fn data(&self) -> ::planus::Result<&'a [u8]> { - self.0.access_required(0, "SendNotification", "data") + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - - 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 ::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<'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 ::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<'a> ::planus::TableRead<'a> for SendNotificationRef<'a> { + impl ::planus::WriteAsOptionalUnion for TraceInfoBuilder<::planus::Initialized<4, T>> + where + T: ::planus::WriteAsOffset, + { #[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, - )?)) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - impl<'a> ::planus::VectorReadInner<'a> for SendNotificationRef<'a> { + /// 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; - 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, - ) - }) - } - } + 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)?, + )) + } - 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) - } + TraceInfoRef::FirTraceInfo(value) => { + Self::FirTraceInfo(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } - #[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, - ); - } + 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::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) - }) + 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 `Score` in the namespace `FBS.Producer` + /// The table `KeyFrameTraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `Score` in the file `../worker/fbs/producer.fbs:31` + /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/producer.fbs:58` #[derive( Clone, Debug, @@ -65869,66 +67885,42 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct Score { - /// 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, + pub struct KeyFrameTraceInfo { + /// The field `is_rtx` in the table `KeyFrameTraceInfo` + pub is_rtx: bool, } #[allow(clippy::derivable_impls)] - impl ::core::default::Default for Score { + impl ::core::default::Default for KeyFrameTraceInfo { fn default() -> Self { - Self { - ssrc: 0, - rid: ::core::default::Default::default(), - score: 0, - } + Self { is_rtx: false } } } - impl Score { - /// Creates a [ScoreBuilder] for serializing an instance of this table. + impl KeyFrameTraceInfo { + /// Creates a [KeyFrameTraceInfoBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> ScoreBuilder<()> { - ScoreBuilder(()) + pub fn builder() -> KeyFrameTraceInfoBuilder<()> { + KeyFrameTraceInfoBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_ssrc: impl ::planus::WriteAsDefault, - field_rid: impl ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - field_score: impl ::planus::WriteAsDefault, + field_is_rtx: impl ::planus::WriteAsDefault, ) -> ::planus::Offset { - let prepared_ssrc = field_ssrc.prepare(builder, &0); - let prepared_rid = field_rid.prepare(builder); - let prepared_score = field_score.prepare(builder, &0); + let prepared_is_rtx = field_is_rtx.prepare(builder, &false); - let mut table_writer: ::planus::table_writer::TableWriter<10> = + let mut table_writer: ::planus::table_writer::TableWriter<6> = ::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_score.is_some() { - table_writer.write_entry::(2); + if prepared_is_rtx.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); - } - 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); + if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { + object_writer.write::<_, _, 1>(&prepared_is_rtx); } }); } @@ -65936,213 +67928,161 @@ mod root { } } - impl ::planus::WriteAs<::planus::Offset> for Score { + impl ::planus::WriteAs<::planus::Offset> for KeyFrameTraceInfo { type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for Score { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for Score { + impl ::planus::WriteAsOffset for KeyFrameTraceInfo { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Score::create(builder, self.ssrc, &self.rid, self.score) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + KeyFrameTraceInfo::create(builder, self.is_rtx) } } - /// Builder for serializing an instance of the [Score] type. + /// Builder for serializing an instance of the [KeyFrameTraceInfo] type. /// - /// Can be created using the [Score::builder] method. + /// Can be created using the [KeyFrameTraceInfo::builder] method. #[derive(Debug)] #[must_use] - pub struct ScoreBuilder(State); - - impl ScoreBuilder<()> { - /// Setter for the [`ssrc` field](Score#structfield.ssrc). - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc(self, value: T0) -> ScoreBuilder<(T0,)> - where - T0: ::planus::WriteAsDefault, - { - ScoreBuilder((value,)) - } - - /// Sets the [`ssrc` field](Score#structfield.ssrc) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn ssrc_as_default(self) -> ScoreBuilder<(::planus::DefaultValue,)> { - self.ssrc(::planus::DefaultValue) - } - } - - impl ScoreBuilder<(T0,)> { - /// Setter for the [`rid` field](Score#structfield.rid). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid(self, value: T1) -> ScoreBuilder<(T0, T1)> - where - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0,) = self.0; - ScoreBuilder((v0, value)) - } - - /// Sets the [`rid` field](Score#structfield.rid) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rid_as_null(self) -> ScoreBuilder<(T0, ())> { - self.rid(()) - } - } + pub struct KeyFrameTraceInfoBuilder(State); - impl ScoreBuilder<(T0, T1)> { - /// Setter for the [`score` field](Score#structfield.score). + impl KeyFrameTraceInfoBuilder<()> { + /// Setter for the [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx). #[inline] #[allow(clippy::type_complexity)] - pub fn score(self, value: T2) -> ScoreBuilder<(T0, T1, T2)> + pub fn is_rtx(self, value: T0) -> KeyFrameTraceInfoBuilder<(T0,)> where - T2: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, { - let (v0, v1) = self.0; - ScoreBuilder((v0, v1, value)) + KeyFrameTraceInfoBuilder((value,)) } - /// Sets the [`score` field](Score#structfield.score) to the default value. + /// Sets the [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn score_as_default(self) -> ScoreBuilder<(T0, T1, ::planus::DefaultValue)> { - self.score(::planus::DefaultValue) + pub fn is_rtx_as_default( + self, + ) -> KeyFrameTraceInfoBuilder<(::planus::DefaultValue,)> { + self.is_rtx(::planus::DefaultValue) } } - impl ScoreBuilder<(T0, T1, T2)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Score]. + impl KeyFrameTraceInfoBuilder<(T0,)> { + /// 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 + pub fn finish( + self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T2: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> for ScoreBuilder<(T0, T1, T2)> + impl> + ::planus::WriteAs<::planus::Offset> + for KeyFrameTraceInfoBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + 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>>, - T2: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for ScoreBuilder<(T0, T1, T2)> + impl> + ::planus::WriteAsOptional<::planus::Offset> + for KeyFrameTraceInfoBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::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>>, - T2: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset for ScoreBuilder<(T0, T1, T2)> + impl> + ::planus::WriteAsOffset for KeyFrameTraceInfoBuilder<(T0,)> { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0, v1, v2) = &self.0; - Score::create(builder, v0, v1, v2) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + let (v0,) = &self.0; + KeyFrameTraceInfo::create(builder, v0) } } - /// Reference to a deserialized [Score]. + /// Reference to a deserialized [KeyFrameTraceInfo]. #[derive(Copy, Clone)] - pub struct ScoreRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> ScoreRef<'a> { - /// Getter for the [`ssrc` field](Score#structfield.ssrc). - #[inline] - pub fn ssrc(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(0, "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(1, "Score", "rid") - } + pub struct KeyFrameTraceInfoRef<'a>(::planus::table_reader::Table<'a>); - /// Getter for the [`score` field](Score#structfield.score). + impl<'a> KeyFrameTraceInfoRef<'a> { + /// Getter for the [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx). #[inline] - pub fn score(&self) -> ::planus::Result { - ::core::result::Result::Ok(self.0.access(2, "Score", "score")?.unwrap_or(0)) + pub fn is_rtx(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "KeyFrameTraceInfo", "is_rtx")? + .unwrap_or(false), + ) } } - impl<'a> ::core::fmt::Debug for ScoreRef<'a> { + 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("ScoreRef"); - 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()); + let mut f = f.debug_struct("KeyFrameTraceInfoRef"); + f.field("is_rtx", &self.is_rtx()); f.finish() } } - impl<'a> ::core::convert::TryFrom> for Score { + impl<'a> ::core::convert::TryFrom> for KeyFrameTraceInfo { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: ScoreRef<'a>) -> ::planus::Result { + fn try_from(value: KeyFrameTraceInfoRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - 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()?)?, + is_rtx: ::core::convert::TryInto::try_into(value.is_rtx()?)?, }) } } - impl<'a> ::planus::TableRead<'a> for ScoreRef<'a> { + impl<'a> ::planus::TableRead<'a> for KeyFrameTraceInfoRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -66154,7 +68094,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for ScoreRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for KeyFrameTraceInfoRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -66164,7 +68104,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[ScoreRef]", + "[KeyFrameTraceInfoRef]", "get", buffer.offset_from_start, ) @@ -66172,8 +68112,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for Score { - type Value = ::planus::Offset; + 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 { @@ -66182,7 +68122,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -66197,7 +68137,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for ScoreRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for KeyFrameTraceInfoRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -66207,15 +68147,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[ScoreRef]", "read_as_root", 0) + error_kind.with_error_location("[KeyFrameTraceInfoRef]", "read_as_root", 0) }) } } - /// The table `ScoreNotification` in the namespace `FBS.Producer` + /// The table `FirTraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `ScoreNotification` in the file `../worker/fbs/producer.fbs:37` + /// * Table `FirTraceInfo` in the file `../worker/fbs/producer.fbs:62` #[derive( Clone, Debug, @@ -66227,47 +68167,42 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct ScoreNotification { - /// The field `scores` in the table `ScoreNotification` - pub scores: ::core::option::Option<::planus::alloc::vec::Vec>, + pub struct FirTraceInfo { + /// The field `ssrc` in the table `FirTraceInfo` + pub ssrc: u32, } #[allow(clippy::derivable_impls)] - impl ::core::default::Default for ScoreNotification { + impl ::core::default::Default for FirTraceInfo { fn default() -> Self { - Self { - scores: ::core::default::Default::default(), - } + Self { ssrc: 0 } } } - impl ScoreNotification { - /// Creates a [ScoreNotificationBuilder] for serializing an instance of this table. + impl FirTraceInfo { + /// Creates a [FirTraceInfoBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> ScoreNotificationBuilder<()> { - ScoreNotificationBuilder(()) + pub fn builder() -> FirTraceInfoBuilder<()> { + FirTraceInfoBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_scores: impl ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, + field_ssrc: impl ::planus::WriteAsDefault, ) -> ::planus::Offset { - let prepared_scores = field_scores.prepare(builder); + let prepared_ssrc = field_ssrc.prepare(builder, &0); let mut table_writer: ::planus::table_writer::TableWriter<6> = ::core::default::Default::default(); - if prepared_scores.is_some() { - table_writer - .write_entry::<::planus::Offset<[::planus::Offset]>>(0); + if prepared_ssrc.is_some() { + table_writer.write_entry::(0); } unsafe { table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_scores) = prepared_scores { - object_writer.write::<_, _, 4>(&prepared_scores); + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + object_writer.write::<_, _, 4>(&prepared_ssrc); } }); } @@ -66275,172 +68210,156 @@ mod root { } } - impl ::planus::WriteAs<::planus::Offset> for ScoreNotification { + impl ::planus::WriteAs<::planus::Offset> for FirTraceInfo { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for ScoreNotification { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for ScoreNotification { + impl ::planus::WriteAsOffset for FirTraceInfo { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ScoreNotification::create(builder, &self.scores) + ) -> ::planus::Offset { + FirTraceInfo::create(builder, self.ssrc) } } - /// Builder for serializing an instance of the [ScoreNotification] type. + /// Builder for serializing an instance of the [FirTraceInfo] type. /// - /// Can be created using the [ScoreNotification::builder] method. + /// Can be created using the [FirTraceInfo::builder] method. #[derive(Debug)] #[must_use] - pub struct ScoreNotificationBuilder(State); + pub struct FirTraceInfoBuilder(State); - impl ScoreNotificationBuilder<()> { - /// Setter for the [`scores` field](ScoreNotification#structfield.scores). + impl FirTraceInfoBuilder<()> { + /// Setter for the [`ssrc` field](FirTraceInfo#structfield.ssrc). #[inline] #[allow(clippy::type_complexity)] - pub fn scores(self, value: T0) -> ScoreNotificationBuilder<(T0,)> + pub fn ssrc(self, value: T0) -> FirTraceInfoBuilder<(T0,)> where - T0: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, + T0: ::planus::WriteAsDefault, { - ScoreNotificationBuilder((value,)) + FirTraceInfoBuilder((value,)) } - /// Sets the [`scores` field](ScoreNotification#structfield.scores) to null. + /// Sets the [`ssrc` field](FirTraceInfo#structfield.ssrc) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn scores_as_null(self) -> ScoreNotificationBuilder<((),)> { - self.scores(()) + pub fn ssrc_as_default(self) -> FirTraceInfoBuilder<(::planus::DefaultValue,)> { + self.ssrc(::planus::DefaultValue) } } - impl ScoreNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ScoreNotification]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAs<::planus::Offset> - for ScoreNotificationBuilder<(T0,)> + impl> + ::planus::WriteAs<::planus::Offset> for FirTraceInfoBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOptional<::planus::Offset> - for ScoreNotificationBuilder<(T0,)> + impl> + ::planus::WriteAsOptional<::planus::Offset> + for FirTraceInfoBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOffset for ScoreNotificationBuilder<(T0,)> + impl> ::planus::WriteAsOffset + for FirTraceInfoBuilder<(T0,)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { let (v0,) = &self.0; - ScoreNotification::create(builder, v0) + FirTraceInfo::create(builder, v0) } } - /// Reference to a deserialized [ScoreNotification]. + /// Reference to a deserialized [FirTraceInfo]. #[derive(Copy, Clone)] - pub struct ScoreNotificationRef<'a>(::planus::table_reader::Table<'a>); + pub struct FirTraceInfoRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> ScoreNotificationRef<'a> { - /// Getter for the [`scores` field](ScoreNotification#structfield.scores). + impl<'a> FirTraceInfoRef<'a> { + /// Getter for the [`ssrc` field](FirTraceInfo#structfield.ssrc). #[inline] - pub fn scores( - &self, - ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, - > { - self.0.access(0, "ScoreNotification", "scores") + 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 ScoreNotificationRef<'a> { + 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("ScoreNotificationRef"); - if let ::core::option::Option::Some(field_scores) = self.scores().transpose() { - f.field("scores", &field_scores); - } + let mut f = f.debug_struct("FirTraceInfoRef"); + f.field("ssrc", &self.ssrc()); f.finish() } } - impl<'a> ::core::convert::TryFrom> for ScoreNotification { + impl<'a> ::core::convert::TryFrom> for FirTraceInfo { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: ScoreNotificationRef<'a>) -> ::planus::Result { + fn try_from(value: FirTraceInfoRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - scores: if let ::core::option::Option::Some(scores) = value.scores()? { - ::core::option::Option::Some(scores.to_vec_result()?) - } else { - ::core::option::Option::None - }, + ssrc: ::core::convert::TryInto::try_into(value.ssrc()?)?, }) } } - impl<'a> ::planus::TableRead<'a> for ScoreNotificationRef<'a> { + impl<'a> ::planus::TableRead<'a> for FirTraceInfoRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -66452,7 +68371,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for ScoreNotificationRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for FirTraceInfoRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -66462,7 +68381,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[ScoreNotificationRef]", + "[FirTraceInfoRef]", "get", buffer.offset_from_start, ) @@ -66470,8 +68389,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for ScoreNotification { - type Value = ::planus::Offset; + 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 { @@ -66480,7 +68399,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -66495,7 +68414,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for ScoreNotificationRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for FirTraceInfoRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -66505,15 +68424,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[ScoreNotificationRef]", "read_as_root", 0) + error_kind.with_error_location("[FirTraceInfoRef]", "read_as_root", 0) }) } } - /// The table `VideoOrientationChangeNotification` in the namespace `FBS.Producer` + /// The table `PliTraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `VideoOrientationChangeNotification` in the file `../worker/fbs/producer.fbs:41` + /// * Table `PliTraceInfo` in the file `../worker/fbs/producer.fbs:66` #[derive( Clone, Debug, @@ -66525,68 +68444,42 @@ mod root { ::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, + pub struct PliTraceInfo { + /// The field `ssrc` in the table `PliTraceInfo` + pub ssrc: u32, } #[allow(clippy::derivable_impls)] - impl ::core::default::Default for VideoOrientationChangeNotification { + impl ::core::default::Default for PliTraceInfo { fn default() -> Self { - Self { - camera: false, - flip: false, - rotation: 0, - } + Self { ssrc: 0 } } } - impl VideoOrientationChangeNotification { - /// Creates a [VideoOrientationChangeNotificationBuilder] for serializing an instance of this table. + impl PliTraceInfo { + /// Creates a [PliTraceInfoBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> VideoOrientationChangeNotificationBuilder<()> { - VideoOrientationChangeNotificationBuilder(()) + pub fn builder() -> PliTraceInfoBuilder<()> { + PliTraceInfoBuilder(()) } #[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, + field_ssrc: 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 prepared_ssrc = field_ssrc.prepare(builder, &0); - let mut table_writer: ::planus::table_writer::TableWriter<10> = + let mut table_writer: ::planus::table_writer::TableWriter<6> = ::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); + if prepared_ssrc.is_some() { + table_writer.write_entry::(0); } 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); + if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { + object_writer.write::<_, _, 4>(&prepared_ssrc); } }); } @@ -66594,270 +68487,156 @@ mod root { } } - impl ::planus::WriteAs<::planus::Offset> - for VideoOrientationChangeNotification - { + impl ::planus::WriteAs<::planus::Offset> for PliTraceInfo { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> - for VideoOrientationChangeNotification - { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset - for VideoOrientationChangeNotification - { + impl ::planus::WriteAsOffset for PliTraceInfo { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - VideoOrientationChangeNotification::create( - builder, - self.camera, - self.flip, - self.rotation, - ) + ) -> ::planus::Offset { + PliTraceInfo::create(builder, self.ssrc) } } - /// Builder for serializing an instance of the [VideoOrientationChangeNotification] type. + /// Builder for serializing an instance of the [PliTraceInfo] type. /// - /// Can be created using the [VideoOrientationChangeNotification::builder] method. + /// Can be created using the [PliTraceInfo::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) - } - } + pub struct PliTraceInfoBuilder(State); - impl VideoOrientationChangeNotificationBuilder<(T0, T1)> { - /// Setter for the [`rotation` field](VideoOrientationChangeNotification#structfield.rotation). + impl PliTraceInfoBuilder<()> { + /// Setter for the [`ssrc` field](PliTraceInfo#structfield.ssrc). #[inline] #[allow(clippy::type_complexity)] - pub fn rotation( - self, - value: T2, - ) -> VideoOrientationChangeNotificationBuilder<(T0, T1, T2)> + pub fn ssrc(self, value: T0) -> PliTraceInfoBuilder<(T0,)> where - T2: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, { - let (v0, v1) = self.0; - VideoOrientationChangeNotificationBuilder((v0, v1, value)) + PliTraceInfoBuilder((value,)) } - /// Sets the [`rotation` field](VideoOrientationChangeNotification#structfield.rotation) to the default value. + /// Sets the [`ssrc` field](PliTraceInfo#structfield.ssrc) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn rotation_as_default( - self, - ) -> VideoOrientationChangeNotificationBuilder<(T0, T1, ::planus::DefaultValue)> - { - self.rotation(::planus::DefaultValue) + pub fn ssrc_as_default(self) -> PliTraceInfoBuilder<(::planus::DefaultValue,)> { + self.ssrc(::planus::DefaultValue) } } - impl VideoOrientationChangeNotificationBuilder<(T0, T1, T2)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [VideoOrientationChangeNotification]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + 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)> + impl> + ::planus::WriteAs<::planus::Offset> for PliTraceInfoBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::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)> + impl> + ::planus::WriteAsOptional<::planus::Offset> + for PliTraceInfoBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { + ) -> ::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)> + impl> ::planus::WriteAsOffset + for PliTraceInfoBuilder<(T0,)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2) = &self.0; - VideoOrientationChangeNotification::create(builder, v0, v1, v2) + ) -> ::planus::Offset { + let (v0,) = &self.0; + PliTraceInfo::create(builder, v0) } } - /// Reference to a deserialized [VideoOrientationChangeNotification]. + /// Reference to a deserialized [PliTraceInfo]. #[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), - ) - } + pub struct PliTraceInfoRef<'a>(::planus::table_reader::Table<'a>); - /// Getter for the [`rotation` field](VideoOrientationChangeNotification#structfield.rotation). + impl<'a> PliTraceInfoRef<'a> { + /// Getter for the [`ssrc` field](PliTraceInfo#structfield.ssrc). #[inline] - pub fn rotation(&self) -> ::planus::Result { + pub fn ssrc(&self) -> ::planus::Result { ::core::result::Result::Ok( - self.0 - .access(2, "VideoOrientationChangeNotification", "rotation")? - .unwrap_or(0), + self.0.access(0, "PliTraceInfo", "ssrc")?.unwrap_or(0), ) } } - impl<'a> ::core::fmt::Debug for VideoOrientationChangeNotificationRef<'a> { + 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("VideoOrientationChangeNotificationRef"); - f.field("camera", &self.camera()); - f.field("flip", &self.flip()); - f.field("rotation", &self.rotation()); + let mut f = f.debug_struct("PliTraceInfoRef"); + f.field("ssrc", &self.ssrc()); f.finish() } } - impl<'a> ::core::convert::TryFrom> - for VideoOrientationChangeNotification - { + impl<'a> ::core::convert::TryFrom> for PliTraceInfo { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from( - value: VideoOrientationChangeNotificationRef<'a>, - ) -> ::planus::Result { + fn try_from(value: PliTraceInfoRef<'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()?)?, + ssrc: ::core::convert::TryInto::try_into(value.ssrc()?)?, }) } } - impl<'a> ::planus::TableRead<'a> for VideoOrientationChangeNotificationRef<'a> { + impl<'a> ::planus::TableRead<'a> for PliTraceInfoRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -66869,7 +68648,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for VideoOrientationChangeNotificationRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for PliTraceInfoRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -66879,7 +68658,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[VideoOrientationChangeNotificationRef]", + "[PliTraceInfoRef]", "get", buffer.offset_from_start, ) @@ -66887,10 +68666,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> - for VideoOrientationChangeNotification - { - type Value = ::planus::Offset; + 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 { @@ -66899,7 +68676,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -66914,7 +68691,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for VideoOrientationChangeNotificationRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for PliTraceInfoRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -66924,372 +68701,292 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location( - "[VideoOrientationChangeNotificationRef]", - "read_as_root", - 0, - ) + error_kind.with_error_location("[PliTraceInfoRef]", "read_as_root", 0) }) } } - /// The enum `TraceType` in the namespace `FBS.Producer` + /// The table `RtpTraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Enum `TraceType` in the file `../worker/fbs/producer.fbs:47` + /// * Table `RtpTraceInfo` in the file `../worker/fbs/producer.fbs:70` #[derive( - Copy, Clone, Debug, PartialEq, - Eq, PartialOrd, + Eq, Ord, Hash, ::serde::Serialize, ::serde::Deserialize, )] - #[repr(u8)] - pub enum TraceType { - /// The variant `KEYFRAME` in the enum `TraceType` - Keyframe = 0, - - /// The variant `FIR` in the enum `TraceType` - Fir = 1, - - /// The variant `NACK` in the enum `TraceType` - Nack = 2, - - /// The variant `PLI` in the enum `TraceType` - Pli = 3, - - /// The variant `RTP` in the enum `TraceType` - Rtp = 4, - } - - impl TraceType { - /// Array containing all valid variants of TraceType - pub const ENUM_VALUES: [Self; 5] = - [Self::Keyframe, Self::Fir, Self::Nack, Self::Pli, Self::Rtp]; + pub struct RtpTraceInfo { + /// The field `is_rtx` in the table `RtpTraceInfo` + pub is_rtx: bool, } - impl ::core::convert::TryFrom for TraceType { - 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(TraceType::Keyframe), - 1 => ::core::result::Result::Ok(TraceType::Fir), - 2 => ::core::result::Result::Ok(TraceType::Nack), - 3 => ::core::result::Result::Ok(TraceType::Pli), - 4 => ::core::result::Result::Ok(TraceType::Rtp), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for RtpTraceInfo { + fn default() -> Self { + Self { is_rtx: false } } } - impl ::core::convert::From for u8 { + impl RtpTraceInfo { + /// Creates a [RtpTraceInfoBuilder] for serializing an instance of this table. #[inline] - fn from(value: TraceType) -> Self { - value as u8 + pub fn builder() -> RtpTraceInfoBuilder<()> { + RtpTraceInfoBuilder(()) } - } - - impl ::planus::Primitive for TraceType { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - impl ::planus::WriteAsPrimitive for TraceType { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } + #[allow(clippy::too_many_arguments)] + pub fn create( + builder: &mut ::planus::Builder, + field_is_rtx: impl ::planus::WriteAsDefault, + ) -> ::planus::Offset { + let prepared_is_rtx = field_is_rtx.prepare(builder, &false); - impl ::planus::WriteAs for TraceType { - type Prepared = Self; + let mut table_writer: ::planus::table_writer::TableWriter<6> = + ::core::default::Default::default(); + if prepared_is_rtx.is_some() { + table_writer.write_entry::(0); + } - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> TraceType { - *self + unsafe { + table_writer.finish(builder, |object_writer| { + if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { + object_writer.write::<_, _, 1>(&prepared_is_rtx); + } + }); + } + builder.current_offset() } } - impl ::planus::WriteAsDefault for TraceType { - type Prepared = Self; + impl ::planus::WriteAs<::planus::Offset> for RtpTraceInfo { + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, - _builder: &mut ::planus::Builder, - default: &TraceType, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional for TraceType { - type Prepared = Self; + impl ::planus::WriteAsOptional<::planus::Offset> for RtpTraceInfo { + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) - } - } - - impl<'buf> ::planus::TableRead<'buf> for TraceType { - #[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 TraceType { - 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( - "TraceType", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::VectorWrite for TraceType { - const STRIDE: usize = 1; - - type Value = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self - } - + impl ::planus::WriteAsOffset for RtpTraceInfo { #[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, - ); - } + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + RtpTraceInfo::create(builder, self.is_rtx) } } - /// The enum `TraceDirection` in the namespace `FBS.Producer` + /// Builder for serializing an instance of the [RtpTraceInfo] type. /// - /// Generated from these locations: - /// * Enum `TraceDirection` in the file `../worker/fbs/producer.fbs:49` - #[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]; - } + /// Can be created using the [RtpTraceInfo::builder] method. + #[derive(Debug)] + #[must_use] + pub struct RtpTraceInfoBuilder(State); - impl ::core::convert::TryFrom for TraceDirection { - type Error = ::planus::errors::UnknownEnumTagKind; + impl RtpTraceInfoBuilder<()> { + /// Setter for the [`is_rtx` field](RtpTraceInfo#structfield.is_rtx). #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result + #[allow(clippy::type_complexity)] + pub fn is_rtx(self, value: T0) -> RtpTraceInfoBuilder<(T0,)> + where + T0: ::planus::WriteAsDefault, { - #[allow(clippy::match_single_binding)] - match value { - 0 => ::core::result::Result::Ok(TraceDirection::DirectionIn), - 1 => ::core::result::Result::Ok(TraceDirection::DirectionOut), + RtpTraceInfoBuilder((value,)) + } - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } + /// 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<(::planus::DefaultValue,)> { + self.is_rtx(::planus::DefaultValue) } } - impl ::core::convert::From for u8 { + impl RtpTraceInfoBuilder<(T0,)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtpTraceInfo]. #[inline] - fn from(value: TraceDirection) -> Self { - value as u8 + pub fn finish( + self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset + where + Self: ::planus::WriteAsOffset, + { + ::planus::WriteAsOffset::prepare(&self, builder) } } - impl ::planus::Primitive for TraceDirection { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } + impl> + ::planus::WriteAs<::planus::Offset> for RtpTraceInfoBuilder<(T0,)> + { + type Prepared = ::planus::Offset; - impl ::planus::WriteAsPrimitive for TraceDirection { #[inline] - fn write( + fn prepare( &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAs for TraceDirection { - type Prepared = Self; + impl> + ::planus::WriteAsOptional<::planus::Offset> + for RtpTraceInfoBuilder<(T0,)> + { + type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> TraceDirection { - *self + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsDefault for TraceDirection { - type Prepared = Self; - + impl> ::planus::WriteAsOffset + for RtpTraceInfoBuilder<(T0,)> + { #[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) - } + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + let (v0,) = &self.0; + RtpTraceInfo::create(builder, v0) } } - impl ::planus::WriteAsOptional for TraceDirection { - type Prepared = Self; + /// Reference to a deserialized [RtpTraceInfo]. + #[derive(Copy, Clone)] + pub struct RtpTraceInfoRef<'a>(::planus::table_reader::Table<'a>); + impl<'a> RtpTraceInfoRef<'a> { + /// Getter for the [`is_rtx` field](RtpTraceInfo#structfield.is_rtx). #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) + pub fn is_rtx(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0.access(0, "RtpTraceInfo", "is_rtx")?.unwrap_or(false), + ) } } - impl<'buf> ::planus::TableRead<'buf> for TraceDirection { + 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("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 { + 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<'buf>, + buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) + ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( + buffer, offset, + )?)) } } - impl<'buf> ::planus::VectorReadInner<'buf> for TraceDirection { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] + impl<'a> ::planus::VectorReadInner<'a> for RtpTraceInfoRef<'a> { + type Error = ::planus::Error; + const STRIDE: usize = 4; + unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, + buffer: ::planus::SliceWithStartOffset<'a>, 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| { + ) -> ::planus::Result { + ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "TraceDirection", - "VectorRead::from_buffer", + "[RtpTraceInfoRef]", + "get", buffer.offset_from_start, ) }) } } - impl ::planus::VectorWrite for TraceDirection { - const STRIDE: usize = 1; - - type Value = Self; - + impl ::planus::VectorWrite<::planus::Offset> for RtpTraceInfo { + type Value = ::planus::Offset; + const STRIDE: usize = 4; #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self + fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { + ::planus::WriteAs::prepare(self, builder) } #[inline] unsafe fn write_values( - values: &[Self], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; + 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 - i as u32, + buffer_position - (Self::STRIDE * i) as u32, ); } } } - /// The union `TraceInfo` in the namespace `FBS.Producer` + 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: - /// * Union `TraceInfo` in the file `../worker/fbs/producer.fbs:51` + /// * Table `TraceNotification` in the file `../worker/fbs/producer.fbs:74` #[derive( Clone, Debug, @@ -67301,327 +68998,455 @@ mod root { ::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), + pub struct TraceNotification { + /// The field `type` in the table `TraceNotification` + pub type_: self::TraceType, + /// The field `timestamp` in the table `TraceNotification` + pub timestamp: u64, + /// The field `direction` in the table `TraceNotification` + pub direction: self::TraceDirection, + /// The field `info` in the table `TraceNotification` + pub info: ::core::option::Option, } - impl TraceInfo { - /// Creates a [TraceInfoBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> TraceInfoBuilder<::planus::Uninitialized> { - TraceInfoBuilder(::planus::Uninitialized) + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for TraceNotification { + fn default() -> Self { + Self { + type_: self::TraceType::Keyframe, + timestamp: 0, + direction: self::TraceDirection::DirectionIn, + info: ::core::default::Default::default(), + } } + } + impl TraceNotification { + /// Creates a [TraceNotificationBuilder] for serializing an instance of this table. #[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()) + pub fn builder() -> TraceNotificationBuilder<()> { + TraceNotificationBuilder(()) } - #[inline] - pub fn create_fir_trace_info( + #[allow(clippy::too_many_arguments)] + pub fn create( builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) - } + field_type_: impl ::planus::WriteAsDefault, + field_timestamp: impl ::planus::WriteAsDefault, + field_direction: impl ::planus::WriteAsDefault< + self::TraceDirection, + self::TraceDirection, + >, + field_info: impl ::planus::WriteAsOptionalUnion, + ) -> ::planus::Offset { + let prepared_type_ = field_type_.prepare(builder, &self::TraceType::Keyframe); + let prepared_timestamp = field_timestamp.prepare(builder, &0); + let prepared_direction = + field_direction.prepare(builder, &self::TraceDirection::DirectionIn); + let prepared_info = field_info.prepare(builder); - #[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()) + 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] - pub fn create_rtp_trace_info( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsUnion for TraceInfo { + impl ::planus::WriteAsOptional<::planus::Offset> for TraceNotification { + type Prepared = ::planus::Offset; + #[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), - } + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOptionalUnion for TraceInfo { + impl ::planus::WriteAsOffset for TraceNotification { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Offset { + TraceNotification::create( + builder, + self.type_, + self.timestamp, + self.direction, + &self.info, + ) } } - /// Builder for serializing an instance of the [TraceInfo] type. + /// Builder for serializing an instance of the [TraceNotification] type. /// - /// Can be created using the [TraceInfo::builder] method. + /// Can be created using the [TraceNotification::builder] method. #[derive(Debug)] #[must_use] - pub struct TraceInfoBuilder(T); + pub struct TraceNotificationBuilder(State); - impl TraceInfoBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`KeyFrameTraceInfo` variant](TraceInfo#variant.KeyFrameTraceInfo). + impl TraceNotificationBuilder<()> { + /// Setter for the [`type` field](TraceNotification#structfield.type_). #[inline] - pub fn key_frame_trace_info( - self, - value: T, - ) -> TraceInfoBuilder<::planus::Initialized<1, T>> + #[allow(clippy::type_complexity)] + pub fn type_(self, value: T0) -> TraceNotificationBuilder<(T0,)> where - T: ::planus::WriteAsOffset, + T0: ::planus::WriteAsDefault, { - TraceInfoBuilder(::planus::Initialized(value)) + TraceNotificationBuilder((value,)) } - /// Creates an instance of the [`FirTraceInfo` variant](TraceInfo#variant.FirTraceInfo). + /// Sets the [`type` field](TraceNotification#structfield.type_) to the default value. #[inline] - pub fn fir_trace_info( + #[allow(clippy::type_complexity)] + pub fn type_as_default( self, - value: T, - ) -> TraceInfoBuilder<::planus::Initialized<2, T>> + ) -> 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 - T: ::planus::WriteAsOffset, + T1: ::planus::WriteAsDefault, { - TraceInfoBuilder(::planus::Initialized(value)) + let (v0,) = self.0; + TraceNotificationBuilder((v0, value)) } - /// Creates an instance of the [`PliTraceInfo` variant](TraceInfo#variant.PliTraceInfo). + /// Sets the [`timestamp` field](TraceNotification#structfield.timestamp) to the default value. #[inline] - pub fn pli_trace_info( + #[allow(clippy::type_complexity)] + pub fn timestamp_as_default( self, - value: T, - ) -> TraceInfoBuilder<::planus::Initialized<3, T>> + ) -> 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 - T: ::planus::WriteAsOffset, + T2: ::planus::WriteAsDefault, { - TraceInfoBuilder(::planus::Initialized(value)) + let (v0, v1) = self.0; + TraceNotificationBuilder((v0, v1, value)) } - /// Creates an instance of the [`RtpTraceInfo` variant](TraceInfo#variant.RtpTraceInfo). + /// Sets the [`direction` field](TraceNotification#structfield.direction) to the default value. #[inline] - pub fn rtp_trace_info( + #[allow(clippy::type_complexity)] + pub fn direction_as_default( self, - value: T, - ) -> TraceInfoBuilder<::planus::Initialized<4, T>> + ) -> 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 - T: ::planus::WriteAsOffset, + T3: ::planus::WriteAsOptionalUnion, { - TraceInfoBuilder(::planus::Initialized(value)) + 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 TraceInfoBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [TraceInfo]. + 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::UnionOffset + ) -> ::planus::Offset where - Self: ::planus::WriteAsUnion, + Self: ::planus::WriteAsOffset, { - ::planus::WriteAsUnion::prepare(&self, builder) + ::planus::WriteAsOffset::prepare(&self, builder) } } - impl ::planus::WriteAsUnion for TraceInfoBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, + impl< + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault, + T3: ::planus::WriteAsOptionalUnion, + > ::planus::WriteAs<::planus::Offset> + for TraceNotificationBuilder<(T0, T1, T2, T3)> { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) - } - } + type Prepared = ::planus::Offset; - 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)) + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsUnion for TraceInfoBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, + + impl< + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault, + 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, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOptionalUnion for TraceInfoBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, + impl< + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault, + T3: ::planus::WriteAsOptionalUnion, + > ::planus::WriteAsOffset + for TraceNotificationBuilder<(T0, T1, T2, T3)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Offset { + let (v0, v1, v2, v3) = &self.0; + TraceNotification::create(builder, v0, v1, v2, v3) } } - impl ::planus::WriteAsUnion for TraceInfoBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { + + /// 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] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, (self.0).0.prepare(builder).downcast()) + pub fn type_(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(0, "TraceNotification", "type_")? + .unwrap_or(self::TraceType::Keyframe), + ) } - } - impl ::planus::WriteAsOptionalUnion for TraceInfoBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { + /// Getter for the [`timestamp` field](TraceNotification#structfield.timestamp). #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + pub fn timestamp(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "TraceNotification", "timestamp")? + .unwrap_or(0), + ) } - } - impl ::planus::WriteAsUnion for TraceInfoBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { + + /// Getter for the [`direction` field](TraceNotification#structfield.direction). #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, (self.0).0.prepare(builder).downcast()) + pub fn direction(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(2, "TraceNotification", "direction")? + .unwrap_or(self::TraceDirection::DirectionIn), + ) } - } - impl ::planus::WriteAsOptionalUnion for TraceInfoBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { + /// Getter for the [`info` field](TraceNotification#structfield.info). #[inline] - fn prepare( + pub fn info( &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Result<::core::option::Option>> + { + self.0.access_union(3, "TraceNotification", "info") } } - /// 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::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 TraceInfo { + impl<'a> ::core::convert::TryFrom> for TraceNotification { 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)?, - )) - } + #[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::TableReadUnion<'a> for TraceInfoRef<'a> { + impl<'a> ::planus::TableRead<'a> for TraceNotificationRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, - field_offset: usize, - tag: u8, + offset: usize, ) -> ::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 }, - ), + ::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, + ); } } } - /// The table `KeyFrameTraceInfo` in the namespace `FBS.Producer` + 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 `KeyFrameTraceInfo` in the file `../worker/fbs/producer.fbs:58` + /// * Table `PipeTransportOptions` in the file `../worker/fbs/pipeTransport.fbs:6` #[derive( Clone, Debug, @@ -67633,42 +69458,63 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct KeyFrameTraceInfo { - /// 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 { is_rtx: false } - } + 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 KeyFrameTraceInfo { - /// Creates a [KeyFrameTraceInfoBuilder] for serializing an instance of this table. + impl PipeTransportOptions { + /// Creates a [PipeTransportOptionsBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> KeyFrameTraceInfoBuilder<()> { - KeyFrameTraceInfoBuilder(()) + pub fn builder() -> PipeTransportOptionsBuilder<()> { + PipeTransportOptionsBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_is_rtx: impl ::planus::WriteAsDefault, + 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_is_rtx = field_is_rtx.prepare(builder, &false); + 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<6> = + let mut table_writer: ::planus::table_writer::TableWriter<12> = ::core::default::Default::default(); - if prepared_is_rtx.is_some() { - table_writer.write_entry::(0); + 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| { - if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { - object_writer.write::<_, _, 1>(&prepared_is_rtx); + 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); } }); } @@ -67676,161 +69522,267 @@ mod root { } } - impl ::planus::WriteAs<::planus::Offset> for KeyFrameTraceInfo { + impl ::planus::WriteAs<::planus::Offset> for PipeTransportOptions { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for KeyFrameTraceInfo { + 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<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for KeyFrameTraceInfo { + impl ::planus::WriteAsOffset for PipeTransportOptions { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - KeyFrameTraceInfo::create(builder, self.is_rtx) + ) -> ::planus::Offset { + PipeTransportOptions::create( + builder, + &self.base, + &self.listen_info, + self.enable_rtx, + self.enable_srtp, + ) } } - /// Builder for serializing an instance of the [KeyFrameTraceInfo] type. + /// Builder for serializing an instance of the [PipeTransportOptions] type. /// - /// Can be created using the [KeyFrameTraceInfo::builder] method. + /// Can be created using the [PipeTransportOptions::builder] method. #[derive(Debug)] #[must_use] - pub struct KeyFrameTraceInfoBuilder(State); + pub struct PipeTransportOptionsBuilder(State); - impl KeyFrameTraceInfoBuilder<()> { - /// Setter for the [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx). + impl PipeTransportOptionsBuilder<()> { + /// Setter for the [`base` field](PipeTransportOptions#structfield.base). #[inline] #[allow(clippy::type_complexity)] - pub fn is_rtx(self, value: T0) -> KeyFrameTraceInfoBuilder<(T0,)> + pub fn base(self, value: T0) -> PipeTransportOptionsBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAs<::planus::Offset>, { - KeyFrameTraceInfoBuilder((value,)) + PipeTransportOptionsBuilder((value,)) } + } - /// Sets the [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx) to the default value. + impl PipeTransportOptionsBuilder<(T0,)> { + /// Setter for the [`listen_info` field](PipeTransportOptions#structfield.listen_info). #[inline] #[allow(clippy::type_complexity)] - pub fn is_rtx_as_default( + 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, - ) -> KeyFrameTraceInfoBuilder<(::planus::DefaultValue,)> { - self.is_rtx(::planus::DefaultValue) + ) -> PipeTransportOptionsBuilder<(T0, T1, ::planus::DefaultValue)> { + self.enable_rtx(::planus::DefaultValue) } } - impl KeyFrameTraceInfoBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [KeyFrameTraceInfo]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl> - ::planus::WriteAs<::planus::Offset> - for KeyFrameTraceInfoBuilder<(T0,)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl> - ::planus::WriteAsOptional<::planus::Offset> - for KeyFrameTraceInfoBuilder<(T0,)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl> - ::planus::WriteAsOffset for KeyFrameTraceInfoBuilder<(T0,)> + 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,) = &self.0; - KeyFrameTraceInfo::create(builder, v0) + ) -> ::planus::Offset { + let (v0, v1, v2, v3) = &self.0; + PipeTransportOptions::create(builder, v0, v1, v2, v3) } } - /// Reference to a deserialized [KeyFrameTraceInfo]. + /// Reference to a deserialized [PipeTransportOptions]. #[derive(Copy, Clone)] - pub struct KeyFrameTraceInfoRef<'a>(::planus::table_reader::Table<'a>); + pub struct PipeTransportOptionsRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> KeyFrameTraceInfoRef<'a> { - /// Getter for the [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx). + impl<'a> PipeTransportOptionsRef<'a> { + /// Getter for the [`base` field](PipeTransportOptions#structfield.base). #[inline] - pub fn is_rtx(&self) -> ::planus::Result { + 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(0, "KeyFrameTraceInfo", "is_rtx")? + .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 KeyFrameTraceInfoRef<'a> { + 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("KeyFrameTraceInfoRef"); - f.field("is_rtx", &self.is_rtx()); + 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 KeyFrameTraceInfo { + impl<'a> ::core::convert::TryFrom> for PipeTransportOptions { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: KeyFrameTraceInfoRef<'a>) -> ::planus::Result { + fn try_from(value: PipeTransportOptionsRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - is_rtx: ::core::convert::TryInto::try_into(value.is_rtx()?)?, + 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 KeyFrameTraceInfoRef<'a> { + impl<'a> ::planus::TableRead<'a> for PipeTransportOptionsRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -67842,7 +69794,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for KeyFrameTraceInfoRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for PipeTransportOptionsRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -67852,7 +69804,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[KeyFrameTraceInfoRef]", + "[PipeTransportOptionsRef]", "get", buffer.offset_from_start, ) @@ -67860,8 +69812,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for KeyFrameTraceInfo { - type Value = ::planus::Offset; + 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 { @@ -67870,7 +69822,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -67885,7 +69837,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for KeyFrameTraceInfoRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for PipeTransportOptionsRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -67895,15 +69847,19 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[KeyFrameTraceInfoRef]", "read_as_root", 0) + error_kind.with_error_location( + "[PipeTransportOptionsRef]", + "read_as_root", + 0, + ) }) } } - /// The table `FirTraceInfo` in the namespace `FBS.Producer` + /// The table `ConnectRequest` in the namespace `FBS.PipeTransport` /// /// Generated from these locations: - /// * Table `FirTraceInfo` in the file `../worker/fbs/producer.fbs:62` + /// * Table `ConnectRequest` in the file `../worker/fbs/pipeTransport.fbs:13` #[derive( Clone, Debug, @@ -67915,42 +69871,57 @@ mod root { ::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 } - } + 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 FirTraceInfo { - /// Creates a [FirTraceInfoBuilder] for serializing an instance of this table. + impl ConnectRequest { + /// Creates a [ConnectRequestBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> FirTraceInfoBuilder<()> { - FirTraceInfoBuilder(()) + pub fn builder() -> ConnectRequestBuilder<()> { + ConnectRequestBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_ssrc: impl ::planus::WriteAsDefault, + field_ip: impl ::planus::WriteAs<::planus::Offset>, + field_port: impl ::planus::WriteAsOptional, + field_srtp_parameters: impl ::planus::WriteAsOptional< + ::planus::Offset, + >, ) -> ::planus::Offset { - let prepared_ssrc = field_ssrc.prepare(builder, &0); + 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<6> = - ::core::default::Default::default(); - if prepared_ssrc.is_some() { - table_writer.write_entry::(0); + 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| { - if let ::core::option::Option::Some(prepared_ssrc) = prepared_ssrc { - object_writer.write::<_, _, 4>(&prepared_ssrc); + 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); } }); } @@ -67958,156 +69929,243 @@ mod root { } } - impl ::planus::WriteAs<::planus::Offset> for FirTraceInfo { + impl ::planus::WriteAs<::planus::Offset> for ConnectRequest { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for FirTraceInfo { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for FirTraceInfo { + impl ::planus::WriteAsOffset for ConnectRequest { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - FirTraceInfo::create(builder, self.ssrc) + ) -> ::planus::Offset { + ConnectRequest::create(builder, &self.ip, self.port, &self.srtp_parameters) } } - /// Builder for serializing an instance of the [FirTraceInfo] type. + /// Builder for serializing an instance of the [ConnectRequest] type. /// - /// Can be created using the [FirTraceInfo::builder] method. + /// Can be created using the [ConnectRequest::builder] method. #[derive(Debug)] #[must_use] - pub struct FirTraceInfoBuilder(State); + pub struct ConnectRequestBuilder(State); - impl FirTraceInfoBuilder<()> { - /// Setter for the [`ssrc` field](FirTraceInfo#structfield.ssrc). + impl ConnectRequestBuilder<()> { + /// Setter for the [`ip` field](ConnectRequest#structfield.ip). #[inline] #[allow(clippy::type_complexity)] - pub fn ssrc(self, value: T0) -> FirTraceInfoBuilder<(T0,)> + pub fn ip(self, value: T0) -> ConnectRequestBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAs<::planus::Offset>, { - FirTraceInfoBuilder((value,)) + ConnectRequestBuilder((value,)) } + } - /// Sets the [`ssrc` field](FirTraceInfo#structfield.ssrc) to the default value. + impl ConnectRequestBuilder<(T0,)> { + /// Setter for the [`port` field](ConnectRequest#structfield.port). #[inline] #[allow(clippy::type_complexity)] - pub fn ssrc_as_default(self) -> FirTraceInfoBuilder<(::planus::DefaultValue,)> { - self.ssrc(::planus::DefaultValue) + 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 FirTraceInfoBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [FirTraceInfo]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl> - ::planus::WriteAs<::planus::Offset> for FirTraceInfoBuilder<(T0,)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl> - ::planus::WriteAsOptional<::planus::Offset> - for FirTraceInfoBuilder<(T0,)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl> ::planus::WriteAsOffset - for FirTraceInfoBuilder<(T0,)> + 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,) = &self.0; - FirTraceInfo::create(builder, v0) + ) -> ::planus::Offset { + let (v0, v1, v2) = &self.0; + ConnectRequest::create(builder, v0, v1, v2) } } - /// Reference to a deserialized [FirTraceInfo]. + /// Reference to a deserialized [ConnectRequest]. #[derive(Copy, Clone)] - pub struct FirTraceInfoRef<'a>(::planus::table_reader::Table<'a>); + pub struct ConnectRequestRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> FirTraceInfoRef<'a> { - /// Getter for the [`ssrc` field](FirTraceInfo#structfield.ssrc). + impl<'a> ConnectRequestRef<'a> { + /// Getter for the [`ip` field](ConnectRequest#structfield.ip). #[inline] - pub fn ssrc(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "FirTraceInfo", "ssrc")?.unwrap_or(0), - ) + 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 FirTraceInfoRef<'a> { + 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("FirTraceInfoRef"); - f.field("ssrc", &self.ssrc()); + 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 FirTraceInfo { + impl<'a> ::core::convert::TryFrom> for ConnectRequest { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: FirTraceInfoRef<'a>) -> ::planus::Result { + fn try_from(value: ConnectRequestRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - ssrc: ::core::convert::TryInto::try_into(value.ssrc()?)?, + 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 FirTraceInfoRef<'a> { + impl<'a> ::planus::TableRead<'a> for ConnectRequestRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -68119,7 +70177,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for FirTraceInfoRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for ConnectRequestRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -68129,7 +70187,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[FirTraceInfoRef]", + "[ConnectRequestRef]", "get", buffer.offset_from_start, ) @@ -68137,8 +70195,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for FirTraceInfo { - type Value = ::planus::Offset; + 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 { @@ -68147,7 +70205,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -68162,7 +70220,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for FirTraceInfoRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for ConnectRequestRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -68172,15 +70230,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[FirTraceInfoRef]", "read_as_root", 0) + error_kind.with_error_location("[ConnectRequestRef]", "read_as_root", 0) }) } } - /// The table `PliTraceInfo` in the namespace `FBS.Producer` + /// The table `ConnectResponse` in the namespace `FBS.PipeTransport` /// /// Generated from these locations: - /// * Table `PliTraceInfo` in the file `../worker/fbs/producer.fbs:66` + /// * Table `ConnectResponse` in the file `../worker/fbs/pipeTransport.fbs:19` #[derive( Clone, Debug, @@ -68192,199 +70250,182 @@ mod root { ::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 } - } + pub struct ConnectResponse { + /// The field `tuple` in the table `ConnectResponse` + pub tuple: ::planus::alloc::boxed::Box, } - impl PliTraceInfo { - /// Creates a [PliTraceInfoBuilder] for serializing an instance of this table. + impl ConnectResponse { + /// Creates a [ConnectResponseBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> PliTraceInfoBuilder<()> { - PliTraceInfoBuilder(()) + pub fn builder() -> ConnectResponseBuilder<()> { + ConnectResponseBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_ssrc: impl ::planus::WriteAsDefault, + field_tuple: impl ::planus::WriteAs<::planus::Offset>, ) -> ::planus::Offset { - let prepared_ssrc = field_ssrc.prepare(builder, &0); + let prepared_tuple = field_tuple.prepare(builder); let mut table_writer: ::planus::table_writer::TableWriter<6> = ::core::default::Default::default(); - if prepared_ssrc.is_some() { - table_writer.write_entry::(0); - } + table_writer.write_entry::<::planus::Offset>(0); 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_tuple); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for PliTraceInfo { + impl ::planus::WriteAs<::planus::Offset> for ConnectResponse { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for PliTraceInfo { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for PliTraceInfo { + impl ::planus::WriteAsOffset for ConnectResponse { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - PliTraceInfo::create(builder, self.ssrc) + ) -> ::planus::Offset { + ConnectResponse::create(builder, &self.tuple) } } - /// Builder for serializing an instance of the [PliTraceInfo] type. + /// Builder for serializing an instance of the [ConnectResponse] type. /// - /// Can be created using the [PliTraceInfo::builder] method. + /// Can be created using the [ConnectResponse::builder] method. #[derive(Debug)] #[must_use] - pub struct PliTraceInfoBuilder(State); + pub struct ConnectResponseBuilder(State); - impl PliTraceInfoBuilder<()> { - /// Setter for the [`ssrc` field](PliTraceInfo#structfield.ssrc). + impl ConnectResponseBuilder<()> { + /// Setter for the [`tuple` field](ConnectResponse#structfield.tuple). #[inline] #[allow(clippy::type_complexity)] - pub fn ssrc(self, value: T0) -> PliTraceInfoBuilder<(T0,)> + pub fn tuple(self, value: T0) -> ConnectResponseBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAs<::planus::Offset>, { - 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) + ConnectResponseBuilder((value,)) } } - impl PliTraceInfoBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [PliTraceInfo]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl> - ::planus::WriteAs<::planus::Offset> for PliTraceInfoBuilder<(T0,)> + impl>> + ::planus::WriteAs<::planus::Offset> + for ConnectResponseBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl> - ::planus::WriteAsOptional<::planus::Offset> - for PliTraceInfoBuilder<(T0,)> + impl>> + ::planus::WriteAsOptional<::planus::Offset> + for ConnectResponseBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl> ::planus::WriteAsOffset - for PliTraceInfoBuilder<(T0,)> + impl>> + ::planus::WriteAsOffset for ConnectResponseBuilder<(T0,)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { let (v0,) = &self.0; - PliTraceInfo::create(builder, v0) + ConnectResponse::create(builder, v0) } } - /// Reference to a deserialized [PliTraceInfo]. + /// Reference to a deserialized [ConnectResponse]. #[derive(Copy, Clone)] - pub struct PliTraceInfoRef<'a>(::planus::table_reader::Table<'a>); + pub struct ConnectResponseRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> PliTraceInfoRef<'a> { - /// Getter for the [`ssrc` field](PliTraceInfo#structfield.ssrc). + impl<'a> ConnectResponseRef<'a> { + /// Getter for the [`tuple` field](ConnectResponse#structfield.tuple). #[inline] - pub fn ssrc(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(0, "PliTraceInfo", "ssrc")?.unwrap_or(0), - ) + pub fn tuple(&self) -> ::planus::Result> { + self.0.access_required(0, "ConnectResponse", "tuple") } } - impl<'a> ::core::fmt::Debug for PliTraceInfoRef<'a> { + 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("PliTraceInfoRef"); - f.field("ssrc", &self.ssrc()); + let mut f = f.debug_struct("ConnectResponseRef"); + f.field("tuple", &self.tuple()); f.finish() } } - impl<'a> ::core::convert::TryFrom> for PliTraceInfo { + impl<'a> ::core::convert::TryFrom> for ConnectResponse { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: PliTraceInfoRef<'a>) -> ::planus::Result { + fn try_from(value: ConnectResponseRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - ssrc: ::core::convert::TryInto::try_into(value.ssrc()?)?, + tuple: ::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(value.tuple()?)?, + ), }) } } - impl<'a> ::planus::TableRead<'a> for PliTraceInfoRef<'a> { + impl<'a> ::planus::TableRead<'a> for ConnectResponseRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -68396,7 +70437,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for PliTraceInfoRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for ConnectResponseRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -68406,7 +70447,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[PliTraceInfoRef]", + "[ConnectResponseRef]", "get", buffer.offset_from_start, ) @@ -68414,8 +70455,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for PliTraceInfo { - type Value = ::planus::Offset; + 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 { @@ -68424,7 +70465,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -68439,7 +70480,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for PliTraceInfoRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for ConnectResponseRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -68449,15 +70490,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[PliTraceInfoRef]", "read_as_root", 0) + error_kind.with_error_location("[ConnectResponseRef]", "read_as_root", 0) }) } } - /// The table `RtpTraceInfo` in the namespace `FBS.Producer` + /// The table `DumpResponse` in the namespace `FBS.PipeTransport` /// /// Generated from these locations: - /// * Table `RtpTraceInfo` in the file `../worker/fbs/producer.fbs:70` + /// * Table `DumpResponse` in the file `../worker/fbs/pipeTransport.fbs:23` #[derive( Clone, Debug, @@ -68469,42 +70510,63 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct RtpTraceInfo { - /// 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 { is_rtx: false } - } + 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 RtpTraceInfo { - /// Creates a [RtpTraceInfoBuilder] for serializing an instance of this table. + impl DumpResponse { + /// Creates a [DumpResponseBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> RtpTraceInfoBuilder<()> { - RtpTraceInfoBuilder(()) + pub fn builder() -> DumpResponseBuilder<()> { + DumpResponseBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_is_rtx: impl ::planus::WriteAsDefault, + 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_is_rtx = field_is_rtx.prepare(builder, &false); + 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<6> = + let mut table_writer: ::planus::table_writer::TableWriter<12> = ::core::default::Default::default(); - if prepared_is_rtx.is_some() { - table_writer.write_entry::(0); + 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| { - if let ::core::option::Option::Some(prepared_is_rtx) = prepared_is_rtx { - object_writer.write::<_, _, 1>(&prepared_is_rtx); + 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); } }); } @@ -68512,156 +70574,275 @@ mod root { } } - impl ::planus::WriteAs<::planus::Offset> for RtpTraceInfo { + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for RtpTraceInfo { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for RtpTraceInfo { + impl ::planus::WriteAsOffset for DumpResponse { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RtpTraceInfo::create(builder, self.is_rtx) + ) -> ::planus::Offset { + DumpResponse::create( + builder, + &self.base, + &self.tuple, + self.rtx, + &self.srtp_parameters, + ) } } - /// Builder for serializing an instance of the [RtpTraceInfo] type. + /// Builder for serializing an instance of the [DumpResponse] type. /// - /// Can be created using the [RtpTraceInfo::builder] method. + /// Can be created using the [DumpResponse::builder] method. #[derive(Debug)] #[must_use] - pub struct RtpTraceInfoBuilder(State); + pub struct DumpResponseBuilder(State); - impl RtpTraceInfoBuilder<()> { - /// Setter for the [`is_rtx` field](RtpTraceInfo#structfield.is_rtx). + impl DumpResponseBuilder<()> { + /// Setter for the [`base` field](DumpResponse#structfield.base). #[inline] #[allow(clippy::type_complexity)] - pub fn is_rtx(self, value: T0) -> RtpTraceInfoBuilder<(T0,)> + pub fn base(self, value: T0) -> DumpResponseBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAs<::planus::Offset>, { - RtpTraceInfoBuilder((value,)) + 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 [`is_rtx` field](RtpTraceInfo#structfield.is_rtx) to the default value. + /// Sets the [`srtp_parameters` field](DumpResponse#structfield.srtp_parameters) to null. #[inline] #[allow(clippy::type_complexity)] - pub fn is_rtx_as_default(self) -> RtpTraceInfoBuilder<(::planus::DefaultValue,)> { - self.is_rtx(::planus::DefaultValue) + pub fn srtp_parameters_as_null(self) -> DumpResponseBuilder<(T0, T1, T2, ())> { + self.srtp_parameters(()) } } - impl RtpTraceInfoBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtpTraceInfo]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl> - ::planus::WriteAs<::planus::Offset> for RtpTraceInfoBuilder<(T0,)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl> - ::planus::WriteAsOptional<::planus::Offset> - for RtpTraceInfoBuilder<(T0,)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl> ::planus::WriteAsOffset - for RtpTraceInfoBuilder<(T0,)> + 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,) = &self.0; - RtpTraceInfo::create(builder, v0) + ) -> ::planus::Offset { + let (v0, v1, v2, v3) = &self.0; + DumpResponse::create(builder, v0, v1, v2, v3) } } - /// Reference to a deserialized [RtpTraceInfo]. + /// Reference to a deserialized [DumpResponse]. #[derive(Copy, Clone)] - pub struct RtpTraceInfoRef<'a>(::planus::table_reader::Table<'a>); + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> RtpTraceInfoRef<'a> { - /// Getter for the [`is_rtx` field](RtpTraceInfo#structfield.is_rtx). + impl<'a> DumpResponseRef<'a> { + /// Getter for the [`base` field](DumpResponse#structfield.base). #[inline] - pub fn is_rtx(&self) -> ::planus::Result { + 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(0, "RtpTraceInfo", "is_rtx")?.unwrap_or(false), + 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 RtpTraceInfoRef<'a> { + 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("RtpTraceInfoRef"); - f.field("is_rtx", &self.is_rtx()); + 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 RtpTraceInfo { + impl<'a> ::core::convert::TryFrom> for DumpResponse { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: RtpTraceInfoRef<'a>) -> ::planus::Result { + fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - is_rtx: ::core::convert::TryInto::try_into(value.is_rtx()?)?, + 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 RtpTraceInfoRef<'a> { + impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -68673,7 +70854,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for RtpTraceInfoRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -68683,7 +70864,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[RtpTraceInfoRef]", + "[DumpResponseRef]", "get", buffer.offset_from_start, ) @@ -68691,8 +70872,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for RtpTraceInfo { - type Value = ::planus::Offset; + 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 { @@ -68701,7 +70882,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -68716,7 +70897,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for RtpTraceInfoRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -68726,397 +70907,229 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[RtpTraceInfoRef]", "read_as_root", 0) + error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) }) } } - /// The table `TraceNotification` in the namespace `FBS.Producer` + /// The table `GetStatsResponse` in the namespace `FBS.PipeTransport` /// /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/producer.fbs:74` + /// * Table `GetStatsResponse` in the file `../worker/fbs/pipeTransport.fbs:30` #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, + Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] - pub struct TraceNotification { - /// The field `type` in the table `TraceNotification` - pub type_: self::TraceType, - /// The field `timestamp` in the table `TraceNotification` - pub timestamp: u64, - /// The field `direction` in the table `TraceNotification` - pub direction: self::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::TraceType::Keyframe, - timestamp: 0, - direction: self::TraceDirection::DirectionIn, - info: ::core::default::Default::default(), - } - } + 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 TraceNotification { - /// Creates a [TraceNotificationBuilder] for serializing an instance of this table. + impl GetStatsResponse { + /// Creates a [GetStatsResponseBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> TraceNotificationBuilder<()> { - TraceNotificationBuilder(()) + pub fn builder() -> GetStatsResponseBuilder<()> { + GetStatsResponseBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_type_: impl ::planus::WriteAsDefault, - field_timestamp: impl ::planus::WriteAsDefault, - field_direction: impl ::planus::WriteAsDefault< - self::TraceDirection, - self::TraceDirection, - >, - field_info: impl ::planus::WriteAsOptionalUnion, + field_base: impl ::planus::WriteAs<::planus::Offset>, + field_tuple: impl ::planus::WriteAs<::planus::Offset>, ) -> ::planus::Offset { - let prepared_type_ = field_type_.prepare(builder, &self::TraceType::Keyframe); - let prepared_timestamp = field_timestamp.prepare(builder, &0); - let prepared_direction = - field_direction.prepare(builder, &self::TraceDirection::DirectionIn); - let prepared_info = field_info.prepare(builder); + let prepared_base = field_base.prepare(builder); + let prepared_tuple = field_tuple.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<14> = + let mut table_writer: ::planus::table_writer::TableWriter<8> = ::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); - } + table_writer.write_entry::<::planus::Offset>(0); + table_writer.write_entry::<::planus::Offset>(1); 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()); - } + object_writer.write::<_, _, 4>(&prepared_base); + object_writer.write::<_, _, 4>(&prepared_tuple); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for TraceNotification { + impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for TraceNotification { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for TraceNotification { + impl ::planus::WriteAsOffset for GetStatsResponse { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - TraceNotification::create( - builder, - self.type_, - self.timestamp, - self.direction, - &self.info, - ) + ) -> ::planus::Offset { + GetStatsResponse::create(builder, &self.base, &self.tuple) } } - /// Builder for serializing an instance of the [TraceNotification] type. + /// Builder for serializing an instance of the [GetStatsResponse] type. /// - /// Can be created using the [TraceNotification::builder] method. + /// Can be created using the [GetStatsResponse::builder] method. #[derive(Debug)] #[must_use] - pub struct TraceNotificationBuilder(State); + pub struct GetStatsResponseBuilder(State); - impl TraceNotificationBuilder<()> { - /// Setter for the [`type` field](TraceNotification#structfield.type_). + impl GetStatsResponseBuilder<()> { + /// Setter for the [`base` field](GetStatsResponse#structfield.base). #[inline] #[allow(clippy::type_complexity)] - pub fn type_(self, value: T0) -> TraceNotificationBuilder<(T0,)> + pub fn base(self, value: T0) -> GetStatsResponseBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAs<::planus::Offset>, { - 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) + GetStatsResponseBuilder((value,)) } } - impl TraceNotificationBuilder<(T0,)> { - /// Setter for the [`timestamp` field](TraceNotification#structfield.timestamp). + impl GetStatsResponseBuilder<(T0,)> { + /// Setter for the [`tuple` field](GetStatsResponse#structfield.tuple). #[inline] #[allow(clippy::type_complexity)] - pub fn timestamp(self, value: T1) -> TraceNotificationBuilder<(T0, T1)> + pub fn tuple(self, value: T1) -> GetStatsResponseBuilder<(T0, T1)> where - T1: ::planus::WriteAsDefault, + T1: ::planus::WriteAs<::planus::Offset>, { 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, - { - 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(()) + GetStatsResponseBuilder((v0, value)) } } - impl TraceNotificationBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [TraceNotification]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAs<::planus::Offset> - for TraceNotificationBuilder<(T0, T1, T2, T3)> + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAs<::planus::Offset>, + > ::planus::WriteAs<::planus::Offset> + for GetStatsResponseBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptionalUnion, - > ::planus::WriteAsOptional<::planus::Offset> - for TraceNotificationBuilder<(T0, T1, T2, T3)> + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAs<::planus::Offset>, + > ::planus::WriteAsOptional<::planus::Offset> + for GetStatsResponseBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::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::WriteAsOptionalUnion, - > ::planus::WriteAsOffset - for TraceNotificationBuilder<(T0, T1, T2, T3)> + 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, v2, v3) = &self.0; - TraceNotification::create(builder, v0, v1, v2, v3) + ) -> ::planus::Offset { + let (v0, v1) = &self.0; + GetStatsResponse::create(builder, v0, v1) } } - /// Reference to a deserialized [TraceNotification]. + /// Reference to a deserialized [GetStatsResponse]. #[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::TraceType::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), - ) - } + pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); - /// Getter for the [`direction` field](TraceNotification#structfield.direction). + impl<'a> GetStatsResponseRef<'a> { + /// Getter for the [`base` field](GetStatsResponse#structfield.base). #[inline] - pub fn direction(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "TraceNotification", "direction")? - .unwrap_or(self::TraceDirection::DirectionIn), - ) + pub fn base(&self) -> ::planus::Result> { + self.0.access_required(0, "GetStatsResponse", "base") } - /// Getter for the [`info` field](TraceNotification#structfield.info). + /// Getter for the [`tuple` field](GetStatsResponse#structfield.tuple). #[inline] - pub fn info( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access_union(3, "TraceNotification", "info") + pub fn tuple(&self) -> ::planus::Result> { + self.0.access_required(1, "GetStatsResponse", "tuple") } } - impl<'a> ::core::fmt::Debug for TraceNotificationRef<'a> { + 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("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); - } + 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 TraceNotification { + impl<'a> ::core::convert::TryFrom> for GetStatsResponse { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: TraceNotificationRef<'a>) -> ::planus::Result { + fn try_from(value: GetStatsResponseRef<'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 - }, + 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 TraceNotificationRef<'a> { + impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -69128,7 +71141,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for TraceNotificationRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for GetStatsResponseRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -69138,7 +71151,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[TraceNotificationRef]", + "[GetStatsResponseRef]", "get", buffer.offset_from_start, ) @@ -69146,8 +71159,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for TraceNotification { - type Value = ::planus::Offset; + 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 { @@ -69156,7 +71169,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -69171,7 +71184,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for TraceNotificationRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for GetStatsResponseRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -69181,20 +71194,20 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[TraceNotificationRef]", "read_as_root", 0) + error_kind.with_error_location("[GetStatsResponseRef]", "read_as_root", 0) }) } } } - /// The namespace `FBS.PipeTransport` + /// The namespace `FBS.PlainTransport` /// /// Generated from these locations: - /// * File `../worker/fbs/pipeTransport.fbs` - pub mod pipe_transport { - /// The table `PipeTransportOptions` in the namespace `FBS.PipeTransport` + /// * File `../worker/fbs/plainTransport.fbs` + pub mod plain_transport { + /// The table `PlainTransportOptions` in the namespace `FBS.PlainTransport` /// /// Generated from these locations: - /// * Table `PipeTransportOptions` in the file `../worker/fbs/pipeTransport.fbs:5` + /// * Table `PlainTransportOptions` in the file `../worker/fbs/plainTransport.fbs:7` #[derive( Clone, Debug, @@ -69206,22 +71219,31 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct PipeTransportOptions { - /// The field `base` in the table `PipeTransportOptions` + pub struct PlainTransportOptions { + /// The field `base` in the table `PlainTransportOptions` 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` + /// 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 PipeTransportOptions { - /// Creates a [PipeTransportOptionsBuilder] for serializing an instance of this table. + impl PlainTransportOptions { + /// Creates a [PlainTransportOptionsBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> PipeTransportOptionsBuilder<()> { - PipeTransportOptionsBuilder(()) + pub fn builder() -> PlainTransportOptionsBuilder<()> { + PlainTransportOptionsBuilder(()) } #[allow(clippy::too_many_arguments)] @@ -69231,175 +71253,292 @@ mod root { field_listen_info: impl ::planus::WriteAs< ::planus::Offset, >, - field_enable_rtx: impl ::planus::WriteAsDefault, + 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_enable_rtx = field_enable_rtx.prepare(builder, &false); + 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<12> = + 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_enable_rtx.is_some() { - table_writer.write_entry::(2); + if prepared_rtcp_listen_info.is_some() { + table_writer + .write_entry::<::planus::Offset>(2); } - if prepared_enable_srtp.is_some() { + 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_enable_rtx) = - prepared_enable_rtx + if let ::core::option::Option::Some(prepared_rtcp_listen_info) = + prepared_rtcp_listen_info { - object_writer.write::<_, _, 1>(&prepared_enable_rtx); + 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 PipeTransportOptions { + impl ::planus::WriteAs<::planus::Offset> for PlainTransportOptions { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for PipeTransportOptions { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for PipeTransportOptions { + impl ::planus::WriteAsOffset for PlainTransportOptions { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - PipeTransportOptions::create( + ) -> ::planus::Offset { + PlainTransportOptions::create( builder, &self.base, &self.listen_info, - self.enable_rtx, + &self.rtcp_listen_info, + self.rtcp_mux, + self.comedia, self.enable_srtp, + self.srtp_crypto_suite, ) } } - /// Builder for serializing an instance of the [PipeTransportOptions] type. + /// Builder for serializing an instance of the [PlainTransportOptions] type. /// - /// Can be created using the [PipeTransportOptions::builder] method. + /// Can be created using the [PlainTransportOptions::builder] method. #[derive(Debug)] #[must_use] - pub struct PipeTransportOptionsBuilder(State); + pub struct PlainTransportOptionsBuilder(State); - impl PipeTransportOptionsBuilder<()> { - /// Setter for the [`base` field](PipeTransportOptions#structfield.base). + impl PlainTransportOptionsBuilder<()> { + /// Setter for the [`base` field](PlainTransportOptions#structfield.base). #[inline] #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> PipeTransportOptionsBuilder<(T0,)> + pub fn base(self, value: T0) -> PlainTransportOptionsBuilder<(T0,)> where T0: ::planus::WriteAs<::planus::Offset>, { - PipeTransportOptionsBuilder((value,)) + PlainTransportOptionsBuilder((value,)) } } - impl PipeTransportOptionsBuilder<(T0,)> { - /// Setter for the [`listen_info` field](PipeTransportOptions#structfield.listen_info). + 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) -> PipeTransportOptionsBuilder<(T0, T1)> + pub fn listen_info(self, value: T1) -> PlainTransportOptionsBuilder<(T0, T1)> where T1: ::planus::WriteAs<::planus::Offset>, { let (v0,) = self.0; - PipeTransportOptionsBuilder((v0, value)) + PlainTransportOptionsBuilder((v0, value)) } } - impl PipeTransportOptionsBuilder<(T0, T1)> { - /// Setter for the [`enable_rtx` field](PipeTransportOptions#structfield.enable_rtx). + impl PlainTransportOptionsBuilder<(T0, T1)> { + /// Setter for the [`rtcp_listen_info` field](PlainTransportOptions#structfield.rtcp_listen_info). #[inline] #[allow(clippy::type_complexity)] - pub fn enable_rtx(self, value: T2) -> PipeTransportOptionsBuilder<(T0, T1, T2)> + pub fn rtcp_listen_info( + self, + value: T2, + ) -> PlainTransportOptionsBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsOptional<::planus::Offset>, { let (v0, v1) = self.0; - PipeTransportOptionsBuilder((v0, v1, value)) + PlainTransportOptionsBuilder((v0, v1, value)) } - /// Sets the [`enable_rtx` field](PipeTransportOptions#structfield.enable_rtx) to the default value. + /// Sets the [`rtcp_listen_info` field](PlainTransportOptions#structfield.rtcp_listen_info) to null. #[inline] #[allow(clippy::type_complexity)] - pub fn enable_rtx_as_default( + pub fn rtcp_listen_info_as_null( self, - ) -> PipeTransportOptionsBuilder<(T0, T1, ::planus::DefaultValue)> { - self.enable_rtx(::planus::DefaultValue) + ) -> PlainTransportOptionsBuilder<(T0, T1, ())> { + self.rtcp_listen_info(()) } } - impl PipeTransportOptionsBuilder<(T0, T1, T2)> { - /// Setter for the [`enable_srtp` field](PipeTransportOptions#structfield.enable_srtp). + impl PlainTransportOptionsBuilder<(T0, T1, T2)> { + /// Setter for the [`rtcp_mux` field](PlainTransportOptions#structfield.rtcp_mux). #[inline] #[allow(clippy::type_complexity)] - pub fn enable_srtp( + pub fn rtcp_mux( self, value: T3, - ) -> PipeTransportOptionsBuilder<(T0, T1, T2, T3)> + ) -> PlainTransportOptionsBuilder<(T0, T1, T2, T3)> where T3: ::planus::WriteAsDefault, { let (v0, v1, v2) = self.0; - PipeTransportOptionsBuilder((v0, v1, v2, value)) + PlainTransportOptionsBuilder((v0, v1, v2, value)) } - /// Sets the [`enable_srtp` field](PipeTransportOptions#structfield.enable_srtp) to the default 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, - ) -> PipeTransportOptionsBuilder<(T0, T1, T2, ::planus::DefaultValue)> + ) -> PlainTransportOptionsBuilder<(T0, T1, T2, T3, T4, ::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]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } @@ -69408,18 +71547,21 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsOptional<::planus::Offset>, T3: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for PipeTransportOptionsBuilder<(T0, T1, T2, T3)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } @@ -69427,18 +71569,21 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsOptional<::planus::Offset>, T3: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for PipeTransportOptionsBuilder<(T0, T1, T2, T3)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } @@ -69447,76 +71592,120 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsOptional<::planus::Offset>, T3: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for PipeTransportOptionsBuilder<(T0, T1, T2, T3)> + 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) = &self.0; - PipeTransportOptions::create(builder, v0, v1, v2, v3) + ) -> ::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 [PipeTransportOptions]. + /// Reference to a deserialized [PlainTransportOptions]. #[derive(Copy, Clone)] - pub struct PipeTransportOptionsRef<'a>(::planus::table_reader::Table<'a>); + pub struct PlainTransportOptionsRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> PipeTransportOptionsRef<'a> { - /// Getter for the [`base` field](PipeTransportOptions#structfield.base). + impl<'a> PlainTransportOptionsRef<'a> { + /// Getter for the [`base` field](PlainTransportOptions#structfield.base). #[inline] pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "PipeTransportOptions", "base") + self.0.access_required(0, "PlainTransportOptions", "base") } - /// Getter for the [`listen_info` field](PipeTransportOptions#structfield.listen_info). + /// Getter for the [`listen_info` field](PlainTransportOptions#structfield.listen_info). #[inline] pub fn listen_info(&self) -> ::planus::Result> { self.0 - .access_required(1, "PipeTransportOptions", "listen_info") + .access_required(1, "PlainTransportOptions", "listen_info") } - /// Getter for the [`enable_rtx` field](PipeTransportOptions#structfield.enable_rtx). + /// Getter for the [`rtcp_listen_info` field](PlainTransportOptions#structfield.rtcp_listen_info). #[inline] - pub fn enable_rtx(&self) -> ::planus::Result { + 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(2, "PipeTransportOptions", "enable_rtx")? + .access(3, "PlainTransportOptions", "rtcp_mux")? .unwrap_or(false), ) } - /// Getter for the [`enable_srtp` field](PipeTransportOptions#structfield.enable_srtp). + /// 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(3, "PipeTransportOptions", "enable_srtp")? + .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 PipeTransportOptionsRef<'a> { + 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("PipeTransportOptionsRef"); + let mut f = f.debug_struct("PlainTransportOptionsRef"); f.field("base", &self.base()); f.field("listen_info", &self.listen_info()); - f.field("enable_rtx", &self.enable_rtx()); + 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 PipeTransportOptions { + impl<'a> ::core::convert::TryFrom> for PlainTransportOptions { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: PipeTransportOptionsRef<'a>) -> ::planus::Result { + 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()?, @@ -69524,13 +71713,32 @@ mod root { 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()?)?, + 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 PipeTransportOptionsRef<'a> { + impl<'a> ::planus::TableRead<'a> for PlainTransportOptionsRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -69542,7 +71750,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for PipeTransportOptionsRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for PlainTransportOptionsRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -69552,7 +71760,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[PipeTransportOptionsRef]", + "[PlainTransportOptionsRef]", "get", buffer.offset_from_start, ) @@ -69560,8 +71768,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for PipeTransportOptions { - type Value = ::planus::Offset; + 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 { @@ -69570,7 +71778,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -69585,7 +71793,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for PipeTransportOptionsRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for PlainTransportOptionsRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -69596,7 +71804,7 @@ mod root { ) .map_err(|error_kind| { error_kind.with_error_location( - "[PipeTransportOptionsRef]", + "[PlainTransportOptionsRef]", "read_as_root", 0, ) @@ -69604,10 +71812,10 @@ mod root { } } - /// The table `ConnectRequest` in the namespace `FBS.PipeTransport` + /// The table `ConnectRequest` in the namespace `FBS.PlainTransport` /// /// Generated from these locations: - /// * Table `ConnectRequest` in the file `../worker/fbs/pipeTransport.fbs:12` + /// * Table `ConnectRequest` in the file `../worker/fbs/plainTransport.fbs:17` #[derive( Clone, Debug, @@ -69621,15 +71829,29 @@ mod root { )] pub struct ConnectRequest { /// The field `ip` in the table `ConnectRequest` - pub ip: ::planus::alloc::string::String, + 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, + ::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] @@ -69640,30 +71862,38 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_ip: impl ::planus::WriteAs<::planus::Offset>, + 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, >, ) -> ::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<10> = + let mut table_writer: ::planus::table_writer::TableWriter<12> = ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); + if prepared_ip.is_some() { + table_writer.write_entry::<::planus::Offset>(0); + } if prepared_srtp_parameters.is_some() { - table_writer - .write_entry::<::planus::Offset>(2); + 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| { - object_writer.write::<_, _, 4>(&prepared_ip); + 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 { @@ -69672,6 +71902,11 @@ mod root { 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() @@ -69708,7 +71943,13 @@ mod root { &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - ConnectRequest::create(builder, &self.ip, self.port, &self.srtp_parameters) + ConnectRequest::create( + builder, + &self.ip, + self.port, + self.rtcp_port, + &self.srtp_parameters, + ) } } @@ -69725,10 +71966,17 @@ mod root { #[allow(clippy::type_complexity)] pub fn ip(self, value: T0) -> ConnectRequestBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset>, + 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,)> { @@ -69752,28 +72000,51 @@ mod root { } impl ConnectRequestBuilder<(T0, T1)> { - /// Setter for the [`srtp_parameters` field](ConnectRequest#structfield.srtp_parameters). + /// Setter for the [`rtcp_port` field](ConnectRequest#structfield.rtcp_port). #[inline] #[allow(clippy::type_complexity)] - pub fn srtp_parameters(self, value: T2) -> ConnectRequestBuilder<(T0, T1, T2)> + pub fn rtcp_port(self, value: T2) -> ConnectRequestBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAsOptional< - ::planus::Offset, - >, + 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, ())> { + pub fn srtp_parameters_as_null(self) -> ConnectRequestBuilder<(T0, T1, T2, ())> { self.srtp_parameters(()) } } - impl ConnectRequestBuilder<(T0, T1, T2)> { + impl ConnectRequestBuilder<(T0, T1, T2, T3)> { /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ConnectRequest]. #[inline] pub fn finish( @@ -69788,11 +72059,14 @@ mod root { } impl< - T0: ::planus::WriteAs<::planus::Offset>, + T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional<::planus::Offset>, + T2: ::planus::WriteAsOptional, + T3: ::planus::WriteAsOptional< + ::planus::Offset, + >, > ::planus::WriteAs<::planus::Offset> - for ConnectRequestBuilder<(T0, T1, T2)> + for ConnectRequestBuilder<(T0, T1, T2, T3)> { type Prepared = ::planus::Offset; @@ -69806,11 +72080,14 @@ mod root { } impl< - T0: ::planus::WriteAs<::planus::Offset>, + T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional<::planus::Offset>, + T2: ::planus::WriteAsOptional, + T3: ::planus::WriteAsOptional< + ::planus::Offset, + >, > ::planus::WriteAsOptional<::planus::Offset> - for ConnectRequestBuilder<(T0, T1, T2)> + for ConnectRequestBuilder<(T0, T1, T2, T3)> { type Prepared = ::planus::Offset; @@ -69824,18 +72101,22 @@ mod root { } impl< - T0: ::planus::WriteAs<::planus::Offset>, + T0: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, T1: ::planus::WriteAsOptional, - T2: ::planus::WriteAsOptional<::planus::Offset>, - > ::planus::WriteAsOffset for ConnectRequestBuilder<(T0, T1, T2)> + 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) = &self.0; - ConnectRequest::create(builder, v0, v1, v2) + let (v0, v1, v2, v3) = &self.0; + ConnectRequest::create(builder, v0, v1, v2, v3) } } @@ -69846,8 +72127,11 @@ mod root { 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") + 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). @@ -69856,23 +72140,37 @@ mod root { 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(2, "ConnectRequest", "srtp_parameters") + ) -> ::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"); - f.field("ip", &self.ip()); + 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() { @@ -69888,12 +72186,25 @@ mod root { #[allow(unreachable_code)] fn try_from(value: ConnectRequestRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - ip: ::core::convert::TryInto::try_into(value.ip()?)?, + 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()? { @@ -69977,10 +72288,10 @@ mod root { } } - /// The table `ConnectResponse` in the namespace `FBS.PipeTransport` + /// The table `ConnectResponse` in the namespace `FBS.PlainTransport` /// /// Generated from these locations: - /// * Table `ConnectResponse` in the file `../worker/fbs/pipeTransport.fbs:18` + /// * Table `ConnectResponse` in the file `../worker/fbs/plainTransport.fbs:24` #[derive( Clone, Debug, @@ -69994,17 +72305,14 @@ mod root { )] pub struct ConnectResponse { /// The field `tuple` in the table `ConnectResponse` - pub tuple: + pub tuple: ::planus::alloc::boxed::Box, + /// The field `rtcp_tuple` in the table `ConnectResponse` + pub rtcp_tuple: ::core::option::Option<::planus::alloc::boxed::Box>, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for ConnectResponse { - fn default() -> Self { - Self { - tuple: ::core::default::Default::default(), - } - } + /// The field `srtp_parameters` in the table `ConnectResponse` + pub srtp_parameters: ::core::option::Option< + ::planus::alloc::boxed::Box, + >, } impl ConnectResponse { @@ -70017,22 +72325,40 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_tuple: impl ::planus::WriteAsOptional< + 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<6> = + let mut table_writer: ::planus::table_writer::TableWriter<10> = ::core::default::Default::default(); - if prepared_tuple.is_some() { - table_writer.write_entry::<::planus::Offset>(0); + 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| { - if let ::core::option::Option::Some(prepared_tuple) = prepared_tuple { - object_writer.write::<_, _, 4>(&prepared_tuple); + 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); } }); } @@ -70070,7 +72396,12 @@ mod root { &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - ConnectResponse::create(builder, &self.tuple) + ConnectResponse::create( + builder, + &self.tuple, + &self.rtcp_tuple, + &self.srtp_parameters, + ) } } @@ -70087,20 +72418,55 @@ mod root { #[allow(clippy::type_complexity)] pub fn tuple(self, value: T0) -> ConnectResponseBuilder<(T0,)> where - T0: ::planus::WriteAsOptional<::planus::Offset>, + 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 [`tuple` field](ConnectResponse#structfield.tuple) to null. + /// Sets the [`rtcp_tuple` field](ConnectResponse#structfield.rtcp_tuple) to null. #[inline] #[allow(clippy::type_complexity)] - pub fn tuple_as_null(self) -> ConnectResponseBuilder<((),)> { - self.tuple(()) + pub fn rtcp_tuple_as_null(self) -> ConnectResponseBuilder<(T0, ())> { + self.rtcp_tuple(()) } } - impl ConnectResponseBuilder<(T0,)> { + 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( @@ -70114,9 +72480,14 @@ mod root { } } - impl>> - ::planus::WriteAs<::planus::Offset> - for ConnectResponseBuilder<(T0,)> + 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; @@ -70129,9 +72500,14 @@ mod root { } } - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for ConnectResponseBuilder<(T0,)> + 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; @@ -70144,16 +72520,22 @@ mod root { } } - impl>> - ::planus::WriteAsOffset for ConnectResponseBuilder<(T0,)> + 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,) = &self.0; - ConnectResponse::create(builder, v0) + let (v0, v1, v2) = &self.0; + ConnectResponse::create(builder, v0, v1, v2) } } @@ -70164,19 +72546,43 @@ mod root { impl<'a> ConnectResponseRef<'a> { /// Getter for the [`tuple` field](ConnectResponse#structfield.tuple). #[inline] - pub fn tuple( + 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(0, "ConnectResponse", "tuple") + 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"); - if let ::core::option::Option::Some(field_tuple) = self.tuple().transpose() { - f.field("tuple", &field_tuple); + 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() } @@ -70188,9 +72594,23 @@ mod root { #[allow(unreachable_code)] fn try_from(value: ConnectResponseRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - tuple: if let ::core::option::Option::Some(tuple) = value.tuple()? { + 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(tuple)?, + ::core::convert::TryInto::try_into(srtp_parameters)?, )) } else { ::core::option::Option::None @@ -70269,10 +72689,10 @@ mod root { } } - /// The table `DumpResponse` in the namespace `FBS.PipeTransport` + /// The table `DumpResponse` in the namespace `FBS.PlainTransport` /// /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/pipeTransport.fbs:22` + /// * Table `DumpResponse` in the file `../worker/fbs/plainTransport.fbs:30` #[derive( Clone, Debug, @@ -70287,13 +72707,18 @@ mod root { 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 `rtx` in the table `DumpResponse` - pub rtx: bool, + /// 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, + ::planus::alloc::boxed::Box, >, } @@ -70308,26 +72733,37 @@ mod root { 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_rtx: impl ::planus::WriteAsDefault, + field_rtcp_tuple: impl ::planus::WriteAsOptional< + ::planus::Offset, + >, field_srtp_parameters: impl ::planus::WriteAsOptional< - ::planus::Offset, + ::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_rtx = field_rtx.prepare(builder, &false); + 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<12> = + 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>(1); + 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>(3); + table_writer.write_entry::<::planus::Offset>(5); } - if prepared_rtx.is_some() { + if prepared_rtcp_mux.is_some() { + table_writer.write_entry::(1); + } + if prepared_comedia.is_some() { table_writer.write_entry::(2); } @@ -70335,13 +72771,24 @@ mod root { 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_rtx) = prepared_rtx { - object_writer.write::<_, _, 1>(&prepared_rtx); + 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); } }); } @@ -70382,8 +72829,10 @@ mod root { DumpResponse::create( builder, &self.base, + self.rtcp_mux, + self.comedia, &self.tuple, - self.rtx, + &self.rtcp_tuple, &self.srtp_parameters, ) } @@ -70409,23 +72858,32 @@ mod root { } impl DumpResponseBuilder<(T0,)> { - /// Setter for the [`tuple` field](DumpResponse#structfield.tuple). + /// Setter for the [`rtcp_mux` field](DumpResponse#structfield.rtcp_mux). #[inline] #[allow(clippy::type_complexity)] - pub fn tuple(self, value: T1) -> DumpResponseBuilder<(T0, T1)> + pub fn rtcp_mux(self, value: T1) -> DumpResponseBuilder<(T0, T1)> where - T1: ::planus::WriteAs<::planus::Offset>, + 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 [`rtx` field](DumpResponse#structfield.rtx). + /// Setter for the [`comedia` field](DumpResponse#structfield.comedia). #[inline] #[allow(clippy::type_complexity)] - pub fn rtx(self, value: T2) -> DumpResponseBuilder<(T0, T1, T2)> + pub fn comedia(self, value: T2) -> DumpResponseBuilder<(T0, T1, T2)> where T2: ::planus::WriteAsDefault, { @@ -70433,39 +72891,77 @@ mod root { DumpResponseBuilder((v0, v1, value)) } - /// Sets the [`rtx` field](DumpResponse#structfield.rtx) to the default value. + /// Sets the [`comedia` field](DumpResponse#structfield.comedia) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn rtx_as_default( + pub fn comedia_as_default( self, ) -> DumpResponseBuilder<(T0, T1, ::planus::DefaultValue)> { - self.rtx(::planus::DefaultValue) + self.comedia(::planus::DefaultValue) } } impl DumpResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`srtp_parameters` field](DumpResponse#structfield.srtp_parameters). + /// Setter for the [`tuple` field](DumpResponse#structfield.tuple). #[inline] #[allow(clippy::type_complexity)] - pub fn srtp_parameters(self, value: T3) -> DumpResponseBuilder<(T0, T1, T2, T3)> + pub fn tuple(self, value: T3) -> DumpResponseBuilder<(T0, T1, T2, T3)> where - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, + 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, ())> { + pub fn srtp_parameters_as_null( + self, + ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, ())> { self.srtp_parameters(()) } } - impl DumpResponseBuilder<(T0, T1, T2, T3)> { + 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( @@ -70481,11 +72977,15 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional<::planus::Offset>, + 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)> + for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> { type Prepared = ::planus::Offset; @@ -70500,11 +73000,15 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional<::planus::Offset>, + 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)> + for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> { type Prepared = ::planus::Offset; @@ -70519,18 +73023,23 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsOptional<::planus::Offset>, - > ::planus::WriteAsOffset for DumpResponseBuilder<(T0, T1, T2, T3)> + 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) = &self.0; - DumpResponse::create(builder, v0, v1, v2, v3) + let (v0, v1, v2, v3, v4, v5) = &self.0; + DumpResponse::create(builder, v0, v1, v2, v3, v4, v5) } } @@ -70545,27 +73054,49 @@ mod root { self.0.access_required(0, "DumpResponse", "base") } - /// Getter for the [`tuple` field](DumpResponse#structfield.tuple). + /// Getter for the [`rtcp_mux` field](DumpResponse#structfield.rtcp_mux). #[inline] - pub fn tuple(&self) -> ::planus::Result> { - self.0.access_required(1, "DumpResponse", "tuple") + pub fn rtcp_mux(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(1, "DumpResponse", "rtcp_mux")? + .unwrap_or(false), + ) } - /// Getter for the [`rtx` field](DumpResponse#structfield.rtx). + /// Getter for the [`comedia` field](DumpResponse#structfield.comedia). #[inline] - pub fn rtx(&self) -> ::planus::Result { + pub fn comedia(&self) -> ::planus::Result { ::core::result::Result::Ok( - self.0.access(2, "DumpResponse", "rtx")?.unwrap_or(false), + 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(3, "DumpResponse", "srtp_parameters") + ) -> ::planus::Result< + ::core::option::Option>, + > { + self.0.access(5, "DumpResponse", "srtp_parameters") } } @@ -70573,8 +73104,14 @@ mod root { 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()); - f.field("rtx", &self.rtx()); + 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() { @@ -70593,10 +73130,20 @@ mod root { 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()?)?, ), - rtx: ::core::convert::TryInto::try_into(value.rtx()?)?, + 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()? { @@ -70680,18 +73227,25 @@ mod root { } } - /// The table `GetStatsResponse` in the namespace `FBS.PipeTransport` + /// The table `GetStatsResponse` in the namespace `FBS.PlainTransport` /// /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/pipeTransport.fbs:29` + /// * 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 { @@ -70705,20 +73259,51 @@ mod root { 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<8> = + 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>(1); + 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() @@ -70751,47 +73336,121 @@ mod root { impl ::planus::WriteAsOffset for GetStatsResponse { #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - GetStatsResponse::create(builder, &self.base, &self.tuple) + 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) } } - /// 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). + impl GetStatsResponseBuilder<(T0, T1, T2)> { + /// Setter for the [`tuple` field](GetStatsResponse#structfield.tuple). #[inline] #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> GetStatsResponseBuilder<(T0,)> + pub fn tuple(self, value: T3) -> GetStatsResponseBuilder<(T0, T1, T2, T3)> where - T0: ::planus::WriteAs<::planus::Offset>, + T3: ::planus::WriteAs<::planus::Offset>, { - GetStatsResponseBuilder((value,)) + let (v0, v1, v2) = self.0; + GetStatsResponseBuilder((v0, v1, v2, value)) } } - impl GetStatsResponseBuilder<(T0,)> { - /// Setter for the [`tuple` field](GetStatsResponse#structfield.tuple). + impl GetStatsResponseBuilder<(T0, T1, T2, T3)> { + /// Setter for the [`rtcp_tuple` field](GetStatsResponse#structfield.rtcp_tuple). #[inline] #[allow(clippy::type_complexity)] - pub fn tuple(self, value: T1) -> GetStatsResponseBuilder<(T0, T1)> + pub fn rtcp_tuple( + self, + value: T4, + ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> where - T1: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAsOptional<::planus::Offset>, { - let (v0,) = self.0; - GetStatsResponseBuilder((v0, value)) + 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)> { + 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( @@ -70807,9 +73466,12 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::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)> + for GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> { type Prepared = ::planus::Offset; @@ -70824,9 +73486,12 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::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)> + for GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> { type Prepared = ::planus::Offset; @@ -70841,16 +73506,20 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOffset for GetStatsResponseBuilder<(T0, T1)> + 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) = &self.0; - GetStatsResponse::create(builder, v0, v1) + let (v0, v1, v2, v3, v4) = &self.0; + GetStatsResponse::create(builder, v0, v1, v2, v3, v4) } } @@ -70865,10 +73534,39 @@ mod root { 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(1, "GetStatsResponse", "tuple") + 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") } } @@ -70876,7 +73574,14 @@ mod root { 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() } } @@ -70890,9 +73595,20 @@ mod root { 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 + }, }) } } @@ -70966,16 +73682,11 @@ mod root { }) } } - } - /// 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` + + /// The table `TupleNotification` in the namespace `FBS.PlainTransport` /// /// Generated from these locations: - /// * Table `PlainTransportOptions` in the file `../worker/fbs/plainTransport.fbs:6` + /// * Table `TupleNotification` in the file `../worker/fbs/plainTransport.fbs:49` #[derive( Clone, Debug, @@ -70987,525 +73698,182 @@ mod root { ::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<::planus::alloc::string::String>, + pub struct TupleNotification { + /// The field `tuple` in the table `TupleNotification` + pub tuple: ::planus::alloc::boxed::Box, } - impl PlainTransportOptions { - /// Creates a [PlainTransportOptionsBuilder] for serializing an instance of this table. + impl TupleNotification { + /// Creates a [TupleNotificationBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> PlainTransportOptionsBuilder<()> { - PlainTransportOptionsBuilder(()) + pub fn builder() -> TupleNotificationBuilder<()> { + TupleNotificationBuilder(()) } #[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< - ::planus::Offset<::core::primitive::str>, - >, + field_tuple: impl ::planus::WriteAs<::planus::Offset>, ) -> ::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 prepared_tuple = field_tuple.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<18> = + let mut table_writer: ::planus::table_writer::TableWriter<6> = ::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_srtp_crypto_suite.is_some() { - table_writer.write_entry::<::planus::Offset>(6); - } - 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); - } + table_writer.write_entry::<::planus::Offset>(0); 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_srtp_crypto_suite) = - prepared_srtp_crypto_suite - { - object_writer.write::<_, _, 4>(&prepared_srtp_crypto_suite); - } - 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); - } + object_writer.write::<_, _, 4>(&prepared_tuple); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for PlainTransportOptions { + impl ::planus::WriteAs<::planus::Offset> for TupleNotification { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for PlainTransportOptions { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for PlainTransportOptions { + impl ::planus::WriteAsOffset for TupleNotification { #[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, - ) + ) -> ::planus::Offset { + TupleNotification::create(builder, &self.tuple) } } - /// Builder for serializing an instance of the [PlainTransportOptions] type. + /// Builder for serializing an instance of the [TupleNotification] type. /// - /// Can be created using the [PlainTransportOptions::builder] method. + /// Can be created using the [TupleNotification::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) - } - } + pub struct TupleNotificationBuilder(State); - impl PlainTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`srtp_crypto_suite` field](PlainTransportOptions#structfield.srtp_crypto_suite). + impl TupleNotificationBuilder<()> { + /// Setter for the [`tuple` field](TupleNotification#structfield.tuple). #[inline] #[allow(clippy::type_complexity)] - pub fn srtp_crypto_suite( - self, - value: T6, - ) -> PlainTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5, T6)> + pub fn tuple(self, value: T0) -> TupleNotificationBuilder<(T0,)> where - T6: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T0: ::planus::WriteAs<::planus::Offset>, { - 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(()) + TupleNotificationBuilder((value,)) } } - impl PlainTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [PlainTransportOptions]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + 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::Offset<::core::primitive::str>>, - > ::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::Offset<::core::primitive::str>>, - > ::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::Offset<::core::primitive::str>>, - > ::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") - } + impl>> + ::planus::WriteAs<::planus::Offset> + for TupleNotificationBuilder<(T0,)> + { + type Prepared = ::planus::Offset; - /// 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), - ) + 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; - /// 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), - ) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } + } - /// Getter for the [`enable_srtp` field](PlainTransportOptions#structfield.enable_srtp). + impl>> + ::planus::WriteAsOffset for TupleNotificationBuilder<(T0,)> + { #[inline] - pub fn enable_srtp(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "PlainTransportOptions", "enable_srtp")? - .unwrap_or(false), - ) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + let (v0,) = &self.0; + TupleNotification::create(builder, v0) } + } - /// Getter for the [`srtp_crypto_suite` field](PlainTransportOptions#structfield.srtp_crypto_suite). + /// 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 srtp_crypto_suite( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0 - .access(6, "PlainTransportOptions", "srtp_crypto_suite") + pub fn tuple(&self) -> ::planus::Result> { + self.0.access_required(0, "TupleNotification", "tuple") } } - impl<'a> ::core::fmt::Debug for PlainTransportOptionsRef<'a> { + 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("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); - } + let mut f = f.debug_struct("TupleNotificationRef"); + f.field("tuple", &self.tuple()); f.finish() } } - impl<'a> ::core::convert::TryFrom> for PlainTransportOptions { + impl<'a> ::core::convert::TryFrom> for TupleNotification { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: PlainTransportOptionsRef<'a>) -> ::planus::Result { + fn try_from(value: TupleNotificationRef<'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()?)?, + tuple: ::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(value.tuple()?)?, ), - 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> { + impl<'a> ::planus::TableRead<'a> for TupleNotificationRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -71517,7 +73885,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for PlainTransportOptionsRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for TupleNotificationRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -71527,7 +73895,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[PlainTransportOptionsRef]", + "[TupleNotificationRef]", "get", buffer.offset_from_start, ) @@ -71535,8 +73903,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for PlainTransportOptions { - type Value = ::planus::Offset; + 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 { @@ -71545,7 +73913,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -71560,7 +73928,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for PlainTransportOptionsRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for TupleNotificationRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -71570,19 +73938,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location( - "[PlainTransportOptionsRef]", - "read_as_root", - 0, - ) + error_kind.with_error_location("[TupleNotificationRef]", "read_as_root", 0) }) } } - /// The table `ConnectRequest` in the namespace `FBS.PlainTransport` + /// The table `RtcpTupleNotification` in the namespace `FBS.PlainTransport` /// /// Generated from these locations: - /// * Table `ConnectRequest` in the file `../worker/fbs/plainTransport.fbs:16` + /// * Table `RtcpTupleNotification` in the file `../worker/fbs/plainTransport.fbs:53` #[derive( Clone, Debug, @@ -71594,392 +73958,185 @@ mod root { ::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(), - } - } + pub struct RtcpTupleNotification { + /// The field `tuple` in the table `RtcpTupleNotification` + pub tuple: ::planus::alloc::boxed::Box, } - impl ConnectRequest { - /// Creates a [ConnectRequestBuilder] for serializing an instance of this table. + impl RtcpTupleNotification { + /// Creates a [RtcpTupleNotificationBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> ConnectRequestBuilder<()> { - ConnectRequestBuilder(()) + pub fn builder() -> RtcpTupleNotificationBuilder<()> { + RtcpTupleNotificationBuilder(()) } #[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, - >, + field_tuple: impl ::planus::WriteAs<::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 prepared_tuple = field_tuple.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<12> = + let mut table_writer: ::planus::table_writer::TableWriter<6> = ::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); - } + table_writer.write_entry::<::planus::Offset>(0); 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); - } + object_writer.write::<_, _, 4>(&prepared_tuple); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for ConnectRequest { + impl ::planus::WriteAs<::planus::Offset> for RtcpTupleNotification { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for ConnectRequest { + 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<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for ConnectRequest { + impl ::planus::WriteAsOffset for RtcpTupleNotification { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ConnectRequest::create( - builder, - &self.ip, - self.port, - self.rtcp_port, - &self.srtp_parameters, - ) + ) -> ::planus::Offset { + RtcpTupleNotification::create(builder, &self.tuple) } } - /// Builder for serializing an instance of the [ConnectRequest] type. + /// Builder for serializing an instance of the [RtcpTupleNotification] type. /// - /// Can be created using the [ConnectRequest::builder] method. + /// Can be created using the [RtcpTupleNotification::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(()) - } - } + pub struct RtcpTupleNotificationBuilder(State); - impl ConnectRequestBuilder<(T0, T1, T2)> { - /// Setter for the [`srtp_parameters` field](ConnectRequest#structfield.srtp_parameters). + impl RtcpTupleNotificationBuilder<()> { + /// Setter for the [`tuple` field](RtcpTupleNotification#structfield.tuple). #[inline] #[allow(clippy::type_complexity)] - pub fn srtp_parameters( - self, - value: T3, - ) -> ConnectRequestBuilder<(T0, T1, T2, T3)> + pub fn tuple(self, value: T0) -> RtcpTupleNotificationBuilder<(T0,)> where - T3: ::planus::WriteAsOptional< - ::planus::Offset, - >, + T0: ::planus::WriteAs<::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(()) + RtcpTupleNotificationBuilder((value,)) } } - impl ConnectRequestBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ConnectRequest]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + 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)> + impl>> + ::planus::WriteAs<::planus::Offset> + for RtcpTupleNotificationBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::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)> + impl>> + ::planus::WriteAsOptional<::planus::Offset> + for RtcpTupleNotificationBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::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)> + impl>> + ::planus::WriteAsOffset + for RtcpTupleNotificationBuilder<(T0,)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2, v3) = &self.0; - ConnectRequest::create(builder, v0, v1, v2, v3) + ) -> ::planus::Offset { + let (v0,) = &self.0; + RtcpTupleNotification::create(builder, v0) } } - /// Reference to a deserialized [ConnectRequest]. + /// Reference to a deserialized [RtcpTupleNotification]. #[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") - } + pub struct RtcpTupleNotificationRef<'a>(::planus::table_reader::Table<'a>); - /// Getter for the [`srtp_parameters` field](ConnectRequest#structfield.srtp_parameters). + impl<'a> RtcpTupleNotificationRef<'a> { + /// Getter for the [`tuple` field](RtcpTupleNotification#structfield.tuple). #[inline] - pub fn srtp_parameters( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(3, "ConnectRequest", "srtp_parameters") + pub fn tuple(&self) -> ::planus::Result> { + self.0.access_required(0, "RtcpTupleNotification", "tuple") } } - impl<'a> ::core::fmt::Debug for ConnectRequestRef<'a> { + 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("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); - } + let mut f = f.debug_struct("RtcpTupleNotificationRef"); + f.field("tuple", &self.tuple()); f.finish() } } - impl<'a> ::core::convert::TryFrom> for ConnectRequest { + impl<'a> ::core::convert::TryFrom> for RtcpTupleNotification { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: ConnectRequestRef<'a>) -> ::planus::Result { + fn try_from(value: RtcpTupleNotificationRef<'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 - }, + tuple: ::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(value.tuple()?)?, + ), }) } } - impl<'a> ::planus::TableRead<'a> for ConnectRequestRef<'a> { + impl<'a> ::planus::TableRead<'a> for RtcpTupleNotificationRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -71991,7 +74148,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for ConnectRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for RtcpTupleNotificationRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -72001,7 +74158,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[ConnectRequestRef]", + "[RtcpTupleNotificationRef]", "get", buffer.offset_from_start, ) @@ -72009,8 +74166,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for ConnectRequest { - type Value = ::planus::Offset; + 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 { @@ -72019,7 +74176,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -72034,7 +74191,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for ConnectRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for RtcpTupleNotificationRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -72044,337 +74201,227 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[ConnectRequestRef]", "read_as_root", 0) + error_kind.with_error_location( + "[RtcpTupleNotificationRef]", + "read_as_root", + 0, + ) }) } } - - /// The table `ConnectResponse` in the namespace `FBS.PlainTransport` + } + /// 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 `ConnectResponse` in the file `../worker/fbs/plainTransport.fbs:23` + /// * Table `ListenIndividual` in the file `../worker/fbs/webRtcTransport.fbs:6` #[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, - >, + 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 ConnectResponse { - /// Creates a [ConnectResponseBuilder] for serializing an instance of this table. + impl ListenIndividual { + /// Creates a [ListenIndividualBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> ConnectResponseBuilder<()> { - ConnectResponseBuilder(()) + pub fn builder() -> ListenIndividualBuilder<()> { + ListenIndividualBuilder(()) } #[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, + field_listen_infos: impl ::planus::WriteAs< + ::planus::Offset<[::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 prepared_listen_infos = field_listen_infos.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<10> = + let mut table_writer: ::planus::table_writer::TableWriter<6> = ::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); - } + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(0); 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); - } + object_writer.write::<_, _, 4>(&prepared_listen_infos); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for ConnectResponse { + impl ::planus::WriteAs<::planus::Offset> for ListenIndividual { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for ConnectResponse { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for ConnectResponse { + impl ::planus::WriteAsOffset for ListenIndividual { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ConnectResponse::create( - builder, - &self.tuple, - &self.rtcp_tuple, - &self.srtp_parameters, - ) + ) -> ::planus::Offset { + ListenIndividual::create(builder, &self.listen_infos) } } - /// Builder for serializing an instance of the [ConnectResponse] type. + /// Builder for serializing an instance of the [ListenIndividual] type. /// - /// Can be created using the [ConnectResponse::builder] method. + /// Can be created using the [ListenIndividual::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(()) - } - } + pub struct ListenIndividualBuilder(State); - impl ConnectResponseBuilder<(T0, T1)> { - /// Setter for the [`srtp_parameters` field](ConnectResponse#structfield.srtp_parameters). + impl ListenIndividualBuilder<()> { + /// Setter for the [`listen_infos` field](ListenIndividual#structfield.listen_infos). #[inline] #[allow(clippy::type_complexity)] - pub fn srtp_parameters(self, value: T2) -> ConnectResponseBuilder<(T0, T1, T2)> + pub fn listen_infos(self, value: T0) -> ListenIndividualBuilder<(T0,)> where - T2: ::planus::WriteAsOptional< - ::planus::Offset, + T0: ::planus::WriteAs< + ::planus::Offset<[::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(()) + ListenIndividualBuilder((value,)) } } - impl ConnectResponseBuilder<(T0, T1, T2)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ConnectResponse]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + 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)> + T0: ::planus::WriteAs< + ::planus::Offset<[::planus::Offset]>, + >, + > ::planus::WriteAs<::planus::Offset> + for ListenIndividualBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::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)> + T0: ::planus::WriteAs< + ::planus::Offset<[::planus::Offset]>, + >, + > ::planus::WriteAsOptional<::planus::Offset> + for ListenIndividualBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::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)> + T0: ::planus::WriteAs< + ::planus::Offset<[::planus::Offset]>, + >, + > ::planus::WriteAsOffset for ListenIndividualBuilder<(T0,)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2) = &self.0; - ConnectResponse::create(builder, v0, v1, v2) + ) -> ::planus::Offset { + let (v0,) = &self.0; + ListenIndividual::create(builder, v0) } } - /// Reference to a deserialized [ConnectResponse]. + /// Reference to a deserialized [ListenIndividual]. #[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") - } + pub struct ListenIndividualRef<'a>(::planus::table_reader::Table<'a>); - /// Getter for the [`srtp_parameters` field](ConnectResponse#structfield.srtp_parameters). + impl<'a> ListenIndividualRef<'a> { + /// Getter for the [`listen_infos` field](ListenIndividual#structfield.listen_infos). #[inline] - pub fn srtp_parameters( + pub fn listen_infos( &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(2, "ConnectResponse", "srtp_parameters") + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result>>, + > { + self.0 + .access_required(0, "ListenIndividual", "listen_infos") } } - impl<'a> ::core::fmt::Debug for ConnectResponseRef<'a> { + 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("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); - } + let mut f = f.debug_struct("ListenIndividualRef"); + f.field("listen_infos", &self.listen_infos()); f.finish() } } - impl<'a> ::core::convert::TryFrom> for ConnectResponse { + impl<'a> ::core::convert::TryFrom> for ListenIndividual { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: ConnectResponseRef<'a>) -> ::planus::Result { + fn try_from(value: ListenIndividualRef<'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 - }, + listen_infos: value.listen_infos()?.to_vec_result()?, }) } } - impl<'a> ::planus::TableRead<'a> for ConnectResponseRef<'a> { + impl<'a> ::planus::TableRead<'a> for ListenIndividualRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -72386,7 +74433,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for ConnectResponseRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for ListenIndividualRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -72396,7 +74443,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[ConnectResponseRef]", + "[ListenIndividualRef]", "get", buffer.offset_from_start, ) @@ -72404,8 +74451,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for ConnectResponse { - type Value = ::planus::Offset; + 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 { @@ -72414,7 +74461,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -72429,7 +74476,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for ConnectResponseRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for ListenIndividualRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -72439,15 +74486,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[ConnectResponseRef]", "read_as_root", 0) + error_kind.with_error_location("[ListenIndividualRef]", "read_as_root", 0) }) } } - /// The table `DumpResponse` in the namespace `FBS.PlainTransport` + /// The table `ListenServer` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/plainTransport.fbs:29` + /// * Table `ListenServer` in the file `../worker/fbs/webRtcTransport.fbs:10` #[derive( Clone, Debug, @@ -72459,454 +74506,182 @@ mod root { ::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, - >, + pub struct ListenServer { + /// The field `web_rtc_server_id` in the table `ListenServer` + pub web_rtc_server_id: ::planus::alloc::string::String, } - impl DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. + impl ListenServer { + /// Creates a [ListenServerBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) + pub fn builder() -> ListenServerBuilder<()> { + ListenServerBuilder(()) } #[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, - >, + field_web_rtc_server_id: impl ::planus::WriteAs<::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 prepared_web_rtc_server_id = field_web_rtc_server_id.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<16> = + let mut table_writer: ::planus::table_writer::TableWriter<6> = ::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); - } + table_writer.write_entry::<::planus::Offset>(0); 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); - } + object_writer.write::<_, _, 4>(&prepared_web_rtc_server_id); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for DumpResponse { + impl ::planus::WriteAs<::planus::Offset> for ListenServer { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for DumpResponse { + impl ::planus::WriteAsOffset for ListenServer { #[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, - ) + ) -> ::planus::Offset { + ListenServer::create(builder, &self.web_rtc_server_id) } } - /// Builder for serializing an instance of the [DumpResponse] type. + /// Builder for serializing an instance of the [ListenServer] type. /// - /// Can be created using the [DumpResponse::builder] method. + /// Can be created using the [ListenServer::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(()) - } - } + pub struct ListenServerBuilder(State); - impl DumpResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`srtp_parameters` field](DumpResponse#structfield.srtp_parameters). + impl ListenServerBuilder<()> { + /// Setter for the [`web_rtc_server_id` field](ListenServer#structfield.web_rtc_server_id). #[inline] #[allow(clippy::type_complexity)] - pub fn srtp_parameters( - self, - value: T5, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> + pub fn web_rtc_server_id(self, value: T0) -> ListenServerBuilder<(T0,)> where - T5: ::planus::WriteAsOptional< - ::planus::Offset, - >, + T0: ::planus::WriteAs<::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(()) + ListenServerBuilder((value,)) } } - impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. + 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 + ) -> ::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)> + Self: ::planus::WriteAsOffset, + { + ::planus::WriteAsOffset::prepare(&self, builder) + } + } + + impl>> + ::planus::WriteAs<::planus::Offset> for ListenServerBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::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)> + impl>> + ::planus::WriteAsOptional<::planus::Offset> + for ListenServerBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::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)> + impl>> ::planus::WriteAsOffset + for ListenServerBuilder<(T0,)> { #[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) + ) -> ::planus::Offset { + let (v0,) = &self.0; + ListenServer::create(builder, v0) } } - /// Reference to a deserialized [DumpResponse]. + /// Reference to a deserialized [ListenServer]. #[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") - } + pub struct ListenServerRef<'a>(::planus::table_reader::Table<'a>); - /// Getter for the [`srtp_parameters` field](DumpResponse#structfield.srtp_parameters). + impl<'a> ListenServerRef<'a> { + /// Getter for the [`web_rtc_server_id` field](ListenServer#structfield.web_rtc_server_id). #[inline] - pub fn srtp_parameters( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(5, "DumpResponse", "srtp_parameters") + 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 DumpResponseRef<'a> { + 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("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); - } + 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 DumpResponse { + impl<'a> ::core::convert::TryFrom> for ListenServer { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { + fn try_from(value: ListenServerRef<'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 - }, + web_rtc_server_id: ::core::convert::TryInto::try_into( + value.web_rtc_server_id()?, + )?, }) } } - impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { + impl<'a> ::planus::TableRead<'a> for ListenServerRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -72918,7 +74693,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for ListenServerRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -72928,7 +74703,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[DumpResponseRef]", + "[ListenServerRef]", "get", buffer.offset_from_start, ) @@ -72936,8 +74711,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; + 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 { @@ -72946,7 +74721,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -72961,7 +74736,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for ListenServerRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -72971,471 +74746,229 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) + error_kind.with_error_location("[ListenServerRef]", "read_as_root", 0) }) } } - /// The table `GetStatsResponse` in the namespace `FBS.PlainTransport` + /// The union `Listen` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/plainTransport.fbs:38` + /// * Union `Listen` in the file `../worker/fbs/webRtcTransport.fbs:14` #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, + Clone, + Debug, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + ::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>, + 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 GetStatsResponse { - /// Creates a [GetStatsResponseBuilder] for serializing an instance of this table. + impl Listen { + /// Creates a [ListenBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> GetStatsResponseBuilder<()> { - GetStatsResponseBuilder(()) + pub fn builder() -> ListenBuilder<::planus::Uninitialized> { + ListenBuilder(::planus::Uninitialized) } - #[allow(clippy::too_many_arguments)] - pub fn create( + #[inline] + pub fn create_listen_individual( 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() + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) } - } - - impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; #[inline] - fn prepare( - &self, + pub fn create_listen_server( builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) } } - impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { - type Prepared = ::planus::Offset; - + impl ::planus::WriteAsUnion for Listen { #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + 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::WriteAsOffset for GetStatsResponse { + impl ::planus::WriteAsOptionalUnion for Listen { #[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, - ) + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - /// Builder for serializing an instance of the [GetStatsResponse] type. + /// Builder for serializing an instance of the [Listen] type. /// - /// Can be created using the [GetStatsResponse::builder] method. + /// Can be created using the [Listen::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)) - } + pub struct ListenBuilder(T); - /// Sets the [`comedia` field](GetStatsResponse#structfield.comedia) to the default value. + impl ListenBuilder<::planus::Uninitialized> { + /// Creates an instance of the [`ListenIndividual` variant](Listen#variant.ListenIndividual). #[inline] - #[allow(clippy::type_complexity)] - pub fn comedia_as_default( + pub fn listen_individual( 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)> + value: T, + ) -> ListenBuilder<::planus::Initialized<1, T>> where - T3: ::planus::WriteAs<::planus::Offset>, + T: ::planus::WriteAsOffset, { - let (v0, v1, v2) = self.0; - GetStatsResponseBuilder((v0, v1, v2, value)) + ListenBuilder(::planus::Initialized(value)) } - } - impl GetStatsResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`rtcp_tuple` field](GetStatsResponse#structfield.rtcp_tuple). + /// Creates an instance of the [`ListenServer` variant](Listen#variant.ListenServer). #[inline] - #[allow(clippy::type_complexity)] - pub fn rtcp_tuple( + pub fn listen_server( self, - value: T4, - ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> + value: T, + ) -> ListenBuilder<::planus::Initialized<2, T>> where - T4: ::planus::WriteAsOptional<::planus::Offset>, + T: ::planus::WriteAsOffset, { - 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(()) + ListenBuilder(::planus::Initialized(value)) } } - impl GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [GetStatsResponse]. + 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::Offset + ) -> ::planus::UnionOffset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsUnion, { - ::planus::WriteAsOffset::prepare(&self, builder) + ::planus::WriteAsUnion::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)> + impl ::planus::WriteAsUnion for ListenBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, { - type Prepared = ::planus::Offset; - #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) } } - 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)> + impl ::planus::WriteAsOptionalUnion for ListenBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, { - type Prepared = ::planus::Offset; - #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::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)> + impl ::planus::WriteAsUnion for ListenBuilder<::planus::Initialized<2, T>> + where + T: ::planus::WriteAsOffset, { #[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) + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) } } - /// 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). + impl ::planus::WriteAsOptionalUnion for ListenBuilder<::planus::Initialized<2, T>> + where + T: ::planus::WriteAsOffset, + { #[inline] - pub fn rtcp_tuple( + fn prepare( &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(4, "GetStatsResponse", "rtcp_tuple") + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - 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() - } + /// 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 GetStatsResponse { + impl<'a> ::core::convert::TryFrom> for Listen { 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)?, + 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)?, )) - } else { - ::core::option::Option::None - }, + } + + ListenRef::ListenServer(value) => { + Self::ListenServer(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } }) } } - impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { - #[inline] + impl<'a> ::planus::TableReadUnion<'a> for ListenRef<'a> { fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, + field_offset: usize, + tag: u8, ) -> ::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, - ); + 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 }, + ), } } } - 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` + /// The table `WebRtcTransportOptions` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `TupleNotification` in the file `../worker/fbs/plainTransport.fbs:48` + /// * Table `WebRtcTransportOptions` in the file `../worker/fbs/webRtcTransport.fbs:19` #[derive( Clone, Debug, @@ -73447,182 +74980,223 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct TupleNotification { - /// The field `tuple` in the table `TupleNotification` - pub tuple: ::planus::alloc::boxed::Box, + 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, } - impl TupleNotification { - /// Creates a [TupleNotificationBuilder] for serializing an instance of this table. + impl WebRtcTransportOptions { + /// Creates a [WebRtcTransportOptionsBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> TupleNotificationBuilder<()> { - TupleNotificationBuilder(()) + pub fn builder() -> WebRtcTransportOptionsBuilder<()> { + WebRtcTransportOptionsBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_tuple: impl ::planus::WriteAs<::planus::Offset>, + field_base: impl ::planus::WriteAs<::planus::Offset>, + field_listen: impl ::planus::WriteAsUnion, ) -> ::planus::Offset { - let prepared_tuple = field_tuple.prepare(builder); + let prepared_base = field_base.prepare(builder); + let prepared_listen = field_listen.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<6> = + 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>(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_tuple); + object_writer.write::<_, _, 4>(&prepared_base); + object_writer.write::<_, _, 4>(&prepared_listen.offset()); + object_writer.write::<_, _, 1>(&prepared_listen.tag()); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for TupleNotification { + impl ::planus::WriteAs<::planus::Offset> for WebRtcTransportOptions { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for TupleNotification { + 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<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for TupleNotification { + impl ::planus::WriteAsOffset for WebRtcTransportOptions { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - TupleNotification::create(builder, &self.tuple) + ) -> ::planus::Offset { + WebRtcTransportOptions::create(builder, &self.base, &self.listen) } } - /// Builder for serializing an instance of the [TupleNotification] type. + /// Builder for serializing an instance of the [WebRtcTransportOptions] type. /// - /// Can be created using the [TupleNotification::builder] method. + /// Can be created using the [WebRtcTransportOptions::builder] method. #[derive(Debug)] #[must_use] - pub struct TupleNotificationBuilder(State); + pub struct WebRtcTransportOptionsBuilder(State); - impl TupleNotificationBuilder<()> { - /// Setter for the [`tuple` field](TupleNotification#structfield.tuple). + impl WebRtcTransportOptionsBuilder<()> { + /// Setter for the [`base` field](WebRtcTransportOptions#structfield.base). #[inline] #[allow(clippy::type_complexity)] - pub fn tuple(self, value: T0) -> TupleNotificationBuilder<(T0,)> + pub fn base(self, value: T0) -> WebRtcTransportOptionsBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset>, + T0: ::planus::WriteAs<::planus::Offset>, { - TupleNotificationBuilder((value,)) + WebRtcTransportOptionsBuilder((value,)) } } - impl TupleNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [TupleNotification]. + 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)> { + /// 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl>> - ::planus::WriteAs<::planus::Offset> - for TupleNotificationBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsUnion, + > ::planus::WriteAs<::planus::Offset> + for WebRtcTransportOptionsBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for TupleNotificationBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsUnion, + > ::planus::WriteAsOptional<::planus::Offset> + for WebRtcTransportOptionsBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl>> - ::planus::WriteAsOffset for TupleNotificationBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsUnion, + > ::planus::WriteAsOffset + for WebRtcTransportOptionsBuilder<(T0, T1)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - TupleNotification::create(builder, v0) + ) -> ::planus::Offset { + let (v0, v1) = &self.0; + WebRtcTransportOptions::create(builder, v0, v1) } } - /// Reference to a deserialized [TupleNotification]. + /// Reference to a deserialized [WebRtcTransportOptions]. #[derive(Copy, Clone)] - pub struct TupleNotificationRef<'a>(::planus::table_reader::Table<'a>); + pub struct WebRtcTransportOptionsRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> TupleNotificationRef<'a> { - /// Getter for the [`tuple` field](TupleNotification#structfield.tuple). + impl<'a> WebRtcTransportOptionsRef<'a> { + /// Getter for the [`base` field](WebRtcTransportOptions#structfield.base). #[inline] - pub fn tuple(&self) -> ::planus::Result> { - self.0.access_required(0, "TupleNotification", "tuple") + 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") } } - impl<'a> ::core::fmt::Debug for TupleNotificationRef<'a> { + 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("TupleNotificationRef"); - f.field("tuple", &self.tuple()); + let mut f = f.debug_struct("WebRtcTransportOptionsRef"); + f.field("base", &self.base()); + f.field("listen", &self.listen()); f.finish() } } - impl<'a> ::core::convert::TryFrom> for TupleNotification { + impl<'a> ::core::convert::TryFrom> for WebRtcTransportOptions { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: TupleNotificationRef<'a>) -> ::planus::Result { + fn try_from(value: WebRtcTransportOptionsRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - tuple: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.tuple()?)?, - ), + base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( + value.base()?, + )?), + listen: ::core::convert::TryInto::try_into(value.listen()?)?, }) } } - impl<'a> ::planus::TableRead<'a> for TupleNotificationRef<'a> { + impl<'a> ::planus::TableRead<'a> for WebRtcTransportOptionsRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -73634,7 +75208,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for TupleNotificationRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for WebRtcTransportOptionsRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -73644,7 +75218,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[TupleNotificationRef]", + "[WebRtcTransportOptionsRef]", "get", buffer.offset_from_start, ) @@ -73652,8 +75226,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for TupleNotification { - type Value = ::planus::Offset; + 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 { @@ -73662,7 +75236,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -73677,7 +75251,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for TupleNotificationRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for WebRtcTransportOptionsRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -73687,287 +75261,207 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[TupleNotificationRef]", "read_as_root", 0) + error_kind.with_error_location( + "[WebRtcTransportOptionsRef]", + "read_as_root", + 0, + ) }) } } - /// The table `RtcpTupleNotification` in the namespace `FBS.PlainTransport` + /// The enum `FingerprintAlgorithm` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `RtcpTupleNotification` in the file `../worker/fbs/plainTransport.fbs:52` + /// * Enum `FingerprintAlgorithm` in the file `../worker/fbs/webRtcTransport.fbs:24` #[derive( + Copy, Clone, Debug, PartialEq, - PartialOrd, Eq, + PartialOrd, Ord, Hash, ::serde::Serialize, ::serde::Deserialize, )] - pub struct RtcpTupleNotification { - /// The field `tuple` in the table `RtcpTupleNotification` - pub tuple: ::planus::alloc::boxed::Box, - } + #[repr(u8)] + pub enum FingerprintAlgorithm { + /// The variant `SHA1` in the enum `FingerprintAlgorithm` + Sha1 = 0, - impl RtcpTupleNotification { - /// Creates a [RtcpTupleNotificationBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> RtcpTupleNotificationBuilder<()> { - RtcpTupleNotificationBuilder(()) - } + /// The variant `SHA224` in the enum `FingerprintAlgorithm` + Sha224 = 1, - #[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); + /// The variant `SHA256` in the enum `FingerprintAlgorithm` + Sha256 = 2, - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); + /// The variant `SHA384` in the enum `FingerprintAlgorithm` + Sha384 = 3, - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_tuple); - }); - } - builder.current_offset() - } + /// The variant `SHA512` in the enum `FingerprintAlgorithm` + Sha512 = 4, } - 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 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 ::planus::WriteAsOptional<::planus::Offset> for RtcpTupleNotification { - type Prepared = ::planus::Offset; - + impl ::core::convert::TryFrom for FingerprintAlgorithm { + type Error = ::planus::errors::UnknownEnumTagKind; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> + fn try_from( + value: u8, + ) -> ::core::result::Result { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } + #[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), - impl ::planus::WriteAsOffset for RtcpTupleNotification { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - RtcpTupleNotification::create(builder, &self.tuple) + _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { + tag: value as i128, + }), + } } } - /// 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). + impl ::core::convert::From for u8 { #[inline] - #[allow(clippy::type_complexity)] - pub fn tuple(self, value: T0) -> RtcpTupleNotificationBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - RtcpTupleNotificationBuilder((value,)) + fn from(value: FingerprintAlgorithm) -> Self { + value as u8 } } - 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::Primitive for FingerprintAlgorithm { + const ALIGNMENT: usize = 1; + const SIZE: usize = 1; } - impl>> - ::planus::WriteAs<::planus::Offset> - for RtcpTupleNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - + impl ::planus::WriteAsPrimitive for FingerprintAlgorithm { #[inline] - fn prepare( + fn write( &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + cursor: ::planus::Cursor<'_, N>, + buffer_position: u32, + ) { + (*self as u8).write(cursor, buffer_position); } } - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for RtcpTupleNotificationBuilder<(T0,)> - { - type Prepared = ::planus::Offset; + impl ::planus::WriteAs for FingerprintAlgorithm { + type Prepared = Self; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + fn prepare(&self, _builder: &mut ::planus::Builder) -> FingerprintAlgorithm { + *self } } - impl>> - ::planus::WriteAsOffset - for RtcpTupleNotificationBuilder<(T0,)> - { + impl ::planus::WriteAsDefault for FingerprintAlgorithm { + type Prepared = Self; + #[inline] fn prepare( &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - RtcpTupleNotification::create(builder, v0) + _builder: &mut ::planus::Builder, + default: &FingerprintAlgorithm, + ) -> ::core::option::Option { + if self == default { + ::core::option::Option::None + } else { + ::core::option::Option::Some(*self) + } } } - /// Reference to a deserialized [RtcpTupleNotification]. - #[derive(Copy, Clone)] - pub struct RtcpTupleNotificationRef<'a>(::planus::table_reader::Table<'a>); + impl ::planus::WriteAsOptional for FingerprintAlgorithm { + type Prepared = Self; - 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()?)?, - ), - }) + fn prepare( + &self, + _builder: &mut ::planus::Builder, + ) -> ::core::option::Option { + ::core::option::Option::Some(*self) } } - impl<'a> ::planus::TableRead<'a> for RtcpTupleNotificationRef<'a> { + impl<'buf> ::planus::TableRead<'buf> for FingerprintAlgorithm { #[inline] fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, + buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) + let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; + ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) } } - impl<'a> ::planus::VectorReadInner<'a> for RtcpTupleNotificationRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - + impl<'buf> ::planus::VectorReadInner<'buf> for FingerprintAlgorithm { + type Error = ::planus::errors::UnknownEnumTag; + const STRIDE: usize = 1; + #[inline] unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, + buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { + ) -> ::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( - "[RtcpTupleNotificationRef]", - "get", + "FingerprintAlgorithm", + "VectorRead::from_buffer", buffer.offset_from_start, ) }) } } - impl ::planus::VectorWrite<::planus::Offset> for RtcpTupleNotification { - type Value = ::planus::Offset; - const STRIDE: usize = 4; + impl ::planus::VectorWrite for FingerprintAlgorithm { + const STRIDE: usize = 1; + + type Value = Self; + #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) + fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { + *self } #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[Self], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; + 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 - (Self::STRIDE * i) as u32, + buffer_position - 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` + /// The table `Fingerprint` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `ListenIndividual` in the file `../worker/fbs/webRtcTransport.fbs:6` + /// * Table `Fingerprint` in the file `../worker/fbs/webRtcTransport.fbs:32` #[derive( Clone, Debug, @@ -73979,198 +75473,246 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct ListenIndividual { - /// The field `listen_infos` in the table `ListenIndividual` - pub listen_infos: ::planus::alloc::vec::Vec, + 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 ListenIndividual { - /// Creates a [ListenIndividualBuilder] for serializing an instance of this table. + impl Fingerprint { + /// Creates a [FingerprintBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> ListenIndividualBuilder<()> { - ListenIndividualBuilder(()) + pub fn builder() -> FingerprintBuilder<()> { + FingerprintBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_listen_infos: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, + field_algorithm: impl ::planus::WriteAsDefault< + self::FingerprintAlgorithm, + self::FingerprintAlgorithm, >, + field_value: impl ::planus::WriteAs<::planus::Offset>, ) -> ::planus::Offset { - let prepared_listen_infos = field_listen_infos.prepare(builder); + 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<6> = + 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>(1); + if prepared_algorithm.is_some() { + table_writer.write_entry::(0); + } unsafe { table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_listen_infos); + 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 ListenIndividual { + impl ::planus::WriteAs<::planus::Offset> for Fingerprint { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for ListenIndividual { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for ListenIndividual { + impl ::planus::WriteAsOffset for Fingerprint { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ListenIndividual::create(builder, &self.listen_infos) + ) -> ::planus::Offset { + Fingerprint::create(builder, self.algorithm, &self.value) } } - /// Builder for serializing an instance of the [ListenIndividual] type. + /// Builder for serializing an instance of the [Fingerprint] type. /// - /// Can be created using the [ListenIndividual::builder] method. + /// Can be created using the [Fingerprint::builder] method. #[derive(Debug)] #[must_use] - pub struct ListenIndividualBuilder(State); + pub struct FingerprintBuilder(State); - impl ListenIndividualBuilder<()> { - /// Setter for the [`listen_infos` field](ListenIndividual#structfield.listen_infos). + impl FingerprintBuilder<()> { + /// Setter for the [`algorithm` field](Fingerprint#structfield.algorithm). #[inline] #[allow(clippy::type_complexity)] - pub fn listen_infos(self, value: T0) -> ListenIndividualBuilder<(T0,)> + pub fn algorithm(self, value: T0) -> FingerprintBuilder<(T0,)> where - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, + T0: ::planus::WriteAsDefault< + self::FingerprintAlgorithm, + self::FingerprintAlgorithm, >, { - ListenIndividualBuilder((value,)) + 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 ListenIndividualBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ListenIndividual]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, + T0: ::planus::WriteAsDefault< + self::FingerprintAlgorithm, + self::FingerprintAlgorithm, >, - > ::planus::WriteAs<::planus::Offset> - for ListenIndividualBuilder<(T0,)> + T1: ::planus::WriteAs<::planus::Offset>, + > ::planus::WriteAs<::planus::Offset> + for FingerprintBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, + T0: ::planus::WriteAsDefault< + self::FingerprintAlgorithm, + self::FingerprintAlgorithm, >, - > ::planus::WriteAsOptional<::planus::Offset> - for ListenIndividualBuilder<(T0,)> + T1: ::planus::WriteAs<::planus::Offset>, + > ::planus::WriteAsOptional<::planus::Offset> + for FingerprintBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } impl< - T0: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, + T0: ::planus::WriteAsDefault< + self::FingerprintAlgorithm, + self::FingerprintAlgorithm, >, - > ::planus::WriteAsOffset for ListenIndividualBuilder<(T0,)> + T1: ::planus::WriteAs<::planus::Offset>, + > ::planus::WriteAsOffset for FingerprintBuilder<(T0, T1)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - ListenIndividual::create(builder, v0) + ) -> ::planus::Offset { + let (v0, v1) = &self.0; + Fingerprint::create(builder, v0, v1) } } - /// Reference to a deserialized [ListenIndividual]. + /// Reference to a deserialized [Fingerprint]. #[derive(Copy, Clone)] - pub struct ListenIndividualRef<'a>(::planus::table_reader::Table<'a>); + pub struct FingerprintRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> ListenIndividualRef<'a> { - /// Getter for the [`listen_infos` field](ListenIndividual#structfield.listen_infos). + impl<'a> FingerprintRef<'a> { + /// Getter for the [`algorithm` field](Fingerprint#structfield.algorithm). #[inline] - pub fn listen_infos( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0 - .access_required(0, "ListenIndividual", "listen_infos") + 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 ListenIndividualRef<'a> { + 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("ListenIndividualRef"); - f.field("listen_infos", &self.listen_infos()); + 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 ListenIndividual { + impl<'a> ::core::convert::TryFrom> for Fingerprint { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: ListenIndividualRef<'a>) -> ::planus::Result { + fn try_from(value: FingerprintRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - listen_infos: value.listen_infos()?.to_vec_result()?, + algorithm: ::core::convert::TryInto::try_into(value.algorithm()?)?, + value: ::core::convert::TryInto::try_into(value.value()?)?, }) } } - impl<'a> ::planus::TableRead<'a> for ListenIndividualRef<'a> { + impl<'a> ::planus::TableRead<'a> for FingerprintRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -74182,7 +75724,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for ListenIndividualRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for FingerprintRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -74192,7 +75734,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[ListenIndividualRef]", + "[FingerprintRef]", "get", buffer.offset_from_start, ) @@ -74200,8 +75742,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for ListenIndividual { - type Value = ::planus::Offset; + 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 { @@ -74210,7 +75752,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -74225,7 +75767,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for ListenIndividualRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for FingerprintRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -74235,489 +75777,377 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[ListenIndividualRef]", "read_as_root", 0) + error_kind.with_error_location("[FingerprintRef]", "read_as_root", 0) }) } } - /// The table `ListenServer` in the namespace `FBS.WebRtcTransport` + /// The enum `DtlsRole` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `ListenServer` in the file `../worker/fbs/webRtcTransport.fbs:10` + /// * Enum `DtlsRole` in the file `../worker/fbs/webRtcTransport.fbs:37` #[derive( + Copy, Clone, Debug, PartialEq, - PartialOrd, Eq, + PartialOrd, 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); + #[repr(u8)] + pub enum DtlsRole { + /// The variant `AUTO` in the enum `DtlsRole` + Auto = 0, - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); + /// The variant `CLIENT` in the enum `DtlsRole` + Client = 1, - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_web_rtc_server_id); - }); - } - builder.current_offset() - } + /// The variant `SERVER` in the enum `DtlsRole` + Server = 2, } - 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 DtlsRole { + /// Array containing all valid variants of DtlsRole + pub const ENUM_VALUES: [Self; 3] = [Self::Auto, Self::Client, Self::Server]; } - impl ::planus::WriteAsOptional<::planus::Offset> for ListenServer { - type Prepared = ::planus::Offset; - + impl ::core::convert::TryFrom for DtlsRole { + type Error = ::planus::errors::UnknownEnumTagKind; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) - } - } + 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), - impl ::planus::WriteAsOffset for ListenServer { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ListenServer::create(builder, &self.web_rtc_server_id) + _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { + tag: value as i128, + }), + } } } - /// 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). + impl ::core::convert::From for u8 { #[inline] - #[allow(clippy::type_complexity)] - pub fn web_rtc_server_id(self, value: T0) -> ListenServerBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - ListenServerBuilder((value,)) + fn from(value: DtlsRole) -> Self { + value as u8 } } - 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::Primitive for DtlsRole { + const ALIGNMENT: usize = 1; + const SIZE: usize = 1; } - impl>> - ::planus::WriteAs<::planus::Offset> for ListenServerBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - + impl ::planus::WriteAsPrimitive for DtlsRole { #[inline] - fn prepare( + fn write( &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + cursor: ::planus::Cursor<'_, N>, + buffer_position: u32, + ) { + (*self as u8).write(cursor, buffer_position); } } - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for ListenServerBuilder<(T0,)> - { - type Prepared = ::planus::Offset; + impl ::planus::WriteAs for DtlsRole { + type Prepared = Self; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + fn prepare(&self, _builder: &mut ::planus::Builder) -> DtlsRole { + *self } } - impl>> ::planus::WriteAsOffset - for ListenServerBuilder<(T0,)> - { + impl ::planus::WriteAsDefault for DtlsRole { + type Prepared = Self; + #[inline] fn prepare( &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0,) = &self.0; - ListenServer::create(builder, v0) + _builder: &mut ::planus::Builder, + default: &DtlsRole, + ) -> ::core::option::Option { + if self == default { + ::core::option::Option::None + } else { + ::core::option::Option::Some(*self) + } } } - /// Reference to a deserialized [ListenServer]. - #[derive(Copy, Clone)] - pub struct ListenServerRef<'a>(::planus::table_reader::Table<'a>); + impl ::planus::WriteAsOptional for DtlsRole { + type Prepared = Self; - 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()?, - )?, - }) + fn prepare( + &self, + _builder: &mut ::planus::Builder, + ) -> ::core::option::Option { + ::core::option::Option::Some(*self) } } - impl<'a> ::planus::TableRead<'a> for ListenServerRef<'a> { + impl<'buf> ::planus::TableRead<'buf> for DtlsRole { #[inline] fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, + buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) + let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; + ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) } } - impl<'a> ::planus::VectorReadInner<'a> for ListenServerRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - + impl<'buf> ::planus::VectorReadInner<'buf> for DtlsRole { + type Error = ::planus::errors::UnknownEnumTag; + const STRIDE: usize = 1; + #[inline] unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, + buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { + ) -> ::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( - "[ListenServerRef]", - "get", + "DtlsRole", + "VectorRead::from_buffer", buffer.offset_from_start, ) }) } } - impl ::planus::VectorWrite<::planus::Offset> for ListenServer { - type Value = ::planus::Offset; - const STRIDE: usize = 4; + impl ::planus::VectorWrite for DtlsRole { + const STRIDE: usize = 1; + + type Value = Self; + #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) + fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { + *self } #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[Self], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; + 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 - (Self::STRIDE * i) as u32, + buffer_position - 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` + /// The enum `DtlsState` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Union `Listen` in the file `../worker/fbs/webRtcTransport.fbs:14` + /// * Enum `DtlsState` in the file `../worker/fbs/webRtcTransport.fbs:43` #[derive( + Copy, Clone, Debug, PartialEq, - PartialOrd, Eq, + PartialOrd, Ord, Hash, ::serde::Serialize, ::serde::Deserialize, )] - pub enum Listen { - /// The variant of type `ListenIndividual` in the union `Listen` - ListenIndividual(::planus::alloc::boxed::Box), + #[repr(u8)] + pub enum DtlsState { + /// The variant `NEW` in the enum `DtlsState` + New = 0, - /// The variant of type `ListenServer` in the union `Listen` - ListenServer(::planus::alloc::boxed::Box), - } + /// The variant `CONNECTING` in the enum `DtlsState` + Connecting = 1, - impl Listen { - /// Creates a [ListenBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> ListenBuilder<::planus::Uninitialized> { - ListenBuilder(::planus::Uninitialized) - } + /// The variant `CONNECTED` in the enum `DtlsState` + Connected = 2, - #[inline] - pub fn create_listen_individual( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) - } + /// The variant `FAILED` in the enum `DtlsState` + Failed = 3, - #[inline] - pub fn create_listen_server( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) - } + /// 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 ::planus::WriteAsUnion for Listen { + impl ::core::convert::TryFrom for DtlsState { + type Error = ::planus::errors::UnknownEnumTagKind; #[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), + 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 ::planus::WriteAsOptionalUnion for Listen { + impl ::core::convert::From for u8 { #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + fn from(value: DtlsState) -> Self { + value as u8 } } - /// 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)) - } + impl ::planus::Primitive for DtlsState { + const ALIGNMENT: usize = 1; + const SIZE: usize = 1; + } - /// Creates an instance of the [`ListenServer` variant](Listen#variant.ListenServer). + impl ::planus::WriteAsPrimitive for DtlsState { #[inline] - pub fn listen_server( - self, - value: T, - ) -> ListenBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - ListenBuilder(::planus::Initialized(value)) + fn write( + &self, + cursor: ::planus::Cursor<'_, N>, + buffer_position: u32, + ) { + (*self as u8).write(cursor, buffer_position); } } - impl ListenBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Listen]. + impl ::planus::WriteAs for DtlsState { + type Prepared = Self; + #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset - where - Self: ::planus::WriteAsUnion, - { - ::planus::WriteAsUnion::prepare(&self, builder) + fn prepare(&self, _builder: &mut ::planus::Builder) -> DtlsState { + *self } } - impl ::planus::WriteAsUnion for ListenBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::planus::WriteAsDefault for DtlsState { + type Prepared = Self; + #[inline] fn prepare( &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) + _builder: &mut ::planus::Builder, + default: &DtlsState, + ) -> ::core::option::Option { + if self == default { + ::core::option::Option::None + } else { + ::core::option::Option::Some(*self) + } } } - impl ::planus::WriteAsOptionalUnion for ListenBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { + impl ::planus::WriteAsOptional for DtlsState { + type Prepared = Self; + #[inline] fn prepare( &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + _builder: &mut ::planus::Builder, + ) -> ::core::option::Option { + ::core::option::Option::Some(*self) } } - impl ::planus::WriteAsUnion for ListenBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { + + impl<'buf> ::planus::TableRead<'buf> for DtlsState { #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) + 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 ::planus::WriteAsOptionalUnion for ListenBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { + impl<'buf> ::planus::VectorReadInner<'buf> for DtlsState { + type Error = ::planus::errors::UnknownEnumTag; + const STRIDE: usize = 1; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + 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, + ) + }) } } - /// 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; + impl ::planus::VectorWrite for DtlsState { + const STRIDE: usize = 1; - 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)?, - )) - } + type Value = Self; - ListenRef::ListenServer(value) => { - Self::ListenServer(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - }) + #[inline] + fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { + *self } - } - 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 }, - ), + #[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 `WebRtcTransportOptions` in the namespace `FBS.WebRtcTransport` + /// The table `DtlsParameters` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `WebRtcTransportOptions` in the file `../worker/fbs/webRtcTransport.fbs:19` + /// * Table `DtlsParameters` in the file `../worker/fbs/webRtcTransport.fbs:51` #[derive( Clone, Debug, @@ -74729,223 +76159,237 @@ mod root { ::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, + 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 WebRtcTransportOptions { - /// Creates a [WebRtcTransportOptionsBuilder] for serializing an instance of this table. + impl DtlsParameters { + /// Creates a [DtlsParametersBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> WebRtcTransportOptionsBuilder<()> { - WebRtcTransportOptionsBuilder(()) + pub fn builder() -> DtlsParametersBuilder<()> { + DtlsParametersBuilder(()) } #[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_fingerprints: impl ::planus::WriteAs< + ::planus::Offset<[::planus::Offset]>, + >, + field_role: impl ::planus::WriteAsDefault, ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - let prepared_listen = field_listen.prepare(builder); + 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<10> = + 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>(2); - table_writer.write_entry::(1); + 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_base); - object_writer.write::<_, _, 4>(&prepared_listen.offset()); - object_writer.write::<_, _, 1>(&prepared_listen.tag()); + 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 WebRtcTransportOptions { + impl ::planus::WriteAs<::planus::Offset> for DtlsParameters { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> - for WebRtcTransportOptions - { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for WebRtcTransportOptions { + impl ::planus::WriteAsOffset for DtlsParameters { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - WebRtcTransportOptions::create(builder, &self.base, &self.listen) + ) -> ::planus::Offset { + DtlsParameters::create(builder, &self.fingerprints, self.role) } } - /// Builder for serializing an instance of the [WebRtcTransportOptions] type. + /// Builder for serializing an instance of the [DtlsParameters] type. /// - /// Can be created using the [WebRtcTransportOptions::builder] method. + /// Can be created using the [DtlsParameters::builder] method. #[derive(Debug)] #[must_use] - pub struct WebRtcTransportOptionsBuilder(State); + pub struct DtlsParametersBuilder(State); - impl WebRtcTransportOptionsBuilder<()> { - /// Setter for the [`base` field](WebRtcTransportOptions#structfield.base). + impl DtlsParametersBuilder<()> { + /// Setter for the [`fingerprints` field](DtlsParameters#structfield.fingerprints). #[inline] #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> WebRtcTransportOptionsBuilder<(T0,)> + pub fn fingerprints(self, value: T0) -> DtlsParametersBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset>, + T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, { - WebRtcTransportOptionsBuilder((value,)) + DtlsParametersBuilder((value,)) } } - impl WebRtcTransportOptionsBuilder<(T0,)> { - /// Setter for the [`listen` field](WebRtcTransportOptions#structfield.listen). + impl DtlsParametersBuilder<(T0,)> { + /// Setter for the [`role` field](DtlsParameters#structfield.role). #[inline] #[allow(clippy::type_complexity)] - pub fn listen(self, value: T1) -> WebRtcTransportOptionsBuilder<(T0, T1)> + pub fn role(self, value: T1) -> DtlsParametersBuilder<(T0, T1)> where - T1: ::planus::WriteAsUnion, + T1: ::planus::WriteAsDefault, { let (v0,) = self.0; - WebRtcTransportOptionsBuilder((v0, value)) + 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 WebRtcTransportOptionsBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [WebRtcTransportOptions]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsUnion, - > ::planus::WriteAs<::planus::Offset> - for WebRtcTransportOptionsBuilder<(T0, T1)> + T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T1: ::planus::WriteAsDefault, + > ::planus::WriteAs<::planus::Offset> + for DtlsParametersBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } impl< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsUnion, - > ::planus::WriteAsOptional<::planus::Offset> - for WebRtcTransportOptionsBuilder<(T0, T1)> + T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T1: ::planus::WriteAsDefault, + > ::planus::WriteAsOptional<::planus::Offset> + for DtlsParametersBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { + ) -> ::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 WebRtcTransportOptionsBuilder<(T0, T1)> + 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 { + ) -> ::planus::Offset { let (v0, v1) = &self.0; - WebRtcTransportOptions::create(builder, v0, v1) + DtlsParameters::create(builder, v0, v1) } } - /// Reference to a deserialized [WebRtcTransportOptions]. + /// Reference to a deserialized [DtlsParameters]. #[derive(Copy, Clone)] - pub struct WebRtcTransportOptionsRef<'a>(::planus::table_reader::Table<'a>); + pub struct DtlsParametersRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> WebRtcTransportOptionsRef<'a> { - /// Getter for the [`base` field](WebRtcTransportOptions#structfield.base). + impl<'a> DtlsParametersRef<'a> { + /// Getter for the [`fingerprints` field](DtlsParameters#structfield.fingerprints). #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "WebRtcTransportOptions", "base") + pub fn fingerprints( + &self, + ) -> ::planus::Result< + ::planus::Vector<'a, ::planus::Result>>, + > { + self.0.access_required(0, "DtlsParameters", "fingerprints") } - /// Getter for the [`listen` field](WebRtcTransportOptions#structfield.listen). + /// Getter for the [`role` field](DtlsParameters#structfield.role). #[inline] - pub fn listen(&self) -> ::planus::Result> { - self.0 - .access_union_required(1, "WebRtcTransportOptions", "listen") + 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 WebRtcTransportOptionsRef<'a> { + 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("WebRtcTransportOptionsRef"); - f.field("base", &self.base()); - f.field("listen", &self.listen()); + 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 WebRtcTransportOptions { + impl<'a> ::core::convert::TryFrom> for DtlsParameters { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: WebRtcTransportOptionsRef<'a>) -> ::planus::Result { + fn try_from(value: DtlsParametersRef<'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()?)?, + fingerprints: value.fingerprints()?.to_vec_result()?, + role: ::core::convert::TryInto::try_into(value.role()?)?, }) } } - impl<'a> ::planus::TableRead<'a> for WebRtcTransportOptionsRef<'a> { + impl<'a> ::planus::TableRead<'a> for DtlsParametersRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -74957,7 +76401,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for WebRtcTransportOptionsRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for DtlsParametersRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -74967,7 +76411,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[WebRtcTransportOptionsRef]", + "[DtlsParametersRef]", "get", buffer.offset_from_start, ) @@ -74975,8 +76419,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for WebRtcTransportOptions { - type Value = ::planus::Offset; + 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 { @@ -74985,7 +76429,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -75000,7 +76444,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for WebRtcTransportOptionsRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for DtlsParametersRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -75010,19 +76454,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location( - "[WebRtcTransportOptionsRef]", - "read_as_root", - 0, - ) + error_kind.with_error_location("[DtlsParametersRef]", "read_as_root", 0) }) } } - /// The table `Fingerprint` in the namespace `FBS.WebRtcTransport` + /// The table `IceParameters` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `Fingerprint` in the file `../worker/fbs/webRtcTransport.fbs:24` + /// * Table `IceParameters` in the file `../worker/fbs/webRtcTransport.fbs:56` #[derive( Clone, Debug, @@ -75034,119 +76474,158 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct Fingerprint { - /// The field `algorithm` in the table `Fingerprint` - pub algorithm: ::planus::alloc::string::String, - /// The field `value` in the table `Fingerprint` - pub value: ::planus::alloc::string::String, + 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 Fingerprint { - /// Creates a [FingerprintBuilder] for serializing an instance of this table. + impl IceParameters { + /// Creates a [IceParametersBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> FingerprintBuilder<()> { - FingerprintBuilder(()) + pub fn builder() -> IceParametersBuilder<()> { + IceParametersBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_algorithm: impl ::planus::WriteAs<::planus::Offset>, - field_value: impl ::planus::WriteAs<::planus::Offset>, + 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_algorithm = field_algorithm.prepare(builder); - let prepared_value = field_value.prepare(builder); + 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<8> = + 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_algorithm); - object_writer.write::<_, _, 4>(&prepared_value); + 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 Fingerprint { + impl ::planus::WriteAs<::planus::Offset> for IceParameters { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for Fingerprint { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for Fingerprint { + impl ::planus::WriteAsOffset for IceParameters { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - Fingerprint::create(builder, &self.algorithm, &self.value) + ) -> ::planus::Offset { + IceParameters::create( + builder, + &self.username_fragment, + &self.password, + self.ice_lite, + ) } } - /// Builder for serializing an instance of the [Fingerprint] type. + /// Builder for serializing an instance of the [IceParameters] type. /// - /// Can be created using the [Fingerprint::builder] method. + /// Can be created using the [IceParameters::builder] method. #[derive(Debug)] #[must_use] - pub struct FingerprintBuilder(State); + pub struct IceParametersBuilder(State); - impl FingerprintBuilder<()> { - /// Setter for the [`algorithm` field](Fingerprint#structfield.algorithm). + impl IceParametersBuilder<()> { + /// Setter for the [`username_fragment` field](IceParameters#structfield.username_fragment). #[inline] #[allow(clippy::type_complexity)] - pub fn algorithm(self, value: T0) -> FingerprintBuilder<(T0,)> + pub fn username_fragment(self, value: T0) -> IceParametersBuilder<(T0,)> where T0: ::planus::WriteAs<::planus::Offset>, { - FingerprintBuilder((value,)) + IceParametersBuilder((value,)) } } - impl FingerprintBuilder<(T0,)> { - /// Setter for the [`value` field](Fingerprint#structfield.value). + impl IceParametersBuilder<(T0,)> { + /// Setter for the [`password` field](IceParameters#structfield.password). #[inline] #[allow(clippy::type_complexity)] - pub fn value(self, value: T1) -> FingerprintBuilder<(T0, T1)> + pub fn password(self, value: T1) -> IceParametersBuilder<(T0, T1)> where T1: ::planus::WriteAs<::planus::Offset>, { let (v0,) = self.0; - FingerprintBuilder((v0, value)) + 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 FingerprintBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Fingerprint]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } @@ -75155,16 +76634,17 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAs<::planus::Offset> - for FingerprintBuilder<(T0, T1)> + T2: ::planus::WriteAsDefault, + > ::planus::WriteAs<::planus::Offset> + for IceParametersBuilder<(T0, T1, T2)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } @@ -75172,16 +76652,17 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOptional<::planus::Offset> - for FingerprintBuilder<(T0, T1)> + T2: ::planus::WriteAsDefault, + > ::planus::WriteAsOptional<::planus::Offset> + for IceParametersBuilder<(T0, T1, T2)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } @@ -75189,58 +76670,74 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs<::planus::Offset>, - > ::planus::WriteAsOffset for FingerprintBuilder<(T0, T1)> + T2: ::planus::WriteAsDefault, + > ::planus::WriteAsOffset for IceParametersBuilder<(T0, T1, T2)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - Fingerprint::create(builder, v0, v1) + ) -> ::planus::Offset { + let (v0, v1, v2) = &self.0; + IceParameters::create(builder, v0, v1, v2) } } - /// Reference to a deserialized [Fingerprint]. + /// Reference to a deserialized [IceParameters]. #[derive(Copy, Clone)] - pub struct FingerprintRef<'a>(::planus::table_reader::Table<'a>); + pub struct IceParametersRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> FingerprintRef<'a> { - /// Getter for the [`algorithm` field](Fingerprint#structfield.algorithm). + impl<'a> IceParametersRef<'a> { + /// Getter for the [`username_fragment` field](IceParameters#structfield.username_fragment). #[inline] - pub fn algorithm(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "Fingerprint", "algorithm") + pub fn username_fragment(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0 + .access_required(0, "IceParameters", "username_fragment") } - /// Getter for the [`value` field](Fingerprint#structfield.value). + /// Getter for the [`password` field](IceParameters#structfield.password). #[inline] - pub fn value(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "Fingerprint", "value") + 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 FingerprintRef<'a> { + 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("FingerprintRef"); - f.field("algorithm", &self.algorithm()); - f.field("value", &self.value()); + 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 Fingerprint { + impl<'a> ::core::convert::TryFrom> for IceParameters { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: FingerprintRef<'a>) -> ::planus::Result { + fn try_from(value: IceParametersRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - algorithm: ::core::convert::TryInto::try_into(value.algorithm()?)?, - value: ::core::convert::TryInto::try_into(value.value()?)?, + 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 FingerprintRef<'a> { + impl<'a> ::planus::TableRead<'a> for IceParametersRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -75252,7 +76749,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for FingerprintRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for IceParametersRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -75262,7 +76759,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[FingerprintRef]", + "[IceParametersRef]", "get", buffer.offset_from_start, ) @@ -75270,8 +76767,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for Fingerprint { - type Value = ::planus::Offset; + 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 { @@ -75280,7 +76777,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -75295,7 +76792,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for FingerprintRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for IceParametersRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -75305,681 +76802,700 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[FingerprintRef]", "read_as_root", 0) + error_kind.with_error_location("[IceParametersRef]", "read_as_root", 0) }) } } - /// The table `DtlsParameters` in the namespace `FBS.WebRtcTransport` + /// The enum `IceCandidateType` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `DtlsParameters` in the file `../worker/fbs/webRtcTransport.fbs:29` + /// * Enum `IceCandidateType` in the file `../worker/fbs/webRtcTransport.fbs:62` #[derive( + Copy, Clone, Debug, PartialEq, - PartialOrd, Eq, + PartialOrd, 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: ::core::option::Option<::planus::alloc::string::String>, + #[repr(u8)] + pub enum IceCandidateType { + /// The variant `HOST` in the enum `IceCandidateType` + Host = 0, } - impl DtlsParameters { - /// Creates a [DtlsParametersBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DtlsParametersBuilder<()> { - DtlsParametersBuilder(()) - } + impl IceCandidateType { + /// Array containing all valid variants of IceCandidateType + pub const ENUM_VALUES: [Self; 1] = [Self::Host]; + } - #[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::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - ) -> ::planus::Offset { - let prepared_fingerprints = field_fingerprints.prepare(builder); - let prepared_role = field_role.prepare(builder); + 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), - 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::<::planus::Offset>(1); + _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { + tag: value as i128, + }), } + } + } - 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::<_, _, 4>(&prepared_role); - } - }); - } - builder.current_offset() + impl ::core::convert::From for u8 { + #[inline] + fn from(value: IceCandidateType) -> Self { + value as u8 } } - impl ::planus::WriteAs<::planus::Offset> for DtlsParameters { - type Prepared = ::planus::Offset; + impl ::planus::Primitive for IceCandidateType { + const ALIGNMENT: usize = 1; + const SIZE: usize = 1; + } + impl ::planus::WriteAsPrimitive for IceCandidateType { #[inline] - fn prepare( + fn write( &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + cursor: ::planus::Cursor<'_, N>, + buffer_position: u32, + ) { + (*self as u8).write(cursor, buffer_position); } } - impl ::planus::WriteAsOptional<::planus::Offset> for DtlsParameters { - type Prepared = ::planus::Offset; + impl ::planus::WriteAs for IceCandidateType { + type Prepared = Self; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + fn prepare(&self, _builder: &mut ::planus::Builder) -> IceCandidateType { + *self } } - impl ::planus::WriteAsOffset for DtlsParameters { + impl ::planus::WriteAsDefault for IceCandidateType { + type Prepared = Self; + #[inline] fn prepare( &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - DtlsParameters::create(builder, &self.fingerprints, &self.role) + _builder: &mut ::planus::Builder, + default: &IceCandidateType, + ) -> ::core::option::Option { + if self == default { + ::core::option::Option::None + } else { + ::core::option::Option::Some(*self) + } } } - /// 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 ::planus::WriteAsOptional for IceCandidateType { + type Prepared = Self; - 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,)) + fn prepare( + &self, + _builder: &mut ::planus::Builder, + ) -> ::core::option::Option { + ::core::option::Option::Some(*self) } } - 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::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - { - let (v0,) = self.0; - DtlsParametersBuilder((v0, value)) - } - - /// Sets the [`role` field](DtlsParameters#structfield.role) to null. + impl<'buf> ::planus::TableRead<'buf> for IceCandidateType { #[inline] - #[allow(clippy::type_complexity)] - pub fn role_as_null(self) -> DtlsParametersBuilder<(T0, ())> { - self.role(()) + 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 DtlsParametersBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DtlsParameters]. + impl<'buf> ::planus::VectorReadInner<'buf> for IceCandidateType { + type Error = ::planus::errors::UnknownEnumTag; + const STRIDE: usize = 1; #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset - where - Self: ::planus::WriteAsOffset, + unsafe fn from_buffer( + buffer: ::planus::SliceWithStartOffset<'buf>, + offset: usize, + ) -> ::core::result::Result { - ::planus::WriteAsOffset::prepare(&self, builder) + 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< - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - > ::planus::WriteAs<::planus::Offset> - for DtlsParametersBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; + impl ::planus::VectorWrite for IceCandidateType { + const STRIDE: usize = 1; + + type Value = Self; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + 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, + ); + } } } - impl< - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - > ::planus::WriteAsOptional<::planus::Offset> - for DtlsParametersBuilder<(T0, T1)> - { - type Prepared = ::planus::Offset; + /// The enum `IceCandidateTcpType` in the namespace `FBS.WebRtcTransport` + /// + /// Generated from these locations: + /// * Enum `IceCandidateTcpType` in the file `../worker/fbs/webRtcTransport.fbs:63` + #[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 prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + 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< - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - > ::planus::WriteAsOffset for DtlsParametersBuilder<(T0, T1)> - { + impl ::core::convert::From for u8 { #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - DtlsParameters::create(builder, v0, v1) + fn from(value: IceCandidateTcpType) -> Self { + value as u8 } } - /// Reference to a deserialized [DtlsParameters]. - #[derive(Copy, Clone)] - pub struct DtlsParametersRef<'a>(::planus::table_reader::Table<'a>); + impl ::planus::Primitive for IceCandidateTcpType { + const ALIGNMENT: usize = 1; + const SIZE: usize = 1; + } - impl<'a> DtlsParametersRef<'a> { - /// Getter for the [`fingerprints` field](DtlsParameters#structfield.fingerprints). + impl ::planus::WriteAsPrimitive for IceCandidateTcpType { #[inline] - pub fn fingerprints( + fn write( &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(0, "DtlsParameters", "fingerprints") + cursor: ::planus::Cursor<'_, N>, + buffer_position: u32, + ) { + (*self as u8).write(cursor, buffer_position); } + } + + impl ::planus::WriteAs for IceCandidateTcpType { + type Prepared = Self; - /// Getter for the [`role` field](DtlsParameters#structfield.role). #[inline] - pub fn role( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(1, "DtlsParameters", "role") + fn prepare(&self, _builder: &mut ::planus::Builder) -> IceCandidateTcpType { + *self } } - 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()); - if let ::core::option::Option::Some(field_role) = self.role().transpose() { - f.field("role", &field_role); + 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) } - f.finish() } } - impl<'a> ::core::convert::TryFrom> for DtlsParameters { - type Error = ::planus::Error; + impl ::planus::WriteAsOptional for IceCandidateTcpType { + type Prepared = Self; - #[allow(unreachable_code)] - fn try_from(value: DtlsParametersRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - fingerprints: value.fingerprints()?.to_vec_result()?, - role: if let ::core::option::Option::Some(role) = value.role()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(role)?) - } else { - ::core::option::Option::None - }, - }) + #[inline] + fn prepare( + &self, + _builder: &mut ::planus::Builder, + ) -> ::core::option::Option { + ::core::option::Option::Some(*self) } } - impl<'a> ::planus::TableRead<'a> for DtlsParametersRef<'a> { + impl<'buf> ::planus::TableRead<'buf> for IceCandidateTcpType { #[inline] fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, + buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) + let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; + ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) } } - impl<'a> ::planus::VectorReadInner<'a> for DtlsParametersRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - + impl<'buf> ::planus::VectorReadInner<'buf> for IceCandidateTcpType { + type Error = ::planus::errors::UnknownEnumTag; + const STRIDE: usize = 1; + #[inline] unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, + buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { + ) -> ::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( - "[DtlsParametersRef]", - "get", + "IceCandidateTcpType", + "VectorRead::from_buffer", buffer.offset_from_start, ) }) } } - impl ::planus::VectorWrite<::planus::Offset> for DtlsParameters { - type Value = ::planus::Offset; - const STRIDE: usize = 4; + impl ::planus::VectorWrite for IceCandidateTcpType { + const STRIDE: usize = 1; + + type Value = Self; + #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) + fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { + *self } #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[Self], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; + 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 - (Self::STRIDE * i) as u32, + buffer_position - 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` + /// The enum `IceRole` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `IceParameters` in the file `../worker/fbs/webRtcTransport.fbs:34` + /// * Enum `IceRole` in the file `../worker/fbs/webRtcTransport.fbs:64` #[derive( + Copy, Clone, Debug, PartialEq, - PartialOrd, Eq, + PartialOrd, 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(()) - } + #[repr(u8)] + pub enum IceRole { + /// The variant `CONTROLLED` in the enum `IceRole` + Controlled = 0, - #[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); + /// The variant `CONTROLLING` in the enum `IceRole` + Controlling = 1, + } - 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); - } + impl IceRole { + /// Array containing all valid variants of IceRole + pub const ENUM_VALUES: [Self; 2] = [Self::Controlled, Self::Controlling]; + } - 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); - } - }); + 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, + }), } - builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for IceParameters { - type Prepared = ::planus::Offset; + 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 prepare( + fn write( &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + cursor: ::planus::Cursor<'_, N>, + buffer_position: u32, + ) { + (*self as u8).write(cursor, buffer_position); } } - impl ::planus::WriteAsOptional<::planus::Offset> for IceParameters { - type Prepared = ::planus::Offset; + impl ::planus::WriteAs for IceRole { + type Prepared = Self; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + fn prepare(&self, _builder: &mut ::planus::Builder) -> IceRole { + *self } } - impl ::planus::WriteAsOffset for IceParameters { + impl ::planus::WriteAsDefault for IceRole { + type Prepared = Self; + #[inline] fn prepare( &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - IceParameters::create( - builder, - &self.username_fragment, - &self.password, - self.ice_lite, - ) + _builder: &mut ::planus::Builder, + default: &IceRole, + ) -> ::core::option::Option { + if self == default { + ::core::option::Option::None + } else { + ::core::option::Option::Some(*self) + } } } - /// 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 ::planus::WriteAsOptional for IceRole { + type Prepared = Self; - 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,)) + fn prepare( + &self, + _builder: &mut ::planus::Builder, + ) -> ::core::option::Option { + ::core::option::Option::Some(*self) } } - impl IceParametersBuilder<(T0,)> { - /// Setter for the [`password` field](IceParameters#structfield.password). + impl<'buf> ::planus::TableRead<'buf> for IceRole { #[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)) + 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 IceParametersBuilder<(T0, T1)> { - /// Setter for the [`ice_lite` field](IceParameters#structfield.ice_lite). + impl<'buf> ::planus::VectorReadInner<'buf> for IceRole { + type Error = ::planus::errors::UnknownEnumTag; + const STRIDE: usize = 1; #[inline] - #[allow(clippy::type_complexity)] - pub fn ice_lite(self, value: T2) -> IceParametersBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, + unsafe fn from_buffer( + buffer: ::planus::SliceWithStartOffset<'buf>, + offset: usize, + ) -> ::core::result::Result { - let (v0, v1) = self.0; - IceParametersBuilder((v0, v1, value)) + 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; - /// 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) + fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { + *self } - } - 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) + 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, + ); + } } } - 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; + /// The enum `IceState` in the namespace `FBS.WebRtcTransport` + /// + /// Generated from these locations: + /// * Enum `IceState` in the file `../worker/fbs/webRtcTransport.fbs:65` + #[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, - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) - } + /// 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< - 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; + 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 prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + 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< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset for IceParametersBuilder<(T0, T1, T2)> - { + impl ::core::convert::From for u8 { #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1, v2) = &self.0; - IceParameters::create(builder, v0, v1, v2) + fn from(value: IceState) -> Self { + value as u8 } } - /// Reference to a deserialized [IceParameters]. - #[derive(Copy, Clone)] - pub struct IceParametersRef<'a>(::planus::table_reader::Table<'a>); + impl ::planus::Primitive for IceState { + const ALIGNMENT: usize = 1; + const SIZE: usize = 1; + } - impl<'a> IceParametersRef<'a> { - /// Getter for the [`username_fragment` field](IceParameters#structfield.username_fragment). + impl ::planus::WriteAsPrimitive for IceState { #[inline] - pub fn username_fragment(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "IceParameters", "username_fragment") + fn write( + &self, + cursor: ::planus::Cursor<'_, N>, + buffer_position: u32, + ) { + (*self as u8).write(cursor, buffer_position); } + } - /// 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") - } + impl ::planus::WriteAs for IceState { + type Prepared = Self; - /// 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), - ) + fn prepare(&self, _builder: &mut ::planus::Builder) -> IceState { + *self } } - 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 ::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<'a> ::core::convert::TryFrom> for IceParameters { - type Error = ::planus::Error; + impl ::planus::WriteAsOptional for IceState { + type Prepared = Self; - #[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()?)?, - }) + #[inline] + fn prepare( + &self, + _builder: &mut ::planus::Builder, + ) -> ::core::option::Option { + ::core::option::Option::Some(*self) } } - impl<'a> ::planus::TableRead<'a> for IceParametersRef<'a> { + impl<'buf> ::planus::TableRead<'buf> for IceState { #[inline] fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, + buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) + let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; + ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) } } - impl<'a> ::planus::VectorReadInner<'a> for IceParametersRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - + impl<'buf> ::planus::VectorReadInner<'buf> for IceState { + type Error = ::planus::errors::UnknownEnumTag; + const STRIDE: usize = 1; + #[inline] unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, + buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { + ) -> ::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( - "[IceParametersRef]", - "get", + "IceState", + "VectorRead::from_buffer", buffer.offset_from_start, ) }) } } - impl ::planus::VectorWrite<::planus::Offset> for IceParameters { - type Value = ::planus::Offset; - const STRIDE: usize = 4; + impl ::planus::VectorWrite for IceState { + const STRIDE: usize = 1; + + type Value = Self; + #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) + fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { + *self } #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[Self], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; + 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 - (Self::STRIDE * i) as u32, + buffer_position - 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 table `IceCandidate` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `IceCandidate` in the file `../worker/fbs/webRtcTransport.fbs:40` + /// * Table `IceCandidate` in the file `../worker/fbs/webRtcTransport.fbs:72` #[derive( Clone, Debug, @@ -76003,9 +77519,9 @@ mod root { /// The field `port` in the table `IceCandidate` pub port: u16, /// The field `type` in the table `IceCandidate` - pub type_: ::core::option::Option<::planus::alloc::string::String>, + pub type_: self::IceCandidateType, /// The field `tcp_type` in the table `IceCandidate` - pub tcp_type: ::core::option::Option<::planus::alloc::string::String>, + pub tcp_type: ::core::option::Option, } impl IceCandidate { @@ -76026,12 +77542,11 @@ mod root { super::transport::Protocol, >, field_port: impl ::planus::WriteAsDefault, - field_type_: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, - >, - field_tcp_type: impl ::planus::WriteAsOptional< - ::planus::Offset<::core::primitive::str>, + 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); @@ -76039,7 +77554,8 @@ mod root { 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); + 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> = @@ -76049,18 +77565,18 @@ mod root { table_writer.write_entry::(1); } table_writer.write_entry::<::planus::Offset>(2); - if prepared_type_.is_some() { - table_writer.write_entry::<::planus::Offset>(5); - } - if prepared_tcp_type.is_some() { - table_writer.write_entry::<::planus::Offset>(6); - } 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| { @@ -76071,14 +77587,6 @@ mod root { object_writer.write::<_, _, 4>(&prepared_priority); } object_writer.write::<_, _, 4>(&prepared_ip); - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - object_writer.write::<_, _, 4>(&prepared_type_); - } - if let ::core::option::Option::Some(prepared_tcp_type) = - prepared_tcp_type - { - object_writer.write::<_, _, 4>(&prepared_tcp_type); - } if let ::core::option::Option::Some(prepared_port) = prepared_port { object_writer.write::<_, _, 2>(&prepared_port); } @@ -76087,6 +77595,14 @@ mod root { { 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() @@ -76130,8 +77646,8 @@ mod root { &self.ip, self.protocol, self.port, - &self.type_, - &self.tcp_type, + self.type_, + self.tcp_type, ) } } @@ -76243,17 +77759,20 @@ mod root { #[allow(clippy::type_complexity)] pub fn type_(self, value: T5) -> IceCandidateBuilder<(T0, T1, T2, T3, T4, T5)> where - T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + 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 null. + /// Sets the [`type` field](IceCandidate#structfield.type_) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn type_as_null(self) -> IceCandidateBuilder<(T0, T1, T2, T3, T4, ())> { - self.type_(()) + pub fn type_as_default( + self, + ) -> IceCandidateBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> + { + self.type_(::planus::DefaultValue) } } @@ -76266,7 +77785,7 @@ mod root { value: T6, ) -> IceCandidateBuilder<(T0, T1, T2, T3, T4, T5, T6)> where - T6: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T6: ::planus::WriteAsOptional, { let (v0, v1, v2, v3, v4, v5) = self.0; IceCandidateBuilder((v0, v1, v2, v3, v4, v5, value)) @@ -76303,8 +77822,8 @@ mod root { super::transport::Protocol, >, T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T6: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T5: ::planus::WriteAsDefault, + T6: ::planus::WriteAsOptional, > ::planus::WriteAs<::planus::Offset> for IceCandidateBuilder<(T0, T1, T2, T3, T4, T5, T6)> { @@ -76328,8 +77847,8 @@ mod root { super::transport::Protocol, >, T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T6: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T5: ::planus::WriteAsDefault, + T6: ::planus::WriteAsOptional, > ::planus::WriteAsOptional<::planus::Offset> for IceCandidateBuilder<(T0, T1, T2, T3, T4, T5, T6)> { @@ -76353,8 +77872,8 @@ mod root { super::transport::Protocol, >, T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T6: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T5: ::planus::WriteAsDefault, + T6: ::planus::WriteAsOptional, > ::planus::WriteAsOffset for IceCandidateBuilder<(T0, T1, T2, T3, T4, T5, T6)> { @@ -76413,18 +77932,19 @@ mod root { /// Getter for the [`type` field](IceCandidate#structfield.type_). #[inline] - pub fn type_( - &self, - ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> - { - self.0.access(5, "IceCandidate", "type_") + 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<&'a ::core::primitive::str>> + ) -> ::planus::Result<::core::option::Option> { self.0.access(6, "IceCandidate", "tcp_type") } @@ -76438,9 +77958,7 @@ mod root { f.field("ip", &self.ip()); f.field("protocol", &self.protocol()); f.field("port", &self.port()); - if let ::core::option::Option::Some(field_type_) = self.type_().transpose() { - f.field("type_", &field_type_); - } + f.field("type_", &self.type_()); if let ::core::option::Option::Some(field_tcp_type) = self.tcp_type().transpose() { @@ -76461,11 +77979,7 @@ mod root { 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_: if let ::core::option::Option::Some(type_) = value.type_()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(type_)?) - } else { - ::core::option::Option::None - }, + type_: ::core::convert::TryInto::try_into(value.type_()?)?, tcp_type: if let ::core::option::Option::Some(tcp_type) = value.tcp_type()? { @@ -76552,7 +78066,7 @@ mod root { /// The table `ConnectRequest` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `ConnectRequest` in the file `../worker/fbs/webRtcTransport.fbs:50` + /// * Table `ConnectRequest` in the file `../worker/fbs/webRtcTransport.fbs:82` #[derive( Clone, Debug, @@ -76815,7 +78329,7 @@ mod root { /// The table `ConnectResponse` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `ConnectResponse` in the file `../worker/fbs/webRtcTransport.fbs:54` + /// * Table `ConnectResponse` in the file `../worker/fbs/webRtcTransport.fbs:86` #[derive( Clone, Debug, @@ -76829,7 +78343,16 @@ mod root { )] pub struct ConnectResponse { /// The field `dtls_local_role` in the table `ConnectResponse` - pub dtls_local_role: ::planus::alloc::string::String, + 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 { @@ -76842,17 +78365,24 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_dtls_local_role: impl ::planus::WriteAs<::planus::Offset>, + field_dtls_local_role: impl ::planus::WriteAsDefault, ) -> ::planus::Offset { - let prepared_dtls_local_role = field_dtls_local_role.prepare(builder); + 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(); - table_writer.write_entry::<::planus::Offset>(0); + if prepared_dtls_local_role.is_some() { + table_writer.write_entry::(0); + } unsafe { table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_dtls_local_role); + 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() @@ -76889,7 +78419,7 @@ mod root { &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - ConnectResponse::create(builder, &self.dtls_local_role) + ConnectResponse::create(builder, self.dtls_local_role) } } @@ -76906,10 +78436,19 @@ mod root { #[allow(clippy::type_complexity)] pub fn dtls_local_role(self, value: T0) -> ConnectResponseBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset>, + 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,)> { @@ -76926,7 +78465,7 @@ mod root { } } - impl>> + impl> ::planus::WriteAs<::planus::Offset> for ConnectResponseBuilder<(T0,)> { @@ -76941,7 +78480,7 @@ mod root { } } - impl>> + impl> ::planus::WriteAsOptional<::planus::Offset> for ConnectResponseBuilder<(T0,)> { @@ -76956,7 +78495,7 @@ mod root { } } - impl>> + impl> ::planus::WriteAsOffset for ConnectResponseBuilder<(T0,)> { #[inline] @@ -76976,9 +78515,12 @@ mod root { 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<&'a ::core::primitive::str> { - self.0 - .access_required(0, "ConnectResponse", "dtls_local_role") + 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), + ) } } @@ -77076,7 +78618,7 @@ mod root { /// The table `DumpResponse` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/webRtcTransport.fbs:58` + /// * Table `DumpResponse` in the file `../worker/fbs/webRtcTransport.fbs:90` #[derive( Clone, Debug, @@ -77092,20 +78634,20 @@ mod root { /// The field `base` in the table `DumpResponse` pub base: ::planus::alloc::boxed::Box, /// The field `ice_role` in the table `DumpResponse` - pub ice_role: ::planus::alloc::string::String, + 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: ::planus::alloc::string::String, + 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: ::planus::alloc::string::String, + pub dtls_state: self::DtlsState, } impl DumpResponse { @@ -77119,57 +78661,77 @@ mod root { pub fn create( builder: &mut ::planus::Builder, field_base: impl ::planus::WriteAs<::planus::Offset>, - field_ice_role: 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::WriteAs<::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::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); + 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); + 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); + 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>(1); table_writer.write_entry::<::planus::Offset>(2); table_writer .write_entry::<::planus::Offset<[::planus::Offset]>>(3); - table_writer.write_entry::<::planus::Offset>(4); if prepared_ice_selected_tuple.is_some() { table_writer.write_entry::<::planus::Offset>(5); } table_writer.write_entry::<::planus::Offset>(6); - table_writer.write_entry::<::planus::Offset>(7); + 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_role); object_writer.write::<_, _, 4>(&prepared_ice_parameters); object_writer.write::<_, _, 4>(&prepared_ice_candidates); - object_writer.write::<_, _, 4>(&prepared_ice_state); 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); - object_writer.write::<_, _, 4>(&prepared_dtls_state); + 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() @@ -77209,13 +78771,13 @@ mod root { DumpResponse::create( builder, &self.base, - &self.ice_role, + self.ice_role, &self.ice_parameters, &self.ice_candidates, - &self.ice_state, + self.ice_state, &self.ice_selected_tuple, &self.dtls_parameters, - &self.dtls_state, + self.dtls_state, ) } } @@ -77245,11 +78807,20 @@ mod root { #[allow(clippy::type_complexity)] pub fn ice_role(self, value: T1) -> DumpResponseBuilder<(T0, T1)> where - T1: ::planus::WriteAs<::planus::Offset>, + 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)> { @@ -77284,11 +78855,20 @@ mod root { #[allow(clippy::type_complexity)] pub fn ice_state(self, value: T4) -> DumpResponseBuilder<(T0, T1, T2, T3, T4)> where - T4: ::planus::WriteAs<::planus::Offset>, + 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)> { @@ -77341,11 +78921,21 @@ mod root { value: T7, ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> where - T7: ::planus::WriteAs<::planus::Offset>, + 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)> { @@ -77364,13 +78954,13 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, T2: ::planus::WriteAs<::planus::Offset>, T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T4: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAsDefault, T5: ::planus::WriteAsOptional<::planus::Offset>, T6: ::planus::WriteAs<::planus::Offset>, - T7: ::planus::WriteAs<::planus::Offset>, + T7: ::planus::WriteAsDefault, > ::planus::WriteAs<::planus::Offset> for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { @@ -77387,13 +78977,13 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, T2: ::planus::WriteAs<::planus::Offset>, T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T4: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAsDefault, T5: ::planus::WriteAsOptional<::planus::Offset>, T6: ::planus::WriteAs<::planus::Offset>, - T7: ::planus::WriteAs<::planus::Offset>, + T7: ::planus::WriteAsDefault, > ::planus::WriteAsOptional<::planus::Offset> for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { @@ -77410,13 +79000,13 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, T2: ::planus::WriteAs<::planus::Offset>, T3: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T4: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAsDefault, T5: ::planus::WriteAsOptional<::planus::Offset>, T6: ::planus::WriteAs<::planus::Offset>, - T7: ::planus::WriteAs<::planus::Offset>, + T7: ::planus::WriteAsDefault, > ::planus::WriteAsOffset for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { @@ -77443,8 +79033,12 @@ mod root { /// Getter for the [`ice_role` field](DumpResponse#structfield.ice_role). #[inline] - pub fn ice_role(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "DumpResponse", "ice_role") + 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). @@ -77465,8 +79059,12 @@ mod root { /// Getter for the [`ice_state` field](DumpResponse#structfield.ice_state). #[inline] - pub fn ice_state(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(4, "DumpResponse", "ice_state") + 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). @@ -77486,8 +79084,12 @@ mod root { /// Getter for the [`dtls_state` field](DumpResponse#structfield.dtls_state). #[inline] - pub fn dtls_state(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(7, "DumpResponse", "dtls_state") + pub fn dtls_state(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(7, "DumpResponse", "dtls_state")? + .unwrap_or(self::DtlsState::New), + ) } } @@ -77616,7 +79218,7 @@ mod root { /// The table `GetStatsResponse` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/webRtcTransport.fbs:69` + /// * Table `GetStatsResponse` in the file `../worker/fbs/webRtcTransport.fbs:101` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -77624,14 +79226,14 @@ mod root { /// The field `base` in the table `GetStatsResponse` pub base: ::planus::alloc::boxed::Box, /// The field `ice_role` in the table `GetStatsResponse` - pub ice_role: ::planus::alloc::string::String, + pub ice_role: self::IceRole, /// The field `ice_state` in the table `GetStatsResponse` - pub ice_state: ::planus::alloc::string::String, + 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: ::planus::alloc::string::String, + pub dtls_state: self::DtlsState, } impl GetStatsResponse { @@ -77645,40 +79247,60 @@ mod root { pub fn create( builder: &mut ::planus::Builder, field_base: impl ::planus::WriteAs<::planus::Offset>, - field_ice_role: impl ::planus::WriteAs<::planus::Offset>, - field_ice_state: 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::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); - let prepared_ice_state = field_ice_state.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); + 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); - table_writer.write_entry::<::planus::Offset>(1); - table_writer.write_entry::<::planus::Offset>(2); if prepared_ice_selected_tuple.is_some() { table_writer.write_entry::<::planus::Offset>(3); } - table_writer.write_entry::<::planus::Offset>(4); + 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); - object_writer.write::<_, _, 4>(&prepared_ice_role); - object_writer.write::<_, _, 4>(&prepared_ice_state); 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_state); + 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() @@ -77718,10 +79340,10 @@ mod root { GetStatsResponse::create( builder, &self.base, - &self.ice_role, - &self.ice_state, + self.ice_role, + self.ice_state, &self.ice_selected_tuple, - &self.dtls_state, + self.dtls_state, ) } } @@ -77751,11 +79373,20 @@ mod root { #[allow(clippy::type_complexity)] pub fn ice_role(self, value: T1) -> GetStatsResponseBuilder<(T0, T1)> where - T1: ::planus::WriteAs<::planus::Offset>, + 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)> { @@ -77764,11 +79395,20 @@ mod root { #[allow(clippy::type_complexity)] pub fn ice_state(self, value: T2) -> GetStatsResponseBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAs<::planus::Offset>, + 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)> { @@ -77805,11 +79445,21 @@ mod root { value: T4, ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> where - T4: ::planus::WriteAs<::planus::Offset>, + 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)> { @@ -77828,10 +79478,10 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsOptional<::planus::Offset>, - T4: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAsDefault, > ::planus::WriteAs<::planus::Offset> for GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> { @@ -77848,10 +79498,10 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsOptional<::planus::Offset>, - T4: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAsDefault, > ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> { @@ -77868,10 +79518,10 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsOptional<::planus::Offset>, - T4: ::planus::WriteAs<::planus::Offset>, + T4: ::planus::WriteAsDefault, > ::planus::WriteAsOffset for GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> { @@ -77898,14 +79548,22 @@ mod root { /// Getter for the [`ice_role` field](GetStatsResponse#structfield.ice_role). #[inline] - pub fn ice_role(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "GetStatsResponse", "ice_role") + 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<&'a ::core::primitive::str> { - self.0.access_required(2, "GetStatsResponse", "ice_state") + 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). @@ -77919,8 +79577,12 @@ mod root { /// Getter for the [`dtls_state` field](GetStatsResponse#structfield.dtls_state). #[inline] - pub fn dtls_state(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(4, "GetStatsResponse", "dtls_state") + pub fn dtls_state(&self) -> ::planus::Result { + ::core::result::Result::Ok( + self.0 + .access(4, "GetStatsResponse", "dtls_state")? + .unwrap_or(self::DtlsState::New), + ) } } @@ -78039,7 +79701,7 @@ mod root { /// The table `IceSelectedTupleChangeNotification` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `IceSelectedTupleChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:79` + /// * Table `IceSelectedTupleChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:111` #[derive( Clone, Debug, @@ -78319,386 +79981,10 @@ mod root { } } - /// The enum `IceState` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Enum `IceState` in the file `../worker/fbs/webRtcTransport.fbs:83` - #[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, - - /// The variant `CLOSED` in the enum `IceState` - Closed = 4, - } - - impl IceState { - /// Array containing all valid variants of IceState - pub const ENUM_VALUES: [Self; 5] = [ - Self::New, - Self::Connected, - Self::Completed, - Self::Disconnected, - Self::Closed, - ]; - } - - 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), - 4 => ::core::result::Result::Ok(IceState::Closed), - - _ => ::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 enum `DtlsState` in the namespace `FBS.WebRtcTransport` - /// - /// Generated from these locations: - /// * Enum `DtlsState` in the file `../worker/fbs/webRtcTransport.fbs:84` - #[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 `IceStateChangeNotification` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `IceStateChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:86` + /// * Table `IceStateChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:115` #[derive( Clone, Debug, @@ -78999,7 +80285,7 @@ mod root { /// The table `DtlsStateChangeNotification` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `DtlsStateChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:90` + /// * Table `DtlsStateChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:119` #[derive( Clone, Debug, diff --git a/rust/src/messages.rs b/rust/src/messages.rs index 0e9124b824..93ec73b62e 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -13,7 +13,7 @@ use crate::data_structures::{ use crate::direct_transport::DirectTransportOptions; use crate::fbs::{ direct_transport, message, pipe_transport, plain_transport, request, response, router, - transport, worker, + transport, web_rtc_transport, worker, }; use crate::ortc::RtpMapping; use crate::pipe_transport::PipeTransportOptions; @@ -757,8 +757,8 @@ impl RouterCreateDirectTransportData { direct_transport::DirectTransportOptions { base: Box::new(transport::Options { direct: true, - max_message_size: self.max_message_size, - initial_available_outgoing_bitrate: 0, + max_message_size: Some(self.max_message_size), + initial_available_outgoing_bitrate: None, enable_sctp: false, num_sctp_streams: None, max_sctp_message_size: 0, @@ -821,9 +821,31 @@ enum RouterCreateWebrtcTransportListen { }, } +impl RouterCreateWebrtcTransportListen { + pub(crate) fn to_fbs(&self) -> web_rtc_transport::Listen { + match self { + RouterCreateWebrtcTransportListen::Individual { listen_infos } => { + web_rtc_transport::Listen::ListenIndividual(Box::new( + web_rtc_transport::ListenIndividual { + listen_infos: listen_infos + .iter() + .map(|listen_info| listen_info.to_fbs()) + .collect(), + }, + )) + } + RouterCreateWebrtcTransportListen::Server { webrtc_server_id } => { + web_rtc_transport::Listen::ListenServer(Box::new(web_rtc_transport::ListenServer { + web_rtc_server_id: webrtc_server_id.to_string(), + })) + } + } + } +} + #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] -pub(crate) struct RouterCreateWebrtcTransportRequest { +pub(crate) struct RouterCreateWebrtcTransportData { transport_id: TransportId, #[serde(flatten)] listen: RouterCreateWebrtcTransportListen, @@ -835,7 +857,7 @@ pub(crate) struct RouterCreateWebrtcTransportRequest { is_data_channel: bool, } -impl RouterCreateWebrtcTransportRequest { +impl RouterCreateWebrtcTransportData { pub(crate) fn from_options( transport_id: TransportId, webrtc_transport_options: &WebRtcTransportOptions, @@ -863,6 +885,22 @@ impl RouterCreateWebrtcTransportRequest { is_data_channel: true, } } + + pub(crate) fn to_fbs(&self) -> web_rtc_transport::WebRtcTransportOptions { + web_rtc_transport::WebRtcTransportOptions { + base: Box::new(transport::Options { + direct: false, + max_message_size: None, + initial_available_outgoing_bitrate: Some(self.initial_available_outgoing_bitrate), + enable_sctp: self.enable_sctp, + num_sctp_streams: Some(Box::new(self.num_sctp_streams.to_fbs())), + max_sctp_message_size: self.max_sctp_message_size, + sctp_send_buffer_size: self.sctp_send_buffer_size, + is_data_channel: true, + }), + listen: self.listen.to_fbs(), + } + } } #[derive(Debug, Deserialize)] @@ -880,17 +918,71 @@ pub(crate) struct WebRtcTransportData { pub(crate) sctp_state: Mutex>, } -impl Request for RouterCreateWebrtcTransportRequest { +#[derive(Debug)] +pub(crate) struct RouterCreateWebRtcTransportRequest { + pub(crate) data: RouterCreateWebrtcTransportData, +} + +impl RequestFbs for RouterCreateWebRtcTransportRequest { + const METHOD: request::Method = request::Method::RouterCreateWebrtctransport; type HandlerId = RouterId; type Response = WebRtcTransportData; - fn as_method(&self) -> &'static str { - match &self.listen { - RouterCreateWebrtcTransportListen::Individual { .. } => "router.createWebRtcTransport", - RouterCreateWebrtcTransportListen::Server { .. } => { - "router.createWebRtcTransportWithServer" - } - } + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = router::CreateWebRtcTransportRequest::create( + &mut builder, + self.data.transport_id.to_string(), + self.data.to_fbs(), + ); + let request_body = + request::Body::create_create_web_rtc_transport_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::FbsWebRtcTransportDumpResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(WebRtcTransportData { + ice_role: IceRole::from_fbs(data.ice_role), + ice_parameters: IceParameters::from_fbs(*data.ice_parameters), + ice_candidates: data + .ice_candidates + .iter() + .map(IceCandidate::from_fbs) + .collect(), + ice_state: Mutex::new(IceState::from_fbs(data.ice_state)), + ice_selected_tuple: Mutex::new( + data.ice_selected_tuple + .map(|tuple| TransportTuple::from_fbs(tuple.as_ref())), + ), + dtls_parameters: Mutex::new(DtlsParameters::from_fbs(*data.dtls_parameters)), + dtls_state: Mutex::new(DtlsState::from_fbs(data.dtls_state)), + dtls_remote_cert: Mutex::new(None), + sctp_parameters: data + .base + .sctp_parameters + .map(|parameters| SctpParameters::from_fbs(parameters.as_ref())), + sctp_state: Mutex::new( + data.base + .sctp_state + .map(|state| SctpState::from_fbs(&state)), + ), + }) } } @@ -936,13 +1028,13 @@ impl RouterCreatePlainTransportData { plain_transport::PlainTransportOptions { base: Box::new(transport::Options { direct: false, - initial_available_outgoing_bitrate: 0, + max_message_size: None, + initial_available_outgoing_bitrate: None, enable_sctp: self.enable_sctp, num_sctp_streams: Some(Box::new(self.num_sctp_streams.to_fbs())), max_sctp_message_size: self.max_sctp_message_size, sctp_send_buffer_size: self.sctp_send_buffer_size, is_data_channel: self.is_data_channel, - max_message_size: self.max_sctp_message_size, }), listen_info: Box::new(self.listen_info.to_fbs()), rtcp_listen_info: self @@ -951,7 +1043,7 @@ impl RouterCreatePlainTransportData { rtcp_mux: self.rtcp_mux, comedia: self.comedia, enable_srtp: self.enable_srtp, - srtp_crypto_suite: Some(self.srtp_crypto_suite.to_string()), + srtp_crypto_suite: Some(SrtpCryptoSuite::to_fbs(self.srtp_crypto_suite)), } } } @@ -1268,16 +1360,52 @@ impl RequestFbs for TransportCloseRequestFbs { } } -request_response!( - TransportId, - "transport.connect", - TransportConnectWebRtcRequest { - dtls_parameters: DtlsParameters, - }, - TransportConnectResponseWebRtc { - dtls_local_role: DtlsRole, - }, -); +#[derive(Debug)] +pub(crate) struct WebRtcTransportConnectResponse { + pub(crate) dtls_local_role: DtlsRole, +} + +#[derive(Debug)] +pub(crate) struct WebRtcTransportConnectRequest { + pub(crate) dtls_parameters: DtlsParameters, +} + +impl RequestFbs for WebRtcTransportConnectRequest { + const METHOD: request::Method = request::Method::WebrtctransportConnect; + type HandlerId = TransportId; + type Response = WebRtcTransportConnectResponse; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = + web_rtc_transport::ConnectRequest::create(&mut builder, self.dtls_parameters.to_fbs()); + let request_body = + request::Body::create_web_rtc_transport_connect_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::FbsWebRtcTransportConnectResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(WebRtcTransportConnectResponse { + dtls_local_role: DtlsRole::from_fbs(data.dtls_local_role), + }) + } +} #[derive(Debug)] pub(crate) struct PipeTransportConnectResponse { @@ -1321,7 +1449,7 @@ impl RequestFbs for PipeTransportConnectRequest { fn convert_response( response: Option, ) -> Result> { - let Some(response::Body::FbsPlainTransportConnectResponse(data)) = response else { + let Some(response::Body::FbsPipeTransportConnectResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; @@ -1412,15 +1540,43 @@ request_response!( TransportSetMinOutgoingBitrateRequest { bitrate: u32 }, ); -request_response!( - TransportId, - "transport.restartIce", - TransportRestartIceRequest {}, - TransportRestartIceResponse { - ice_parameters: IceParameters, - }, -); +#[derive(Debug)] +pub(crate) struct TransportRestartIceRequest {} + +impl RequestFbs for TransportRestartIceRequest { + const METHOD: request::Method = request::Method::TransportRestartIce; + type HandlerId = TransportId; + type Response = IceParameters; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::FbsTransportRestartIceResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(IceParameters::from_fbs(web_rtc_transport::IceParameters { + username_fragment: data.username_fragment, + password: data.password, + ice_lite: data.ice_lite, + })) + } +} request_response!( TransportId, "transport.produce", diff --git a/rust/src/router.rs b/rust/src/router.rs index a5e2b632c1..c4ce4abc37 100644 --- a/rust/src/router.rs +++ b/rust/src/router.rs @@ -36,7 +36,8 @@ use crate::messages::{ RouterCreateAudioLevelObserverRequest, RouterCreateDirectTransportData, RouterCreateDirectTransportRequest, RouterCreatePipeTransportData, RouterCreatePipeTransportRequest, RouterCreatePlainTransportData, - RouterCreatePlainTransportRequest, RouterCreateWebrtcTransportRequest, RouterDumpRequest, + RouterCreatePlainTransportRequest, RouterCreateWebRtcTransportRequest, + RouterCreateWebrtcTransportData, RouterDumpRequest, }; use crate::pipe_transport::{ PipeTransport, PipeTransportOptions, PipeTransportRemoteParameters, WeakPipeTransport, @@ -628,12 +629,14 @@ impl Router { let data = self .inner .channel - .request( + .request_fbs( self.inner.id, - RouterCreateWebrtcTransportRequest::from_options( - transport_id, - &webrtc_transport_options, - ), + RouterCreateWebRtcTransportRequest { + data: RouterCreateWebrtcTransportData::from_options( + transport_id, + &webrtc_transport_options, + ), + }, ) .await?; diff --git a/rust/src/router/direct_transport.rs b/rust/src/router/direct_transport.rs index 6530268986..543587ad06 100644 --- a/rust/src/router/direct_transport.rs +++ b/rust/src/router/direct_transport.rs @@ -168,9 +168,9 @@ pub struct DirectTransportStat { pub available_outgoing_bitrate: Option, #[serde(skip_serializing_if = "Option::is_none")] pub available_incoming_bitrate: Option, - pub max_incoming_bitrate: u32, - pub max_outgoing_bitrate: u32, - pub min_outgoing_bitrate: u32, + pub max_incoming_bitrate: Option, + pub max_outgoing_bitrate: Option, + pub min_outgoing_bitrate: Option, #[serde(skip_serializing_if = "Option::is_none")] pub rtp_packet_loss_received: Option, #[serde(skip_serializing_if = "Option::is_none")] diff --git a/rust/src/router/pipe_transport.rs b/rust/src/router/pipe_transport.rs index 7e37e767b2..0cc91acb5a 100644 --- a/rust/src/router/pipe_transport.rs +++ b/rust/src/router/pipe_transport.rs @@ -209,9 +209,9 @@ pub struct PipeTransportStat { pub available_outgoing_bitrate: Option, #[serde(skip_serializing_if = "Option::is_none")] pub available_incoming_bitrate: Option, - pub max_incoming_bitrate: u32, - pub max_outgoing_bitrate: u32, - pub min_outgoing_bitrate: u32, + pub max_incoming_bitrate: Option, + pub max_outgoing_bitrate: Option, + pub min_outgoing_bitrate: Option, #[serde(skip_serializing_if = "Option::is_none")] pub rtp_packet_loss_received: Option, #[serde(skip_serializing_if = "Option::is_none")] diff --git a/rust/src/router/plain_transport.rs b/rust/src/router/plain_transport.rs index 933f12d2da..06e01fd096 100644 --- a/rust/src/router/plain_transport.rs +++ b/rust/src/router/plain_transport.rs @@ -234,9 +234,9 @@ pub struct PlainTransportStat { pub available_outgoing_bitrate: Option, #[serde(skip_serializing_if = "Option::is_none")] pub available_incoming_bitrate: Option, - pub max_incoming_bitrate: u32, - pub max_outgoing_bitrate: u32, - pub min_outgoing_bitrate: u32, + pub max_incoming_bitrate: Option, + pub max_outgoing_bitrate: Option, + pub min_outgoing_bitrate: Option, #[serde(skip_serializing_if = "Option::is_none")] pub rtp_packet_loss_received: Option, #[serde(skip_serializing_if = "Option::is_none")] diff --git a/rust/src/router/webrtc_transport.rs b/rust/src/router/webrtc_transport.rs index 954b24ef81..fb0079869e 100644 --- a/rust/src/router/webrtc_transport.rs +++ b/rust/src/router/webrtc_transport.rs @@ -8,8 +8,9 @@ use crate::data_structures::{ AppData, DtlsParameters, DtlsState, IceCandidate, IceParameters, IceRole, IceState, ListenInfo, SctpState, TransportTuple, }; +use crate::fbs::{response, web_rtc_transport}; use crate::messages::{ - TransportCloseRequest, TransportConnectWebRtcRequest, TransportRestartIceRequest, + TransportCloseRequestFbs, TransportRestartIceRequest, WebRtcTransportConnectRequest, WebRtcTransportData, }; use crate::producer::{Producer, ProducerId, ProducerOptions}; @@ -31,6 +32,7 @@ use nohash_hasher::IntMap; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use std::convert::TryFrom; +use std::error::Error; use std::fmt; use std::ops::Deref; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; @@ -175,7 +177,7 @@ pub struct WebRtcTransportDump { pub data_consumer_ids: Vec, pub recv_rtp_header_extensions: RecvRtpHeaderExtensions, pub rtp_listener: RtpListener, - pub max_message_size: usize, + pub max_message_size: u32, pub sctp_parameters: Option, pub sctp_state: Option, pub sctp_listener: Option, @@ -190,6 +192,89 @@ pub struct WebRtcTransportDump { pub ice_selected_tuple: Option, } +impl WebRtcTransportDump { + pub(crate) fn from_fbs(dump: web_rtc_transport::DumpResponse) -> Result> { + Ok(Self { + // Common to all Transports. + id: dump.base.id.parse()?, + direct: false, + producer_ids: dump + .base + .producer_ids + .iter() + .map(|producer_id| Ok(producer_id.parse()?)) + .collect::>>()?, + consumer_ids: dump + .base + .consumer_ids + .iter() + .map(|consumer_id| Ok(consumer_id.parse()?)) + .collect::>>()?, + map_ssrc_consumer_id: dump + .base + .map_ssrc_consumer_id + .iter() + .map(|key_value| Ok((key_value.key, key_value.value.parse()?))) + .collect::>>()?, + map_rtx_ssrc_consumer_id: dump + .base + .map_rtx_ssrc_consumer_id + .iter() + .map(|key_value| Ok((key_value.key, key_value.value.parse()?))) + .collect::>>()?, + data_producer_ids: dump + .base + .data_producer_ids + .iter() + .map(|data_producer_id| Ok(data_producer_id.parse()?)) + .collect::>>()?, + data_consumer_ids: dump + .base + .data_consumer_ids + .iter() + .map(|data_consumer_id| Ok(data_consumer_id.parse()?)) + .collect::>>()?, + recv_rtp_header_extensions: RecvRtpHeaderExtensions::from_fbs( + dump.base.recv_rtp_header_extensions.as_ref(), + ), + rtp_listener: RtpListener::from_fbs(dump.base.rtp_listener.as_ref())?, + max_message_size: dump.base.max_message_size, + sctp_parameters: dump + .base + .sctp_parameters + .as_ref() + .map(|parameters| SctpParameters::from_fbs(parameters.as_ref())), + sctp_state: dump + .base + .sctp_state + .map(|state| SctpState::from_fbs(&state)), + sctp_listener: dump.base.sctp_listener.as_ref().map(|listener| { + SctpListener::from_fbs(listener.as_ref()).expect("Error parsing SctpListner") + }), + trace_event_types: dump + .base + .trace_event_types + .iter() + .map(|event| event.to_string()) + .collect(), + // WebRtcTransport specific. + dtls_parameters: DtlsParameters::from_fbs(*dump.dtls_parameters), + dtls_state: DtlsState::from_fbs(dump.dtls_state), + ice_candidates: dump + .ice_candidates + .iter() + .map(IceCandidate::from_fbs) + .collect(), + ice_parameters: IceParameters::from_fbs(*dump.ice_parameters), + ice_role: IceRole::from_fbs(dump.ice_role), + ice_state: IceState::from_fbs(dump.ice_state), + ice_selected_tuple: dump + .ice_selected_tuple + .map(|tuple| TransportTuple::from_fbs(tuple.as_ref())), + }) + } +} + /// RTC statistics of the [`WebRtcTransport`]. #[derive(Debug, Clone, PartialOrd, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -201,26 +286,27 @@ pub struct WebRtcTransportStat { pub transport_id: TransportId, pub timestamp: u64, pub sctp_state: Option, - pub bytes_received: usize, + pub bytes_received: u64, pub recv_bitrate: u32, - pub bytes_sent: usize, + pub bytes_sent: u64, pub send_bitrate: u32, - pub rtp_bytes_received: usize, + pub rtp_bytes_received: u64, pub rtp_recv_bitrate: u32, - pub rtp_bytes_sent: usize, + pub rtp_bytes_sent: u64, pub rtp_send_bitrate: u32, - pub rtx_bytes_received: usize, + pub rtx_bytes_received: u64, pub rtx_recv_bitrate: u32, - pub rtx_bytes_sent: usize, + pub rtx_bytes_sent: u64, pub rtx_send_bitrate: u32, - pub probation_bytes_sent: usize, + pub probation_bytes_sent: u64, pub probation_send_bitrate: u32, #[serde(skip_serializing_if = "Option::is_none")] pub available_outgoing_bitrate: Option, #[serde(skip_serializing_if = "Option::is_none")] pub available_incoming_bitrate: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub max_incoming_bitrate: Option, + pub max_outgoing_bitrate: Option, + pub min_outgoing_bitrate: Option, #[serde(skip_serializing_if = "Option::is_none")] pub rtp_packet_loss_received: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -233,6 +319,45 @@ pub struct WebRtcTransportStat { pub dtls_state: DtlsState, } +impl WebRtcTransportStat { + pub(crate) fn from_fbs( + stats: web_rtc_transport::GetStatsResponse, + ) -> Result> { + Ok(Self { + transport_id: stats.base.transport_id.parse()?, + timestamp: stats.base.timestamp, + sctp_state: stats.base.sctp_state.as_ref().map(SctpState::from_fbs), + bytes_received: stats.base.bytes_received, + recv_bitrate: stats.base.recv_bitrate, + bytes_sent: stats.base.bytes_sent, + send_bitrate: stats.base.send_bitrate, + rtp_bytes_received: stats.base.rtp_bytes_received, + rtp_recv_bitrate: stats.base.rtp_recv_bitrate, + rtp_bytes_sent: stats.base.rtp_bytes_sent, + rtp_send_bitrate: stats.base.rtp_send_bitrate, + rtx_bytes_received: stats.base.rtx_bytes_received, + rtx_recv_bitrate: stats.base.rtx_recv_bitrate, + rtx_bytes_sent: stats.base.rtx_bytes_sent, + rtx_send_bitrate: stats.base.rtx_send_bitrate, + probation_bytes_sent: stats.base.probation_bytes_sent, + probation_send_bitrate: stats.base.probation_send_bitrate, + available_outgoing_bitrate: stats.base.available_outgoing_bitrate, + available_incoming_bitrate: stats.base.available_incoming_bitrate, + max_incoming_bitrate: stats.base.max_incoming_bitrate, + max_outgoing_bitrate: stats.base.max_outgoing_bitrate, + min_outgoing_bitrate: stats.base.min_outgoing_bitrate, + rtp_packet_loss_received: stats.base.rtp_packet_loss_received, + rtp_packet_loss_sent: stats.base.rtp_packet_loss_sent, + // WebRtcTransport specific. + ice_role: IceRole::from_fbs(stats.ice_role), + ice_state: IceState::from_fbs(stats.ice_state), + ice_selected_tuple: stats + .ice_selected_tuple + .map(|tuple| TransportTuple::from_fbs(tuple.as_ref())), + dtls_state: DtlsState::from_fbs(stats.dtls_state), + }) + } +} /// Remote parameters for [`WebRtcTransport`]. #[derive(Debug, Clone, PartialOrd, Eq, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -320,13 +445,13 @@ impl Inner { if close_request { let channel = self.channel.clone(); let router_id = self.router.id(); - let request = TransportCloseRequest { + let request = TransportCloseRequestFbs { transport_id: self.id, }; self.executor .spawn(async move { - if let Err(error) = channel.request(router_id, request).await { + if let Err(error) = channel.request_fbs(router_id, request).await { error!("transport closing failed on drop: {}", error); } }) @@ -517,29 +642,25 @@ impl TransportGeneric for WebRtcTransport { async fn dump(&self) -> Result { debug!("dump()"); - todo!(); - - /* - serde_json::from_value(self.dump_impl().await?).map_err(|error| { - RequestError::FailedToParse { - error: error.to_string(), - } - }) - */ + if let response::Body::FbsWebRtcTransportDumpResponse(data) = self.dump_impl().await? { + Ok(WebRtcTransportDump::from_fbs(*data).expect("Error parsing dump response")) + } else { + panic!("Wrong message from worker"); + } } async fn get_stats(&self) -> Result, RequestError> { debug!("get_stats()"); - todo!(); - - /* - serde_json::from_value(self.get_stats_impl().await?).map_err(|error| { - RequestError::FailedToParse { - error: error.to_string(), - } - }) - */ + if let response::Body::FbsWebRtcTransportGetStatsResponse(data) = + self.get_stats_impl().await? + { + Ok(vec![ + WebRtcTransportStat::from_fbs(*data).expect("Error parsing dump response") + ]) + } else { + panic!("Wrong message from worker"); + } } } @@ -737,9 +858,9 @@ impl WebRtcTransport { let response = self .inner .channel - .request( + .request_fbs( self.id(), - TransportConnectWebRtcRequest { + WebRtcTransportConnectRequest { dtls_parameters: remote_parameters.dtls_parameters, }, ) @@ -849,13 +970,10 @@ impl WebRtcTransport { pub async fn restart_ice(&self) -> Result { debug!("restart_ice()"); - let response = self - .inner + self.inner .channel - .request(self.id(), TransportRestartIceRequest {}) - .await?; - - Ok(response.ice_parameters) + .request_fbs(self.id(), TransportRestartIceRequest {}) + .await } /// Callback is called when the WebRTC server used during creation of this transport is closed diff --git a/rust/src/srtp_parameters.rs b/rust/src/srtp_parameters.rs index 464b9e2779..e7e90e500b 100644 --- a/rust/src/srtp_parameters.rs +++ b/rust/src/srtp_parameters.rs @@ -1,9 +1,8 @@ //! Collection of SRTP-related data structures that are used to specify SRTP encryption/decryption //! parameters. -use crate::fbs::transport; +use crate::fbs::srtp_parameters; use serde::{Deserialize, Serialize}; -use std::str::FromStr; /// SRTP parameters. #[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Deserialize, Serialize)] @@ -16,16 +15,16 @@ pub struct SrtpParameters { } impl SrtpParameters { - pub(crate) fn from_fbs(tuple: &transport::SrtpParameters) -> Self { + pub(crate) fn from_fbs(tuple: &srtp_parameters::SrtpParameters) -> Self { Self { - crypto_suite: tuple.crypto_suite.parse().unwrap(), + crypto_suite: SrtpCryptoSuite::from_fbs(tuple.crypto_suite), key_base64: String::from(tuple.key_base64.as_str()), } } - pub(crate) fn to_fbs(&self) -> transport::SrtpParameters { - transport::SrtpParameters { - crypto_suite: self.crypto_suite.to_string(), + pub(crate) fn to_fbs(&self) -> srtp_parameters::SrtpParameters { + srtp_parameters::SrtpParameters { + crypto_suite: SrtpCryptoSuite::to_fbs(self.crypto_suite), key_base64: String::from(self.key_base64.as_str()), } } @@ -48,39 +47,28 @@ pub enum SrtpCryptoSuite { AesCm128HmacSha132, } -impl Default for SrtpCryptoSuite { - fn default() -> Self { - Self::AesCm128HmacSha180 +impl SrtpCryptoSuite { + pub(crate) fn from_fbs(crypto_suite: srtp_parameters::SrtpCryptoSuite) -> Self { + match crypto_suite { + srtp_parameters::SrtpCryptoSuite::AeadAes256Gcm => Self::AeadAes256Gcm, + srtp_parameters::SrtpCryptoSuite::AeadAes128Gcm => Self::AeadAes128Gcm, + srtp_parameters::SrtpCryptoSuite::AesCm128HmacSha180 => Self::AesCm128HmacSha180, + srtp_parameters::SrtpCryptoSuite::AesCm128HmacSha132 => Self::AesCm128HmacSha132, + } } -} -// TODO: Remove once SrtpCryptoSuite is defined in fbs. -impl ToString for SrtpCryptoSuite { - fn to_string(&self) -> String { + pub(crate) fn to_fbs(self) -> srtp_parameters::SrtpCryptoSuite { match self { - Self::AeadAes256Gcm => String::from("AEAD_AES_256_GCM"), - Self::AeadAes128Gcm => String::from("AEAD_AES_128_GCM"), - Self::AesCm128HmacSha180 => String::from("AES_CM_128_HMAC_SHA1_80"), - Self::AesCm128HmacSha132 => String::from("AES_CM_128_HMAC_SHA1_32"), + Self::AeadAes256Gcm => srtp_parameters::SrtpCryptoSuite::AeadAes256Gcm, + Self::AeadAes128Gcm => srtp_parameters::SrtpCryptoSuite::AeadAes128Gcm, + Self::AesCm128HmacSha180 => srtp_parameters::SrtpCryptoSuite::AesCm128HmacSha180, + Self::AesCm128HmacSha132 => srtp_parameters::SrtpCryptoSuite::AesCm128HmacSha132, } } } -/// Error that caused [`SrtpCryptoSuite`] parsing error. -#[derive(Debug, Eq, PartialEq)] -pub struct ParseCryptoSuiteError; - -// TODO: Remove once SrtpCryptoSuite is defined in fbs. -impl FromStr for SrtpCryptoSuite { - type Err = ParseCryptoSuiteError; - - fn from_str(s: &str) -> Result { - match s { - "AEAD_AES_256_GCM" => Ok(Self::AeadAes256Gcm), - "AEAD_AES_128_GCM" => Ok(Self::AeadAes128Gcm), - "AES_CM_128_HMAC_SHA1_80" => Ok(Self::AesCm128HmacSha180), - "AES_CM_128_HMAC_SHA1_32" => Ok(Self::AesCm128HmacSha132), - _ => Err(ParseCryptoSuiteError), - } +impl Default for SrtpCryptoSuite { + fn default() -> Self { + Self::AesCm128HmacSha180 } } diff --git a/rust/tests/integration/webrtc_transport.rs b/rust/tests/integration/webrtc_transport.rs index 21c562bf2f..7311aa364c 100644 --- a/rust/tests/integration/webrtc_transport.rs +++ b/rust/tests/integration/webrtc_transport.rs @@ -1,8 +1,8 @@ use futures_lite::future; use hash_hasher::HashedSet; use mediasoup::data_structures::{ - AppData, DtlsFingerprint, DtlsParameters, DtlsRole, DtlsState, IceCandidateTcpType, - IceCandidateType, IceRole, IceState, ListenInfo, Protocol, SctpState, + AppData, DtlsFingerprint, DtlsParameters, DtlsRole, DtlsState, IceCandidateType, IceRole, + IceState, ListenInfo, Protocol, SctpState, }; use mediasoup::prelude::*; use mediasoup::router::{Router, RouterOptions}; @@ -88,7 +88,6 @@ async fn init() -> (Worker, Router) { } #[test] -#[ignore] fn create_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -161,6 +160,8 @@ fn create_succeeds() { .try_into() .unwrap(), ); + // TODO: I wonder how this was not needed before... + webrtc_transport_options.enable_sctp = true; webrtc_transport_options.num_sctp_streams = NumSctpStreams { os: 2048, mis: 2048, @@ -195,42 +196,25 @@ fn create_succeeds() { ); { let ice_candidates = transport1.ice_candidates(); - assert_eq!(ice_candidates.len(), 6); + assert_eq!(ice_candidates.len(), 3); assert_eq!(ice_candidates[0].ip, "9.9.9.1".parse::().unwrap()); assert_eq!(ice_candidates[0].protocol, Protocol::Udp); assert_eq!(ice_candidates[0].r#type, IceCandidateType::Host); assert_eq!(ice_candidates[0].tcp_type, None); - assert_eq!(ice_candidates[1].ip, "9.9.9.1".parse::().unwrap()); - assert_eq!(ice_candidates[1].protocol, Protocol::Tcp); + assert_eq!(ice_candidates[1].ip, "9.9.9.2".parse::().unwrap()); + assert_eq!(ice_candidates[1].protocol, Protocol::Udp); assert_eq!(ice_candidates[1].r#type, IceCandidateType::Host); - assert_eq!( - ice_candidates[1].tcp_type, - Some(IceCandidateTcpType::Passive), - ); - assert_eq!(ice_candidates[2].ip, "9.9.9.2".parse::().unwrap()); + assert_eq!(ice_candidates[1].tcp_type, None); + assert_eq!(ice_candidates[2].ip, "127.0.0.1".parse::().unwrap()); + assert_eq!(ice_candidates[2].protocol, Protocol::Udp); + assert_eq!(ice_candidates[2].r#type, IceCandidateType::Host); + assert_eq!(ice_candidates[2].tcp_type, None); + assert_eq!(ice_candidates[2].ip, "127.0.0.1".parse::().unwrap()); assert_eq!(ice_candidates[2].protocol, Protocol::Udp); assert_eq!(ice_candidates[2].r#type, IceCandidateType::Host); assert_eq!(ice_candidates[2].tcp_type, None); - assert_eq!(ice_candidates[3].ip, "9.9.9.2".parse::().unwrap()); - assert_eq!(ice_candidates[3].protocol, Protocol::Tcp); - assert_eq!(ice_candidates[3].r#type, IceCandidateType::Host); - assert_eq!( - ice_candidates[3].tcp_type, - Some(IceCandidateTcpType::Passive), - ); - assert_eq!(ice_candidates[4].ip, "127.0.0.1".parse::().unwrap()); - assert_eq!(ice_candidates[4].protocol, Protocol::Udp); - assert_eq!(ice_candidates[4].r#type, IceCandidateType::Host); - assert_eq!(ice_candidates[4].tcp_type, None); - assert_eq!(ice_candidates[4].ip, "127.0.0.1".parse::().unwrap()); - assert_eq!(ice_candidates[4].protocol, Protocol::Udp); - assert_eq!(ice_candidates[4].r#type, IceCandidateType::Host); - assert_eq!(ice_candidates[4].tcp_type, None); assert!(ice_candidates[0].priority > ice_candidates[1].priority); assert!(ice_candidates[1].priority > ice_candidates[2].priority); - assert!(ice_candidates[2].priority > ice_candidates[3].priority); - assert!(ice_candidates[3].priority > ice_candidates[4].priority); - assert!(ice_candidates[4].priority > ice_candidates[5].priority); } assert_eq!(transport1.ice_state(), IceState::New); @@ -267,7 +251,6 @@ fn create_succeeds() { } #[test] -#[ignore] fn create_with_fixed_port_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -293,7 +276,6 @@ fn create_with_fixed_port_succeeds() { } #[test] -#[ignore] fn weak() { future::block_on(async move { let (_worker, router) = init().await; @@ -323,7 +305,6 @@ fn weak() { } #[test] -#[ignore] fn create_non_bindable_ip() { future::block_on(async move { let (_worker, router) = init().await; @@ -347,7 +328,6 @@ fn create_non_bindable_ip() { } #[test] -#[ignore] fn get_stats_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -399,7 +379,6 @@ fn get_stats_succeeds() { } #[test] -#[ignore] fn connect_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -624,7 +603,6 @@ fn set_min_outgoing_bitrate_fails_if_value_is_higher_than_current_max_limit() { } #[test] -#[ignore] fn restart_ice_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -727,7 +705,6 @@ fn enable_trace_event_succeeds() { } #[test] -#[ignore] fn close_event() { future::block_on(async move { let (_worker, router) = init().await; diff --git a/worker/fbs/pipeTransport.fbs b/worker/fbs/pipeTransport.fbs index 82cc56515e..13c548d008 100644 --- a/worker/fbs/pipeTransport.fbs +++ b/worker/fbs/pipeTransport.fbs @@ -1,4 +1,5 @@ include "transport.fbs"; +include "srtpParameters.fbs"; namespace FBS.PipeTransport; @@ -12,18 +13,18 @@ table PipeTransportOptions { table ConnectRequest { ip:string (required); port:uint16 = null; - srtp_parameters:FBS.Transport.SrtpParameters; + srtp_parameters:FBS.SrtpParameters.SrtpParameters; } table ConnectResponse { - tuple:FBS.Transport.Tuple; + tuple:FBS.Transport.Tuple (required); } table DumpResponse { base:FBS.Transport.Dump (required); tuple:FBS.Transport.Tuple (required); rtx:bool; - srtp_parameters:FBS.Transport.SrtpParameters; + srtp_parameters:FBS.SrtpParameters.SrtpParameters; } table GetStatsResponse { diff --git a/worker/fbs/plainTransport.fbs b/worker/fbs/plainTransport.fbs index 4470d2eace..9d51a9af9d 100644 --- a/worker/fbs/plainTransport.fbs +++ b/worker/fbs/plainTransport.fbs @@ -1,5 +1,6 @@ include "transport.fbs"; include "sctpParameters.fbs"; +include "srtpParameters.fbs"; namespace FBS.PlainTransport; @@ -10,20 +11,20 @@ table PlainTransportOptions { rtcp_mux:bool; comedia:bool; enable_srtp:bool; - srtp_crypto_suite:string; + srtp_crypto_suite:FBS.SrtpParameters.SrtpCryptoSuite = null; } table ConnectRequest { ip:string; port:uint16 = null; rtcp_port:uint16 = null; - srtp_parameters:FBS.Transport.SrtpParameters; + srtp_parameters:FBS.SrtpParameters.SrtpParameters; } table ConnectResponse { tuple:FBS.Transport.Tuple (required); rtcp_tuple:FBS.Transport.Tuple; - srtp_parameters:FBS.Transport.SrtpParameters; + srtp_parameters:FBS.SrtpParameters.SrtpParameters; } table DumpResponse { @@ -32,7 +33,7 @@ table DumpResponse { comedia:bool; tuple:FBS.Transport.Tuple (required); rtcp_tuple:FBS.Transport.Tuple; - srtp_parameters:FBS.Transport.SrtpParameters; + srtp_parameters:FBS.SrtpParameters.SrtpParameters; } table GetStatsResponse { diff --git a/worker/fbs/request.fbs b/worker/fbs/request.fbs index ac1ad5fd99..7359f235ee 100644 --- a/worker/fbs/request.fbs +++ b/worker/fbs/request.fbs @@ -106,7 +106,7 @@ union Body { FBS.Transport.CloseDataConsumerRequest, PlainTransport_ConnectRequest: FBS.PlainTransport.ConnectRequest, PipeTransport_ConnectRequest: FBS.PipeTransport.ConnectRequest, - FBS.WebRtcTransport.ConnectRequest, + WebRtcTransport_ConnectRequest: FBS.WebRtcTransport.ConnectRequest, FBS.Producer.EnableTraceEventRequest, FBS.Consumer.SetPreferredLayersRequest, FBS.Consumer.SetPriorityRequest, diff --git a/worker/fbs/srtpParameters.fbs b/worker/fbs/srtpParameters.fbs new file mode 100644 index 0000000000..eb376d87c3 --- /dev/null +++ b/worker/fbs/srtpParameters.fbs @@ -0,0 +1,15 @@ + +namespace FBS.SrtpParameters; + +enum SrtpCryptoSuite: uint8 { + AEAD_AES_256_GCM, + AEAD_AES_128_GCM, + AES_CM_128_HMAC_SHA1_80, + AES_CM_128_HMAC_SHA1_32, +} + +table SrtpParameters { + crypto_suite:FBS.SrtpParameters.SrtpCryptoSuite; + key_base64:string (required); +} + diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs index 5b7af3ef61..299dc42982 100644 --- a/worker/fbs/transport.fbs +++ b/worker/fbs/transport.fbs @@ -3,6 +3,7 @@ include "consumer.fbs"; include "rtpParameters.fbs"; include "sctpAssociation.fbs"; include "sctpParameters.fbs"; +include "srtpParameters.fbs"; namespace FBS.Transport; @@ -83,11 +84,6 @@ table Tuple { protocol:FBS.Transport.Protocol=UDP; } -table SrtpParameters { - crypto_suite:string (required); - key_base64:string (required); -} - table RtpListener { ssrc_table:[FBS.Common.Uint32String] (required); mid_table:[FBS.Common.StringString] (required); @@ -108,8 +104,9 @@ table RecvRtpHeaderExtensions { table Options { direct:bool = false; - max_message_size:uint32; - initial_available_outgoing_bitrate:uint32; + /// Only needed for DirectTransport. This value is handled by base Transport. + max_message_size:uint32 = null; + initial_available_outgoing_bitrate:uint32 = null; enable_sctp:bool = false; num_sctp_streams:FBS.SctpParameters.NumSctpStreams; max_sctp_message_size:uint32; @@ -155,9 +152,9 @@ table Stats { probation_send_bitrate:uint32; available_outgoing_bitrate:uint32 = null; available_incoming_bitrate:uint32 = null; - max_incoming_bitrate:uint32; - max_outgoing_bitrate:uint32; - min_outgoing_bitrate:uint32; + max_incoming_bitrate:uint32 = null; + max_outgoing_bitrate:uint32 = null; + min_outgoing_bitrate:uint32 = null; rtp_packet_loss_received:float64 = null; rtp_packet_loss_sent:float64 = null; } diff --git a/worker/fbs/webRtcTransport.fbs b/worker/fbs/webRtcTransport.fbs index 6a77106c35..002123c242 100644 --- a/worker/fbs/webRtcTransport.fbs +++ b/worker/fbs/webRtcTransport.fbs @@ -21,14 +21,36 @@ table WebRtcTransportOptions { listen:Listen (required); } +enum FingerprintAlgorithm: uint8 { + SHA1, + SHA224, + SHA256, + SHA384, + SHA512, +} + table Fingerprint { - algorithm:string (required); + algorithm:FingerprintAlgorithm; value:string (required); } +enum DtlsRole: uint8 { + AUTO, + CLIENT, + SERVER +} + +enum DtlsState: uint8 { + NEW, + CONNECTING, + CONNECTED, + FAILED, + CLOSED +} + table DtlsParameters { fingerprints:[Fingerprint] (required); - role:string; + role:DtlsRole = AUTO; } table IceParameters { @@ -37,14 +59,24 @@ table IceParameters { ice_lite:bool = true; } +enum IceCandidateType: uint8 { HOST } +enum IceCandidateTcpType: uint8 { PASSIVE } +enum IceRole: uint8 { CONTROLLED, CONTROLLING } +enum IceState: uint8 { + NEW, + CONNECTED, + COMPLETED, + DISCONNECTED, +} + table IceCandidate { foundation:string (required); priority:uint32; ip:string (required); protocol:FBS.Transport.Protocol=UDP; port:uint16; - type:string; - tcp_type:string; + type:IceCandidateType; + tcp_type:IceCandidateTcpType = null; } table ConnectRequest { @@ -52,26 +84,26 @@ table ConnectRequest { } table ConnectResponse { - dtls_local_role:string (required); + dtls_local_role:DtlsRole; } table DumpResponse { base:FBS.Transport.Dump (required); - ice_role:string (required); + ice_role:IceRole; ice_parameters:IceParameters (required); ice_candidates:[IceCandidate] (required); - ice_state:string (required); + ice_state:IceState; ice_selected_tuple:FBS.Transport.Tuple; dtls_parameters:DtlsParameters (required); - dtls_state:string (required); + dtls_state:DtlsState; } table GetStatsResponse { base:FBS.Transport.Stats (required); - ice_role:string (required); - ice_state:string (required); + ice_role:IceRole; + ice_state:IceState; ice_selected_tuple:FBS.Transport.Tuple; - dtls_state:string (required); + dtls_state:DtlsState; } // Notifications from Worker. @@ -80,9 +112,6 @@ table IceSelectedTupleChangeNotification { tuple:FBS.Transport.Tuple (required); } -enum IceState: uint8 { NEW = 0, CONNECTED, COMPLETED, DISCONNECTED, CLOSED } -enum DtlsState: uint8 { NEW = 0, CONNECTING, CONNECTED, FAILED, CLOSED } - table IceStateChangeNotification { ice_state:IceState; } diff --git a/worker/include/RTC/DtlsTransport.hpp b/worker/include/RTC/DtlsTransport.hpp index 80b03802e1..9cec6ae8f6 100644 --- a/worker/include/RTC/DtlsTransport.hpp +++ b/worker/include/RTC/DtlsTransport.hpp @@ -2,6 +2,7 @@ #define MS_RTC_DTLS_TRANSPORT_HPP #include "common.hpp" +#include "FBS/webRtcTransport_generated.h" #include "RTC/SrtpSession.hpp" #include "handles/TimerHandle.hpp" #include @@ -28,7 +29,6 @@ namespace RTC public: enum class Role { - NONE = 0, AUTO = 1, CLIENT, SERVER @@ -37,7 +37,6 @@ namespace RTC public: enum class FingerprintAlgorithm { - NONE = 0, SHA1 = 1, SHA224, SHA256, @@ -48,7 +47,7 @@ namespace RTC public: struct Fingerprint { - FingerprintAlgorithm algorithm{ FingerprintAlgorithm::NONE }; + FingerprintAlgorithm algorithm; std::string value; }; @@ -97,30 +96,11 @@ namespace RTC public: static void ClassInit(); static void ClassDestroy(); - static Role StringToRole(const std::string& role) - { - auto it = DtlsTransport::string2Role.find(role); - - if (it != DtlsTransport::string2Role.end()) - return it->second; - else - return DtlsTransport::Role::NONE; - } - static FingerprintAlgorithm GetFingerprintAlgorithm(const std::string& fingerprint) - { - auto it = DtlsTransport::string2FingerprintAlgorithm.find(fingerprint); - - if (it != DtlsTransport::string2FingerprintAlgorithm.end()) - return it->second; - else - return DtlsTransport::FingerprintAlgorithm::NONE; - } - static std::string& GetFingerprintAlgorithmString(FingerprintAlgorithm fingerprint) - { - auto it = DtlsTransport::fingerprintAlgorithm2String.find(fingerprint); - - return it->second; - } + static Role RoleFromFbs(FBS::WebRtcTransport::DtlsRole role); + static FBS::WebRtcTransport::DtlsRole RoleToFbs(Role role); + static FBS::WebRtcTransport::DtlsState StateToFbs(DtlsState state); + static FingerprintAlgorithm AlgorithmFromFbs(FBS::WebRtcTransport::FingerprintAlgorithm algorithm); + static FBS::WebRtcTransport::FingerprintAlgorithm AlgorithmToFbs(FingerprintAlgorithm algorithm); static bool IsDtls(const uint8_t* data, size_t len) { // clang-format off @@ -167,7 +147,7 @@ namespace RTC { return this->state; } - Role GetLocalRole() const + std::optional GetLocalRole() const { return this->localRole; } @@ -198,7 +178,7 @@ namespace RTC bool ProcessHandshake(); bool CheckRemoteFingerprint(); void ExtractSrtpKeys(RTC::SrtpSession::CryptoSuite srtpCryptoSuite); - RTC::SrtpSession::CryptoSuite GetNegotiatedSrtpCryptoSuite(); + std::optional GetNegotiatedSrtpCryptoSuite(); /* Callbacks fired by OpenSSL events. */ public: @@ -218,8 +198,8 @@ namespace RTC TimerHandle* timer{ nullptr }; // Others. DtlsState state{ DtlsState::NEW }; - Role localRole{ Role::NONE }; - Fingerprint remoteFingerprint; + std::optional localRole; + std::optional remoteFingerprint; bool handshakeDone{ false }; bool handshakeDoneNow{ false }; std::string remoteCert; diff --git a/worker/include/RTC/IceCandidate.hpp b/worker/include/RTC/IceCandidate.hpp index 0fef17b75d..db1a9e047b 100644 --- a/worker/include/RTC/IceCandidate.hpp +++ b/worker/include/RTC/IceCandidate.hpp @@ -27,6 +27,12 @@ namespace RTC PASSIVE = 1 }; + public: + static CandidateType CandidateTypeFromFbs(FBS::WebRtcTransport::IceCandidateType type); + static FBS::WebRtcTransport::IceCandidateType CandidateTypeToFbs(CandidateType type); + static TcpCandidateType TcpCandidateTypeFromFbs(FBS::WebRtcTransport::IceCandidateTcpType type); + static FBS::WebRtcTransport::IceCandidateTcpType TcpCandidateTypeToFbs(TcpCandidateType type); + public: IceCandidate(RTC::UdpSocket* udpSocket, uint32_t priority) : foundation("udpcandidate"), priority(priority), ip(udpSocket->GetLocalIp()), diff --git a/worker/include/RTC/IceServer.hpp b/worker/include/RTC/IceServer.hpp index 51fa85919d..acbdea2909 100644 --- a/worker/include/RTC/IceServer.hpp +++ b/worker/include/RTC/IceServer.hpp @@ -2,6 +2,7 @@ #define MS_RTC_ICE_SERVER_HPP #include "common.hpp" +#include "FBS/webRtcTransport_generated.h" #include "RTC/StunPacket.hpp" #include "RTC/TransportTuple.hpp" #include @@ -17,9 +18,13 @@ namespace RTC NEW = 1, CONNECTED, COMPLETED, - DISCONNECTED + DISCONNECTED, }; + public: + static IceState RoleFromFbs(FBS::WebRtcTransport::IceState state); + static FBS::WebRtcTransport::IceState IceStateToFbs(IceState state); + public: class Listener { diff --git a/worker/include/RTC/PlainTransport.hpp b/worker/include/RTC/PlainTransport.hpp index c0cd6f5901..5b728a406a 100644 --- a/worker/include/RTC/PlainTransport.hpp +++ b/worker/include/RTC/PlainTransport.hpp @@ -13,10 +13,6 @@ namespace RTC { class PlainTransport : public RTC::Transport, public RTC::UdpSocket::Listener { - private: - static absl::flat_hash_map string2SrtpCryptoSuite; - static absl::flat_hash_map srtpCryptoSuite2String; - public: PlainTransport( RTC::Shared* shared, diff --git a/worker/include/RTC/SrtpSession.hpp b/worker/include/RTC/SrtpSession.hpp index 7b6f34c0f0..61108b6cee 100644 --- a/worker/include/RTC/SrtpSession.hpp +++ b/worker/include/RTC/SrtpSession.hpp @@ -2,6 +2,7 @@ #define MS_RTC_SRTP_SESSION_HPP #include "common.hpp" +#include "FBS/srtpParameters_generated.h" #include namespace RTC @@ -11,8 +12,7 @@ namespace RTC public: enum class CryptoSuite { - NONE = 0, - AEAD_AES_256_GCM = 1, + AEAD_AES_256_GCM = 0, AEAD_AES_128_GCM, AES_CM_128_HMAC_SHA1_80, AES_CM_128_HMAC_SHA1_32, @@ -27,6 +27,8 @@ namespace RTC public: static void ClassInit(); + static FBS::SrtpParameters::SrtpCryptoSuite CryptoSuiteToFbs(CryptoSuite cryptoSuite); + static CryptoSuite CryptoSuiteFromFbs(FBS::SrtpParameters::SrtpCryptoSuite cryptoSuite); private: static void OnSrtpEvent(srtp_event_data_t* data); diff --git a/worker/src/Channel/ChannelSocket.cpp b/worker/src/Channel/ChannelSocket.cpp index 8d0f54bb13..abdcf11f9f 100644 --- a/worker/src/Channel/ChannelSocket.cpp +++ b/worker/src/Channel/ChannelSocket.cpp @@ -179,10 +179,11 @@ namespace Channel { const auto* message = FBS::Message::GetMessage(msg); - // TMP: For debugging. +#if MS_LOG_DEV_LEVEL == 3 auto s = flatbuffers::FlatBufferToString( reinterpret_cast(msg), FBS::Message::MessageTypeTable()); - MS_ERROR("%s", s.c_str()); + MS_DUMP("%s", s.c_str()); +#endif if (message->type() == FBS::Message::Type::REQUEST) { @@ -256,12 +257,13 @@ namespace Channel { MS_TRACE(); - auto* message = FBS::Message::GetMessage(msg); + const auto* message = FBS::Message::GetMessage(msg); - // TMP: For debugging. - // auto s = flatbuffers::FlatBufferToString( - // reinterpret_cast(msg), FBS::Message::MessageTypeTable()); - // MS_ERROR("%s", s.c_str()); +#if MS_LOG_DEV_LEVEL == 3 + auto s = flatbuffers::FlatBufferToString( + reinterpret_cast(msg), FBS::Message::MessageTypeTable()); + MS_DUMP("%s", s.c_str()); +#endif if (message->type() == FBS::Message::Type::REQUEST) { diff --git a/worker/src/RTC/DtlsTransport.cpp b/worker/src/RTC/DtlsTransport.cpp index 51413f0238..04c4d4b179 100644 --- a/worker/src/RTC/DtlsTransport.cpp +++ b/worker/src/RTC/DtlsTransport.cpp @@ -149,6 +149,101 @@ namespace RTC SSL_CTX_free(DtlsTransport::sslCtx); } + DtlsTransport::Role DtlsTransport::RoleFromFbs(FBS::WebRtcTransport::DtlsRole role) + { + switch (role) + { + case FBS::WebRtcTransport::DtlsRole::AUTO: + return DtlsTransport::Role::AUTO; + + case FBS::WebRtcTransport::DtlsRole::CLIENT: + return DtlsTransport::Role::CLIENT; + + case FBS::WebRtcTransport::DtlsRole::SERVER: + return DtlsTransport::Role::SERVER; + } + } + + FBS::WebRtcTransport::DtlsRole DtlsTransport::RoleToFbs(DtlsTransport::Role role) + { + switch (role) + { + case DtlsTransport::Role::AUTO: + return FBS::WebRtcTransport::DtlsRole::AUTO; + + case DtlsTransport::Role::CLIENT: + return FBS::WebRtcTransport::DtlsRole::CLIENT; + + case DtlsTransport::Role::SERVER: + return FBS::WebRtcTransport::DtlsRole::SERVER; + } + } + + FBS::WebRtcTransport::DtlsState DtlsTransport::StateToFbs(DtlsTransport::DtlsState state) + { + switch (state) + { + case DtlsTransport::DtlsState::NEW: + return FBS::WebRtcTransport::DtlsState::NEW; + + case DtlsTransport::DtlsState::CONNECTING: + return FBS::WebRtcTransport::DtlsState::CONNECTING; + + case DtlsTransport::DtlsState::CONNECTED: + return FBS::WebRtcTransport::DtlsState::CONNECTED; + + case DtlsTransport::DtlsState::FAILED: + return FBS::WebRtcTransport::DtlsState::FAILED; + + case DtlsTransport::DtlsState::CLOSED: + return FBS::WebRtcTransport::DtlsState::CLOSED; + } + } + + DtlsTransport::FingerprintAlgorithm DtlsTransport::AlgorithmFromFbs( + FBS::WebRtcTransport::FingerprintAlgorithm algorithm) + { + switch (algorithm) + { + case FBS::WebRtcTransport::FingerprintAlgorithm::SHA1: + return DtlsTransport::FingerprintAlgorithm::SHA1; + + case FBS::WebRtcTransport::FingerprintAlgorithm::SHA224: + return DtlsTransport::FingerprintAlgorithm::SHA224; + + case FBS::WebRtcTransport::FingerprintAlgorithm::SHA256: + return DtlsTransport::FingerprintAlgorithm::SHA256; + + case FBS::WebRtcTransport::FingerprintAlgorithm::SHA384: + return DtlsTransport::FingerprintAlgorithm::SHA384; + + case FBS::WebRtcTransport::FingerprintAlgorithm::SHA512: + return DtlsTransport::FingerprintAlgorithm::SHA512; + } + } + + FBS::WebRtcTransport::FingerprintAlgorithm DtlsTransport::AlgorithmToFbs( + DtlsTransport::FingerprintAlgorithm algorithm) + { + switch (algorithm) + { + case DtlsTransport::FingerprintAlgorithm::SHA1: + return FBS::WebRtcTransport::FingerprintAlgorithm::SHA1; + + case DtlsTransport::FingerprintAlgorithm::SHA224: + return FBS::WebRtcTransport::FingerprintAlgorithm::SHA224; + + case DtlsTransport::FingerprintAlgorithm::SHA256: + return FBS::WebRtcTransport::FingerprintAlgorithm::SHA256; + + case DtlsTransport::FingerprintAlgorithm::SHA384: + return FBS::WebRtcTransport::FingerprintAlgorithm::SHA384; + + case DtlsTransport::FingerprintAlgorithm::SHA512: + return FBS::WebRtcTransport::FingerprintAlgorithm::SHA512; + } + } + void DtlsTransport::GenerateCertificateAndPrivateKey() { MS_TRACE(); @@ -488,7 +583,7 @@ namespace RTC // Store it in the vector. DtlsTransport::Fingerprint fingerprint; - fingerprint.algorithm = DtlsTransport::GetFingerprintAlgorithm(algorithmString); + fingerprint.algorithm = algorithm; fingerprint.value = hexFingerprint; DtlsTransport::localFingerprints.push_back(fingerprint); @@ -618,18 +713,20 @@ namespace RTC default:; } - switch (this->localRole) + if (this->localRole.has_value()) { - case Role::AUTO: - role = "auto"; - break; - case Role::SERVER: - role = "server"; - break; - case Role::CLIENT: - role = "client"; - break; - default:; + switch (this->localRole.value()) + { + case Role::AUTO: + role = "auto"; + break; + case Role::SERVER: + role = "server"; + break; + case Role::CLIENT: + role = "client"; + break; + } } MS_DUMP(""); @@ -647,9 +744,7 @@ namespace RTC localRole == Role::CLIENT || localRole == Role::SERVER, "local DTLS role must be 'client' or 'server'"); - const Role previousLocalRole = this->localRole; - - if (localRole == previousLocalRole) + if (this->localRole.has_value() && localRole == this->localRole.value()) { MS_ERROR("same local DTLS role provided, doing nothing"); @@ -657,7 +752,9 @@ namespace RTC } // If the previous local DTLS role was 'client' or 'server' do reset. - if (previousLocalRole == Role::CLIENT || previousLocalRole == Role::SERVER) + if ( + this->localRole.has_value() && + (this->localRole.value() == Role::CLIENT || this->localRole.value() == Role::SERVER)) { MS_DEBUG_TAG(dtls, "resetting DTLS due to local role change"); @@ -671,7 +768,7 @@ namespace RTC this->state = DtlsState::CONNECTING; this->listener->OnDtlsTransportConnecting(this); - switch (this->localRole) + switch (this->localRole.value()) { case Role::CLIENT: { @@ -706,9 +803,6 @@ namespace RTC { MS_TRACE(); - MS_ASSERT( - fingerprint.algorithm != FingerprintAlgorithm::NONE, "no fingerprint algorithm provided"); - this->remoteFingerprint = fingerprint; // The remote fingerpring may have been set after DTLS handshake was done, @@ -840,7 +934,7 @@ namespace RTC // SendPendingOutgoingDTLSData(). SSL_shutdown(this->ssl); - this->localRole = Role::NONE; + this->localRole.reset(); this->state = DtlsState::NEW; this->handshakeDone = false; this->handshakeDoneNow = false; @@ -913,7 +1007,7 @@ namespace RTC this->timer->Stop(); // Process the handshake just once (ignore if DTLS renegotiation). - if (!wasHandshakeDone && this->remoteFingerprint.algorithm != FingerprintAlgorithm::NONE) + if (!wasHandshakeDone) return ProcessHandshake(); return true; @@ -1031,8 +1125,6 @@ namespace RTC MS_TRACE(); MS_ASSERT(this->handshakeDone, "handshake not done yet"); - MS_ASSERT( - this->remoteFingerprint.algorithm != FingerprintAlgorithm::NONE, "remote fingerprint not set"); // Validate the remote fingerprint. if (!CheckRemoteFingerprint()) @@ -1047,12 +1139,12 @@ namespace RTC } // Get the negotiated SRTP crypto suite. - RTC::SrtpSession::CryptoSuite srtpCryptoSuite = GetNegotiatedSrtpCryptoSuite(); + auto srtpCryptoSuite = GetNegotiatedSrtpCryptoSuite(); - if (srtpCryptoSuite != RTC::SrtpSession::CryptoSuite::NONE) + if (srtpCryptoSuite) { // Extract the SRTP keys (will notify the listener with them). - ExtractSrtpKeys(srtpCryptoSuite); + ExtractSrtpKeys(srtpCryptoSuite.value()); return true; } @@ -1074,8 +1166,7 @@ namespace RTC { MS_TRACE(); - MS_ASSERT( - this->remoteFingerprint.algorithm != FingerprintAlgorithm::NONE, "remote fingerprint not set"); + MS_ASSERT(this->remoteFingerprint.has_value(), "remote fingerprint not set"); X509* certificate; uint8_t binaryFingerprint[EVP_MAX_MD_SIZE]; @@ -1093,7 +1184,7 @@ namespace RTC return false; } - switch (this->remoteFingerprint.algorithm) + switch (this->remoteFingerprint->algorithm) { case FingerprintAlgorithm::SHA1: hashFunction = EVP_sha1(); @@ -1114,9 +1205,6 @@ namespace RTC case FingerprintAlgorithm::SHA512: hashFunction = EVP_sha512(); break; - - default: - MS_ABORT("unknown algorithm"); } // Compare the remote fingerprint with the value given via signaling. @@ -1138,13 +1226,13 @@ namespace RTC } hexFingerprint[(size * 3) - 1] = '\0'; - if (this->remoteFingerprint.value != hexFingerprint) + if (this->remoteFingerprint->value != hexFingerprint) { MS_WARN_TAG( dtls, "fingerprint in the remote certificate (%s) does not match the announced one (%s)", hexFingerprint, - this->remoteFingerprint.value.c_str()); + this->remoteFingerprint->value.c_str()); X509_free(certificate); @@ -1233,11 +1321,6 @@ namespace RTC break; } - - default: - { - MS_ABORT("unknown SRTP crypto suite"); - } } auto* srtpMaterial = new uint8_t[srtpMasterLength * 2]; @@ -1253,8 +1336,9 @@ namespace RTC this->ssl, srtpMaterial, srtpMasterLength * 2, "EXTRACTOR-dtls_srtp", 19, nullptr, 0, 0); MS_ASSERT(ret != 0, "SSL_export_keying_material() failed"); + MS_ASSERT(this->localRole.has_value(), "no DTLS role set"); - switch (this->localRole) + switch (this->localRole.value()) { case Role::SERVER: { @@ -1305,11 +1389,11 @@ namespace RTC delete[] srtpRemoteMasterKey; } - inline RTC::SrtpSession::CryptoSuite DtlsTransport::GetNegotiatedSrtpCryptoSuite() + inline std::optional DtlsTransport::GetNegotiatedSrtpCryptoSuite() { MS_TRACE(); - RTC::SrtpSession::CryptoSuite negotiatedSrtpCryptoSuite = RTC::SrtpSession::CryptoSuite::NONE; + std::optional negotiatedSrtpCryptoSuite; // Ensure that the SRTP crypto suite has been negotiated. // NOTE: This is a OpenSSL type. @@ -1332,8 +1416,7 @@ namespace RTC } MS_ASSERT( - negotiatedSrtpCryptoSuite != RTC::SrtpSession::CryptoSuite::NONE, - "chosen SRTP crypto suite is not an available one"); + negotiatedSrtpCryptoSuite.has_value(), "chosen SRTP crypto suite is not an available one"); return negotiatedSrtpCryptoSuite; } diff --git a/worker/src/RTC/IceCandidate.cpp b/worker/src/RTC/IceCandidate.cpp index f04aa10c21..d3e23ee978 100644 --- a/worker/src/RTC/IceCandidate.cpp +++ b/worker/src/RTC/IceCandidate.cpp @@ -6,34 +6,61 @@ namespace RTC { - /* Instance methods. */ + /* Class methods. */ - flatbuffers::Offset IceCandidate::FillBuffer( - flatbuffers::FlatBufferBuilder& builder) const + IceCandidate::CandidateType IceCandidate::CandidateTypeFromFbs( + FBS::WebRtcTransport::IceCandidateType type) { - MS_TRACE(); + switch (type) + { + case FBS::WebRtcTransport::IceCandidateType::HOST: + return IceCandidate::CandidateType::HOST; + } + } - auto protocol = TransportTuple::ProtocolToFbs(this->protocol); + FBS::WebRtcTransport::IceCandidateType IceCandidate::CandidateTypeToFbs(IceCandidate::CandidateType type) + { + switch (type) + { + case IceCandidate::CandidateType::HOST: + return FBS::WebRtcTransport::IceCandidateType::HOST; + } + } - std::string type; + IceCandidate::TcpCandidateType IceCandidate::TcpCandidateTypeFromFbs( + FBS::WebRtcTransport::IceCandidateTcpType type) + { + switch (type) + { + case FBS::WebRtcTransport::IceCandidateTcpType::PASSIVE: + return IceCandidate::TcpCandidateType::PASSIVE; + } + } - switch (this->type) + FBS::WebRtcTransport::IceCandidateTcpType IceCandidate::TcpCandidateTypeToFbs( + IceCandidate::TcpCandidateType type) + { + switch (type) { - case CandidateType::HOST: - type = "host"; - break; + case IceCandidate::TcpCandidateType::PASSIVE: + return FBS::WebRtcTransport::IceCandidateTcpType::PASSIVE; } + } + + /* Instance methods. */ - std::string tcpType; + flatbuffers::Offset IceCandidate::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const + { + MS_TRACE(); + + auto protocol = TransportTuple::ProtocolToFbs(this->protocol); + auto type = CandidateTypeToFbs(this->type); + flatbuffers::Optional tcpType; if (this->protocol == Protocol::TCP) { - switch (this->tcpType) - { - case TcpCandidateType::PASSIVE: - tcpType = "passive"; - break; - } + tcpType.emplace(TcpCandidateTypeToFbs(this->tcpType)); } return FBS::WebRtcTransport::CreateIceCandidateDirect( @@ -49,8 +76,8 @@ namespace RTC // port. this->port, // type. - type.c_str(), + type, // tcpType. - tcpType.c_str()); + tcpType); } } // namespace RTC diff --git a/worker/src/RTC/IceServer.cpp b/worker/src/RTC/IceServer.cpp index fde3d25a1b..ca215134a0 100644 --- a/worker/src/RTC/IceServer.cpp +++ b/worker/src/RTC/IceServer.cpp @@ -14,6 +14,43 @@ namespace RTC thread_local static uint8_t StunSerializeBuffer[StunSerializeBufferSize]; static constexpr size_t MaxTuples{ 8 }; + /* Class methods. */ + IceServer::IceState IceStateFromFbs(FBS::WebRtcTransport::IceState state) + { + switch (state) + { + case FBS::WebRtcTransport::IceState::NEW: + return IceServer::IceState::NEW; + + case FBS::WebRtcTransport::IceState::CONNECTED: + return IceServer::IceState::CONNECTED; + + case FBS::WebRtcTransport::IceState::COMPLETED: + return IceServer::IceState::COMPLETED; + + case FBS::WebRtcTransport::IceState::DISCONNECTED: + return IceServer::IceState::DISCONNECTED; + } + } + + FBS::WebRtcTransport::IceState IceServer::IceStateToFbs(IceServer::IceState state) + { + switch (state) + { + case IceServer::IceState::NEW: + return FBS::WebRtcTransport::IceState::NEW; + + case IceServer::IceState::CONNECTED: + return FBS::WebRtcTransport::IceState::CONNECTED; + + case IceServer::IceState::COMPLETED: + return FBS::WebRtcTransport::IceState::COMPLETED; + + case IceServer::IceState::DISCONNECTED: + return FBS::WebRtcTransport::IceState::DISCONNECTED; + } + } + /* Instance methods. */ IceServer::IceServer(Listener* listener, const std::string& usernameFragment, const std::string& password) diff --git a/worker/src/RTC/PipeTransport.cpp b/worker/src/RTC/PipeTransport.cpp index ea17fe8b3f..ebfb123ab9 100644 --- a/worker/src/RTC/PipeTransport.cpp +++ b/worker/src/RTC/PipeTransport.cpp @@ -15,7 +15,6 @@ namespace RTC RTC::SrtpSession::CryptoSuite PipeTransport::srtpCryptoSuite{ RTC::SrtpSession::CryptoSuite::AEAD_AES_256_GCM }; - std::string PipeTransport::srtpCryptoSuiteString{ "AEAD_AES_256_GCM" }; // MAster length of AEAD_AES_256_GCM. size_t PipeTransport::srtpMasterLength{ 44 }; @@ -173,12 +172,14 @@ namespace RTC } // Add srtpParameters. - flatbuffers::Offset srtpParameters; + flatbuffers::Offset srtpParameters; if (HasSrtp()) { - srtpParameters = FBS::Transport::CreateSrtpParametersDirect( - builder, PipeTransport::srtpCryptoSuiteString.c_str(), this->srtpKeyBase64.c_str()); + srtpParameters = FBS::SrtpParameters::CreateSrtpParametersDirect( + builder, + SrtpSession::CryptoSuiteToFbs(PipeTransport::srtpCryptoSuite), + this->srtpKeyBase64.c_str()); } // Add base transport dump. @@ -288,7 +289,7 @@ namespace RTC // NOTE: We just use AEAD_AES_256_GCM as SRTP crypto suite in // PipeTransport. - if (srtpParameters->cryptoSuite()->str() != PipeTransport::srtpCryptoSuiteString) + if (srtpParameters->cryptoSuite() != FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_256_GCM) { MS_THROW_TYPE_ERROR("invalid/unsupported srtpParameters.cryptoSuite"); } diff --git a/worker/src/RTC/PlainTransport.cpp b/worker/src/RTC/PlainTransport.cpp index 224efc4fd2..265cd52887 100644 --- a/worker/src/RTC/PlainTransport.cpp +++ b/worker/src/RTC/PlainTransport.cpp @@ -26,22 +26,6 @@ namespace RTC /* Class variables. */ - // clang-format off - absl::flat_hash_map PlainTransport::string2SrtpCryptoSuite = - { - { "AEAD_AES_256_GCM", RTC::SrtpSession::CryptoSuite::AEAD_AES_256_GCM }, - { "AEAD_AES_128_GCM", RTC::SrtpSession::CryptoSuite::AEAD_AES_128_GCM }, - { "AES_CM_128_HMAC_SHA1_80", RTC::SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_80 }, - { "AES_CM_128_HMAC_SHA1_32", RTC::SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_32 } - }; - absl::flat_hash_map PlainTransport::srtpCryptoSuite2String = - { - { RTC::SrtpSession::CryptoSuite::AEAD_AES_256_GCM, "AEAD_AES_256_GCM" }, - { RTC::SrtpSession::CryptoSuite::AEAD_AES_128_GCM, "AEAD_AES_128_GCM" }, - { RTC::SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_80, "AES_CM_128_HMAC_SHA1_80" }, - { RTC::SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_32, "AES_CM_128_HMAC_SHA1_32" } - }; - /* Instance methods. */ PlainTransport::PlainTransport( @@ -70,12 +54,14 @@ namespace RTC this->listenInfo.port = options->listenInfo()->port(); - if (flatbuffers::IsFieldPresent(options->listenInfo(), FBS::Transport::ListenInfo::VT_SENDBUFFERSIZE)) + if (flatbuffers::IsFieldPresent( + options->listenInfo(), FBS::Transport::ListenInfo::VT_SENDBUFFERSIZE)) { this->listenInfo.sendBufferSize = options->listenInfo()->sendBufferSize(); } - if (flatbuffers::IsFieldPresent(options->listenInfo(), FBS::Transport::ListenInfo::VT_RECVBUFFERSIZE)) + if (flatbuffers::IsFieldPresent( + options->listenInfo(), FBS::Transport::ListenInfo::VT_RECVBUFFERSIZE)) { this->listenInfo.recvBufferSize = options->listenInfo()->recvBufferSize(); } @@ -85,7 +71,8 @@ namespace RTC if (!this->rtcpMux) { - if (flatbuffers::IsFieldPresent(options, FBS::PlainTransport::PlainTransportOptions::VT_RTCPLISTENINFO)) + if (flatbuffers::IsFieldPresent( + options, FBS::PlainTransport::PlainTransportOptions::VT_RTCPLISTENINFO)) { if (options->rtcpListenInfo()->protocol() != FBS::Transport::Protocol::UDP) { @@ -97,19 +84,22 @@ namespace RTC // This may throw. Utils::IP::NormalizeIp(this->rtcpListenInfo.ip); - if (flatbuffers::IsFieldPresent(options->rtcpListenInfo(), FBS::Transport::ListenInfo::VT_ANNOUNCEDIP)) + if (flatbuffers::IsFieldPresent( + options->rtcpListenInfo(), FBS::Transport::ListenInfo::VT_ANNOUNCEDIP)) { this->rtcpListenInfo.announcedIp.assign(options->rtcpListenInfo()->announcedIp()->str()); } this->rtcpListenInfo.port = options->rtcpListenInfo()->port(); - if (flatbuffers::IsFieldPresent(options->rtcpListenInfo(), FBS::Transport::ListenInfo::VT_SENDBUFFERSIZE)) + if (flatbuffers::IsFieldPresent( + options->rtcpListenInfo(), FBS::Transport::ListenInfo::VT_SENDBUFFERSIZE)) { this->rtcpListenInfo.sendBufferSize = options->rtcpListenInfo()->sendBufferSize(); } - if (flatbuffers::IsFieldPresent(options->rtcpListenInfo(), FBS::Transport::ListenInfo::VT_RECVBUFFERSIZE)) + if (flatbuffers::IsFieldPresent( + options->rtcpListenInfo(), FBS::Transport::ListenInfo::VT_RECVBUFFERSIZE)) { this->rtcpListenInfo.recvBufferSize = options->rtcpListenInfo()->recvBufferSize(); } @@ -123,22 +113,13 @@ namespace RTC if (options->enableSrtp()) { - if (!flatbuffers::IsFieldPresent( - options, FBS::PlainTransport::PlainTransportOptions::VT_SRTPCRYPTOSUITE)) + if (!options->srtpCryptoSuite().has_value()) { MS_THROW_TYPE_ERROR("missing srtpCryptoSuite"); } - // Ensure it's a crypto suite supported by us. - auto it = PlainTransport::string2SrtpCryptoSuite.find(options->srtpCryptoSuite()->str()); - - if (it == PlainTransport::string2SrtpCryptoSuite.end()) - { - MS_THROW_TYPE_ERROR("invalid/unsupported srtpCryptoSuite"); - } - // NOTE: The SRTP crypto suite may change later on connect(). - this->srtpCryptoSuite = it->second; + this->srtpCryptoSuite = SrtpSession::CryptoSuiteFromFbs(options->srtpCryptoSuite().value()); switch (this->srtpCryptoSuite) { @@ -203,7 +184,8 @@ namespace RTC // This may throw. if (this->rtcpListenInfo.port != 0) { - this->rtcpUdpSocket = new RTC::UdpSocket(this, this->rtcpListenInfo.ip, this->rtcpListenInfo.port); + this->rtcpUdpSocket = + new RTC::UdpSocket(this, this->rtcpListenInfo.ip, this->rtcpListenInfo.port); } else { @@ -296,7 +278,12 @@ namespace RTC } tuple = FBS::Transport::CreateTupleDirect( - builder, localIp.c_str(), this->udpSocket->GetLocalPort(), nullptr, 0, FBS::Transport::Protocol::UDP); + builder, + localIp.c_str(), + this->udpSocket->GetLocalPort(), + nullptr, + 0, + FBS::Transport::Protocol::UDP); } // Add rtcpTuple. @@ -322,19 +309,22 @@ namespace RTC } rtcpTuple = FBS::Transport::CreateTupleDirect( - builder, localIp.c_str(), this->rtcpUdpSocket->GetLocalPort(), nullptr, 0, FBS::Transport::Protocol::UDP); + builder, + localIp.c_str(), + this->rtcpUdpSocket->GetLocalPort(), + nullptr, + 0, + FBS::Transport::Protocol::UDP); } } // Add srtpParameters. - flatbuffers::Offset srtpParameters; + flatbuffers::Offset srtpParameters; if (HasSrtp()) { - srtpParameters = FBS::Transport::CreateSrtpParametersDirect( - builder, - PlainTransport::srtpCryptoSuite2String[this->srtpCryptoSuite].c_str(), - this->srtpKeyBase64.c_str()); + srtpParameters = FBS::SrtpParameters::CreateSrtpParametersDirect( + builder, SrtpSession::CryptoSuiteToFbs(this->srtpCryptoSuite), this->srtpKeyBase64.c_str()); } // Add base transport dump. @@ -345,7 +335,7 @@ namespace RTC } flatbuffers::Offset PlainTransport::FillBufferStats( - flatbuffers::FlatBufferBuilder& builder) + flatbuffers::FlatBufferBuilder& builder) { MS_TRACE(); @@ -360,7 +350,6 @@ namespace RTC { std::string localIp; - if (this->listenInfo.announcedIp.empty()) { localIp = this->udpSocket->GetLocalIp(); @@ -371,18 +360,17 @@ namespace RTC } tuple = FBS::Transport::CreateTupleDirect( - builder, - // localIp. - localIp.c_str(), - // localPort, - this->udpSocket->GetLocalPort(), - // remoteIp. - nullptr, - // remotePort. - 0, - // protocol. - FBS::Transport::Protocol::UDP - ); + builder, + // localIp. + localIp.c_str(), + // localPort, + this->udpSocket->GetLocalPort(), + // remoteIp. + nullptr, + // remotePort. + 0, + // protocol. + FBS::Transport::Protocol::UDP); } // Add rtcpTuple. @@ -397,12 +385,7 @@ namespace RTC auto base = Transport::FillBufferStats(builder); return FBS::PlainTransport::CreateGetStatsResponse( - builder, - base, - this->rtcpMux, - this->comedia, - tuple, - rtcpTuple); + builder, base, this->rtcpMux, this->comedia, tuple, rtcpTuple); } void PlainTransport::HandleRequest(Channel::ChannelRequest* request) @@ -444,10 +427,10 @@ namespace RTC uint16_t rtcpPort{ 0u }; std::string srtpKeyBase64; - const auto *body = request->data->body_as(); + const auto* body = request->data->body_as(); auto srtpParametersPresent = flatbuffers::IsFieldPresent( - body, FBS::PlainTransport::ConnectRequest::VT_SRTPPARAMETERS); + body, FBS::PlainTransport::ConnectRequest::VT_SRTPPARAMETERS); if (!HasSrtp() && srtpParametersPresent) { @@ -460,19 +443,11 @@ namespace RTC MS_THROW_TYPE_ERROR("missing srtpParameters (SRTP enabled)"); } - const auto *srtpParameters = body->srtpParameters(); - // Ensure it's a crypto suite supported by us. - auto it = - PlainTransport::string2SrtpCryptoSuite.find(srtpParameters->cryptoSuite()->str()); - - if (it == PlainTransport::string2SrtpCryptoSuite.end()) - { - MS_THROW_TYPE_ERROR("invalid/unsupported srtpParameters.cryptoSuite"); - } + const auto srtpParameters = body->srtpParameters(); // Update out SRTP crypto suite with the one used by the remote. auto previousSrtpCryptoSuite = this->srtpCryptoSuite; - this->srtpCryptoSuite = it->second; + this->srtpCryptoSuite = SrtpSession::CryptoSuiteFromFbs(srtpParameters->cryptoSuite()); switch (this->srtpCryptoSuite) { @@ -723,7 +698,7 @@ namespace RTC // Tell the caller about the selected local DTLS role. flatbuffers::Offset tupleOffset; flatbuffers::Offset rtcpTupleOffset; - flatbuffers::Offset srtpParametersOffset; + flatbuffers::Offset srtpParametersOffset; if (this->tuple) { @@ -737,15 +712,13 @@ namespace RTC if (HasSrtp()) { - srtpParametersOffset = FBS::Transport::CreateSrtpParametersDirect( - request->GetBufferBuilder(), - PlainTransport::srtpCryptoSuite2String[this->srtpCryptoSuite].c_str(), - this->srtpKeyBase64.c_str() - ); + srtpParametersOffset = FBS::SrtpParameters::CreateSrtpParametersDirect( + request->GetBufferBuilder(), + SrtpSession::CryptoSuiteToFbs(this->srtpCryptoSuite), + this->srtpKeyBase64.c_str()); } - auto responseOffset = - FBS::PlainTransport::CreateConnectResponse( + auto responseOffset = FBS::PlainTransport::CreateConnectResponse( request->GetBufferBuilder(), tupleOffset, rtcpTupleOffset, srtpParametersOffset); request->Accept(FBS::Response::Body::FBS_PlainTransport_ConnectResponse, responseOffset); @@ -897,7 +870,7 @@ namespace RTC { MS_TRACE(); - this->sctpAssociation->SendSctpMessage(dataConsumer, msg, len,ppid, cb); + this->sctpAssociation->SendSctpMessage(dataConsumer, msg, len, ppid, cb); } void PlainTransport::SendSctpData(const uint8_t* data, size_t len) @@ -1211,30 +1184,28 @@ namespace RTC inline void PlainTransport::EmitTuple() const { - auto tuple = this->tuple->FillBuffer(this->shared->channelNotifier->GetBufferBuilder()); + auto tuple = this->tuple->FillBuffer(this->shared->channelNotifier->GetBufferBuilder()); auto notification = FBS::PlainTransport::CreateTupleNotification( - this->shared->channelNotifier->GetBufferBuilder(), - tuple); + this->shared->channelNotifier->GetBufferBuilder(), tuple); this->shared->channelNotifier->Emit( - this->id, - FBS::Notification::Event::PLAINTRANSPORT_TUPLE, - FBS::Notification::Body::FBS_PlainTransport_TupleNotification, - notification); + this->id, + FBS::Notification::Event::PLAINTRANSPORT_TUPLE, + FBS::Notification::Body::FBS_PlainTransport_TupleNotification, + notification); } inline void PlainTransport::EmitRtcpTuple() const { auto rtcpTuple = this->rtcpTuple->FillBuffer(this->shared->channelNotifier->GetBufferBuilder()); auto notification = FBS::PlainTransport::CreateRtcpTupleNotification( - this->shared->channelNotifier->GetBufferBuilder(), - rtcpTuple); + this->shared->channelNotifier->GetBufferBuilder(), rtcpTuple); this->shared->channelNotifier->Emit( - this->id, - FBS::Notification::Event::PLAINTRANSPORT_RTCP_TUPLE, - FBS::Notification::Body::FBS_PlainTransport_RtcpTupleNotification, - notification); + this->id, + FBS::Notification::Event::PLAINTRANSPORT_RTCP_TUPLE, + FBS::Notification::Body::FBS_PlainTransport_RtcpTupleNotification, + notification); } inline void PlainTransport::OnUdpSocketPacketReceived( diff --git a/worker/src/RTC/SrtpSession.cpp b/worker/src/RTC/SrtpSession.cpp index 97051e0cfd..ee400c07eb 100644 --- a/worker/src/RTC/SrtpSession.cpp +++ b/worker/src/RTC/SrtpSession.cpp @@ -28,6 +28,42 @@ namespace RTC } } + FBS::SrtpParameters::SrtpCryptoSuite SrtpSession::CryptoSuiteToFbs(CryptoSuite cryptoSuite) + { + switch (cryptoSuite) + { + case SrtpSession::CryptoSuite::AEAD_AES_256_GCM: + return FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_256_GCM; + + case SrtpSession::CryptoSuite::AEAD_AES_128_GCM: + return FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_128_GCM; + + case SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_80: + return FBS::SrtpParameters::SrtpCryptoSuite::AES_CM_128_HMAC_SHA1_80; + + case SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_32: + return FBS::SrtpParameters::SrtpCryptoSuite::AES_CM_128_HMAC_SHA1_32; + } + } + + SrtpSession::CryptoSuite SrtpSession::CryptoSuiteFromFbs(FBS::SrtpParameters::SrtpCryptoSuite cryptoSuite) + { + switch (cryptoSuite) + { + case FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_256_GCM: + return SrtpSession::CryptoSuite::AEAD_AES_256_GCM; + + case FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_128_GCM: + return SrtpSession::CryptoSuite::AEAD_AES_128_GCM; + + case FBS::SrtpParameters::SrtpCryptoSuite::AES_CM_128_HMAC_SHA1_80: + return SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_80; + + case FBS::SrtpParameters::SrtpCryptoSuite::AES_CM_128_HMAC_SHA1_32: + return SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_32; + } + } + void SrtpSession::OnSrtpEvent(srtp_event_data_t* data) { MS_TRACE(); diff --git a/worker/src/RTC/Transport.cpp b/worker/src/RTC/Transport.cpp index 1393ddf15a..459a852eed 100644 --- a/worker/src/RTC/Transport.cpp +++ b/worker/src/RTC/Transport.cpp @@ -44,11 +44,18 @@ namespace RTC if (options->direct()) { - this->direct = true; - this->maxMessageSize = options->maxMessageSize(); + this->direct = true; + + if (options->maxMessageSize().has_value()) + { + this->maxMessageSize = options->maxMessageSize().value(); + } } - this->initialAvailableOutgoingBitrate = options->initialAvailableOutgoingBitrate(); + if (options->initialAvailableOutgoingBitrate().has_value()) + { + this->initialAvailableOutgoingBitrate = options->initialAvailableOutgoingBitrate().value(); + } if (options->enableSctp()) { @@ -457,11 +464,14 @@ namespace RTC this->tccServer ? flatbuffers::Optional(this->tccServer->GetAvailableBitrate()) : flatbuffers::nullopt, // maxIncomingBitrate. - this->maxIncomingBitrate, + this->maxIncomingBitrate ? flatbuffers::Optional(this->maxIncomingBitrate) + : flatbuffers::nullopt, // maxOutgoingBitrate. - this->maxOutgoingBitrate, + this->maxOutgoingBitrate ? flatbuffers::Optional(this->maxOutgoingBitrate) + : flatbuffers::nullopt, // minOutgoingBitrate. - this->minOutgoingBitrate, + this->minOutgoingBitrate ? flatbuffers::Optional(this->minOutgoingBitrate) + : flatbuffers::nullopt, // packetLossReceived. this->tccServer ? flatbuffers::Optional(this->tccServer->GetPacketLoss()) : flatbuffers::nullopt, diff --git a/worker/src/RTC/WebRtcTransport.cpp b/worker/src/RTC/WebRtcTransport.cpp index f1f083f9d2..3354996011 100644 --- a/worker/src/RTC/WebRtcTransport.cpp +++ b/worker/src/RTC/WebRtcTransport.cpp @@ -316,23 +316,7 @@ namespace RTC } // Add iceState. - std::string iceState; - - switch (this->iceServer->GetState()) - { - case RTC::IceServer::IceState::NEW: - iceState = "new"; - break; - case RTC::IceServer::IceState::CONNECTED: - iceState = "connected"; - break; - case RTC::IceServer::IceState::COMPLETED: - iceState = "completed"; - break; - case RTC::IceServer::IceState::DISCONNECTED: - iceState = "disconnected"; - break; - } + auto iceState = RTC::IceServer::IceStateToFbs(this->iceServer->GetState()); // Add iceSelectedTuple. flatbuffers::Offset iceSelectedTuple; @@ -345,71 +329,33 @@ namespace RTC for (const auto& fingerprint : this->dtlsTransport->GetLocalFingerprints()) { - auto& algorithm = RTC::DtlsTransport::GetFingerprintAlgorithmString(fingerprint.algorithm); + auto algorithm = DtlsTransport::AlgorithmToFbs(fingerprint.algorithm); const auto& value = fingerprint.value; fingerprints.emplace_back( - FBS::WebRtcTransport::CreateFingerprintDirect(builder, algorithm.c_str(), value.c_str())); + FBS::WebRtcTransport::CreateFingerprintDirect(builder, algorithm, value.c_str())); } // Add dtlsParameters.role. - std::string dtlsRole; - - switch (this->dtlsRole) - { - case RTC::DtlsTransport::Role::NONE: - dtlsRole = "none"; - break; - case RTC::DtlsTransport::Role::AUTO: - dtlsRole = "auto"; - break; - case RTC::DtlsTransport::Role::CLIENT: - dtlsRole = "client"; - break; - case RTC::DtlsTransport::Role::SERVER: - dtlsRole = "server"; - break; - } - - // Add dtlsState. - std::string dtlsState; - - switch (this->dtlsTransport->GetState()) - { - case RTC::DtlsTransport::DtlsState::NEW: - dtlsState = "new"; - break; - case RTC::DtlsTransport::DtlsState::CONNECTING: - dtlsState = "connecting"; - break; - case RTC::DtlsTransport::DtlsState::CONNECTED: - dtlsState = "connected"; - break; - case RTC::DtlsTransport::DtlsState::FAILED: - dtlsState = "failed"; - break; - case RTC::DtlsTransport::DtlsState::CLOSED: - dtlsState = "closed"; - break; - } + auto dtlsRole = DtlsTransport::RoleToFbs(this->dtlsRole); + auto dtlsState = DtlsTransport::StateToFbs(this->dtlsTransport->GetState()); // Add base transport dump. auto base = Transport::FillBuffer(builder); // Add dtlsParameters. auto dtlsParameters = - FBS::WebRtcTransport::CreateDtlsParametersDirect(builder, &fingerprints, dtlsRole.c_str()); + FBS::WebRtcTransport::CreateDtlsParametersDirect(builder, &fingerprints, dtlsRole); return FBS::WebRtcTransport::CreateDumpResponseDirect( builder, base, - // iceRole (we are always "controlled"). - "controlled", + FBS::WebRtcTransport::IceRole::CONTROLLED, iceParameters, &iceCandidates, - iceState.c_str(), + iceState, iceSelectedTuple, dtlsParameters, - dtlsState.c_str()); + dtlsState); } flatbuffers::Offset WebRtcTransport::FillBufferStats( @@ -418,23 +364,7 @@ namespace RTC MS_TRACE(); // Add iceState. - std::string iceState; - - switch (this->iceServer->GetState()) - { - case RTC::IceServer::IceState::NEW: - iceState = "new"; - break; - case RTC::IceServer::IceState::CONNECTED: - iceState = "connected"; - break; - case RTC::IceServer::IceState::COMPLETED: - iceState = "completed"; - break; - case RTC::IceServer::IceState::DISCONNECTED: - iceState = "disconnected"; - break; - } + auto iceState = RTC::IceServer::IceStateToFbs(this->iceServer->GetState()); // Add iceSelectedTuple. flatbuffers::Offset iceSelectedTuple; @@ -442,39 +372,19 @@ namespace RTC if (this->iceServer->GetSelectedTuple()) iceSelectedTuple = this->iceServer->GetSelectedTuple()->FillBuffer(builder); - std::string dtlsState; - - // Add dtlsState. - switch (this->dtlsTransport->GetState()) - { - case RTC::DtlsTransport::DtlsState::NEW: - dtlsState = "new"; - break; - case RTC::DtlsTransport::DtlsState::CONNECTING: - dtlsState = "connecting"; - break; - case RTC::DtlsTransport::DtlsState::CONNECTED: - dtlsState = "connected"; - break; - case RTC::DtlsTransport::DtlsState::FAILED: - dtlsState = "failed"; - break; - case RTC::DtlsTransport::DtlsState::CLOSED: - dtlsState = "closed"; - break; - } + auto dtlsState = DtlsTransport::StateToFbs(this->dtlsTransport->GetState()); // Base Transport stats. auto base = Transport::FillBufferStats(builder); - return FBS::WebRtcTransport::CreateGetStatsResponseDirect( + return FBS::WebRtcTransport::CreateGetStatsResponse( builder, base, // iceRole (we are always "controlled"). - "controlled", - iceState.c_str(), + FBS::WebRtcTransport::IceRole::CONTROLLED, + iceState, iceSelectedTuple, - dtlsState.c_str()); + dtlsState); } void WebRtcTransport::HandleRequest(Channel::ChannelRequest* request) @@ -521,13 +431,7 @@ namespace RTC // NOTE: Just take the first fingerprint. for (const auto& fingerprint : *dtlsParameters->fingerprints()) { - dtlsRemoteFingerprint.algorithm = - RTC::DtlsTransport::GetFingerprintAlgorithm(fingerprint->algorithm()->str()); - - if (dtlsRemoteFingerprint.algorithm == RTC::DtlsTransport::FingerprintAlgorithm::NONE) - { - MS_THROW_TYPE_ERROR("invalid fingerprint.algorithm value"); - } + dtlsRemoteFingerprint.algorithm = DtlsTransport::AlgorithmFromFbs(fingerprint->algorithm()); dtlsRemoteFingerprint.value = fingerprint->value()->str(); @@ -535,17 +439,7 @@ namespace RTC break; } - if (flatbuffers::IsFieldPresent(dtlsParameters, FBS::WebRtcTransport::DtlsParameters::VT_ROLE)) - { - dtlsRemoteRole = RTC::DtlsTransport::StringToRole(dtlsParameters->role()->str()); - - if (dtlsRemoteRole == RTC::DtlsTransport::Role::NONE) - MS_THROW_TYPE_ERROR("invalid dtlsParameters.role value"); - } - else - { - dtlsRemoteRole = RTC::DtlsTransport::Role::AUTO; - } + dtlsRemoteRole = RTC::DtlsTransport::RoleFromFbs(dtlsParameters->role()); // Set local DTLS role. switch (dtlsRemoteRole) @@ -564,10 +458,6 @@ namespace RTC break; } - case RTC::DtlsTransport::Role::NONE: - { - MS_THROW_TYPE_ERROR("invalid remote DTLS role"); - } } this->connectCalled = true; @@ -580,24 +470,10 @@ namespace RTC } // Tell the caller about the selected local DTLS role. - std::string dtlsLocalRole; - - switch (this->dtlsRole) - { - case RTC::DtlsTransport::Role::CLIENT: - dtlsLocalRole = "client"; - break; + auto dtlsLocalRole = DtlsTransport::RoleToFbs(this->dtlsRole); - case RTC::DtlsTransport::Role::SERVER: - dtlsLocalRole = "server"; - break; - - default: - MS_ABORT("invalid local DTLS role"); - } - - auto responseOffset = FBS::WebRtcTransport::CreateConnectResponseDirect( - request->GetBufferBuilder(), dtlsLocalRole.c_str()); + auto responseOffset = + FBS::WebRtcTransport::CreateConnectResponse(request->GetBufferBuilder(), dtlsLocalRole); request->Accept(FBS::Response::Body::FBS_WebRtcTransport_ConnectResponse, responseOffset); @@ -778,11 +654,6 @@ namespace RTC break; } - - case RTC::DtlsTransport::Role::NONE: - { - MS_ABORT("local DTLS role not set"); - } } } From 8472b902de2b452c8a7ec323f284e323f6a4af7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Wed, 13 Sep 2023 14:54:09 +0200 Subject: [PATCH 25/73] Make DTLS fragment stay within MTU size range (#1156) --- CHANGELOG.md | 1 + worker/include/RTC/DtlsTransport.hpp | 3 +- worker/src/RTC/DtlsTransport.cpp | 75 +++++++++++++--------------- 3 files changed, 39 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2619eedf3b..76f1412a91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * Add optional `rtcpListenInfo` in `PlainTransportOptions` ([PR #1099](https://github.com/versatica/mediasoup/pull/1099)). * Add pause/resume API in `DataProducer` and `DataConsumer` ([PR #1104](https://github.com/versatica/mediasoup/pull/1104)). * DataChannel subchannels feature ([PR #1152](https://github.com/versatica/mediasoup/pull/1152)). +* `Worker`: Make DTLS fragment stay within MTU size range ([PR #1156](https://github.com/versatica/mediasoup/pull/1156), based on [PR #1143](https://github.com/versatica/mediasoup/pull/1143) by @vpnts-se). ### 3.12.12 diff --git a/worker/include/RTC/DtlsTransport.hpp b/worker/include/RTC/DtlsTransport.hpp index 9cec6ae8f6..93b81bbd7c 100644 --- a/worker/include/RTC/DtlsTransport.hpp +++ b/worker/include/RTC/DtlsTransport.hpp @@ -152,6 +152,8 @@ namespace RTC return this->localRole; } void SendApplicationData(const uint8_t* data, size_t len); + // This method must be public since it's called within an OpenSSL callback. + void SendDtlsData(const uint8_t* data, size_t len); private: bool IsRunning() const @@ -173,7 +175,6 @@ namespace RTC } void Reset(); bool CheckStatus(int returnCode); - void SendPendingOutgoingDtlsData(); bool SetTimeout(); bool ProcessHandshake(); bool CheckRemoteFingerprint(); diff --git a/worker/src/RTC/DtlsTransport.cpp b/worker/src/RTC/DtlsTransport.cpp index 04c4d4b179..8d4d5895fb 100644 --- a/worker/src/RTC/DtlsTransport.cpp +++ b/worker/src/RTC/DtlsTransport.cpp @@ -53,6 +53,31 @@ inline static unsigned int onSslDtlsTimer(SSL* /*ssl*/, unsigned int timerUs) return 2 * timerUs; } +inline static long onSslBioOut( + BIO* bio, + int operationType, + const char* argp, + size_t len, + int /*argi*/, + long /*argl*/, + int ret, + size_t* /*processed*/) +{ + long resultOfcallback = (operationType == BIO_CB_RETURN) ? static_cast(ret) : 1; + + if (operationType == BIO_CB_WRITE && argp && len > 0) + { + MS_DEBUG_DEV("%zu bytes of DTLS data ready to be sent", len); + + RTC::DtlsTransport* dtlsTransport = + reinterpret_cast(BIO_get_callback_arg(bio)); + + dtlsTransport->SendDtlsData(reinterpret_cast(argp), len); + } + + return resultOfcallback; +} + namespace RTC { /* Static. */ @@ -633,6 +658,8 @@ namespace RTC goto error; } + BIO_set_callback_ex(this->sslBioToNetwork, onSslBioOut); + BIO_set_callback_arg(this->sslBioToNetwork, reinterpret_cast(this)); SSL_set_bio(this->ssl, this->sslBioFromNetwork, this->sslBioToNetwork); // Set the MTU so that we don't send packets that are too large with no fragmentation. @@ -673,7 +700,6 @@ namespace RTC { // Send close alert to the peer. SSL_shutdown(this->ssl); - SendPendingOutgoingDtlsData(); } if (this->ssl) @@ -776,7 +802,6 @@ namespace RTC SSL_set_connect_state(this->ssl); SSL_do_handshake(this->ssl); - SendPendingOutgoingDtlsData(); SetTimeout(); break; @@ -847,9 +872,6 @@ namespace RTC // Must call SSL_read() to process received DTLS data. read = SSL_read(this->ssl, static_cast(DtlsTransport::sslReadBuffer), SslReadBufferSize); - // Send data if it's ready. - SendPendingOutgoingDtlsData(); - // Check SSL status and return if it is bad/closed. if (!CheckStatus(read)) return; @@ -910,9 +932,14 @@ namespace RTC MS_WARN_TAG( dtls, "OpenSSL SSL_write() wrote less (%d bytes) than given data (%zu bytes)", written, len); } + } - // Send data. - SendPendingOutgoingDtlsData(); + void DtlsTransport::SendDtlsData(const uint8_t* data, size_t len) + { + MS_TRACE(); + + // Notify the listener. + this->listener->OnDtlsTransportSendData(this, data, len); } void DtlsTransport::Reset() @@ -929,9 +956,8 @@ namespace RTC // Stop the DTLS timer. this->timer->Stop(); - // We need to reset the SSL instance so we need to "shutdown" it, but we - // don't want to send a Close Alert to the peer, so just don't call - // SendPendingOutgoingDTLSData(). + // NOTE: We need to reset the SSL instance so we need to "shutdown" it, but we + // don't want to send a Close Alert to the peer. However this is gonna happen. SSL_shutdown(this->ssl); this->localRole.reset(); @@ -1044,32 +1070,6 @@ namespace RTC } } - inline void DtlsTransport::SendPendingOutgoingDtlsData() - { - MS_TRACE(); - - if (BIO_eof(this->sslBioToNetwork)) - return; - - int64_t read; - char* data{ nullptr }; - - read = BIO_get_mem_data(this->sslBioToNetwork, &data); // NOLINT - - if (read <= 0) - return; - - MS_DEBUG_DEV("%" PRIu64 " bytes of DTLS data ready to sent to the peer", read); - - // Notify the listener. - this->listener->OnDtlsTransportSendData( - this, reinterpret_cast(data), static_cast(read)); - - // Clear the BIO buffer. - // NOTE: the (void) avoids the -Wunused-value warning. - (void)BIO_reset(this->sslBioToNetwork); - } - inline bool DtlsTransport::SetTimeout() { MS_TRACE(); @@ -1512,9 +1512,6 @@ namespace RTC if (ret == 1) { - // If required, send DTLS data. - SendPendingOutgoingDtlsData(); - // Set the DTLS timer again. SetTimeout(); } From 80e81a088e287c54ba8745284195b2bf21f400a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 14 Sep 2023 17:32:26 +0200 Subject: [PATCH 26/73] Rust: port transport methods to FBS (#1157) Rust: port transport methods to FBS --- node/src/Consumer.ts | 2 +- node/src/Producer.ts | 2 +- node/src/Transport.ts | 51 +- rust/src/fbs.rs | 678 +++++++++++++-------- rust/src/messages.rs | 172 +++++- rust/src/router/direct_transport.rs | 4 +- rust/src/router/pipe_transport.rs | 6 +- rust/src/router/plain_transport.rs | 4 +- rust/src/router/transport.rs | 24 +- rust/src/router/webrtc_transport.rs | 4 +- rust/tests/integration/webrtc_transport.rs | 21 +- worker/fbs/request.fbs | 6 +- worker/fbs/transport.fbs | 9 +- worker/src/RTC/Transport.cpp | 32 +- 14 files changed, 674 insertions(+), 341 deletions(-) diff --git a/node/src/Consumer.ts b/node/src/Consumer.ts index 750c9b3f3d..b3a1e7c276 100644 --- a/node/src/Consumer.ts +++ b/node/src/Consumer.ts @@ -796,7 +796,7 @@ export class Consumer await this.#channel.request( FbsRequest.Method.CONSUMER_ENABLE_TRACE_EVENT, - FbsRequest.Body.FBS_Consumer_EnableTraceEventRequest, + FbsRequest.Body.Consumer_EnableTraceEventRequest, requestOffset, this.#internal.consumerId ); diff --git a/node/src/Producer.ts b/node/src/Producer.ts index fa19a4edcc..70309b3567 100644 --- a/node/src/Producer.ts +++ b/node/src/Producer.ts @@ -505,7 +505,7 @@ export class Producer await this.#channel.request( FbsRequest.Method.PRODUCER_ENABLE_TRACE_EVENT, - FbsRequest.Body.FBS_Producer_EnableTraceEventRequest, + FbsRequest.Body.Producer_EnableTraceEventRequest, requestOffset, this.#internal.producerId ); diff --git a/node/src/Transport.ts b/node/src/Transport.ts index 39e5686d85..b4a59b106a 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -1246,14 +1246,29 @@ export class Transport throw new TypeError('every type must be a string'); } + // Convert event types. + const fbsEventTypes: FbsTransport.TraceEventType[] = []; + + for (const eventType of types) + { + try + { + fbsEventTypes.push(transportTraceEventTypeToFbs(eventType)); + } + catch (error) + { + // Ignore invalid event types. + } + } + /* Build Request. */ const requestOffset = new FbsTransport.EnableTraceEventRequestT( - types + fbsEventTypes ).pack(this.channel.bufferBuilder); await this.channel.request( FbsRequest.Method.TRANSPORT_ENABLE_TRACE_EVENT, - FbsRequest.Body.FBS_Transport_EnableTraceEventRequest, + FbsRequest.Body.Transport_EnableTraceEventRequest, requestOffset, this.internal.transportId ); @@ -1294,6 +1309,32 @@ export class Transport } } +function transportTraceEventTypeToFbs(eventType: TransportTraceEventType) + : FbsTransport.TraceEventType +{ + switch (eventType) + { + case 'probation': + return FbsTransport.TraceEventType.PROBATION; + case 'bwe': + return FbsTransport.TraceEventType.BWE; + default: + throw new TypeError(`invalid transport event type: ${eventType}`); + } +} + +function transportTraceEventTypeFromFbs(eventType: FbsTransport.TraceEventType) + : TransportTraceEventType +{ + switch (eventType) + { + case FbsTransport.TraceEventType.PROBATION: + return 'probation'; + case FbsTransport.TraceEventType.BWE: + return 'bwe'; + } +} + export function parseSctpState(fbsSctpState: FbsSctpState): SctpState { switch (fbsSctpState) @@ -1387,7 +1428,7 @@ export function parseBaseTransportDump( undefined; // Retrieve traceEventTypes. - const traceEventTypes = utils.parseVector(binary, 'traceEventTypes'); + const traceEventTypes = utils.parseVector(binary, 'traceEventTypes', transportTraceEventTypeFromFbs); return { id : binary.id()!, @@ -1446,7 +1487,7 @@ export function parseTransportTraceEventData( { switch (trace.type()) { - case FbsTransport.TraceType.BWE: + case FbsTransport.TraceEventType.BWE: { const info = new FbsTransport.BweTraceInfo(); @@ -1460,7 +1501,7 @@ export function parseTransportTraceEventData( }; } - case FbsTransport.TraceType.PROBATION: + case FbsTransport.TraceEventType.PROBATION: { return { type : 'probation', diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index 0089f8c6a6..198e2060c0 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -38972,10 +38972,180 @@ mod root { } } + /// The enum `TraceEventType` in the namespace `FBS.Transport` + /// + /// Generated from these locations: + /// * Enum `TraceEventType` in the file `../worker/fbs/transport.fbs:117` + #[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:117` + /// * Table `Dump` in the file `../worker/fbs/transport.fbs:119` #[derive( Clone, Debug, @@ -39022,7 +39192,7 @@ mod root { 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<::planus::alloc::string::String>, + pub trace_event_types: ::planus::alloc::vec::Vec, } impl Dump { @@ -39068,7 +39238,7 @@ mod root { ::planus::Offset, >, field_trace_event_types: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, + ::planus::Offset<[self::TraceEventType]>, >, ) -> ::planus::Offset { let prepared_id = field_id.prepare(builder); @@ -39109,7 +39279,7 @@ mod root { if prepared_sctp_listener.is_some() { table_writer.write_entry::<::planus::Offset>(13); } - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(14); + table_writer.write_entry::<::planus::Offset<[self::TraceEventType]>>(14); if prepared_direct.is_some() { table_writer.write_entry::(1); } @@ -39518,7 +39688,7 @@ mod root { T14, )> where - T14: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + 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(( @@ -39577,7 +39747,7 @@ mod root { >, T12: ::planus::WriteAsOptional, T13: ::planus::WriteAsOptional<::planus::Offset>, - T14: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T14: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, > ::planus::WriteAs<::planus::Offset> for DumpBuilder<( T0, @@ -39626,7 +39796,7 @@ mod root { >, T12: ::planus::WriteAsOptional, T13: ::planus::WriteAsOptional<::planus::Offset>, - T14: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T14: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, > ::planus::WriteAsOptional<::planus::Offset> for DumpBuilder<( T0, @@ -39678,7 +39848,7 @@ mod root { >, T12: ::planus::WriteAsOptional, T13: ::planus::WriteAsOptional<::planus::Offset>, - T14: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T14: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, > ::planus::WriteAsOffset for DumpBuilder<( T0, @@ -39841,7 +40011,13 @@ mod root { pub fn trace_event_types( &self, ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + ::planus::Vector< + 'a, + ::core::result::Result< + self::TraceEventType, + ::planus::errors::UnknownEnumTag, + >, + >, > { self.0.access_required(14, "Dump", "trace_event_types") } @@ -40012,7 +40188,7 @@ mod root { /// The table `Stats` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Stats` in the file `../worker/fbs/transport.fbs:135` + /// * Table `Stats` in the file `../worker/fbs/transport.fbs:137` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -42673,7 +42849,7 @@ mod root { /// The table `SetMaxIncomingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMaxIncomingBitrateRequest` in the file `../worker/fbs/transport.fbs:162` + /// * Table `SetMaxIncomingBitrateRequest` in the file `../worker/fbs/transport.fbs:164` #[derive( Clone, Debug, @@ -42981,7 +43157,7 @@ mod root { /// The table `SetMaxOutgoingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMaxOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:166` + /// * Table `SetMaxOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:168` #[derive( Clone, Debug, @@ -43289,7 +43465,7 @@ mod root { /// The table `SetMinOutgoingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMinOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:170` + /// * Table `SetMinOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:172` #[derive( Clone, Debug, @@ -43597,7 +43773,7 @@ mod root { /// The table `EnableTraceEventRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/transport.fbs:174` + /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/transport.fbs:176` #[derive( Clone, Debug, @@ -43611,7 +43787,7 @@ mod root { )] pub struct EnableTraceEventRequest { /// The field `events` in the table `EnableTraceEventRequest` - pub events: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + pub events: ::planus::alloc::vec::Vec, } impl EnableTraceEventRequest { @@ -43624,13 +43800,13 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_events: impl ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + 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<[::planus::Offset]>>(0); + table_writer.write_entry::<::planus::Offset<[self::TraceEventType]>>(0); unsafe { table_writer.finish(builder, |object_writer| { @@ -43691,7 +43867,7 @@ mod root { #[allow(clippy::type_complexity)] pub fn events(self, value: T0) -> EnableTraceEventRequestBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T0: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, { EnableTraceEventRequestBuilder((value,)) } @@ -43711,7 +43887,7 @@ mod root { } } - impl]>>> + impl>> ::planus::WriteAs<::planus::Offset> for EnableTraceEventRequestBuilder<(T0,)> { @@ -43726,7 +43902,7 @@ mod root { } } - impl]>>> + impl>> ::planus::WriteAsOptional<::planus::Offset> for EnableTraceEventRequestBuilder<(T0,)> { @@ -43742,7 +43918,7 @@ mod root { } } - impl]>>> + impl>> ::planus::WriteAsOffset for EnableTraceEventRequestBuilder<(T0,)> { @@ -43766,7 +43942,13 @@ mod root { pub fn events( &self, ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + ::planus::Vector< + 'a, + ::core::result::Result< + self::TraceEventType, + ::planus::errors::UnknownEnumTag, + >, + >, > { self.0 .access_required(0, "EnableTraceEventRequest", "events") @@ -43869,7 +44051,7 @@ mod root { /// The table `CloseProducerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseProducerRequest` in the file `../worker/fbs/transport.fbs:178` + /// * Table `CloseProducerRequest` in the file `../worker/fbs/transport.fbs:180` #[derive( Clone, Debug, @@ -44135,7 +44317,7 @@ mod root { /// The table `CloseConsumerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseConsumerRequest` in the file `../worker/fbs/transport.fbs:182` + /// * Table `CloseConsumerRequest` in the file `../worker/fbs/transport.fbs:184` #[derive( Clone, Debug, @@ -44401,7 +44583,7 @@ mod root { /// The table `CloseDataProducerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseDataProducerRequest` in the file `../worker/fbs/transport.fbs:186` + /// * Table `CloseDataProducerRequest` in the file `../worker/fbs/transport.fbs:188` #[derive( Clone, Debug, @@ -44676,7 +44858,7 @@ mod root { /// The table `CloseDataConsumerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseDataConsumerRequest` in the file `../worker/fbs/transport.fbs:190` + /// * Table `CloseDataConsumerRequest` in the file `../worker/fbs/transport.fbs:192` #[derive( Clone, Debug, @@ -44951,7 +45133,7 @@ mod root { /// The table `SendRtcpNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SendRtcpNotification` in the file `../worker/fbs/transport.fbs:196` + /// * Table `SendRtcpNotification` in the file `../worker/fbs/transport.fbs:198` #[derive( Clone, Debug, @@ -45216,7 +45398,7 @@ mod root { /// The table `SctpStateChangeNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SctpStateChangeNotification` in the file `../worker/fbs/transport.fbs:202` + /// * Table `SctpStateChangeNotification` in the file `../worker/fbs/transport.fbs:204` #[derive( Clone, Debug, @@ -45534,180 +45716,10 @@ mod root { } } - /// The enum `TraceType` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Enum `TraceType` in the file `../worker/fbs/transport.fbs:206` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum TraceType { - /// The variant `PROBATION` in the enum `TraceType` - Probation = 0, - - /// The variant `BWE` in the enum `TraceType` - Bwe = 1, - } - - impl TraceType { - /// Array containing all valid variants of TraceType - pub const ENUM_VALUES: [Self; 2] = [Self::Probation, Self::Bwe]; - } - - impl ::core::convert::TryFrom for TraceType { - 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(TraceType::Probation), - 1 => ::core::result::Result::Ok(TraceType::Bwe), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: TraceType) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for TraceType { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for TraceType { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for TraceType { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> TraceType { - *self - } - } - - impl ::planus::WriteAsDefault for TraceType { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &TraceType, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for TraceType { - 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 TraceType { - #[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 TraceType { - 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( - "TraceType", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for TraceType { - 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 `TraceDirection` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `TraceDirection` in the file `../worker/fbs/transport.fbs:208` + /// * Enum `TraceDirection` in the file `../worker/fbs/transport.fbs:209` #[derive( Copy, Clone, @@ -45877,7 +45889,7 @@ mod root { /// The union `TraceInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:210` + /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:211` #[derive( Clone, Debug, @@ -46030,7 +46042,7 @@ mod root { /// The enum `BweType` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:214` + /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:215` #[derive( Copy, Clone, @@ -46200,7 +46212,7 @@ mod root { /// The table `BweTraceInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:216` + /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:217` #[derive( Clone, Debug, @@ -46883,7 +46895,7 @@ mod root { /// The table `TraceNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:227` + /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:228` #[derive( Clone, Debug, @@ -46897,7 +46909,7 @@ mod root { )] pub struct TraceNotification { /// The field `type` in the table `TraceNotification` - pub type_: self::TraceType, + pub type_: self::TraceEventType, /// The field `timestamp` in the table `TraceNotification` pub timestamp: u64, /// The field `direction` in the table `TraceNotification` @@ -46910,7 +46922,7 @@ mod root { impl ::core::default::Default for TraceNotification { fn default() -> Self { Self { - type_: self::TraceType::Probation, + type_: self::TraceEventType::Probation, timestamp: 0, direction: self::TraceDirection::DirectionIn, info: ::core::default::Default::default(), @@ -46928,7 +46940,10 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_type_: impl ::planus::WriteAsDefault, + field_type_: impl ::planus::WriteAsDefault< + self::TraceEventType, + self::TraceEventType, + >, field_timestamp: impl ::planus::WriteAsDefault, field_direction: impl ::planus::WriteAsDefault< self::TraceDirection, @@ -46936,7 +46951,8 @@ mod root { >, field_info: impl ::planus::WriteAsOptionalUnion, ) -> ::planus::Offset { - let prepared_type_ = field_type_.prepare(builder, &self::TraceType::Probation); + 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, &self::TraceDirection::DirectionIn); @@ -46951,7 +46967,7 @@ mod root { table_writer.write_entry::<::planus::Offset>(4); } if prepared_type_.is_some() { - table_writer.write_entry::(0); + table_writer.write_entry::(0); } if prepared_direction.is_some() { table_writer.write_entry::(2); @@ -47040,7 +47056,7 @@ mod root { #[allow(clippy::type_complexity)] pub fn type_(self, value: T0) -> TraceNotificationBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, { TraceNotificationBuilder((value,)) } @@ -47134,7 +47150,7 @@ mod root { } impl< - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsOptionalUnion, @@ -47153,7 +47169,7 @@ mod root { } impl< - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsOptionalUnion, @@ -47172,7 +47188,7 @@ mod root { } impl< - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsOptionalUnion, @@ -47196,11 +47212,11 @@ mod root { impl<'a> TraceNotificationRef<'a> { /// Getter for the [`type` field](TraceNotification#structfield.type_). #[inline] - pub fn type_(&self) -> ::planus::Result { + pub fn type_(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 .access(0, "TraceNotification", "type_")? - .unwrap_or(self::TraceType::Probation), + .unwrap_or(self::TraceEventType::Probation), ) } @@ -51550,9 +51566,9 @@ mod root { ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Consumer.EnableTraceEventRequest` in the union `Body` - EnableTraceEventRequest( - ::planus::alloc::boxed::Box, + /// The variant `Transport_EnableTraceEventRequest` in the union `Body` + TransportEnableTraceEventRequest( + ::planus::alloc::boxed::Box, ), /// The variant of type `FBS.Transport.CloseProducerRequest` in the union `Body` @@ -51590,6 +51606,11 @@ mod root { ::planus::alloc::boxed::Box, ), + /// The variant `Producer_EnableTraceEventRequest` in the union `Body` + ProducerEnableTraceEventRequest( + ::planus::alloc::boxed::Box, + ), + /// The variant of type `FBS.Consumer.SetPreferredLayersRequest` in the union `Body` SetPreferredLayersRequest( ::planus::alloc::boxed::Box, @@ -51600,6 +51621,11 @@ mod root { ::planus::alloc::boxed::Box, ), + /// The variant `Consumer_EnableTraceEventRequest` in the union `Body` + ConsumerEnableTraceEventRequest( + ::planus::alloc::boxed::Box, + ), + /// The variant of type `FBS.DataConsumer.SetBufferedAmountLowThresholdRequest` in the union `Body` SetBufferedAmountLowThresholdRequest( ::planus::alloc::boxed::Box< @@ -51796,9 +51822,9 @@ mod root { } #[inline] - pub fn create_enable_trace_event_request( + pub fn create_transport_enable_trace_event_request( builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, + value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { ::planus::UnionOffset::new(21, value.prepare(builder).downcast()) } @@ -51859,12 +51885,20 @@ mod root { ::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_set_preferred_layers_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(29, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(30, value.prepare(builder).downcast()) } #[inline] @@ -51872,7 +51906,15 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(30, value.prepare(builder).downcast()) + ::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] @@ -51882,7 +51924,7 @@ mod root { super::data_consumer::SetBufferedAmountLowThresholdRequest, >, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(31, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(33, value.prepare(builder).downcast()) } #[inline] @@ -51890,7 +51932,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(32, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(34, value.prepare(builder).downcast()) } #[inline] @@ -51898,7 +51940,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(33, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(35, value.prepare(builder).downcast()) } #[inline] @@ -51906,7 +51948,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(34, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(36, value.prepare(builder).downcast()) } #[inline] @@ -51914,7 +51956,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(35, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(37, value.prepare(builder).downcast()) } } @@ -51978,8 +52020,8 @@ mod root { Self::ConsumeDataRequest(value) => { Self::create_consume_data_request(builder, value) } - Self::EnableTraceEventRequest(value) => { - Self::create_enable_trace_event_request(builder, value) + Self::TransportEnableTraceEventRequest(value) => { + Self::create_transport_enable_trace_event_request(builder, value) } Self::CloseProducerRequest(value) => { Self::create_close_producer_request(builder, value) @@ -52002,12 +52044,18 @@ mod root { 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::SetPreferredLayersRequest(value) => { Self::create_set_preferred_layers_request(builder, value) } Self::SetPriorityRequest(value) => { Self::create_set_priority_request(builder, value) } + Self::ConsumerEnableTraceEventRequest(value) => { + Self::create_consumer_enable_trace_event_request(builder, value) + } Self::SetBufferedAmountLowThresholdRequest(value) => { Self::create_set_buffered_amount_low_threshold_request(builder, value) } @@ -52283,14 +52331,14 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`EnableTraceEventRequest` variant](Body#variant.EnableTraceEventRequest). + /// Creates an instance of the [`Transport_EnableTraceEventRequest` variant](Body#variant.TransportEnableTraceEventRequest). #[inline] - pub fn enable_trace_event_request( + pub fn transport_enable_trace_event_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<21, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } @@ -52379,12 +52427,24 @@ mod root { 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 [`SetPreferredLayersRequest` variant](Body#variant.SetPreferredLayersRequest). #[inline] pub fn set_preferred_layers_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<29, T>> + ) -> BodyBuilder<::planus::Initialized<30, T>> where T: ::planus::WriteAsOffset, { @@ -52396,19 +52456,31 @@ mod root { pub fn set_priority_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<30, 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 [`SetBufferedAmountLowThresholdRequest` variant](Body#variant.SetBufferedAmountLowThresholdRequest). #[inline] pub fn set_buffered_amount_low_threshold_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<31, T>> + ) -> BodyBuilder<::planus::Initialized<33, T>> where T: ::planus::WriteAsOffset< super::data_consumer::SetBufferedAmountLowThresholdRequest, @@ -52419,7 +52491,7 @@ mod root { /// Creates an instance of the [`SendRequest` variant](Body#variant.SendRequest). #[inline] - pub fn send_request(self, value: T) -> BodyBuilder<::planus::Initialized<32, T>> + pub fn send_request(self, value: T) -> BodyBuilder<::planus::Initialized<34, T>> where T: ::planus::WriteAsOffset, { @@ -52431,7 +52503,7 @@ mod root { pub fn set_subchannels_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<33, T>> + ) -> BodyBuilder<::planus::Initialized<35, T>> where T: ::planus::WriteAsOffset, { @@ -52443,7 +52515,7 @@ mod root { pub fn add_producer_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<34, T>> + ) -> BodyBuilder<::planus::Initialized<36, T>> where T: ::planus::WriteAsOffset, { @@ -52455,7 +52527,7 @@ mod root { pub fn remove_producer_request( self, value: T, - ) -> BodyBuilder<::planus::Initialized<35, T>> + ) -> BodyBuilder<::planus::Initialized<37, T>> where T: ::planus::WriteAsOffset, { @@ -52916,7 +52988,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<21, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -52926,7 +52998,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<21, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -53092,7 +53164,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<29, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -53102,7 +53174,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<29, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -53114,7 +53186,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<30, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -53124,7 +53196,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<30, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -53136,9 +53208,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<31, T>> where - T: ::planus::WriteAsOffset< - super::data_consumer::SetBufferedAmountLowThresholdRequest, - >, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -53148,9 +53218,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<31, T>> where - T: ::planus::WriteAsOffset< - super::data_consumer::SetBufferedAmountLowThresholdRequest, - >, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -53162,7 +53230,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<32, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -53172,7 +53240,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<32, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -53184,7 +53252,9 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<33, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset< + super::data_consumer::SetBufferedAmountLowThresholdRequest, + >, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -53194,7 +53264,9 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<33, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset< + super::data_consumer::SetBufferedAmountLowThresholdRequest, + >, { #[inline] fn prepare( @@ -53206,7 +53278,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<34, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -53216,7 +53288,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<34, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -53228,7 +53300,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<35, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -53237,6 +53309,50 @@ mod root { } 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, { @@ -53276,7 +53392,7 @@ mod root { ConsumeRequest(super::transport::ConsumeRequestRef<'a>), ProduceDataRequest(super::transport::ProduceDataRequestRef<'a>), ConsumeDataRequest(super::transport::ConsumeDataRequestRef<'a>), - EnableTraceEventRequest(super::consumer::EnableTraceEventRequestRef<'a>), + TransportEnableTraceEventRequest(super::transport::EnableTraceEventRequestRef<'a>), CloseProducerRequest(super::transport::CloseProducerRequestRef<'a>), CloseConsumerRequest(super::transport::CloseConsumerRequestRef<'a>), CloseDataProducerRequest(super::transport::CloseDataProducerRequestRef<'a>), @@ -53284,8 +53400,10 @@ mod root { PlainTransportConnectRequest(super::plain_transport::ConnectRequestRef<'a>), PipeTransportConnectRequest(super::pipe_transport::ConnectRequestRef<'a>), WebRtcTransportConnectRequest(super::web_rtc_transport::ConnectRequestRef<'a>), + ProducerEnableTraceEventRequest(super::producer::EnableTraceEventRequestRef<'a>), SetPreferredLayersRequest(super::consumer::SetPreferredLayersRequestRef<'a>), SetPriorityRequest(super::consumer::SetPriorityRequestRef<'a>), + ConsumerEnableTraceEventRequest(super::consumer::EnableTraceEventRequestRef<'a>), SetBufferedAmountLowThresholdRequest( super::data_consumer::SetBufferedAmountLowThresholdRequestRef<'a>, ), @@ -53422,10 +53540,12 @@ mod root { )) } - BodyRef::EnableTraceEventRequest(value) => { - Self::EnableTraceEventRequest(::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::CloseProducerRequest(value) => { @@ -53470,6 +53590,12 @@ mod root { )) } + BodyRef::ProducerEnableTraceEventRequest(value) => { + Self::ProducerEnableTraceEventRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + BodyRef::SetPreferredLayersRequest(value) => { Self::SetPreferredLayersRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, @@ -53482,6 +53608,12 @@ mod root { )) } + BodyRef::ConsumerEnableTraceEventRequest(value) => { + Self::ConsumerEnableTraceEventRequest(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + BodyRef::SetBufferedAmountLowThresholdRequest(value) => { Self::SetBufferedAmountLowThresholdRequest( ::planus::alloc::boxed::Box::new( @@ -53584,7 +53716,7 @@ mod root { 20 => ::core::result::Result::Ok(Self::ConsumeDataRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 21 => ::core::result::Result::Ok(Self::EnableTraceEventRequest( + 21 => ::core::result::Result::Ok(Self::TransportEnableTraceEventRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), 22 => ::core::result::Result::Ok(Self::CloseProducerRequest( @@ -53608,27 +53740,33 @@ mod root { 28 => ::core::result::Result::Ok(Self::WebRtcTransportConnectRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 29 => ::core::result::Result::Ok(Self::SetPreferredLayersRequest( + 29 => ::core::result::Result::Ok(Self::ProducerEnableTraceEventRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 30 => ::core::result::Result::Ok(Self::SetPreferredLayersRequest( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 31 => ::core::result::Result::Ok(Self::SetPriorityRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 30 => ::core::result::Result::Ok(Self::SetPriorityRequest( + 32 => ::core::result::Result::Ok(Self::ConsumerEnableTraceEventRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 31 => { + 33 => { ::core::result::Result::Ok(Self::SetBufferedAmountLowThresholdRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )) } - 32 => ::core::result::Result::Ok(Self::SendRequest( + 34 => ::core::result::Result::Ok(Self::SendRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 33 => ::core::result::Result::Ok(Self::SetSubchannelsRequest( + 35 => ::core::result::Result::Ok(Self::SetSubchannelsRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 34 => ::core::result::Result::Ok(Self::AddProducerRequest( + 36 => ::core::result::Result::Ok(Self::AddProducerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 35 => ::core::result::Result::Ok(Self::RemoveProducerRequest( + 37 => ::core::result::Result::Ok(Self::RemoveProducerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), _ => ::core::result::Result::Err( diff --git a/rust/src/messages.rs b/rust/src/messages.rs index 93ec73b62e..de9098e86e 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -1522,23 +1522,113 @@ impl RequestFbs for TransportConnectPlainRequest { } } -request_response!( - TransportId, - "transport.setMaxIncomingBitrate", - TransportSetMaxIncomingBitrateRequest { bitrate: u32 }, -); +#[derive(Debug)] +pub(crate) struct TransportSetMaxIncomingBitrateRequest { + pub(crate) bitrate: u32, +} -request_response!( - TransportId, - "transport.setMaxOutgoingBitrate", - TransportSetMaxOutgoingBitrateRequest { bitrate: u32 }, -); +impl RequestFbs for TransportSetMaxIncomingBitrateRequest { + const METHOD: request::Method = request::Method::TransportSetMaxIncomingBitrate; + type HandlerId = TransportId; + type Response = (); -request_response!( - TransportId, - "transport.setMinOutgoingBitrate", - TransportSetMinOutgoingBitrateRequest { bitrate: u32 }, -); + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let data = transport::SetMaxIncomingBitrateRequest::create(&mut builder, self.bitrate); + let request_body = + request::Body::create_set_max_incoming_bitrate_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug)] +pub(crate) struct TransportSetMaxOutgoingBitrateRequest { + pub(crate) bitrate: u32, +} + +impl RequestFbs for TransportSetMaxOutgoingBitrateRequest { + const METHOD: request::Method = request::Method::TransportSetMaxOutgoingBitrate; + type HandlerId = TransportId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let data = transport::SetMaxOutgoingBitrateRequest::create(&mut builder, self.bitrate); + let request_body = + request::Body::create_set_max_outgoing_bitrate_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug)] +pub(crate) struct TransportSetMinOutgoingBitrateRequest { + pub(crate) bitrate: u32, +} + +impl RequestFbs for TransportSetMinOutgoingBitrateRequest { + const METHOD: request::Method = request::Method::TransportSetMinOutgoingBitrate; + type HandlerId = TransportId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let data = transport::SetMinOutgoingBitrateRequest::create(&mut builder, self.bitrate); + let request_body = + request::Body::create_set_min_outgoing_bitrate_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} #[derive(Debug)] pub(crate) struct TransportRestartIceRequest {} @@ -1659,13 +1749,51 @@ request_response!( }, ); -request_response!( - TransportId, - "transport.enableTraceEvent", - TransportEnableTraceEventRequest { - types: Vec, - }, -); +#[derive(Debug)] +pub(crate) struct TransportEnableTraceEventRequest { + pub(crate) types: Vec, +} + +impl RequestFbs for TransportEnableTraceEventRequest { + const METHOD: request::Method = request::Method::TransportEnableTraceEvent; + type HandlerId = TransportId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let data = transport::EnableTraceEventRequest { + events: self + .types + .into_iter() + .map(TransportTraceEventType::to_fbs) + .collect(), + }; + + let request_body = request::Body::TransportEnableTraceEventRequest(Box::new(data)); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } + + fn default_for_soft_error() -> Option { + None + } +} #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] diff --git a/rust/src/router/direct_transport.rs b/rust/src/router/direct_transport.rs index 543587ad06..0a2ff41f8c 100644 --- a/rust/src/router/direct_transport.rs +++ b/rust/src/router/direct_transport.rs @@ -69,7 +69,7 @@ pub struct DirectTransportDump { pub sctp_parameters: Option, pub sctp_state: Option, pub sctp_listener: Option, - pub trace_event_types: Vec, + pub trace_event_types: Vec, } impl DirectTransportDump { @@ -134,7 +134,7 @@ impl DirectTransportDump { .base .trace_event_types .iter() - .map(|event| event.to_string()) + .map(TransportTraceEventType::from_fbs) .collect(), }) } diff --git a/rust/src/router/pipe_transport.rs b/rust/src/router/pipe_transport.rs index 0cc91acb5a..2edd41948d 100644 --- a/rust/src/router/pipe_transport.rs +++ b/rust/src/router/pipe_transport.rs @@ -98,7 +98,7 @@ pub struct PipeTransportDump { pub sctp_parameters: Option, pub sctp_state: Option, pub sctp_listener: Option, - pub trace_event_types: String, + pub trace_event_types: Vec, // PipeTransport specific. pub tuple: TransportTuple, pub rtx: bool, @@ -168,9 +168,9 @@ impl PipeTransportDump { .base .trace_event_types .iter() - .map(|event| event.to_string()) + .map(TransportTraceEventType::from_fbs) .collect(), - // PlainTransport specific. + // PipeTransport specific. tuple: TransportTuple::from_fbs(dump.tuple.as_ref()), rtx: dump.rtx, srtp_parameters: dump diff --git a/rust/src/router/plain_transport.rs b/rust/src/router/plain_transport.rs index 06e01fd096..38096aa678 100644 --- a/rust/src/router/plain_transport.rs +++ b/rust/src/router/plain_transport.rs @@ -117,7 +117,7 @@ pub struct PlainTransportDump { pub sctp_parameters: Option, pub sctp_state: Option, pub sctp_listener: Option, - pub trace_event_types: String, + pub trace_event_types: Vec, // PlainTransport specific. pub rtcp_mux: bool, pub comedia: bool, @@ -189,7 +189,7 @@ impl PlainTransportDump { .base .trace_event_types .iter() - .map(|event| event.to_string()) + .map(TransportTraceEventType::from_fbs) .collect(), // PlainTransport specific. rtcp_mux: dump.rtcp_mux, diff --git a/rust/src/router/transport.rs b/rust/src/router/transport.rs index bbae2096cf..ecc988c35c 100644 --- a/rust/src/router/transport.rs +++ b/rust/src/router/transport.rs @@ -74,6 +74,22 @@ pub enum TransportTraceEventType { Bwe, } +impl TransportTraceEventType { + pub(crate) fn to_fbs(self) -> transport::TraceEventType { + match self { + TransportTraceEventType::Probation => transport::TraceEventType::Probation, + TransportTraceEventType::Bwe => transport::TraceEventType::Bwe, + } + } + + pub(crate) fn from_fbs(event_type: &transport::TraceEventType) -> Self { + match event_type { + transport::TraceEventType::Probation => TransportTraceEventType::Probation, + transport::TraceEventType::Bwe => TransportTraceEventType::Bwe, + } + } +} + #[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] #[doc(hidden)] @@ -420,13 +436,13 @@ pub(super) trait TransportImpl: TransportGeneric { async fn set_max_incoming_bitrate_impl(&self, bitrate: u32) -> Result<(), RequestError> { self.channel() - .request(self.id(), TransportSetMaxIncomingBitrateRequest { bitrate }) + .request_fbs(self.id(), TransportSetMaxIncomingBitrateRequest { bitrate }) .await } async fn set_max_outgoing_bitrate_impl(&self, bitrate: u32) -> Result<(), RequestError> { self.channel() - .request(self.id(), TransportSetMaxOutgoingBitrateRequest { bitrate }) + .request_fbs(self.id(), TransportSetMaxOutgoingBitrateRequest { bitrate }) .await } @@ -435,13 +451,13 @@ pub(super) trait TransportImpl: TransportGeneric { types: Vec, ) -> Result<(), RequestError> { self.channel() - .request(self.id(), TransportEnableTraceEventRequest { types }) + .request_fbs(self.id(), TransportEnableTraceEventRequest { types }) .await } async fn set_min_outgoing_bitrate_impl(&self, bitrate: u32) -> Result<(), RequestError> { self.channel() - .request(self.id(), TransportSetMinOutgoingBitrateRequest { bitrate }) + .request_fbs(self.id(), TransportSetMinOutgoingBitrateRequest { bitrate }) .await } diff --git a/rust/src/router/webrtc_transport.rs b/rust/src/router/webrtc_transport.rs index fb0079869e..dc30f48c6a 100644 --- a/rust/src/router/webrtc_transport.rs +++ b/rust/src/router/webrtc_transport.rs @@ -181,7 +181,7 @@ pub struct WebRtcTransportDump { pub sctp_parameters: Option, pub sctp_state: Option, pub sctp_listener: Option, - pub trace_event_types: String, + pub trace_event_types: Vec, // WebRtcTransport specific. pub dtls_parameters: DtlsParameters, pub dtls_state: DtlsState, @@ -255,7 +255,7 @@ impl WebRtcTransportDump { .base .trace_event_types .iter() - .map(|event| event.to_string()) + .map(TransportTraceEventType::from_fbs) .collect(), // WebRtcTransport specific. dtls_parameters: DtlsParameters::from_fbs(*dump.dtls_parameters), diff --git a/rust/tests/integration/webrtc_transport.rs b/rust/tests/integration/webrtc_transport.rs index 7311aa364c..90707e41eb 100644 --- a/rust/tests/integration/webrtc_transport.rs +++ b/rust/tests/integration/webrtc_transport.rs @@ -428,7 +428,6 @@ fn connect_succeeds() { } #[test] -#[ignore] fn set_max_incoming_bitrate_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -461,7 +460,6 @@ fn set_max_incoming_bitrate_succeeds() { } #[test] -#[ignore] fn set_max_outgoing_bitrate_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -494,7 +492,6 @@ fn set_max_outgoing_bitrate_succeeds() { } #[test] -#[ignore] fn set_min_outgoing_bitrate_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -527,7 +524,6 @@ fn set_min_outgoing_bitrate_succeeds() { } #[test] -#[ignore] fn set_max_outgoing_bitrate_fails_if_value_is_lower_than_current_min_limit() { future::block_on(async move { let (_worker, router) = init().await; @@ -565,7 +561,6 @@ fn set_max_outgoing_bitrate_fails_if_value_is_lower_than_current_min_limit() { } #[test] -#[ignore] fn set_min_outgoing_bitrate_fails_if_value_is_higher_than_current_max_limit() { future::block_on(async move { let (_worker, router) = init().await; @@ -638,7 +633,6 @@ fn restart_ice_succeeds() { } #[test] -#[ignore] fn enable_trace_event_succeeds() { future::block_on(async move { let (_worker, router) = init().await; @@ -668,7 +662,10 @@ fn enable_trace_event_succeeds() { .await .expect("Failed to dump WebRTC transport"); - assert_eq!(dump.trace_event_types.as_str(), "probation"); + assert_eq!( + dump.trace_event_types, + vec![TransportTraceEventType::Probation] + ); } { @@ -685,7 +682,13 @@ fn enable_trace_event_succeeds() { .await .expect("Failed to dump WebRTC transport"); - assert_eq!(dump.trace_event_types.as_str(), "probation,bwe"); + assert_eq!( + dump.trace_event_types, + vec![ + TransportTraceEventType::Probation, + TransportTraceEventType::Bwe, + ] + ); } { @@ -699,7 +702,7 @@ fn enable_trace_event_succeeds() { .await .expect("Failed to dump WebRTC transport"); - assert_eq!(dump.trace_event_types.as_str(), ""); + assert_eq!(dump.trace_event_types, vec![]); } }); } diff --git a/worker/fbs/request.fbs b/worker/fbs/request.fbs index 7359f235ee..da6fdf8a21 100644 --- a/worker/fbs/request.fbs +++ b/worker/fbs/request.fbs @@ -99,7 +99,7 @@ union Body { FBS.Transport.ConsumeRequest, FBS.Transport.ProduceDataRequest, FBS.Transport.ConsumeDataRequest, - FBS.Transport.EnableTraceEventRequest, + Transport_EnableTraceEventRequest: FBS.Transport.EnableTraceEventRequest, FBS.Transport.CloseProducerRequest, FBS.Transport.CloseConsumerRequest, FBS.Transport.CloseDataProducerRequest, @@ -107,10 +107,10 @@ union Body { PlainTransport_ConnectRequest: FBS.PlainTransport.ConnectRequest, PipeTransport_ConnectRequest: FBS.PipeTransport.ConnectRequest, WebRtcTransport_ConnectRequest: FBS.WebRtcTransport.ConnectRequest, - FBS.Producer.EnableTraceEventRequest, + Producer_EnableTraceEventRequest: FBS.Producer.EnableTraceEventRequest, FBS.Consumer.SetPreferredLayersRequest, FBS.Consumer.SetPriorityRequest, - FBS.Consumer.EnableTraceEventRequest, + Consumer_EnableTraceEventRequest: FBS.Consumer.EnableTraceEventRequest, FBS.DataConsumer.SetBufferedAmountLowThresholdRequest, FBS.DataConsumer.SendRequest, FBS.DataConsumer.SetSubchannelsRequest, diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs index 299dc42982..d0aabada5a 100644 --- a/worker/fbs/transport.fbs +++ b/worker/fbs/transport.fbs @@ -114,6 +114,8 @@ table Options { is_data_channel:bool = false; } +enum TraceEventType: uint8 { PROBATION = 0, BWE } + table Dump { id:string (required); direct:bool=false; @@ -129,7 +131,7 @@ table Dump { sctp_parameters:FBS.SctpParameters.SctpParameters; sctp_state:FBS.SctpAssociation.SctpState = null; sctp_listener: SctpListener; - trace_event_types:[string] (required); + trace_event_types:[TraceEventType] (required); } table Stats { @@ -172,7 +174,7 @@ table SetMinOutgoingBitrateRequest { } table EnableTraceEventRequest { - events:[string] (required); + events:[TraceEventType] (required); } table CloseProducerRequest { @@ -203,7 +205,6 @@ table SctpStateChangeNotification { sctp_state:FBS.SctpAssociation.SctpState; } -enum TraceType: uint8 { PROBATION = 0, BWE } // NOTE (windows): IN|OUT are macros defined in windef.h. enum TraceDirection: uint8 { DIRECTION_IN = 0, DIRECTION_OUT } @@ -225,7 +226,7 @@ table BweTraceInfo { } table TraceNotification { - type: TraceType; + type: TraceEventType; timestamp: uint64; direction: TraceDirection; info: TraceInfo; diff --git a/worker/src/RTC/Transport.cpp b/worker/src/RTC/Transport.cpp index 459a852eed..95ff357194 100644 --- a/worker/src/RTC/Transport.cpp +++ b/worker/src/RTC/Transport.cpp @@ -356,15 +356,15 @@ namespace RTC } // Add traceEventTypes. - std::vector> traceEventTypes; + std::vector traceEventTypes; if (this->traceEventTypes.probation) { - traceEventTypes.emplace_back(builder.CreateString("probation")); + traceEventTypes.emplace_back(FBS::Transport::TraceEventType::PROBATION); } if (this->traceEventTypes.bwe) { - traceEventTypes.emplace_back(builder.CreateString("bwe")); + traceEventTypes.emplace_back(FBS::Transport::TraceEventType::BWE); } return FBS::Transport::CreateDumpDirect( @@ -1213,15 +1213,21 @@ namespace RTC for (const auto& type : *body->events()) { - const auto typeStr = type->str(); - - if (typeStr == "probation") - { - newTraceEventTypes.probation = true; - } - else if (typeStr == "bwe") + switch (type) { - newTraceEventTypes.bwe = true; + case FBS::Transport::TraceEventType::PROBATION: + { + newTraceEventTypes.probation = true; + + break; + } + + case FBS::Transport::TraceEventType::BWE: + { + newTraceEventTypes.bwe = true; + + break; + } } } @@ -2287,7 +2293,7 @@ namespace RTC auto notification = FBS::Transport::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), - FBS::Transport::TraceType::PROBATION, + FBS::Transport::TraceEventType::PROBATION, DepLibUV::GetTimeMs(), FBS::Transport::TraceDirection::DIRECTION_OUT); @@ -2323,7 +2329,7 @@ namespace RTC auto notification = FBS::Transport::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), - FBS::Transport::TraceType::BWE, + FBS::Transport::TraceEventType::BWE, DepLibUV::GetTimeMs(), FBS::Transport::TraceDirection::DIRECTION_OUT, FBS::Transport::TraceInfo::BweTraceInfo, From 949bae3df317001484bbc9e67c12640f4ff76579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Fri, 15 Sep 2023 13:54:48 +0200 Subject: [PATCH 27/73] Jest coverage: ignore tests/ and fbs/ folders --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index f747252181..639c6734a2 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,10 @@ } ] }, + "coveragePathIgnorePatterns": [ + "node/src/fbs", + "node/src/tests" + ], "cacheDirectory": ".cache/jest" }, "dependencies": { From 67dd174fb7ffca57fbb60b13b7263ebb2e35d17a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Tue, 19 Sep 2023 12:33:04 +0200 Subject: [PATCH 28/73] Rust: port transport notifications to FBS (#1158) Rust: port transport notifications to FBS --- rust/src/data_structures.rs | 33 +++ rust/src/fbs.rs | 399 ++++++++++++++++++---------- rust/src/router/direct_transport.rs | 43 ++- rust/src/router/pipe_transport.rs | 41 ++- rust/src/router/plain_transport.rs | 63 ++++- rust/src/router/transport.rs | 19 ++ rust/src/router/webrtc_transport.rs | 79 +++++- rust/src/worker.rs | 2 +- rust/src/worker/channel.rs | 8 + worker/fbs/notification.fbs | 6 +- worker/fbs/transport.fbs | 2 +- worker/src/RTC/Consumer.cpp | 2 +- worker/src/RTC/Producer.cpp | 2 +- worker/src/RTC/Transport.cpp | 13 +- 14 files changed, 542 insertions(+), 170 deletions(-) diff --git a/rust/src/data_structures.rs b/rust/src/data_structures.rs index 375f233964..910b11de46 100644 --- a/rust/src/data_structures.rs +++ b/rust/src/data_structures.rs @@ -1033,6 +1033,15 @@ pub enum TraceEventDirection { Out, } +impl TraceEventDirection { + pub(crate) fn from_fbs(event_type: transport::TraceDirection) -> Self { + match event_type { + transport::TraceDirection::DirectionIn => TraceEventDirection::In, + transport::TraceDirection::DirectionOut => TraceEventDirection::Out, + } + } +} + /// Container used for sending/receiving messages using `DirectTransport` data producers and data /// consumers. #[derive(Debug, Clone)] @@ -1163,6 +1172,15 @@ pub enum BweType { Remb, } +impl BweType { + pub(crate) fn from_fbs(info: transport::BweType) -> Self { + match info { + transport::BweType::TransportCc => BweType::TransportCc, + transport::BweType::Remb => BweType::Remb, + } + } +} + /// BWE info in trace event. #[derive(Debug, Copy, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -1184,3 +1202,18 @@ pub struct BweTraceInfo { /// Available bitrate. available_bitrate: u32, } + +impl BweTraceInfo { + pub(crate) fn from_fbs(info: transport::BweTraceInfo) -> Self { + Self { + r#type: BweType::from_fbs(info.bwe_type), + desired_bitrate: info.desired_bitrate, + effective_desired_bitrate: info.effective_desired_bitrate, + min_bitrate: info.min_bitrate, + max_bitrate: info.max_bitrate, + start_bitrate: info.start_bitrate, + max_padding_bitrate: info.max_padding_bitrate, + available_bitrate: info.available_bitrate, + } + } +} diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index 198e2060c0..4668798ec3 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -46225,6 +46225,8 @@ mod root { ::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` @@ -46239,14 +46241,13 @@ mod root { pub max_padding_bitrate: u32, /// The field `available_bitrate` in the table `BweTraceInfo` pub available_bitrate: u32, - /// The field `bwe_type` in the table `BweTraceInfo` - pub bwe_type: self::BweType, } #[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, @@ -46254,7 +46255,6 @@ mod root { start_bitrate: 0, max_padding_bitrate: 0, available_bitrate: 0, - bwe_type: self::BweType::TransportCc, } } } @@ -46269,6 +46269,7 @@ mod root { #[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, @@ -46276,8 +46277,9 @@ mod root { field_start_bitrate: impl ::planus::WriteAsDefault, field_max_padding_bitrate: impl ::planus::WriteAsDefault, field_available_bitrate: impl ::planus::WriteAsDefault, - field_bwe_type: 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); @@ -46287,34 +46289,32 @@ mod root { let prepared_max_padding_bitrate = field_max_padding_bitrate.prepare(builder, &0); let prepared_available_bitrate = field_available_bitrate.prepare(builder, &0); - let prepared_bwe_type = - field_bwe_type.prepare(builder, &self::BweType::TransportCc); let mut table_writer: ::planus::table_writer::TableWriter<20> = ::core::default::Default::default(); if prepared_desired_bitrate.is_some() { - table_writer.write_entry::(0); + table_writer.write_entry::(1); } if prepared_effective_desired_bitrate.is_some() { - table_writer.write_entry::(1); + table_writer.write_entry::(2); } if prepared_min_bitrate.is_some() { - table_writer.write_entry::(2); + table_writer.write_entry::(3); } if prepared_max_bitrate.is_some() { - table_writer.write_entry::(3); + table_writer.write_entry::(4); } if prepared_start_bitrate.is_some() { - table_writer.write_entry::(4); + table_writer.write_entry::(5); } if prepared_max_padding_bitrate.is_some() { - table_writer.write_entry::(5); + table_writer.write_entry::(6); } if prepared_available_bitrate.is_some() { - table_writer.write_entry::(6); + table_writer.write_entry::(7); } if prepared_bwe_type.is_some() { - table_writer.write_entry::(7); + table_writer.write_entry::(0); } unsafe { @@ -46398,6 +46398,7 @@ mod root { ) -> ::planus::Offset { BweTraceInfo::create( builder, + self.bwe_type, self.desired_bitrate, self.effective_desired_bitrate, self.min_bitrate, @@ -46405,7 +46406,6 @@ mod root { self.start_bitrate, self.max_padding_bitrate, self.available_bitrate, - self.bwe_type, ) } } @@ -46418,34 +46418,29 @@ mod root { pub struct BweTraceInfoBuilder(State); impl BweTraceInfoBuilder<()> { - /// Setter for the [`desired_bitrate` field](BweTraceInfo#structfield.desired_bitrate). + /// Setter for the [`bwe_type` field](BweTraceInfo#structfield.bwe_type). #[inline] #[allow(clippy::type_complexity)] - pub fn desired_bitrate(self, value: T0) -> BweTraceInfoBuilder<(T0,)> + pub fn bwe_type(self, value: T0) -> BweTraceInfoBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, { BweTraceInfoBuilder((value,)) } - /// Sets the [`desired_bitrate` field](BweTraceInfo#structfield.desired_bitrate) to the default value. + /// Sets the [`bwe_type` field](BweTraceInfo#structfield.bwe_type) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn desired_bitrate_as_default( - self, - ) -> BweTraceInfoBuilder<(::planus::DefaultValue,)> { - self.desired_bitrate(::planus::DefaultValue) + pub fn bwe_type_as_default(self) -> BweTraceInfoBuilder<(::planus::DefaultValue,)> { + self.bwe_type(::planus::DefaultValue) } } impl BweTraceInfoBuilder<(T0,)> { - /// Setter for the [`effective_desired_bitrate` field](BweTraceInfo#structfield.effective_desired_bitrate). + /// Setter for the [`desired_bitrate` field](BweTraceInfo#structfield.desired_bitrate). #[inline] #[allow(clippy::type_complexity)] - pub fn effective_desired_bitrate( - self, - value: T1, - ) -> BweTraceInfoBuilder<(T0, T1)> + pub fn desired_bitrate(self, value: T1) -> BweTraceInfoBuilder<(T0, T1)> where T1: ::planus::WriteAsDefault, { @@ -46453,21 +46448,24 @@ mod root { BweTraceInfoBuilder((v0, value)) } - /// Sets the [`effective_desired_bitrate` field](BweTraceInfo#structfield.effective_desired_bitrate) to the default value. + /// Sets the [`desired_bitrate` field](BweTraceInfo#structfield.desired_bitrate) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn effective_desired_bitrate_as_default( + pub fn desired_bitrate_as_default( self, ) -> BweTraceInfoBuilder<(T0, ::planus::DefaultValue)> { - self.effective_desired_bitrate(::planus::DefaultValue) + self.desired_bitrate(::planus::DefaultValue) } } impl BweTraceInfoBuilder<(T0, T1)> { - /// Setter for the [`min_bitrate` field](BweTraceInfo#structfield.min_bitrate). + /// Setter for the [`effective_desired_bitrate` field](BweTraceInfo#structfield.effective_desired_bitrate). #[inline] #[allow(clippy::type_complexity)] - pub fn min_bitrate(self, value: T2) -> BweTraceInfoBuilder<(T0, T1, T2)> + pub fn effective_desired_bitrate( + self, + value: T2, + ) -> BweTraceInfoBuilder<(T0, T1, T2)> where T2: ::planus::WriteAsDefault, { @@ -46475,21 +46473,21 @@ mod root { BweTraceInfoBuilder((v0, v1, value)) } - /// Sets the [`min_bitrate` field](BweTraceInfo#structfield.min_bitrate) to the default value. + /// Sets the [`effective_desired_bitrate` field](BweTraceInfo#structfield.effective_desired_bitrate) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn min_bitrate_as_default( + pub fn effective_desired_bitrate_as_default( self, ) -> BweTraceInfoBuilder<(T0, T1, ::planus::DefaultValue)> { - self.min_bitrate(::planus::DefaultValue) + self.effective_desired_bitrate(::planus::DefaultValue) } } impl BweTraceInfoBuilder<(T0, T1, T2)> { - /// Setter for the [`max_bitrate` field](BweTraceInfo#structfield.max_bitrate). + /// Setter for the [`min_bitrate` field](BweTraceInfo#structfield.min_bitrate). #[inline] #[allow(clippy::type_complexity)] - pub fn max_bitrate(self, value: T3) -> BweTraceInfoBuilder<(T0, T1, T2, T3)> + pub fn min_bitrate(self, value: T3) -> BweTraceInfoBuilder<(T0, T1, T2, T3)> where T3: ::planus::WriteAsDefault, { @@ -46497,24 +46495,21 @@ mod root { BweTraceInfoBuilder((v0, v1, v2, value)) } - /// Sets the [`max_bitrate` field](BweTraceInfo#structfield.max_bitrate) to the default value. + /// Sets the [`min_bitrate` field](BweTraceInfo#structfield.min_bitrate) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn max_bitrate_as_default( + pub fn min_bitrate_as_default( self, ) -> BweTraceInfoBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.max_bitrate(::planus::DefaultValue) + self.min_bitrate(::planus::DefaultValue) } } impl BweTraceInfoBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`start_bitrate` field](BweTraceInfo#structfield.start_bitrate). + /// Setter for the [`max_bitrate` field](BweTraceInfo#structfield.max_bitrate). #[inline] #[allow(clippy::type_complexity)] - pub fn start_bitrate( - self, - value: T4, - ) -> BweTraceInfoBuilder<(T0, T1, T2, T3, T4)> + pub fn max_bitrate(self, value: T4) -> BweTraceInfoBuilder<(T0, T1, T2, T3, T4)> where T4: ::planus::WriteAsDefault, { @@ -46522,21 +46517,21 @@ mod root { BweTraceInfoBuilder((v0, v1, v2, v3, value)) } - /// Sets the [`start_bitrate` field](BweTraceInfo#structfield.start_bitrate) to the default value. + /// Sets the [`max_bitrate` field](BweTraceInfo#structfield.max_bitrate) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn start_bitrate_as_default( + pub fn max_bitrate_as_default( self, ) -> BweTraceInfoBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> { - self.start_bitrate(::planus::DefaultValue) + self.max_bitrate(::planus::DefaultValue) } } impl BweTraceInfoBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`max_padding_bitrate` field](BweTraceInfo#structfield.max_padding_bitrate). + /// Setter for the [`start_bitrate` field](BweTraceInfo#structfield.start_bitrate). #[inline] #[allow(clippy::type_complexity)] - pub fn max_padding_bitrate( + pub fn start_bitrate( self, value: T5, ) -> BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5)> @@ -46547,22 +46542,22 @@ mod root { BweTraceInfoBuilder((v0, v1, v2, v3, v4, value)) } - /// Sets the [`max_padding_bitrate` field](BweTraceInfo#structfield.max_padding_bitrate) to the default value. + /// Sets the [`start_bitrate` field](BweTraceInfo#structfield.start_bitrate) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn max_padding_bitrate_as_default( + pub fn start_bitrate_as_default( self, ) -> BweTraceInfoBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> { - self.max_padding_bitrate(::planus::DefaultValue) + self.start_bitrate(::planus::DefaultValue) } } impl BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`available_bitrate` field](BweTraceInfo#structfield.available_bitrate). + /// Setter for the [`max_padding_bitrate` field](BweTraceInfo#structfield.max_padding_bitrate). #[inline] #[allow(clippy::type_complexity)] - pub fn available_bitrate( + pub fn max_padding_bitrate( self, value: T6, ) -> BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6)> @@ -46573,40 +46568,40 @@ mod root { BweTraceInfoBuilder((v0, v1, v2, v3, v4, v5, value)) } - /// Sets the [`available_bitrate` field](BweTraceInfo#structfield.available_bitrate) to the default value. + /// Sets the [`max_padding_bitrate` field](BweTraceInfo#structfield.max_padding_bitrate) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn available_bitrate_as_default( + pub fn max_padding_bitrate_as_default( self, ) -> BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, ::planus::DefaultValue)> { - self.available_bitrate(::planus::DefaultValue) + self.max_padding_bitrate(::planus::DefaultValue) } } impl BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`bwe_type` field](BweTraceInfo#structfield.bwe_type). + /// Setter for the [`available_bitrate` field](BweTraceInfo#structfield.available_bitrate). #[inline] #[allow(clippy::type_complexity)] - pub fn bwe_type( + pub fn available_bitrate( self, value: T7, ) -> BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> where - T7: ::planus::WriteAsDefault, + T7: ::planus::WriteAsDefault, { let (v0, v1, v2, v3, v4, v5, v6) = self.0; BweTraceInfoBuilder((v0, v1, v2, v3, v4, v5, v6, value)) } - /// Sets the [`bwe_type` field](BweTraceInfo#structfield.bwe_type) to the default value. + /// Sets the [`available_bitrate` field](BweTraceInfo#structfield.available_bitrate) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn bwe_type_as_default( + pub fn available_bitrate_as_default( self, ) -> BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6, ::planus::DefaultValue)> { - self.bwe_type(::planus::DefaultValue) + self.available_bitrate(::planus::DefaultValue) } } @@ -46625,14 +46620,14 @@ mod root { } impl< - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsDefault, T4: ::planus::WriteAsDefault, T5: ::planus::WriteAsDefault, T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, + T7: ::planus::WriteAsDefault, > ::planus::WriteAs<::planus::Offset> for BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { @@ -46648,14 +46643,14 @@ mod root { } impl< - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsDefault, T4: ::planus::WriteAsDefault, T5: ::planus::WriteAsDefault, T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, + T7: ::planus::WriteAsDefault, > ::planus::WriteAsOptional<::planus::Offset> for BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { @@ -46671,14 +46666,14 @@ mod root { } impl< - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsDefault, T4: ::planus::WriteAsDefault, T5: ::planus::WriteAsDefault, T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, + T7: ::planus::WriteAsDefault, > ::planus::WriteAsOffset for BweTraceInfoBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { @@ -46697,12 +46692,22 @@ mod root { 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(0, "BweTraceInfo", "desired_bitrate")? + .access(1, "BweTraceInfo", "desired_bitrate")? .unwrap_or(0), ) } @@ -46712,7 +46717,7 @@ mod root { pub fn effective_desired_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 - .access(1, "BweTraceInfo", "effective_desired_bitrate")? + .access(2, "BweTraceInfo", "effective_desired_bitrate")? .unwrap_or(0), ) } @@ -46722,7 +46727,7 @@ mod root { pub fn min_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 - .access(2, "BweTraceInfo", "min_bitrate")? + .access(3, "BweTraceInfo", "min_bitrate")? .unwrap_or(0), ) } @@ -46732,7 +46737,7 @@ mod root { pub fn max_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 - .access(3, "BweTraceInfo", "max_bitrate")? + .access(4, "BweTraceInfo", "max_bitrate")? .unwrap_or(0), ) } @@ -46742,7 +46747,7 @@ mod root { pub fn start_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 - .access(4, "BweTraceInfo", "start_bitrate")? + .access(5, "BweTraceInfo", "start_bitrate")? .unwrap_or(0), ) } @@ -46752,7 +46757,7 @@ mod root { pub fn max_padding_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 - .access(5, "BweTraceInfo", "max_padding_bitrate")? + .access(6, "BweTraceInfo", "max_padding_bitrate")? .unwrap_or(0), ) } @@ -46762,25 +46767,16 @@ mod root { pub fn available_bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 - .access(6, "BweTraceInfo", "available_bitrate")? + .access(7, "BweTraceInfo", "available_bitrate")? .unwrap_or(0), ) } - - /// 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(7, "BweTraceInfo", "bwe_type")? - .unwrap_or(self::BweType::TransportCc), - ) - } } 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", @@ -46791,7 +46787,6 @@ mod root { f.field("start_bitrate", &self.start_bitrate()); f.field("max_padding_bitrate", &self.max_padding_bitrate()); f.field("available_bitrate", &self.available_bitrate()); - f.field("bwe_type", &self.bwe_type()); f.finish() } } @@ -46802,6 +46797,7 @@ mod root { #[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()?, )?, @@ -46817,7 +46813,6 @@ mod root { available_bitrate: ::core::convert::TryInto::try_into( value.available_bitrate()?, )?, - bwe_type: ::core::convert::TryInto::try_into(value.bwe_type()?)?, }) } } @@ -49405,8 +49400,10 @@ mod root { ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Consumer.TraceNotification` in the union `Body` - TraceNotification(::planus::alloc::boxed::Box), + /// The variant `Transport_TraceNotification` in the union `Body` + TransportTraceNotification( + ::planus::alloc::boxed::Box, + ), /// The variant of type `FBS.WebRtcTransport.IceSelectedTupleChangeNotification` in the union `Body` IceSelectedTupleChangeNotification( @@ -49447,6 +49444,11 @@ mod root { /// The variant of type `FBS.Consumer.ScoreNotification` in the union `Body` ScoreNotification(::planus::alloc::boxed::Box), + /// The variant `Producer_TraceNotification` in the union `Body` + ProducerTraceNotification( + ::planus::alloc::boxed::Box, + ), + /// The variant of type `FBS.Producer.VideoOrientationChangeNotification` in the union `Body` VideoOrientationChangeNotification( ::planus::alloc::boxed::Box< @@ -49462,6 +49464,11 @@ mod root { /// The variant of type `FBS.Consumer.RtpNotification` in the union `Body` RtpNotification(::planus::alloc::boxed::Box), + /// The variant `Consumer_TraceNotification` in the union `Body` + ConsumerTraceNotification( + ::planus::alloc::boxed::Box, + ), + /// The variant of type `FBS.DataConsumer.MessageNotification` in the union `Body` MessageNotification( ::planus::alloc::boxed::Box, @@ -49519,9 +49526,9 @@ mod root { } #[inline] - pub fn create_trace_notification( + pub fn create_transport_trace_notification( builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, + value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) } @@ -49588,6 +49595,14 @@ mod root { ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) } + #[inline] + pub fn create_producer_trace_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) + } + #[inline] pub fn create_video_orientation_change_notification( builder: &mut ::planus::Builder, @@ -49595,7 +49610,7 @@ mod root { super::producer::VideoOrientationChangeNotification, >, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) } #[inline] @@ -49603,7 +49618,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) } #[inline] @@ -49611,7 +49626,15 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) + } + + #[inline] + pub fn create_consumer_trace_notification( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) } #[inline] @@ -49619,7 +49642,7 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) } #[inline] @@ -49629,7 +49652,7 @@ mod root { super::data_consumer::BufferedAmountLowNotification, >, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(18, value.prepare(builder).downcast()) } #[inline] @@ -49639,7 +49662,7 @@ mod root { super::active_speaker_observer::DominantSpeakerNotification, >, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(19, value.prepare(builder).downcast()) } #[inline] @@ -49649,7 +49672,7 @@ mod root { super::audio_level_observer::VolumesNotification, >, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(18, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(20, value.prepare(builder).downcast()) } } @@ -49666,8 +49689,8 @@ mod root { Self::SendNotification(value) => { Self::create_send_notification(builder, value) } - Self::TraceNotification(value) => { - Self::create_trace_notification(builder, value) + Self::TransportTraceNotification(value) => { + Self::create_transport_trace_notification(builder, value) } Self::IceSelectedTupleChangeNotification(value) => { Self::create_ice_selected_tuple_change_notification(builder, value) @@ -49690,6 +49713,9 @@ mod root { Self::ScoreNotification(value) => { Self::create_score_notification(builder, value) } + Self::ProducerTraceNotification(value) => { + Self::create_producer_trace_notification(builder, value) + } Self::VideoOrientationChangeNotification(value) => { Self::create_video_orientation_change_notification(builder, value) } @@ -49699,6 +49725,9 @@ mod root { Self::RtpNotification(value) => { Self::create_rtp_notification(builder, value) } + Self::ConsumerTraceNotification(value) => { + Self::create_consumer_trace_notification(builder, value) + } Self::MessageNotification(value) => { Self::create_message_notification(builder, value) } @@ -49769,14 +49798,14 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`TraceNotification` variant](Body#variant.TraceNotification). + /// Creates an instance of the [`Transport_TraceNotification` variant](Body#variant.TransportTraceNotification). #[inline] - pub fn trace_notification( + pub fn transport_trace_notification( self, value: T, ) -> BodyBuilder<::planus::Initialized<4, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } @@ -49871,12 +49900,24 @@ mod root { 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<12, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + /// Creates an instance of the [`VideoOrientationChangeNotification` variant](Body#variant.VideoOrientationChangeNotification). #[inline] pub fn video_orientation_change_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<12, T>> + ) -> BodyBuilder<::planus::Initialized<13, T>> where T: ::planus::WriteAsOffset, { @@ -49888,7 +49929,7 @@ mod root { pub fn layers_change_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<13, T>> + ) -> BodyBuilder<::planus::Initialized<14, T>> where T: ::planus::WriteAsOffset, { @@ -49900,19 +49941,31 @@ mod root { pub fn rtp_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<14, T>> + ) -> BodyBuilder<::planus::Initialized<15, 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<16, T>> + where + T: ::planus::WriteAsOffset, + { + BodyBuilder(::planus::Initialized(value)) + } + /// Creates an instance of the [`MessageNotification` variant](Body#variant.MessageNotification). #[inline] pub fn message_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<15, T>> + ) -> BodyBuilder<::planus::Initialized<17, T>> where T: ::planus::WriteAsOffset, { @@ -49924,7 +49977,7 @@ mod root { pub fn buffered_amount_low_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<16, T>> + ) -> BodyBuilder<::planus::Initialized<18, T>> where T: ::planus::WriteAsOffset, { @@ -49936,7 +49989,7 @@ mod root { pub fn dominant_speaker_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<17, T>> + ) -> BodyBuilder<::planus::Initialized<19, T>> where T: ::planus::WriteAsOffset< super::active_speaker_observer::DominantSpeakerNotification, @@ -49950,7 +50003,7 @@ mod root { pub fn volumes_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<18, T>> + ) -> BodyBuilder<::planus::Initialized<20, T>> where T: ::planus::WriteAsOffset, { @@ -50037,7 +50090,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<4, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50047,7 +50100,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<4, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50217,7 +50270,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<12, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50227,7 +50280,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<12, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50239,7 +50292,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<13, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50249,7 +50302,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<13, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50261,7 +50314,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<14, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50271,7 +50324,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<14, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50283,7 +50336,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<15, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50293,7 +50346,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<15, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50305,7 +50358,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<16, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50315,7 +50368,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<16, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50326,6 +50379,50 @@ mod root { } } 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< super::active_speaker_observer::DominantSpeakerNotification, @@ -50333,11 +50430,11 @@ mod root { { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(17, (self.0).0.prepare(builder).downcast()) + ::planus::UnionOffset::new(19, (self.0).0.prepare(builder).downcast()) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<17, T>> + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<19, T>> where T: ::planus::WriteAsOffset< super::active_speaker_observer::DominantSpeakerNotification, @@ -50351,17 +50448,17 @@ mod root { ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<18, T>> + 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(18, (self.0).0.prepare(builder).downcast()) + ::planus::UnionOffset::new(20, (self.0).0.prepare(builder).downcast()) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<18, T>> + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<20, T>> where T: ::planus::WriteAsOffset, { @@ -50380,7 +50477,7 @@ mod root { SendRtcpNotification(super::transport::SendRtcpNotificationRef<'a>), SctpStateChangeNotification(super::transport::SctpStateChangeNotificationRef<'a>), SendNotification(super::data_producer::SendNotificationRef<'a>), - TraceNotification(super::consumer::TraceNotificationRef<'a>), + TransportTraceNotification(super::transport::TraceNotificationRef<'a>), IceSelectedTupleChangeNotification( super::web_rtc_transport::IceSelectedTupleChangeNotificationRef<'a>, ), @@ -50394,11 +50491,13 @@ mod root { RtcpTupleNotification(super::plain_transport::RtcpTupleNotificationRef<'a>), RtcpNotification(super::direct_transport::RtcpNotificationRef<'a>), ScoreNotification(super::consumer::ScoreNotificationRef<'a>), + ProducerTraceNotification(super::producer::TraceNotificationRef<'a>), VideoOrientationChangeNotification( super::producer::VideoOrientationChangeNotificationRef<'a>, ), LayersChangeNotification(super::consumer::LayersChangeNotificationRef<'a>), RtpNotification(super::consumer::RtpNotificationRef<'a>), + ConsumerTraceNotification(super::consumer::TraceNotificationRef<'a>), MessageNotification(super::data_consumer::MessageNotificationRef<'a>), BufferedAmountLowNotification( super::data_consumer::BufferedAmountLowNotificationRef<'a>, @@ -50432,8 +50531,8 @@ mod root { )) } - BodyRef::TraceNotification(value) => { - Self::TraceNotification(::planus::alloc::boxed::Box::new( + BodyRef::TransportTraceNotification(value) => { + Self::TransportTraceNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -50482,6 +50581,12 @@ mod root { )) } + BodyRef::ProducerTraceNotification(value) => { + Self::ProducerTraceNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + BodyRef::VideoOrientationChangeNotification(value) => { Self::VideoOrientationChangeNotification( ::planus::alloc::boxed::Box::new( @@ -50502,6 +50607,12 @@ mod root { )) } + BodyRef::ConsumerTraceNotification(value) => { + Self::ConsumerTraceNotification(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )) + } + BodyRef::MessageNotification(value) => { Self::MessageNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, @@ -50545,7 +50656,7 @@ mod root { 3 => ::core::result::Result::Ok(Self::SendNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 4 => ::core::result::Result::Ok(Self::TraceNotification( + 4 => ::core::result::Result::Ok(Self::TransportTraceNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), 5 => ::core::result::Result::Ok(Self::IceSelectedTupleChangeNotification( @@ -50569,25 +50680,31 @@ mod root { 11 => ::core::result::Result::Ok(Self::ScoreNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 12 => ::core::result::Result::Ok(Self::VideoOrientationChangeNotification( + 12 => ::core::result::Result::Ok(Self::ProducerTraceNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 13 => ::core::result::Result::Ok(Self::VideoOrientationChangeNotification( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 14 => ::core::result::Result::Ok(Self::LayersChangeNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 13 => ::core::result::Result::Ok(Self::LayersChangeNotification( + 15 => ::core::result::Result::Ok(Self::RtpNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 14 => ::core::result::Result::Ok(Self::RtpNotification( + 16 => ::core::result::Result::Ok(Self::ConsumerTraceNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 15 => ::core::result::Result::Ok(Self::MessageNotification( + 17 => ::core::result::Result::Ok(Self::MessageNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 16 => ::core::result::Result::Ok(Self::BufferedAmountLowNotification( + 18 => ::core::result::Result::Ok(Self::BufferedAmountLowNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 17 => ::core::result::Result::Ok(Self::DominantSpeakerNotification( + 19 => ::core::result::Result::Ok(Self::DominantSpeakerNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 18 => ::core::result::Result::Ok(Self::VolumesNotification( + 20 => ::core::result::Result::Ok(Self::VolumesNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), _ => ::core::result::Result::Err( diff --git a/rust/src/router/direct_transport.rs b/rust/src/router/direct_transport.rs index 0a2ff41f8c..bf1020e151 100644 --- a/rust/src/router/direct_transport.rs +++ b/rust/src/router/direct_transport.rs @@ -5,7 +5,7 @@ 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, response}; +use crate::fbs::{direct_transport, notification, response, transport}; use crate::messages::{TransportCloseRequestFbs, TransportSendRtcpNotification}; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; @@ -16,7 +16,9 @@ use crate::transport::{ RtpListener, SctpListener, Transport, TransportGeneric, TransportId, TransportTraceEventData, TransportTraceEventType, }; -use crate::worker::{Channel, NotificationError, RequestError, SubscriptionHandler}; +use crate::worker::{ + Channel, NotificationError, NotificationParseError, RequestError, SubscriptionHandler, +}; use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::{Bag, BagOnce, HandlerId}; @@ -231,6 +233,39 @@ enum Notification { // Rtcp, } +impl Notification { + pub(crate) fn from_fbs( + notification: notification::NotificationRef<'_>, + ) -> Result { + match notification.event().unwrap() { + notification::Event::TransportTrace => { + let Ok(Some(notification::BodyRef::TransportTraceNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let trace_notification_fbs = transport::TraceNotification::try_from(body).unwrap(); + let trace_notification = TransportTraceEventData::from_fbs(trace_notification_fbs); + + Ok(Notification::Trace(trace_notification)) + } + /* + * TODO. + notification::Event::DirecttransportRtcp => { + let Ok(Some(notification::BodyRef::RtcpNotification(_body))) = notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + Ok(Notification::Rtcp) + } + */ + _ => Err(NotificationParseError::InvalidEvent), + } + } +} + struct Inner { id: TransportId, next_mid_for_consumers: AtomicUsize, @@ -533,8 +568,8 @@ impl DirectTransport { let subscription_handler = { let handlers = Arc::clone(&handlers); - channel.subscribe_to_notifications(id.into(), move |notification| { - match serde_json::from_slice::(notification) { + channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::Trace(trace_event_data) => { handlers.trace.call_simple(&trace_event_data); diff --git a/rust/src/router/pipe_transport.rs b/rust/src/router/pipe_transport.rs index 2edd41948d..5d21720b7d 100644 --- a/rust/src/router/pipe_transport.rs +++ b/rust/src/router/pipe_transport.rs @@ -5,7 +5,7 @@ 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::{pipe_transport, response}; +use crate::fbs::{notification, pipe_transport, response, transport}; use crate::messages::{PipeTransportConnectRequest, PipeTransportData, TransportCloseRequestFbs}; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; @@ -17,7 +17,7 @@ use crate::transport::{ RtpListener, SctpListener, Transport, TransportGeneric, TransportId, TransportTraceEventData, TransportTraceEventType, }; -use crate::worker::{Channel, RequestError, SubscriptionHandler}; +use crate::worker::{Channel, NotificationParseError, RequestError, SubscriptionHandler}; use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::{Bag, BagOnce, HandlerId}; @@ -291,6 +291,39 @@ enum Notification { Trace(TransportTraceEventData), } +impl Notification { + pub(crate) fn from_fbs( + notification: notification::NotificationRef<'_>, + ) -> Result { + match notification.event().unwrap() { + notification::Event::TransportSctpStateChange => { + let Ok(Some(notification::BodyRef::SctpStateChangeNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let sctp_state = SctpState::from_fbs(&body.sctp_state().unwrap()); + + Ok(Notification::SctpStateChange { sctp_state }) + } + notification::Event::TransportTrace => { + let Ok(Some(notification::BodyRef::TransportTraceNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let trace_notification_fbs = transport::TraceNotification::try_from(body).unwrap(); + let trace_notification = TransportTraceEventData::from_fbs(trace_notification_fbs); + + Ok(Notification::Trace(trace_notification)) + } + _ => Err(NotificationParseError::InvalidEvent), + } + } +} + struct Inner { id: TransportId, next_mid_for_consumers: AtomicUsize, @@ -585,8 +618,8 @@ impl PipeTransport { let handlers = Arc::clone(&handlers); let data = Arc::clone(&data); - channel.subscribe_to_notifications(id.into(), move |notification| { - match serde_json::from_slice::(notification) { + channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::SctpStateChange { sctp_state } => { data.sctp_state.lock().replace(sctp_state); diff --git a/rust/src/router/plain_transport.rs b/rust/src/router/plain_transport.rs index 38096aa678..0596867066 100644 --- a/rust/src/router/plain_transport.rs +++ b/rust/src/router/plain_transport.rs @@ -5,7 +5,7 @@ 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::{plain_transport, response}; +use crate::fbs::{notification, plain_transport, response, transport}; use crate::messages::{PlainTransportData, TransportCloseRequestFbs, TransportConnectPlainRequest}; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; @@ -17,7 +17,7 @@ use crate::transport::{ RtpListener, SctpListener, Transport, TransportGeneric, TransportId, TransportTraceEventData, TransportTraceEventType, }; -use crate::worker::{Channel, RequestError, SubscriptionHandler}; +use crate::worker::{Channel, NotificationParseError, RequestError, SubscriptionHandler}; use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::{Bag, BagOnce, HandlerId}; @@ -340,6 +340,61 @@ enum Notification { Trace(TransportTraceEventData), } +impl Notification { + pub(crate) fn from_fbs( + notification: notification::NotificationRef<'_>, + ) -> Result { + match notification.event().unwrap() { + notification::Event::PlaintransportTuple => { + let Ok(Some(notification::BodyRef::TupleNotification(body))) = notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let tuple_fbs = transport::Tuple::try_from(body.tuple().unwrap()).unwrap(); + let tuple = TransportTuple::from_fbs(&tuple_fbs); + + Ok(Notification::Tuple { tuple }) + } + notification::Event::PlaintransportRtcpTuple => { + let Ok(Some(notification::BodyRef::RtcpTupleNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let rtcp_tuple_fbs = transport::Tuple::try_from(body.tuple().unwrap()).unwrap(); + let rtcp_tuple = TransportTuple::from_fbs(&rtcp_tuple_fbs); + + Ok(Notification::RtcpTuple { rtcp_tuple }) + } + notification::Event::TransportSctpStateChange => { + let Ok(Some(notification::BodyRef::SctpStateChangeNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let sctp_state = SctpState::from_fbs(&body.sctp_state().unwrap()); + + Ok(Notification::SctpStateChange { sctp_state }) + } + notification::Event::TransportTrace => { + let Ok(Some(notification::BodyRef::TransportTraceNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let trace_notification_fbs = transport::TraceNotification::try_from(body).unwrap(); + let trace_notification = TransportTraceEventData::from_fbs(trace_notification_fbs); + + Ok(Notification::Trace(trace_notification)) + } + _ => Err(NotificationParseError::InvalidEvent), + } + } +} struct Inner { id: TransportId, next_mid_for_consumers: AtomicUsize, @@ -627,8 +682,8 @@ impl PlainTransport { let handlers = Arc::clone(&handlers); let data = Arc::clone(&data); - channel.subscribe_to_notifications(id.into(), move |notification| { - match serde_json::from_slice::(notification) { + channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::Tuple { tuple } => { *data.tuple.lock() = tuple; diff --git a/rust/src/router/transport.rs b/rust/src/router/transport.rs index ecc988c35c..ebb5394f4a 100644 --- a/rust/src/router/transport.rs +++ b/rust/src/router/transport.rs @@ -64,6 +64,25 @@ pub enum TransportTraceEventData { }, } +impl TransportTraceEventData { + pub(crate) fn from_fbs(data: transport::TraceNotification) -> Self { + match data.type_ { + transport::TraceEventType::Probation => unimplemented!(), + transport::TraceEventType::Bwe => TransportTraceEventData::Bwe { + timestamp: data.timestamp, + direction: TraceEventDirection::from_fbs(data.direction), + info: { + let Some(transport::TraceInfo::BweTraceInfo(info)) = data.info else { + panic!("Wrong message from worker: {data:?}"); + }; + + BweTraceInfo::from_fbs(*info) + }, + }, + } + } +} + /// Valid types for "trace" event. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] diff --git a/rust/src/router/webrtc_transport.rs b/rust/src/router/webrtc_transport.rs index dc30f48c6a..8f3dd496d2 100644 --- a/rust/src/router/webrtc_transport.rs +++ b/rust/src/router/webrtc_transport.rs @@ -8,7 +8,7 @@ use crate::data_structures::{ AppData, DtlsParameters, DtlsState, IceCandidate, IceParameters, IceRole, IceState, ListenInfo, SctpState, TransportTuple, }; -use crate::fbs::{response, web_rtc_transport}; +use crate::fbs::{notification, response, transport, web_rtc_transport}; use crate::messages::{ TransportCloseRequestFbs, TransportRestartIceRequest, WebRtcTransportConnectRequest, WebRtcTransportData, @@ -23,7 +23,7 @@ use crate::transport::{ TransportTraceEventType, }; use crate::webrtc_server::WebRtcServer; -use crate::worker::{Channel, RequestError, SubscriptionHandler}; +use crate::worker::{Channel, NotificationParseError, RequestError, SubscriptionHandler}; use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::{Bag, BagOnce, HandlerId}; @@ -406,6 +406,77 @@ enum Notification { Trace(TransportTraceEventData), } +impl Notification { + pub(crate) fn from_fbs( + notification: notification::NotificationRef<'_>, + ) -> Result { + match notification.event().unwrap() { + notification::Event::WebrtctransportIceStateChange => { + let Ok(Some(notification::BodyRef::IceStateChangeNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let ice_state = IceState::from_fbs(body.ice_state().unwrap()); + + Ok(Notification::IceStateChange { ice_state }) + } + notification::Event::WebrtctransportIceSelectedTupleChange => { + let Ok(Some(notification::BodyRef::IceSelectedTupleChangeNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let ice_selected_tuple_fbs = + transport::Tuple::try_from(body.tuple().unwrap()).unwrap(); + let ice_selected_tuple = TransportTuple::from_fbs(&ice_selected_tuple_fbs); + + Ok(Notification::IceSelectedTupleChange { ice_selected_tuple }) + } + notification::Event::WebrtctransportDtlsStateChange => { + let Ok(Some(notification::BodyRef::DtlsStateChangeNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let dtls_state = DtlsState::from_fbs(body.dtls_state().unwrap()); + + Ok(Notification::DtlsStateChange { + dtls_state, + dtls_remote_cert: None, + }) + } + notification::Event::TransportSctpStateChange => { + let Ok(Some(notification::BodyRef::SctpStateChangeNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let sctp_state = SctpState::from_fbs(&body.sctp_state().unwrap()); + + Ok(Notification::SctpStateChange { sctp_state }) + } + notification::Event::TransportTrace => { + let Ok(Some(notification::BodyRef::TransportTraceNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let trace_notification_fbs = transport::TraceNotification::try_from(body).unwrap(); + let trace_notification = TransportTraceEventData::from_fbs(trace_notification_fbs); + + Ok(Notification::Trace(trace_notification)) + } + _ => Err(NotificationParseError::InvalidEvent), + } + } +} + struct Inner { id: TransportId, next_mid_for_consumers: AtomicUsize, @@ -706,8 +777,8 @@ impl WebRtcTransport { let handlers = Arc::clone(&handlers); let data = Arc::clone(&data); - channel.subscribe_to_notifications(id.into(), move |notification| { - match serde_json::from_slice::(notification) { + channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::IceStateChange { ice_state } => { *data.ice_state.lock() = ice_state; diff --git a/rust/src/worker.rs b/rust/src/worker.rs index ebe5f90846..e28b0cd6fc 100644 --- a/rust/src/worker.rs +++ b/rust/src/worker.rs @@ -19,7 +19,7 @@ pub use crate::worker::utils::ExitError; use crate::worker_manager::WorkerManager; use crate::{ortc, uuid_based_wrapper_type}; use async_executor::Executor; -pub(crate) use channel::{Channel, NotificationError}; +pub(crate) use channel::{Channel, NotificationError, NotificationParseError}; pub(crate) use common::{SubscriptionHandler, SubscriptionTarget}; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use futures_lite::FutureExt; diff --git a/rust/src/worker/channel.rs b/rust/src/worker/channel.rs index 328ca0eca9..58478a2b36 100644 --- a/rust/src/worker/channel.rs +++ b/rust/src/worker/channel.rs @@ -49,6 +49,14 @@ pub enum NotificationError { ChannelClosed, } +/// Flabtuffers notification parse error. +#[derive(Debug, Error, Eq, PartialEq)] +pub enum NotificationParseError { + /// Invalid event + #[error("Invalid event")] + InvalidEvent, +} + #[allow(clippy::type_complexity)] pub(crate) struct BufferMessagesGuard { target_id: SubscriptionTarget, diff --git a/worker/fbs/notification.fbs b/worker/fbs/notification.fbs index a1672dc5ae..5fb8316194 100644 --- a/worker/fbs/notification.fbs +++ b/worker/fbs/notification.fbs @@ -53,7 +53,7 @@ union Body { FBS.Producer.SendNotification, FBS.DataProducer.SendNotification, // Notifications from worker. - FBS.Transport.TraceNotification, + Transport_TraceNotification: FBS.Transport.TraceNotification, FBS.WebRtcTransport.IceSelectedTupleChangeNotification, FBS.WebRtcTransport.IceStateChangeNotification, FBS.WebRtcTransport.DtlsStateChangeNotification, @@ -61,12 +61,12 @@ union Body { FBS.PlainTransport.RtcpTupleNotification, FBS.DirectTransport.RtcpNotification, FBS.Producer.ScoreNotification, - FBS.Producer.TraceNotification, + Producer_TraceNotification: FBS.Producer.TraceNotification, FBS.Producer.VideoOrientationChangeNotification, FBS.Consumer.LayersChangeNotification, FBS.Consumer.RtpNotification, FBS.Consumer.ScoreNotification, - FBS.Consumer.TraceNotification, + Consumer_TraceNotification: FBS.Consumer.TraceNotification, FBS.DataConsumer.MessageNotification, FBS.DataConsumer.BufferedAmountLowNotification, FBS.ActiveSpeakerObserver.DominantSpeakerNotification, diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs index d0aabada5a..807ce624cb 100644 --- a/worker/fbs/transport.fbs +++ b/worker/fbs/transport.fbs @@ -215,6 +215,7 @@ union TraceInfo { enum BweType: uint8 { TRANSPORT_CC = 0, REMB } table BweTraceInfo { + bwe_type:BweType; desired_bitrate:uint32; effective_desired_bitrate:uint32; min_bitrate:uint32; @@ -222,7 +223,6 @@ table BweTraceInfo { start_bitrate:uint32; max_padding_bitrate:uint32; available_bitrate:uint32; - bwe_type:BweType; } table TraceNotification { diff --git a/worker/src/RTC/Consumer.cpp b/worker/src/RTC/Consumer.cpp index 023b30310b..fd5ee974ff 100644 --- a/worker/src/RTC/Consumer.cpp +++ b/worker/src/RTC/Consumer.cpp @@ -559,7 +559,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::CONSUMER_TRACE, - FBS::Notification::Body::FBS_Consumer_TraceNotification, + FBS::Notification::Body::Consumer_TraceNotification, notification); } } // namespace RTC diff --git a/worker/src/RTC/Producer.cpp b/worker/src/RTC/Producer.cpp index da0e20274e..9cbf637295 100644 --- a/worker/src/RTC/Producer.cpp +++ b/worker/src/RTC/Producer.cpp @@ -1560,7 +1560,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::PRODUCER_TRACE, - FBS::Notification::Body::FBS_Producer_TraceNotification, + FBS::Notification::Body::Producer_TraceNotification, notification); } diff --git a/worker/src/RTC/Transport.cpp b/worker/src/RTC/Transport.cpp index 95ff357194..c86965a6c0 100644 --- a/worker/src/RTC/Transport.cpp +++ b/worker/src/RTC/Transport.cpp @@ -2291,6 +2291,7 @@ namespace RTC return; } + // TODO: Missing trace info (RTP packet dump). auto notification = FBS::Transport::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), FBS::Transport::TraceEventType::PROBATION, @@ -2300,7 +2301,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::TRANSPORT_TRACE, - FBS::Notification::Body::FBS_Transport_TraceNotification, + FBS::Notification::Body::Transport_TraceNotification, notification); } @@ -2316,16 +2317,16 @@ namespace RTC auto traceInfo = FBS::Transport::CreateBweTraceInfo( this->shared->channelNotifier->GetBufferBuilder(), + this->tccClient->GetBweType() == RTC::BweType::TRANSPORT_CC + ? FBS::Transport::BweType::TRANSPORT_CC + : FBS::Transport::BweType::REMB, bitrates.desiredBitrate, bitrates.effectiveDesiredBitrate, bitrates.minBitrate, bitrates.maxBitrate, bitrates.startBitrate, bitrates.maxPaddingBitrate, - bitrates.availableBitrate, - this->tccClient->GetBweType() == RTC::BweType::TRANSPORT_CC - ? FBS::Transport::BweType::TRANSPORT_CC - : FBS::Transport::BweType::REMB); + bitrates.availableBitrate); auto notification = FBS::Transport::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), @@ -2338,7 +2339,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::TRANSPORT_TRACE, - FBS::Notification::Body::FBS_Transport_TraceNotification, + FBS::Notification::Body::Transport_TraceNotification, notification); } From d57e3b0d8b433d7430696c93a8eeaa8718903042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Tue, 19 Sep 2023 16:41:53 +0200 Subject: [PATCH 29/73] FBS: normalize FBS types (#1159) * FBS: normalize FBS types * FBS: format schemas * FBS: type for RtpHeaderExtensionUri (#1161) --- node/src/Channel.ts | 4 +- node/src/Consumer.ts | 6 +- node/src/DataConsumer.ts | 8 +- node/src/DataProducer.ts | 4 +- node/src/DirectTransport.ts | 2 +- node/src/PipeTransport.ts | 2 +- node/src/Producer.ts | 4 +- node/src/Router.ts | 14 +- node/src/RtpObserver.ts | 6 +- node/src/RtpParameters.ts | 84 +- node/src/Transport.ts | 16 +- node/src/WebRtcServer.ts | 2 +- node/src/Worker.ts | 6 +- node/src/tests/test-Consumer.ts | 2 +- node/src/tests/test-Producer.ts | 2 +- node/src/tests/test-WebRtcTransport.ts | 6 +- rust/src/fbs.rs | 2802 ++++++++++------- rust/src/messages.rs | 45 +- rust/src/router/direct_transport.rs | 5 +- rust/src/router/pipe_transport.rs | 8 +- rust/src/router/plain_transport.rs | 14 +- rust/src/router/webrtc_transport.rs | 22 +- rust/src/rtp_parameters.rs | 71 +- worker/fbs/activeSpeakerObserver.fbs | 5 +- worker/fbs/audioLevelObserver.fbs | 13 +- worker/fbs/common.fbs | 21 +- worker/fbs/consumer.fbs | 139 +- worker/fbs/dataConsumer.fbs | 57 +- worker/fbs/dataProducer.fbs | 41 +- worker/fbs/directTransport.fbs | 9 +- worker/fbs/log.fbs | 4 +- worker/fbs/message.fbs | 23 +- worker/fbs/notification.fbs | 123 +- worker/fbs/pipeTransport.fbs | 29 +- worker/fbs/plainTransport.fbs | 55 +- worker/fbs/producer.fbs | 75 +- worker/fbs/request.fbs | 217 +- worker/fbs/response.fbs | 71 +- worker/fbs/router.fbs | 45 +- worker/fbs/rtpObserver.fbs | 6 +- worker/fbs/rtpParameters.fbs | 125 +- worker/fbs/rtpStream.fbs | 107 +- worker/fbs/rtxStream.fbs | 16 +- worker/fbs/sctpAssociation.fbs | 11 +- worker/fbs/sctpParameters.fbs | 30 +- worker/fbs/srtpParameters.fbs | 13 +- worker/fbs/transport.fbs | 278 +- worker/fbs/webRtcServer.fbs | 25 +- worker/fbs/webRtcTransport.fbs | 129 +- worker/fbs/worker.fbs | 59 +- worker/include/Channel/ChannelNotifier.hpp | 4 +- worker/include/Channel/ChannelRequest.hpp | 5 +- worker/include/RTC/RtpDictionaries.hpp | 8 +- worker/src/Channel/ChannelRequest.cpp | 5 +- worker/src/Channel/ChannelSocket.cpp | 2 +- worker/src/RTC/ActiveSpeakerObserver.cpp | 2 +- worker/src/RTC/AudioLevelObserver.cpp | 2 +- worker/src/RTC/Consumer.cpp | 4 +- worker/src/RTC/DataConsumer.cpp | 13 +- worker/src/RTC/DataProducer.cpp | 4 +- worker/src/RTC/DirectTransport.cpp | 12 +- worker/src/RTC/PipeConsumer.cpp | 2 +- worker/src/RTC/PipeTransport.cpp | 6 +- worker/src/RTC/PlainTransport.cpp | 10 +- worker/src/RTC/Producer.cpp | 8 +- worker/src/RTC/Router.cpp | 12 +- .../RtpHeaderExtensionParameters.cpp | 10 +- .../RtpDictionaries/RtpHeaderExtensionUri.cpp | 88 +- worker/src/RTC/SimpleConsumer.cpp | 4 +- worker/src/RTC/SimulcastConsumer.cpp | 8 +- worker/src/RTC/SvcConsumer.cpp | 8 +- worker/src/RTC/Transport.cpp | 16 +- worker/src/RTC/WebRtcServer.cpp | 2 +- worker/src/RTC/WebRtcTransport.cpp | 24 +- worker/src/Worker.cpp | 6 +- 75 files changed, 2931 insertions(+), 2195 deletions(-) diff --git a/node/src/Channel.ts b/node/src/Channel.ts index 96969980bc..56944985c9 100644 --- a/node/src/Channel.ts +++ b/node/src/Channel.ts @@ -283,7 +283,7 @@ export class Channel extends EnhancedEventEmitter const messageOffset = Message.createMessage( this.#bufferBuilder, MessageType.NOTIFICATION, - MessageBody.FBS_Notification_Notification, + MessageBody.Notification, notificationOffset ); @@ -348,7 +348,7 @@ export class Channel extends EnhancedEventEmitter const messageOffset = Message.createMessage( this.#bufferBuilder, MessageType.REQUEST, - MessageBody.FBS_Request_Request, + MessageBody.Request, requestOffset ); diff --git a/node/src/Consumer.ts b/node/src/Consumer.ts index b3a1e7c276..4c0aeb1f19 100644 --- a/node/src/Consumer.ts +++ b/node/src/Consumer.ts @@ -523,7 +523,7 @@ export class Consumer this.#channel.request( FbsRequest.Method.TRANSPORT_CLOSE_CONSUMER, - FbsRequest.Body.FBS_Transport_CloseConsumerRequest, + FbsRequest.Body.Transport_CloseConsumerRequest, requestOffset, this.#internal.transportId ).catch(() => {}); @@ -686,7 +686,7 @@ export class Consumer const response = await this.#channel.request( FbsRequest.Method.CONSUMER_SET_PREFERRED_LAYERS, - FbsRequest.Body.FBS_Consumer_SetPreferredLayersRequest, + FbsRequest.Body.Consumer_SetPreferredLayersRequest, requestOffset, this.#internal.consumerId ); @@ -734,7 +734,7 @@ export class Consumer const response = await this.#channel.request( FbsRequest.Method.CONSUMER_SET_PRIORITY, - FbsRequest.Body.FBS_Consumer_SetPriorityRequest, + FbsRequest.Body.Consumer_SetPriorityRequest, requestOffset, this.#internal.consumerId ); diff --git a/node/src/DataConsumer.ts b/node/src/DataConsumer.ts index 87d856e823..c5d27c759d 100644 --- a/node/src/DataConsumer.ts +++ b/node/src/DataConsumer.ts @@ -317,7 +317,7 @@ export class DataConsumer this.#channel.request( FbsRequest.Method.TRANSPORT_CLOSE_DATACONSUMER, - FbsRequest.Body.FBS_Transport_CloseDataConsumerRequest, + FbsRequest.Body.Transport_CloseDataConsumerRequest, requestOffset, this.#internal.transportId ).catch(() => {}); @@ -460,7 +460,7 @@ export class DataConsumer await this.#channel.request( FbsRequest.Method.DATACONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, - FbsRequest.Body.FBS_DataConsumer_SetBufferedAmountLowThresholdRequest, + FbsRequest.Body.DataConsumer_SetBufferedAmountLowThresholdRequest, requestOffset, this.#internal.dataConsumerId ); @@ -537,7 +537,7 @@ export class DataConsumer await this.#channel.request( FbsRequest.Method.DATACONSUMER_SEND, - FbsRequest.Body.FBS_DataConsumer_SendRequest, + FbsRequest.Body.DataConsumer_SendRequest, requestOffset, this.#internal.dataConsumerId ); @@ -578,7 +578,7 @@ export class DataConsumer const response = await this.#channel.request( FbsRequest.Method.DATACONSUMER_SET_SUBCHANNELS, - FbsRequest.Body.FBS_DataConsumer_SetSubchannelsRequest, + FbsRequest.Body.DataConsumer_SetSubchannelsRequest, requestOffset, this.#internal.dataConsumerId ); diff --git a/node/src/DataProducer.ts b/node/src/DataProducer.ts index 467d9ae130..0e268ac9bb 100644 --- a/node/src/DataProducer.ts +++ b/node/src/DataProducer.ts @@ -254,7 +254,7 @@ export class DataProducer this.#channel.request( FbsRequest.Method.TRANSPORT_CLOSE_DATAPRODUCER, - FbsRequest.Body.FBS_Transport_CloseDataProducerRequest, + FbsRequest.Body.Transport_CloseDataProducerRequest, requestOffset, this.#internal.transportId ).catch(() => {}); @@ -466,7 +466,7 @@ export class DataProducer this.#channel.notify( FbsNotification.Event.DATAPRODUCER_SEND, - FbsNotification.Body.FBS_DataProducer_SendNotification, + FbsNotification.Body.DataProducer_SendNotification, notificationOffset, this.#internal.dataProducerId ); diff --git a/node/src/DirectTransport.ts b/node/src/DirectTransport.ts index be2ea5b207..d5ee0b85fc 100644 --- a/node/src/DirectTransport.ts +++ b/node/src/DirectTransport.ts @@ -222,7 +222,7 @@ export class DirectTransport this.channel.notify( FbsNotification.Event.TRANSPORT_SEND_RTCP, - FbsNotification.Body.FBS_Transport_SendRtcpNotification, + FbsNotification.Body.Transport_SendRtcpNotification, notificationOffset, this.internal.transportId ); diff --git a/node/src/PipeTransport.ts b/node/src/PipeTransport.ts index 4782182777..6dfead6a0c 100644 --- a/node/src/PipeTransport.ts +++ b/node/src/PipeTransport.ts @@ -379,7 +379,7 @@ export class PipeTransport const response = await this.channel.request( FbsRequest.Method.TRANSPORT_CONSUME, - FbsRequest.Body.FBS_Transport_ConsumeRequest, + FbsRequest.Body.Transport_ConsumeRequest, consumeRequestOffset, this.internal.transportId ); diff --git a/node/src/Producer.ts b/node/src/Producer.ts index 70309b3567..45b7bb3227 100644 --- a/node/src/Producer.ts +++ b/node/src/Producer.ts @@ -352,7 +352,7 @@ export class Producer this.#channel.request( FbsRequest.Method.TRANSPORT_CLOSE_PRODUCER, - FbsRequest.Body.FBS_Transport_CloseProducerRequest, + FbsRequest.Body.Transport_CloseProducerRequest, requestOffset, this.#internal.transportId ).catch(() => {}); @@ -530,7 +530,7 @@ export class Producer this.#channel.notify( FbsNotification.Event.PRODUCER_SEND, - FbsNotification.Body.FBS_Producer_SendNotification, + FbsNotification.Body.Producer_SendNotification, notificationOffset, this.#internal.producerId ); diff --git a/node/src/Router.ts b/node/src/Router.ts index 7c3ceff247..965f6905ff 100644 --- a/node/src/Router.ts +++ b/node/src/Router.ts @@ -301,7 +301,7 @@ export class Router this.#channel.request( FbsRequest.Method.WORKER_CLOSE_ROUTER, - FbsRequest.Body.FBS_Worker_CloseRouterRequest, + FbsRequest.Body.Worker_CloseRouterRequest, requestOffset) .catch(() => {}); @@ -556,7 +556,7 @@ export class Router webRtcServer ? FbsRequest.Method.ROUTER_CREATE_WEBRTCTRANSPORT_WITH_SERVER : FbsRequest.Method.ROUTER_CREATE_WEBRTCTRANSPORT, - FbsRequest.Body.FBS_Router_CreateWebRtcTransportRequest, + FbsRequest.Body.Router_CreateWebRtcTransportRequest, requestOffset, this.#internal.routerId ); @@ -720,7 +720,7 @@ export class Router const response = await this.#channel.request( FbsRequest.Method.ROUTER_CREATE_PLAINTRANSPORT, - FbsRequest.Body.FBS_Router_CreatePlainTransportRequest, + FbsRequest.Body.Router_CreatePlainTransportRequest, requestOffset, this.#internal.routerId ); @@ -856,7 +856,7 @@ export class Router const response = await this.#channel.request( FbsRequest.Method.ROUTER_CREATE_PIPETRANSPORT, - FbsRequest.Body.FBS_Router_CreatePipeTransportRequest, + FbsRequest.Body.Router_CreatePipeTransportRequest, requestOffset, this.#internal.routerId ); @@ -953,7 +953,7 @@ export class Router const response = await this.#channel.request( FbsRequest.Method.ROUTER_CREATE_DIRECTTRANSPORT, - FbsRequest.Body.FBS_Router_CreateDirectTransportRequest, + FbsRequest.Body.Router_CreateDirectTransportRequest, requestOffset, this.#internal.routerId ); @@ -1403,7 +1403,7 @@ export class Router await this.#channel.request( FbsRequest.Method.ROUTER_CREATE_ACTIVESPEAKEROBSERVER, - FbsRequest.Body.FBS_Router_CreateActiveSpeakerObserverRequest, + FbsRequest.Body.Router_CreateActiveSpeakerObserverRequest, requestOffset, this.#internal.routerId ); @@ -1482,7 +1482,7 @@ export class Router await this.#channel.request( FbsRequest.Method.ROUTER_CREATE_AUDIOLEVELOBSERVER, - FbsRequest.Body.FBS_Router_CreateAudioLevelObserverRequest, + FbsRequest.Body.Router_CreateAudioLevelObserverRequest, requestOffset, this.#internal.routerId ); diff --git a/node/src/RtpObserver.ts b/node/src/RtpObserver.ts index fa18136aeb..4c3d64051c 100644 --- a/node/src/RtpObserver.ts +++ b/node/src/RtpObserver.ts @@ -168,7 +168,7 @@ export class RtpObserver this.channel.request( FbsRequest.Method.ROUTER_CLOSE_RTPOBSERVER, - FbsRequest.Body.FBS_Router_CloseRtpObserverRequest, + FbsRequest.Body.Router_CloseRtpObserverRequest, requestOffset, this.internal.routerId ).catch(() => {}); @@ -274,7 +274,7 @@ export class RtpObserver await this.channel.request( FbsRequest.Method.RTPOBSERVER_ADD_PRODUCER, - FbsRequest.Body.FBS_RtpObserver_AddProducerRequest, + FbsRequest.Body.RtpObserver_AddProducerRequest, requestOffset, this.internal.rtpObserverId ); @@ -303,7 +303,7 @@ export class RtpObserver await this.channel.request( FbsRequest.Method.RTPOBSERVER_REMOVE_PRODUCER, - FbsRequest.Body.FBS_RtpObserver_RemoveProducerRequest, + FbsRequest.Body.RtpObserver_RemoveProducerRequest, requestOffset, this.internal.rtpObserverId ); diff --git a/node/src/RtpParameters.ts b/node/src/RtpParameters.ts index af9a976da6..8791a7d39a 100644 --- a/node/src/RtpParameters.ts +++ b/node/src/RtpParameters.ts @@ -11,6 +11,7 @@ import { RtpCodecParameters as FbsRtpCodecParameters, RtpEncodingParameters as FbsRtpEncodingParameters, RtpHeaderExtensionParameters as FbsRtpHeaderExtensionParameters, + RtpHeaderExtensionUri as FbsRtpHeaderExtensionUri, RtpParameters as FbsRtpParameters, Rtx as FbsRtx, Value as FbsValue @@ -122,7 +123,7 @@ export type RtpHeaderExtension = /* * The URI of the RTP header extension, as defined in RFC 5285. */ - uri: string; + uri: RtpHeaderExtensionUri; /** * The preferred numeric identifier that goes in the RTP packet. Must be @@ -312,6 +313,19 @@ export type RtpEncodingParameters = maxBitrate?: number; }; +export type RtpHeaderExtensionUri = + 'urn:ietf:params:rtp-hdrext:sdes:mid' | + 'urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id' | + 'urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id' | + 'http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07' | + 'urn:ietf:params:rtp-hdrext:framemarking' | + 'urn:ietf:params:rtp-hdrext:ssrc-audio-level' | + 'urn:3gpp:video-orientation' | + 'urn:ietf:params:rtp-hdrext:toffset' | + 'http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01' | + 'http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time' | + 'http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time'; + /** * Defines a RTP header extension within the RTP parameters. The list of RTP * header extensions supported by mediasoup is defined in the @@ -325,7 +339,7 @@ export type RtpHeaderExtensionParameters = /** * The URI of the RTP header extension, as defined in RFC 5285. */ - uri: string; + uri: RtpHeaderExtensionUri; /** * The numeric identifier that goes in the RTP packet. Must be unique. @@ -409,7 +423,7 @@ export function serializeRtpParameters( // RtpHeaderExtensionParameters. for (const headerExtension of rtpParameters.headerExtensions ?? []) { - const uriOffset = builder.createString(headerExtension.uri); + const uri = rtpHeaderExtensionUriToFbs(headerExtension.uri); const parameters = serializeParameters(builder, headerExtension.parameters); const parametersOffset = FbsRtpCodecParameters.createParametersVector(builder, parameters); @@ -417,7 +431,7 @@ export function serializeRtpParameters( headerExtensions.push( FbsRtpHeaderExtensionParameters.createRtpHeaderExtensionParameters( builder, - uriOffset, + uri, headerExtension.id, Boolean(headerExtension.encrypt), parametersOffset)); @@ -711,11 +725,71 @@ export function parseRtpCodecParameters(data: FbsRtpCodecParameters): RtpCodecPa }; } +export function rtpHeaderExtensionUriFromFbs(uri: FbsRtpHeaderExtensionUri): RtpHeaderExtensionUri +{ + switch (uri) + { + case FbsRtpHeaderExtensionUri.Mid: + return 'urn:ietf:params:rtp-hdrext:sdes:mid'; + case FbsRtpHeaderExtensionUri.RtpStreamId: + return 'urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id'; + case FbsRtpHeaderExtensionUri.RepairRtpStreamId: + return 'urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id'; + case FbsRtpHeaderExtensionUri.FrameMarkingDraft07: + return 'http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07'; + case FbsRtpHeaderExtensionUri.FrameMarking: + return 'urn:ietf:params:rtp-hdrext:framemarking'; + case FbsRtpHeaderExtensionUri.AudioLevel: + return 'urn:ietf:params:rtp-hdrext:ssrc-audio-level'; + case FbsRtpHeaderExtensionUri.VideoOrientation: + return 'urn:3gpp:video-orientation'; + case FbsRtpHeaderExtensionUri.TimeOffset: + return 'urn:ietf:params:rtp-hdrext:toffset'; + case FbsRtpHeaderExtensionUri.TransportWideCcDraft01: + return 'http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01'; + case FbsRtpHeaderExtensionUri.AbsSendTime: + return 'http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time'; + case FbsRtpHeaderExtensionUri.AbsCaptureTime: + return 'http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time'; + } +} + +export function rtpHeaderExtensionUriToFbs(uri: RtpHeaderExtensionUri): FbsRtpHeaderExtensionUri +{ + switch (uri) + { + case 'urn:ietf:params:rtp-hdrext:sdes:mid': + return FbsRtpHeaderExtensionUri.Mid; + case 'urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id': + return FbsRtpHeaderExtensionUri.RtpStreamId; + case 'urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id': + return FbsRtpHeaderExtensionUri.RepairRtpStreamId; + case 'http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07': + return FbsRtpHeaderExtensionUri.FrameMarkingDraft07; + case 'urn:ietf:params:rtp-hdrext:framemarking': + return FbsRtpHeaderExtensionUri.FrameMarking; + case 'urn:ietf:params:rtp-hdrext:ssrc-audio-level': + return FbsRtpHeaderExtensionUri.AudioLevel; + case 'urn:3gpp:video-orientation': + return FbsRtpHeaderExtensionUri.VideoOrientation; + case 'urn:ietf:params:rtp-hdrext:toffset': + return FbsRtpHeaderExtensionUri.TimeOffset; + case 'http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01': + return FbsRtpHeaderExtensionUri.TransportWideCcDraft01; + case 'http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time': + return FbsRtpHeaderExtensionUri.AbsSendTime; + case 'http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time': + return FbsRtpHeaderExtensionUri.AbsCaptureTime; + default: + throw new TypeError(`invalid RTP header extension URI: ${uri}`); + } +} + export function parseRtpHeaderExtensionParameters( data: FbsRtpHeaderExtensionParameters): RtpHeaderExtensionParameters { return { - uri : data.uri()!, + uri : rtpHeaderExtensionUriFromFbs(data.uri()), id : data.id(), encrypt : data.encrypt(), parameters : parseParameters(data) diff --git a/node/src/Transport.ts b/node/src/Transport.ts index b4a59b106a..8074a9b6e8 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -417,7 +417,7 @@ export class Transport this.channel.request( FbsRequest.Method.ROUTER_CLOSE_TRANSPORT, - FbsRequest.Body.FBS_Router_CloseTransportRequest, + FbsRequest.Body.Router_CloseTransportRequest, requestOffset, this.internal.routerId ).catch(() => {}); @@ -634,7 +634,7 @@ export class Transport await this.channel.request( FbsRequest.Method.TRANSPORT_SET_MAX_INCOMING_BITRATE, - FbsRequest.Body.FBS_Transport_SetMaxIncomingBitrateRequest, + FbsRequest.Body.Transport_SetMaxIncomingBitrateRequest, requestOffset, this.internal.transportId ); @@ -654,7 +654,7 @@ export class Transport await this.channel.request( FbsRequest.Method.TRANSPORT_SET_MAX_OUTGOING_BITRATE, - FbsRequest.Body.FBS_Transport_SetMaxOutgoingBitrateRequest, + FbsRequest.Body.Transport_SetMaxOutgoingBitrateRequest, requestOffset, this.internal.transportId ); @@ -674,7 +674,7 @@ export class Transport await this.channel.request( FbsRequest.Method.TRANSPORT_SET_MIN_OUTGOING_BITRATE, - FbsRequest.Body.FBS_Transport_SetMinOutgoingBitrateRequest, + FbsRequest.Body.Transport_SetMinOutgoingBitrateRequest, requestOffset, this.internal.transportId ); @@ -767,7 +767,7 @@ export class Transport const response = await this.channel.request( FbsRequest.Method.TRANSPORT_PRODUCE, - FbsRequest.Body.FBS_Transport_ProduceRequest, + FbsRequest.Body.Transport_ProduceRequest, requestOffset, this.internal.transportId ); @@ -911,7 +911,7 @@ export class Transport const response = await this.channel.request( FbsRequest.Method.TRANSPORT_CONSUME, - FbsRequest.Body.FBS_Transport_ConsumeRequest, + FbsRequest.Body.Transport_ConsumeRequest, requestOffset, this.internal.transportId ); @@ -1024,7 +1024,7 @@ export class Transport const response = await this.channel.request( FbsRequest.Method.TRANSPORT_PRODUCE_DATA, - FbsRequest.Body.FBS_Transport_ProduceDataRequest, + FbsRequest.Body.Transport_ProduceDataRequest, requestOffset, this.internal.transportId ); @@ -1170,7 +1170,7 @@ export class Transport const response = await this.channel.request( FbsRequest.Method.TRANSPORT_CONSUME_DATA, - FbsRequest.Body.FBS_Transport_ConsumeDataRequest, + FbsRequest.Body.Transport_ConsumeDataRequest, requestOffset, this.internal.transportId ); diff --git a/node/src/WebRtcServer.ts b/node/src/WebRtcServer.ts index 8039f66e7c..171299ebc4 100644 --- a/node/src/WebRtcServer.ts +++ b/node/src/WebRtcServer.ts @@ -163,7 +163,7 @@ export class WebRtcServer this.#channel.request( Method.WORKER_WEBRTCSERVER_CLOSE, - RequestBody.FBS_Worker_CloseWebRtcServerRequest, + RequestBody.Worker_CloseWebRtcServerRequest, requestOffset) .catch(() => {}); diff --git a/node/src/Worker.ts b/node/src/Worker.ts index cba836a855..349fb9a054 100644 --- a/node/src/Worker.ts +++ b/node/src/Worker.ts @@ -656,7 +656,7 @@ export class Worker await this.#channel.request( FbsRequest.Method.WORKER_UPDATE_SETTINGS, - FbsRequest.Body.FBS_Worker_UpdateSettingsRequest, + FbsRequest.Body.Worker_UpdateSettingsRequest, requestOffset ); } @@ -703,7 +703,7 @@ export class Worker await this.#channel.request( FbsRequest.Method.WORKER_CREATE_WEBRTCSERVER, - FbsRequest.Body.FBS_Worker_CreateWebRtcServerRequest, + FbsRequest.Body.Worker_CreateWebRtcServerRequest, createWebRtcServerRequestOffset ); @@ -749,7 +749,7 @@ export class Worker new FbsWorker.CreateRouterRequestT(routerId).pack(this.#channel.bufferBuilder); await this.#channel.request(FbsRequest.Method.WORKER_CREATE_ROUTER, - FbsRequest.Body.FBS_Worker_CreateRouterRequest, createRouterRequestOffset); + FbsRequest.Body.Worker_CreateRouterRequest, createRouterRequestOffset); const data = { rtpCapabilities }; const router = new Router( diff --git a/node/src/tests/test-Consumer.ts b/node/src/tests/test-Consumer.ts index 9a2937f1f0..bc443382bc 100644 --- a/node/src/tests/test-Consumer.ts +++ b/node/src/tests/test-Consumer.ts @@ -983,7 +983,7 @@ test('Consumer emits "score"', async () => builder, builder.createString(audioConsumer.id), Event.CONSUMER_SCORE, - NotificationBody.FBS_Consumer_ScoreNotification, + NotificationBody.Consumer_ScoreNotification, consumerScoreNotification.pack(builder) ); diff --git a/node/src/tests/test-Producer.ts b/node/src/tests/test-Producer.ts index c04d6743a1..d87e0a17ab 100644 --- a/node/src/tests/test-Producer.ts +++ b/node/src/tests/test-Producer.ts @@ -706,7 +706,7 @@ test('Producer emits "score"', async () => builder, builder.createString(videoProducer.id), Event.PRODUCER_SCORE, - NotificationBody.FBS_Producer_ScoreNotification, + NotificationBody.Producer_ScoreNotification, producerScoreNotification.pack(builder) ); diff --git a/node/src/tests/test-WebRtcTransport.ts b/node/src/tests/test-WebRtcTransport.ts index 7381610d32..91987cccfe 100644 --- a/node/src/tests/test-WebRtcTransport.ts +++ b/node/src/tests/test-WebRtcTransport.ts @@ -506,7 +506,7 @@ test('WebRtcTransport events succeed', async () => builder, builder.createString(transport.id), Event.WEBRTCTRANSPORT_ICE_STATE_CHANGE, - NotificationBody.FBS_WebRtcTransport_IceStateChangeNotification, + NotificationBody.WebRtcTransport_IceStateChangeNotification, iceStateChangeNotification.pack(builder) ); @@ -550,7 +550,7 @@ test('WebRtcTransport events succeed', async () => builder, builder.createString(transport.id), Event.WEBRTCTRANSPORT_ICE_SELECTED_TUPLE_CHANGE, - NotificationBody.FBS_WebRtcTransport_IceSelectedTupleChangeNotification, + NotificationBody.WebRtcTransport_IceSelectedTupleChangeNotification, iceSelectedTupleChangeNotification.pack(builder) ); @@ -580,7 +580,7 @@ test('WebRtcTransport events succeed', async () => builder, builder.createString(transport.id), Event.WEBRTCTRANSPORT_DTLS_STATE_CHANGE, - NotificationBody.FBS_WebRtcTransport_DtlsStateChangeNotification, + NotificationBody.WebRtcTransport_DtlsStateChangeNotification, dtlsStateChangeNotification.pack(builder) ); diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index 4668798ec3..1bd15bfb1c 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -1571,7 +1571,7 @@ mod root { /// The table `StringString` in the namespace `FBS.Common` /// /// Generated from these locations: - /// * Table `StringString` in the file `../worker/fbs/common.fbs:4` + /// * Table `StringString` in the file `../worker/fbs/common.fbs:3` #[derive( Clone, Debug, @@ -1862,7 +1862,7 @@ mod root { /// The table `StringUint8` in the namespace `FBS.Common` /// /// Generated from these locations: - /// * Table `StringUint8` in the file `../worker/fbs/common.fbs:9` + /// * Table `StringUint8` in the file `../worker/fbs/common.fbs:8` #[derive( Clone, Debug, @@ -2166,7 +2166,7 @@ mod root { /// The table `Uint16String` in the namespace `FBS.Common` /// /// Generated from these locations: - /// * Table `Uint16String` in the file `../worker/fbs/common.fbs:14` + /// * Table `Uint16String` in the file `../worker/fbs/common.fbs:13` #[derive( Clone, Debug, @@ -2470,7 +2470,7 @@ mod root { /// The table `Uint32String` in the namespace `FBS.Common` /// /// Generated from these locations: - /// * Table `Uint32String` in the file `../worker/fbs/common.fbs:19` + /// * Table `Uint32String` in the file `../worker/fbs/common.fbs:18` #[derive( Clone, Debug, @@ -2774,7 +2774,7 @@ mod root { /// The table `StringStringArray` in the namespace `FBS.Common` /// /// Generated from these locations: - /// * Table `StringStringArray` in the file `../worker/fbs/common.fbs:24` + /// * Table `StringStringArray` in the file `../worker/fbs/common.fbs:23` #[derive( Clone, Debug, @@ -9883,7 +9883,7 @@ mod root { /// The enum `TraceDirection` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Enum `TraceDirection` in the file `../worker/fbs/consumer.fbs:114` + /// * Enum `TraceDirection` in the file `../worker/fbs/consumer.fbs:121` #[derive( Copy, Clone, @@ -10053,7 +10053,7 @@ mod root { /// The union `TraceInfo` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Union `TraceInfo` in the file `../worker/fbs/consumer.fbs:116` + /// * Union `TraceInfo` in the file `../worker/fbs/consumer.fbs:126` #[derive( Clone, Debug, @@ -10385,7 +10385,7 @@ mod root { /// The table `KeyFrameTraceInfo` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/consumer.fbs:123` + /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/consumer.fbs:133` #[derive( Clone, Debug, @@ -10667,7 +10667,7 @@ mod root { /// The table `FirTraceInfo` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `FirTraceInfo` in the file `../worker/fbs/consumer.fbs:127` + /// * Table `FirTraceInfo` in the file `../worker/fbs/consumer.fbs:137` #[derive( Clone, Debug, @@ -10944,7 +10944,7 @@ mod root { /// The table `PliTraceInfo` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `PliTraceInfo` in the file `../worker/fbs/consumer.fbs:131` + /// * Table `PliTraceInfo` in the file `../worker/fbs/consumer.fbs:141` #[derive( Clone, Debug, @@ -11221,7 +11221,7 @@ mod root { /// The table `RtpTraceInfo` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `RtpTraceInfo` in the file `../worker/fbs/consumer.fbs:135` + /// * Table `RtpTraceInfo` in the file `../worker/fbs/consumer.fbs:145` #[derive( Clone, Debug, @@ -11498,7 +11498,7 @@ mod root { /// The table `TraceNotification` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/consumer.fbs:139` + /// * Table `TraceNotification` in the file `../worker/fbs/consumer.fbs:149` #[derive( Clone, Debug, @@ -11958,7 +11958,7 @@ mod root { /// The enum `MediaKind` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Enum `MediaKind` in the file `../worker/fbs/rtpParameters.fbs:4` + /// * Enum `MediaKind` in the file `../worker/fbs/rtpParameters.fbs:3` #[derive( Copy, Clone, @@ -12132,7 +12132,7 @@ mod root { /// The enum `Type` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Enum `Type` in the file `../worker/fbs/rtpParameters.fbs:5` + /// * Enum `Type` in the file `../worker/fbs/rtpParameters.fbs:9` #[derive( Copy, Clone, @@ -12320,7 +12320,7 @@ mod root { /// The table `Boolean` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `Boolean` in the file `../worker/fbs/rtpParameters.fbs:8` + /// * Table `Boolean` in the file `../worker/fbs/rtpParameters.fbs:18` #[derive( Clone, Debug, @@ -12579,7 +12579,7 @@ mod root { /// The table `Integer32` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `Integer32` in the file `../worker/fbs/rtpParameters.fbs:12` + /// * Table `Integer32` in the file `../worker/fbs/rtpParameters.fbs:22` #[derive( Clone, Debug, @@ -12838,7 +12838,7 @@ mod root { /// The table `Integer32Array` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `Integer32Array` in the file `../worker/fbs/rtpParameters.fbs:16` + /// * Table `Integer32Array` in the file `../worker/fbs/rtpParameters.fbs:26` #[derive( Clone, Debug, @@ -13125,7 +13125,7 @@ mod root { /// The table `Double` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `Double` in the file `../worker/fbs/rtpParameters.fbs:20` + /// * Table `Double` in the file `../worker/fbs/rtpParameters.fbs:30` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -13376,7 +13376,7 @@ mod root { /// The table `String` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `String` in the file `../worker/fbs/rtpParameters.fbs:24` + /// * Table `String` in the file `../worker/fbs/rtpParameters.fbs:34` #[derive( Clone, Debug, @@ -13617,7 +13617,7 @@ mod root { /// The union `Value` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Union `Value` in the file `../worker/fbs/rtpParameters.fbs:28` + /// * Union `Value` in the file `../worker/fbs/rtpParameters.fbs:38` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -13964,7 +13964,7 @@ mod root { /// The table `Parameter` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `Parameter` in the file `../worker/fbs/rtpParameters.fbs:36` + /// * Table `Parameter` in the file `../worker/fbs/rtpParameters.fbs:46` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -14233,7 +14233,7 @@ mod root { /// The table `RtcpFeedback` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `RtcpFeedback` in the file `../worker/fbs/rtpParameters.fbs:41` + /// * Table `RtcpFeedback` in the file `../worker/fbs/rtpParameters.fbs:51` #[derive( Clone, Debug, @@ -14524,7 +14524,7 @@ mod root { /// The table `RtpCodecParameters` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `RtpCodecParameters` in the file `../worker/fbs/rtpParameters.fbs:46` + /// * Table `RtpCodecParameters` in the file `../worker/fbs/rtpParameters.fbs:56` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -15086,16 +15086,238 @@ mod root { } } + /// The enum `RtpHeaderExtensionUri` in the namespace `FBS.RtpParameters` + /// + /// Generated from these locations: + /// * Enum `RtpHeaderExtensionUri` in the file `../worker/fbs/rtpParameters.fbs:65` + #[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:55` + /// * Table `RtpHeaderExtensionParameters` in the file `../worker/fbs/rtpParameters.fbs:79` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct RtpHeaderExtensionParameters { /// The field `uri` in the table `RtpHeaderExtensionParameters` - pub uri: ::planus::alloc::string::String, + pub uri: self::RtpHeaderExtensionUri, /// The field `id` in the table `RtpHeaderExtensionParameters` pub id: u8, /// The field `encrypt` in the table `RtpHeaderExtensionParameters` @@ -15104,6 +15326,18 @@ mod root { 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] @@ -15114,27 +15348,33 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_uri: impl ::planus::WriteAs<::planus::Offset>, + 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); + 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(); - table_writer.write_entry::<::planus::Offset>(0); 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); } @@ -15144,12 +15384,14 @@ mod root { unsafe { table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_uri); 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); } @@ -15200,7 +15442,7 @@ mod root { ) -> ::planus::Offset { RtpHeaderExtensionParameters::create( builder, - &self.uri, + self.uri, self.id, self.encrypt, &self.parameters, @@ -15221,10 +15463,23 @@ mod root { #[allow(clippy::type_complexity)] pub fn uri(self, value: T0) -> RtpHeaderExtensionParametersBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset>, + 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,)> { @@ -15318,7 +15573,10 @@ mod root { } impl< - T0: ::planus::WriteAs<::planus::Offset>, + T0: ::planus::WriteAsDefault< + self::RtpHeaderExtensionUri, + self::RtpHeaderExtensionUri, + >, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsOptional< @@ -15339,7 +15597,10 @@ mod root { } impl< - T0: ::planus::WriteAs<::planus::Offset>, + T0: ::planus::WriteAsDefault< + self::RtpHeaderExtensionUri, + self::RtpHeaderExtensionUri, + >, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsOptional< @@ -15362,7 +15623,10 @@ mod root { } impl< - T0: ::planus::WriteAs<::planus::Offset>, + T0: ::planus::WriteAsDefault< + self::RtpHeaderExtensionUri, + self::RtpHeaderExtensionUri, + >, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsOptional< @@ -15388,9 +15652,12 @@ mod root { impl<'a> RtpHeaderExtensionParametersRef<'a> { /// Getter for the [`uri` field](RtpHeaderExtensionParameters#structfield.uri). #[inline] - pub fn uri(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0 - .access_required(0, "RtpHeaderExtensionParameters", "uri") + 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). @@ -15543,7 +15810,7 @@ mod root { /// The table `Rtx` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `Rtx` in the file `../worker/fbs/rtpParameters.fbs:62` + /// * Table `Rtx` in the file `../worker/fbs/rtpParameters.fbs:86` #[derive( Clone, Debug, @@ -15796,7 +16063,7 @@ mod root { /// The table `RtpEncodingParameters` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `RtpEncodingParameters` in the file `../worker/fbs/rtpParameters.fbs:66` + /// * Table `RtpEncodingParameters` in the file `../worker/fbs/rtpParameters.fbs:90` #[derive( Clone, Debug, @@ -16443,7 +16710,7 @@ mod root { /// The table `RtcpParameters` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `RtcpParameters` in the file `../worker/fbs/rtpParameters.fbs:76` + /// * Table `RtcpParameters` in the file `../worker/fbs/rtpParameters.fbs:100` #[derive( Clone, Debug, @@ -16785,7 +17052,7 @@ mod root { /// The table `RtpParameters` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `RtpParameters` in the file `../worker/fbs/rtpParameters.fbs:81` + /// * Table `RtpParameters` in the file `../worker/fbs/rtpParameters.fbs:105` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -17237,7 +17504,7 @@ mod root { /// The table `CodecMapping` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `CodecMapping` in the file `../worker/fbs/rtpParameters.fbs:89` + /// * Table `CodecMapping` in the file `../worker/fbs/rtpParameters.fbs:113` #[derive( Clone, Debug, @@ -17573,7 +17840,7 @@ mod root { /// The table `EncodingMapping` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `EncodingMapping` in the file `../worker/fbs/rtpParameters.fbs:94` + /// * Table `EncodingMapping` in the file `../worker/fbs/rtpParameters.fbs:118` #[derive( Clone, Debug, @@ -18029,7 +18296,7 @@ mod root { /// The table `RtpMapping` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `RtpMapping` in the file `../worker/fbs/rtpParameters.fbs:101` + /// * Table `RtpMapping` in the file `../worker/fbs/rtpParameters.fbs:125` #[derive( Clone, Debug, @@ -23196,7 +23463,7 @@ mod root { /// The table `Params` in the namespace `FBS.RtxStream` /// /// Generated from these locations: - /// * Table `Params` in the file `../worker/fbs/rtxStream.fbs:4` + /// * Table `Params` in the file `../worker/fbs/rtxStream.fbs:3` #[derive( Clone, Debug, @@ -23665,7 +23932,7 @@ mod root { /// The table `RtxDump` in the namespace `FBS.RtxStream` /// /// Generated from these locations: - /// * Table `RtxDump` in the file `../worker/fbs/rtxStream.fbs:14` + /// * Table `RtxDump` in the file `../worker/fbs/rtxStream.fbs:13` #[derive( Clone, Debug, @@ -27873,7 +28140,7 @@ mod root { /// The table `NumSctpStreams` in the namespace `FBS.SctpParameters` /// /// Generated from these locations: - /// * Table `NumSctpStreams` in the file `../worker/fbs/sctpParameters.fbs:4` + /// * Table `NumSctpStreams` in the file `../worker/fbs/sctpParameters.fbs:3` #[derive( Clone, Debug, @@ -28200,7 +28467,7 @@ mod root { /// The table `SctpParameters` in the namespace `FBS.SctpParameters` /// /// Generated from these locations: - /// * Table `SctpParameters` in the file `../worker/fbs/sctpParameters.fbs:9` + /// * Table `SctpParameters` in the file `../worker/fbs/sctpParameters.fbs:8` #[derive( Clone, Debug, @@ -28807,7 +29074,7 @@ mod root { /// The table `SctpStreamParameters` in the namespace `FBS.SctpParameters` /// /// Generated from these locations: - /// * Table `SctpStreamParameters` in the file `../worker/fbs/sctpParameters.fbs:20` + /// * Table `SctpStreamParameters` in the file `../worker/fbs/sctpParameters.fbs:19` #[derive( Clone, Debug, @@ -32619,7 +32886,7 @@ mod root { /// The table `ListenInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ListenInfo` in the file `../worker/fbs/transport.fbs:12` + /// * Table `ListenInfo` in the file `../worker/fbs/transport.fbs:15` #[derive( Clone, Debug, @@ -33133,7 +33400,7 @@ mod root { /// The table `RestartIceResponse` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `RestartIceResponse` in the file `../worker/fbs/transport.fbs:21` + /// * Table `RestartIceResponse` in the file `../worker/fbs/transport.fbs:24` #[derive( Clone, Debug, @@ -33482,7 +33749,7 @@ mod root { /// The table `ProduceRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ProduceRequest` in the file `../worker/fbs/transport.fbs:27` + /// * Table `ProduceRequest` in the file `../worker/fbs/transport.fbs:30` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -33990,7 +34257,7 @@ mod root { /// The table `ProduceResponse` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ProduceResponse` in the file `../worker/fbs/transport.fbs:36` + /// * Table `ProduceResponse` in the file `../worker/fbs/transport.fbs:39` #[derive( Clone, Debug, @@ -34291,7 +34558,7 @@ mod root { /// The table `ConsumeRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ConsumeRequest` in the file `../worker/fbs/transport.fbs:40` + /// * Table `ConsumeRequest` in the file `../worker/fbs/transport.fbs:43` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -34998,7 +35265,7 @@ mod root { /// The table `ConsumeResponse` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ConsumeResponse` in the file `../worker/fbs/transport.fbs:52` + /// * Table `ConsumeResponse` in the file `../worker/fbs/transport.fbs:55` #[derive( Clone, Debug, @@ -35471,7 +35738,7 @@ mod root { /// The table `ProduceDataRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ProduceDataRequest` in the file `../worker/fbs/transport.fbs:59` + /// * Table `ProduceDataRequest` in the file `../worker/fbs/transport.fbs:62` #[derive( Clone, Debug, @@ -36019,7 +36286,7 @@ mod root { /// The table `ConsumeDataRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ConsumeDataRequest` in the file `../worker/fbs/transport.fbs:68` + /// * Table `ConsumeDataRequest` in the file `../worker/fbs/transport.fbs:71` #[derive( Clone, Debug, @@ -36665,7 +36932,7 @@ mod root { /// The table `Tuple` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Tuple` in the file `../worker/fbs/transport.fbs:79` + /// * Table `Tuple` in the file `../worker/fbs/transport.fbs:82` #[derive( Clone, Debug, @@ -37119,7 +37386,7 @@ mod root { /// The table `RtpListener` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `RtpListener` in the file `../worker/fbs/transport.fbs:87` + /// * Table `RtpListener` in the file `../worker/fbs/transport.fbs:90` #[derive( Clone, Debug, @@ -37482,7 +37749,7 @@ mod root { /// The table `SctpListener` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SctpListener` in the file `../worker/fbs/transport.fbs:93` + /// * Table `SctpListener` in the file `../worker/fbs/transport.fbs:96` #[derive( Clone, Debug, @@ -37756,7 +38023,7 @@ mod root { /// The table `RecvRtpHeaderExtensions` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `RecvRtpHeaderExtensions` in the file `../worker/fbs/transport.fbs:97` + /// * Table `RecvRtpHeaderExtensions` in the file `../worker/fbs/transport.fbs:100` #[derive( Clone, Debug, @@ -38279,7 +38546,7 @@ mod root { /// The table `Options` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Options` in the file `../worker/fbs/transport.fbs:105` + /// * Table `Options` in the file `../worker/fbs/transport.fbs:108` #[derive( Clone, Debug, @@ -38975,7 +39242,7 @@ mod root { /// The enum `TraceEventType` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `TraceEventType` in the file `../worker/fbs/transport.fbs:117` + /// * Enum `TraceEventType` in the file `../worker/fbs/transport.fbs:121` #[derive( Copy, Clone, @@ -39145,7 +39412,7 @@ mod root { /// The table `Dump` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Dump` in the file `../worker/fbs/transport.fbs:119` + /// * Table `Dump` in the file `../worker/fbs/transport.fbs:126` #[derive( Clone, Debug, @@ -40188,7 +40455,7 @@ mod root { /// The table `Stats` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Stats` in the file `../worker/fbs/transport.fbs:137` + /// * Table `Stats` in the file `../worker/fbs/transport.fbs:144` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -42849,7 +43116,7 @@ mod root { /// The table `SetMaxIncomingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMaxIncomingBitrateRequest` in the file `../worker/fbs/transport.fbs:164` + /// * Table `SetMaxIncomingBitrateRequest` in the file `../worker/fbs/transport.fbs:171` #[derive( Clone, Debug, @@ -43157,7 +43424,7 @@ mod root { /// The table `SetMaxOutgoingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMaxOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:168` + /// * Table `SetMaxOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:175` #[derive( Clone, Debug, @@ -43465,7 +43732,7 @@ mod root { /// The table `SetMinOutgoingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMinOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:172` + /// * Table `SetMinOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:179` #[derive( Clone, Debug, @@ -43773,7 +44040,7 @@ mod root { /// The table `EnableTraceEventRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/transport.fbs:176` + /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/transport.fbs:183` #[derive( Clone, Debug, @@ -44051,7 +44318,7 @@ mod root { /// The table `CloseProducerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseProducerRequest` in the file `../worker/fbs/transport.fbs:180` + /// * Table `CloseProducerRequest` in the file `../worker/fbs/transport.fbs:187` #[derive( Clone, Debug, @@ -44317,7 +44584,7 @@ mod root { /// The table `CloseConsumerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseConsumerRequest` in the file `../worker/fbs/transport.fbs:184` + /// * Table `CloseConsumerRequest` in the file `../worker/fbs/transport.fbs:191` #[derive( Clone, Debug, @@ -44583,7 +44850,7 @@ mod root { /// The table `CloseDataProducerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseDataProducerRequest` in the file `../worker/fbs/transport.fbs:188` + /// * Table `CloseDataProducerRequest` in the file `../worker/fbs/transport.fbs:195` #[derive( Clone, Debug, @@ -44858,7 +45125,7 @@ mod root { /// The table `CloseDataConsumerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseDataConsumerRequest` in the file `../worker/fbs/transport.fbs:192` + /// * Table `CloseDataConsumerRequest` in the file `../worker/fbs/transport.fbs:199` #[derive( Clone, Debug, @@ -45133,7 +45400,7 @@ mod root { /// The table `SendRtcpNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SendRtcpNotification` in the file `../worker/fbs/transport.fbs:198` + /// * Table `SendRtcpNotification` in the file `../worker/fbs/transport.fbs:205` #[derive( Clone, Debug, @@ -45398,7 +45665,7 @@ mod root { /// The table `SctpStateChangeNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SctpStateChangeNotification` in the file `../worker/fbs/transport.fbs:204` + /// * Table `SctpStateChangeNotification` in the file `../worker/fbs/transport.fbs:211` #[derive( Clone, Debug, @@ -45719,7 +45986,7 @@ mod root { /// The enum `TraceDirection` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `TraceDirection` in the file `../worker/fbs/transport.fbs:209` + /// * Enum `TraceDirection` in the file `../worker/fbs/transport.fbs:216` #[derive( Copy, Clone, @@ -45889,7 +46156,7 @@ mod root { /// The union `TraceInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:211` + /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:221` #[derive( Clone, Debug, @@ -46042,7 +46309,7 @@ mod root { /// The enum `BweType` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:215` + /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:225` #[derive( Copy, Clone, @@ -46212,7 +46479,7 @@ mod root { /// The table `BweTraceInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:217` + /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:230` #[derive( Clone, Debug, @@ -46890,7 +47157,7 @@ mod root { /// The table `TraceNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:228` + /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:241` #[derive( Clone, Debug, @@ -47354,7 +47621,7 @@ mod root { /// The enum `SctpState` in the namespace `FBS.SctpAssociation` /// /// Generated from these locations: - /// * Enum `SctpState` in the file `../worker/fbs/sctpAssociation.fbs:4` + /// * Enum `SctpState` in the file `../worker/fbs/sctpAssociation.fbs:3` #[derive( Copy, Clone, @@ -47547,7 +47814,7 @@ mod root { /// The enum `SrtpCryptoSuite` in the namespace `FBS.SrtpParameters` /// /// Generated from these locations: - /// * Enum `SrtpCryptoSuite` in the file `../worker/fbs/srtpParameters.fbs:4` + /// * Enum `SrtpCryptoSuite` in the file `../worker/fbs/srtpParameters.fbs:3` #[derive( Copy, Clone, @@ -47730,7 +47997,7 @@ mod root { /// The table `SrtpParameters` in the namespace `FBS.SrtpParameters` /// /// Generated from these locations: - /// * Table `SrtpParameters` in the file `../worker/fbs/srtpParameters.fbs:11` + /// * Table `SrtpParameters` in the file `../worker/fbs/srtpParameters.fbs:10` #[derive( Clone, Debug, @@ -48049,7 +48316,7 @@ mod root { /// The table `Log` in the namespace `FBS.Log` /// /// Generated from these locations: - /// * Table `Log` in the file `../worker/fbs/log.fbs:4` + /// * Table `Log` in the file `../worker/fbs/log.fbs:3` #[derive( Clone, Debug, @@ -48475,16 +48742,16 @@ mod root { Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub enum Body { - /// The variant of type `FBS.Request.Request` in the union `Body` + /// The variant `Request` in the union `Body` Request(::planus::alloc::boxed::Box), - /// The variant of type `FBS.Response.Response` in the union `Body` + /// The variant `Response` in the union `Body` Response(::planus::alloc::boxed::Box), - /// The variant of type `FBS.Notification.Notification` in the union `Body` + /// The variant `Notification` in the union `Body` Notification(::planus::alloc::boxed::Box), - /// The variant of type `FBS.Log.Log` in the union `Body` + /// The variant `Log` in the union `Body` Log(::planus::alloc::boxed::Box), } @@ -49372,7 +49639,7 @@ mod root { /// The union `Body` in the namespace `FBS.Notification` /// /// Generated from these locations: - /// * Union `Body` in the file `../worker/fbs/notification.fbs:49` + /// * Union `Body` in the file `../worker/fbs/notification.fbs:50` #[derive( Clone, Debug, @@ -49385,18 +49652,23 @@ mod root { ::serde::Deserialize, )] pub enum Body { - /// The variant of type `FBS.Transport.SendRtcpNotification` in the union `Body` - SendRtcpNotification( + /// The variant `Transport_SendRtcpNotification` in the union `Body` + TransportSendRtcpNotification( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Transport.SctpStateChangeNotification` in the union `Body` - SctpStateChangeNotification( + /// The variant `Transport_SctpStateChangeNotification` in the union `Body` + TransportSctpStateChangeNotification( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.DataProducer.SendNotification` in the union `Body` - SendNotification( + /// 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, ), @@ -49405,91 +49677,100 @@ mod root { ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.WebRtcTransport.IceSelectedTupleChangeNotification` in the union `Body` - IceSelectedTupleChangeNotification( + /// The variant `WebRtcTransport_IceSelectedTupleChangeNotification` in the union `Body` + WebRtcTransportIceSelectedTupleChangeNotification( ::planus::alloc::boxed::Box< super::web_rtc_transport::IceSelectedTupleChangeNotification, >, ), - /// The variant of type `FBS.WebRtcTransport.IceStateChangeNotification` in the union `Body` - IceStateChangeNotification( + /// The variant `WebRtcTransport_IceStateChangeNotification` in the union `Body` + WebRtcTransportIceStateChangeNotification( ::planus::alloc::boxed::Box< super::web_rtc_transport::IceStateChangeNotification, >, ), - /// The variant of type `FBS.WebRtcTransport.DtlsStateChangeNotification` in the union `Body` - DtlsStateChangeNotification( + /// The variant `WebRtcTransport_DtlsStateChangeNotification` in the union `Body` + WebRtcTransportDtlsStateChangeNotification( ::planus::alloc::boxed::Box< super::web_rtc_transport::DtlsStateChangeNotification, >, ), - /// The variant of type `FBS.PlainTransport.TupleNotification` in the union `Body` - TupleNotification( + /// The variant `PlainTransport_TupleNotification` in the union `Body` + PlainTransportTupleNotification( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.PlainTransport.RtcpTupleNotification` in the union `Body` - RtcpTupleNotification( + /// The variant `PlainTransport_RtcpTupleNotification` in the union `Body` + PlainTransportRtcpTupleNotification( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.DirectTransport.RtcpNotification` in the union `Body` - RtcpNotification( + /// The variant `DirectTransport_RtcpNotification` in the union `Body` + DirectTransportRtcpNotification( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Consumer.ScoreNotification` in the union `Body` - ScoreNotification(::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 of type `FBS.Producer.VideoOrientationChangeNotification` in the union `Body` - VideoOrientationChangeNotification( + /// The variant `Producer_VideoOrientationChangeNotification` in the union `Body` + ProducerVideoOrientationChangeNotification( ::planus::alloc::boxed::Box< super::producer::VideoOrientationChangeNotification, >, ), - /// The variant of type `FBS.Consumer.LayersChangeNotification` in the union `Body` - LayersChangeNotification( + /// The variant `Consumer_LayersChangeNotification` in the union `Body` + ConsumerLayersChangeNotification( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Consumer.RtpNotification` in the union `Body` - RtpNotification(::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 of type `FBS.DataConsumer.MessageNotification` in the union `Body` - MessageNotification( + /// The variant `DataConsumer_MessageNotification` in the union `Body` + DataConsumerMessageNotification( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.DataConsumer.BufferedAmountLowNotification` in the union `Body` - BufferedAmountLowNotification( + /// The variant `DataConsumer_BufferedAmountLowNotification` in the union `Body` + DataConsumerBufferedAmountLowNotification( ::planus::alloc::boxed::Box< super::data_consumer::BufferedAmountLowNotification, >, ), - /// The variant of type `FBS.ActiveSpeakerObserver.DominantSpeakerNotification` in the union `Body` - DominantSpeakerNotification( + /// The variant `ActiveSpeakerObserver_DominantSpeakerNotification` in the union `Body` + ActiveSpeakerObserverDominantSpeakerNotification( ::planus::alloc::boxed::Box< super::active_speaker_observer::DominantSpeakerNotification, >, ), - /// The variant of type `FBS.AudioLevelObserver.VolumesNotification` in the union `Body` - VolumesNotification( + /// The variant `AudioLevelObserver_VolumesNotification` in the union `Body` + AudioLevelObserverVolumesNotification( ::planus::alloc::boxed::Box, ), } @@ -49502,7 +49783,7 @@ mod root { } #[inline] - pub fn create_send_rtcp_notification( + pub fn create_transport_send_rtcp_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -49510,7 +49791,7 @@ mod root { } #[inline] - pub fn create_sctp_state_change_notification( + pub fn create_transport_sctp_state_change_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -49518,81 +49799,89 @@ mod root { } #[inline] - pub fn create_send_notification( + pub fn create_producer_send_notification( builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, + 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(4, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(5, value.prepare(builder).downcast()) } #[inline] - pub fn create_ice_selected_tuple_change_notification( + 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(5, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(6, value.prepare(builder).downcast()) } #[inline] - pub fn create_ice_state_change_notification( + 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(6, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(7, value.prepare(builder).downcast()) } #[inline] - pub fn create_dtls_state_change_notification( + 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(7, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(8, value.prepare(builder).downcast()) } #[inline] - pub fn create_tuple_notification( + pub fn create_plain_transport_tuple_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(8, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(9, value.prepare(builder).downcast()) } #[inline] - pub fn create_rtcp_tuple_notification( + pub fn create_plain_transport_rtcp_tuple_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(9, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(10, value.prepare(builder).downcast()) } #[inline] - pub fn create_rtcp_notification( + pub fn create_direct_transport_rtcp_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(10, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) } #[inline] - pub fn create_score_notification( + pub fn create_producer_score_notification( builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, + value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(11, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) } #[inline] @@ -49600,33 +49889,41 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(12, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) } #[inline] - pub fn create_video_orientation_change_notification( + pub fn create_producer_video_orientation_change_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset< super::producer::VideoOrientationChangeNotification, >, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(13, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) } #[inline] - pub fn create_layers_change_notification( + pub fn create_consumer_layers_change_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(14, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) } #[inline] - pub fn create_rtp_notification( + pub fn create_consumer_rtp_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(15, value.prepare(builder).downcast()) + ::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] @@ -49634,45 +49931,45 @@ mod root { builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(16, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(18, value.prepare(builder).downcast()) } #[inline] - pub fn create_message_notification( + pub fn create_data_consumer_message_notification( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(17, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(19, value.prepare(builder).downcast()) } #[inline] - pub fn create_buffered_amount_low_notification( + 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(18, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(20, value.prepare(builder).downcast()) } #[inline] - pub fn create_dominant_speaker_notification( + 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(19, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(21, value.prepare(builder).downcast()) } #[inline] - pub fn create_volumes_notification( + 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(20, value.prepare(builder).downcast()) + ::planus::UnionOffset::new(22, value.prepare(builder).downcast()) } } @@ -49680,65 +49977,83 @@ mod root { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { match self { - Self::SendRtcpNotification(value) => { - Self::create_send_rtcp_notification(builder, value) + Self::TransportSendRtcpNotification(value) => { + Self::create_transport_send_rtcp_notification(builder, value) } - Self::SctpStateChangeNotification(value) => { - Self::create_sctp_state_change_notification(builder, value) + Self::TransportSctpStateChangeNotification(value) => { + Self::create_transport_sctp_state_change_notification(builder, value) } - Self::SendNotification(value) => { - Self::create_send_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::IceSelectedTupleChangeNotification(value) => { - Self::create_ice_selected_tuple_change_notification(builder, value) + Self::WebRtcTransportIceSelectedTupleChangeNotification(value) => { + Self::create_web_rtc_transport_ice_selected_tuple_change_notification( + builder, value, + ) } - Self::IceStateChangeNotification(value) => { - Self::create_ice_state_change_notification(builder, value) + Self::WebRtcTransportIceStateChangeNotification(value) => { + Self::create_web_rtc_transport_ice_state_change_notification( + builder, value, + ) } - Self::DtlsStateChangeNotification(value) => { - Self::create_dtls_state_change_notification(builder, value) + Self::WebRtcTransportDtlsStateChangeNotification(value) => { + Self::create_web_rtc_transport_dtls_state_change_notification( + builder, value, + ) } - Self::TupleNotification(value) => { - Self::create_tuple_notification(builder, value) + Self::PlainTransportTupleNotification(value) => { + Self::create_plain_transport_tuple_notification(builder, value) } - Self::RtcpTupleNotification(value) => { - Self::create_rtcp_tuple_notification(builder, value) + Self::PlainTransportRtcpTupleNotification(value) => { + Self::create_plain_transport_rtcp_tuple_notification(builder, value) } - Self::RtcpNotification(value) => { - Self::create_rtcp_notification(builder, value) + Self::DirectTransportRtcpNotification(value) => { + Self::create_direct_transport_rtcp_notification(builder, value) } - Self::ScoreNotification(value) => { - Self::create_score_notification(builder, value) + Self::ProducerScoreNotification(value) => { + Self::create_producer_score_notification(builder, value) } Self::ProducerTraceNotification(value) => { Self::create_producer_trace_notification(builder, value) } - Self::VideoOrientationChangeNotification(value) => { - Self::create_video_orientation_change_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::LayersChangeNotification(value) => { - Self::create_layers_change_notification(builder, value) + Self::ConsumerRtpNotification(value) => { + Self::create_consumer_rtp_notification(builder, value) } - Self::RtpNotification(value) => { - Self::create_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::MessageNotification(value) => { - Self::create_message_notification(builder, value) + Self::DataConsumerMessageNotification(value) => { + Self::create_data_consumer_message_notification(builder, value) } - Self::BufferedAmountLowNotification(value) => { - Self::create_buffered_amount_low_notification(builder, value) + Self::DataConsumerBufferedAmountLowNotification(value) => { + Self::create_data_consumer_buffered_amount_low_notification( + builder, value, + ) } - Self::DominantSpeakerNotification(value) => { - Self::create_dominant_speaker_notification(builder, value) + Self::ActiveSpeakerObserverDominantSpeakerNotification(value) => { + Self::create_active_speaker_observer_dominant_speaker_notification( + builder, value, + ) } - Self::VolumesNotification(value) => { - Self::create_volumes_notification(builder, value) + Self::AudioLevelObserverVolumesNotification(value) => { + Self::create_audio_level_observer_volumes_notification(builder, value) } } } @@ -49762,9 +50077,9 @@ mod root { pub struct BodyBuilder(T); impl BodyBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`SendRtcpNotification` variant](Body#variant.SendRtcpNotification). + /// Creates an instance of the [`Transport_SendRtcpNotification` variant](Body#variant.TransportSendRtcpNotification). #[inline] - pub fn send_rtcp_notification( + pub fn transport_send_rtcp_notification( self, value: T, ) -> BodyBuilder<::planus::Initialized<1, T>> @@ -49774,9 +50089,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`SctpStateChangeNotification` variant](Body#variant.SctpStateChangeNotification). + /// Creates an instance of the [`Transport_SctpStateChangeNotification` variant](Body#variant.TransportSctpStateChangeNotification). #[inline] - pub fn sctp_state_change_notification( + pub fn transport_sctp_state_change_notification( self, value: T, ) -> BodyBuilder<::planus::Initialized<2, T>> @@ -49786,12 +50101,24 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`SendNotification` variant](Body#variant.SendNotification). + /// Creates an instance of the [`Producer_SendNotification` variant](Body#variant.ProducerSendNotification). #[inline] - pub fn send_notification( + 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, { @@ -49803,19 +50130,19 @@ mod root { pub fn transport_trace_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<4, T>> + ) -> BodyBuilder<::planus::Initialized<5, T>> where T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`IceSelectedTupleChangeNotification` variant](Body#variant.IceSelectedTupleChangeNotification). + /// Creates an instance of the [`WebRtcTransport_IceSelectedTupleChangeNotification` variant](Body#variant.WebRtcTransportIceSelectedTupleChangeNotification). #[inline] - pub fn ice_selected_tuple_change_notification( + pub fn web_rtc_transport_ice_selected_tuple_change_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<5, T>> + ) -> BodyBuilder<::planus::Initialized<6, T>> where T: ::planus::WriteAsOffset< super::web_rtc_transport::IceSelectedTupleChangeNotification, @@ -49824,12 +50151,12 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`IceStateChangeNotification` variant](Body#variant.IceStateChangeNotification). + /// Creates an instance of the [`WebRtcTransport_IceStateChangeNotification` variant](Body#variant.WebRtcTransportIceStateChangeNotification). #[inline] - pub fn ice_state_change_notification( + pub fn web_rtc_transport_ice_state_change_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<6, T>> + ) -> BodyBuilder<::planus::Initialized<7, T>> where T: ::planus::WriteAsOffset< super::web_rtc_transport::IceStateChangeNotification, @@ -49838,12 +50165,12 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`DtlsStateChangeNotification` variant](Body#variant.DtlsStateChangeNotification). + /// Creates an instance of the [`WebRtcTransport_DtlsStateChangeNotification` variant](Body#variant.WebRtcTransportDtlsStateChangeNotification). #[inline] - pub fn dtls_state_change_notification( + pub fn web_rtc_transport_dtls_state_change_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<7, T>> + ) -> BodyBuilder<::planus::Initialized<8, T>> where T: ::planus::WriteAsOffset< super::web_rtc_transport::DtlsStateChangeNotification, @@ -49852,50 +50179,50 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`TupleNotification` variant](Body#variant.TupleNotification). + /// Creates an instance of the [`PlainTransport_TupleNotification` variant](Body#variant.PlainTransportTupleNotification). #[inline] - pub fn tuple_notification( + pub fn plain_transport_tuple_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<8, T>> + ) -> BodyBuilder<::planus::Initialized<9, T>> where T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`RtcpTupleNotification` variant](Body#variant.RtcpTupleNotification). + /// Creates an instance of the [`PlainTransport_RtcpTupleNotification` variant](Body#variant.PlainTransportRtcpTupleNotification). #[inline] - pub fn rtcp_tuple_notification( + pub fn plain_transport_rtcp_tuple_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<9, T>> + ) -> BodyBuilder<::planus::Initialized<10, T>> where T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`RtcpNotification` variant](Body#variant.RtcpNotification). + /// Creates an instance of the [`DirectTransport_RtcpNotification` variant](Body#variant.DirectTransportRtcpNotification). #[inline] - pub fn rtcp_notification( + pub fn direct_transport_rtcp_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<10, T>> + ) -> BodyBuilder<::planus::Initialized<11, T>> where T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`ScoreNotification` variant](Body#variant.ScoreNotification). + /// Creates an instance of the [`Producer_ScoreNotification` variant](Body#variant.ProducerScoreNotification). #[inline] - pub fn score_notification( + pub fn producer_score_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<11, T>> + ) -> BodyBuilder<::planus::Initialized<12, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } @@ -49905,91 +50232,103 @@ mod root { pub fn producer_trace_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<12, T>> + ) -> BodyBuilder<::planus::Initialized<13, T>> where T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`VideoOrientationChangeNotification` variant](Body#variant.VideoOrientationChangeNotification). + /// Creates an instance of the [`Producer_VideoOrientationChangeNotification` variant](Body#variant.ProducerVideoOrientationChangeNotification). #[inline] - pub fn video_orientation_change_notification( + pub fn producer_video_orientation_change_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<13, T>> + ) -> BodyBuilder<::planus::Initialized<14, T>> where T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`LayersChangeNotification` variant](Body#variant.LayersChangeNotification). + /// Creates an instance of the [`Consumer_LayersChangeNotification` variant](Body#variant.ConsumerLayersChangeNotification). #[inline] - pub fn layers_change_notification( + pub fn consumer_layers_change_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<14, T>> + ) -> BodyBuilder<::planus::Initialized<15, T>> where T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`RtpNotification` variant](Body#variant.RtpNotification). + /// Creates an instance of the [`Consumer_RtpNotification` variant](Body#variant.ConsumerRtpNotification). #[inline] - pub fn rtp_notification( + pub fn consumer_rtp_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<15, 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<16, T>> + ) -> BodyBuilder<::planus::Initialized<18, T>> where T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`MessageNotification` variant](Body#variant.MessageNotification). + /// Creates an instance of the [`DataConsumer_MessageNotification` variant](Body#variant.DataConsumerMessageNotification). #[inline] - pub fn message_notification( + pub fn data_consumer_message_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<17, T>> + ) -> BodyBuilder<::planus::Initialized<19, T>> where T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`BufferedAmountLowNotification` variant](Body#variant.BufferedAmountLowNotification). + /// Creates an instance of the [`DataConsumer_BufferedAmountLowNotification` variant](Body#variant.DataConsumerBufferedAmountLowNotification). #[inline] - pub fn buffered_amount_low_notification( + pub fn data_consumer_buffered_amount_low_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<18, T>> + ) -> BodyBuilder<::planus::Initialized<20, T>> where T: ::planus::WriteAsOffset, { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`DominantSpeakerNotification` variant](Body#variant.DominantSpeakerNotification). + /// Creates an instance of the [`ActiveSpeakerObserver_DominantSpeakerNotification` variant](Body#variant.ActiveSpeakerObserverDominantSpeakerNotification). #[inline] - pub fn dominant_speaker_notification( + pub fn active_speaker_observer_dominant_speaker_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<19, T>> + ) -> BodyBuilder<::planus::Initialized<21, T>> where T: ::planus::WriteAsOffset< super::active_speaker_observer::DominantSpeakerNotification, @@ -49998,12 +50337,12 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`VolumesNotification` variant](Body#variant.VolumesNotification). + /// Creates an instance of the [`AudioLevelObserver_VolumesNotification` variant](Body#variant.AudioLevelObserverVolumesNotification). #[inline] - pub fn volumes_notification( + pub fn audio_level_observer_volumes_notification( self, value: T, - ) -> BodyBuilder<::planus::Initialized<20, T>> + ) -> BodyBuilder<::planus::Initialized<22, T>> where T: ::planus::WriteAsOffset, { @@ -50068,7 +50407,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<3, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50078,7 +50417,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<3, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50090,7 +50429,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<4, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50100,7 +50439,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<4, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50112,9 +50451,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<5, T>> where - T: ::planus::WriteAsOffset< - super::web_rtc_transport::IceSelectedTupleChangeNotification, - >, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50124,9 +50461,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<5, T>> where - T: ::planus::WriteAsOffset< - super::web_rtc_transport::IceSelectedTupleChangeNotification, - >, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50138,7 +50473,9 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<6, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset< + super::web_rtc_transport::IceSelectedTupleChangeNotification, + >, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50148,7 +50485,9 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<6, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset< + super::web_rtc_transport::IceSelectedTupleChangeNotification, + >, { #[inline] fn prepare( @@ -50160,7 +50499,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<7, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50170,7 +50509,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<7, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50182,7 +50521,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<8, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50192,7 +50531,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<8, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50204,7 +50543,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<9, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50214,7 +50553,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<9, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50226,7 +50565,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<10, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50236,7 +50575,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<10, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50248,7 +50587,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<11, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50258,7 +50597,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<11, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50270,7 +50609,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<12, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50280,7 +50619,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<12, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50292,7 +50631,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<13, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50302,7 +50641,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<13, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50314,7 +50653,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<14, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50324,7 +50663,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<14, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50336,7 +50675,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<15, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50346,7 +50685,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<15, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50358,7 +50697,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<16, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50368,7 +50707,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<16, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50380,7 +50719,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<17, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50390,7 +50729,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<17, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50402,7 +50741,7 @@ mod root { } impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<18, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { @@ -50412,7 +50751,7 @@ mod root { impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<18, T>> where - T: ::planus::WriteAsOffset, + T: ::planus::WriteAsOffset, { #[inline] fn prepare( @@ -50423,6 +50762,50 @@ mod root { } } 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, @@ -50430,11 +50813,11 @@ mod root { { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(19, (self.0).0.prepare(builder).downcast()) + ::planus::UnionOffset::new(21, (self.0).0.prepare(builder).downcast()) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<19, T>> + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<21, T>> where T: ::planus::WriteAsOffset< super::active_speaker_observer::DominantSpeakerNotification, @@ -50448,17 +50831,17 @@ mod root { ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - impl ::planus::WriteAsUnion for BodyBuilder<::planus::Initialized<20, T>> + 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(20, (self.0).0.prepare(builder).downcast()) + ::planus::UnionOffset::new(22, (self.0).0.prepare(builder).downcast()) } } - impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<20, T>> + impl ::planus::WriteAsOptionalUnion for BodyBuilder<::planus::Initialized<22, T>> where T: ::planus::WriteAsOffset, { @@ -50474,38 +50857,46 @@ mod root { /// Reference to a deserialized [Body]. #[derive(Copy, Clone, Debug)] pub enum BodyRef<'a> { - SendRtcpNotification(super::transport::SendRtcpNotificationRef<'a>), - SctpStateChangeNotification(super::transport::SctpStateChangeNotificationRef<'a>), - SendNotification(super::data_producer::SendNotificationRef<'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>), - IceSelectedTupleChangeNotification( + WebRtcTransportIceSelectedTupleChangeNotification( super::web_rtc_transport::IceSelectedTupleChangeNotificationRef<'a>, ), - IceStateChangeNotification( + WebRtcTransportIceStateChangeNotification( super::web_rtc_transport::IceStateChangeNotificationRef<'a>, ), - DtlsStateChangeNotification( + WebRtcTransportDtlsStateChangeNotification( super::web_rtc_transport::DtlsStateChangeNotificationRef<'a>, ), - TupleNotification(super::plain_transport::TupleNotificationRef<'a>), - RtcpTupleNotification(super::plain_transport::RtcpTupleNotificationRef<'a>), - RtcpNotification(super::direct_transport::RtcpNotificationRef<'a>), - ScoreNotification(super::consumer::ScoreNotificationRef<'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>), - VideoOrientationChangeNotification( + ProducerVideoOrientationChangeNotification( super::producer::VideoOrientationChangeNotificationRef<'a>, ), - LayersChangeNotification(super::consumer::LayersChangeNotificationRef<'a>), - RtpNotification(super::consumer::RtpNotificationRef<'a>), + ConsumerLayersChangeNotification(super::consumer::LayersChangeNotificationRef<'a>), + ConsumerRtpNotification(super::consumer::RtpNotificationRef<'a>), + ConsumerScoreNotification(super::consumer::ScoreNotificationRef<'a>), ConsumerTraceNotification(super::consumer::TraceNotificationRef<'a>), - MessageNotification(super::data_consumer::MessageNotificationRef<'a>), - BufferedAmountLowNotification( + DataConsumerMessageNotification(super::data_consumer::MessageNotificationRef<'a>), + DataConsumerBufferedAmountLowNotification( super::data_consumer::BufferedAmountLowNotificationRef<'a>, ), - DominantSpeakerNotification( + ActiveSpeakerObserverDominantSpeakerNotification( super::active_speaker_observer::DominantSpeakerNotificationRef<'a>, ), - VolumesNotification(super::audio_level_observer::VolumesNotificationRef<'a>), + AudioLevelObserverVolumesNotification( + super::audio_level_observer::VolumesNotificationRef<'a>, + ), } impl<'a> ::core::convert::TryFrom> for Body { @@ -50513,20 +50904,28 @@ mod root { fn try_from(value: BodyRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(match value { - BodyRef::SendRtcpNotification(value) => { - Self::SendRtcpNotification(::planus::alloc::boxed::Box::new( + BodyRef::TransportSendRtcpNotification(value) => { + Self::TransportSendRtcpNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::SctpStateChangeNotification(value) => { - Self::SctpStateChangeNotification(::planus::alloc::boxed::Box::new( + 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::SendNotification(value) => { - Self::SendNotification(::planus::alloc::boxed::Box::new( + BodyRef::DataProducerSendNotification(value) => { + Self::DataProducerSendNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -50537,46 +50936,52 @@ mod root { )) } - BodyRef::IceSelectedTupleChangeNotification(value) => { - Self::IceSelectedTupleChangeNotification( + BodyRef::WebRtcTransportIceSelectedTupleChangeNotification(value) => { + Self::WebRtcTransportIceSelectedTupleChangeNotification( ::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, ), ) } - BodyRef::IceStateChangeNotification(value) => { - Self::IceStateChangeNotification(::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::DtlsStateChangeNotification(value) => { - Self::DtlsStateChangeNotification(::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::TupleNotification(value) => { - Self::TupleNotification(::planus::alloc::boxed::Box::new( + BodyRef::PlainTransportTupleNotification(value) => { + Self::PlainTransportTupleNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::RtcpTupleNotification(value) => { - Self::RtcpTupleNotification(::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::RtcpNotification(value) => { - Self::RtcpNotification(::planus::alloc::boxed::Box::new( + BodyRef::DirectTransportRtcpNotification(value) => { + Self::DirectTransportRtcpNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::ScoreNotification(value) => { - Self::ScoreNotification(::planus::alloc::boxed::Box::new( + BodyRef::ProducerScoreNotification(value) => { + Self::ProducerScoreNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -50587,22 +50992,30 @@ mod root { )) } - BodyRef::VideoOrientationChangeNotification(value) => { - Self::VideoOrientationChangeNotification( + 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::LayersChangeNotification(value) => { - Self::LayersChangeNotification(::planus::alloc::boxed::Box::new( + BodyRef::ConsumerRtpNotification(value) => { + Self::ConsumerRtpNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::RtpNotification(value) => { - Self::RtpNotification(::planus::alloc::boxed::Box::new( + BodyRef::ConsumerScoreNotification(value) => { + Self::ConsumerScoreNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -50613,28 +51026,34 @@ mod root { )) } - BodyRef::MessageNotification(value) => { - Self::MessageNotification(::planus::alloc::boxed::Box::new( + BodyRef::DataConsumerMessageNotification(value) => { + Self::DataConsumerMessageNotification(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::BufferedAmountLowNotification(value) => { - Self::BufferedAmountLowNotification(::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::DominantSpeakerNotification(value) => { - Self::DominantSpeakerNotification(::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::VolumesNotification(value) => { - Self::VolumesNotification(::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)?, + ), + ) } }) } @@ -50647,66 +51066,90 @@ mod root { tag: u8, ) -> ::core::result::Result { match tag { - 1 => ::core::result::Result::Ok(Self::SendRtcpNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::SctpStateChangeNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 3 => ::core::result::Result::Ok(Self::SendNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 4 => ::core::result::Result::Ok(Self::TransportTraceNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 5 => ::core::result::Result::Ok(Self::IceSelectedTupleChangeNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 6 => ::core::result::Result::Ok(Self::IceStateChangeNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 7 => ::core::result::Result::Ok(Self::DtlsStateChangeNotification( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 8 => ::core::result::Result::Ok(Self::TupleNotification( + 1 => ::core::result::Result::Ok(Self::TransportSendRtcpNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 9 => ::core::result::Result::Ok(Self::RtcpTupleNotification( + 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)?, )), - 10 => ::core::result::Result::Ok(Self::RtcpNotification( + 4 => ::core::result::Result::Ok(Self::DataProducerSendNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 11 => ::core::result::Result::Ok(Self::ScoreNotification( + 5 => ::core::result::Result::Ok(Self::TransportTraceNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 12 => ::core::result::Result::Ok(Self::ProducerTraceNotification( + 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)?, )), - 13 => ::core::result::Result::Ok(Self::VideoOrientationChangeNotification( + 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)?, )), - 14 => ::core::result::Result::Ok(Self::LayersChangeNotification( + 12 => ::core::result::Result::Ok(Self::ProducerScoreNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 15 => ::core::result::Result::Ok(Self::RtpNotification( + 13 => ::core::result::Result::Ok(Self::ProducerTraceNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 16 => ::core::result::Result::Ok(Self::ConsumerTraceNotification( + 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)?, )), - 17 => ::core::result::Result::Ok(Self::MessageNotification( + 16 => ::core::result::Result::Ok(Self::ConsumerRtpNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 18 => ::core::result::Result::Ok(Self::BufferedAmountLowNotification( + 17 => ::core::result::Result::Ok(Self::ConsumerScoreNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 19 => ::core::result::Result::Ok(Self::DominantSpeakerNotification( + 18 => ::core::result::Result::Ok(Self::ConsumerTraceNotification( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 20 => ::core::result::Result::Ok(Self::VolumesNotification( + 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 }, ), @@ -50717,7 +51160,7 @@ mod root { /// The table `Notification` in the namespace `FBS.Notification` /// /// Generated from these locations: - /// * Table `Notification` in the file `../worker/fbs/notification.fbs:76` + /// * Table `Notification` in the file `../worker/fbs/notification.fbs:78` #[derive( Clone, Debug, @@ -51589,97 +52032,103 @@ mod root { Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub enum Body { - /// The variant of type `FBS.Worker.UpdateSettingsRequest` in the union `Body` - UpdateSettingsRequest( + /// The variant `Worker_UpdateSettingsRequest` in the union `Body` + WorkerUpdateSettingsRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Worker.CreateWebRtcServerRequest` in the union `Body` - CreateWebRtcServerRequest( + /// The variant `Worker_CreateWebRtcServerRequest` in the union `Body` + WorkerCreateWebRtcServerRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Worker.CloseWebRtcServerRequest` in the union `Body` - CloseWebRtcServerRequest( + /// The variant `Worker_CloseWebRtcServerRequest` in the union `Body` + WorkerCloseWebRtcServerRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Worker.CreateRouterRequest` in the union `Body` - CreateRouterRequest( + /// The variant `Worker_CreateRouterRequest` in the union `Body` + WorkerCreateRouterRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Worker.CloseRouterRequest` in the union `Body` - CloseRouterRequest(::planus::alloc::boxed::Box), + /// The variant `Worker_CloseRouterRequest` in the union `Body` + WorkerCloseRouterRequest( + ::planus::alloc::boxed::Box, + ), - /// The variant of type `FBS.Router.CreateWebRtcTransportRequest` in the union `Body` - CreateWebRtcTransportRequest( + /// The variant `Router_CreateWebRtcTransportRequest` in the union `Body` + RouterCreateWebRtcTransportRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Router.CreatePlainTransportRequest` in the union `Body` - CreatePlainTransportRequest( + /// The variant `Router_CreatePlainTransportRequest` in the union `Body` + RouterCreatePlainTransportRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Router.CreatePipeTransportRequest` in the union `Body` - CreatePipeTransportRequest( + /// The variant `Router_CreatePipeTransportRequest` in the union `Body` + RouterCreatePipeTransportRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Router.CreateDirectTransportRequest` in the union `Body` - CreateDirectTransportRequest( + /// The variant `Router_CreateDirectTransportRequest` in the union `Body` + RouterCreateDirectTransportRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Router.CreateActiveSpeakerObserverRequest` in the union `Body` - CreateActiveSpeakerObserverRequest( + /// The variant `Router_CreateActiveSpeakerObserverRequest` in the union `Body` + RouterCreateActiveSpeakerObserverRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Router.CreateAudioLevelObserverRequest` in the union `Body` - CreateAudioLevelObserverRequest( + /// The variant `Router_CreateAudioLevelObserverRequest` in the union `Body` + RouterCreateAudioLevelObserverRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Router.CloseTransportRequest` in the union `Body` - CloseTransportRequest( + /// The variant `Router_CloseTransportRequest` in the union `Body` + RouterCloseTransportRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Router.CloseRtpObserverRequest` in the union `Body` - CloseRtpObserverRequest( + /// The variant `Router_CloseRtpObserverRequest` in the union `Body` + RouterCloseRtpObserverRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Transport.SetMaxIncomingBitrateRequest` in the union `Body` - SetMaxIncomingBitrateRequest( + /// The variant `Transport_SetMaxIncomingBitrateRequest` in the union `Body` + TransportSetMaxIncomingBitrateRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Transport.SetMaxOutgoingBitrateRequest` in the union `Body` - SetMaxOutgoingBitrateRequest( + /// The variant `Transport_SetMaxOutgoingBitrateRequest` in the union `Body` + TransportSetMaxOutgoingBitrateRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Transport.SetMinOutgoingBitrateRequest` in the union `Body` - SetMinOutgoingBitrateRequest( + /// The variant `Transport_SetMinOutgoingBitrateRequest` in the union `Body` + TransportSetMinOutgoingBitrateRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Transport.ProduceRequest` in the union `Body` - ProduceRequest(::planus::alloc::boxed::Box), + /// The variant `Transport_ProduceRequest` in the union `Body` + TransportProduceRequest( + ::planus::alloc::boxed::Box, + ), - /// The variant of type `FBS.Transport.ConsumeRequest` in the union `Body` - ConsumeRequest(::planus::alloc::boxed::Box), + /// The variant `Transport_ConsumeRequest` in the union `Body` + TransportConsumeRequest( + ::planus::alloc::boxed::Box, + ), - /// The variant of type `FBS.Transport.ProduceDataRequest` in the union `Body` - ProduceDataRequest( + /// The variant `Transport_ProduceDataRequest` in the union `Body` + TransportProduceDataRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Transport.ConsumeDataRequest` in the union `Body` - ConsumeDataRequest( + /// The variant `Transport_ConsumeDataRequest` in the union `Body` + TransportConsumeDataRequest( ::planus::alloc::boxed::Box, ), @@ -51688,23 +52137,23 @@ mod root { ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Transport.CloseProducerRequest` in the union `Body` - CloseProducerRequest( + /// The variant `Transport_CloseProducerRequest` in the union `Body` + TransportCloseProducerRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Transport.CloseConsumerRequest` in the union `Body` - CloseConsumerRequest( + /// The variant `Transport_CloseConsumerRequest` in the union `Body` + TransportCloseConsumerRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Transport.CloseDataProducerRequest` in the union `Body` - CloseDataProducerRequest( + /// The variant `Transport_CloseDataProducerRequest` in the union `Body` + TransportCloseDataProducerRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Transport.CloseDataConsumerRequest` in the union `Body` - CloseDataConsumerRequest( + /// The variant `Transport_CloseDataConsumerRequest` in the union `Body` + TransportCloseDataConsumerRequest( ::planus::alloc::boxed::Box, ), @@ -51728,13 +52177,13 @@ mod root { ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Consumer.SetPreferredLayersRequest` in the union `Body` - SetPreferredLayersRequest( + /// The variant `Consumer_SetPreferredLayersRequest` in the union `Body` + ConsumerSetPreferredLayersRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.Consumer.SetPriorityRequest` in the union `Body` - SetPriorityRequest( + /// The variant `Consumer_SetPriorityRequest` in the union `Body` + ConsumerSetPriorityRequest( ::planus::alloc::boxed::Box, ), @@ -51743,28 +52192,30 @@ mod root { ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.DataConsumer.SetBufferedAmountLowThresholdRequest` in the union `Body` - SetBufferedAmountLowThresholdRequest( + /// The variant `DataConsumer_SetBufferedAmountLowThresholdRequest` in the union `Body` + DataConsumerSetBufferedAmountLowThresholdRequest( ::planus::alloc::boxed::Box< super::data_consumer::SetBufferedAmountLowThresholdRequest, >, ), - /// The variant of type `FBS.DataConsumer.SendRequest` in the union `Body` - SendRequest(::planus::alloc::boxed::Box), + /// The variant `DataConsumer_SendRequest` in the union `Body` + DataConsumerSendRequest( + ::planus::alloc::boxed::Box, + ), - /// The variant of type `FBS.DataConsumer.SetSubchannelsRequest` in the union `Body` - SetSubchannelsRequest( + /// The variant `DataConsumer_SetSubchannelsRequest` in the union `Body` + DataConsumerSetSubchannelsRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.RtpObserver.AddProducerRequest` in the union `Body` - AddProducerRequest( + /// The variant `RtpObserver_AddProducerRequest` in the union `Body` + RtpObserverAddProducerRequest( ::planus::alloc::boxed::Box, ), - /// The variant of type `FBS.RtpObserver.RemoveProducerRequest` in the union `Body` - RemoveProducerRequest( + /// The variant `RtpObserver_RemoveProducerRequest` in the union `Body` + RtpObserverRemoveProducerRequest( ::planus::alloc::boxed::Box, ), } @@ -51777,7 +52228,7 @@ mod root { } #[inline] - pub fn create_update_settings_request( + pub fn create_worker_update_settings_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51785,7 +52236,7 @@ mod root { } #[inline] - pub fn create_create_web_rtc_server_request( + pub fn create_worker_create_web_rtc_server_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51793,7 +52244,7 @@ mod root { } #[inline] - pub fn create_close_web_rtc_server_request( + pub fn create_worker_close_web_rtc_server_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51801,7 +52252,7 @@ mod root { } #[inline] - pub fn create_create_router_request( + pub fn create_worker_create_router_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51809,7 +52260,7 @@ mod root { } #[inline] - pub fn create_close_router_request( + pub fn create_worker_close_router_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51817,7 +52268,7 @@ mod root { } #[inline] - pub fn create_create_web_rtc_transport_request( + pub fn create_router_create_web_rtc_transport_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51825,7 +52276,7 @@ mod root { } #[inline] - pub fn create_create_plain_transport_request( + pub fn create_router_create_plain_transport_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51833,7 +52284,7 @@ mod root { } #[inline] - pub fn create_create_pipe_transport_request( + pub fn create_router_create_pipe_transport_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51841,7 +52292,7 @@ mod root { } #[inline] - pub fn create_create_direct_transport_request( + pub fn create_router_create_direct_transport_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51849,7 +52300,7 @@ mod root { } #[inline] - pub fn create_create_active_speaker_observer_request( + pub fn create_router_create_active_speaker_observer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset< super::router::CreateActiveSpeakerObserverRequest, @@ -51859,7 +52310,7 @@ mod root { } #[inline] - pub fn create_create_audio_level_observer_request( + pub fn create_router_create_audio_level_observer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51867,7 +52318,7 @@ mod root { } #[inline] - pub fn create_close_transport_request( + pub fn create_router_close_transport_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51875,7 +52326,7 @@ mod root { } #[inline] - pub fn create_close_rtp_observer_request( + pub fn create_router_close_rtp_observer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51883,7 +52334,7 @@ mod root { } #[inline] - pub fn create_set_max_incoming_bitrate_request( + pub fn create_transport_set_max_incoming_bitrate_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51891,7 +52342,7 @@ mod root { } #[inline] - pub fn create_set_max_outgoing_bitrate_request( + pub fn create_transport_set_max_outgoing_bitrate_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51899,7 +52350,7 @@ mod root { } #[inline] - pub fn create_set_min_outgoing_bitrate_request( + pub fn create_transport_set_min_outgoing_bitrate_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51907,7 +52358,7 @@ mod root { } #[inline] - pub fn create_produce_request( + pub fn create_transport_produce_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51915,7 +52366,7 @@ mod root { } #[inline] - pub fn create_consume_request( + pub fn create_transport_consume_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51923,7 +52374,7 @@ mod root { } #[inline] - pub fn create_produce_data_request( + pub fn create_transport_produce_data_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51931,7 +52382,7 @@ mod root { } #[inline] - pub fn create_consume_data_request( + pub fn create_transport_consume_data_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51947,7 +52398,7 @@ mod root { } #[inline] - pub fn create_close_producer_request( + pub fn create_transport_close_producer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51955,7 +52406,7 @@ mod root { } #[inline] - pub fn create_close_consumer_request( + pub fn create_transport_close_consumer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51963,7 +52414,7 @@ mod root { } #[inline] - pub fn create_close_data_producer_request( + pub fn create_transport_close_data_producer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -51971,7 +52422,7 @@ mod root { } #[inline] - pub fn create_close_data_consumer_request( + pub fn create_transport_close_data_consumer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -52011,7 +52462,7 @@ mod root { } #[inline] - pub fn create_set_preferred_layers_request( + pub fn create_consumer_set_preferred_layers_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -52019,7 +52470,7 @@ mod root { } #[inline] - pub fn create_set_priority_request( + pub fn create_consumer_set_priority_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -52035,7 +52486,7 @@ mod root { } #[inline] - pub fn create_set_buffered_amount_low_threshold_request( + pub fn create_data_consumer_set_buffered_amount_low_threshold_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset< super::data_consumer::SetBufferedAmountLowThresholdRequest, @@ -52045,7 +52496,7 @@ mod root { } #[inline] - pub fn create_send_request( + pub fn create_data_consumer_send_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -52053,7 +52504,7 @@ mod root { } #[inline] - pub fn create_set_subchannels_request( + pub fn create_data_consumer_set_subchannels_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -52061,7 +52512,7 @@ mod root { } #[inline] - pub fn create_add_producer_request( + pub fn create_rtp_observer_add_producer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -52069,7 +52520,7 @@ mod root { } #[inline] - pub fn create_remove_producer_request( + pub fn create_rtp_observer_remove_producer_request( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -52081,76 +52532,82 @@ mod root { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { match self { - Self::UpdateSettingsRequest(value) => { - Self::create_update_settings_request(builder, value) + 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::CreateWebRtcServerRequest(value) => { - Self::create_create_web_rtc_server_request(builder, value) + Self::WorkerCloseWebRtcServerRequest(value) => { + Self::create_worker_close_web_rtc_server_request(builder, value) } - Self::CloseWebRtcServerRequest(value) => { - Self::create_close_web_rtc_server_request(builder, value) + Self::WorkerCreateRouterRequest(value) => { + Self::create_worker_create_router_request(builder, value) } - Self::CreateRouterRequest(value) => { - Self::create_create_router_request(builder, value) + Self::WorkerCloseRouterRequest(value) => { + Self::create_worker_close_router_request(builder, value) } - Self::CloseRouterRequest(value) => { - Self::create_close_router_request(builder, value) + Self::RouterCreateWebRtcTransportRequest(value) => { + Self::create_router_create_web_rtc_transport_request(builder, value) } - Self::CreateWebRtcTransportRequest(value) => { - Self::create_create_web_rtc_transport_request(builder, value) + Self::RouterCreatePlainTransportRequest(value) => { + Self::create_router_create_plain_transport_request(builder, value) } - Self::CreatePlainTransportRequest(value) => { - Self::create_create_plain_transport_request(builder, value) + Self::RouterCreatePipeTransportRequest(value) => { + Self::create_router_create_pipe_transport_request(builder, value) } - Self::CreatePipeTransportRequest(value) => { - Self::create_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::CreateDirectTransportRequest(value) => { - Self::create_create_direct_transport_request(builder, value) + Self::RouterCreateAudioLevelObserverRequest(value) => { + Self::create_router_create_audio_level_observer_request(builder, value) } - Self::CreateActiveSpeakerObserverRequest(value) => { - Self::create_create_active_speaker_observer_request(builder, value) + Self::RouterCloseTransportRequest(value) => { + Self::create_router_close_transport_request(builder, value) } - Self::CreateAudioLevelObserverRequest(value) => { - Self::create_create_audio_level_observer_request(builder, value) + Self::RouterCloseRtpObserverRequest(value) => { + Self::create_router_close_rtp_observer_request(builder, value) } - Self::CloseTransportRequest(value) => { - Self::create_close_transport_request(builder, value) + Self::TransportSetMaxIncomingBitrateRequest(value) => { + Self::create_transport_set_max_incoming_bitrate_request(builder, value) } - Self::CloseRtpObserverRequest(value) => { - Self::create_close_rtp_observer_request(builder, value) + Self::TransportSetMaxOutgoingBitrateRequest(value) => { + Self::create_transport_set_max_outgoing_bitrate_request(builder, value) } - Self::SetMaxIncomingBitrateRequest(value) => { - Self::create_set_max_incoming_bitrate_request(builder, value) + Self::TransportSetMinOutgoingBitrateRequest(value) => { + Self::create_transport_set_min_outgoing_bitrate_request(builder, value) } - Self::SetMaxOutgoingBitrateRequest(value) => { - Self::create_set_max_outgoing_bitrate_request(builder, value) + Self::TransportProduceRequest(value) => { + Self::create_transport_produce_request(builder, value) } - Self::SetMinOutgoingBitrateRequest(value) => { - Self::create_set_min_outgoing_bitrate_request(builder, value) + Self::TransportConsumeRequest(value) => { + Self::create_transport_consume_request(builder, value) } - Self::ProduceRequest(value) => Self::create_produce_request(builder, value), - Self::ConsumeRequest(value) => Self::create_consume_request(builder, value), - Self::ProduceDataRequest(value) => { - Self::create_produce_data_request(builder, value) + Self::TransportProduceDataRequest(value) => { + Self::create_transport_produce_data_request(builder, value) } - Self::ConsumeDataRequest(value) => { - Self::create_consume_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::CloseProducerRequest(value) => { - Self::create_close_producer_request(builder, value) + Self::TransportCloseProducerRequest(value) => { + Self::create_transport_close_producer_request(builder, value) } - Self::CloseConsumerRequest(value) => { - Self::create_close_consumer_request(builder, value) + Self::TransportCloseConsumerRequest(value) => { + Self::create_transport_close_consumer_request(builder, value) } - Self::CloseDataProducerRequest(value) => { - Self::create_close_data_producer_request(builder, value) + Self::TransportCloseDataProducerRequest(value) => { + Self::create_transport_close_data_producer_request(builder, value) } - Self::CloseDataConsumerRequest(value) => { - Self::create_close_data_consumer_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) @@ -52164,27 +52621,31 @@ mod root { Self::ProducerEnableTraceEventRequest(value) => { Self::create_producer_enable_trace_event_request(builder, value) } - Self::SetPreferredLayersRequest(value) => { - Self::create_set_preferred_layers_request(builder, value) + Self::ConsumerSetPreferredLayersRequest(value) => { + Self::create_consumer_set_preferred_layers_request(builder, value) } - Self::SetPriorityRequest(value) => { - Self::create_set_priority_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::SetBufferedAmountLowThresholdRequest(value) => { - Self::create_set_buffered_amount_low_threshold_request(builder, value) + Self::DataConsumerSetBufferedAmountLowThresholdRequest(value) => { + Self::create_data_consumer_set_buffered_amount_low_threshold_request( + builder, value, + ) } - Self::SendRequest(value) => Self::create_send_request(builder, value), - Self::SetSubchannelsRequest(value) => { - Self::create_set_subchannels_request(builder, value) + Self::DataConsumerSendRequest(value) => { + Self::create_data_consumer_send_request(builder, value) } - Self::AddProducerRequest(value) => { - Self::create_add_producer_request(builder, value) + Self::DataConsumerSetSubchannelsRequest(value) => { + Self::create_data_consumer_set_subchannels_request(builder, value) } - Self::RemoveProducerRequest(value) => { - Self::create_remove_producer_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) } } } @@ -52208,9 +52669,9 @@ mod root { pub struct BodyBuilder(T); impl BodyBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`UpdateSettingsRequest` variant](Body#variant.UpdateSettingsRequest). + /// Creates an instance of the [`Worker_UpdateSettingsRequest` variant](Body#variant.WorkerUpdateSettingsRequest). #[inline] - pub fn update_settings_request( + pub fn worker_update_settings_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<1, T>> @@ -52220,9 +52681,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`CreateWebRtcServerRequest` variant](Body#variant.CreateWebRtcServerRequest). + /// Creates an instance of the [`Worker_CreateWebRtcServerRequest` variant](Body#variant.WorkerCreateWebRtcServerRequest). #[inline] - pub fn create_web_rtc_server_request( + pub fn worker_create_web_rtc_server_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<2, T>> @@ -52232,9 +52693,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`CloseWebRtcServerRequest` variant](Body#variant.CloseWebRtcServerRequest). + /// Creates an instance of the [`Worker_CloseWebRtcServerRequest` variant](Body#variant.WorkerCloseWebRtcServerRequest). #[inline] - pub fn close_web_rtc_server_request( + pub fn worker_close_web_rtc_server_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<3, T>> @@ -52244,9 +52705,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`CreateRouterRequest` variant](Body#variant.CreateRouterRequest). + /// Creates an instance of the [`Worker_CreateRouterRequest` variant](Body#variant.WorkerCreateRouterRequest). #[inline] - pub fn create_router_request( + pub fn worker_create_router_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<4, T>> @@ -52256,9 +52717,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`CloseRouterRequest` variant](Body#variant.CloseRouterRequest). + /// Creates an instance of the [`Worker_CloseRouterRequest` variant](Body#variant.WorkerCloseRouterRequest). #[inline] - pub fn close_router_request( + pub fn worker_close_router_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<5, T>> @@ -52268,9 +52729,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`CreateWebRtcTransportRequest` variant](Body#variant.CreateWebRtcTransportRequest). + /// Creates an instance of the [`Router_CreateWebRtcTransportRequest` variant](Body#variant.RouterCreateWebRtcTransportRequest). #[inline] - pub fn create_web_rtc_transport_request( + pub fn router_create_web_rtc_transport_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<6, T>> @@ -52280,9 +52741,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`CreatePlainTransportRequest` variant](Body#variant.CreatePlainTransportRequest). + /// Creates an instance of the [`Router_CreatePlainTransportRequest` variant](Body#variant.RouterCreatePlainTransportRequest). #[inline] - pub fn create_plain_transport_request( + pub fn router_create_plain_transport_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<7, T>> @@ -52292,9 +52753,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`CreatePipeTransportRequest` variant](Body#variant.CreatePipeTransportRequest). + /// Creates an instance of the [`Router_CreatePipeTransportRequest` variant](Body#variant.RouterCreatePipeTransportRequest). #[inline] - pub fn create_pipe_transport_request( + pub fn router_create_pipe_transport_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<8, T>> @@ -52304,9 +52765,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`CreateDirectTransportRequest` variant](Body#variant.CreateDirectTransportRequest). + /// Creates an instance of the [`Router_CreateDirectTransportRequest` variant](Body#variant.RouterCreateDirectTransportRequest). #[inline] - pub fn create_direct_transport_request( + pub fn router_create_direct_transport_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<9, T>> @@ -52316,9 +52777,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`CreateActiveSpeakerObserverRequest` variant](Body#variant.CreateActiveSpeakerObserverRequest). + /// Creates an instance of the [`Router_CreateActiveSpeakerObserverRequest` variant](Body#variant.RouterCreateActiveSpeakerObserverRequest). #[inline] - pub fn create_active_speaker_observer_request( + pub fn router_create_active_speaker_observer_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<10, T>> @@ -52328,9 +52789,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`CreateAudioLevelObserverRequest` variant](Body#variant.CreateAudioLevelObserverRequest). + /// Creates an instance of the [`Router_CreateAudioLevelObserverRequest` variant](Body#variant.RouterCreateAudioLevelObserverRequest). #[inline] - pub fn create_audio_level_observer_request( + pub fn router_create_audio_level_observer_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<11, T>> @@ -52340,9 +52801,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`CloseTransportRequest` variant](Body#variant.CloseTransportRequest). + /// Creates an instance of the [`Router_CloseTransportRequest` variant](Body#variant.RouterCloseTransportRequest). #[inline] - pub fn close_transport_request( + pub fn router_close_transport_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<12, T>> @@ -52352,9 +52813,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`CloseRtpObserverRequest` variant](Body#variant.CloseRtpObserverRequest). + /// Creates an instance of the [`Router_CloseRtpObserverRequest` variant](Body#variant.RouterCloseRtpObserverRequest). #[inline] - pub fn close_rtp_observer_request( + pub fn router_close_rtp_observer_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<13, T>> @@ -52364,9 +52825,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`SetMaxIncomingBitrateRequest` variant](Body#variant.SetMaxIncomingBitrateRequest). + /// Creates an instance of the [`Transport_SetMaxIncomingBitrateRequest` variant](Body#variant.TransportSetMaxIncomingBitrateRequest). #[inline] - pub fn set_max_incoming_bitrate_request( + pub fn transport_set_max_incoming_bitrate_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<14, T>> @@ -52376,9 +52837,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`SetMaxOutgoingBitrateRequest` variant](Body#variant.SetMaxOutgoingBitrateRequest). + /// Creates an instance of the [`Transport_SetMaxOutgoingBitrateRequest` variant](Body#variant.TransportSetMaxOutgoingBitrateRequest). #[inline] - pub fn set_max_outgoing_bitrate_request( + pub fn transport_set_max_outgoing_bitrate_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<15, T>> @@ -52388,9 +52849,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`SetMinOutgoingBitrateRequest` variant](Body#variant.SetMinOutgoingBitrateRequest). + /// Creates an instance of the [`Transport_SetMinOutgoingBitrateRequest` variant](Body#variant.TransportSetMinOutgoingBitrateRequest). #[inline] - pub fn set_min_outgoing_bitrate_request( + pub fn transport_set_min_outgoing_bitrate_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<16, T>> @@ -52400,9 +52861,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`ProduceRequest` variant](Body#variant.ProduceRequest). + /// Creates an instance of the [`Transport_ProduceRequest` variant](Body#variant.TransportProduceRequest). #[inline] - pub fn produce_request( + pub fn transport_produce_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<17, T>> @@ -52412,9 +52873,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`ConsumeRequest` variant](Body#variant.ConsumeRequest). + /// Creates an instance of the [`Transport_ConsumeRequest` variant](Body#variant.TransportConsumeRequest). #[inline] - pub fn consume_request( + pub fn transport_consume_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<18, T>> @@ -52424,9 +52885,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`ProduceDataRequest` variant](Body#variant.ProduceDataRequest). + /// Creates an instance of the [`Transport_ProduceDataRequest` variant](Body#variant.TransportProduceDataRequest). #[inline] - pub fn produce_data_request( + pub fn transport_produce_data_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<19, T>> @@ -52436,9 +52897,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`ConsumeDataRequest` variant](Body#variant.ConsumeDataRequest). + /// Creates an instance of the [`Transport_ConsumeDataRequest` variant](Body#variant.TransportConsumeDataRequest). #[inline] - pub fn consume_data_request( + pub fn transport_consume_data_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<20, T>> @@ -52460,9 +52921,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`CloseProducerRequest` variant](Body#variant.CloseProducerRequest). + /// Creates an instance of the [`Transport_CloseProducerRequest` variant](Body#variant.TransportCloseProducerRequest). #[inline] - pub fn close_producer_request( + pub fn transport_close_producer_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<22, T>> @@ -52472,9 +52933,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`CloseConsumerRequest` variant](Body#variant.CloseConsumerRequest). + /// Creates an instance of the [`Transport_CloseConsumerRequest` variant](Body#variant.TransportCloseConsumerRequest). #[inline] - pub fn close_consumer_request( + pub fn transport_close_consumer_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<23, T>> @@ -52484,9 +52945,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`CloseDataProducerRequest` variant](Body#variant.CloseDataProducerRequest). + /// Creates an instance of the [`Transport_CloseDataProducerRequest` variant](Body#variant.TransportCloseDataProducerRequest). #[inline] - pub fn close_data_producer_request( + pub fn transport_close_data_producer_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<24, T>> @@ -52496,9 +52957,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`CloseDataConsumerRequest` variant](Body#variant.CloseDataConsumerRequest). + /// Creates an instance of the [`Transport_CloseDataConsumerRequest` variant](Body#variant.TransportCloseDataConsumerRequest). #[inline] - pub fn close_data_consumer_request( + pub fn transport_close_data_consumer_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<25, T>> @@ -52556,9 +53017,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`SetPreferredLayersRequest` variant](Body#variant.SetPreferredLayersRequest). + /// Creates an instance of the [`Consumer_SetPreferredLayersRequest` variant](Body#variant.ConsumerSetPreferredLayersRequest). #[inline] - pub fn set_preferred_layers_request( + pub fn consumer_set_preferred_layers_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<30, T>> @@ -52568,9 +53029,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`SetPriorityRequest` variant](Body#variant.SetPriorityRequest). + /// Creates an instance of the [`Consumer_SetPriorityRequest` variant](Body#variant.ConsumerSetPriorityRequest). #[inline] - pub fn set_priority_request( + pub fn consumer_set_priority_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<31, T>> @@ -52592,9 +53053,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`SetBufferedAmountLowThresholdRequest` variant](Body#variant.SetBufferedAmountLowThresholdRequest). + /// Creates an instance of the [`DataConsumer_SetBufferedAmountLowThresholdRequest` variant](Body#variant.DataConsumerSetBufferedAmountLowThresholdRequest). #[inline] - pub fn set_buffered_amount_low_threshold_request( + pub fn data_consumer_set_buffered_amount_low_threshold_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<33, T>> @@ -52606,18 +53067,21 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`SendRequest` variant](Body#variant.SendRequest). + /// Creates an instance of the [`DataConsumer_SendRequest` variant](Body#variant.DataConsumerSendRequest). #[inline] - pub fn send_request(self, value: T) -> BodyBuilder<::planus::Initialized<34, T>> + 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 [`SetSubchannelsRequest` variant](Body#variant.SetSubchannelsRequest). + /// Creates an instance of the [`DataConsumer_SetSubchannelsRequest` variant](Body#variant.DataConsumerSetSubchannelsRequest). #[inline] - pub fn set_subchannels_request( + pub fn data_consumer_set_subchannels_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<35, T>> @@ -52627,9 +53091,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`AddProducerRequest` variant](Body#variant.AddProducerRequest). + /// Creates an instance of the [`RtpObserver_AddProducerRequest` variant](Body#variant.RtpObserverAddProducerRequest). #[inline] - pub fn add_producer_request( + pub fn rtp_observer_add_producer_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<36, T>> @@ -52639,9 +53103,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`RemoveProducerRequest` variant](Body#variant.RemoveProducerRequest). + /// Creates an instance of the [`RtpObserver_RemoveProducerRequest` variant](Body#variant.RtpObserverRemoveProducerRequest). #[inline] - pub fn remove_producer_request( + pub fn rtp_observer_remove_producer_request( self, value: T, ) -> BodyBuilder<::planus::Initialized<37, T>> @@ -53485,49 +53949,69 @@ mod root { /// Reference to a deserialized [Body]. #[derive(Copy, Clone, Debug)] pub enum BodyRef<'a> { - UpdateSettingsRequest(super::worker::UpdateSettingsRequestRef<'a>), - CreateWebRtcServerRequest(super::worker::CreateWebRtcServerRequestRef<'a>), - CloseWebRtcServerRequest(super::worker::CloseWebRtcServerRequestRef<'a>), - CreateRouterRequest(super::worker::CreateRouterRequestRef<'a>), - CloseRouterRequest(super::worker::CloseRouterRequestRef<'a>), - CreateWebRtcTransportRequest(super::router::CreateWebRtcTransportRequestRef<'a>), - CreatePlainTransportRequest(super::router::CreatePlainTransportRequestRef<'a>), - CreatePipeTransportRequest(super::router::CreatePipeTransportRequestRef<'a>), - CreateDirectTransportRequest(super::router::CreateDirectTransportRequestRef<'a>), - CreateActiveSpeakerObserverRequest( + 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>, ), - CreateAudioLevelObserverRequest( + RouterCreateAudioLevelObserverRequest( super::router::CreateAudioLevelObserverRequestRef<'a>, ), - CloseTransportRequest(super::router::CloseTransportRequestRef<'a>), - CloseRtpObserverRequest(super::router::CloseRtpObserverRequestRef<'a>), - SetMaxIncomingBitrateRequest(super::transport::SetMaxIncomingBitrateRequestRef<'a>), - SetMaxOutgoingBitrateRequest(super::transport::SetMaxOutgoingBitrateRequestRef<'a>), - SetMinOutgoingBitrateRequest(super::transport::SetMinOutgoingBitrateRequestRef<'a>), - ProduceRequest(super::transport::ProduceRequestRef<'a>), - ConsumeRequest(super::transport::ConsumeRequestRef<'a>), - ProduceDataRequest(super::transport::ProduceDataRequestRef<'a>), - ConsumeDataRequest(super::transport::ConsumeDataRequestRef<'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>), - CloseProducerRequest(super::transport::CloseProducerRequestRef<'a>), - CloseConsumerRequest(super::transport::CloseConsumerRequestRef<'a>), - CloseDataProducerRequest(super::transport::CloseDataProducerRequestRef<'a>), - CloseDataConsumerRequest(super::transport::CloseDataConsumerRequestRef<'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>), - SetPreferredLayersRequest(super::consumer::SetPreferredLayersRequestRef<'a>), - SetPriorityRequest(super::consumer::SetPriorityRequestRef<'a>), + ConsumerSetPreferredLayersRequest( + super::consumer::SetPreferredLayersRequestRef<'a>, + ), + ConsumerSetPriorityRequest(super::consumer::SetPriorityRequestRef<'a>), ConsumerEnableTraceEventRequest(super::consumer::EnableTraceEventRequestRef<'a>), - SetBufferedAmountLowThresholdRequest( + DataConsumerSetBufferedAmountLowThresholdRequest( super::data_consumer::SetBufferedAmountLowThresholdRequestRef<'a>, ), - SendRequest(super::data_consumer::SendRequestRef<'a>), - SetSubchannelsRequest(super::data_consumer::SetSubchannelsRequestRef<'a>), - AddProducerRequest(super::rtp_observer::AddProducerRequestRef<'a>), - RemoveProducerRequest(super::rtp_observer::RemoveProducerRequestRef<'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 { @@ -53535,124 +54019,140 @@ mod root { fn try_from(value: BodyRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(match value { - BodyRef::UpdateSettingsRequest(value) => { - Self::UpdateSettingsRequest(::planus::alloc::boxed::Box::new( + BodyRef::WorkerUpdateSettingsRequest(value) => { + Self::WorkerUpdateSettingsRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::CreateWebRtcServerRequest(value) => { - Self::CreateWebRtcServerRequest(::planus::alloc::boxed::Box::new( + BodyRef::WorkerCreateWebRtcServerRequest(value) => { + Self::WorkerCreateWebRtcServerRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::CloseWebRtcServerRequest(value) => { - Self::CloseWebRtcServerRequest(::planus::alloc::boxed::Box::new( + BodyRef::WorkerCloseWebRtcServerRequest(value) => { + Self::WorkerCloseWebRtcServerRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::CreateRouterRequest(value) => { - Self::CreateRouterRequest(::planus::alloc::boxed::Box::new( + BodyRef::WorkerCreateRouterRequest(value) => { + Self::WorkerCreateRouterRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::CloseRouterRequest(value) => { - Self::CloseRouterRequest(::planus::alloc::boxed::Box::new( + BodyRef::WorkerCloseRouterRequest(value) => { + Self::WorkerCloseRouterRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::CreateWebRtcTransportRequest(value) => { - Self::CreateWebRtcTransportRequest(::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::CreatePlainTransportRequest(value) => { - Self::CreatePlainTransportRequest(::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::CreatePipeTransportRequest(value) => { - Self::CreatePipeTransportRequest(::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::CreateDirectTransportRequest(value) => { - Self::CreateDirectTransportRequest(::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::CreateActiveSpeakerObserverRequest(value) => { - Self::CreateActiveSpeakerObserverRequest( + BodyRef::RouterCreateActiveSpeakerObserverRequest(value) => { + Self::RouterCreateActiveSpeakerObserverRequest( ::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, ), ) } - BodyRef::CreateAudioLevelObserverRequest(value) => { - Self::CreateAudioLevelObserverRequest(::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::CloseTransportRequest(value) => { - Self::CloseTransportRequest(::planus::alloc::boxed::Box::new( + BodyRef::RouterCloseTransportRequest(value) => { + Self::RouterCloseTransportRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::CloseRtpObserverRequest(value) => { - Self::CloseRtpObserverRequest(::planus::alloc::boxed::Box::new( + BodyRef::RouterCloseRtpObserverRequest(value) => { + Self::RouterCloseRtpObserverRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::SetMaxIncomingBitrateRequest(value) => { - Self::SetMaxIncomingBitrateRequest(::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::SetMaxOutgoingBitrateRequest(value) => { - Self::SetMaxOutgoingBitrateRequest(::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::SetMinOutgoingBitrateRequest(value) => { - Self::SetMinOutgoingBitrateRequest(::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::ProduceRequest(value) => { - Self::ProduceRequest(::planus::alloc::boxed::Box::new( + BodyRef::TransportProduceRequest(value) => { + Self::TransportProduceRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::ConsumeRequest(value) => { - Self::ConsumeRequest(::planus::alloc::boxed::Box::new( + BodyRef::TransportConsumeRequest(value) => { + Self::TransportConsumeRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::ProduceDataRequest(value) => { - Self::ProduceDataRequest(::planus::alloc::boxed::Box::new( + BodyRef::TransportProduceDataRequest(value) => { + Self::TransportProduceDataRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::ConsumeDataRequest(value) => { - Self::ConsumeDataRequest(::planus::alloc::boxed::Box::new( + BodyRef::TransportConsumeDataRequest(value) => { + Self::TransportConsumeDataRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -53665,28 +54165,32 @@ mod root { ) } - BodyRef::CloseProducerRequest(value) => { - Self::CloseProducerRequest(::planus::alloc::boxed::Box::new( + BodyRef::TransportCloseProducerRequest(value) => { + Self::TransportCloseProducerRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::CloseConsumerRequest(value) => { - Self::CloseConsumerRequest(::planus::alloc::boxed::Box::new( + BodyRef::TransportCloseConsumerRequest(value) => { + Self::TransportCloseConsumerRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::CloseDataProducerRequest(value) => { - Self::CloseDataProducerRequest(::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::CloseDataConsumerRequest(value) => { - Self::CloseDataConsumerRequest(::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) => { @@ -53713,14 +54217,16 @@ mod root { )) } - BodyRef::SetPreferredLayersRequest(value) => { - Self::SetPreferredLayersRequest(::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::SetPriorityRequest(value) => { - Self::SetPriorityRequest(::planus::alloc::boxed::Box::new( + BodyRef::ConsumerSetPriorityRequest(value) => { + Self::ConsumerSetPriorityRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } @@ -53731,36 +54237,40 @@ mod root { )) } - BodyRef::SetBufferedAmountLowThresholdRequest(value) => { - Self::SetBufferedAmountLowThresholdRequest( + BodyRef::DataConsumerSetBufferedAmountLowThresholdRequest(value) => { + Self::DataConsumerSetBufferedAmountLowThresholdRequest( ::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, ), ) } - BodyRef::SendRequest(value) => { - Self::SendRequest(::planus::alloc::boxed::Box::new( + BodyRef::DataConsumerSendRequest(value) => { + Self::DataConsumerSendRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::SetSubchannelsRequest(value) => { - Self::SetSubchannelsRequest(::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::AddProducerRequest(value) => { - Self::AddProducerRequest(::planus::alloc::boxed::Box::new( + BodyRef::RtpObserverAddProducerRequest(value) => { + Self::RtpObserverAddProducerRequest(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::RemoveProducerRequest(value) => { - Self::RemoveProducerRequest(::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)?, + ), + ) } }) } @@ -53773,79 +54283,89 @@ mod root { tag: u8, ) -> ::core::result::Result { match tag { - 1 => ::core::result::Result::Ok(Self::UpdateSettingsRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::CreateWebRtcServerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 3 => ::core::result::Result::Ok(Self::CloseWebRtcServerRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 4 => ::core::result::Result::Ok(Self::CreateRouterRequest( + 1 => ::core::result::Result::Ok(Self::WorkerUpdateSettingsRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 5 => ::core::result::Result::Ok(Self::CloseRouterRequest( + 2 => ::core::result::Result::Ok(Self::WorkerCreateWebRtcServerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 6 => ::core::result::Result::Ok(Self::CreateWebRtcTransportRequest( + 3 => ::core::result::Result::Ok(Self::WorkerCloseWebRtcServerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 7 => ::core::result::Result::Ok(Self::CreatePlainTransportRequest( + 4 => ::core::result::Result::Ok(Self::WorkerCreateRouterRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 8 => ::core::result::Result::Ok(Self::CreatePipeTransportRequest( + 5 => ::core::result::Result::Ok(Self::WorkerCloseRouterRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 9 => ::core::result::Result::Ok(Self::CreateDirectTransportRequest( + 6 => ::core::result::Result::Ok(Self::RouterCreateWebRtcTransportRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 10 => ::core::result::Result::Ok(Self::CreateActiveSpeakerObserverRequest( + 7 => ::core::result::Result::Ok(Self::RouterCreatePlainTransportRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 11 => ::core::result::Result::Ok(Self::CreateAudioLevelObserverRequest( + 8 => ::core::result::Result::Ok(Self::RouterCreatePipeTransportRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 12 => ::core::result::Result::Ok(Self::CloseTransportRequest( + 9 => ::core::result::Result::Ok(Self::RouterCreateDirectTransportRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 13 => ::core::result::Result::Ok(Self::CloseRtpObserverRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 14 => ::core::result::Result::Ok(Self::SetMaxIncomingBitrateRequest( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 15 => ::core::result::Result::Ok(Self::SetMaxOutgoingBitrateRequest( + 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)?, )), - 16 => ::core::result::Result::Ok(Self::SetMinOutgoingBitrateRequest( + 13 => ::core::result::Result::Ok(Self::RouterCloseRtpObserverRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 17 => ::core::result::Result::Ok(Self::ProduceRequest( + 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::ConsumeRequest( + 18 => ::core::result::Result::Ok(Self::TransportConsumeRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 19 => ::core::result::Result::Ok(Self::ProduceDataRequest( + 19 => ::core::result::Result::Ok(Self::TransportProduceDataRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 20 => ::core::result::Result::Ok(Self::ConsumeDataRequest( + 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::CloseProducerRequest( + 22 => ::core::result::Result::Ok(Self::TransportCloseProducerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 23 => ::core::result::Result::Ok(Self::CloseConsumerRequest( + 23 => ::core::result::Result::Ok(Self::TransportCloseConsumerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 24 => ::core::result::Result::Ok(Self::CloseDataProducerRequest( + 24 => ::core::result::Result::Ok(Self::TransportCloseDataProducerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 25 => ::core::result::Result::Ok(Self::CloseDataConsumerRequest( + 25 => ::core::result::Result::Ok(Self::TransportCloseDataConsumerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), 26 => ::core::result::Result::Ok(Self::PlainTransportConnectRequest( @@ -53860,30 +54380,30 @@ mod root { 29 => ::core::result::Result::Ok(Self::ProducerEnableTraceEventRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 30 => ::core::result::Result::Ok(Self::SetPreferredLayersRequest( + 30 => ::core::result::Result::Ok(Self::ConsumerSetPreferredLayersRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 31 => ::core::result::Result::Ok(Self::SetPriorityRequest( + 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::SetBufferedAmountLowThresholdRequest( + 33 => ::core::result::Result::Ok( + Self::DataConsumerSetBufferedAmountLowThresholdRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, - )) - } - 34 => ::core::result::Result::Ok(Self::SendRequest( + ), + ), + 34 => ::core::result::Result::Ok(Self::DataConsumerSendRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 35 => ::core::result::Result::Ok(Self::SetSubchannelsRequest( + 35 => ::core::result::Result::Ok(Self::DataConsumerSetSubchannelsRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 36 => ::core::result::Result::Ok(Self::AddProducerRequest( + 36 => ::core::result::Result::Ok(Self::RtpObserverAddProducerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 37 => ::core::result::Result::Ok(Self::RemoveProducerRequest( + 37 => ::core::result::Result::Ok(Self::RtpObserverRemoveProducerRequest( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), _ => ::core::result::Result::Err( @@ -54283,145 +54803,145 @@ mod root { Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub enum Body { - /// The variant `FBS_Worker_DumpResponse` in the union `Body` - FbsWorkerDumpResponse(::planus::alloc::boxed::Box), + /// The variant `Worker_DumpResponse` in the union `Body` + WorkerDumpResponse(::planus::alloc::boxed::Box), - /// The variant `FBS_Worker_ResourceUsageResponse` in the union `Body` - FbsWorkerResourceUsageResponse( + /// The variant `Worker_ResourceUsageResponse` in the union `Body` + WorkerResourceUsageResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_WebRtcServer_DumpResponse` in the union `Body` - FbsWebRtcServerDumpResponse( + /// The variant `WebRtcServer_DumpResponse` in the union `Body` + WebRtcServerDumpResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_Router_DumpResponse` in the union `Body` - FbsRouterDumpResponse(::planus::alloc::boxed::Box), + /// The variant `Router_DumpResponse` in the union `Body` + RouterDumpResponse(::planus::alloc::boxed::Box), - /// The variant `FBS_Transport_ProduceResponse` in the union `Body` - FbsTransportProduceResponse( + /// The variant `Transport_ProduceResponse` in the union `Body` + TransportProduceResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_Transport_ConsumeResponse` in the union `Body` - FbsTransportConsumeResponse( + /// The variant `Transport_ConsumeResponse` in the union `Body` + TransportConsumeResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_Transport_RestartIceResponse` in the union `Body` - FbsTransportRestartIceResponse( + /// The variant `Transport_RestartIceResponse` in the union `Body` + TransportRestartIceResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_PlainTransport_ConnectResponse` in the union `Body` - FbsPlainTransportConnectResponse( + /// The variant `PlainTransport_ConnectResponse` in the union `Body` + PlainTransportConnectResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_PlainTransport_DumpResponse` in the union `Body` - FbsPlainTransportDumpResponse( + /// The variant `PlainTransport_DumpResponse` in the union `Body` + PlainTransportDumpResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_PlainTransport_GetStatsResponse` in the union `Body` - FbsPlainTransportGetStatsResponse( + /// The variant `PlainTransport_GetStatsResponse` in the union `Body` + PlainTransportGetStatsResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_PipeTransport_ConnectResponse` in the union `Body` - FbsPipeTransportConnectResponse( + /// The variant `PipeTransport_ConnectResponse` in the union `Body` + PipeTransportConnectResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_PipeTransport_DumpResponse` in the union `Body` - FbsPipeTransportDumpResponse( + /// The variant `PipeTransport_DumpResponse` in the union `Body` + PipeTransportDumpResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_PipeTransport_GetStatsResponse` in the union `Body` - FbsPipeTransportGetStatsResponse( + /// The variant `PipeTransport_GetStatsResponse` in the union `Body` + PipeTransportGetStatsResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_DirectTransport_DumpResponse` in the union `Body` - FbsDirectTransportDumpResponse( + /// The variant `DirectTransport_DumpResponse` in the union `Body` + DirectTransportDumpResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_DirectTransport_GetStatsResponse` in the union `Body` - FbsDirectTransportGetStatsResponse( + /// The variant `DirectTransport_GetStatsResponse` in the union `Body` + DirectTransportGetStatsResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_WebRtcTransport_ConnectResponse` in the union `Body` - FbsWebRtcTransportConnectResponse( + /// The variant `WebRtcTransport_ConnectResponse` in the union `Body` + WebRtcTransportConnectResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_WebRtcTransport_DumpResponse` in the union `Body` - FbsWebRtcTransportDumpResponse( + /// The variant `WebRtcTransport_DumpResponse` in the union `Body` + WebRtcTransportDumpResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_WebRtcTransport_GetStatsResponse` in the union `Body` - FbsWebRtcTransportGetStatsResponse( + /// The variant `WebRtcTransport_GetStatsResponse` in the union `Body` + WebRtcTransportGetStatsResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_Producer_DumpResponse` in the union `Body` - FbsProducerDumpResponse(::planus::alloc::boxed::Box), + /// The variant `Producer_DumpResponse` in the union `Body` + ProducerDumpResponse(::planus::alloc::boxed::Box), - /// The variant `FBS_Producer_GetStatsResponse` in the union `Body` - FbsProducerGetStatsResponse( + /// The variant `Producer_GetStatsResponse` in the union `Body` + ProducerGetStatsResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_Consumer_DumpResponse` in the union `Body` - FbsConsumerDumpResponse(::planus::alloc::boxed::Box), + /// The variant `Consumer_DumpResponse` in the union `Body` + ConsumerDumpResponse(::planus::alloc::boxed::Box), - /// The variant `FBS_Consumer_GetStatsResponse` in the union `Body` - FbsConsumerGetStatsResponse( + /// The variant `Consumer_GetStatsResponse` in the union `Body` + ConsumerGetStatsResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_Consumer_SetPreferredLayersResponse` in the union `Body` - FbsConsumerSetPreferredLayersResponse( + /// The variant `Consumer_SetPreferredLayersResponse` in the union `Body` + ConsumerSetPreferredLayersResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_Consumer_SetPriorityResponse` in the union `Body` - FbsConsumerSetPriorityResponse( + /// The variant `Consumer_SetPriorityResponse` in the union `Body` + ConsumerSetPriorityResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_DataProducer_DumpResponse` in the union `Body` - FbsDataProducerDumpResponse( + /// The variant `DataProducer_DumpResponse` in the union `Body` + DataProducerDumpResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_DataProducer_GetStatsResponse` in the union `Body` - FbsDataProducerGetStatsResponse( + /// The variant `DataProducer_GetStatsResponse` in the union `Body` + DataProducerGetStatsResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_DataConsumer_GetBufferedAmountResponse` in the union `Body` - FbsDataConsumerGetBufferedAmountResponse( + /// The variant `DataConsumer_GetBufferedAmountResponse` in the union `Body` + DataConsumerGetBufferedAmountResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_DataConsumer_DumpResponse` in the union `Body` - FbsDataConsumerDumpResponse( + /// The variant `DataConsumer_DumpResponse` in the union `Body` + DataConsumerDumpResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_DataConsumer_GetStatsResponse` in the union `Body` - FbsDataConsumerGetStatsResponse( + /// The variant `DataConsumer_GetStatsResponse` in the union `Body` + DataConsumerGetStatsResponse( ::planus::alloc::boxed::Box, ), - /// The variant `FBS_DataConsumer_SetSubchannelsResponse` in the union `Body` - FbsDataConsumerSetSubchannelsResponse( + /// The variant `DataConsumer_SetSubchannelsResponse` in the union `Body` + DataConsumerSetSubchannelsResponse( ::planus::alloc::boxed::Box, ), } @@ -54434,7 +54954,7 @@ mod root { } #[inline] - pub fn create_fbs_worker_dump_response( + pub fn create_worker_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54442,7 +54962,7 @@ mod root { } #[inline] - pub fn create_fbs_worker_resource_usage_response( + pub fn create_worker_resource_usage_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54450,7 +54970,7 @@ mod root { } #[inline] - pub fn create_fbs_web_rtc_server_dump_response( + pub fn create_web_rtc_server_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54458,7 +54978,7 @@ mod root { } #[inline] - pub fn create_fbs_router_dump_response( + pub fn create_router_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54466,7 +54986,7 @@ mod root { } #[inline] - pub fn create_fbs_transport_produce_response( + pub fn create_transport_produce_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54474,7 +54994,7 @@ mod root { } #[inline] - pub fn create_fbs_transport_consume_response( + pub fn create_transport_consume_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54482,7 +55002,7 @@ mod root { } #[inline] - pub fn create_fbs_transport_restart_ice_response( + pub fn create_transport_restart_ice_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54490,7 +55010,7 @@ mod root { } #[inline] - pub fn create_fbs_plain_transport_connect_response( + pub fn create_plain_transport_connect_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54498,7 +55018,7 @@ mod root { } #[inline] - pub fn create_fbs_plain_transport_dump_response( + pub fn create_plain_transport_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54506,7 +55026,7 @@ mod root { } #[inline] - pub fn create_fbs_plain_transport_get_stats_response( + pub fn create_plain_transport_get_stats_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54514,7 +55034,7 @@ mod root { } #[inline] - pub fn create_fbs_pipe_transport_connect_response( + pub fn create_pipe_transport_connect_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54522,7 +55042,7 @@ mod root { } #[inline] - pub fn create_fbs_pipe_transport_dump_response( + pub fn create_pipe_transport_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54530,7 +55050,7 @@ mod root { } #[inline] - pub fn create_fbs_pipe_transport_get_stats_response( + pub fn create_pipe_transport_get_stats_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54538,7 +55058,7 @@ mod root { } #[inline] - pub fn create_fbs_direct_transport_dump_response( + pub fn create_direct_transport_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54546,7 +55066,7 @@ mod root { } #[inline] - pub fn create_fbs_direct_transport_get_stats_response( + pub fn create_direct_transport_get_stats_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54554,7 +55074,7 @@ mod root { } #[inline] - pub fn create_fbs_web_rtc_transport_connect_response( + pub fn create_web_rtc_transport_connect_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54562,7 +55082,7 @@ mod root { } #[inline] - pub fn create_fbs_web_rtc_transport_dump_response( + pub fn create_web_rtc_transport_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54570,7 +55090,7 @@ mod root { } #[inline] - pub fn create_fbs_web_rtc_transport_get_stats_response( + pub fn create_web_rtc_transport_get_stats_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54578,7 +55098,7 @@ mod root { } #[inline] - pub fn create_fbs_producer_dump_response( + pub fn create_producer_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54586,7 +55106,7 @@ mod root { } #[inline] - pub fn create_fbs_producer_get_stats_response( + pub fn create_producer_get_stats_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54594,7 +55114,7 @@ mod root { } #[inline] - pub fn create_fbs_consumer_dump_response( + pub fn create_consumer_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54602,7 +55122,7 @@ mod root { } #[inline] - pub fn create_fbs_consumer_get_stats_response( + pub fn create_consumer_get_stats_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54610,7 +55130,7 @@ mod root { } #[inline] - pub fn create_fbs_consumer_set_preferred_layers_response( + pub fn create_consumer_set_preferred_layers_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54618,7 +55138,7 @@ mod root { } #[inline] - pub fn create_fbs_consumer_set_priority_response( + pub fn create_consumer_set_priority_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54626,7 +55146,7 @@ mod root { } #[inline] - pub fn create_fbs_data_producer_dump_response( + pub fn create_data_producer_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54634,7 +55154,7 @@ mod root { } #[inline] - pub fn create_fbs_data_producer_get_stats_response( + pub fn create_data_producer_get_stats_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54642,7 +55162,7 @@ mod root { } #[inline] - pub fn create_fbs_data_consumer_get_buffered_amount_response( + pub fn create_data_consumer_get_buffered_amount_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54650,7 +55170,7 @@ mod root { } #[inline] - pub fn create_fbs_data_consumer_dump_response( + pub fn create_data_consumer_dump_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54658,7 +55178,7 @@ mod root { } #[inline] - pub fn create_fbs_data_consumer_get_stats_response( + pub fn create_data_consumer_get_stats_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54666,7 +55186,7 @@ mod root { } #[inline] - pub fn create_fbs_data_consumer_set_subchannels_response( + pub fn create_data_consumer_set_subchannels_response( builder: &mut ::planus::Builder, value: impl ::planus::WriteAsOffset, ) -> ::planus::UnionOffset { @@ -54678,97 +55198,95 @@ mod root { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { match self { - Self::FbsWorkerDumpResponse(value) => { - Self::create_fbs_worker_dump_response(builder, value) + Self::WorkerDumpResponse(value) => { + Self::create_worker_dump_response(builder, value) } - Self::FbsWorkerResourceUsageResponse(value) => { - Self::create_fbs_worker_resource_usage_response(builder, value) + Self::WorkerResourceUsageResponse(value) => { + Self::create_worker_resource_usage_response(builder, value) } - Self::FbsWebRtcServerDumpResponse(value) => { - Self::create_fbs_web_rtc_server_dump_response(builder, value) + Self::WebRtcServerDumpResponse(value) => { + Self::create_web_rtc_server_dump_response(builder, value) } - Self::FbsRouterDumpResponse(value) => { - Self::create_fbs_router_dump_response(builder, value) + Self::RouterDumpResponse(value) => { + Self::create_router_dump_response(builder, value) } - Self::FbsTransportProduceResponse(value) => { - Self::create_fbs_transport_produce_response(builder, value) + Self::TransportProduceResponse(value) => { + Self::create_transport_produce_response(builder, value) } - Self::FbsTransportConsumeResponse(value) => { - Self::create_fbs_transport_consume_response(builder, value) + Self::TransportConsumeResponse(value) => { + Self::create_transport_consume_response(builder, value) } - Self::FbsTransportRestartIceResponse(value) => { - Self::create_fbs_transport_restart_ice_response(builder, value) + Self::TransportRestartIceResponse(value) => { + Self::create_transport_restart_ice_response(builder, value) } - Self::FbsPlainTransportConnectResponse(value) => { - Self::create_fbs_plain_transport_connect_response(builder, value) + Self::PlainTransportConnectResponse(value) => { + Self::create_plain_transport_connect_response(builder, value) } - Self::FbsPlainTransportDumpResponse(value) => { - Self::create_fbs_plain_transport_dump_response(builder, value) + Self::PlainTransportDumpResponse(value) => { + Self::create_plain_transport_dump_response(builder, value) } - Self::FbsPlainTransportGetStatsResponse(value) => { - Self::create_fbs_plain_transport_get_stats_response(builder, value) + Self::PlainTransportGetStatsResponse(value) => { + Self::create_plain_transport_get_stats_response(builder, value) } - Self::FbsPipeTransportConnectResponse(value) => { - Self::create_fbs_pipe_transport_connect_response(builder, value) + Self::PipeTransportConnectResponse(value) => { + Self::create_pipe_transport_connect_response(builder, value) } - Self::FbsPipeTransportDumpResponse(value) => { - Self::create_fbs_pipe_transport_dump_response(builder, value) + Self::PipeTransportDumpResponse(value) => { + Self::create_pipe_transport_dump_response(builder, value) } - Self::FbsPipeTransportGetStatsResponse(value) => { - Self::create_fbs_pipe_transport_get_stats_response(builder, value) + Self::PipeTransportGetStatsResponse(value) => { + Self::create_pipe_transport_get_stats_response(builder, value) } - Self::FbsDirectTransportDumpResponse(value) => { - Self::create_fbs_direct_transport_dump_response(builder, value) + Self::DirectTransportDumpResponse(value) => { + Self::create_direct_transport_dump_response(builder, value) } - Self::FbsDirectTransportGetStatsResponse(value) => { - Self::create_fbs_direct_transport_get_stats_response(builder, value) + Self::DirectTransportGetStatsResponse(value) => { + Self::create_direct_transport_get_stats_response(builder, value) } - Self::FbsWebRtcTransportConnectResponse(value) => { - Self::create_fbs_web_rtc_transport_connect_response(builder, value) + Self::WebRtcTransportConnectResponse(value) => { + Self::create_web_rtc_transport_connect_response(builder, value) } - Self::FbsWebRtcTransportDumpResponse(value) => { - Self::create_fbs_web_rtc_transport_dump_response(builder, value) + Self::WebRtcTransportDumpResponse(value) => { + Self::create_web_rtc_transport_dump_response(builder, value) } - Self::FbsWebRtcTransportGetStatsResponse(value) => { - Self::create_fbs_web_rtc_transport_get_stats_response(builder, value) + Self::WebRtcTransportGetStatsResponse(value) => { + Self::create_web_rtc_transport_get_stats_response(builder, value) } - Self::FbsProducerDumpResponse(value) => { - Self::create_fbs_producer_dump_response(builder, value) + Self::ProducerDumpResponse(value) => { + Self::create_producer_dump_response(builder, value) } - Self::FbsProducerGetStatsResponse(value) => { - Self::create_fbs_producer_get_stats_response(builder, value) + Self::ProducerGetStatsResponse(value) => { + Self::create_producer_get_stats_response(builder, value) } - Self::FbsConsumerDumpResponse(value) => { - Self::create_fbs_consumer_dump_response(builder, value) + Self::ConsumerDumpResponse(value) => { + Self::create_consumer_dump_response(builder, value) } - Self::FbsConsumerGetStatsResponse(value) => { - Self::create_fbs_consumer_get_stats_response(builder, value) + Self::ConsumerGetStatsResponse(value) => { + Self::create_consumer_get_stats_response(builder, value) } - Self::FbsConsumerSetPreferredLayersResponse(value) => { - Self::create_fbs_consumer_set_preferred_layers_response(builder, value) + Self::ConsumerSetPreferredLayersResponse(value) => { + Self::create_consumer_set_preferred_layers_response(builder, value) } - Self::FbsConsumerSetPriorityResponse(value) => { - Self::create_fbs_consumer_set_priority_response(builder, value) + Self::ConsumerSetPriorityResponse(value) => { + Self::create_consumer_set_priority_response(builder, value) } - Self::FbsDataProducerDumpResponse(value) => { - Self::create_fbs_data_producer_dump_response(builder, value) + Self::DataProducerDumpResponse(value) => { + Self::create_data_producer_dump_response(builder, value) } - Self::FbsDataProducerGetStatsResponse(value) => { - Self::create_fbs_data_producer_get_stats_response(builder, value) + Self::DataProducerGetStatsResponse(value) => { + Self::create_data_producer_get_stats_response(builder, value) } - Self::FbsDataConsumerGetBufferedAmountResponse(value) => { - Self::create_fbs_data_consumer_get_buffered_amount_response( - builder, value, - ) + Self::DataConsumerGetBufferedAmountResponse(value) => { + Self::create_data_consumer_get_buffered_amount_response(builder, value) } - Self::FbsDataConsumerDumpResponse(value) => { - Self::create_fbs_data_consumer_dump_response(builder, value) + Self::DataConsumerDumpResponse(value) => { + Self::create_data_consumer_dump_response(builder, value) } - Self::FbsDataConsumerGetStatsResponse(value) => { - Self::create_fbs_data_consumer_get_stats_response(builder, value) + Self::DataConsumerGetStatsResponse(value) => { + Self::create_data_consumer_get_stats_response(builder, value) } - Self::FbsDataConsumerSetSubchannelsResponse(value) => { - Self::create_fbs_data_consumer_set_subchannels_response(builder, value) + Self::DataConsumerSetSubchannelsResponse(value) => { + Self::create_data_consumer_set_subchannels_response(builder, value) } } } @@ -54792,9 +55310,9 @@ mod root { pub struct BodyBuilder(T); impl BodyBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`FBS_Worker_DumpResponse` variant](Body#variant.FbsWorkerDumpResponse). + /// Creates an instance of the [`Worker_DumpResponse` variant](Body#variant.WorkerDumpResponse). #[inline] - pub fn fbs_worker_dump_response( + pub fn worker_dump_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<1, T>> @@ -54804,9 +55322,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_Worker_ResourceUsageResponse` variant](Body#variant.FbsWorkerResourceUsageResponse). + /// Creates an instance of the [`Worker_ResourceUsageResponse` variant](Body#variant.WorkerResourceUsageResponse). #[inline] - pub fn fbs_worker_resource_usage_response( + pub fn worker_resource_usage_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<2, T>> @@ -54816,9 +55334,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_WebRtcServer_DumpResponse` variant](Body#variant.FbsWebRtcServerDumpResponse). + /// Creates an instance of the [`WebRtcServer_DumpResponse` variant](Body#variant.WebRtcServerDumpResponse). #[inline] - pub fn fbs_web_rtc_server_dump_response( + pub fn web_rtc_server_dump_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<3, T>> @@ -54828,9 +55346,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_Router_DumpResponse` variant](Body#variant.FbsRouterDumpResponse). + /// Creates an instance of the [`Router_DumpResponse` variant](Body#variant.RouterDumpResponse). #[inline] - pub fn fbs_router_dump_response( + pub fn router_dump_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<4, T>> @@ -54840,9 +55358,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_Transport_ProduceResponse` variant](Body#variant.FbsTransportProduceResponse). + /// Creates an instance of the [`Transport_ProduceResponse` variant](Body#variant.TransportProduceResponse). #[inline] - pub fn fbs_transport_produce_response( + pub fn transport_produce_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<5, T>> @@ -54852,9 +55370,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_Transport_ConsumeResponse` variant](Body#variant.FbsTransportConsumeResponse). + /// Creates an instance of the [`Transport_ConsumeResponse` variant](Body#variant.TransportConsumeResponse). #[inline] - pub fn fbs_transport_consume_response( + pub fn transport_consume_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<6, T>> @@ -54864,9 +55382,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_Transport_RestartIceResponse` variant](Body#variant.FbsTransportRestartIceResponse). + /// Creates an instance of the [`Transport_RestartIceResponse` variant](Body#variant.TransportRestartIceResponse). #[inline] - pub fn fbs_transport_restart_ice_response( + pub fn transport_restart_ice_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<7, T>> @@ -54876,9 +55394,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_PlainTransport_ConnectResponse` variant](Body#variant.FbsPlainTransportConnectResponse). + /// Creates an instance of the [`PlainTransport_ConnectResponse` variant](Body#variant.PlainTransportConnectResponse). #[inline] - pub fn fbs_plain_transport_connect_response( + pub fn plain_transport_connect_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<8, T>> @@ -54888,9 +55406,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_PlainTransport_DumpResponse` variant](Body#variant.FbsPlainTransportDumpResponse). + /// Creates an instance of the [`PlainTransport_DumpResponse` variant](Body#variant.PlainTransportDumpResponse). #[inline] - pub fn fbs_plain_transport_dump_response( + pub fn plain_transport_dump_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<9, T>> @@ -54900,9 +55418,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_PlainTransport_GetStatsResponse` variant](Body#variant.FbsPlainTransportGetStatsResponse). + /// Creates an instance of the [`PlainTransport_GetStatsResponse` variant](Body#variant.PlainTransportGetStatsResponse). #[inline] - pub fn fbs_plain_transport_get_stats_response( + pub fn plain_transport_get_stats_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<10, T>> @@ -54912,9 +55430,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_PipeTransport_ConnectResponse` variant](Body#variant.FbsPipeTransportConnectResponse). + /// Creates an instance of the [`PipeTransport_ConnectResponse` variant](Body#variant.PipeTransportConnectResponse). #[inline] - pub fn fbs_pipe_transport_connect_response( + pub fn pipe_transport_connect_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<11, T>> @@ -54924,9 +55442,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_PipeTransport_DumpResponse` variant](Body#variant.FbsPipeTransportDumpResponse). + /// Creates an instance of the [`PipeTransport_DumpResponse` variant](Body#variant.PipeTransportDumpResponse). #[inline] - pub fn fbs_pipe_transport_dump_response( + pub fn pipe_transport_dump_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<12, T>> @@ -54936,9 +55454,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_PipeTransport_GetStatsResponse` variant](Body#variant.FbsPipeTransportGetStatsResponse). + /// Creates an instance of the [`PipeTransport_GetStatsResponse` variant](Body#variant.PipeTransportGetStatsResponse). #[inline] - pub fn fbs_pipe_transport_get_stats_response( + pub fn pipe_transport_get_stats_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<13, T>> @@ -54948,9 +55466,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_DirectTransport_DumpResponse` variant](Body#variant.FbsDirectTransportDumpResponse). + /// Creates an instance of the [`DirectTransport_DumpResponse` variant](Body#variant.DirectTransportDumpResponse). #[inline] - pub fn fbs_direct_transport_dump_response( + pub fn direct_transport_dump_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<14, T>> @@ -54960,9 +55478,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_DirectTransport_GetStatsResponse` variant](Body#variant.FbsDirectTransportGetStatsResponse). + /// Creates an instance of the [`DirectTransport_GetStatsResponse` variant](Body#variant.DirectTransportGetStatsResponse). #[inline] - pub fn fbs_direct_transport_get_stats_response( + pub fn direct_transport_get_stats_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<15, T>> @@ -54972,9 +55490,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_WebRtcTransport_ConnectResponse` variant](Body#variant.FbsWebRtcTransportConnectResponse). + /// Creates an instance of the [`WebRtcTransport_ConnectResponse` variant](Body#variant.WebRtcTransportConnectResponse). #[inline] - pub fn fbs_web_rtc_transport_connect_response( + pub fn web_rtc_transport_connect_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<16, T>> @@ -54984,9 +55502,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_WebRtcTransport_DumpResponse` variant](Body#variant.FbsWebRtcTransportDumpResponse). + /// Creates an instance of the [`WebRtcTransport_DumpResponse` variant](Body#variant.WebRtcTransportDumpResponse). #[inline] - pub fn fbs_web_rtc_transport_dump_response( + pub fn web_rtc_transport_dump_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<17, T>> @@ -54996,9 +55514,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_WebRtcTransport_GetStatsResponse` variant](Body#variant.FbsWebRtcTransportGetStatsResponse). + /// Creates an instance of the [`WebRtcTransport_GetStatsResponse` variant](Body#variant.WebRtcTransportGetStatsResponse). #[inline] - pub fn fbs_web_rtc_transport_get_stats_response( + pub fn web_rtc_transport_get_stats_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<18, T>> @@ -55008,9 +55526,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_Producer_DumpResponse` variant](Body#variant.FbsProducerDumpResponse). + /// Creates an instance of the [`Producer_DumpResponse` variant](Body#variant.ProducerDumpResponse). #[inline] - pub fn fbs_producer_dump_response( + pub fn producer_dump_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<19, T>> @@ -55020,9 +55538,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_Producer_GetStatsResponse` variant](Body#variant.FbsProducerGetStatsResponse). + /// Creates an instance of the [`Producer_GetStatsResponse` variant](Body#variant.ProducerGetStatsResponse). #[inline] - pub fn fbs_producer_get_stats_response( + pub fn producer_get_stats_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<20, T>> @@ -55032,9 +55550,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_Consumer_DumpResponse` variant](Body#variant.FbsConsumerDumpResponse). + /// Creates an instance of the [`Consumer_DumpResponse` variant](Body#variant.ConsumerDumpResponse). #[inline] - pub fn fbs_consumer_dump_response( + pub fn consumer_dump_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<21, T>> @@ -55044,9 +55562,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_Consumer_GetStatsResponse` variant](Body#variant.FbsConsumerGetStatsResponse). + /// Creates an instance of the [`Consumer_GetStatsResponse` variant](Body#variant.ConsumerGetStatsResponse). #[inline] - pub fn fbs_consumer_get_stats_response( + pub fn consumer_get_stats_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<22, T>> @@ -55056,9 +55574,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_Consumer_SetPreferredLayersResponse` variant](Body#variant.FbsConsumerSetPreferredLayersResponse). + /// Creates an instance of the [`Consumer_SetPreferredLayersResponse` variant](Body#variant.ConsumerSetPreferredLayersResponse). #[inline] - pub fn fbs_consumer_set_preferred_layers_response( + pub fn consumer_set_preferred_layers_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<23, T>> @@ -55068,9 +55586,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_Consumer_SetPriorityResponse` variant](Body#variant.FbsConsumerSetPriorityResponse). + /// Creates an instance of the [`Consumer_SetPriorityResponse` variant](Body#variant.ConsumerSetPriorityResponse). #[inline] - pub fn fbs_consumer_set_priority_response( + pub fn consumer_set_priority_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<24, T>> @@ -55080,9 +55598,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_DataProducer_DumpResponse` variant](Body#variant.FbsDataProducerDumpResponse). + /// Creates an instance of the [`DataProducer_DumpResponse` variant](Body#variant.DataProducerDumpResponse). #[inline] - pub fn fbs_data_producer_dump_response( + pub fn data_producer_dump_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<25, T>> @@ -55092,9 +55610,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_DataProducer_GetStatsResponse` variant](Body#variant.FbsDataProducerGetStatsResponse). + /// Creates an instance of the [`DataProducer_GetStatsResponse` variant](Body#variant.DataProducerGetStatsResponse). #[inline] - pub fn fbs_data_producer_get_stats_response( + pub fn data_producer_get_stats_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<26, T>> @@ -55104,9 +55622,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_DataConsumer_GetBufferedAmountResponse` variant](Body#variant.FbsDataConsumerGetBufferedAmountResponse). + /// Creates an instance of the [`DataConsumer_GetBufferedAmountResponse` variant](Body#variant.DataConsumerGetBufferedAmountResponse). #[inline] - pub fn fbs_data_consumer_get_buffered_amount_response( + pub fn data_consumer_get_buffered_amount_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<27, T>> @@ -55116,9 +55634,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_DataConsumer_DumpResponse` variant](Body#variant.FbsDataConsumerDumpResponse). + /// Creates an instance of the [`DataConsumer_DumpResponse` variant](Body#variant.DataConsumerDumpResponse). #[inline] - pub fn fbs_data_consumer_dump_response( + pub fn data_consumer_dump_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<28, T>> @@ -55128,9 +55646,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_DataConsumer_GetStatsResponse` variant](Body#variant.FbsDataConsumerGetStatsResponse). + /// Creates an instance of the [`DataConsumer_GetStatsResponse` variant](Body#variant.DataConsumerGetStatsResponse). #[inline] - pub fn fbs_data_consumer_get_stats_response( + pub fn data_consumer_get_stats_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<29, T>> @@ -55140,9 +55658,9 @@ mod root { BodyBuilder(::planus::Initialized(value)) } - /// Creates an instance of the [`FBS_DataConsumer_SetSubchannelsResponse` variant](Body#variant.FbsDataConsumerSetSubchannelsResponse). + /// Creates an instance of the [`DataConsumer_SetSubchannelsResponse` variant](Body#variant.DataConsumerSetSubchannelsResponse). #[inline] - pub fn fbs_data_consumer_set_subchannels_response( + pub fn data_consumer_set_subchannels_response( self, value: T, ) -> BodyBuilder<::planus::Initialized<30, T>> @@ -55828,44 +56346,40 @@ mod root { /// Reference to a deserialized [Body]. #[derive(Copy, Clone, Debug)] pub enum BodyRef<'a> { - FbsWorkerDumpResponse(super::worker::DumpResponseRef<'a>), - FbsWorkerResourceUsageResponse(super::worker::ResourceUsageResponseRef<'a>), - FbsWebRtcServerDumpResponse(super::web_rtc_server::DumpResponseRef<'a>), - FbsRouterDumpResponse(super::router::DumpResponseRef<'a>), - FbsTransportProduceResponse(super::transport::ProduceResponseRef<'a>), - FbsTransportConsumeResponse(super::transport::ConsumeResponseRef<'a>), - FbsTransportRestartIceResponse(super::transport::RestartIceResponseRef<'a>), - FbsPlainTransportConnectResponse(super::plain_transport::ConnectResponseRef<'a>), - FbsPlainTransportDumpResponse(super::plain_transport::DumpResponseRef<'a>), - FbsPlainTransportGetStatsResponse(super::plain_transport::GetStatsResponseRef<'a>), - FbsPipeTransportConnectResponse(super::pipe_transport::ConnectResponseRef<'a>), - FbsPipeTransportDumpResponse(super::pipe_transport::DumpResponseRef<'a>), - FbsPipeTransportGetStatsResponse(super::pipe_transport::GetStatsResponseRef<'a>), - FbsDirectTransportDumpResponse(super::direct_transport::DumpResponseRef<'a>), - FbsDirectTransportGetStatsResponse( - super::direct_transport::GetStatsResponseRef<'a>, - ), - FbsWebRtcTransportConnectResponse(super::web_rtc_transport::ConnectResponseRef<'a>), - FbsWebRtcTransportDumpResponse(super::web_rtc_transport::DumpResponseRef<'a>), - FbsWebRtcTransportGetStatsResponse( - super::web_rtc_transport::GetStatsResponseRef<'a>, - ), - FbsProducerDumpResponse(super::producer::DumpResponseRef<'a>), - FbsProducerGetStatsResponse(super::producer::GetStatsResponseRef<'a>), - FbsConsumerDumpResponse(super::consumer::DumpResponseRef<'a>), - FbsConsumerGetStatsResponse(super::consumer::GetStatsResponseRef<'a>), - FbsConsumerSetPreferredLayersResponse( + 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>, ), - FbsConsumerSetPriorityResponse(super::consumer::SetPriorityResponseRef<'a>), - FbsDataProducerDumpResponse(super::data_producer::DumpResponseRef<'a>), - FbsDataProducerGetStatsResponse(super::data_producer::GetStatsResponseRef<'a>), - FbsDataConsumerGetBufferedAmountResponse( + ConsumerSetPriorityResponse(super::consumer::SetPriorityResponseRef<'a>), + DataProducerDumpResponse(super::data_producer::DumpResponseRef<'a>), + DataProducerGetStatsResponse(super::data_producer::GetStatsResponseRef<'a>), + DataConsumerGetBufferedAmountResponse( super::data_consumer::GetBufferedAmountResponseRef<'a>, ), - FbsDataConsumerDumpResponse(super::data_consumer::DumpResponseRef<'a>), - FbsDataConsumerGetStatsResponse(super::data_consumer::GetStatsResponseRef<'a>), - FbsDataConsumerSetSubchannelsResponse( + DataConsumerDumpResponse(super::data_consumer::DumpResponseRef<'a>), + DataConsumerGetStatsResponse(super::data_consumer::GetStatsResponseRef<'a>), + DataConsumerSetSubchannelsResponse( super::data_consumer::SetSubchannelsResponseRef<'a>, ), } @@ -55875,198 +56389,186 @@ mod root { fn try_from(value: BodyRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(match value { - BodyRef::FbsWorkerDumpResponse(value) => { - Self::FbsWorkerDumpResponse(::planus::alloc::boxed::Box::new( + BodyRef::WorkerDumpResponse(value) => { + Self::WorkerDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsWorkerResourceUsageResponse(value) => { - Self::FbsWorkerResourceUsageResponse(::planus::alloc::boxed::Box::new( + BodyRef::WorkerResourceUsageResponse(value) => { + Self::WorkerResourceUsageResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsWebRtcServerDumpResponse(value) => { - Self::FbsWebRtcServerDumpResponse(::planus::alloc::boxed::Box::new( + BodyRef::WebRtcServerDumpResponse(value) => { + Self::WebRtcServerDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsRouterDumpResponse(value) => { - Self::FbsRouterDumpResponse(::planus::alloc::boxed::Box::new( + BodyRef::RouterDumpResponse(value) => { + Self::RouterDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsTransportProduceResponse(value) => { - Self::FbsTransportProduceResponse(::planus::alloc::boxed::Box::new( + BodyRef::TransportProduceResponse(value) => { + Self::TransportProduceResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsTransportConsumeResponse(value) => { - Self::FbsTransportConsumeResponse(::planus::alloc::boxed::Box::new( + BodyRef::TransportConsumeResponse(value) => { + Self::TransportConsumeResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsTransportRestartIceResponse(value) => { - Self::FbsTransportRestartIceResponse(::planus::alloc::boxed::Box::new( + BodyRef::TransportRestartIceResponse(value) => { + Self::TransportRestartIceResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsPlainTransportConnectResponse(value) => { - Self::FbsPlainTransportConnectResponse( - ::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::FbsPlainTransportDumpResponse(value) => { - Self::FbsPlainTransportDumpResponse(::planus::alloc::boxed::Box::new( + BodyRef::PlainTransportDumpResponse(value) => { + Self::PlainTransportDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsPlainTransportGetStatsResponse(value) => { - Self::FbsPlainTransportGetStatsResponse( - ::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::FbsPipeTransportConnectResponse(value) => { - Self::FbsPipeTransportConnectResponse(::planus::alloc::boxed::Box::new( + BodyRef::PipeTransportConnectResponse(value) => { + Self::PipeTransportConnectResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsPipeTransportDumpResponse(value) => { - Self::FbsPipeTransportDumpResponse(::planus::alloc::boxed::Box::new( + BodyRef::PipeTransportDumpResponse(value) => { + Self::PipeTransportDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsPipeTransportGetStatsResponse(value) => { - Self::FbsPipeTransportGetStatsResponse( - ::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::FbsDirectTransportDumpResponse(value) => { - Self::FbsDirectTransportDumpResponse(::planus::alloc::boxed::Box::new( + BodyRef::DirectTransportDumpResponse(value) => { + Self::DirectTransportDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsDirectTransportGetStatsResponse(value) => { - Self::FbsDirectTransportGetStatsResponse( - ::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::FbsWebRtcTransportConnectResponse(value) => { - Self::FbsWebRtcTransportConnectResponse( - ::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::FbsWebRtcTransportDumpResponse(value) => { - Self::FbsWebRtcTransportDumpResponse(::planus::alloc::boxed::Box::new( + BodyRef::WebRtcTransportDumpResponse(value) => { + Self::WebRtcTransportDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsWebRtcTransportGetStatsResponse(value) => { - Self::FbsWebRtcTransportGetStatsResponse( - ::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::FbsProducerDumpResponse(value) => { - Self::FbsProducerDumpResponse(::planus::alloc::boxed::Box::new( + BodyRef::ProducerDumpResponse(value) => { + Self::ProducerDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsProducerGetStatsResponse(value) => { - Self::FbsProducerGetStatsResponse(::planus::alloc::boxed::Box::new( + BodyRef::ProducerGetStatsResponse(value) => { + Self::ProducerGetStatsResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsConsumerDumpResponse(value) => { - Self::FbsConsumerDumpResponse(::planus::alloc::boxed::Box::new( + BodyRef::ConsumerDumpResponse(value) => { + Self::ConsumerDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsConsumerGetStatsResponse(value) => { - Self::FbsConsumerGetStatsResponse(::planus::alloc::boxed::Box::new( + BodyRef::ConsumerGetStatsResponse(value) => { + Self::ConsumerGetStatsResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsConsumerSetPreferredLayersResponse(value) => { - Self::FbsConsumerSetPreferredLayersResponse( + BodyRef::ConsumerSetPreferredLayersResponse(value) => { + Self::ConsumerSetPreferredLayersResponse( ::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, ), ) } - BodyRef::FbsConsumerSetPriorityResponse(value) => { - Self::FbsConsumerSetPriorityResponse(::planus::alloc::boxed::Box::new( + BodyRef::ConsumerSetPriorityResponse(value) => { + Self::ConsumerSetPriorityResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsDataProducerDumpResponse(value) => { - Self::FbsDataProducerDumpResponse(::planus::alloc::boxed::Box::new( + BodyRef::DataProducerDumpResponse(value) => { + Self::DataProducerDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsDataProducerGetStatsResponse(value) => { - Self::FbsDataProducerGetStatsResponse(::planus::alloc::boxed::Box::new( + BodyRef::DataProducerGetStatsResponse(value) => { + Self::DataProducerGetStatsResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsDataConsumerGetBufferedAmountResponse(value) => { - Self::FbsDataConsumerGetBufferedAmountResponse( + BodyRef::DataConsumerGetBufferedAmountResponse(value) => { + Self::DataConsumerGetBufferedAmountResponse( ::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, ), ) } - BodyRef::FbsDataConsumerDumpResponse(value) => { - Self::FbsDataConsumerDumpResponse(::planus::alloc::boxed::Box::new( + BodyRef::DataConsumerDumpResponse(value) => { + Self::DataConsumerDumpResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsDataConsumerGetStatsResponse(value) => { - Self::FbsDataConsumerGetStatsResponse(::planus::alloc::boxed::Box::new( + BodyRef::DataConsumerGetStatsResponse(value) => { + Self::DataConsumerGetStatsResponse(::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, )) } - BodyRef::FbsDataConsumerSetSubchannelsResponse(value) => { - Self::FbsDataConsumerSetSubchannelsResponse( + BodyRef::DataConsumerSetSubchannelsResponse(value) => { + Self::DataConsumerSetSubchannelsResponse( ::planus::alloc::boxed::Box::new( ::core::convert::TryFrom::try_from(value)?, ), @@ -56083,102 +56585,98 @@ mod root { tag: u8, ) -> ::core::result::Result { match tag { - 1 => ::core::result::Result::Ok(Self::FbsWorkerDumpResponse( + 1 => ::core::result::Result::Ok(Self::WorkerDumpResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 2 => ::core::result::Result::Ok(Self::FbsWorkerResourceUsageResponse( + 2 => ::core::result::Result::Ok(Self::WorkerResourceUsageResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 3 => ::core::result::Result::Ok(Self::FbsWebRtcServerDumpResponse( + 3 => ::core::result::Result::Ok(Self::WebRtcServerDumpResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 4 => ::core::result::Result::Ok(Self::FbsRouterDumpResponse( + 4 => ::core::result::Result::Ok(Self::RouterDumpResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 5 => ::core::result::Result::Ok(Self::FbsTransportProduceResponse( + 5 => ::core::result::Result::Ok(Self::TransportProduceResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 6 => ::core::result::Result::Ok(Self::FbsTransportConsumeResponse( + 6 => ::core::result::Result::Ok(Self::TransportConsumeResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 7 => ::core::result::Result::Ok(Self::FbsTransportRestartIceResponse( + 7 => ::core::result::Result::Ok(Self::TransportRestartIceResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 8 => ::core::result::Result::Ok(Self::FbsPlainTransportConnectResponse( + 8 => ::core::result::Result::Ok(Self::PlainTransportConnectResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 9 => ::core::result::Result::Ok(Self::FbsPlainTransportDumpResponse( + 9 => ::core::result::Result::Ok(Self::PlainTransportDumpResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 10 => ::core::result::Result::Ok(Self::FbsPlainTransportGetStatsResponse( + 10 => ::core::result::Result::Ok(Self::PlainTransportGetStatsResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 11 => ::core::result::Result::Ok(Self::FbsPipeTransportConnectResponse( + 11 => ::core::result::Result::Ok(Self::PipeTransportConnectResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 12 => ::core::result::Result::Ok(Self::FbsPipeTransportDumpResponse( + 12 => ::core::result::Result::Ok(Self::PipeTransportDumpResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 13 => ::core::result::Result::Ok(Self::FbsPipeTransportGetStatsResponse( + 13 => ::core::result::Result::Ok(Self::PipeTransportGetStatsResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 14 => ::core::result::Result::Ok(Self::FbsDirectTransportDumpResponse( + 14 => ::core::result::Result::Ok(Self::DirectTransportDumpResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 15 => ::core::result::Result::Ok(Self::FbsDirectTransportGetStatsResponse( + 15 => ::core::result::Result::Ok(Self::DirectTransportGetStatsResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 16 => ::core::result::Result::Ok(Self::FbsWebRtcTransportConnectResponse( + 16 => ::core::result::Result::Ok(Self::WebRtcTransportConnectResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 17 => ::core::result::Result::Ok(Self::FbsWebRtcTransportDumpResponse( + 17 => ::core::result::Result::Ok(Self::WebRtcTransportDumpResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 18 => ::core::result::Result::Ok(Self::FbsWebRtcTransportGetStatsResponse( + 18 => ::core::result::Result::Ok(Self::WebRtcTransportGetStatsResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 19 => ::core::result::Result::Ok(Self::FbsProducerDumpResponse( + 19 => ::core::result::Result::Ok(Self::ProducerDumpResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 20 => ::core::result::Result::Ok(Self::FbsProducerGetStatsResponse( + 20 => ::core::result::Result::Ok(Self::ProducerGetStatsResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 21 => ::core::result::Result::Ok(Self::FbsConsumerDumpResponse( + 21 => ::core::result::Result::Ok(Self::ConsumerDumpResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 22 => ::core::result::Result::Ok(Self::FbsConsumerGetStatsResponse( + 22 => ::core::result::Result::Ok(Self::ConsumerGetStatsResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 23 => { - ::core::result::Result::Ok(Self::FbsConsumerSetPreferredLayersResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )) - } - 24 => ::core::result::Result::Ok(Self::FbsConsumerSetPriorityResponse( + 23 => ::core::result::Result::Ok(Self::ConsumerSetPreferredLayersResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 25 => ::core::result::Result::Ok(Self::FbsDataProducerDumpResponse( + 24 => ::core::result::Result::Ok(Self::ConsumerSetPriorityResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 26 => ::core::result::Result::Ok(Self::FbsDataProducerGetStatsResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 27 => ::core::result::Result::Ok( - Self::FbsDataConsumerGetBufferedAmountResponse( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - ), - ), - 28 => ::core::result::Result::Ok(Self::FbsDataConsumerDumpResponse( + 25 => ::core::result::Result::Ok(Self::DataProducerDumpResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 29 => ::core::result::Result::Ok(Self::FbsDataConsumerGetStatsResponse( + 26 => ::core::result::Result::Ok(Self::DataProducerGetStatsResponse( ::planus::TableRead::from_buffer(buffer, field_offset)?, )), - 30 => { - ::core::result::Result::Ok(Self::FbsDataConsumerSetSubchannelsResponse( + 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 }, ), @@ -67626,7 +68124,7 @@ mod root { /// The enum `TraceDirection` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Enum `TraceDirection` in the file `../worker/fbs/producer.fbs:49` + /// * Enum `TraceDirection` in the file `../worker/fbs/producer.fbs:56` #[derive( Copy, Clone, @@ -67796,7 +68294,7 @@ mod root { /// The union `TraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Union `TraceInfo` in the file `../worker/fbs/producer.fbs:51` + /// * Union `TraceInfo` in the file `../worker/fbs/producer.fbs:61` #[derive( Clone, Debug, @@ -68128,7 +68626,7 @@ mod root { /// The table `KeyFrameTraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/producer.fbs:58` + /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/producer.fbs:68` #[derive( Clone, Debug, @@ -68410,7 +68908,7 @@ mod root { /// The table `FirTraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `FirTraceInfo` in the file `../worker/fbs/producer.fbs:62` + /// * Table `FirTraceInfo` in the file `../worker/fbs/producer.fbs:72` #[derive( Clone, Debug, @@ -68687,7 +69185,7 @@ mod root { /// The table `PliTraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `PliTraceInfo` in the file `../worker/fbs/producer.fbs:66` + /// * Table `PliTraceInfo` in the file `../worker/fbs/producer.fbs:76` #[derive( Clone, Debug, @@ -68964,7 +69462,7 @@ mod root { /// The table `RtpTraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `RtpTraceInfo` in the file `../worker/fbs/producer.fbs:70` + /// * Table `RtpTraceInfo` in the file `../worker/fbs/producer.fbs:80` #[derive( Clone, Debug, @@ -69241,7 +69739,7 @@ mod root { /// The table `TraceNotification` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/producer.fbs:74` + /// * Table `TraceNotification` in the file `../worker/fbs/producer.fbs:84` #[derive( Clone, Debug, @@ -77231,7 +77729,7 @@ mod root { /// The enum `IceCandidateTcpType` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Enum `IceCandidateTcpType` in the file `../worker/fbs/webRtcTransport.fbs:63` + /// * Enum `IceCandidateTcpType` in the file `../worker/fbs/webRtcTransport.fbs:66` #[derive( Copy, Clone, @@ -77397,7 +77895,7 @@ mod root { /// The enum `IceRole` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Enum `IceRole` in the file `../worker/fbs/webRtcTransport.fbs:64` + /// * Enum `IceRole` in the file `../worker/fbs/webRtcTransport.fbs:70` #[derive( Copy, Clone, @@ -77567,7 +78065,7 @@ mod root { /// The enum `IceState` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Enum `IceState` in the file `../worker/fbs/webRtcTransport.fbs:65` + /// * Enum `IceState` in the file `../worker/fbs/webRtcTransport.fbs:75` #[derive( Copy, Clone, @@ -77750,7 +78248,7 @@ mod root { /// The table `IceCandidate` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `IceCandidate` in the file `../worker/fbs/webRtcTransport.fbs:72` + /// * Table `IceCandidate` in the file `../worker/fbs/webRtcTransport.fbs:82` #[derive( Clone, Debug, @@ -78321,7 +78819,7 @@ mod root { /// The table `ConnectRequest` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `ConnectRequest` in the file `../worker/fbs/webRtcTransport.fbs:82` + /// * Table `ConnectRequest` in the file `../worker/fbs/webRtcTransport.fbs:92` #[derive( Clone, Debug, @@ -78584,7 +79082,7 @@ mod root { /// The table `ConnectResponse` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `ConnectResponse` in the file `../worker/fbs/webRtcTransport.fbs:86` + /// * Table `ConnectResponse` in the file `../worker/fbs/webRtcTransport.fbs:96` #[derive( Clone, Debug, @@ -78873,7 +79371,7 @@ mod root { /// The table `DumpResponse` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/webRtcTransport.fbs:90` + /// * Table `DumpResponse` in the file `../worker/fbs/webRtcTransport.fbs:100` #[derive( Clone, Debug, @@ -79473,7 +79971,7 @@ mod root { /// The table `GetStatsResponse` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/webRtcTransport.fbs:101` + /// * Table `GetStatsResponse` in the file `../worker/fbs/webRtcTransport.fbs:111` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -79956,7 +80454,7 @@ mod root { /// The table `IceSelectedTupleChangeNotification` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `IceSelectedTupleChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:111` + /// * Table `IceSelectedTupleChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:121` #[derive( Clone, Debug, @@ -80239,7 +80737,7 @@ mod root { /// The table `IceStateChangeNotification` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `IceStateChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:115` + /// * Table `IceStateChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:125` #[derive( Clone, Debug, @@ -80540,7 +81038,7 @@ mod root { /// The table `DtlsStateChangeNotification` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `DtlsStateChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:119` + /// * Table `DtlsStateChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:129` #[derive( Clone, Debug, @@ -80916,7 +81414,7 @@ mod root { /// The table `AddProducerRequest` in the namespace `FBS.RtpObserver` /// /// Generated from these locations: - /// * Table `AddProducerRequest` in the file `../worker/fbs/rtpObserver.fbs:4` + /// * Table `AddProducerRequest` in the file `../worker/fbs/rtpObserver.fbs:3` #[derive( Clone, Debug, @@ -81175,7 +81673,7 @@ mod root { /// The table `RemoveProducerRequest` in the namespace `FBS.RtpObserver` /// /// Generated from these locations: - /// * Table `RemoveProducerRequest` in the file `../worker/fbs/rtpObserver.fbs:8` + /// * Table `RemoveProducerRequest` in the file `../worker/fbs/rtpObserver.fbs:7` #[derive( Clone, Debug, diff --git a/rust/src/messages.rs b/rust/src/messages.rs index de9098e86e..f97edf769b 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -332,7 +332,7 @@ impl RequestFbs for WorkerDumpRequest { fn convert_response( response: Option, ) -> Result> { - let Some(response::Body::FbsWorkerDumpResponse(data)) = response else { + let Some(response::Body::WorkerDumpResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; @@ -390,7 +390,7 @@ impl RequestFbs for WorkerUpdateSettingsRequest { .collect::>() }), ); - let request_body = request::Body::create_update_settings_request(&mut builder, data); + let request_body = request::Body::create_worker_update_settings_request(&mut builder, data); let request = request::Request::create( &mut builder, id, @@ -429,7 +429,8 @@ impl RequestFbs for WorkerCreateWebRtcServerRequest { self.webrtc_server_id.to_string(), self.listen_infos.to_fbs(), ); - let request_body = request::Body::create_create_web_rtc_server_request(&mut builder, data); + let request_body = + request::Body::create_worker_create_web_rtc_server_request(&mut builder, data); let request = request::Request::create( &mut builder, id, @@ -467,7 +468,8 @@ impl RequestFbs for WebRtcServerCloseRequest { &mut builder, self.webrtc_server_id.to_string(), ); - let request_body = request::Body::create_close_web_rtc_server_request(&mut builder, data); + let request_body = + request::Body::create_worker_close_web_rtc_server_request(&mut builder, data); let request = request::Request::create( &mut builder, id, @@ -515,7 +517,7 @@ impl RequestFbs for WebRtcServerDumpRequest { fn convert_response( response: Option, ) -> Result> { - let Some(response::Body::FbsWebRtcServerDumpResponse(data)) = response else { + let Some(response::Body::WebRtcServerDumpResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; @@ -578,7 +580,7 @@ impl RequestFbs for WorkerCreateRouterRequest { fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { let mut builder = Builder::new(); let data = worker::CreateRouterRequest::create(&mut builder, self.router_id.to_string()); - let request_body = request::Body::create_create_router_request(&mut builder, data); + let request_body = request::Body::create_worker_create_router_request(&mut builder, data); let request = request::Request::create( &mut builder, id, @@ -613,7 +615,7 @@ impl RequestFbs for RouterCloseRequest { let mut builder = Builder::new(); let data = worker::CloseRouterRequest::create(&mut builder, self.router_id.to_string()); - let request_body = request::Body::create_close_router_request(&mut builder, data); + let request_body = request::Body::create_worker_close_router_request(&mut builder, data); let request = request::Request::create( &mut builder, id, @@ -661,7 +663,7 @@ impl RequestFbs for RouterDumpRequest { fn convert_response( response: Option, ) -> Result> { - let Some(response::Body::FbsRouterDumpResponse(data)) = response else { + let Some(response::Body::RouterDumpResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; @@ -787,7 +789,7 @@ impl RequestFbs for RouterCreateDirectTransportRequest { self.data.to_fbs(), ); let request_body = - request::Body::create_create_direct_transport_request(&mut builder, data); + request::Body::create_router_create_direct_transport_request(&mut builder, data); let request = request::Request::create( &mut builder, id, @@ -936,7 +938,7 @@ impl RequestFbs for RouterCreateWebRtcTransportRequest { self.data.to_fbs(), ); let request_body = - request::Body::create_create_web_rtc_transport_request(&mut builder, data); + request::Body::create_router_create_web_rtc_transport_request(&mut builder, data); let request = request::Request::create( &mut builder, id, @@ -953,7 +955,7 @@ impl RequestFbs for RouterCreateWebRtcTransportRequest { fn convert_response( response: Option, ) -> Result> { - let Some(response::Body::FbsWebRtcTransportDumpResponse(data)) = response else { + let Some(response::Body::WebRtcTransportDumpResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; @@ -1065,7 +1067,8 @@ impl RequestFbs for RouterCreatePlainTransportRequest { self.data.transport_id.to_string(), self.data.to_fbs(), ); - let request_body = request::Body::create_create_plain_transport_request(&mut builder, data); + let request_body = + request::Body::create_router_create_plain_transport_request(&mut builder, data); let request = request::Request::create( &mut builder, id, @@ -1082,7 +1085,7 @@ impl RequestFbs for RouterCreatePlainTransportRequest { fn convert_response( response: Option, ) -> Result> { - let Some(response::Body::FbsPlainTransportDumpResponse(data)) = response else { + let Some(response::Body::PlainTransportDumpResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; @@ -1338,7 +1341,7 @@ impl RequestFbs for TransportCloseRequestFbs { let mut builder = Builder::new(); let data = router::CloseTransportRequest::create(&mut builder, self.transport_id.to_string()); - let request_body = request::Body::create_close_transport_request(&mut builder, data); + let request_body = request::Body::create_router_close_transport_request(&mut builder, data); let request = request::Request::create( &mut builder, @@ -1397,7 +1400,7 @@ impl RequestFbs for WebRtcTransportConnectRequest { fn convert_response( response: Option, ) -> Result> { - let Some(response::Body::FbsWebRtcTransportConnectResponse(data)) = response else { + let Some(response::Body::WebRtcTransportConnectResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; @@ -1449,7 +1452,7 @@ impl RequestFbs for PipeTransportConnectRequest { fn convert_response( response: Option, ) -> Result> { - let Some(response::Body::FbsPipeTransportConnectResponse(data)) = response else { + let Some(response::Body::PipeTransportConnectResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; @@ -1506,7 +1509,7 @@ impl RequestFbs for TransportConnectPlainRequest { fn convert_response( response: Option, ) -> Result> { - let Some(response::Body::FbsPlainTransportConnectResponse(data)) = response else { + let Some(response::Body::PlainTransportConnectResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; @@ -1537,7 +1540,7 @@ impl RequestFbs for TransportSetMaxIncomingBitrateRequest { let data = transport::SetMaxIncomingBitrateRequest::create(&mut builder, self.bitrate); let request_body = - request::Body::create_set_max_incoming_bitrate_request(&mut builder, data); + request::Body::create_transport_set_max_incoming_bitrate_request(&mut builder, data); let request = request::Request::create( &mut builder, id, @@ -1573,7 +1576,7 @@ impl RequestFbs for TransportSetMaxOutgoingBitrateRequest { let data = transport::SetMaxOutgoingBitrateRequest::create(&mut builder, self.bitrate); let request_body = - request::Body::create_set_max_outgoing_bitrate_request(&mut builder, data); + request::Body::create_transport_set_max_outgoing_bitrate_request(&mut builder, data); let request = request::Request::create( &mut builder, id, @@ -1609,7 +1612,7 @@ impl RequestFbs for TransportSetMinOutgoingBitrateRequest { let data = transport::SetMinOutgoingBitrateRequest::create(&mut builder, self.bitrate); let request_body = - request::Body::create_set_min_outgoing_bitrate_request(&mut builder, data); + request::Body::create_transport_set_min_outgoing_bitrate_request(&mut builder, data); let request = request::Request::create( &mut builder, id, @@ -1656,7 +1659,7 @@ impl RequestFbs for TransportRestartIceRequest { fn convert_response( response: Option, ) -> Result> { - let Some(response::Body::FbsTransportRestartIceResponse(data)) = response else { + let Some(response::Body::TransportRestartIceResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; diff --git a/rust/src/router/direct_transport.rs b/rust/src/router/direct_transport.rs index bf1020e151..37126e8b15 100644 --- a/rust/src/router/direct_transport.rs +++ b/rust/src/router/direct_transport.rs @@ -505,7 +505,7 @@ impl TransportGeneric for DirectTransport { async fn dump(&self) -> Result { debug!("dump()"); - if let response::Body::FbsDirectTransportDumpResponse(data) = self.dump_impl().await? { + if let response::Body::DirectTransportDumpResponse(data) = self.dump_impl().await? { Ok(DirectTransportDump::from_fbs(*data).expect("Error parsing dump response")) } else { panic!("Wrong message from worker"); @@ -519,8 +519,7 @@ impl TransportGeneric for DirectTransport { async fn get_stats(&self) -> Result, RequestError> { debug!("get_stats()"); - if let response::Body::FbsDirectTransportGetStatsResponse(data) = - self.get_stats_impl().await? + if let response::Body::DirectTransportGetStatsResponse(data) = self.get_stats_impl().await? { Ok(vec![ DirectTransportStat::from_fbs(*data).expect("Error parsing dump response") diff --git a/rust/src/router/pipe_transport.rs b/rust/src/router/pipe_transport.rs index 5d21720b7d..5121bf79b0 100644 --- a/rust/src/router/pipe_transport.rs +++ b/rust/src/router/pipe_transport.rs @@ -297,7 +297,7 @@ impl Notification { ) -> Result { match notification.event().unwrap() { notification::Event::TransportSctpStateChange => { - let Ok(Some(notification::BodyRef::SctpStateChangeNotification(body))) = + let Ok(Some(notification::BodyRef::TransportSctpStateChangeNotification(body))) = notification.body() else { panic!("Wrong message from worker: {notification:?}"); @@ -556,7 +556,7 @@ impl TransportGeneric for PipeTransport { async fn dump(&self) -> Result { debug!("dump()"); - if let response::Body::FbsPipeTransportDumpResponse(data) = self.dump_impl().await? { + if let response::Body::PipeTransportDumpResponse(data) = self.dump_impl().await? { Ok(PipeTransportDump::from_fbs(*data).expect("Error parsing dump response")) } else { panic!("Wrong message from worker"); @@ -566,9 +566,7 @@ impl TransportGeneric for PipeTransport { async fn get_stats(&self) -> Result, RequestError> { debug!("get_stats()"); - if let response::Body::FbsPipeTransportGetStatsResponse(data) = - self.get_stats_impl().await? - { + if let response::Body::PipeTransportGetStatsResponse(data) = self.get_stats_impl().await? { Ok(vec![ PipeTransportStat::from_fbs(*data).expect("Error parsing dump response") ]) diff --git a/rust/src/router/plain_transport.rs b/rust/src/router/plain_transport.rs index 0596867066..cb38ff5b7a 100644 --- a/rust/src/router/plain_transport.rs +++ b/rust/src/router/plain_transport.rs @@ -346,7 +346,8 @@ impl Notification { ) -> Result { match notification.event().unwrap() { notification::Event::PlaintransportTuple => { - let Ok(Some(notification::BodyRef::TupleNotification(body))) = notification.body() + let Ok(Some(notification::BodyRef::PlainTransportTupleNotification(body))) = + notification.body() else { panic!("Wrong message from worker: {notification:?}"); }; @@ -357,7 +358,7 @@ impl Notification { Ok(Notification::Tuple { tuple }) } notification::Event::PlaintransportRtcpTuple => { - let Ok(Some(notification::BodyRef::RtcpTupleNotification(body))) = + let Ok(Some(notification::BodyRef::PlainTransportRtcpTupleNotification(body))) = notification.body() else { panic!("Wrong message from worker: {notification:?}"); @@ -369,7 +370,7 @@ impl Notification { Ok(Notification::RtcpTuple { rtcp_tuple }) } notification::Event::TransportSctpStateChange => { - let Ok(Some(notification::BodyRef::SctpStateChangeNotification(body))) = + let Ok(Some(notification::BodyRef::TransportSctpStateChangeNotification(body))) = notification.body() else { panic!("Wrong message from worker: {notification:?}"); @@ -395,6 +396,7 @@ impl Notification { } } } + struct Inner { id: TransportId, next_mid_for_consumers: AtomicUsize, @@ -620,7 +622,7 @@ impl TransportGeneric for PlainTransport { async fn dump(&self) -> Result { debug!("dump()"); - if let response::Body::FbsPlainTransportDumpResponse(data) = self.dump_impl().await? { + if let response::Body::PlainTransportDumpResponse(data) = self.dump_impl().await? { Ok(PlainTransportDump::from_fbs(*data).expect("Error parsing dump response")) } else { panic!("Wrong message from worker"); @@ -630,9 +632,7 @@ impl TransportGeneric for PlainTransport { async fn get_stats(&self) -> Result, RequestError> { debug!("get_stats()"); - if let response::Body::FbsPlainTransportGetStatsResponse(data) = - self.get_stats_impl().await? - { + if let response::Body::PlainTransportGetStatsResponse(data) = self.get_stats_impl().await? { Ok(vec![ PlainTransportStat::from_fbs(*data).expect("Error parsing dump response") ]) diff --git a/rust/src/router/webrtc_transport.rs b/rust/src/router/webrtc_transport.rs index 8f3dd496d2..293050a953 100644 --- a/rust/src/router/webrtc_transport.rs +++ b/rust/src/router/webrtc_transport.rs @@ -412,8 +412,9 @@ impl Notification { ) -> Result { match notification.event().unwrap() { notification::Event::WebrtctransportIceStateChange => { - let Ok(Some(notification::BodyRef::IceStateChangeNotification(body))) = - notification.body() + let Ok(Some(notification::BodyRef::WebRtcTransportIceStateChangeNotification( + body, + ))) = notification.body() else { panic!("Wrong message from worker: {notification:?}"); }; @@ -423,8 +424,9 @@ impl Notification { Ok(Notification::IceStateChange { ice_state }) } notification::Event::WebrtctransportIceSelectedTupleChange => { - let Ok(Some(notification::BodyRef::IceSelectedTupleChangeNotification(body))) = - notification.body() + let Ok(Some( + notification::BodyRef::WebRtcTransportIceSelectedTupleChangeNotification(body), + )) = notification.body() else { panic!("Wrong message from worker: {notification:?}"); }; @@ -436,8 +438,9 @@ impl Notification { Ok(Notification::IceSelectedTupleChange { ice_selected_tuple }) } notification::Event::WebrtctransportDtlsStateChange => { - let Ok(Some(notification::BodyRef::DtlsStateChangeNotification(body))) = - notification.body() + let Ok(Some(notification::BodyRef::WebRtcTransportDtlsStateChangeNotification( + body, + ))) = notification.body() else { panic!("Wrong message from worker: {notification:?}"); }; @@ -450,7 +453,7 @@ impl Notification { }) } notification::Event::TransportSctpStateChange => { - let Ok(Some(notification::BodyRef::SctpStateChangeNotification(body))) = + let Ok(Some(notification::BodyRef::TransportSctpStateChangeNotification(body))) = notification.body() else { panic!("Wrong message from worker: {notification:?}"); @@ -713,7 +716,7 @@ impl TransportGeneric for WebRtcTransport { async fn dump(&self) -> Result { debug!("dump()"); - if let response::Body::FbsWebRtcTransportDumpResponse(data) = self.dump_impl().await? { + if let response::Body::WebRtcTransportDumpResponse(data) = self.dump_impl().await? { Ok(WebRtcTransportDump::from_fbs(*data).expect("Error parsing dump response")) } else { panic!("Wrong message from worker"); @@ -723,8 +726,7 @@ impl TransportGeneric for WebRtcTransport { async fn get_stats(&self) -> Result, RequestError> { debug!("get_stats()"); - if let response::Body::FbsWebRtcTransportGetStatsResponse(data) = - self.get_stats_impl().await? + if let response::Body::WebRtcTransportGetStatsResponse(data) = self.get_stats_impl().await? { Ok(vec![ WebRtcTransportStat::from_fbs(*data).expect("Error parsing dump response") diff --git a/rust/src/rtp_parameters.rs b/rust/src/rtp_parameters.rs index db0f6a8dc4..8af1a3a685 100644 --- a/rust/src/rtp_parameters.rs +++ b/rust/src/rtp_parameters.rs @@ -574,6 +574,73 @@ pub enum RtpHeaderExtensionUri { Unsupported, } +impl RtpHeaderExtensionUri { + pub(crate) fn to_fbs(self) -> rtp_parameters::RtpHeaderExtensionUri { + match self { + RtpHeaderExtensionUri::Mid => rtp_parameters::RtpHeaderExtensionUri::Mid, + RtpHeaderExtensionUri::RtpStreamId => { + rtp_parameters::RtpHeaderExtensionUri::RtpStreamId + } + RtpHeaderExtensionUri::RepairRtpStreamId => { + rtp_parameters::RtpHeaderExtensionUri::RepairRtpStreamId + } + RtpHeaderExtensionUri::FrameMarkingDraft07 => { + rtp_parameters::RtpHeaderExtensionUri::FrameMarkingDraft07 + } + RtpHeaderExtensionUri::FrameMarking => { + rtp_parameters::RtpHeaderExtensionUri::FrameMarking + } + RtpHeaderExtensionUri::AudioLevel => rtp_parameters::RtpHeaderExtensionUri::AudioLevel, + RtpHeaderExtensionUri::VideoOrientation => { + rtp_parameters::RtpHeaderExtensionUri::VideoOrientation + } + RtpHeaderExtensionUri::TimeOffset => rtp_parameters::RtpHeaderExtensionUri::TimeOffset, + RtpHeaderExtensionUri::TransportWideCcDraft01 => { + rtp_parameters::RtpHeaderExtensionUri::TransportWideCcDraft01 + } + RtpHeaderExtensionUri::AbsSendTime => { + rtp_parameters::RtpHeaderExtensionUri::AbsSendTime + } + RtpHeaderExtensionUri::AbsCaptureTime => { + rtp_parameters::RtpHeaderExtensionUri::AbsCaptureTime + } + RtpHeaderExtensionUri::Unsupported => panic!("Invalid RTP extension header URI"), + } + } + + pub(crate) fn from_fbs(uri: rtp_parameters::RtpHeaderExtensionUri) -> Self { + match uri { + rtp_parameters::RtpHeaderExtensionUri::Mid => RtpHeaderExtensionUri::Mid, + rtp_parameters::RtpHeaderExtensionUri::RtpStreamId => { + RtpHeaderExtensionUri::RtpStreamId + } + rtp_parameters::RtpHeaderExtensionUri::RepairRtpStreamId => { + RtpHeaderExtensionUri::RepairRtpStreamId + } + rtp_parameters::RtpHeaderExtensionUri::FrameMarkingDraft07 => { + RtpHeaderExtensionUri::FrameMarkingDraft07 + } + rtp_parameters::RtpHeaderExtensionUri::FrameMarking => { + RtpHeaderExtensionUri::FrameMarking + } + rtp_parameters::RtpHeaderExtensionUri::AudioLevel => RtpHeaderExtensionUri::AudioLevel, + rtp_parameters::RtpHeaderExtensionUri::VideoOrientation => { + RtpHeaderExtensionUri::VideoOrientation + } + rtp_parameters::RtpHeaderExtensionUri::TimeOffset => RtpHeaderExtensionUri::TimeOffset, + rtp_parameters::RtpHeaderExtensionUri::TransportWideCcDraft01 => { + RtpHeaderExtensionUri::TransportWideCcDraft01 + } + rtp_parameters::RtpHeaderExtensionUri::AbsSendTime => { + RtpHeaderExtensionUri::AbsSendTime + } + rtp_parameters::RtpHeaderExtensionUri::AbsCaptureTime => { + RtpHeaderExtensionUri::AbsCaptureTime + } + } + } +} + impl FromStr for RtpHeaderExtensionUri { type Err = RtpHeaderExtensionUriParseError; @@ -782,7 +849,7 @@ impl RtpParameters { .into_iter() .map(|header_extension_parameters| { Ok(RtpHeaderExtensionParameters { - uri: header_extension_parameters.uri.parse()?, + uri: RtpHeaderExtensionUri::from_fbs(header_extension_parameters.uri), id: u16::from(header_extension_parameters.id), encrypt: header_extension_parameters.encrypt, }) @@ -874,7 +941,7 @@ impl RtpParameters { .into_iter() .map( |header_extension_parameters| rtp_parameters::RtpHeaderExtensionParameters { - uri: header_extension_parameters.uri.as_str().to_string(), + uri: header_extension_parameters.uri.to_fbs(), id: header_extension_parameters.id as u8, encrypt: header_extension_parameters.encrypt, parameters: None, diff --git a/worker/fbs/activeSpeakerObserver.fbs b/worker/fbs/activeSpeakerObserver.fbs index 02c592eb41..e2de103fd4 100644 --- a/worker/fbs/activeSpeakerObserver.fbs +++ b/worker/fbs/activeSpeakerObserver.fbs @@ -1,11 +1,12 @@ namespace FBS.ActiveSpeakerObserver; table ActiveSpeakerObserverOptions { - interval:uint16; + interval: uint16; } // Notifications from Worker. table DominantSpeakerNotification { - producer_id:string (required); + producer_id: string (required); } + diff --git a/worker/fbs/audioLevelObserver.fbs b/worker/fbs/audioLevelObserver.fbs index 391e7225a3..1ce66e402b 100644 --- a/worker/fbs/audioLevelObserver.fbs +++ b/worker/fbs/audioLevelObserver.fbs @@ -1,18 +1,19 @@ namespace FBS.AudioLevelObserver; table AudioLevelObserverOptions { - max_entries:uint16; - threshold:int8; - interval:uint16; + max_entries: uint16; + threshold: int8; + interval: uint16; } // Notifications from Worker. table Volume { - producer_id:string (required); - volume:int8; + producer_id: string (required); + volume: int8; } table VolumesNotification { - volumes:[Volume] (required); + volumes: [Volume] (required); } + diff --git a/worker/fbs/common.fbs b/worker/fbs/common.fbs index 48c3ad18f6..4495033ab7 100644 --- a/worker/fbs/common.fbs +++ b/worker/fbs/common.fbs @@ -1,28 +1,27 @@ - namespace FBS.Common; table StringString { - key:string (required); - value:string (required); + key: string (required); + value: string (required); } table StringUint8 { - key:string (required); - value:uint8; + key: string (required); + value: uint8; } table Uint16String { - key:uint16; - value:string (required); + key: uint16; + value: string (required); } table Uint32String { - key:uint32; - value:string (required); + key: uint32; + value: string (required); } table StringStringArray { - key:string (required); - values:[string] (required); + key: string (required); + values: [string] (required); } diff --git a/worker/fbs/consumer.fbs b/worker/fbs/consumer.fbs index e926006407..afeada34d5 100644 --- a/worker/fbs/consumer.fbs +++ b/worker/fbs/consumer.fbs @@ -4,141 +4,152 @@ include "rtpStream.fbs"; namespace FBS.Consumer; table ConsumerLayers { - spatial_layer:int16; - temporal_layer:int16 = null; + spatial_layer: int16; + temporal_layer: int16 = null; } table ConsumerScore { - score:uint8; - producer_score:uint8; - producer_scores:[uint8]; + score: uint8; + producer_score: uint8; + producer_scores: [uint8]; } table SetPreferredLayersRequest { - preferred_layers:ConsumerLayers (required); + preferred_layers: ConsumerLayers (required); } table SetPreferredLayersResponse { - preferred_layers:ConsumerLayers; + preferred_layers: ConsumerLayers; } table SetPriorityRequest { - priority:uint8; + priority: uint8; } table SetPriorityResponse { - priority:uint8; + priority: uint8; } table EnableTraceEventRequest { - events:[string] (required); + events: [string] (required); } union DumpData { - SimpleConsumerDump, - SimulcastConsumerDump, - SvcConsumerDump, - PipeConsumerDump, + SimpleConsumerDump, + SimulcastConsumerDump, + SvcConsumerDump, + PipeConsumerDump, } table DumpResponse { - data: DumpData; - type:FBS.RtpParameters.Type; + data: DumpData; + type: FBS.RtpParameters.Type; } table BaseConsumerDump { - id:string (required); - producer_id:string (required); - kind:FBS.RtpParameters.MediaKind; - rtp_parameters:FBS.RtpParameters.RtpParameters (required); - consumable_rtp_encodings:[FBS.RtpParameters.RtpEncodingParameters]; - supported_codec_payload_types:[uint8]; - trace_event_types:[string] (required); - paused:bool; - producer_paused:bool; - priority:uint8; + id: string (required); + producer_id: string (required); + kind: FBS.RtpParameters.MediaKind; + rtp_parameters: FBS.RtpParameters.RtpParameters (required); + consumable_rtp_encodings: [FBS.RtpParameters.RtpEncodingParameters]; + supported_codec_payload_types: [uint8]; + trace_event_types: [string] (required); + paused: bool; + producer_paused: bool; + priority: uint8; } table SimpleConsumerDump { - base:BaseConsumerDump (required); - rtp_stream:FBS.RtpStream.Dump (required); + base: BaseConsumerDump (required); + rtp_stream: FBS.RtpStream.Dump (required); } table SimulcastConsumerDump { - base:BaseConsumerDump (required); - rtp_stream:FBS.RtpStream.Dump (required); - preferred_spatial_layer:int16; - target_spatial_layer:int16; - current_spatial_layer:int16; - preferred_temporal_layer:int16; - target_temporal_layer:int16; - current_temporal_layer:int16; + base: BaseConsumerDump (required); + rtp_stream: FBS.RtpStream.Dump (required); + preferred_spatial_layer: int16; + target_spatial_layer: int16; + current_spatial_layer: int16; + preferred_temporal_layer: int16; + target_temporal_layer: int16; + current_temporal_layer: int16; } table SvcConsumerDump { - base:BaseConsumerDump (required); - rtp_stream:FBS.RtpStream.Dump (required); - preferred_spatial_layer:int16; - target_spatial_layer:int16; - current_spatial_layer:int16; - preferred_temporal_layer:int16; - target_temporal_layer:int16; - current_temporal_layer:int16; + base: BaseConsumerDump (required); + rtp_stream: FBS.RtpStream.Dump (required); + preferred_spatial_layer: int16; + target_spatial_layer: int16; + current_spatial_layer: int16; + preferred_temporal_layer: int16; + target_temporal_layer: int16; + current_temporal_layer: int16; } table PipeConsumerDump { - base:BaseConsumerDump (required); - rtp_streams:[FBS.RtpStream.Dump] (required); + base: BaseConsumerDump (required); + rtp_streams: [FBS.RtpStream.Dump] (required); } table GetStatsResponse { - stats:[FBS.RtpStream.Stats]; + stats: [FBS.RtpStream.Stats]; } // Notifications from Worker. table LayersChangeNotification { - layers:ConsumerLayers; + layers: ConsumerLayers; } table RtpNotification { - data:[ubyte] (required); + data: [ubyte] (required); } table ScoreNotification { - score:ConsumerScore (required); + score: ConsumerScore (required); +} + +enum TraceType: uint8 { + KEYFRAME = 0, + FIR, + NACK, + PLI, + RTP, } -enum TraceType: uint8 { KEYFRAME = 0, FIR, NACK, PLI, RTP, } // NOTE (windows): IN|OUT are macros defined in windef.h. -enum TraceDirection: uint8 { DIRECTION_IN = 0, DIRECTION_OUT } +enum TraceDirection: uint8 { + DIRECTION_IN = 0, + DIRECTION_OUT +} union TraceInfo { - KeyFrameTraceInfo, - FirTraceInfo, - PliTraceInfo, - RtpTraceInfo, + KeyFrameTraceInfo, + FirTraceInfo, + PliTraceInfo, + RtpTraceInfo, } table KeyFrameTraceInfo { - is_rtx:bool; + is_rtx: bool; } table FirTraceInfo { - ssrc:uint32; + ssrc: uint32; } table PliTraceInfo { - ssrc:uint32; + ssrc: uint32; } table RtpTraceInfo { - is_rtx:bool; + is_rtx: bool; } table TraceNotification { - type: TraceType; - timestamp: uint64; - direction: TraceDirection; - info: TraceInfo; + type: TraceType; + timestamp: uint64; + direction: TraceDirection; + info: TraceInfo; } + diff --git a/worker/fbs/dataConsumer.fbs b/worker/fbs/dataConsumer.fbs index 89e29c6ad2..9121de7c84 100644 --- a/worker/fbs/dataConsumer.fbs +++ b/worker/fbs/dataConsumer.fbs @@ -4,67 +4,68 @@ include "sctpParameters.fbs"; namespace FBS.DataConsumer; table GetBufferedAmountResponse { - buffered_amount:uint32; + buffered_amount: uint32; } table SetBufferedAmountLowThresholdRequest { - threshold:uint32; + threshold: uint32; } table DumpResponse { - id:string (required); - data_producer_id:string (required); - type:string (required); - sctp_stream_parameters: FBS.SctpParameters.SctpStreamParameters; - label:string (required); - protocol:string (required); - paused:bool; - data_producer_paused:bool; - subchannels:[uint16]; + id: string (required); + data_producer_id: string (required); + type: string (required); + sctp_stream_parameters: FBS.SctpParameters.SctpStreamParameters; + label: string (required); + protocol: string (required); + paused: bool; + data_producer_paused: bool; + subchannels: [uint16]; } table GetStatsResponse { - timestamp:uint64; - label:string (required); - protocol:string (required); - messages_sent:uint64; - bytes_sent:uint64; - buffered_amount:uint32; + timestamp: uint64; + label: string (required); + protocol: string (required); + messages_sent: uint64; + bytes_sent: uint64; + buffered_amount: uint32; } table String { - value:string (required); + value: string (required); } table Binary { - value:[uint8] (required); + value: [uint8] (required); } union Data { - String, - Binary + String, + Binary } table SendRequest { - ppid:uint8; - data:Data (required); + ppid: uint8; + data: Data (required); } table SetSubchannelsRequest { - subchannels:[uint16]; + subchannels: [uint16]; } table SetSubchannelsResponse { - subchannels:[uint16]; + subchannels: [uint16]; } // Notifications from Worker. table BufferedAmountLowNotification { - buffered_amount:uint32; + buffered_amount: uint32; } table MessageNotification { - ppid:uint32; - data:[ubyte] (required); + ppid: uint32; + data: [ubyte] (required); } + diff --git a/worker/fbs/dataProducer.fbs b/worker/fbs/dataProducer.fbs index 5815733f28..658386d17c 100644 --- a/worker/fbs/dataProducer.fbs +++ b/worker/fbs/dataProducer.fbs @@ -3,39 +3,40 @@ include "sctpParameters.fbs"; namespace FBS.DataProducer; table DumpResponse { - id:string (required); - type:string (required); - sctp_stream_parameters: FBS.SctpParameters.SctpStreamParameters; - label:string (required); - protocol:string (required); - paused:bool; + id: string (required); + type: string (required); + sctp_stream_parameters: FBS.SctpParameters.SctpStreamParameters; + label: string (required); + protocol: string (required); + paused: bool; } table GetStatsResponse { - timestamp:uint64; - label:string (required); - protocol:string (required); - messages_received:uint64; - bytes_received:uint64; - buffered_amount:uint32; + timestamp: uint64; + label: string (required); + protocol: string (required); + messages_received: uint64; + bytes_received: uint64; + buffered_amount: uint32; } table String { - value:string (required); + value: string (required); } table Binary { - value:[uint8] (required); + value: [uint8] (required); } union Data { - String, - Binary + String, + Binary } table SendNotification { - ppid:uint8; - data:Data (required); - subchannels:[uint16]; - required_subchannel:uint16 = null; + ppid: uint8; + data: Data (required); + subchannels: [uint16]; + required_subchannel: uint16 = null; } + diff --git a/worker/fbs/directTransport.fbs b/worker/fbs/directTransport.fbs index 3ea467cebd..18894d086c 100644 --- a/worker/fbs/directTransport.fbs +++ b/worker/fbs/directTransport.fbs @@ -3,19 +3,20 @@ include "transport.fbs"; namespace FBS.DirectTransport; table DirectTransportOptions { - base:FBS.Transport.Options (required); + base: FBS.Transport.Options (required); } table DumpResponse { - base:FBS.Transport.Dump (required); + base: FBS.Transport.Dump (required); } table GetStatsResponse { - base:FBS.Transport.Stats (required); + base: FBS.Transport.Stats (required); } // Notifications from Worker. table RtcpNotification { - data:[ubyte] (required); + data: [ubyte] (required); } + diff --git a/worker/fbs/log.fbs b/worker/fbs/log.fbs index 2558db8eee..562fa58d35 100644 --- a/worker/fbs/log.fbs +++ b/worker/fbs/log.fbs @@ -1,6 +1,6 @@ - namespace FBS.Log; table Log { - data:string (required); + data: string (required); } + diff --git a/worker/fbs/message.fbs b/worker/fbs/message.fbs index 80fca0c762..0e01a809d6 100644 --- a/worker/fbs/message.fbs +++ b/worker/fbs/message.fbs @@ -5,23 +5,24 @@ include "response.fbs"; namespace FBS.Message; -enum Type : uint8 { - REQUEST = 0, - RESPONSE, - NOTIFICATION, - LOG, +enum Type: uint8 { + REQUEST = 0, + RESPONSE, + NOTIFICATION, + LOG, } union Body { - FBS.Request.Request, - FBS.Response.Response, - FBS.Notification.Notification, - FBS.Log.Log, + Request: FBS.Request.Request, + Response: FBS.Response.Response, + Notification: FBS.Notification.Notification, + Log: FBS.Log.Log, } table Message { - type:Type; - data:Body (required); + type: Type; + data: Body (required); } root_type Message; + diff --git a/worker/fbs/notification.fbs b/worker/fbs/notification.fbs index 5fb8316194..10725c1843 100644 --- a/worker/fbs/notification.fbs +++ b/worker/fbs/notification.fbs @@ -11,70 +11,73 @@ include "audioLevelObserver.fbs"; namespace FBS.Notification; enum Event: uint8 { - // Notifications to worker. - TRANSPORT_SEND_RTCP = 0, - PRODUCER_SEND, - DATAPRODUCER_SEND, - // Notifications from worker. - WORKER_RUNNING, - TRANSPORT_SCTP_STATE_CHANGE, - TRANSPORT_TRACE, - WEBRTCTRANSPORT_ICE_SELECTED_TUPLE_CHANGE, - WEBRTCTRANSPORT_ICE_STATE_CHANGE, - WEBRTCTRANSPORT_DTLS_STATE_CHANGE, - PLAINTRANSPORT_TUPLE, - PLAINTRANSPORT_RTCP_TUPLE, - DIRECTTRANSPORT_RTCP, - PRODUCER_SCORE, - PRODUCER_TRACE, - PRODUCER_VIDEO_ORIENTATION_CHANGE, - CONSUMER_PRODUCER_PAUSE, - CONSUMER_PRODUCER_RESUME, - CONSUMER_PRODUCER_CLOSE, - CONSUMER_LAYERS_CHANGE, - CONSUMER_RTP, - CONSUMER_SCORE, - CONSUMER_TRACE, - DATACONSUMER_BUFFERED_AMOUNT_LOW, - DATACONSUMER_SCTP_SENDBUFFER_FULL, - DATACONSUMER_DATAPRODUCER_PAUSE, - DATACONSUMER_DATAPRODUCER_RESUME, - DATACONSUMER_DATAPRODUCER_CLOSE, - DATACONSUMER_MESSAGE, - ACTIVESPEAKEROBSERVER_DOMINANT_SPEAKER, - AUDIOLEVELOBSERVER_SILENCE, - AUDIOLEVELOBSERVER_VOLUMES, + // Notifications to worker. + TRANSPORT_SEND_RTCP = 0, + PRODUCER_SEND, + DATAPRODUCER_SEND, + + // Notifications from worker. + WORKER_RUNNING, + TRANSPORT_SCTP_STATE_CHANGE, + TRANSPORT_TRACE, + WEBRTCTRANSPORT_ICE_SELECTED_TUPLE_CHANGE, + WEBRTCTRANSPORT_ICE_STATE_CHANGE, + WEBRTCTRANSPORT_DTLS_STATE_CHANGE, + PLAINTRANSPORT_TUPLE, + PLAINTRANSPORT_RTCP_TUPLE, + DIRECTTRANSPORT_RTCP, + PRODUCER_SCORE, + PRODUCER_TRACE, + PRODUCER_VIDEO_ORIENTATION_CHANGE, + CONSUMER_PRODUCER_PAUSE, + CONSUMER_PRODUCER_RESUME, + CONSUMER_PRODUCER_CLOSE, + CONSUMER_LAYERS_CHANGE, + CONSUMER_RTP, + CONSUMER_SCORE, + CONSUMER_TRACE, + DATACONSUMER_BUFFERED_AMOUNT_LOW, + DATACONSUMER_SCTP_SENDBUFFER_FULL, + DATACONSUMER_DATAPRODUCER_PAUSE, + DATACONSUMER_DATAPRODUCER_RESUME, + DATACONSUMER_DATAPRODUCER_CLOSE, + DATACONSUMER_MESSAGE, + ACTIVESPEAKEROBSERVER_DOMINANT_SPEAKER, + AUDIOLEVELOBSERVER_SILENCE, + AUDIOLEVELOBSERVER_VOLUMES, } union Body { - // Notifications to worker. - FBS.Transport.SendRtcpNotification, - FBS.Transport.SctpStateChangeNotification, - FBS.Producer.SendNotification, - FBS.DataProducer.SendNotification, - // Notifications from worker. - Transport_TraceNotification: FBS.Transport.TraceNotification, - FBS.WebRtcTransport.IceSelectedTupleChangeNotification, - FBS.WebRtcTransport.IceStateChangeNotification, - FBS.WebRtcTransport.DtlsStateChangeNotification, - FBS.PlainTransport.TupleNotification, - FBS.PlainTransport.RtcpTupleNotification, - FBS.DirectTransport.RtcpNotification, - FBS.Producer.ScoreNotification, - Producer_TraceNotification: FBS.Producer.TraceNotification, - FBS.Producer.VideoOrientationChangeNotification, - FBS.Consumer.LayersChangeNotification, - FBS.Consumer.RtpNotification, - FBS.Consumer.ScoreNotification, - Consumer_TraceNotification: FBS.Consumer.TraceNotification, - FBS.DataConsumer.MessageNotification, - FBS.DataConsumer.BufferedAmountLowNotification, - FBS.ActiveSpeakerObserver.DominantSpeakerNotification, - FBS.AudioLevelObserver.VolumesNotification, + // Notifications to worker. + Transport_SendRtcpNotification: FBS.Transport.SendRtcpNotification, + Transport_SctpStateChangeNotification: FBS.Transport.SctpStateChangeNotification, + Producer_SendNotification: FBS.Producer.SendNotification, + DataProducer_SendNotification: FBS.DataProducer.SendNotification, + + // Notifications from worker. + Transport_TraceNotification: FBS.Transport.TraceNotification, + WebRtcTransport_IceSelectedTupleChangeNotification: FBS.WebRtcTransport.IceSelectedTupleChangeNotification, + WebRtcTransport_IceStateChangeNotification: FBS.WebRtcTransport.IceStateChangeNotification, + WebRtcTransport_DtlsStateChangeNotification: FBS.WebRtcTransport.DtlsStateChangeNotification, + PlainTransport_TupleNotification: FBS.PlainTransport.TupleNotification, + PlainTransport_RtcpTupleNotification: FBS.PlainTransport.RtcpTupleNotification, + DirectTransport_RtcpNotification: FBS.DirectTransport.RtcpNotification, + Producer_ScoreNotification: FBS.Producer.ScoreNotification, + Producer_TraceNotification: FBS.Producer.TraceNotification, + Producer_VideoOrientationChangeNotification: FBS.Producer.VideoOrientationChangeNotification, + Consumer_LayersChangeNotification: FBS.Consumer.LayersChangeNotification, + Consumer_RtpNotification: FBS.Consumer.RtpNotification, + Consumer_ScoreNotification: FBS.Consumer.ScoreNotification, + Consumer_TraceNotification: FBS.Consumer.TraceNotification, + DataConsumer_MessageNotification: FBS.DataConsumer.MessageNotification, + DataConsumer_BufferedAmountLowNotification: FBS.DataConsumer.BufferedAmountLowNotification, + ActiveSpeakerObserver_DominantSpeakerNotification: FBS.ActiveSpeakerObserver.DominantSpeakerNotification, + AudioLevelObserver_VolumesNotification: FBS.AudioLevelObserver.VolumesNotification, } table Notification { - handler_id:string (required); - event:Event; - body:Body; + handler_id: string (required); + event: Event; + body: Body; } + diff --git a/worker/fbs/pipeTransport.fbs b/worker/fbs/pipeTransport.fbs index 13c548d008..6d86b9dce6 100644 --- a/worker/fbs/pipeTransport.fbs +++ b/worker/fbs/pipeTransport.fbs @@ -4,30 +4,31 @@ include "srtpParameters.fbs"; namespace FBS.PipeTransport; table PipeTransportOptions { - base:FBS.Transport.Options (required); - listen_info:FBS.Transport.ListenInfo (required); - enable_rtx:bool; - enable_srtp:bool; + base: FBS.Transport.Options (required); + listen_info: FBS.Transport.ListenInfo (required); + enable_rtx: bool; + enable_srtp: bool; } table ConnectRequest { - ip:string (required); - port:uint16 = null; - srtp_parameters:FBS.SrtpParameters.SrtpParameters; + ip: string (required); + port: uint16 = null; + srtp_parameters: FBS.SrtpParameters.SrtpParameters; } table ConnectResponse { - tuple:FBS.Transport.Tuple (required); + tuple: FBS.Transport.Tuple (required); } table DumpResponse { - base:FBS.Transport.Dump (required); - tuple:FBS.Transport.Tuple (required); - rtx:bool; - srtp_parameters:FBS.SrtpParameters.SrtpParameters; + base: FBS.Transport.Dump (required); + tuple: FBS.Transport.Tuple (required); + rtx: bool; + srtp_parameters: FBS.SrtpParameters.SrtpParameters; } table GetStatsResponse { - base:FBS.Transport.Stats (required); - tuple:FBS.Transport.Tuple (required); + base: FBS.Transport.Stats (required); + tuple: FBS.Transport.Tuple (required); } + diff --git a/worker/fbs/plainTransport.fbs b/worker/fbs/plainTransport.fbs index 9d51a9af9d..670443e721 100644 --- a/worker/fbs/plainTransport.fbs +++ b/worker/fbs/plainTransport.fbs @@ -5,51 +5,52 @@ include "srtpParameters.fbs"; namespace FBS.PlainTransport; table PlainTransportOptions { - base:FBS.Transport.Options (required); - listen_info:FBS.Transport.ListenInfo (required); - rtcp_listen_info:FBS.Transport.ListenInfo; - rtcp_mux:bool; - comedia:bool; - enable_srtp:bool; - srtp_crypto_suite:FBS.SrtpParameters.SrtpCryptoSuite = null; + base: FBS.Transport.Options (required); + listen_info: FBS.Transport.ListenInfo (required); + rtcp_listen_info: FBS.Transport.ListenInfo; + rtcp_mux: bool; + comedia: bool; + enable_srtp: bool; + srtp_crypto_suite: FBS.SrtpParameters.SrtpCryptoSuite = null; } table ConnectRequest { - ip:string; - port:uint16 = null; - rtcp_port:uint16 = null; - srtp_parameters:FBS.SrtpParameters.SrtpParameters; + ip: string; + port: uint16 = null; + rtcp_port: uint16 = null; + srtp_parameters: FBS.SrtpParameters.SrtpParameters; } table ConnectResponse { - tuple:FBS.Transport.Tuple (required); - rtcp_tuple:FBS.Transport.Tuple; - srtp_parameters:FBS.SrtpParameters.SrtpParameters; + tuple: FBS.Transport.Tuple (required); + rtcp_tuple: FBS.Transport.Tuple; + srtp_parameters: FBS.SrtpParameters.SrtpParameters; } table DumpResponse { - base:FBS.Transport.Dump (required); - rtcp_mux:bool; - comedia:bool; - tuple:FBS.Transport.Tuple (required); - rtcp_tuple:FBS.Transport.Tuple; - srtp_parameters:FBS.SrtpParameters.SrtpParameters; + base: FBS.Transport.Dump (required); + rtcp_mux: bool; + comedia: bool; + tuple: FBS.Transport.Tuple (required); + rtcp_tuple: FBS.Transport.Tuple; + srtp_parameters: FBS.SrtpParameters.SrtpParameters; } table GetStatsResponse { - base:FBS.Transport.Stats (required); - rtcp_mux:bool; - comedia:bool; - tuple:FBS.Transport.Tuple (required); - rtcp_tuple:FBS.Transport.Tuple; + base: FBS.Transport.Stats (required); + rtcp_mux: bool; + comedia: bool; + tuple: FBS.Transport.Tuple (required); + rtcp_tuple: FBS.Transport.Tuple; } // Notifications from Worker. table TupleNotification { - tuple:FBS.Transport.Tuple (required); + tuple: FBS.Transport.Tuple (required); } table RtcpTupleNotification { - tuple:FBS.Transport.Tuple (required); + tuple: FBS.Transport.Tuple (required); } + diff --git a/worker/fbs/producer.fbs b/worker/fbs/producer.fbs index b59813c672..28babc677f 100644 --- a/worker/fbs/producer.fbs +++ b/worker/fbs/producer.fbs @@ -4,76 +4,87 @@ include "rtpStream.fbs"; namespace FBS.Producer; table EnableTraceEventRequest { - events:[string] (required); + events: [string] (required); } table DumpResponse { - id:string (required); - kind:FBS.RtpParameters.MediaKind; - type:string (required); - rtp_parameters:FBS.RtpParameters.RtpParameters (required); - rtp_mapping:FBS.RtpParameters.RtpMapping (required); - rtp_streams:[FBS.RtpStream.Dump]; - trace_event_types:[string] (required); - paused:bool; + id: string (required); + kind: FBS.RtpParameters.MediaKind; + type: string (required); + rtp_parameters: FBS.RtpParameters.RtpParameters (required); + rtp_mapping: FBS.RtpParameters.RtpMapping (required); + rtp_streams: [FBS.RtpStream.Dump]; + trace_event_types: [string] (required); + paused: bool; } table GetStatsResponse { - stats:[FBS.RtpStream.Stats]; + stats: [FBS.RtpStream.Stats]; } table SendNotification { - data:[uint8] (required); + data: [uint8] (required); } // Notifications from Worker. table Score { - ssrc:uint32; - rid:string; - score:uint8; + ssrc: uint32; + rid: string; + score: uint8; } table ScoreNotification { - scores:[Score]; + scores: [Score]; } table VideoOrientationChangeNotification { - camera:bool; - flip:bool; - rotation:uint16; + camera: bool; + flip: bool; + rotation: uint16; +} + +enum TraceType: uint8 { + KEYFRAME = 0, + FIR, + NACK, + PLI, + RTP, } -enum TraceType: uint8 { KEYFRAME = 0, FIR, NACK, PLI, RTP, } // NOTE (windows): IN|OUT are macros defined in windef.h. -enum TraceDirection: uint8 { DIRECTION_IN = 0, DIRECTION_OUT } +enum TraceDirection: uint8 { + DIRECTION_IN = 0, + DIRECTION_OUT +} union TraceInfo { - KeyFrameTraceInfo, - FirTraceInfo, - PliTraceInfo, - RtpTraceInfo, + KeyFrameTraceInfo, + FirTraceInfo, + PliTraceInfo, + RtpTraceInfo, } table KeyFrameTraceInfo { - is_rtx:bool; + is_rtx: bool; } table FirTraceInfo { - ssrc:uint32; + ssrc: uint32; } table PliTraceInfo { - ssrc:uint32; + ssrc: uint32; } table RtpTraceInfo { - is_rtx:bool; + is_rtx: bool; } table TraceNotification { - type: TraceType; - timestamp: uint64; - direction: TraceDirection; - info: TraceInfo; + type: TraceType; + timestamp: uint64; + direction: TraceDirection; + info: TraceInfo; } + diff --git a/worker/fbs/request.fbs b/worker/fbs/request.fbs index da6fdf8a21..56eca5674d 100644 --- a/worker/fbs/request.fbs +++ b/worker/fbs/request.fbs @@ -9,120 +9,121 @@ include "rtpObserver.fbs"; namespace FBS.Request; enum Method: uint8 { - WORKER_CLOSE = 0, - WORKER_DUMP, - WORKER_GET_RESOURCE_USAGE, - WORKER_UPDATE_SETTINGS, - WORKER_CREATE_WEBRTCSERVER, - WORKER_CREATE_ROUTER, - WORKER_WEBRTCSERVER_CLOSE, - WORKER_CLOSE_ROUTER, - WEBRTCSERVER_DUMP, - ROUTER_DUMP, - ROUTER_CREATE_WEBRTCTRANSPORT, - ROUTER_CREATE_WEBRTCTRANSPORT_WITH_SERVER, - ROUTER_CREATE_PLAINTRANSPORT, - ROUTER_CREATE_PIPETRANSPORT, - ROUTER_CREATE_DIRECTTRANSPORT, - ROUTER_CLOSE_TRANSPORT, - ROUTER_CREATE_ACTIVESPEAKEROBSERVER, - ROUTER_CREATE_AUDIOLEVELOBSERVER, - ROUTER_CLOSE_RTPOBSERVER, - TRANSPORT_DUMP, - TRANSPORT_GET_STATS, - TRANSPORT_CONNECT, - TRANSPORT_SET_MAX_INCOMING_BITRATE, - TRANSPORT_SET_MAX_OUTGOING_BITRATE, - TRANSPORT_SET_MIN_OUTGOING_BITRATE, - TRANSPORT_RESTART_ICE, - TRANSPORT_PRODUCE, - TRANSPORT_PRODUCE_DATA, - TRANSPORT_CONSUME, - TRANSPORT_CONSUME_DATA, - TRANSPORT_ENABLE_TRACE_EVENT, - TRANSPORT_CLOSE_PRODUCER, - TRANSPORT_CLOSE_CONSUMER, - TRANSPORT_CLOSE_DATAPRODUCER, - TRANSPORT_CLOSE_DATACONSUMER, - PLAINTRANSPORT_CONNECT, - PIPETRANSPORT_CONNECT, - WEBRTCTRANSPORT_CONNECT, - PRODUCER_DUMP, - PRODUCER_GET_STATS, - PRODUCER_PAUSE, - PRODUCER_RESUME, - PRODUCER_ENABLE_TRACE_EVENT, - CONSUMER_DUMP, - CONSUMER_GET_STATS, - CONSUMER_PAUSE, - CONSUMER_RESUME, - CONSUMER_SET_PREFERRED_LAYERS, - CONSUMER_SET_PRIORITY, - CONSUMER_REQUEST_KEY_FRAME, - CONSUMER_ENABLE_TRACE_EVENT, - DATAPRODUCER_DUMP, - DATAPRODUCER_GET_STATS, - DATAPRODUCER_PAUSE, - DATAPRODUCER_RESUME, - DATACONSUMER_DUMP, - DATACONSUMER_GET_STATS, - DATACONSUMER_PAUSE, - DATACONSUMER_RESUME, - DATACONSUMER_GET_BUFFERED_AMOUNT, - DATACONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, - DATACONSUMER_SEND, - DATACONSUMER_SET_SUBCHANNELS, - RTPOBSERVER_PAUSE, - RTPOBSERVER_RESUME, - RTPOBSERVER_ADD_PRODUCER, - RTPOBSERVER_REMOVE_PRODUCER, + WORKER_CLOSE = 0, + WORKER_DUMP, + WORKER_GET_RESOURCE_USAGE, + WORKER_UPDATE_SETTINGS, + WORKER_CREATE_WEBRTCSERVER, + WORKER_CREATE_ROUTER, + WORKER_WEBRTCSERVER_CLOSE, + WORKER_CLOSE_ROUTER, + WEBRTCSERVER_DUMP, + ROUTER_DUMP, + ROUTER_CREATE_WEBRTCTRANSPORT, + ROUTER_CREATE_WEBRTCTRANSPORT_WITH_SERVER, + ROUTER_CREATE_PLAINTRANSPORT, + ROUTER_CREATE_PIPETRANSPORT, + ROUTER_CREATE_DIRECTTRANSPORT, + ROUTER_CLOSE_TRANSPORT, + ROUTER_CREATE_ACTIVESPEAKEROBSERVER, + ROUTER_CREATE_AUDIOLEVELOBSERVER, + ROUTER_CLOSE_RTPOBSERVER, + TRANSPORT_DUMP, + TRANSPORT_GET_STATS, + TRANSPORT_CONNECT, + TRANSPORT_SET_MAX_INCOMING_BITRATE, + TRANSPORT_SET_MAX_OUTGOING_BITRATE, + TRANSPORT_SET_MIN_OUTGOING_BITRATE, + TRANSPORT_RESTART_ICE, + TRANSPORT_PRODUCE, + TRANSPORT_PRODUCE_DATA, + TRANSPORT_CONSUME, + TRANSPORT_CONSUME_DATA, + TRANSPORT_ENABLE_TRACE_EVENT, + TRANSPORT_CLOSE_PRODUCER, + TRANSPORT_CLOSE_CONSUMER, + TRANSPORT_CLOSE_DATAPRODUCER, + TRANSPORT_CLOSE_DATACONSUMER, + PLAINTRANSPORT_CONNECT, + PIPETRANSPORT_CONNECT, + WEBRTCTRANSPORT_CONNECT, + PRODUCER_DUMP, + PRODUCER_GET_STATS, + PRODUCER_PAUSE, + PRODUCER_RESUME, + PRODUCER_ENABLE_TRACE_EVENT, + CONSUMER_DUMP, + CONSUMER_GET_STATS, + CONSUMER_PAUSE, + CONSUMER_RESUME, + CONSUMER_SET_PREFERRED_LAYERS, + CONSUMER_SET_PRIORITY, + CONSUMER_REQUEST_KEY_FRAME, + CONSUMER_ENABLE_TRACE_EVENT, + DATAPRODUCER_DUMP, + DATAPRODUCER_GET_STATS, + DATAPRODUCER_PAUSE, + DATAPRODUCER_RESUME, + DATACONSUMER_DUMP, + DATACONSUMER_GET_STATS, + DATACONSUMER_PAUSE, + DATACONSUMER_RESUME, + DATACONSUMER_GET_BUFFERED_AMOUNT, + DATACONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD, + DATACONSUMER_SEND, + DATACONSUMER_SET_SUBCHANNELS, + RTPOBSERVER_PAUSE, + RTPOBSERVER_RESUME, + RTPOBSERVER_ADD_PRODUCER, + RTPOBSERVER_REMOVE_PRODUCER, } union Body { - FBS.Worker.UpdateSettingsRequest, - FBS.Worker.CreateWebRtcServerRequest, - FBS.Worker.CloseWebRtcServerRequest, - FBS.Worker.CreateRouterRequest, - FBS.Worker.CloseRouterRequest, - FBS.Router.CreateWebRtcTransportRequest, - FBS.Router.CreatePlainTransportRequest, - FBS.Router.CreatePipeTransportRequest, - FBS.Router.CreateDirectTransportRequest, - FBS.Router.CreateActiveSpeakerObserverRequest, - FBS.Router.CreateAudioLevelObserverRequest, - FBS.Router.CloseTransportRequest, - FBS.Router.CloseRtpObserverRequest, - FBS.Transport.SetMaxIncomingBitrateRequest, - FBS.Transport.SetMaxOutgoingBitrateRequest, - FBS.Transport.SetMinOutgoingBitrateRequest, - FBS.Transport.ProduceRequest, - FBS.Transport.ConsumeRequest, - FBS.Transport.ProduceDataRequest, - FBS.Transport.ConsumeDataRequest, - Transport_EnableTraceEventRequest: FBS.Transport.EnableTraceEventRequest, - FBS.Transport.CloseProducerRequest, - FBS.Transport.CloseConsumerRequest, - FBS.Transport.CloseDataProducerRequest, - FBS.Transport.CloseDataConsumerRequest, - PlainTransport_ConnectRequest: FBS.PlainTransport.ConnectRequest, - PipeTransport_ConnectRequest: FBS.PipeTransport.ConnectRequest, - WebRtcTransport_ConnectRequest: FBS.WebRtcTransport.ConnectRequest, - Producer_EnableTraceEventRequest: FBS.Producer.EnableTraceEventRequest, - FBS.Consumer.SetPreferredLayersRequest, - FBS.Consumer.SetPriorityRequest, - Consumer_EnableTraceEventRequest: FBS.Consumer.EnableTraceEventRequest, - FBS.DataConsumer.SetBufferedAmountLowThresholdRequest, - FBS.DataConsumer.SendRequest, - FBS.DataConsumer.SetSubchannelsRequest, - FBS.RtpObserver.AddProducerRequest, - FBS.RtpObserver.RemoveProducerRequest, + Worker_UpdateSettingsRequest: FBS.Worker.UpdateSettingsRequest, + Worker_CreateWebRtcServerRequest: FBS.Worker.CreateWebRtcServerRequest, + Worker_CloseWebRtcServerRequest: FBS.Worker.CloseWebRtcServerRequest, + Worker_CreateRouterRequest: FBS.Worker.CreateRouterRequest, + Worker_CloseRouterRequest: FBS.Worker.CloseRouterRequest, + Router_CreateWebRtcTransportRequest: FBS.Router.CreateWebRtcTransportRequest, + Router_CreatePlainTransportRequest: FBS.Router.CreatePlainTransportRequest, + Router_CreatePipeTransportRequest: FBS.Router.CreatePipeTransportRequest, + Router_CreateDirectTransportRequest: FBS.Router.CreateDirectTransportRequest, + Router_CreateActiveSpeakerObserverRequest: FBS.Router.CreateActiveSpeakerObserverRequest, + Router_CreateAudioLevelObserverRequest: FBS.Router.CreateAudioLevelObserverRequest, + Router_CloseTransportRequest: FBS.Router.CloseTransportRequest, + Router_CloseRtpObserverRequest: FBS.Router.CloseRtpObserverRequest, + Transport_SetMaxIncomingBitrateRequest: FBS.Transport.SetMaxIncomingBitrateRequest, + Transport_SetMaxOutgoingBitrateRequest: FBS.Transport.SetMaxOutgoingBitrateRequest, + Transport_SetMinOutgoingBitrateRequest: FBS.Transport.SetMinOutgoingBitrateRequest, + Transport_ProduceRequest: FBS.Transport.ProduceRequest, + Transport_ConsumeRequest: FBS.Transport.ConsumeRequest, + Transport_ProduceDataRequest: FBS.Transport.ProduceDataRequest, + Transport_ConsumeDataRequest: FBS.Transport.ConsumeDataRequest, + Transport_EnableTraceEventRequest: FBS.Transport.EnableTraceEventRequest, + Transport_CloseProducerRequest: FBS.Transport.CloseProducerRequest, + Transport_CloseConsumerRequest: FBS.Transport.CloseConsumerRequest, + Transport_CloseDataProducerRequest: FBS.Transport.CloseDataProducerRequest, + Transport_CloseDataConsumerRequest: FBS.Transport.CloseDataConsumerRequest, + PlainTransport_ConnectRequest: FBS.PlainTransport.ConnectRequest, + PipeTransport_ConnectRequest: FBS.PipeTransport.ConnectRequest, + WebRtcTransport_ConnectRequest: FBS.WebRtcTransport.ConnectRequest, + Producer_EnableTraceEventRequest: FBS.Producer.EnableTraceEventRequest, + Consumer_SetPreferredLayersRequest: FBS.Consumer.SetPreferredLayersRequest, + Consumer_SetPriorityRequest: FBS.Consumer.SetPriorityRequest, + Consumer_EnableTraceEventRequest: FBS.Consumer.EnableTraceEventRequest, + DataConsumer_SetBufferedAmountLowThresholdRequest: FBS.DataConsumer.SetBufferedAmountLowThresholdRequest, + DataConsumer_SendRequest: FBS.DataConsumer.SendRequest, + DataConsumer_SetSubchannelsRequest: FBS.DataConsumer.SetSubchannelsRequest, + RtpObserver_AddProducerRequest: FBS.RtpObserver.AddProducerRequest, + RtpObserver_RemoveProducerRequest: FBS.RtpObserver.RemoveProducerRequest, } table Request { - id:uint32; - method:Method; - handler_id:string (required); - body:Body; + id: uint32; + method: Method; + handler_id: string (required); + body: Body; } root_type Request; + diff --git a/worker/fbs/response.fbs b/worker/fbs/response.fbs index 41e8cbe422..539d36a72a 100644 --- a/worker/fbs/response.fbs +++ b/worker/fbs/response.fbs @@ -10,42 +10,43 @@ include "dataConsumer.fbs"; namespace FBS.Response; union Body { - FBS_Worker_DumpResponse: FBS.Worker.DumpResponse, - FBS_Worker_ResourceUsageResponse: FBS.Worker.ResourceUsageResponse, - FBS_WebRtcServer_DumpResponse: FBS.WebRtcServer.DumpResponse, - FBS_Router_DumpResponse: FBS.Router.DumpResponse, - FBS_Transport_ProduceResponse: FBS.Transport.ProduceResponse, - FBS_Transport_ConsumeResponse: FBS.Transport.ConsumeResponse, - FBS_Transport_RestartIceResponse: FBS.Transport.RestartIceResponse, - FBS_PlainTransport_ConnectResponse: FBS.PlainTransport.ConnectResponse, - FBS_PlainTransport_DumpResponse: FBS.PlainTransport.DumpResponse, - FBS_PlainTransport_GetStatsResponse: FBS.PlainTransport.GetStatsResponse, - FBS_PipeTransport_ConnectResponse: FBS.PipeTransport.ConnectResponse, - FBS_PipeTransport_DumpResponse: FBS.PipeTransport.DumpResponse, - FBS_PipeTransport_GetStatsResponse: FBS.PipeTransport.GetStatsResponse, - FBS_DirectTransport_DumpResponse: FBS.DirectTransport.DumpResponse, - FBS_DirectTransport_GetStatsResponse: FBS.DirectTransport.GetStatsResponse, - FBS_WebRtcTransport_ConnectResponse: FBS.WebRtcTransport.ConnectResponse, - FBS_WebRtcTransport_DumpResponse: FBS.WebRtcTransport.DumpResponse, - FBS_WebRtcTransport_GetStatsResponse: FBS.WebRtcTransport.GetStatsResponse, - FBS_Producer_DumpResponse: FBS.Producer.DumpResponse, - FBS_Producer_GetStatsResponse: FBS.Producer.GetStatsResponse, - FBS_Consumer_DumpResponse: FBS.Consumer.DumpResponse, - FBS_Consumer_GetStatsResponse: FBS.Consumer.GetStatsResponse, - FBS_Consumer_SetPreferredLayersResponse: FBS.Consumer.SetPreferredLayersResponse, - FBS_Consumer_SetPriorityResponse: FBS.Consumer.SetPriorityResponse, - FBS_DataProducer_DumpResponse: FBS.DataProducer.DumpResponse, - FBS_DataProducer_GetStatsResponse: FBS.DataProducer.GetStatsResponse, - FBS_DataConsumer_GetBufferedAmountResponse: FBS.DataConsumer.GetBufferedAmountResponse, - FBS_DataConsumer_DumpResponse: FBS.DataConsumer.DumpResponse, - FBS_DataConsumer_GetStatsResponse: FBS.DataConsumer.GetStatsResponse, - FBS_DataConsumer_SetSubchannelsResponse: FBS.DataConsumer.SetSubchannelsResponse, + Worker_DumpResponse: FBS.Worker.DumpResponse, + Worker_ResourceUsageResponse: FBS.Worker.ResourceUsageResponse, + WebRtcServer_DumpResponse: FBS.WebRtcServer.DumpResponse, + Router_DumpResponse: FBS.Router.DumpResponse, + Transport_ProduceResponse: FBS.Transport.ProduceResponse, + Transport_ConsumeResponse: FBS.Transport.ConsumeResponse, + Transport_RestartIceResponse: FBS.Transport.RestartIceResponse, + PlainTransport_ConnectResponse: FBS.PlainTransport.ConnectResponse, + PlainTransport_DumpResponse: FBS.PlainTransport.DumpResponse, + PlainTransport_GetStatsResponse: FBS.PlainTransport.GetStatsResponse, + PipeTransport_ConnectResponse: FBS.PipeTransport.ConnectResponse, + PipeTransport_DumpResponse: FBS.PipeTransport.DumpResponse, + PipeTransport_GetStatsResponse: FBS.PipeTransport.GetStatsResponse, + DirectTransport_DumpResponse: FBS.DirectTransport.DumpResponse, + DirectTransport_GetStatsResponse: FBS.DirectTransport.GetStatsResponse, + WebRtcTransport_ConnectResponse: FBS.WebRtcTransport.ConnectResponse, + WebRtcTransport_DumpResponse: FBS.WebRtcTransport.DumpResponse, + WebRtcTransport_GetStatsResponse: FBS.WebRtcTransport.GetStatsResponse, + Producer_DumpResponse: FBS.Producer.DumpResponse, + Producer_GetStatsResponse: FBS.Producer.GetStatsResponse, + Consumer_DumpResponse: FBS.Consumer.DumpResponse, + Consumer_GetStatsResponse: FBS.Consumer.GetStatsResponse, + Consumer_SetPreferredLayersResponse: FBS.Consumer.SetPreferredLayersResponse, + Consumer_SetPriorityResponse: FBS.Consumer.SetPriorityResponse, + DataProducer_DumpResponse: FBS.DataProducer.DumpResponse, + DataProducer_GetStatsResponse: FBS.DataProducer.GetStatsResponse, + DataConsumer_GetBufferedAmountResponse: FBS.DataConsumer.GetBufferedAmountResponse, + DataConsumer_DumpResponse: FBS.DataConsumer.DumpResponse, + DataConsumer_GetStatsResponse: FBS.DataConsumer.GetStatsResponse, + DataConsumer_SetSubchannelsResponse: FBS.DataConsumer.SetSubchannelsResponse, } table Response { - id:uint32; - accepted:bool; - body:Body; - error:string; - reason:string; + id: uint32; + accepted: bool; + body: Body; + error: string; + reason: string; } + diff --git a/worker/fbs/router.fbs b/worker/fbs/router.fbs index 09cb8b6632..d2f95b1376 100644 --- a/worker/fbs/router.fbs +++ b/worker/fbs/router.fbs @@ -10,50 +10,51 @@ include "directTransport.fbs"; namespace FBS.Router; table DumpResponse { - id:string (required); - transport_ids:[string] (required); - rtp_observer_ids:[string] (required); - map_producer_id_consumer_ids:[FBS.Common.StringStringArray] (required); - map_consumer_id_producer_id:[FBS.Common.StringString] (required); - map_producer_id_observer_ids:[FBS.Common.StringStringArray] (required); - map_data_producer_id_data_consumer_ids:[FBS.Common.StringStringArray] (required); - map_data_consumer_id_data_producer_id:[FBS.Common.StringString] (required); + id: string (required); + transport_ids: [string] (required); + rtp_observer_ids: [string] (required); + map_producer_id_consumer_ids: [FBS.Common.StringStringArray] (required); + map_consumer_id_producer_id: [FBS.Common.StringString] (required); + map_producer_id_observer_ids: [FBS.Common.StringStringArray] (required); + map_data_producer_id_data_consumer_ids: [FBS.Common.StringStringArray] (required); + map_data_consumer_id_data_producer_id: [FBS.Common.StringString] (required); } table CreatePipeTransportRequest { - transport_id:string (required); - options:FBS.PipeTransport.PipeTransportOptions (required); + transport_id: string (required); + options: FBS.PipeTransport.PipeTransportOptions (required); } table CreatePlainTransportRequest { - transport_id:string (required); - options:FBS.PlainTransport.PlainTransportOptions (required); + transport_id: string (required); + options: FBS.PlainTransport.PlainTransportOptions (required); } table CreateWebRtcTransportRequest { - transport_id:string (required); - options:FBS.WebRtcTransport.WebRtcTransportOptions (required); + transport_id: string (required); + options: FBS.WebRtcTransport.WebRtcTransportOptions (required); } table CreateDirectTransportRequest { - transport_id:string (required); - options:FBS.DirectTransport.DirectTransportOptions (required); + transport_id: string (required); + options: FBS.DirectTransport.DirectTransportOptions (required); } table CreateAudioLevelObserverRequest { - rtp_observer_id:string (required); - options:FBS.AudioLevelObserver.AudioLevelObserverOptions (required); + rtp_observer_id: string (required); + options: FBS.AudioLevelObserver.AudioLevelObserverOptions (required); } table CreateActiveSpeakerObserverRequest { - active_speaker_observer_id:string (required); - options:FBS.ActiveSpeakerObserver.ActiveSpeakerObserverOptions (required); + active_speaker_observer_id: string (required); + options: FBS.ActiveSpeakerObserver.ActiveSpeakerObserverOptions (required); } table CloseTransportRequest { - transport_id:string (required); + transport_id: string (required); } table CloseRtpObserverRequest { - rtp_observer_id:string (required); + rtp_observer_id: string (required); } + diff --git a/worker/fbs/rtpObserver.fbs b/worker/fbs/rtpObserver.fbs index b3f754f670..68f2a40c14 100644 --- a/worker/fbs/rtpObserver.fbs +++ b/worker/fbs/rtpObserver.fbs @@ -1,10 +1,10 @@ - namespace FBS.RtpObserver; table AddProducerRequest { - producer_id:string (required); + producer_id: string (required); } table RemoveProducerRequest { - producer_id:string (required); + producer_id: string (required); } + diff --git a/worker/fbs/rtpParameters.fbs b/worker/fbs/rtpParameters.fbs index e5e34fca6b..a102b66cee 100644 --- a/worker/fbs/rtpParameters.fbs +++ b/worker/fbs/rtpParameters.fbs @@ -1,104 +1,129 @@ - namespace FBS.RtpParameters; -enum MediaKind : uint8 { ALL = 0, AUDIO, VIDEO } -enum Type: uint8 { NONE = 0, SIMPLE, SIMULCAST, SVC, PIPE } +enum MediaKind: uint8 { + ALL = 0, + AUDIO, + VIDEO +} + +enum Type: uint8 { + NONE = 0, + SIMPLE, + SIMULCAST, + SVC, + PIPE +} // Boolean is a uint8/byte type. table Boolean { - value:uint8; + value: uint8; } table Integer32 { - value:int32; + value: int32; } table Integer32Array { - value:[int32]; + value: [int32]; } table Double { - value:double; + value: double; } table String { - value:string (required); + value: string (required); } union Value { - Boolean, - Integer32, - Double, - String, - Integer32Array, + Boolean, + Integer32, + Double, + String, + Integer32Array, } table Parameter { - name: string (required); - value: Value (required); + name: string (required); + value: Value (required); } table RtcpFeedback { - type:string (required); - parameter:string (required); + type: string (required); + parameter: string (required); } table RtpCodecParameters { - mime_type:string (required); - payload_type:uint8; - clock_rate:uint32; - channels:uint8 = null; - parameters:[Parameter]; - rtcp_feedback:[RtcpFeedback]; + mime_type: string (required); + payload_type: uint8; + clock_rate: uint32; + channels: uint8 = null; + parameters: [Parameter]; + rtcp_feedback: [RtcpFeedback]; +} + +enum RtpHeaderExtensionUri: uint8 { + Mid, + RtpStreamId, + RepairRtpStreamId, + FrameMarkingDraft07, + FrameMarking, + AudioLevel, + VideoOrientation, + TimeOffset, + TransportWideCcDraft01, + AbsSendTime, + AbsCaptureTime, } table RtpHeaderExtensionParameters { - uri:string (required); - id:uint8; - encrypt:bool = false; - parameters:[Parameter]; + uri: RtpHeaderExtensionUri; + id: uint8; + encrypt: bool = false; + parameters: [Parameter]; } table Rtx { - ssrc:uint32; + ssrc: uint32; } table RtpEncodingParameters { - ssrc:uint32 = null; - rid:string; - codec_payload_type:uint8 = null; - rtx:Rtx; - dtx:bool = false; - scalability_mode:string; - max_bitrate:uint32 = null; + ssrc: uint32 = null; + rid: string; + codec_payload_type: uint8 = null; + rtx: Rtx; + dtx: bool = false; + scalability_mode: string; + max_bitrate: uint32 = null; } table RtcpParameters { - cname:string; - reduced_size:bool = true; + cname: string; + reduced_size: bool = true; } table RtpParameters { - mid:string; - codecs:[RtpCodecParameters] (required); - header_extensions:[RtpHeaderExtensionParameters] (required); - encodings:[RtpEncodingParameters] (required); - rtcp:RtcpParameters (required); + mid: string; + codecs: [RtpCodecParameters] (required); + header_extensions: [RtpHeaderExtensionParameters] (required); + encodings: [RtpEncodingParameters] (required); + rtcp: RtcpParameters (required); } table CodecMapping { - payload_type:uint8; - mapped_payload_type:uint8; + payload_type: uint8; + mapped_payload_type: uint8; } table EncodingMapping { - rid:string; - ssrc:uint32 = null; - scalability_mode:string; - mapped_ssrc:uint32; + rid: string; + ssrc: uint32 = null; + scalability_mode: string; + mapped_ssrc: uint32; } table RtpMapping { - codecs:[CodecMapping] (required); - encodings:[EncodingMapping] (required); + codecs: [CodecMapping] (required); + encodings: [EncodingMapping] (required); } + diff --git a/worker/fbs/rtpStream.fbs b/worker/fbs/rtpStream.fbs index f12187ca5c..05496ebafa 100644 --- a/worker/fbs/rtpStream.fbs +++ b/worker/fbs/rtpStream.fbs @@ -4,78 +4,79 @@ include "rtxStream.fbs"; namespace FBS.RtpStream; table Params { - encoding_idx:uint32; - ssrc:uint32; - payload_type:uint8; - mime_type:string (required); - clock_rate: uint32; - rid:string; - cname:string (required); - rtx_ssrc:uint32 = null; - rtx_payload_type:uint8 = null; - use_nack:bool; - use_pli:bool; - use_fir:bool; - use_in_band_fec:bool; - use_dtx:bool; - spatial_layers:uint8; - temporal_layers:uint8; + encoding_idx: uint32; + ssrc: uint32; + payload_type: uint8; + mime_type: string (required); + clock_rate: uint32; + rid: string; + cname: string (required); + rtx_ssrc: uint32 = null; + rtx_payload_type: uint8 = null; + use_nack: bool; + use_pli: bool; + use_fir: bool; + use_in_band_fec: bool; + use_dtx: bool; + spatial_layers: uint8; + temporal_layers: uint8; } table Dump { - params:Params (required); - score:uint8; - rtx_stream:FBS.RtxStream.RtxDump; + params: Params (required); + score: uint8; + rtx_stream: FBS.RtxStream.RtxDump; } table BitrateByLayer { - layer:string (required); - bitrate:uint64; + layer: string (required); + bitrate: uint64; } union StatsData { - BaseStats, - RecvStats, - SendStats, + BaseStats, + RecvStats, + SendStats, } table Stats { - data:StatsData; + data: StatsData; } table BaseStats { - timestamp:uint64; - ssrc:uint32; - kind:FBS.RtpParameters.MediaKind; - mime_type:string (required); - packets_lost:uint64; - fraction_lost:uint64; - packets_discarded:uint64; - packets_retransmitted:uint64; - packets_repaired:uint64; - nack_count:uint64; - nack_packet_count:uint64; - pli_count:uint64; - fir_count:uint64; - score:uint8; - rid:string; - rtx_ssrc:uint32 = null; - rtx_packets_discarded:uint64; - round_trip_time:float; + timestamp: uint64; + ssrc: uint32; + kind: FBS.RtpParameters.MediaKind; + mime_type: string (required); + packets_lost: uint64; + fraction_lost: uint64; + packets_discarded: uint64; + packets_retransmitted: uint64; + packets_repaired: uint64; + nack_count: uint64; + nack_packet_count: uint64; + pli_count: uint64; + fir_count: uint64; + score: uint8; + rid: string; + rtx_ssrc: uint32 = null; + rtx_packets_discarded: uint64; + round_trip_time: float; } table RecvStats { - base:Stats (required); - jitter:uint32; - packet_count:uint64; - byte_count:uint64; - bitrate:uint64; - bitrate_by_layer:[BitrateByLayer]; + base: Stats (required); + jitter: uint32; + packet_count: uint64; + byte_count: uint64; + bitrate: uint64; + bitrate_by_layer: [BitrateByLayer]; } table SendStats { - base:Stats (required); - packet_count:uint64; - byte_count:uint64; - bitrate:uint64; + base: Stats (required); + packet_count: uint64; + byte_count: uint64; + bitrate: uint64; } + diff --git a/worker/fbs/rtxStream.fbs b/worker/fbs/rtxStream.fbs index 9e96efc568..693d27ab77 100644 --- a/worker/fbs/rtxStream.fbs +++ b/worker/fbs/rtxStream.fbs @@ -1,16 +1,16 @@ - namespace FBS.RtxStream; table Params { - ssrc:uint32; - payload_type:uint8; - mime_type:string (required); - clock_rate: uint32; - rrid:string; - cname:string (required); + ssrc: uint32; + payload_type: uint8; + mime_type: string (required); + clock_rate: uint32; + rrid: string; + cname: string (required); } // NOTE: Naming this Dump collides in TS generation for Producer.DumpResponse. table RtxDump { - params:Params (required); + params: Params (required); } + diff --git a/worker/fbs/sctpAssociation.fbs b/worker/fbs/sctpAssociation.fbs index ef5e0b17d6..85e83c12a6 100644 --- a/worker/fbs/sctpAssociation.fbs +++ b/worker/fbs/sctpAssociation.fbs @@ -1,11 +1,10 @@ - namespace FBS.SctpAssociation; enum SctpState: uint8 { - NEW = 0, - CONNECTING, - CONNECTED, - FAILED, - CLOSED, + NEW = 0, + CONNECTING, + CONNECTED, + FAILED, + CLOSED, } diff --git a/worker/fbs/sctpParameters.fbs b/worker/fbs/sctpParameters.fbs index 5727fcf22a..019eecd9b2 100644 --- a/worker/fbs/sctpParameters.fbs +++ b/worker/fbs/sctpParameters.fbs @@ -1,25 +1,25 @@ - namespace FBS.SctpParameters; table NumSctpStreams { - os:uint16 = 1024; - mis:uint16 = 1024; + os: uint16 = 1024; + mis: uint16 = 1024; } table SctpParameters { - // Port is always 5000. - port:uint16=5000; - os:uint16; - mis:uint16; - max_message_size:uint32; - send_buffer_size:uint32; - sctp_buffered_amount:uint32; - is_data_channel:bool; + // Port is always 5000. + port: uint16 = 5000; + os: uint16; + mis: uint16; + max_message_size: uint32; + send_buffer_size: uint32; + sctp_buffered_amount: uint32; + is_data_channel: bool; } table SctpStreamParameters { - stream_id:uint16; - ordered:bool = null; - max_packet_life_time:uint16 = null; - max_retransmits:uint16 = null; + stream_id: uint16; + ordered: bool = null; + max_packet_life_time: uint16 = null; + max_retransmits: uint16 = null; } + diff --git a/worker/fbs/srtpParameters.fbs b/worker/fbs/srtpParameters.fbs index eb376d87c3..8f6a194469 100644 --- a/worker/fbs/srtpParameters.fbs +++ b/worker/fbs/srtpParameters.fbs @@ -1,15 +1,14 @@ - namespace FBS.SrtpParameters; enum SrtpCryptoSuite: uint8 { - AEAD_AES_256_GCM, - AEAD_AES_128_GCM, - AES_CM_128_HMAC_SHA1_80, - AES_CM_128_HMAC_SHA1_32, + AEAD_AES_256_GCM, + AEAD_AES_128_GCM, + AES_CM_128_HMAC_SHA1_80, + AES_CM_128_HMAC_SHA1_32, } table SrtpParameters { - crypto_suite:FBS.SrtpParameters.SrtpCryptoSuite; - key_base64:string (required); + crypto_suite: FBS.SrtpParameters.SrtpCryptoSuite; + key_base64: string (required); } diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs index 807ce624cb..4f21f9cc6c 100644 --- a/worker/fbs/transport.fbs +++ b/worker/fbs/transport.fbs @@ -7,227 +7,241 @@ include "srtpParameters.fbs"; namespace FBS.Transport; -enum Protocol: uint8 { UDP = 1, TCP } +enum Protocol: uint8 { + UDP = 1, + TCP +} table ListenInfo { - protocol:FBS.Transport.Protocol=UDP; - ip:string (required); - announced_ip:string; - port:uint16 = 0; - send_buffer_size:uint32 = 0; - recv_buffer_size:uint32 = 0; + protocol: FBS.Transport.Protocol = UDP; + ip: string (required); + announced_ip: string; + port: uint16 = 0; + send_buffer_size: uint32 = 0; + recv_buffer_size: uint32 = 0; } table RestartIceResponse { - username_fragment:string (required); - password:string (required); - ice_lite:bool; + username_fragment: string (required); + password: string (required); + ice_lite: bool; } table ProduceRequest { - producer_id:string (required); - kind:FBS.RtpParameters.MediaKind; - rtp_parameters:FBS.RtpParameters.RtpParameters (required); - rtp_mapping:FBS.RtpParameters.RtpMapping (required); - key_frame_request_delay:uint16; - paused:bool = false; + producer_id: string (required); + kind: FBS.RtpParameters.MediaKind; + rtp_parameters: FBS.RtpParameters.RtpParameters (required); + rtp_mapping: FBS.RtpParameters.RtpMapping (required); + key_frame_request_delay: uint16; + paused: bool = false; } table ProduceResponse { - type:FBS.RtpParameters.Type; + type: FBS.RtpParameters.Type; } table ConsumeRequest { - consumer_id:string (required); - producer_id:string (required); - kind:FBS.RtpParameters.MediaKind; - rtp_parameters:FBS.RtpParameters.RtpParameters (required); - type:FBS.RtpParameters.Type; - consumable_rtp_encodings:[FBS.RtpParameters.RtpEncodingParameters] (required); - paused:bool = false; - preferred_layers:FBS.Consumer.ConsumerLayers; - ignore_dtx:bool = false; + consumer_id: string (required); + producer_id: string (required); + kind: FBS.RtpParameters.MediaKind; + rtp_parameters: FBS.RtpParameters.RtpParameters (required); + type: FBS.RtpParameters.Type; + consumable_rtp_encodings: [FBS.RtpParameters.RtpEncodingParameters] (required); + paused: bool = false; + preferred_layers: FBS.Consumer.ConsumerLayers; + ignore_dtx: bool = false; } table ConsumeResponse { - paused:bool; - producer_paused:bool; - score:FBS.Consumer.ConsumerScore; - preferred_layers:FBS.Consumer.ConsumerLayers; + paused: bool; + producer_paused: bool; + score: FBS.Consumer.ConsumerScore; + preferred_layers: FBS.Consumer.ConsumerLayers; } table ProduceDataRequest { - data_producer_id:string (required); - type:string (required); - sctp_stream_parameters:FBS.SctpParameters.SctpStreamParameters; - label:string; - protocol:string; - paused:bool = false; + data_producer_id: string (required); + type: string (required); + sctp_stream_parameters: FBS.SctpParameters.SctpStreamParameters; + label: string; + protocol: string; + paused: bool = false; } table ConsumeDataRequest { - data_consumer_id:string (required); - data_producer_id:string (required); - type:string (required); - sctp_stream_parameters:FBS.SctpParameters.SctpStreamParameters; - label:string; - protocol:string; - paused:bool = false; - subchannels:[uint16]; + data_consumer_id: string (required); + data_producer_id: string (required); + type: string (required); + sctp_stream_parameters: FBS.SctpParameters.SctpStreamParameters; + label: string; + protocol: string; + paused: bool = false; + subchannels: [uint16]; } table Tuple { - local_ip:string (required); - local_port:uint16; - remote_ip:string; - remote_port:uint16; - protocol:FBS.Transport.Protocol=UDP; + local_ip: string (required); + local_port: uint16; + remote_ip: string; + remote_port: uint16; + protocol: FBS.Transport.Protocol = UDP; } table RtpListener { - ssrc_table:[FBS.Common.Uint32String] (required); - mid_table:[FBS.Common.StringString] (required); - rid_table:[FBS.Common.StringString] (required); + ssrc_table: [FBS.Common.Uint32String] (required); + mid_table: [FBS.Common.StringString] (required); + rid_table: [FBS.Common.StringString] (required); } table SctpListener { - stream_id_table:[FBS.Common.Uint16String] (required); + stream_id_table: [FBS.Common.Uint16String] (required); } table RecvRtpHeaderExtensions { - mid:uint8 = null; - rid:uint8 = null; - rrid:uint8 = null; - abs_send_time:uint8 = null; - transport_wide_cc01:uint8 = null; + mid: uint8 = null; + rid: uint8 = null; + rrid: uint8 = null; + abs_send_time: uint8 = null; + transport_wide_cc01: uint8 = null; } table Options { - direct:bool = false; - /// Only needed for DirectTransport. This value is handled by base Transport. - max_message_size:uint32 = null; - initial_available_outgoing_bitrate:uint32 = null; - enable_sctp:bool = false; - num_sctp_streams:FBS.SctpParameters.NumSctpStreams; - max_sctp_message_size:uint32; - sctp_send_buffer_size:uint32; - is_data_channel:bool = false; + direct: bool = false; + + /// Only needed for DirectTransport. This value is handled by base Transport. + max_message_size: uint32 = null; + initial_available_outgoing_bitrate: uint32 = null; + enable_sctp: bool = false; + num_sctp_streams: FBS.SctpParameters.NumSctpStreams; + max_sctp_message_size: uint32; + sctp_send_buffer_size: uint32; + is_data_channel: bool = false; } -enum TraceEventType: uint8 { PROBATION = 0, BWE } +enum TraceEventType: uint8 { + PROBATION = 0, + BWE +} table Dump { - id:string (required); - direct:bool=false; - producer_ids:[string] (required); - consumer_ids:[string] (required); - map_ssrc_consumer_id:[FBS.Common.Uint32String] (required); - map_rtx_ssrc_consumer_id:[FBS.Common.Uint32String] (required); - data_producer_ids:[string] (required); - data_consumer_ids:[string] (required); - recv_rtp_header_extensions:RecvRtpHeaderExtensions (required); - rtp_listener:RtpListener (required); - max_message_size:uint32; - sctp_parameters:FBS.SctpParameters.SctpParameters; - sctp_state:FBS.SctpAssociation.SctpState = null; - sctp_listener: SctpListener; - trace_event_types:[TraceEventType] (required); + id: string (required); + direct: bool = false; + producer_ids: [string] (required); + consumer_ids: [string] (required); + map_ssrc_consumer_id: [FBS.Common.Uint32String] (required); + map_rtx_ssrc_consumer_id: [FBS.Common.Uint32String] (required); + data_producer_ids: [string] (required); + data_consumer_ids: [string] (required); + recv_rtp_header_extensions: RecvRtpHeaderExtensions (required); + rtp_listener: RtpListener (required); + max_message_size: uint32; + sctp_parameters: FBS.SctpParameters.SctpParameters; + sctp_state: FBS.SctpAssociation.SctpState = null; + sctp_listener: SctpListener; + trace_event_types: [TraceEventType] (required); } table Stats { - transport_id:string (required); - timestamp:uint64; - sctp_state:FBS.SctpAssociation.SctpState = null; - bytes_received:uint64; - recv_bitrate:uint32; - bytes_sent:uint64; - send_bitrate:uint32; - rtp_bytes_received:uint64; - rtp_recv_bitrate:uint32; - rtp_bytes_sent:uint64; - rtp_send_bitrate:uint32; - rtx_bytes_received:uint64; - rtx_recv_bitrate:uint32; - rtx_bytes_sent:uint64; - rtx_send_bitrate:uint32; - probation_bytes_sent:uint64; - probation_send_bitrate:uint32; - available_outgoing_bitrate:uint32 = null; - available_incoming_bitrate:uint32 = null; - max_incoming_bitrate:uint32 = null; - max_outgoing_bitrate:uint32 = null; - min_outgoing_bitrate:uint32 = null; - rtp_packet_loss_received:float64 = null; - rtp_packet_loss_sent:float64 = null; + transport_id: string (required); + timestamp: uint64; + sctp_state: FBS.SctpAssociation.SctpState = null; + bytes_received: uint64; + recv_bitrate: uint32; + bytes_sent: uint64; + send_bitrate: uint32; + rtp_bytes_received: uint64; + rtp_recv_bitrate: uint32; + rtp_bytes_sent: uint64; + rtp_send_bitrate: uint32; + rtx_bytes_received: uint64; + rtx_recv_bitrate: uint32; + rtx_bytes_sent: uint64; + rtx_send_bitrate: uint32; + probation_bytes_sent: uint64; + probation_send_bitrate: uint32; + available_outgoing_bitrate: uint32 = null; + available_incoming_bitrate: uint32 = null; + max_incoming_bitrate: uint32 = null; + max_outgoing_bitrate: uint32 = null; + min_outgoing_bitrate: uint32 = null; + rtp_packet_loss_received: float64 = null; + rtp_packet_loss_sent: float64 = null; } table SetMaxIncomingBitrateRequest { - max_incoming_bitrate:uint32; + max_incoming_bitrate: uint32; } table SetMaxOutgoingBitrateRequest { - max_outgoing_bitrate:uint32; + max_outgoing_bitrate: uint32; } table SetMinOutgoingBitrateRequest { - min_outgoing_bitrate:uint32; + min_outgoing_bitrate: uint32; } table EnableTraceEventRequest { - events:[TraceEventType] (required); + events: [TraceEventType] (required); } table CloseProducerRequest { - producer_id:string (required); + producer_id: string (required); } table CloseConsumerRequest { - consumer_id:string (required); + consumer_id: string (required); } table CloseDataProducerRequest { - data_producer_id:string (required); + data_producer_id: string (required); } table CloseDataConsumerRequest { - data_consumer_id:string (required); + data_consumer_id: string (required); } // Notifications to Worker. table SendRtcpNotification { - data:[uint8] (required); + data: [uint8] (required); } // Notifications from Worker. table SctpStateChangeNotification { - sctp_state:FBS.SctpAssociation.SctpState; + sctp_state: FBS.SctpAssociation.SctpState; } // NOTE (windows): IN|OUT are macros defined in windef.h. -enum TraceDirection: uint8 { DIRECTION_IN = 0, DIRECTION_OUT } +enum TraceDirection: uint8 { + DIRECTION_IN = 0, + DIRECTION_OUT +} union TraceInfo { - BweTraceInfo, + BweTraceInfo, } -enum BweType: uint8 { TRANSPORT_CC = 0, REMB } +enum BweType: uint8 { + TRANSPORT_CC = 0, + REMB +} table BweTraceInfo { - bwe_type:BweType; - desired_bitrate:uint32; - effective_desired_bitrate:uint32; - min_bitrate:uint32; - max_bitrate:uint32; - start_bitrate:uint32; - max_padding_bitrate:uint32; - available_bitrate:uint32; + bwe_type: BweType; + desired_bitrate: uint32; + effective_desired_bitrate: uint32; + min_bitrate: uint32; + max_bitrate: uint32; + start_bitrate: uint32; + max_padding_bitrate: uint32; + available_bitrate: uint32; } table TraceNotification { - type: TraceEventType; - timestamp: uint64; - direction: TraceDirection; - info: TraceInfo; + type: TraceEventType; + timestamp: uint64; + direction: TraceDirection; + info: TraceInfo; } + diff --git a/worker/fbs/webRtcServer.fbs b/worker/fbs/webRtcServer.fbs index d9d6a7282f..6f93b9bbc6 100644 --- a/worker/fbs/webRtcServer.fbs +++ b/worker/fbs/webRtcServer.fbs @@ -3,25 +3,26 @@ include "transport.fbs"; namespace FBS.WebRtcServer; table IpPort { - ip:string (required); - port:uint16; + ip: string (required); + port: uint16; } table IceUserNameFragment { - local_ice_username_fragment:string (required); - web_rtc_transport_id:string (required); + local_ice_username_fragment: string (required); + web_rtc_transport_id: string (required); } table TupleHash { - local_ice_username_fragment:uint64; - web_rtc_transport_id:string (required); + local_ice_username_fragment: uint64; + web_rtc_transport_id: string (required); } table DumpResponse { - id:string (required); - udp_sockets:[IpPort] (required); - tcp_servers:[IpPort] (required); - web_rtc_transport_ids:[string] (required); - local_ice_username_fragments:[IceUserNameFragment] (required); - tuple_hashes:[TupleHash] (required); + id: string (required); + udp_sockets: [IpPort] (required); + tcp_servers: [IpPort] (required); + web_rtc_transport_ids: [string] (required); + local_ice_username_fragments: [IceUserNameFragment] (required); + tuple_hashes: [TupleHash] (required); } + diff --git a/worker/fbs/webRtcTransport.fbs b/worker/fbs/webRtcTransport.fbs index 002123c242..7af0c308b8 100644 --- a/worker/fbs/webRtcTransport.fbs +++ b/worker/fbs/webRtcTransport.fbs @@ -4,119 +4,130 @@ include "sctpParameters.fbs"; namespace FBS.WebRtcTransport; table ListenIndividual { - listen_infos:[FBS.Transport.ListenInfo] (required); + listen_infos: [FBS.Transport.ListenInfo] (required); } table ListenServer { - web_rtc_server_id:string (required); + web_rtc_server_id: string (required); } union Listen { - ListenIndividual, - ListenServer, + ListenIndividual, + ListenServer, } table WebRtcTransportOptions { - base:FBS.Transport.Options (required); - listen:Listen (required); + base: FBS.Transport.Options (required); + listen: Listen (required); } enum FingerprintAlgorithm: uint8 { - SHA1, - SHA224, - SHA256, - SHA384, - SHA512, + SHA1, + SHA224, + SHA256, + SHA384, + SHA512, } table Fingerprint { - algorithm:FingerprintAlgorithm; - value:string (required); + algorithm: FingerprintAlgorithm; + value: string (required); } enum DtlsRole: uint8 { - AUTO, - CLIENT, - SERVER + AUTO, + CLIENT, + SERVER } enum DtlsState: uint8 { - NEW, - CONNECTING, - CONNECTED, - FAILED, - CLOSED + NEW, + CONNECTING, + CONNECTED, + FAILED, + CLOSED } table DtlsParameters { - fingerprints:[Fingerprint] (required); - role:DtlsRole = AUTO; + fingerprints: [Fingerprint] (required); + role: DtlsRole = AUTO; } table IceParameters { - username_fragment:string (required); - password:string (required); - ice_lite:bool = true; + username_fragment: string (required); + password: string (required); + ice_lite: bool = true; +} + +enum IceCandidateType: uint8 { + HOST +} + +enum IceCandidateTcpType: uint8 { + PASSIVE +} + +enum IceRole: uint8 { + CONTROLLED, + CONTROLLING } -enum IceCandidateType: uint8 { HOST } -enum IceCandidateTcpType: uint8 { PASSIVE } -enum IceRole: uint8 { CONTROLLED, CONTROLLING } enum IceState: uint8 { - NEW, - CONNECTED, - COMPLETED, - DISCONNECTED, + NEW, + CONNECTED, + COMPLETED, + DISCONNECTED, } table IceCandidate { - foundation:string (required); - priority:uint32; - ip:string (required); - protocol:FBS.Transport.Protocol=UDP; - port:uint16; - type:IceCandidateType; - tcp_type:IceCandidateTcpType = null; + foundation: string (required); + priority: uint32; + ip: string (required); + protocol: FBS.Transport.Protocol = UDP; + port: uint16; + type: IceCandidateType; + tcp_type: IceCandidateTcpType = null; } table ConnectRequest { - dtls_parameters:DtlsParameters (required); + dtls_parameters: DtlsParameters (required); } table ConnectResponse { - dtls_local_role:DtlsRole; + dtls_local_role: DtlsRole; } table DumpResponse { - base:FBS.Transport.Dump (required); - ice_role:IceRole; - ice_parameters:IceParameters (required); - ice_candidates:[IceCandidate] (required); - ice_state:IceState; - ice_selected_tuple:FBS.Transport.Tuple; - dtls_parameters:DtlsParameters (required); - dtls_state:DtlsState; + base: FBS.Transport.Dump (required); + ice_role: IceRole; + ice_parameters: IceParameters (required); + ice_candidates: [IceCandidate] (required); + ice_state: IceState; + ice_selected_tuple: FBS.Transport.Tuple; + dtls_parameters: DtlsParameters (required); + dtls_state: DtlsState; } table GetStatsResponse { - base:FBS.Transport.Stats (required); - ice_role:IceRole; - ice_state:IceState; - ice_selected_tuple:FBS.Transport.Tuple; - dtls_state:DtlsState; + base: FBS.Transport.Stats (required); + ice_role: IceRole; + ice_state: IceState; + ice_selected_tuple: FBS.Transport.Tuple; + dtls_state: DtlsState; } // Notifications from Worker. table IceSelectedTupleChangeNotification { - tuple:FBS.Transport.Tuple (required); + tuple: FBS.Transport.Tuple (required); } table IceStateChangeNotification { - ice_state:IceState; + ice_state: IceState; } table DtlsStateChangeNotification { - dtls_state:DtlsState; - remote_cert:string; + dtls_state: DtlsState; + remote_cert: string; } + diff --git a/worker/fbs/worker.fbs b/worker/fbs/worker.fbs index 1048a1a89a..392598a732 100644 --- a/worker/fbs/worker.fbs +++ b/worker/fbs/worker.fbs @@ -3,54 +3,55 @@ include "transport.fbs"; namespace FBS.Worker; table ChannelMessageHandlers { - channel_request_handlers:[string] (required); - channel_notification_handlers:[string] (required); + channel_request_handlers: [string] (required); + channel_notification_handlers: [string] (required); } table DumpResponse { - pid:uint32; - web_rtc_server_ids:[string] (required); - router_ids:[string] (required); - channel_message_handlers:ChannelMessageHandlers (required); + pid: uint32; + web_rtc_server_ids: [string] (required); + router_ids: [string] (required); + channel_message_handlers: ChannelMessageHandlers (required); } table ResourceUsageResponse { - ru_utime:uint64; - ru_stime:uint64; - ru_maxrss:uint64; - ru_ixrss:uint64; - ru_idrss:uint64; - ru_isrss:uint64; - ru_minflt:uint64; - ru_majflt:uint64; - ru_nswap:uint64; - ru_inblock:uint64; - ru_oublock:uint64; - ru_msgsnd:uint64; - ru_msgrcv:uint64; - ru_nsignals:uint64; - ru_nvcsw:uint64; - ru_nivcsw:uint64; + ru_utime: uint64; + ru_stime: uint64; + ru_maxrss: uint64; + ru_ixrss: uint64; + ru_idrss: uint64; + ru_isrss: uint64; + ru_minflt: uint64; + ru_majflt: uint64; + ru_nswap: uint64; + ru_inblock: uint64; + ru_oublock: uint64; + ru_msgsnd: uint64; + ru_msgrcv: uint64; + ru_nsignals: uint64; + ru_nvcsw: uint64; + ru_nivcsw: uint64; } table UpdateSettingsRequest { - log_level:string; - log_tags:[string]; + log_level: string; + log_tags: [string]; } table CreateWebRtcServerRequest { - web_rtc_server_id:string (required); - listen_infos:[FBS.Transport.ListenInfo]; + web_rtc_server_id: string (required); + listen_infos: [FBS.Transport.ListenInfo]; } table CloseWebRtcServerRequest { - web_rtc_server_id:string (required); + web_rtc_server_id: string (required); } table CreateRouterRequest { - router_id:string (required); + router_id: string (required); } table CloseRouterRequest { - router_id:string (required); + router_id: string (required); } + diff --git a/worker/include/Channel/ChannelNotifier.hpp b/worker/include/Channel/ChannelNotifier.hpp index c918b077a3..4c16204feb 100644 --- a/worker/include/Channel/ChannelNotifier.hpp +++ b/worker/include/Channel/ChannelNotifier.hpp @@ -32,7 +32,7 @@ namespace Channel auto message = FBS::Message::CreateMessage( builder, FBS::Message::Type::NOTIFICATION, - FBS::Message::Body::FBS_Notification_Notification, + FBS::Message::Body::Notification, notification.Union()); builder.FinishSizePrefixed(message); @@ -49,7 +49,7 @@ namespace Channel auto message = FBS::Message::CreateMessage( builder, FBS::Message::Type::NOTIFICATION, - FBS::Message::Body::FBS_Notification_Notification, + FBS::Message::Body::Notification, notification.Union()); builder.FinishSizePrefixed(message); diff --git a/worker/include/Channel/ChannelRequest.hpp b/worker/include/Channel/ChannelRequest.hpp index c26d20690c..d718d9aaa2 100644 --- a/worker/include/Channel/ChannelRequest.hpp +++ b/worker/include/Channel/ChannelRequest.hpp @@ -43,10 +43,7 @@ namespace Channel auto response = FBS::Response::CreateResponse(builder, this->id, true, type, body.Union()); auto message = FBS::Message::CreateMessage( - builder, - FBS::Message::Type::RESPONSE, - FBS::Message::Body::FBS_Response_Response, - response.Union()); + builder, FBS::Message::Type::RESPONSE, FBS::Message::Body::Response, response.Union()); builder.FinishSizePrefixed(message); this->Send(builder.GetBufferPointer(), builder.GetSize()); diff --git a/worker/include/RTC/RtpDictionaries.hpp b/worker/include/RTC/RtpDictionaries.hpp index 39a55827ea..0544d60c85 100644 --- a/worker/include/RTC/RtpDictionaries.hpp +++ b/worker/include/RTC/RtpDictionaries.hpp @@ -128,7 +128,6 @@ namespace RTC public: enum class Type : uint8_t { - UNKNOWN = 0, MID = 1, RTP_STREAM_ID = 2, REPAIRED_RTP_STREAM_ID = 3, @@ -142,11 +141,9 @@ namespace RTC ABS_CAPTURE_TIME = 13, }; - private: - static absl::flat_hash_map string2Type; - public: - static Type GetType(std::string& uri); + static RtpHeaderExtensionUri::Type TypeFromFbs(FBS::RtpParameters::RtpHeaderExtensionUri uri); + static FBS::RtpParameters::RtpHeaderExtensionUri TypeToFbs(RtpHeaderExtensionUri::Type uri); }; class RtcpFeedback @@ -232,7 +229,6 @@ namespace RTC flatbuffers::FlatBufferBuilder& builder) const; public: - std::string uri; RtpHeaderExtensionUri::Type type; uint8_t id{ 0u }; bool encrypt{ false }; diff --git a/worker/src/Channel/ChannelRequest.cpp b/worker/src/Channel/ChannelRequest.cpp index e69bbb3da7..f70619c642 100644 --- a/worker/src/Channel/ChannelRequest.cpp +++ b/worker/src/Channel/ChannelRequest.cpp @@ -166,10 +166,7 @@ namespace Channel { auto& builder = this->bufferBuilder; auto message = FBS::Message::CreateMessage( - builder, - FBS::Message::Type::RESPONSE, - FBS::Message::Body::FBS_Response_Response, - response.Union()); + builder, FBS::Message::Type::RESPONSE, FBS::Message::Body::Response, response.Union()); builder.FinishSizePrefixed(message); this->Send(builder.GetBufferPointer(), builder.GetSize()); diff --git a/worker/src/Channel/ChannelSocket.cpp b/worker/src/Channel/ChannelSocket.cpp index abdcf11f9f..a38670b34a 100644 --- a/worker/src/Channel/ChannelSocket.cpp +++ b/worker/src/Channel/ChannelSocket.cpp @@ -151,7 +151,7 @@ namespace Channel auto log = FBS::Log::CreateLogDirect(this->bufferBuilder, msg); auto message = FBS::Message::CreateMessage( - this->bufferBuilder, FBS::Message::Type::LOG, FBS::Message::Body::FBS_Log_Log, log.Union()); + this->bufferBuilder, FBS::Message::Type::LOG, FBS::Message::Body::Log, log.Union()); this->bufferBuilder.FinishSizePrefixed(message); this->Send(this->bufferBuilder.GetBufferPointer(), this->bufferBuilder.GetSize()); diff --git a/worker/src/RTC/ActiveSpeakerObserver.cpp b/worker/src/RTC/ActiveSpeakerObserver.cpp index be92f59f44..ad332f6f51 100644 --- a/worker/src/RTC/ActiveSpeakerObserver.cpp +++ b/worker/src/RTC/ActiveSpeakerObserver.cpp @@ -276,7 +276,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::ACTIVESPEAKEROBSERVER_DOMINANT_SPEAKER, - FBS::Notification::Body::FBS_ActiveSpeakerObserver_DominantSpeakerNotification, + FBS::Notification::Body::ActiveSpeakerObserver_DominantSpeakerNotification, notification); } } diff --git a/worker/src/RTC/AudioLevelObserver.cpp b/worker/src/RTC/AudioLevelObserver.cpp index d59f6b289e..2b0b6ccda4 100644 --- a/worker/src/RTC/AudioLevelObserver.cpp +++ b/worker/src/RTC/AudioLevelObserver.cpp @@ -176,7 +176,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::AUDIOLEVELOBSERVER_VOLUMES, - FBS::Notification::Body::FBS_AudioLevelObserver_VolumesNotification, + FBS::Notification::Body::AudioLevelObserver_VolumesNotification, notification); } else if (!this->silence) diff --git a/worker/src/RTC/Consumer.cpp b/worker/src/RTC/Consumer.cpp index fd5ee974ff..16a6276261 100644 --- a/worker/src/RTC/Consumer.cpp +++ b/worker/src/RTC/Consumer.cpp @@ -234,7 +234,7 @@ namespace RTC { auto responseOffset = FillBufferStats(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_Consumer_GetStatsResponse, responseOffset); + request->Accept(FBS::Response::Body::Consumer_GetStatsResponse, responseOffset); break; } @@ -301,7 +301,7 @@ namespace RTC auto responseOffset = FBS::Consumer::CreateSetPriorityResponse(request->GetBufferBuilder(), this->priority); - request->Accept(FBS::Response::Body::FBS_Consumer_SetPriorityResponse, responseOffset); + request->Accept(FBS::Response::Body::Consumer_SetPriorityResponse, responseOffset); break; } diff --git a/worker/src/RTC/DataConsumer.cpp b/worker/src/RTC/DataConsumer.cpp index 26e2c2bd70..a12d872129 100644 --- a/worker/src/RTC/DataConsumer.cpp +++ b/worker/src/RTC/DataConsumer.cpp @@ -151,7 +151,7 @@ namespace RTC { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_DataConsumer_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::DataConsumer_DumpResponse, dumpOffset); break; } @@ -160,7 +160,7 @@ namespace RTC { auto responseOffset = FillBufferStats(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_DataConsumer_GetStatsResponse, responseOffset); + request->Accept(FBS::Response::Body::DataConsumer_GetStatsResponse, responseOffset); break; } @@ -217,8 +217,7 @@ namespace RTC auto responseOffset = FBS::DataConsumer::CreateGetBufferedAmountResponse( request->GetBufferBuilder(), this->sctpAssociation->GetSctpBufferedAmount()); - request->Accept( - FBS::Response::Body::FBS_DataConsumer_GetBufferedAmountResponse, responseOffset); + request->Accept(FBS::Response::Body::DataConsumer_GetBufferedAmountResponse, responseOffset); break; } @@ -248,7 +247,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::DATACONSUMER_BUFFERED_AMOUNT_LOW, - FBS::Notification::Body::FBS_DataConsumer_BufferedAmountLowNotification, + FBS::Notification::Body::DataConsumer_BufferedAmountLowNotification, bufferedAmountLowOffset); } // Force the trigger of 'bufferedamountlow' once there is less or same @@ -342,7 +341,7 @@ namespace RTC auto responseOffset = FBS::DataConsumer::CreateSetSubchannelsResponseDirect( request->GetBufferBuilder(), std::addressof(subchannels)); - request->Accept(FBS::Response::Body::FBS_DataConsumer_SetSubchannelsResponse, responseOffset); + request->Accept(FBS::Response::Body::DataConsumer_SetSubchannelsResponse, responseOffset); break; } @@ -448,7 +447,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::DATACONSUMER_BUFFERED_AMOUNT_LOW, - FBS::Notification::Body::FBS_DataConsumer_BufferedAmountLowNotification, + FBS::Notification::Body::DataConsumer_BufferedAmountLowNotification, bufferedAmountLowOffset); } } diff --git a/worker/src/RTC/DataProducer.cpp b/worker/src/RTC/DataProducer.cpp index dc084ed25a..2583387885 100644 --- a/worker/src/RTC/DataProducer.cpp +++ b/worker/src/RTC/DataProducer.cpp @@ -128,7 +128,7 @@ namespace RTC { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_DataProducer_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::DataProducer_DumpResponse, dumpOffset); break; } @@ -137,7 +137,7 @@ namespace RTC { auto responseOffset = FillBufferStats(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_DataProducer_GetStatsResponse, responseOffset); + request->Accept(FBS::Response::Body::DataProducer_GetStatsResponse, responseOffset); break; } diff --git a/worker/src/RTC/DirectTransport.cpp b/worker/src/RTC/DirectTransport.cpp index 4c3f4e108a..d11d5a3acd 100644 --- a/worker/src/RTC/DirectTransport.cpp +++ b/worker/src/RTC/DirectTransport.cpp @@ -67,7 +67,7 @@ namespace RTC { auto responseOffset = FillBufferStats(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_DirectTransport_GetStatsResponse, responseOffset); + request->Accept(FBS::Response::Body::DirectTransport_GetStatsResponse, responseOffset); break; } @@ -76,7 +76,7 @@ namespace RTC { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_DirectTransport_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::DirectTransport_DumpResponse, dumpOffset); break; } @@ -159,7 +159,7 @@ namespace RTC this->shared->channelNotifier->Emit( consumer->id, FBS::Notification::Event::CONSUMER_RTP, - FBS::Notification::Body::FBS_Consumer_RtpNotification, + FBS::Notification::Body::Consumer_RtpNotification, notification); if (cb) @@ -186,7 +186,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::DIRECTTRANSPORT_RTCP, - FBS::Notification::Body::FBS_DirectTransport_RtcpNotification, + FBS::Notification::Body::DirectTransport_RtcpNotification, notification); // Increase send transmission. @@ -208,7 +208,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::DIRECTTRANSPORT_RTCP, - FBS::Notification::Body::FBS_DirectTransport_RtcpNotification, + FBS::Notification::Body::DirectTransport_RtcpNotification, notification); } @@ -226,7 +226,7 @@ namespace RTC this->shared->channelNotifier->Emit( dataConsumer->id, FBS::Notification::Event::DATACONSUMER_MESSAGE, - FBS::Notification::Body::FBS_DataConsumer_MessageNotification, + FBS::Notification::Body::DataConsumer_MessageNotification, notification); // Increase send transmission. diff --git a/worker/src/RTC/PipeConsumer.cpp b/worker/src/RTC/PipeConsumer.cpp index 40d7238320..6553282fd3 100644 --- a/worker/src/RTC/PipeConsumer.cpp +++ b/worker/src/RTC/PipeConsumer.cpp @@ -119,7 +119,7 @@ namespace RTC { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_Consumer_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::Consumer_DumpResponse, dumpOffset); break; } diff --git a/worker/src/RTC/PipeTransport.cpp b/worker/src/RTC/PipeTransport.cpp index ebfb123ab9..22ca502d38 100644 --- a/worker/src/RTC/PipeTransport.cpp +++ b/worker/src/RTC/PipeTransport.cpp @@ -243,7 +243,7 @@ namespace RTC { auto responseOffset = FillBufferStats(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_PipeTransport_GetStatsResponse, responseOffset); + request->Accept(FBS::Response::Body::PipeTransport_GetStatsResponse, responseOffset); break; } @@ -252,7 +252,7 @@ namespace RTC { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_PipeTransport_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::PipeTransport_DumpResponse, dumpOffset); break; } @@ -424,7 +424,7 @@ namespace RTC auto responseOffset = FBS::PipeTransport::CreateConnectResponse(request->GetBufferBuilder(), tupleOffset); - request->Accept(FBS::Response::Body::FBS_PipeTransport_ConnectResponse, responseOffset); + request->Accept(FBS::Response::Body::PipeTransport_ConnectResponse, responseOffset); // Assume we are connected (there is no much more we can do to know it) // and tell the parent class. diff --git a/worker/src/RTC/PlainTransport.cpp b/worker/src/RTC/PlainTransport.cpp index 265cd52887..305e67516f 100644 --- a/worker/src/RTC/PlainTransport.cpp +++ b/worker/src/RTC/PlainTransport.cpp @@ -398,7 +398,7 @@ namespace RTC { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_PlainTransport_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::PlainTransport_DumpResponse, dumpOffset); break; } @@ -407,7 +407,7 @@ namespace RTC { auto responseOffset = FillBufferStats(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_PlainTransport_GetStatsResponse, responseOffset); + request->Accept(FBS::Response::Body::PlainTransport_GetStatsResponse, responseOffset); break; } @@ -721,7 +721,7 @@ namespace RTC auto responseOffset = FBS::PlainTransport::CreateConnectResponse( request->GetBufferBuilder(), tupleOffset, rtcpTupleOffset, srtpParametersOffset); - request->Accept(FBS::Response::Body::FBS_PlainTransport_ConnectResponse, responseOffset); + request->Accept(FBS::Response::Body::PlainTransport_ConnectResponse, responseOffset); // Assume we are connected (there is no much more we can do to know it) // and tell the parent class. @@ -1191,7 +1191,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::PLAINTRANSPORT_TUPLE, - FBS::Notification::Body::FBS_PlainTransport_TupleNotification, + FBS::Notification::Body::PlainTransport_TupleNotification, notification); } @@ -1204,7 +1204,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::PLAINTRANSPORT_RTCP_TUPLE, - FBS::Notification::Body::FBS_PlainTransport_RtcpTupleNotification, + FBS::Notification::Body::PlainTransport_RtcpTupleNotification, notification); } diff --git a/worker/src/RTC/Producer.cpp b/worker/src/RTC/Producer.cpp index 9cbf637295..5b67286fd8 100644 --- a/worker/src/RTC/Producer.cpp +++ b/worker/src/RTC/Producer.cpp @@ -362,7 +362,7 @@ namespace RTC { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_Producer_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::Producer_DumpResponse, dumpOffset); break; } @@ -371,7 +371,7 @@ namespace RTC { auto responseOffset = FillBufferStats(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_Producer_GetStatsResponse, responseOffset); + request->Accept(FBS::Response::Body::Producer_GetStatsResponse, responseOffset); break; } @@ -1415,7 +1415,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::PRODUCER_VIDEO_ORIENTATION_CHANGE, - FBS::Notification::Body::FBS_Producer_VideoOrientationChangeNotification, + FBS::Notification::Body::Producer_VideoOrientationChangeNotification, notification); } } @@ -1448,7 +1448,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::PRODUCER_SCORE, - FBS::Notification::Body::FBS_Producer_ScoreNotification, + FBS::Notification::Body::Producer_ScoreNotification, notification); } diff --git a/worker/src/RTC/Router.cpp b/worker/src/RTC/Router.cpp index 364f9a5393..ca6ccd9ae4 100644 --- a/worker/src/RTC/Router.cpp +++ b/worker/src/RTC/Router.cpp @@ -200,7 +200,7 @@ namespace RTC { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_Router_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::Router_DumpResponse, dumpOffset); break; } @@ -225,7 +225,7 @@ namespace RTC auto dumpOffset = webRtcTransport->FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_WebRtcTransport_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::WebRtcTransport_DumpResponse, dumpOffset); break; } @@ -262,7 +262,7 @@ namespace RTC auto dumpOffset = webRtcTransport->FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_WebRtcTransport_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::WebRtcTransport_DumpResponse, dumpOffset); break; } @@ -285,7 +285,7 @@ namespace RTC auto dumpOffset = plainTransport->FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_PlainTransport_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::PlainTransport_DumpResponse, dumpOffset); break; } @@ -308,7 +308,7 @@ namespace RTC auto dumpOffset = pipeTransport->FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_PipeTransport_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::PipeTransport_DumpResponse, dumpOffset); break; } @@ -331,7 +331,7 @@ namespace RTC auto dumpOffset = directTransport->FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_DirectTransport_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::DirectTransport_DumpResponse, dumpOffset); break; } diff --git a/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionParameters.cpp b/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionParameters.cpp index 9eadc74475..3810a759d0 100644 --- a/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionParameters.cpp +++ b/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionParameters.cpp @@ -15,14 +15,8 @@ namespace RTC { MS_TRACE(); - // uri is mandatory. - this->uri = data->uri()->str(); - - if (this->uri.empty()) - MS_THROW_TYPE_ERROR("empty uri"); - // Get the type. - this->type = RTC::RtpHeaderExtensionUri::GetType(this->uri); + this->type = RTC::RtpHeaderExtensionUri::TypeFromFbs(data->uri()); this->id = data->id(); @@ -49,6 +43,6 @@ namespace RTC auto parameters = this->parameters.FillBuffer(builder); return FBS::RtpParameters::CreateRtpHeaderExtensionParametersDirect( - builder, this->uri.c_str(), this->id, this->encrypt, ¶meters); + builder, RTC::RtpHeaderExtensionUri::TypeToFbs(this->type), this->id, this->encrypt, ¶meters); } } // namespace RTC diff --git a/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionUri.cpp b/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionUri.cpp index e4e11e67fe..e5125ea90c 100644 --- a/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionUri.cpp +++ b/worker/src/RTC/RtpDictionaries/RtpHeaderExtensionUri.cpp @@ -7,40 +7,66 @@ namespace RTC { - /* Class variables. */ - - // clang-format off - absl::flat_hash_map RtpHeaderExtensionUri::string2Type = - { - { "urn:ietf:params:rtp-hdrext:sdes:mid", RtpHeaderExtensionUri::Type::MID }, - { "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id", RtpHeaderExtensionUri::Type::RTP_STREAM_ID }, - { "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id", RtpHeaderExtensionUri::Type::REPAIRED_RTP_STREAM_ID }, - { "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time", RtpHeaderExtensionUri::Type::ABS_SEND_TIME }, - { "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01", RtpHeaderExtensionUri::Type::TRANSPORT_WIDE_CC_01 }, - // NOTE: Remove this once framemarking draft becomes RFC. - { "http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07", RtpHeaderExtensionUri::Type::FRAME_MARKING_07 }, - { "urn:ietf:params:rtp-hdrext:framemarking", RtpHeaderExtensionUri::Type::FRAME_MARKING }, - { "urn:ietf:params:rtp-hdrext:ssrc-audio-level", RtpHeaderExtensionUri::Type::SSRC_AUDIO_LEVEL }, - { "urn:3gpp:video-orientation", RtpHeaderExtensionUri::Type::VIDEO_ORIENTATION }, - { "urn:ietf:params:rtp-hdrext:toffset", RtpHeaderExtensionUri::Type::TOFFSET }, - { "http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time", RtpHeaderExtensionUri::Type::ABS_CAPTURE_TIME }, - }; - // clang-format on - /* Class methods. */ - RtpHeaderExtensionUri::Type RtpHeaderExtensionUri::GetType(std::string& uri) + RtpHeaderExtensionUri::Type RtpHeaderExtensionUri::TypeFromFbs( + FBS::RtpParameters::RtpHeaderExtensionUri uri) { - MS_TRACE(); - - // Force lowcase names. - Utils::String::ToLowerCase(uri); - - auto it = RtpHeaderExtensionUri::string2Type.find(uri); - - if (it != RtpHeaderExtensionUri::string2Type.end()) - return it->second; + switch (uri) + { + case FBS::RtpParameters::RtpHeaderExtensionUri::Mid: + return RtpHeaderExtensionUri::Type::MID; + case FBS::RtpParameters::RtpHeaderExtensionUri::RtpStreamId: + return RtpHeaderExtensionUri::Type::RTP_STREAM_ID; + case FBS::RtpParameters::RtpHeaderExtensionUri::RepairRtpStreamId: + return RtpHeaderExtensionUri::Type::REPAIRED_RTP_STREAM_ID; + case FBS::RtpParameters::RtpHeaderExtensionUri::FrameMarkingDraft07: + return RtpHeaderExtensionUri::Type::FRAME_MARKING_07; + case FBS::RtpParameters::RtpHeaderExtensionUri::FrameMarking: + return RtpHeaderExtensionUri::Type::FRAME_MARKING; + case FBS::RtpParameters::RtpHeaderExtensionUri::AudioLevel: + return RtpHeaderExtensionUri::Type::SSRC_AUDIO_LEVEL; + case FBS::RtpParameters::RtpHeaderExtensionUri::VideoOrientation: + return RtpHeaderExtensionUri::Type::VIDEO_ORIENTATION; + case FBS::RtpParameters::RtpHeaderExtensionUri::TimeOffset: + return RtpHeaderExtensionUri::Type::TOFFSET; + case FBS::RtpParameters::RtpHeaderExtensionUri::TransportWideCcDraft01: + return RtpHeaderExtensionUri::Type::TRANSPORT_WIDE_CC_01; + case FBS::RtpParameters::RtpHeaderExtensionUri::AbsSendTime: + return RtpHeaderExtensionUri::Type::ABS_SEND_TIME; + case FBS::RtpParameters::RtpHeaderExtensionUri::AbsCaptureTime: + return RtpHeaderExtensionUri::Type::ABS_CAPTURE_TIME; + } + } - return RtpHeaderExtensionUri::Type::UNKNOWN; + FBS::RtpParameters::RtpHeaderExtensionUri RtpHeaderExtensionUri::TypeToFbs( + RtpHeaderExtensionUri::Type uri) + { + switch (uri) + { + case RtpHeaderExtensionUri::Type::MID: + return FBS::RtpParameters::RtpHeaderExtensionUri::Mid; + case RtpHeaderExtensionUri::Type::RTP_STREAM_ID: + return FBS::RtpParameters::RtpHeaderExtensionUri::RtpStreamId; + case RtpHeaderExtensionUri::Type::REPAIRED_RTP_STREAM_ID: + return FBS::RtpParameters::RtpHeaderExtensionUri::RepairRtpStreamId; + case RtpHeaderExtensionUri::Type::ABS_SEND_TIME: + return FBS::RtpParameters::RtpHeaderExtensionUri::AbsSendTime; + case RtpHeaderExtensionUri::Type::TRANSPORT_WIDE_CC_01: + return FBS::RtpParameters::RtpHeaderExtensionUri::TransportWideCcDraft01; + case RtpHeaderExtensionUri::Type::FRAME_MARKING_07: + return FBS::RtpParameters::RtpHeaderExtensionUri::FrameMarkingDraft07; + case RtpHeaderExtensionUri::Type::FRAME_MARKING: + return FBS::RtpParameters::RtpHeaderExtensionUri::FrameMarking; + case RtpHeaderExtensionUri::Type::SSRC_AUDIO_LEVEL: + return FBS::RtpParameters::RtpHeaderExtensionUri::AudioLevel; + case RtpHeaderExtensionUri::Type::VIDEO_ORIENTATION: + return FBS::RtpParameters::RtpHeaderExtensionUri::VideoOrientation; + case RtpHeaderExtensionUri::Type::TOFFSET: + return FBS::RtpParameters::RtpHeaderExtensionUri::TimeOffset; + case RtpHeaderExtensionUri::Type::ABS_CAPTURE_TIME: + return FBS::RtpParameters::RtpHeaderExtensionUri::AbsCaptureTime; + } } + } // namespace RTC diff --git a/worker/src/RTC/SimpleConsumer.cpp b/worker/src/RTC/SimpleConsumer.cpp index 0f032670ee..ce25d297e4 100644 --- a/worker/src/RTC/SimpleConsumer.cpp +++ b/worker/src/RTC/SimpleConsumer.cpp @@ -128,7 +128,7 @@ namespace RTC { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_Consumer_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::Consumer_DumpResponse, dumpOffset); break; } @@ -657,7 +657,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::CONSUMER_SCORE, - FBS::Notification::Body::FBS_Consumer_ScoreNotification, + FBS::Notification::Body::Consumer_ScoreNotification, notificationOffset); } diff --git a/worker/src/RTC/SimulcastConsumer.cpp b/worker/src/RTC/SimulcastConsumer.cpp index efe5810db9..1bc7d02ed3 100644 --- a/worker/src/RTC/SimulcastConsumer.cpp +++ b/worker/src/RTC/SimulcastConsumer.cpp @@ -203,7 +203,7 @@ namespace RTC { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_Consumer_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::Consumer_DumpResponse, dumpOffset); break; } @@ -257,7 +257,7 @@ namespace RTC auto responseOffset = FBS::Consumer::CreateSetPreferredLayersResponse( request->GetBufferBuilder(), preferredLayersOffset); - request->Accept(FBS::Response::Body::FBS_Consumer_SetPreferredLayersResponse, responseOffset); + request->Accept(FBS::Response::Body::Consumer_SetPreferredLayersResponse, responseOffset); // clang-format off if ( @@ -1495,7 +1495,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::CONSUMER_SCORE, - FBS::Notification::Body::FBS_Consumer_ScoreNotification, + FBS::Notification::Body::Consumer_ScoreNotification, notificationOffset); } @@ -1525,7 +1525,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::CONSUMER_LAYERS_CHANGE, - FBS::Notification::Body::FBS_Consumer_LayersChangeNotification, + FBS::Notification::Body::Consumer_LayersChangeNotification, notificationOffset); } diff --git a/worker/src/RTC/SvcConsumer.cpp b/worker/src/RTC/SvcConsumer.cpp index 61f815da9c..6bae41b5b6 100644 --- a/worker/src/RTC/SvcConsumer.cpp +++ b/worker/src/RTC/SvcConsumer.cpp @@ -176,7 +176,7 @@ namespace RTC { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_Consumer_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::Consumer_DumpResponse, dumpOffset); break; } @@ -230,7 +230,7 @@ namespace RTC auto responseOffset = FBS::Consumer::CreateSetPreferredLayersResponse( request->GetBufferBuilder(), preferredLayersOffset); - request->Accept(FBS::Response::Body::FBS_Consumer_SetPreferredLayersResponse, responseOffset); + request->Accept(FBS::Response::Body::Consumer_SetPreferredLayersResponse, responseOffset); // clang-format off if ( @@ -1124,7 +1124,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::CONSUMER_SCORE, - FBS::Notification::Body::FBS_Consumer_ScoreNotification, + FBS::Notification::Body::Consumer_ScoreNotification, notificationOffset); } @@ -1154,7 +1154,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::CONSUMER_LAYERS_CHANGE, - FBS::Notification::Body::FBS_Consumer_LayersChangeNotification, + FBS::Notification::Body::Consumer_LayersChangeNotification, notificationOffset); } diff --git a/worker/src/RTC/Transport.cpp b/worker/src/RTC/Transport.cpp index c86965a6c0..59d7d0fc7d 100644 --- a/worker/src/RTC/Transport.cpp +++ b/worker/src/RTC/Transport.cpp @@ -664,7 +664,7 @@ namespace RTC auto responseOffset = FBS::Transport::CreateProduceResponse( request->GetBufferBuilder(), FBS::RtpParameters::Type(producer->GetType())); - request->Accept(FBS::Response::Body::FBS_Transport_ProduceResponse, responseOffset); + request->Accept(FBS::Response::Body::Transport_ProduceResponse, responseOffset); // Check if TransportCongestionControlServer or REMB server must be // created. @@ -850,7 +850,7 @@ namespace RTC scoreOffset, preferredLayersOffset); - request->Accept(FBS::Response::Body::FBS_Transport_ConsumeResponse, responseOffset); + request->Accept(FBS::Response::Body::Transport_ConsumeResponse, responseOffset); // Check if Transport Congestion Control client must be created. const auto& rtpHeaderExtensionIds = consumer->GetRtpHeaderExtensionIds(); @@ -1097,7 +1097,7 @@ namespace RTC auto dumpOffset = dataProducer->FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_DataProducer_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::DataProducer_DumpResponse, dumpOffset); break; } @@ -1183,7 +1183,7 @@ namespace RTC auto dumpOffset = dataConsumer->FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_DataConsumer_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::DataConsumer_DumpResponse, dumpOffset); if (IsConnected()) { @@ -2729,7 +2729,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::TRANSPORT_SCTP_STATE_CHANGE, - FBS::Notification::Body::FBS_Transport_SctpStateChangeNotification, + FBS::Notification::Body::Transport_SctpStateChangeNotification, sctpStateChangeOffset); } @@ -2755,7 +2755,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::TRANSPORT_SCTP_STATE_CHANGE, - FBS::Notification::Body::FBS_Transport_SctpStateChangeNotification, + FBS::Notification::Body::Transport_SctpStateChangeNotification, sctpStateChangeOffset); } @@ -2781,7 +2781,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::TRANSPORT_SCTP_STATE_CHANGE, - FBS::Notification::Body::FBS_Transport_SctpStateChangeNotification, + FBS::Notification::Body::Transport_SctpStateChangeNotification, sctpStateChangeOffset); } @@ -2807,7 +2807,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::TRANSPORT_SCTP_STATE_CHANGE, - FBS::Notification::Body::FBS_Transport_SctpStateChangeNotification, + FBS::Notification::Body::Transport_SctpStateChangeNotification, sctpStateChangeOffset); } diff --git a/worker/src/RTC/WebRtcServer.cpp b/worker/src/RTC/WebRtcServer.cpp index e35a99bfc0..b878a90ddb 100644 --- a/worker/src/RTC/WebRtcServer.cpp +++ b/worker/src/RTC/WebRtcServer.cpp @@ -277,7 +277,7 @@ namespace RTC { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_WebRtcServer_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::WebRtcServer_DumpResponse, dumpOffset); break; } diff --git a/worker/src/RTC/WebRtcTransport.cpp b/worker/src/RTC/WebRtcTransport.cpp index 3354996011..9aabf97ab7 100644 --- a/worker/src/RTC/WebRtcTransport.cpp +++ b/worker/src/RTC/WebRtcTransport.cpp @@ -397,7 +397,7 @@ namespace RTC { auto responseOffset = FillBufferStats(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_WebRtcTransport_GetStatsResponse, responseOffset); + request->Accept(FBS::Response::Body::WebRtcTransport_GetStatsResponse, responseOffset); break; } @@ -406,7 +406,7 @@ namespace RTC { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_WebRtcTransport_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::WebRtcTransport_DumpResponse, dumpOffset); break; } @@ -475,7 +475,7 @@ namespace RTC auto responseOffset = FBS::WebRtcTransport::CreateConnectResponse(request->GetBufferBuilder(), dtlsLocalRole); - request->Accept(FBS::Response::Body::FBS_WebRtcTransport_ConnectResponse, responseOffset); + request->Accept(FBS::Response::Body::WebRtcTransport_ConnectResponse, responseOffset); break; } @@ -498,7 +498,7 @@ namespace RTC true /* iceLite */ ); - request->Accept(FBS::Response::Body::FBS_Transport_RestartIceResponse, responseOffset); + request->Accept(FBS::Response::Body::Transport_RestartIceResponse, responseOffset); break; } @@ -1136,7 +1136,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::WEBRTCTRANSPORT_ICE_SELECTED_TUPLE_CHANGE, - FBS::Notification::Body::FBS_WebRtcTransport_IceSelectedTupleChangeNotification, + FBS::Notification::Body::WebRtcTransport_IceSelectedTupleChangeNotification, notification); } @@ -1153,7 +1153,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::WEBRTCTRANSPORT_ICE_STATE_CHANGE, - FBS::Notification::Body::FBS_WebRtcTransport_IceStateChangeNotification, + FBS::Notification::Body::WebRtcTransport_IceStateChangeNotification, iceStateChangeOffset); // If ready, run the DTLS handler. @@ -1179,7 +1179,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::WEBRTCTRANSPORT_ICE_STATE_CHANGE, - FBS::Notification::Body::FBS_WebRtcTransport_IceStateChangeNotification, + FBS::Notification::Body::WebRtcTransport_IceStateChangeNotification, iceStateChangeOffset); // If ready, run the DTLS handler. @@ -1206,7 +1206,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::WEBRTCTRANSPORT_ICE_STATE_CHANGE, - FBS::Notification::Body::FBS_WebRtcTransport_IceStateChangeNotification, + FBS::Notification::Body::WebRtcTransport_IceStateChangeNotification, iceStateChangeOffset); // If DTLS was already connected, notify the parent class. @@ -1229,7 +1229,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::WEBRTCTRANSPORT_DTLS_STATE_CHANGE, - FBS::Notification::Body::FBS_WebRtcTransport_DtlsStateChangeNotification, + FBS::Notification::Body::WebRtcTransport_DtlsStateChangeNotification, dtlsStateChangeOffset); } @@ -1277,7 +1277,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::WEBRTCTRANSPORT_DTLS_STATE_CHANGE, - FBS::Notification::Body::FBS_WebRtcTransport_DtlsStateChangeNotification, + FBS::Notification::Body::WebRtcTransport_DtlsStateChangeNotification, dtlsStateChangeOffset); // Tell the parent class. @@ -1305,7 +1305,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::WEBRTCTRANSPORT_DTLS_STATE_CHANGE, - FBS::Notification::Body::FBS_WebRtcTransport_DtlsStateChangeNotification, + FBS::Notification::Body::WebRtcTransport_DtlsStateChangeNotification, dtlsStateChangeOffset); } @@ -1322,7 +1322,7 @@ namespace RTC this->shared->channelNotifier->Emit( this->id, FBS::Notification::Event::WEBRTCTRANSPORT_DTLS_STATE_CHANGE, - FBS::Notification::Body::FBS_WebRtcTransport_DtlsStateChangeNotification, + FBS::Notification::Body::WebRtcTransport_DtlsStateChangeNotification, dtlsStateChangeOffset); // Tell the parent class. diff --git a/worker/src/Worker.cpp b/worker/src/Worker.cpp index 692988225f..5a0b42e372 100644 --- a/worker/src/Worker.cpp +++ b/worker/src/Worker.cpp @@ -247,7 +247,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) { auto dumpOffset = FillBuffer(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_Worker_DumpResponse, dumpOffset); + request->Accept(FBS::Response::Body::Worker_DumpResponse, dumpOffset); break; } @@ -256,7 +256,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) { auto resourceUsageOffset = FillBufferResourceUsage(request->GetBufferBuilder()); - request->Accept(FBS::Response::Body::FBS_Worker_ResourceUsageResponse, resourceUsageOffset); + request->Accept(FBS::Response::Body::Worker_ResourceUsageResponse, resourceUsageOffset); break; } @@ -272,7 +272,7 @@ inline void Worker::HandleRequest(Channel::ChannelRequest* request) { try { - auto body = request->data->body_as(); + const auto body = request->data->body_as(); std::string webRtcServerId = body->webRtcServerId()->str(); From 8ba475470c5ef36462f6a8eacc74ce5324943d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Mon, 2 Oct 2023 11:16:44 +0200 Subject: [PATCH 30/73] FBS: Producer (#1164) FBS: Producer --- node/src/Producer.ts | 110 +- node/src/Transport.ts | 7 +- node/src/utils.ts | 26 - rust/src/fbs.rs | 1043 ++++++++--------- rust/src/messages.rs | 358 ++++-- rust/src/ortc.rs | 54 + rust/src/router/consumer.rs | 54 +- rust/src/router/direct_transport.rs | 4 +- rust/src/router/pipe_transport.rs | 4 +- rust/src/router/plain_transport.rs | 4 +- rust/src/router/producer.rs | 205 +++- rust/src/router/producer/tests.rs | 1 - rust/src/router/transport.rs | 10 +- rust/src/router/webrtc_transport.rs | 4 +- rust/src/rtp_parameters.rs | 36 +- rust/src/scalability_modes.rs | 2 +- rust/tests/integration/producer.rs | 21 +- worker/fbs/producer.fbs | 28 +- worker/fbs/rtpParameters.fbs | 5 +- worker/fbs/rtpStream.fbs | 12 +- worker/fbs/transport.fbs | 2 +- worker/include/RTC/Codecs/Tools.hpp | 10 - worker/include/RTC/Consumer.hpp | 2 +- worker/include/RTC/Producer.hpp | 2 +- worker/include/RTC/RtpDictionaries.hpp | 25 +- worker/meson.build | 1 - worker/src/RTC/Producer.cpp | 89 +- worker/src/RTC/RtpDictionaries/Media.cpp | 66 -- .../src/RTC/RtpDictionaries/RtcpFeedback.cpp | 2 +- .../RTC/RtpDictionaries/RtpCodecMimeType.cpp | 3 - .../RtpDictionaries/RtpEncodingParameters.cpp | 2 +- .../src/RTC/RtpDictionaries/RtpParameters.cpp | 72 +- worker/src/RTC/RtpStream.cpp | 5 +- worker/src/RTC/RtpStreamSend.cpp | 5 - worker/src/RTC/Transport.cpp | 7 - 35 files changed, 1291 insertions(+), 990 deletions(-) delete mode 100644 worker/src/RTC/RtpDictionaries/Media.cpp diff --git a/node/src/Producer.ts b/node/src/Producer.ts index 45b7bb3227..93e82d11b2 100644 --- a/node/src/Producer.ts +++ b/node/src/Producer.ts @@ -498,9 +498,24 @@ export class Producer throw new TypeError('every type must be a string'); } + // Convert event types. + const fbsEventTypes: FbsProducer.TraceEventType[] = []; + + for (const eventType of types) + { + try + { + fbsEventTypes.push(producerTraceEventTypeToFbs(eventType)); + } + catch (error) + { + logger.warn('enableTraceEvent() | [error:${error}]'); + } + } + /* Build Request. */ const requestOffset = new FbsProducer.EnableTraceEventRequestT( - types + fbsEventTypes ).pack(this.#channel.bufferBuilder); await this.#channel.request( @@ -603,6 +618,74 @@ export class Producer } } +export function producerTypeFromFbs(type: FbsRtpParameters.Type): ProducerType +{ + switch (type) + { + case FbsRtpParameters.Type.SIMPLE: + return 'simple'; + case FbsRtpParameters.Type.SIMULCAST: + return 'simulcast'; + case FbsRtpParameters.Type.SVC: + return 'svc'; + default: + throw new TypeError(`invalid FbsRtpParameters.Type: ${type}`); + } +} + +export function producerTypeToFbs(type: ProducerType): FbsRtpParameters.Type +{ + switch (type) + { + case 'simple': + return FbsRtpParameters.Type.SIMPLE; + + case 'simulcast': + return FbsRtpParameters.Type.SIMULCAST; + + case 'svc': + return FbsRtpParameters.Type.SVC; + } +} + +function producerTraceEventTypeToFbs(eventType: ProducerTraceEventType) + : FbsProducer.TraceEventType +{ + switch (eventType) + { + case 'keyframe': + return FbsProducer.TraceEventType.KEYFRAME; + case 'fir': + return FbsProducer.TraceEventType.FIR; + case 'nack': + return FbsProducer.TraceEventType.NACK; + case 'pli': + return FbsProducer.TraceEventType.PLI; + case 'rtp': + return FbsProducer.TraceEventType.RTP; + default: + throw new TypeError(`invalid eventType: ${eventType}`); + } +} + +function producerTraceEventTypeFromFbs(eventType: FbsProducer.TraceEventType) + : ProducerTraceEventType +{ + switch (eventType) + { + case FbsProducer.TraceEventType.KEYFRAME: + return 'keyframe'; + case FbsProducer.TraceEventType.FIR: + return 'fir'; + case FbsProducer.TraceEventType.NACK: + return 'nack'; + case FbsProducer.TraceEventType.PLI: + return 'pli'; + case FbsProducer.TraceEventType.RTP: + return 'rtp'; + } +} + export function parseProducerDump( data: FbsProducer.DumpResponse ): ProducerDump @@ -610,7 +693,7 @@ export function parseProducerDump( return { id : data.id()!, kind : data.kind() === FbsRtpParameters.MediaKind.AUDIO ? 'audio' : 'video', - type : data.type()! as ProducerType, + type : producerTypeFromFbs(data.type()), rtpParameters : parseRtpParameters(data.rtpParameters()!), // NOTE: optional values are represented with null instead of undefined. // TODO: Make flatbuffers TS return undefined instead of null. @@ -620,7 +703,7 @@ export function parseProducerDump( rtpStreams : data.rtpStreamsLength() > 0 ? utils.parseVector(data, 'rtpStreams', (rtpStream: any) => rtpStream.unpack()) : undefined, - traceEventTypes : utils.parseVector(data, 'traceEventTypes'), + traceEventTypes : utils.parseVector(data, 'traceEventTypes', producerTraceEventTypeFromFbs), paused : data.paused() }; } @@ -657,28 +740,9 @@ function parseTraceEventData( } return { - type : fbstraceType2String(trace.type()), + type : producerTraceEventTypeFromFbs(trace.type()), timestamp : Number(trace.timestamp()), direction : trace.direction() === FbsProducer.TraceDirection.DIRECTION_IN ? 'in' : 'out', info : info ? info.unpack() : undefined }; } - -function fbstraceType2String(traceType: FbsProducer.TraceType): ProducerTraceEventType -{ - switch (traceType) - { - case FbsProducer.TraceType.KEYFRAME: - return 'keyframe'; - case FbsProducer.TraceType.FIR: - return 'fir'; - case FbsProducer.TraceType.NACK: - return 'nack'; - case FbsProducer.TraceType.PLI: - return 'pli'; - case FbsProducer.TraceType.RTP: - return 'rtp'; - default: - throw new TypeError(`invalid TraceType: ${traceType}`); - } -} diff --git a/node/src/Transport.ts b/node/src/Transport.ts index 8074a9b6e8..428c566a9e 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -10,7 +10,7 @@ import { WebRtcTransportData } from './WebRtcTransport'; import { PlainTransportData } from './PlainTransport'; import { PipeTransportData } from './PipeTransport'; import { DirectTransportData } from './DirectTransport'; -import { Producer, ProducerOptions } from './Producer'; +import { Producer, ProducerOptions, producerTypeFromFbs, producerTypeToFbs } from './Producer'; import { Consumer, ConsumerLayers, ConsumerOptions, ConsumerType } from './Consumer'; import { DataProducer, @@ -45,6 +45,7 @@ import * as FbsDataConsumer from './fbs/data-consumer'; import * as FbsDataProducer from './fbs/data-producer'; import * as FbsTransport from './fbs/transport'; import * as FbsRouter from './fbs/router'; +import * as FbsRtpParameters from './fbs/rtp-parameters'; import { SctpState as FbsSctpState } from './fbs/sctp-association/sctp-state'; export type TransportListenInfo = @@ -783,7 +784,7 @@ export class Transport { kind, rtpParameters, - type : utils.getProducerType(status.type), + type : producerTypeFromFbs(status.type), consumableRtpParameters }; @@ -1612,7 +1613,7 @@ function createConsumeRequest({ ConsumeRequest.addRtpParameters(builder, rtpParametersOffset); ConsumeRequest.addType( builder, - utils.getRtpParametersType(producer.type, pipe) + pipe ? FbsRtpParameters.Type.PIPE : producerTypeToFbs(producer.type) ); if (consumableRtpEncodingsOffset) diff --git a/node/src/utils.ts b/node/src/utils.ts index b67e382acd..b24713e833 100644 --- a/node/src/utils.ts +++ b/node/src/utils.ts @@ -56,32 +56,6 @@ export function getRtpParametersType( case 'svc': return FbsRtpParametersType.SVC; - - default: - return FbsRtpParametersType.NONE; - } -} - -/** - * Get the flatbuffers Producer type for a given RtpParameter type. - */ -export function getProducerType( - rtpParameterType: FbsRtpParametersType -): ProducerType -{ - switch (rtpParameterType) - { - case FbsRtpParametersType.SIMPLE: - return 'simple'; - - case FbsRtpParametersType.SIMULCAST: - return 'simulcast'; - - case FbsRtpParametersType.SVC: - return 'svc'; - - default: - throw new TypeError('invalid RtpParameter type'); } } diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index 1bd15bfb1c..e4ee2a87ec 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -5597,7 +5597,7 @@ mod root { fn default() -> Self { Self { data: ::core::default::Default::default(), - type_: super::rtp_parameters::Type::None, + type_: super::rtp_parameters::Type::Simple, } } } @@ -5620,7 +5620,7 @@ mod root { ) -> ::planus::Offset { let prepared_data = field_data.prepare(builder); let prepared_type_ = - field_type_.prepare(builder, &super::rtp_parameters::Type::None); + field_type_.prepare(builder, &super::rtp_parameters::Type::Simple); let mut table_writer: ::planus::table_writer::TableWriter<10> = ::core::default::Default::default(); @@ -5826,7 +5826,7 @@ mod root { ::core::result::Result::Ok( self.0 .access(2, "DumpResponse", "type_")? - .unwrap_or(super::rtp_parameters::Type::None), + .unwrap_or(super::rtp_parameters::Type::Simple), ) } } @@ -5999,7 +5999,7 @@ mod root { let prepared_id = field_id.prepare(builder); let prepared_producer_id = field_producer_id.prepare(builder); let prepared_kind = - field_kind.prepare(builder, &super::rtp_parameters::MediaKind::All); + 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); @@ -6491,7 +6491,7 @@ mod root { ::core::result::Result::Ok( self.0 .access(2, "BaseConsumerDump", "kind")? - .unwrap_or(super::rtp_parameters::MediaKind::All), + .unwrap_or(super::rtp_parameters::MediaKind::Audio), ) } @@ -11973,19 +11973,16 @@ mod root { )] #[repr(u8)] pub enum MediaKind { - /// The variant `ALL` in the enum `MediaKind` - All = 0, - /// The variant `AUDIO` in the enum `MediaKind` - Audio = 1, + Audio = 0, /// The variant `VIDEO` in the enum `MediaKind` - Video = 2, + Video = 1, } impl MediaKind { /// Array containing all valid variants of MediaKind - pub const ENUM_VALUES: [Self; 3] = [Self::All, Self::Audio, Self::Video]; + pub const ENUM_VALUES: [Self; 2] = [Self::Audio, Self::Video]; } impl ::core::convert::TryFrom for MediaKind { @@ -11997,9 +11994,8 @@ mod root { { #[allow(clippy::match_single_binding)] match value { - 0 => ::core::result::Result::Ok(MediaKind::All), - 1 => ::core::result::Result::Ok(MediaKind::Audio), - 2 => ::core::result::Result::Ok(MediaKind::Video), + 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, @@ -12132,7 +12128,7 @@ mod root { /// The enum `Type` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Enum `Type` in the file `../worker/fbs/rtpParameters.fbs:9` + /// * Enum `Type` in the file `../worker/fbs/rtpParameters.fbs:8` #[derive( Copy, Clone, @@ -12147,31 +12143,23 @@ mod root { )] #[repr(u8)] pub enum Type { - /// The variant `NONE` in the enum `Type` - None = 0, - /// The variant `SIMPLE` in the enum `Type` - Simple = 1, + Simple = 0, /// The variant `SIMULCAST` in the enum `Type` - Simulcast = 2, + Simulcast = 1, /// The variant `SVC` in the enum `Type` - Svc = 3, + Svc = 2, /// The variant `PIPE` in the enum `Type` - Pipe = 4, + Pipe = 3, } impl Type { /// Array containing all valid variants of Type - pub const ENUM_VALUES: [Self; 5] = [ - Self::None, - Self::Simple, - Self::Simulcast, - Self::Svc, - Self::Pipe, - ]; + pub const ENUM_VALUES: [Self; 4] = + [Self::Simple, Self::Simulcast, Self::Svc, Self::Pipe]; } impl ::core::convert::TryFrom for Type { @@ -12183,11 +12171,10 @@ mod root { { #[allow(clippy::match_single_binding)] match value { - 0 => ::core::result::Result::Ok(Type::None), - 1 => ::core::result::Result::Ok(Type::Simple), - 2 => ::core::result::Result::Ok(Type::Simulcast), - 3 => ::core::result::Result::Ok(Type::Svc), - 4 => ::core::result::Result::Ok(Type::Pipe), + 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, @@ -12320,7 +12307,7 @@ mod root { /// The table `Boolean` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `Boolean` in the file `../worker/fbs/rtpParameters.fbs:18` + /// * Table `Boolean` in the file `../worker/fbs/rtpParameters.fbs:16` #[derive( Clone, Debug, @@ -12579,7 +12566,7 @@ mod root { /// The table `Integer32` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `Integer32` in the file `../worker/fbs/rtpParameters.fbs:22` + /// * Table `Integer32` in the file `../worker/fbs/rtpParameters.fbs:20` #[derive( Clone, Debug, @@ -12838,7 +12825,7 @@ mod root { /// The table `Integer32Array` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `Integer32Array` in the file `../worker/fbs/rtpParameters.fbs:26` + /// * Table `Integer32Array` in the file `../worker/fbs/rtpParameters.fbs:24` #[derive( Clone, Debug, @@ -13125,7 +13112,7 @@ mod root { /// The table `Double` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `Double` in the file `../worker/fbs/rtpParameters.fbs:30` + /// * Table `Double` in the file `../worker/fbs/rtpParameters.fbs:28` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -13376,7 +13363,7 @@ mod root { /// The table `String` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `String` in the file `../worker/fbs/rtpParameters.fbs:34` + /// * Table `String` in the file `../worker/fbs/rtpParameters.fbs:32` #[derive( Clone, Debug, @@ -13617,7 +13604,7 @@ mod root { /// The union `Value` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Union `Value` in the file `../worker/fbs/rtpParameters.fbs:38` + /// * Union `Value` in the file `../worker/fbs/rtpParameters.fbs:36` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -13964,7 +13951,7 @@ mod root { /// The table `Parameter` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `Parameter` in the file `../worker/fbs/rtpParameters.fbs:46` + /// * Table `Parameter` in the file `../worker/fbs/rtpParameters.fbs:44` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -14233,7 +14220,7 @@ mod root { /// The table `RtcpFeedback` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `RtcpFeedback` in the file `../worker/fbs/rtpParameters.fbs:51` + /// * Table `RtcpFeedback` in the file `../worker/fbs/rtpParameters.fbs:49` #[derive( Clone, Debug, @@ -14249,7 +14236,7 @@ mod root { /// The field `type` in the table `RtcpFeedback` pub type_: ::planus::alloc::string::String, /// The field `parameter` in the table `RtcpFeedback` - pub parameter: ::planus::alloc::string::String, + pub parameter: ::core::option::Option<::planus::alloc::string::String>, } impl RtcpFeedback { @@ -14263,7 +14250,9 @@ mod root { pub fn create( builder: &mut ::planus::Builder, field_type_: impl ::planus::WriteAs<::planus::Offset>, - field_parameter: 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); @@ -14271,12 +14260,18 @@ mod root { 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); + 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_); - object_writer.write::<_, _, 4>(&prepared_parameter); + if let ::core::option::Option::Some(prepared_parameter) = + prepared_parameter + { + object_writer.write::<_, _, 4>(&prepared_parameter); + } }); } builder.current_offset() @@ -14342,11 +14337,18 @@ mod root { #[allow(clippy::type_complexity)] pub fn parameter(self, value: T1) -> RtcpFeedbackBuilder<(T0, T1)> where - T1: ::planus::WriteAs<::planus::Offset>, + 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)> { @@ -14365,7 +14367,7 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, > ::planus::WriteAs<::planus::Offset> for RtcpFeedbackBuilder<(T0, T1)> { @@ -14382,7 +14384,7 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, > ::planus::WriteAsOptional<::planus::Offset> for RtcpFeedbackBuilder<(T0, T1)> { @@ -14399,7 +14401,7 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, > ::planus::WriteAsOffset for RtcpFeedbackBuilder<(T0, T1)> { #[inline] @@ -14425,8 +14427,11 @@ mod root { /// Getter for the [`parameter` field](RtcpFeedback#structfield.parameter). #[inline] - pub fn parameter(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "RtcpFeedback", "parameter") + pub fn parameter( + &self, + ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> + { + self.0.access(1, "RtcpFeedback", "parameter") } } @@ -14434,7 +14439,11 @@ mod root { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut f = f.debug_struct("RtcpFeedbackRef"); f.field("type_", &self.type_()); - f.field("parameter", &self.parameter()); + if let ::core::option::Option::Some(field_parameter) = + self.parameter().transpose() + { + f.field("parameter", &field_parameter); + } f.finish() } } @@ -14446,7 +14455,15 @@ mod root { fn try_from(value: RtcpFeedbackRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { type_: ::core::convert::TryInto::try_into(value.type_()?)?, - parameter: ::core::convert::TryInto::try_into(value.parameter()?)?, + 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 + }, }) } } @@ -14524,7 +14541,7 @@ mod root { /// The table `RtpCodecParameters` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `RtpCodecParameters` in the file `../worker/fbs/rtpParameters.fbs:56` + /// * Table `RtpCodecParameters` in the file `../worker/fbs/rtpParameters.fbs:55` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -15089,7 +15106,7 @@ mod root { /// The enum `RtpHeaderExtensionUri` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Enum `RtpHeaderExtensionUri` in the file `../worker/fbs/rtpParameters.fbs:65` + /// * Enum `RtpHeaderExtensionUri` in the file `../worker/fbs/rtpParameters.fbs:64` #[derive( Copy, Clone, @@ -15311,7 +15328,7 @@ mod root { /// The table `RtpHeaderExtensionParameters` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `RtpHeaderExtensionParameters` in the file `../worker/fbs/rtpParameters.fbs:79` + /// * Table `RtpHeaderExtensionParameters` in the file `../worker/fbs/rtpParameters.fbs:78` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -15810,7 +15827,7 @@ mod root { /// The table `Rtx` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `Rtx` in the file `../worker/fbs/rtpParameters.fbs:86` + /// * Table `Rtx` in the file `../worker/fbs/rtpParameters.fbs:85` #[derive( Clone, Debug, @@ -16063,7 +16080,7 @@ mod root { /// The table `RtpEncodingParameters` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `RtpEncodingParameters` in the file `../worker/fbs/rtpParameters.fbs:90` + /// * Table `RtpEncodingParameters` in the file `../worker/fbs/rtpParameters.fbs:89` #[derive( Clone, Debug, @@ -16710,7 +16727,7 @@ mod root { /// The table `RtcpParameters` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `RtcpParameters` in the file `../worker/fbs/rtpParameters.fbs:100` + /// * Table `RtcpParameters` in the file `../worker/fbs/rtpParameters.fbs:99` #[derive( Clone, Debug, @@ -17052,7 +17069,7 @@ mod root { /// The table `RtpParameters` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `RtpParameters` in the file `../worker/fbs/rtpParameters.fbs:105` + /// * Table `RtpParameters` in the file `../worker/fbs/rtpParameters.fbs:104` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -17504,7 +17521,7 @@ mod root { /// The table `CodecMapping` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `CodecMapping` in the file `../worker/fbs/rtpParameters.fbs:113` + /// * Table `CodecMapping` in the file `../worker/fbs/rtpParameters.fbs:112` #[derive( Clone, Debug, @@ -17840,7 +17857,7 @@ mod root { /// The table `EncodingMapping` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `EncodingMapping` in the file `../worker/fbs/rtpParameters.fbs:118` + /// * Table `EncodingMapping` in the file `../worker/fbs/rtpParameters.fbs:117` #[derive( Clone, Debug, @@ -18296,7 +18313,7 @@ mod root { /// The table `RtpMapping` in the namespace `FBS.RtpParameters` /// /// Generated from these locations: - /// * Table `RtpMapping` in the file `../worker/fbs/rtpParameters.fbs:125` + /// * Table `RtpMapping` in the file `../worker/fbs/rtpParameters.fbs:124` #[derive( Clone, Debug, @@ -20179,7 +20196,7 @@ mod root { /// The field `layer` in the table `BitrateByLayer` pub layer: ::planus::alloc::string::String, /// The field `bitrate` in the table `BitrateByLayer` - pub bitrate: u64, + pub bitrate: u32, } impl BitrateByLayer { @@ -20193,25 +20210,25 @@ mod root { pub fn create( builder: &mut ::planus::Builder, field_layer: impl ::planus::WriteAs<::planus::Offset>, - field_bitrate: impl ::planus::WriteAsDefault, + 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); + table_writer.write_entry::(1); } - table_writer.write_entry::<::planus::Offset>(0); 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::<_, _, 8>(&prepared_bitrate); + object_writer.write::<_, _, 4>(&prepared_bitrate); } - object_writer.write::<_, _, 4>(&prepared_layer); }); } builder.current_offset() @@ -20277,7 +20294,7 @@ mod root { #[allow(clippy::type_complexity)] pub fn bitrate(self, value: T1) -> BitrateByLayerBuilder<(T0, T1)> where - T1: ::planus::WriteAsDefault, + T1: ::planus::WriteAsDefault, { let (v0,) = self.0; BitrateByLayerBuilder((v0, value)) @@ -20309,7 +20326,7 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, + T1: ::planus::WriteAsDefault, > ::planus::WriteAs<::planus::Offset> for BitrateByLayerBuilder<(T0, T1)> { @@ -20326,7 +20343,7 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, + T1: ::planus::WriteAsDefault, > ::planus::WriteAsOptional<::planus::Offset> for BitrateByLayerBuilder<(T0, T1)> { @@ -20343,7 +20360,7 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAsDefault, + T1: ::planus::WriteAsDefault, > ::planus::WriteAsOffset for BitrateByLayerBuilder<(T0, T1)> { #[inline] @@ -20369,7 +20386,7 @@ mod root { /// Getter for the [`bitrate` field](BitrateByLayer#structfield.bitrate). #[inline] - pub fn bitrate(&self) -> ::planus::Result { + pub fn bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0.access(1, "BitrateByLayer", "bitrate")?.unwrap_or(0), ) @@ -20739,16 +20756,7 @@ mod root { )] pub struct Stats { /// The field `data` in the table `Stats` - pub data: ::core::option::Option, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for Stats { - fn default() -> Self { - Self { - data: ::core::default::Default::default(), - } - } + pub data: self::StatsData, } impl Stats { @@ -20761,27 +20769,19 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_data: impl ::planus::WriteAsOptionalUnion, + 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(); - if prepared_data.is_some() { - table_writer.write_entry::<::planus::Offset>(1); - } - if prepared_data.is_some() { - table_writer.write_entry::(0); - } + table_writer.write_entry::<::planus::Offset>(1); + table_writer.write_entry::(0); unsafe { table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_data) = prepared_data { - object_writer.write::<_, _, 4>(&prepared_data.offset()); - } - if let ::core::option::Option::Some(prepared_data) = prepared_data { - object_writer.write::<_, _, 1>(&prepared_data.tag()); - } + object_writer.write::<_, _, 4>(&prepared_data.offset()); + object_writer.write::<_, _, 1>(&prepared_data.tag()); }); } builder.current_offset() @@ -20829,17 +20829,10 @@ mod root { #[allow(clippy::type_complexity)] pub fn data(self, value: T0) -> StatsBuilder<(T0,)> where - T0: ::planus::WriteAsOptionalUnion, + T0: ::planus::WriteAsUnion, { StatsBuilder((value,)) } - - /// Sets the [`data` field](Stats#structfield.data) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn data_as_null(self) -> StatsBuilder<((),)> { - self.data(()) - } } impl StatsBuilder<(T0,)> { @@ -20853,7 +20846,7 @@ mod root { } } - impl> + impl> ::planus::WriteAs<::planus::Offset> for StatsBuilder<(T0,)> { type Prepared = ::planus::Offset; @@ -20864,7 +20857,7 @@ mod root { } } - impl> + impl> ::planus::WriteAsOptional<::planus::Offset> for StatsBuilder<(T0,)> { type Prepared = ::planus::Offset; @@ -20878,7 +20871,7 @@ mod root { } } - impl> ::planus::WriteAsOffset + impl> ::planus::WriteAsOffset for StatsBuilder<(T0,)> { #[inline] @@ -20895,20 +20888,15 @@ mod root { impl<'a> StatsRef<'a> { /// Getter for the [`data` field](Stats#structfield.data). #[inline] - pub fn data( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access_union(0, "Stats", "data") + 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"); - if let ::core::option::Option::Some(field_data) = self.data().transpose() { - f.field("data", &field_data); - } + f.field("data", &self.data()); f.finish() } } @@ -20919,11 +20907,7 @@ mod root { #[allow(unreachable_code)] fn try_from(value: StatsRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - data: if let ::core::option::Option::Some(data) = value.data()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(data)?) - } else { - ::core::option::Option::None - }, + data: ::core::convert::TryInto::try_into(value.data()?)?, }) } } @@ -21017,7 +21001,7 @@ mod root { /// The field `packets_lost` in the table `BaseStats` pub packets_lost: u64, /// The field `fraction_lost` in the table `BaseStats` - pub fraction_lost: u64, + pub fraction_lost: u8, /// The field `packets_discarded` in the table `BaseStats` pub packets_discarded: u64, /// The field `packets_retransmitted` in the table `BaseStats` @@ -21062,7 +21046,7 @@ mod root { >, field_mime_type: impl ::planus::WriteAs<::planus::Offset>, field_packets_lost: impl ::planus::WriteAsDefault, - field_fraction_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, @@ -21079,7 +21063,7 @@ mod root { 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::All); + 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); @@ -21106,9 +21090,6 @@ mod root { if prepared_packets_lost.is_some() { table_writer.write_entry::(4); } - if prepared_fraction_lost.is_some() { - table_writer.write_entry::(5); - } if prepared_packets_discarded.is_some() { table_writer.write_entry::(6); } @@ -21149,6 +21130,9 @@ mod root { 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); } @@ -21165,11 +21149,6 @@ mod root { { object_writer.write::<_, _, 8>(&prepared_packets_lost); } - if let ::core::option::Option::Some(prepared_fraction_lost) = - prepared_fraction_lost - { - object_writer.write::<_, _, 8>(&prepared_fraction_lost); - } if let ::core::option::Option::Some(prepared_packets_discarded) = prepared_packets_discarded { @@ -21230,6 +21209,11 @@ mod root { 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); } @@ -21400,7 +21384,7 @@ mod root { value: T5, ) -> BaseStatsBuilder<(T0, T1, T2, T3, T4, T5)> where - T5: ::planus::WriteAsDefault, + T5: ::planus::WriteAsDefault, { let (v0, v1, v2, v3, v4) = self.0; BaseStatsBuilder((v0, v1, v2, v3, v4, value)) @@ -22053,7 +22037,7 @@ mod root { >, T3: ::planus::WriteAs<::planus::Offset>, T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, + T5: ::planus::WriteAsDefault, T6: ::planus::WriteAsDefault, T7: ::planus::WriteAsDefault, T8: ::planus::WriteAsDefault, @@ -22105,7 +22089,7 @@ mod root { >, T3: ::planus::WriteAs<::planus::Offset>, T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, + T5: ::planus::WriteAsDefault, T6: ::planus::WriteAsDefault, T7: ::planus::WriteAsDefault, T8: ::planus::WriteAsDefault, @@ -22160,7 +22144,7 @@ mod root { >, T3: ::planus::WriteAs<::planus::Offset>, T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, + T5: ::planus::WriteAsDefault, T6: ::planus::WriteAsDefault, T7: ::planus::WriteAsDefault, T8: ::planus::WriteAsDefault, @@ -22249,7 +22233,7 @@ mod root { ::core::result::Result::Ok( self.0 .access(2, "BaseStats", "kind")? - .unwrap_or(super::rtp_parameters::MediaKind::All), + .unwrap_or(super::rtp_parameters::MediaKind::Audio), ) } @@ -22269,7 +22253,7 @@ mod root { /// Getter for the [`fraction_lost` field](BaseStats#structfield.fraction_lost). #[inline] - pub fn fraction_lost(&self) -> ::planus::Result { + pub fn fraction_lost(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0.access(5, "BaseStats", "fraction_lost")?.unwrap_or(0), ) @@ -22553,24 +22537,9 @@ mod root { /// The field `byte_count` in the table `RecvStats` pub byte_count: u64, /// The field `bitrate` in the table `RecvStats` - pub bitrate: u64, + pub bitrate: u32, /// The field `bitrate_by_layer` in the table `RecvStats` - pub bitrate_by_layer: - ::core::option::Option<::planus::alloc::vec::Vec>, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for RecvStats { - fn default() -> Self { - Self { - base: ::core::default::Default::default(), - jitter: 0, - packet_count: 0, - byte_count: 0, - bitrate: 0, - bitrate_by_layer: ::core::default::Default::default(), - } - } + pub bitrate_by_layer: ::planus::alloc::vec::Vec, } impl RecvStats { @@ -22587,8 +22556,8 @@ mod root { 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::WriteAsOptional< + field_bitrate: impl ::planus::WriteAsDefault, + field_bitrate_by_layer: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, ) -> ::planus::Offset { @@ -22607,16 +22576,17 @@ mod root { if prepared_byte_count.is_some() { table_writer.write_entry::(3); } - if prepared_bitrate.is_some() { - table_writer.write_entry::(4); - } table_writer.write_entry::<::planus::Offset>(0); if prepared_jitter.is_some() { table_writer.write_entry::(1); } - if prepared_bitrate_by_layer.is_some() { - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(5); + 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| { @@ -22630,19 +22600,15 @@ mod root { { object_writer.write::<_, _, 8>(&prepared_byte_count); } - if let ::core::option::Option::Some(prepared_bitrate) = prepared_bitrate - { - object_writer.write::<_, _, 8>(&prepared_bitrate); - } 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_by_layer) = - prepared_bitrate_by_layer + if let ::core::option::Option::Some(prepared_bitrate) = prepared_bitrate { - object_writer.write::<_, _, 4>(&prepared_bitrate_by_layer); + object_writer.write::<_, _, 4>(&prepared_bitrate); } + object_writer.write::<_, _, 4>(&prepared_bitrate_by_layer); }); } builder.current_offset() @@ -22774,7 +22740,7 @@ mod root { #[allow(clippy::type_complexity)] pub fn bitrate(self, value: T4) -> RecvStatsBuilder<(T0, T1, T2, T3, T4)> where - T4: ::planus::WriteAsDefault, + T4: ::planus::WriteAsDefault, { let (v0, v1, v2, v3) = self.0; RecvStatsBuilder((v0, v1, v2, v3, value)) @@ -22799,22 +22765,13 @@ mod root { value: T5, ) -> RecvStatsBuilder<(T0, T1, T2, T3, T4, T5)> where - T5: ::planus::WriteAsOptional< + T5: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, { let (v0, v1, v2, v3, v4) = self.0; RecvStatsBuilder((v0, v1, v2, v3, v4, value)) } - - /// Sets the [`bitrate_by_layer` field](RecvStats#structfield.bitrate_by_layer) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn bitrate_by_layer_as_null( - self, - ) -> RecvStatsBuilder<(T0, T1, T2, T3, T4, ())> { - self.bitrate_by_layer(()) - } } impl RecvStatsBuilder<(T0, T1, T2, T3, T4, T5)> { @@ -22833,10 +22790,8 @@ mod root { T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, + T4: ::planus::WriteAsDefault, + T5: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, > ::planus::WriteAs<::planus::Offset> for RecvStatsBuilder<(T0, T1, T2, T3, T4, T5)> { @@ -22853,10 +22808,8 @@ mod root { T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, + T4: ::planus::WriteAsDefault, + T5: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, > ::planus::WriteAsOptional<::planus::Offset> for RecvStatsBuilder<(T0, T1, T2, T3, T4, T5)> { @@ -22876,10 +22829,8 @@ mod root { T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, + T4: ::planus::WriteAsDefault, + T5: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, > ::planus::WriteAsOffset for RecvStatsBuilder<(T0, T1, T2, T3, T4, T5)> { @@ -22927,7 +22878,7 @@ mod root { /// Getter for the [`bitrate` field](RecvStats#structfield.bitrate). #[inline] - pub fn bitrate(&self) -> ::planus::Result { + pub fn bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0.access(4, "RecvStats", "bitrate")?.unwrap_or(0), ) @@ -22938,11 +22889,9 @@ mod root { pub fn bitrate_by_layer( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, + ::planus::Vector<'a, ::planus::Result>>, > { - self.0.access(5, "RecvStats", "bitrate_by_layer") + self.0.access_required(5, "RecvStats", "bitrate_by_layer") } } @@ -22954,11 +22903,7 @@ mod root { f.field("packet_count", &self.packet_count()); f.field("byte_count", &self.byte_count()); f.field("bitrate", &self.bitrate()); - if let ::core::option::Option::Some(field_bitrate_by_layer) = - self.bitrate_by_layer().transpose() - { - f.field("bitrate_by_layer", &field_bitrate_by_layer); - } + f.field("bitrate_by_layer", &self.bitrate_by_layer()); f.finish() } } @@ -22976,13 +22921,7 @@ mod root { 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: if let ::core::option::Option::Some(bitrate_by_layer) = - value.bitrate_by_layer()? - { - ::core::option::Option::Some(bitrate_by_layer.to_vec_result()?) - } else { - ::core::option::Option::None - }, + bitrate_by_layer: value.bitrate_by_layer()?.to_vec_result()?, }) } } @@ -23072,19 +23011,7 @@ mod root { /// The field `byte_count` in the table `SendStats` pub byte_count: u64, /// The field `bitrate` in the table `SendStats` - pub bitrate: u64, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for SendStats { - fn default() -> Self { - Self { - base: ::core::default::Default::default(), - packet_count: 0, - byte_count: 0, - bitrate: 0, - } - } + pub bitrate: u32, } impl SendStats { @@ -23100,7 +23027,7 @@ mod root { field_base: impl ::planus::WriteAs<::planus::Offset>, field_packet_count: impl ::planus::WriteAsDefault, field_byte_count: impl ::planus::WriteAsDefault, - field_bitrate: 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); @@ -23115,10 +23042,10 @@ mod root { 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); + table_writer.write_entry::(3); } - table_writer.write_entry::<::planus::Offset>(0); unsafe { table_writer.finish(builder, |object_writer| { @@ -23132,11 +23059,11 @@ mod root { { 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::<_, _, 8>(&prepared_bitrate); + object_writer.write::<_, _, 4>(&prepared_bitrate); } - object_writer.write::<_, _, 4>(&prepared_base); }); } builder.current_offset() @@ -23246,7 +23173,7 @@ mod root { #[allow(clippy::type_complexity)] pub fn bitrate(self, value: T3) -> SendStatsBuilder<(T0, T1, T2, T3)> where - T3: ::planus::WriteAsDefault, + T3: ::planus::WriteAsDefault, { let (v0, v1, v2) = self.0; SendStatsBuilder((v0, v1, v2, value)) @@ -23277,7 +23204,7 @@ mod root { T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, + T3: ::planus::WriteAsDefault, > ::planus::WriteAs<::planus::Offset> for SendStatsBuilder<(T0, T1, T2, T3)> { @@ -23293,7 +23220,7 @@ mod root { T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, + T3: ::planus::WriteAsDefault, > ::planus::WriteAsOptional<::planus::Offset> for SendStatsBuilder<(T0, T1, T2, T3)> { @@ -23312,7 +23239,7 @@ mod root { T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, + T3: ::planus::WriteAsDefault, > ::planus::WriteAsOffset for SendStatsBuilder<(T0, T1, T2, T3)> { #[inline] @@ -23351,7 +23278,7 @@ mod root { /// Getter for the [`bitrate` field](SendStats#structfield.bitrate). #[inline] - pub fn bitrate(&self) -> ::planus::Result { + pub fn bitrate(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0.access(3, "SendStats", "bitrate")?.unwrap_or(0), ) @@ -33764,7 +33691,7 @@ mod root { /// 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: u16, + pub key_frame_request_delay: u32, /// The field `paused` in the table `ProduceRequest` pub paused: bool, } @@ -33790,12 +33717,12 @@ mod root { field_rtp_mapping: impl ::planus::WriteAs< ::planus::Offset, >, - field_key_frame_request_delay: impl ::planus::WriteAsDefault, + 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::All); + 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 = @@ -33810,7 +33737,7 @@ mod root { table_writer .write_entry::<::planus::Offset>(3); if prepared_key_frame_request_delay.is_some() { - table_writer.write_entry::(4); + table_writer.write_entry::(4); } if prepared_kind.is_some() { table_writer.write_entry::(1); @@ -33827,7 +33754,7 @@ mod root { if let ::core::option::Option::Some(prepared_key_frame_request_delay) = prepared_key_frame_request_delay { - object_writer.write::<_, _, 2>(&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); @@ -33962,7 +33889,7 @@ mod root { value: T4, ) -> ProduceRequestBuilder<(T0, T1, T2, T3, T4)> where - T4: ::planus::WriteAsDefault, + T4: ::planus::WriteAsDefault, { let (v0, v1, v2, v3) = self.0; ProduceRequestBuilder((v0, v1, v2, v3, value)) @@ -34027,7 +33954,7 @@ mod root { >, T2: ::planus::WriteAs<::planus::Offset>, T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsDefault, + T4: ::planus::WriteAsDefault, T5: ::planus::WriteAsDefault, > ::planus::WriteAs<::planus::Offset> for ProduceRequestBuilder<(T0, T1, T2, T3, T4, T5)> @@ -34051,7 +33978,7 @@ mod root { >, T2: ::planus::WriteAs<::planus::Offset>, T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsDefault, + T4: ::planus::WriteAsDefault, T5: ::planus::WriteAsDefault, > ::planus::WriteAsOptional<::planus::Offset> for ProduceRequestBuilder<(T0, T1, T2, T3, T4, T5)> @@ -34075,7 +34002,7 @@ mod root { >, T2: ::planus::WriteAs<::planus::Offset>, T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsDefault, + T4: ::planus::WriteAsDefault, T5: ::planus::WriteAsDefault, > ::planus::WriteAsOffset for ProduceRequestBuilder<(T0, T1, T2, T3, T4, T5)> @@ -34107,7 +34034,7 @@ mod root { ::core::result::Result::Ok( self.0 .access(1, "ProduceRequest", "kind")? - .unwrap_or(super::rtp_parameters::MediaKind::All), + .unwrap_or(super::rtp_parameters::MediaKind::Audio), ) } @@ -34130,7 +34057,7 @@ mod root { /// Getter for the [`key_frame_request_delay` field](ProduceRequest#structfield.key_frame_request_delay). #[inline] - pub fn key_frame_request_delay(&self) -> ::planus::Result { + pub fn key_frame_request_delay(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 .access(4, "ProduceRequest", "key_frame_request_delay")? @@ -34278,7 +34205,7 @@ mod root { impl ::core::default::Default for ProduceResponse { fn default() -> Self { Self { - type_: super::rtp_parameters::Type::None, + type_: super::rtp_parameters::Type::Simple, } } } @@ -34299,7 +34226,7 @@ mod root { >, ) -> ::planus::Offset { let prepared_type_ = - field_type_.prepare(builder, &super::rtp_parameters::Type::None); + field_type_.prepare(builder, &super::rtp_parameters::Type::Simple); let mut table_writer: ::planus::table_writer::TableWriter<6> = ::core::default::Default::default(); @@ -34461,7 +34388,7 @@ mod root { ::core::result::Result::Ok( self.0 .access(0, "ProduceResponse", "type_")? - .unwrap_or(super::rtp_parameters::Type::None), + .unwrap_or(super::rtp_parameters::Type::Simple), ) } } @@ -34624,10 +34551,10 @@ mod root { 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::All); + 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::None); + 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); @@ -35074,7 +35001,7 @@ mod root { ::core::result::Result::Ok( self.0 .access(2, "ConsumeRequest", "kind")? - .unwrap_or(super::rtp_parameters::MediaKind::All), + .unwrap_or(super::rtp_parameters::MediaKind::Audio), ) } @@ -35093,7 +35020,7 @@ mod root { ::core::result::Result::Ok( self.0 .access(4, "ConsumeRequest", "type_")? - .unwrap_or(super::rtp_parameters::Type::None), + .unwrap_or(super::rtp_parameters::Type::Simple), ) } @@ -65441,10 +65368,193 @@ mod root { /// 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:6` + #[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:6` + /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/producer.fbs:14` #[derive( Clone, Debug, @@ -65458,7 +65568,7 @@ mod root { )] pub struct EnableTraceEventRequest { /// The field `events` in the table `EnableTraceEventRequest` - pub events: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + pub events: ::planus::alloc::vec::Vec, } impl EnableTraceEventRequest { @@ -65471,13 +65581,13 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_events: impl ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + 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<[::planus::Offset]>>(0); + table_writer.write_entry::<::planus::Offset<[self::TraceEventType]>>(0); unsafe { table_writer.finish(builder, |object_writer| { @@ -65538,7 +65648,7 @@ mod root { #[allow(clippy::type_complexity)] pub fn events(self, value: T0) -> EnableTraceEventRequestBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T0: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, { EnableTraceEventRequestBuilder((value,)) } @@ -65558,7 +65668,7 @@ mod root { } } - impl]>>> + impl>> ::planus::WriteAs<::planus::Offset> for EnableTraceEventRequestBuilder<(T0,)> { @@ -65573,7 +65683,7 @@ mod root { } } - impl]>>> + impl>> ::planus::WriteAsOptional<::planus::Offset> for EnableTraceEventRequestBuilder<(T0,)> { @@ -65589,7 +65699,7 @@ mod root { } } - impl]>>> + impl>> ::planus::WriteAsOffset for EnableTraceEventRequestBuilder<(T0,)> { @@ -65613,7 +65723,13 @@ mod root { pub fn events( &self, ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + ::planus::Vector< + 'a, + ::core::result::Result< + self::TraceEventType, + ::planus::errors::UnknownEnumTag, + >, + >, > { self.0 .access_required(0, "EnableTraceEventRequest", "events") @@ -65716,7 +65832,7 @@ mod root { /// The table `DumpResponse` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/producer.fbs:10` + /// * Table `DumpResponse` in the file `../worker/fbs/producer.fbs:18` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -65726,17 +65842,16 @@ mod root { /// The field `kind` in the table `DumpResponse` pub kind: super::rtp_parameters::MediaKind, /// The field `type` in the table `DumpResponse` - pub type_: ::planus::alloc::string::String, + 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: - ::core::option::Option<::planus::alloc::vec::Vec>, + pub rtp_streams: ::planus::alloc::vec::Vec, /// The field `trace_event_types` in the table `DumpResponse` - pub trace_event_types: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + pub trace_event_types: ::planus::alloc::vec::Vec, /// The field `paused` in the table `DumpResponse` pub paused: bool, } @@ -65756,25 +65871,29 @@ mod root { super::rtp_parameters::MediaKind, super::rtp_parameters::MediaKind, >, - field_type_: impl ::planus::WriteAs<::planus::Offset>, + 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::WriteAsOptional< + field_rtp_streams: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, field_trace_event_types: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, + ::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::All); - let prepared_type_ = field_type_.prepare(builder); + 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); @@ -65784,18 +65903,18 @@ mod root { 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>(3); table_writer .write_entry::<::planus::Offset>(4); - if prepared_rtp_streams.is_some() { - 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]>>(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); } @@ -65803,18 +65922,16 @@ mod root { unsafe { table_writer.finish(builder, |object_writer| { object_writer.write::<_, _, 4>(&prepared_id); - object_writer.write::<_, _, 4>(&prepared_type_); object_writer.write::<_, _, 4>(&prepared_rtp_parameters); object_writer.write::<_, _, 4>(&prepared_rtp_mapping); - if let ::core::option::Option::Some(prepared_rtp_streams) = - prepared_rtp_streams - { - object_writer.write::<_, _, 4>(&prepared_rtp_streams); - } + 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); } @@ -65858,7 +65975,7 @@ mod root { builder, &self.id, self.kind, - &self.type_, + self.type_, &self.rtp_parameters, &self.rtp_mapping, &self.rtp_streams, @@ -65916,11 +66033,23 @@ mod root { #[allow(clippy::type_complexity)] pub fn type_(self, value: T2) -> DumpResponseBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAs<::planus::Offset>, + 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)> { @@ -65958,20 +66087,13 @@ mod root { value: T5, ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> where - T5: ::planus::WriteAsOptional< + T5: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, { let (v0, v1, v2, v3, v4) = self.0; DumpResponseBuilder((v0, v1, v2, v3, v4, value)) } - - /// Sets the [`rtp_streams` field](DumpResponse#structfield.rtp_streams) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_streams_as_null(self) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, ())> { - self.rtp_streams(()) - } } impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> { @@ -65983,7 +66105,7 @@ mod root { value: T6, ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> where - T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T6: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, { let (v0, v1, v2, v3, v4, v5) = self.0; DumpResponseBuilder((v0, v1, v2, v3, v4, v5, value)) @@ -66036,13 +66158,16 @@ mod root { super::rtp_parameters::MediaKind, super::rtp_parameters::MediaKind, >, - T2: ::planus::WriteAs<::planus::Offset>, + T2: ::planus::WriteAsDefault< + super::rtp_parameters::Type, + super::rtp_parameters::Type, + >, T3: ::planus::WriteAs<::planus::Offset>, T4: ::planus::WriteAs<::planus::Offset>, - T5: ::planus::WriteAsOptional< + T5: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - T6: ::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)> @@ -66064,13 +66189,16 @@ mod root { super::rtp_parameters::MediaKind, super::rtp_parameters::MediaKind, >, - T2: ::planus::WriteAs<::planus::Offset>, + T2: ::planus::WriteAsDefault< + super::rtp_parameters::Type, + super::rtp_parameters::Type, + >, T3: ::planus::WriteAs<::planus::Offset>, T4: ::planus::WriteAs<::planus::Offset>, - T5: ::planus::WriteAsOptional< + T5: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - T6: ::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)> @@ -66092,13 +66220,16 @@ mod root { super::rtp_parameters::MediaKind, super::rtp_parameters::MediaKind, >, - T2: ::planus::WriteAs<::planus::Offset>, + T2: ::planus::WriteAsDefault< + super::rtp_parameters::Type, + super::rtp_parameters::Type, + >, T3: ::planus::WriteAs<::planus::Offset>, T4: ::planus::WriteAs<::planus::Offset>, - T5: ::planus::WriteAsOptional< + T5: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, - T6: ::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)> @@ -66130,14 +66261,18 @@ mod root { ::core::result::Result::Ok( self.0 .access(1, "DumpResponse", "kind")? - .unwrap_or(super::rtp_parameters::MediaKind::All), + .unwrap_or(super::rtp_parameters::MediaKind::Audio), ) } /// Getter for the [`type` field](DumpResponse#structfield.type_). #[inline] - pub fn type_(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(2, "DumpResponse", "type_") + 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). @@ -66161,11 +66296,9 @@ mod root { pub fn rtp_streams( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, + ::planus::Vector<'a, ::planus::Result>>, > { - self.0.access(5, "DumpResponse", "rtp_streams") + self.0.access_required(5, "DumpResponse", "rtp_streams") } /// Getter for the [`trace_event_types` field](DumpResponse#structfield.trace_event_types). @@ -66173,7 +66306,13 @@ mod root { pub fn trace_event_types( &self, ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + ::planus::Vector< + 'a, + ::core::result::Result< + self::TraceEventType, + ::planus::errors::UnknownEnumTag, + >, + >, > { self.0 .access_required(6, "DumpResponse", "trace_event_types") @@ -66196,11 +66335,7 @@ mod root { f.field("type_", &self.type_()); f.field("rtp_parameters", &self.rtp_parameters()); f.field("rtp_mapping", &self.rtp_mapping()); - if let ::core::option::Option::Some(field_rtp_streams) = - self.rtp_streams().transpose() - { - f.field("rtp_streams", &field_rtp_streams); - } + f.field("rtp_streams", &self.rtp_streams()); f.field("trace_event_types", &self.trace_event_types()); f.field("paused", &self.paused()); f.finish() @@ -66222,13 +66357,7 @@ mod root { rtp_mapping: ::planus::alloc::boxed::Box::new( ::core::convert::TryInto::try_into(value.rtp_mapping()?)?, ), - rtp_streams: if let ::core::option::Option::Some(rtp_streams) = - value.rtp_streams()? - { - ::core::option::Option::Some(rtp_streams.to_vec_result()?) - } else { - ::core::option::Option::None - }, + 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()?)?, }) @@ -66308,23 +66437,13 @@ mod root { /// The table `GetStatsResponse` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/producer.fbs:21` + /// * Table `GetStatsResponse` in the file `../worker/fbs/producer.fbs:29` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct GetStatsResponse { /// The field `stats` in the table `GetStatsResponse` - pub stats: - ::core::option::Option<::planus::alloc::vec::Vec>, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for GetStatsResponse { - fn default() -> Self { - Self { - stats: ::core::default::Default::default(), - } - } + pub stats: ::planus::alloc::vec::Vec, } impl GetStatsResponse { @@ -66337,7 +66456,7 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_stats: impl ::planus::WriteAsOptional< + field_stats: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, ) -> ::planus::Offset { @@ -66345,15 +66464,11 @@ mod root { let mut table_writer: ::planus::table_writer::TableWriter<6> = ::core::default::Default::default(); - if prepared_stats.is_some() { - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(0); - } + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(0); unsafe { table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_stats) = prepared_stats { - object_writer.write::<_, _, 4>(&prepared_stats); - } + object_writer.write::<_, _, 4>(&prepared_stats); }); } builder.current_offset() @@ -66407,19 +66522,12 @@ mod root { #[allow(clippy::type_complexity)] pub fn stats(self, value: T0) -> GetStatsResponseBuilder<(T0,)> where - T0: ::planus::WriteAsOptional< + T0: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, { GetStatsResponseBuilder((value,)) } - - /// Sets the [`stats` field](GetStatsResponse#structfield.stats) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn stats_as_null(self) -> GetStatsResponseBuilder<((),)> { - self.stats(()) - } } impl GetStatsResponseBuilder<(T0,)> { @@ -66437,7 +66545,7 @@ mod root { } impl< - T0: ::planus::WriteAsOptional< + T0: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, > ::planus::WriteAs<::planus::Offset> @@ -66455,7 +66563,7 @@ mod root { } impl< - T0: ::planus::WriteAsOptional< + T0: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, > ::planus::WriteAsOptional<::planus::Offset> @@ -66473,7 +66581,7 @@ mod root { } impl< - T0: ::planus::WriteAsOptional< + T0: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, > ::planus::WriteAsOffset for GetStatsResponseBuilder<(T0,)> @@ -66498,20 +66606,16 @@ mod root { pub fn stats( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, + ::planus::Vector<'a, ::planus::Result>>, > { - self.0.access(0, "GetStatsResponse", "stats") + 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"); - if let ::core::option::Option::Some(field_stats) = self.stats().transpose() { - f.field("stats", &field_stats); - } + f.field("stats", &self.stats()); f.finish() } } @@ -66522,11 +66626,7 @@ mod root { #[allow(unreachable_code)] fn try_from(value: GetStatsResponseRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - stats: if let ::core::option::Option::Some(stats) = value.stats()? { - ::core::option::Option::Some(stats.to_vec_result()?) - } else { - ::core::option::Option::None - }, + stats: value.stats()?.to_vec_result()?, }) } } @@ -66604,7 +66704,7 @@ mod root { /// The table `SendNotification` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `SendNotification` in the file `../worker/fbs/producer.fbs:25` + /// * Table `SendNotification` in the file `../worker/fbs/producer.fbs:33` #[derive( Clone, Debug, @@ -66862,7 +66962,7 @@ mod root { /// The table `Score` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `Score` in the file `../worker/fbs/producer.fbs:31` + /// * Table `Score` in the file `../worker/fbs/producer.fbs:39` #[derive( Clone, Debug, @@ -67220,7 +67320,7 @@ mod root { /// The table `ScoreNotification` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `ScoreNotification` in the file `../worker/fbs/producer.fbs:37` + /// * Table `ScoreNotification` in the file `../worker/fbs/producer.fbs:45` #[derive( Clone, Debug, @@ -67518,7 +67618,7 @@ mod root { /// The table `VideoOrientationChangeNotification` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `VideoOrientationChangeNotification` in the file `../worker/fbs/producer.fbs:41` + /// * Table `VideoOrientationChangeNotification` in the file `../worker/fbs/producer.fbs:49` #[derive( Clone, Debug, @@ -67938,189 +68038,6 @@ mod root { } } - /// The enum `TraceType` in the namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * Enum `TraceType` in the file `../worker/fbs/producer.fbs:47` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum TraceType { - /// The variant `KEYFRAME` in the enum `TraceType` - Keyframe = 0, - - /// The variant `FIR` in the enum `TraceType` - Fir = 1, - - /// The variant `NACK` in the enum `TraceType` - Nack = 2, - - /// The variant `PLI` in the enum `TraceType` - Pli = 3, - - /// The variant `RTP` in the enum `TraceType` - Rtp = 4, - } - - impl TraceType { - /// Array containing all valid variants of TraceType - pub const ENUM_VALUES: [Self; 5] = - [Self::Keyframe, Self::Fir, Self::Nack, Self::Pli, Self::Rtp]; - } - - impl ::core::convert::TryFrom for TraceType { - 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(TraceType::Keyframe), - 1 => ::core::result::Result::Ok(TraceType::Fir), - 2 => ::core::result::Result::Ok(TraceType::Nack), - 3 => ::core::result::Result::Ok(TraceType::Pli), - 4 => ::core::result::Result::Ok(TraceType::Rtp), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: TraceType) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for TraceType { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for TraceType { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for TraceType { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> TraceType { - *self - } - } - - impl ::planus::WriteAsDefault for TraceType { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &TraceType, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for TraceType { - 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 TraceType { - #[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 TraceType { - 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( - "TraceType", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite for TraceType { - 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 `TraceDirection` in the namespace `FBS.Producer` /// /// Generated from these locations: @@ -69753,7 +69670,7 @@ mod root { )] pub struct TraceNotification { /// The field `type` in the table `TraceNotification` - pub type_: self::TraceType, + pub type_: self::TraceEventType, /// The field `timestamp` in the table `TraceNotification` pub timestamp: u64, /// The field `direction` in the table `TraceNotification` @@ -69766,7 +69683,7 @@ mod root { impl ::core::default::Default for TraceNotification { fn default() -> Self { Self { - type_: self::TraceType::Keyframe, + type_: self::TraceEventType::Keyframe, timestamp: 0, direction: self::TraceDirection::DirectionIn, info: ::core::default::Default::default(), @@ -69784,7 +69701,10 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_type_: impl ::planus::WriteAsDefault, + field_type_: impl ::planus::WriteAsDefault< + self::TraceEventType, + self::TraceEventType, + >, field_timestamp: impl ::planus::WriteAsDefault, field_direction: impl ::planus::WriteAsDefault< self::TraceDirection, @@ -69792,7 +69712,8 @@ mod root { >, field_info: impl ::planus::WriteAsOptionalUnion, ) -> ::planus::Offset { - let prepared_type_ = field_type_.prepare(builder, &self::TraceType::Keyframe); + 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, &self::TraceDirection::DirectionIn); @@ -69807,7 +69728,7 @@ mod root { table_writer.write_entry::<::planus::Offset>(4); } if prepared_type_.is_some() { - table_writer.write_entry::(0); + table_writer.write_entry::(0); } if prepared_direction.is_some() { table_writer.write_entry::(2); @@ -69896,7 +69817,7 @@ mod root { #[allow(clippy::type_complexity)] pub fn type_(self, value: T0) -> TraceNotificationBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, { TraceNotificationBuilder((value,)) } @@ -69990,7 +69911,7 @@ mod root { } impl< - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsOptionalUnion, @@ -70009,7 +69930,7 @@ mod root { } impl< - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsOptionalUnion, @@ -70028,7 +69949,7 @@ mod root { } impl< - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, T2: ::planus::WriteAsDefault, T3: ::planus::WriteAsOptionalUnion, @@ -70052,11 +69973,11 @@ mod root { impl<'a> TraceNotificationRef<'a> { /// Getter for the [`type` field](TraceNotification#structfield.type_). #[inline] - pub fn type_(&self) -> ::planus::Result { + pub fn type_(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 .access(0, "TraceNotification", "type_")? - .unwrap_or(self::TraceType::Keyframe), + .unwrap_or(self::TraceEventType::Keyframe), ) } diff --git a/rust/src/messages.rs b/rust/src/messages.rs index f97edf769b..5a1a62e8b7 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -12,15 +12,13 @@ use crate::data_structures::{ }; use crate::direct_transport::DirectTransportOptions; use crate::fbs::{ - direct_transport, message, pipe_transport, plain_transport, request, response, router, - transport, web_rtc_transport, worker, + direct_transport, message, pipe_transport, plain_transport, producer, request, response, + router, transport, web_rtc_transport, worker, }; use crate::ortc::RtpMapping; use crate::pipe_transport::PipeTransportOptions; use crate::plain_transport::PlainTransportOptions; -use crate::producer::{ - ProducerDump, ProducerId, ProducerStat, ProducerTraceEventType, ProducerType, -}; +use crate::producer::{ProducerId, ProducerTraceEventType, ProducerType}; use crate::router::{RouterDump, RouterId}; use crate::rtp_observer::RtpObserverId; use crate::rtp_parameters::{MediaKind, RtpEncodingParameters, RtpParameters}; @@ -39,7 +37,6 @@ use parking_lot::Mutex; use planus::Builder; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; -use serde_json::Value; use std::error::Error; use std::fmt::{Debug, Display}; use std::net::IpAddr; @@ -1232,27 +1229,10 @@ request_response!( }, ); -request_response!( - RouterId, - "router.closeTransport", - TransportCloseRequest { - transport_id: TransportId, - }, - (), - Some(()), -); - -request_response!( - TransportId, - "transport.dump", - TransportDumpRequest {}, - Value, -); - #[derive(Debug)] -pub(crate) struct TransportDumpRequestFbs {} +pub(crate) struct TransportDumpRequest {} -impl RequestFbs for TransportDumpRequestFbs { +impl RequestFbs for TransportDumpRequest { const METHOD: request::Method = request::Method::TransportDump; type HandlerId = TransportId; type Response = response::Body; @@ -1284,17 +1264,10 @@ impl RequestFbs for TransportDumpRequestFbs { } } } -request_response!( - TransportId, - "transport.getStats", - TransportGetStatsRequest {}, - Value, -); - #[derive(Debug)] -pub(crate) struct TransportGetStatsRequestFbs {} +pub(crate) struct TransportGetStatsRequest {} -impl RequestFbs for TransportGetStatsRequestFbs { +impl RequestFbs for TransportGetStatsRequest { const METHOD: request::Method = request::Method::TransportGetStats; type HandlerId = TransportId; type Response = response::Body; @@ -1328,11 +1301,11 @@ impl RequestFbs for TransportGetStatsRequestFbs { } #[derive(Debug)] -pub(crate) struct TransportCloseRequestFbs { +pub(crate) struct TransportCloseRequest { pub(crate) transport_id: TransportId, } -impl RequestFbs for TransportCloseRequestFbs { +impl RequestFbs for TransportCloseRequest { const METHOD: request::Method = request::Method::RouterCloseTransport; type HandlerId = RouterId; type Response = (); @@ -1670,21 +1643,64 @@ impl RequestFbs for TransportRestartIceRequest { })) } } -request_response!( - TransportId, - "transport.produce", - TransportProduceRequest { - producer_id: ProducerId, - kind: MediaKind, - rtp_parameters: RtpParameters, - rtp_mapping: RtpMapping, - key_frame_request_delay: u32, - paused: bool, - }, - TransportProduceResponse { - r#type: ProducerType, - }, -); + +#[derive(Debug)] +pub(crate) struct TransportProduceRequest { + pub(crate) producer_id: ProducerId, + pub(crate) kind: MediaKind, + pub(crate) rtp_parameters: RtpParameters, + pub(crate) rtp_mapping: RtpMapping, + pub(crate) key_frame_request_delay: u32, + pub(crate) paused: bool, +} + +#[derive(Debug)] +pub(crate) struct TransportProduceResponse { + pub(crate) r#type: ProducerType, +} + +impl RequestFbs for TransportProduceRequest { + const METHOD: request::Method = request::Method::TransportProduce; + type HandlerId = TransportId; + type Response = TransportProduceResponse; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = transport::ProduceRequest::create( + &mut builder, + self.producer_id.to_string(), + self.kind.to_fbs(), + Box::new(self.rtp_parameters.into_fbs()), + Box::new(self.rtp_mapping.to_fbs()), + self.key_frame_request_delay, + self.paused, + ); + let request_body = request::Body::create_transport_produce_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::TransportProduceResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(TransportProduceResponse { + r#type: ProducerType::from_fbs(data.type_), + }) + } +} request_response!( TransportId, @@ -1810,42 +1826,222 @@ impl Notification for TransportSendRtcpNotification { } } -request_response!( - TransportId, - "transport.closeProducer", - ProducerCloseRequest { - producer_id: ProducerId, - }, - (), - Some(()), -); +#[derive(Debug)] +pub(crate) struct ProducerCloseRequest { + pub(crate) producer_id: ProducerId, +} -request_response!( - ProducerId, - "producer.dump", - ProducerDumpRequest {}, - ProducerDump -); +impl RequestFbs for ProducerCloseRequest { + const METHOD: request::Method = request::Method::TransportCloseProducer; + type HandlerId = TransportId; + type Response = (); -request_response!( - ProducerId, - "producer.getStats", - ProducerGetStatsRequest {}, - Vec, -); + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = + transport::CloseProducerRequest::create(&mut builder, self.producer_id.to_string()); + let request_body = + request::Body::create_transport_close_producer_request(&mut builder, data); -request_response!(ProducerId, "producer.pause", ProducerPauseRequest {}); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); -request_response!(ProducerId, "producer.resume", ProducerResumeRequest {}); + builder.finish(message, None).to_vec() + } -request_response!( - ProducerId, - "producer.enableTraceEvent", - ProducerEnableTraceEventRequest { - types: Vec, - }, -); + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug)] +pub(crate) struct ProducerDumpRequest {} + +impl RequestFbs for ProducerDumpRequest { + const METHOD: request::Method = request::Method::ProducerDump; + type HandlerId = ProducerId; + type Response = response::Body; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + match response { + Some(data) => Ok(data), + _ => { + panic!("Wrong message from worker: {response:?}"); + } + } + } +} + +#[derive(Debug)] +pub(crate) struct ProducerGetStatsRequest {} + +impl RequestFbs for ProducerGetStatsRequest { + const METHOD: request::Method = request::Method::ProducerGetStats; + type HandlerId = ProducerId; + type Response = response::Body; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + match response { + Some(data) => Ok(data), + _ => { + panic!("Wrong message from worker: {response:?}"); + } + } + } +} + +#[derive(Debug, Serialize)] +pub(crate) struct ProducerPauseRequest {} + +impl RequestFbs for ProducerPauseRequest { + const METHOD: request::Method = request::Method::ProducerPause; + type HandlerId = ProducerId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug, Serialize)] +pub(crate) struct ProducerResumeRequest {} + +impl RequestFbs for ProducerResumeRequest { + const METHOD: request::Method = request::Method::ProducerResume; + type HandlerId = ProducerId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug)] +pub(crate) struct ProducerEnableTraceEventRequest { + pub(crate) types: Vec, +} + +impl RequestFbs for ProducerEnableTraceEventRequest { + const METHOD: request::Method = request::Method::ProducerEnableTraceEvent; + type HandlerId = ProducerId; + type Response = (); + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let data = producer::EnableTraceEventRequest { + events: self + .types + .into_iter() + .map(ProducerTraceEventType::to_fbs) + .collect(), + }; + + let request_body = request::Body::ProducerEnableTraceEventRequest(Box::new(data)); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } + + fn default_for_soft_error() -> Option { + None + } +} #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct ProducerSendNotification {} diff --git a/rust/src/ortc.rs b/rust/src/ortc.rs index 1799e29791..03f6726cb3 100644 --- a/rust/src/ortc.rs +++ b/rust/src/ortc.rs @@ -1,3 +1,4 @@ +use crate::fbs::rtp_parameters; use crate::rtp_parameters::{ MediaKind, MimeType, MimeTypeAudio, MimeTypeVideo, RtcpFeedback, RtcpParameters, RtpCapabilities, RtpCapabilitiesFinalized, RtpCodecCapability, RtpCodecCapabilityFinalized, @@ -52,6 +53,59 @@ pub struct RtpMapping { pub encodings: Vec, } +impl RtpMapping { + pub(crate) fn to_fbs(&self) -> rtp_parameters::RtpMapping { + rtp_parameters::RtpMapping { + codecs: self + .codecs + .iter() + .map(|mapping| rtp_parameters::CodecMapping { + payload_type: mapping.payload_type, + mapped_payload_type: mapping.mapped_payload_type, + }) + .collect(), + encodings: self + .encodings + .iter() + .map(|mapping| rtp_parameters::EncodingMapping { + rid: mapping.rid.clone().map(|rid| rid.to_string()), + ssrc: mapping.ssrc, + scalability_mode: Some(mapping.scalability_mode.to_string()), + mapped_ssrc: mapping.mapped_ssrc, + }) + .collect(), + } + } + + pub(crate) fn from_fbs(mapping: rtp_parameters::RtpMapping) -> Self { + Self { + codecs: mapping + .codecs + .iter() + .map(|mapping| RtpMappingCodec { + payload_type: mapping.payload_type, + mapped_payload_type: mapping.mapped_payload_type, + }) + .collect(), + encodings: mapping + .encodings + .iter() + .map(|mapping| RtpMappingEncoding { + rid: mapping.rid.clone().map(|rid| rid.to_string()), + ssrc: mapping.ssrc, + scalability_mode: mapping + .scalability_mode + .clone() + .unwrap_or(String::from("S1T1")) + .parse() + .unwrap(), + mapped_ssrc: mapping.mapped_ssrc, + }) + .collect(), + } + } +} + /// Error caused by invalid RTP parameters. #[derive(Debug, Error, Eq, PartialEq)] pub enum RtpParametersError { diff --git a/rust/src/router/consumer.rs b/rust/src/router/consumer.rs index fc45857d80..b8ca36c0cc 100644 --- a/rust/src/router/consumer.rs +++ b/rust/src/router/consumer.rs @@ -2,6 +2,7 @@ mod tests; use crate::data_structures::{AppData, RtpPacketTraceInfo, SsrcTraceInfo, TraceEventDirection}; +use crate::fbs::{rtp_stream, rtx_stream}; use crate::messages::{ ConsumerCloseRequest, ConsumerDumpRequest, ConsumerEnableTraceEventRequest, ConsumerGetStatsRequest, ConsumerPauseRequest, ConsumerRequestKeyFrameRequest, @@ -116,7 +117,7 @@ impl ConsumerOptions { pub struct RtpStreamParams { pub clock_rate: u32, pub cname: String, - pub encoding_idx: usize, + pub encoding_idx: u32, pub mime_type: MimeType, pub payload_type: u8, pub spatial_layers: u8, @@ -127,8 +128,55 @@ pub struct RtpStreamParams { pub use_nack: bool, pub use_pli: bool, pub rid: Option, - pub rtc_ssrc: Option, - pub rtc_payload_type: Option, + pub rtx_ssrc: Option, + pub rtx_payload_type: Option, +} + +impl RtpStreamParams { + pub(crate) fn from_fbs(params: &rtp_stream::Params) -> Self { + Self { + clock_rate: params.clock_rate, + cname: params.cname.clone(), + encoding_idx: params.encoding_idx, + mime_type: params.mime_type.clone().parse().unwrap(), + payload_type: params.payload_type, + spatial_layers: params.spatial_layers, + ssrc: params.ssrc, + temporal_layers: params.temporal_layers, + use_dtx: params.use_dtx, + use_in_band_fec: params.use_in_band_fec, + use_nack: params.use_nack, + use_pli: params.use_pli, + rid: params.rid.clone(), + rtx_ssrc: params.rtx_ssrc, + rtx_payload_type: params.rtx_payload_type, + } + } +} + +#[derive(Debug, Clone, PartialOrd, Eq, PartialEq, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +#[doc(hidden)] +pub struct RtxStreamParams { + pub clock_rate: u32, + pub cname: String, + pub mime_type: MimeType, + pub payload_type: u8, + pub ssrc: u32, + pub rrid: Option, +} + +impl RtxStreamParams { + pub(crate) fn from_fbs(params: &rtx_stream::Params) -> Self { + Self { + clock_rate: params.clock_rate, + cname: params.cname.clone(), + mime_type: params.mime_type.clone().parse().unwrap(), + payload_type: params.payload_type, + ssrc: params.ssrc, + rrid: params.rrid.clone(), + } + } } #[derive(Debug, Clone, PartialOrd, Eq, PartialEq, Deserialize, Serialize)] diff --git a/rust/src/router/direct_transport.rs b/rust/src/router/direct_transport.rs index 37126e8b15..0bf490f51a 100644 --- a/rust/src/router/direct_transport.rs +++ b/rust/src/router/direct_transport.rs @@ -6,7 +6,7 @@ use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, Da 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::{TransportCloseRequestFbs, TransportSendRtcpNotification}; +use crate::messages::{TransportCloseRequest, TransportSendRtcpNotification}; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; use crate::router::Router; @@ -301,7 +301,7 @@ impl Inner { if close_request { let channel = self.channel.clone(); let router_id = self.router.id(); - let request = TransportCloseRequestFbs { + let request = TransportCloseRequest { transport_id: self.id, }; diff --git a/rust/src/router/pipe_transport.rs b/rust/src/router/pipe_transport.rs index 5121bf79b0..45adb1eb10 100644 --- a/rust/src/router/pipe_transport.rs +++ b/rust/src/router/pipe_transport.rs @@ -6,7 +6,7 @@ use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, Da 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, TransportCloseRequestFbs}; +use crate::messages::{PipeTransportConnectRequest, PipeTransportData, TransportCloseRequest}; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; use crate::router::Router; @@ -360,7 +360,7 @@ impl Inner { if close_request { let channel = self.channel.clone(); let router_id = self.router.id(); - let request = TransportCloseRequestFbs { + let request = TransportCloseRequest { transport_id: self.id, }; diff --git a/rust/src/router/plain_transport.rs b/rust/src/router/plain_transport.rs index cb38ff5b7a..e10859be72 100644 --- a/rust/src/router/plain_transport.rs +++ b/rust/src/router/plain_transport.rs @@ -6,7 +6,7 @@ use crate::data_consumer::{DataConsumer, DataConsumerId, DataConsumerOptions, Da 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, TransportCloseRequestFbs, TransportConnectPlainRequest}; +use crate::messages::{PlainTransportData, TransportCloseRequest, TransportConnectPlainRequest}; use crate::producer::{Producer, ProducerId, ProducerOptions}; use crate::router::transport::{TransportImpl, TransportType}; use crate::router::Router; @@ -433,7 +433,7 @@ impl Inner { if close_request { let channel = self.channel.clone(); let router_id = self.router.id(); - let request = TransportCloseRequestFbs { + let request = TransportCloseRequest { transport_id: self.id, }; diff --git a/rust/src/router/producer.rs b/rust/src/router/producer.rs index 9634f3255b..205cf27232 100644 --- a/rust/src/router/producer.rs +++ b/rust/src/router/producer.rs @@ -1,8 +1,9 @@ #[cfg(test)] mod tests; -use crate::consumer::RtpStreamParams; +use crate::consumer::{RtpStreamParams, RtxStreamParams}; use crate::data_structures::{AppData, RtpPacketTraceInfo, SsrcTraceInfo, TraceEventDirection}; +use crate::fbs::{producer, response, rtp_parameters, rtp_stream}; use crate::messages::{ ProducerCloseRequest, ProducerDumpRequest, ProducerEnableTraceEventRequest, ProducerGetStatsRequest, ProducerPauseRequest, ProducerResumeRequest, ProducerSendNotification, @@ -14,11 +15,11 @@ use crate::uuid_based_wrapper_type; use crate::worker::{Channel, NotificationError, RequestError, SubscriptionHandler}; use async_executor::Executor; use event_listener_primitives::{Bag, BagOnce, HandlerId}; -use hash_hasher::HashedMap; use log::{debug, error}; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; +use std::error::Error; use std::fmt; use std::fmt::Debug; use std::sync::atomic::{AtomicBool, Ordering}; @@ -86,18 +87,32 @@ impl ProducerOptions { } } +#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +#[doc(hidden)] +pub struct RtxStream { + pub params: RtxStreamParams, +} + #[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] #[doc(hidden)] pub struct RtpStreamRecv { pub params: RtpStreamParams, pub score: u8, - // `type` field is present in worker, but ignored here - pub jitter: u32, - pub packet_count: usize, - pub byte_count: usize, - pub bitrate: u32, - pub bitrate_by_layer: Option>, + pub rtx_stream: Option, +} + +impl RtpStreamRecv { + pub(crate) fn from_fbs(dump: &rtp_stream::Dump) -> Self { + Self { + params: RtpStreamParams::from_fbs(&dump.params), + score: dump.score, + rtx_stream: dump.rtx_stream.clone().map(|stream| RtxStream { + params: RtxStreamParams::from_fbs(&stream.params), + }), + } + } } #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] @@ -111,10 +126,33 @@ pub struct ProducerDump { pub rtp_mapping: RtpMapping, pub rtp_parameters: RtpParameters, pub rtp_streams: Vec, - pub trace_event_types: String, + pub trace_event_types: Vec, pub r#type: ProducerType, } +impl ProducerDump { + pub(crate) fn from_fbs(dump: producer::DumpResponse) -> Result> { + Ok(Self { + id: dump.id.parse()?, + kind: MediaKind::from_fbs(dump.kind), + paused: dump.paused, + rtp_mapping: RtpMapping::from_fbs(*dump.rtp_mapping), + rtp_parameters: RtpParameters::from_fbs(*dump.rtp_parameters).unwrap(), + rtp_streams: dump + .rtp_streams + .iter() + .map(RtpStreamRecv::from_fbs) + .collect(), + trace_event_types: dump + .trace_event_types + .iter() + .map(ProducerTraceEventType::from_fbs) + .collect(), + r#type: ProducerType::from_fbs(dump.type_), + }) + } +} + /// Producer type. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] @@ -127,6 +165,19 @@ pub enum ProducerType { Svc, } +impl ProducerType { + pub(crate) fn from_fbs(producer_type: rtp_parameters::Type) -> Self { + match producer_type { + rtp_parameters::Type::Simple => ProducerType::Simple, + rtp_parameters::Type::Simulcast => ProducerType::Simulcast, + rtp_parameters::Type::Svc => ProducerType::Svc, + // TODO: Create a new FBS type ProducerType with just Simple, + // Simulcast and Svc. + rtp_parameters::Type::Pipe => unimplemented!(), + } + } +} + /// Score of the RTP stream in the producer representing its transmission quality. #[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -167,6 +218,16 @@ pub struct ProducerVideoOrientation { pub rotation: Rotation, } +/// Bitrate by layer. +#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +#[non_exhaustive] +#[allow(missing_docs)] +pub struct BitrateByLayer { + layer: String, + bitrate: u32, +} + /// RTC statistics of the producer. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -179,28 +240,72 @@ pub struct ProducerStat { pub ssrc: u32, pub rtx_ssrc: Option, pub rid: Option, - pub kind: String, + pub kind: MediaKind, pub mime_type: MimeType, - pub packets_lost: u32, + pub packets_lost: u64, pub fraction_lost: u8, - pub packets_discarded: usize, - pub packets_retransmitted: usize, - pub packets_repaired: usize, - pub nack_count: usize, - pub nack_packet_count: usize, - pub pli_count: usize, - pub fir_count: usize, + pub packets_discarded: u64, + pub packets_retransmitted: u64, + pub packets_repaired: u64, + pub nack_count: u64, + pub nack_packet_count: u64, + pub pli_count: u64, + pub fir_count: u64, pub score: u8, - pub packet_count: usize, - pub byte_count: usize, + pub packet_count: u64, + pub byte_count: u64, pub bitrate: u32, pub round_trip_time: Option, - pub rtx_packets_discarded: Option, + pub rtx_packets_discarded: Option, // RtpStreamRecv specific. pub jitter: u32, - pub bitrate_by_layer: Option>, + pub bitrate_by_layer: Vec, } +impl ProducerStat { + pub(crate) fn from_fbs(stats: &rtp_stream::Stats) -> Self { + let rtp_stream::StatsData::RecvStats(ref stats) = stats.data else { + panic!("Wrong message from worker"); + }; + + let rtp_stream::StatsData::BaseStats(ref base) = stats.base.data else { + panic!("Wrong message from worker"); + }; + + Self { + timestamp: base.timestamp, + ssrc: base.ssrc, + rtx_ssrc: base.rtx_ssrc, + rid: base.rid.clone(), + kind: MediaKind::from_fbs(base.kind), + mime_type: base.mime_type.to_string().parse().unwrap(), + packets_lost: base.packets_lost, + fraction_lost: base.fraction_lost, + packets_discarded: base.packets_discarded, + packets_retransmitted: base.packets_retransmitted, + packets_repaired: base.packets_repaired, + nack_count: base.nack_count, + nack_packet_count: base.nack_packet_count, + pli_count: base.pli_count, + fir_count: base.fir_count, + score: base.score, + packet_count: stats.packet_count, + byte_count: stats.byte_count, + bitrate: stats.bitrate, + round_trip_time: Some(base.round_trip_time), + rtx_packets_discarded: Some(base.rtx_packets_discarded), + jitter: stats.jitter, + bitrate_by_layer: stats + .bitrate_by_layer + .iter() + .map(|bitrate_by_layer| BitrateByLayer { + layer: bitrate_by_layer.layer.to_string(), + bitrate: bitrate_by_layer.bitrate, + }) + .collect(), + } + } +} /// 'trace' event data. #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(tag = "type", rename_all = "lowercase")] @@ -266,6 +371,28 @@ pub enum ProducerTraceEventType { Fir, } +impl ProducerTraceEventType { + pub(crate) fn to_fbs(self) -> producer::TraceEventType { + match self { + ProducerTraceEventType::Rtp => producer::TraceEventType::Rtp, + ProducerTraceEventType::KeyFrame => producer::TraceEventType::Keyframe, + ProducerTraceEventType::Nack => producer::TraceEventType::Nack, + ProducerTraceEventType::Pli => producer::TraceEventType::Pli, + ProducerTraceEventType::Fir => producer::TraceEventType::Fir, + } + } + + pub(crate) fn from_fbs(event_type: &producer::TraceEventType) -> Self { + match event_type { + producer::TraceEventType::Rtp => ProducerTraceEventType::Rtp, + producer::TraceEventType::Keyframe => ProducerTraceEventType::KeyFrame, + producer::TraceEventType::Nack => ProducerTraceEventType::Nack, + producer::TraceEventType::Pli => ProducerTraceEventType::Pli, + producer::TraceEventType::Fir => ProducerTraceEventType::Fir, + } + } +} + #[derive(Debug, Deserialize)] #[serde(tag = "event", rename_all = "lowercase", content = "data")] enum Notification { @@ -330,7 +457,7 @@ impl Inner { self.executor .spawn(async move { - if let Err(error) = channel.request(transport_id, request).await { + if let Err(error) = channel.request_fbs(transport_id, request).await { error!("producer closing failed on drop: {}", error); } }) @@ -578,10 +705,17 @@ impl Producer { pub async fn dump(&self) -> Result { debug!("dump()"); - self.inner() + let response = self + .inner() .channel - .request(self.id(), ProducerDumpRequest {}) - .await + .request_fbs(self.id(), ProducerDumpRequest {}) + .await?; + + if let response::Body::ProducerDumpResponse(data) = response { + Ok(ProducerDump::from_fbs(*data).expect("Error parsing dump response")) + } else { + panic!("Wrong message from worker"); + } } /// Returns current RTC statistics of the producer. @@ -591,10 +725,17 @@ impl Producer { pub async fn get_stats(&self) -> Result, RequestError> { debug!("get_stats()"); - self.inner() + let response = self + .inner() .channel - .request(self.id(), ProducerGetStatsRequest {}) - .await + .request_fbs(self.id(), ProducerGetStatsRequest {}) + .await; + + if let Ok(response::Body::ProducerGetStatsResponse(data)) = response { + Ok(data.stats.iter().map(ProducerStat::from_fbs).collect()) + } else { + panic!("Wrong message from worker"); + } } /// Pauses the producer (no RTP is sent to its associated consumers). Calls @@ -605,7 +746,7 @@ impl Producer { self.inner() .channel - .request(self.id(), ProducerPauseRequest {}) + .request_fbs(self.id(), ProducerPauseRequest {}) .await?; let was_paused = self.inner().paused.swap(true, Ordering::SeqCst); @@ -625,7 +766,7 @@ impl Producer { self.inner() .channel - .request(self.id(), ProducerResumeRequest {}) + .request_fbs(self.id(), ProducerResumeRequest {}) .await?; let was_paused = self.inner().paused.swap(false, Ordering::SeqCst); @@ -646,7 +787,7 @@ impl Producer { self.inner() .channel - .request(self.id(), ProducerEnableTraceEventRequest { types }) + .request_fbs(self.id(), ProducerEnableTraceEventRequest { types }) .await } diff --git a/rust/src/router/producer/tests.rs b/rust/src/router/producer/tests.rs index 49ed0da09f..92533c3c32 100644 --- a/rust/src/router/producer/tests.rs +++ b/rust/src/router/producer/tests.rs @@ -85,7 +85,6 @@ async fn init() -> (Router, WebRtcTransport) { } #[test] -#[ignore] fn transport_close_event() { future::block_on(async move { let (router, transport_1) = init().await; diff --git a/rust/src/router/transport.rs b/rust/src/router/transport.rs index ebb5394f4a..ba22a2fbdb 100644 --- a/rust/src/router/transport.rs +++ b/rust/src/router/transport.rs @@ -4,8 +4,8 @@ use crate::data_producer::{DataProducer, DataProducerId, DataProducerOptions, Da use crate::data_structures::{AppData, BweTraceInfo, RtpPacketTraceInfo, TraceEventDirection}; use crate::fbs::{response, transport}; use crate::messages::{ - TransportConsumeDataRequest, TransportConsumeRequest, TransportDumpRequestFbs, - TransportEnableTraceEventRequest, TransportGetStatsRequestFbs, TransportProduceDataRequest, + TransportConsumeDataRequest, TransportConsumeRequest, TransportDumpRequest, + TransportEnableTraceEventRequest, TransportGetStatsRequest, TransportProduceDataRequest, TransportProduceRequest, TransportSetMaxIncomingBitrateRequest, TransportSetMaxOutgoingBitrateRequest, TransportSetMinOutgoingBitrateRequest, }; @@ -443,13 +443,13 @@ pub(super) trait TransportImpl: TransportGeneric { async fn dump_impl(&self) -> Result { self.channel() - .request_fbs(self.id(), TransportDumpRequestFbs {}) + .request_fbs(self.id(), TransportDumpRequest {}) .await } async fn get_stats_impl(&self) -> Result { self.channel() - .request_fbs(self.id(), TransportGetStatsRequestFbs {}) + .request_fbs(self.id(), TransportGetStatsRequest {}) .await } @@ -548,7 +548,7 @@ pub(super) trait TransportImpl: TransportGeneric { let response = self .channel() - .request( + .request_fbs( self.id(), TransportProduceRequest { producer_id, diff --git a/rust/src/router/webrtc_transport.rs b/rust/src/router/webrtc_transport.rs index 293050a953..f66623cc18 100644 --- a/rust/src/router/webrtc_transport.rs +++ b/rust/src/router/webrtc_transport.rs @@ -10,7 +10,7 @@ use crate::data_structures::{ }; use crate::fbs::{notification, response, transport, web_rtc_transport}; use crate::messages::{ - TransportCloseRequestFbs, TransportRestartIceRequest, WebRtcTransportConnectRequest, + TransportCloseRequest, TransportRestartIceRequest, WebRtcTransportConnectRequest, WebRtcTransportData, }; use crate::producer::{Producer, ProducerId, ProducerOptions}; @@ -519,7 +519,7 @@ impl Inner { if close_request { let channel = self.channel.clone(); let router_id = self.router.id(); - let request = TransportCloseRequestFbs { + let request = TransportCloseRequest { transport_id: self.id, }; diff --git a/rust/src/rtp_parameters.rs b/rust/src/rtp_parameters.rs index 8af1a3a685..cdd782cc5b 100644 --- a/rust/src/rtp_parameters.rs +++ b/rust/src/rtp_parameters.rs @@ -204,11 +204,27 @@ pub enum MediaKind { Video, } +impl MediaKind { + pub(crate) fn to_fbs(self) -> rtp_parameters::MediaKind { + match self { + MediaKind::Audio => rtp_parameters::MediaKind::Audio, + MediaKind::Video => rtp_parameters::MediaKind::Video, + } + } + + pub(crate) fn from_fbs(kind: rtp_parameters::MediaKind) -> Self { + match kind { + rtp_parameters::MediaKind::Audio => MediaKind::Audio, + rtp_parameters::MediaKind::Video => MediaKind::Video, + } + } +} + /// Error that caused [`MimeType`] parsing error. #[derive(Debug, Error, Eq, PartialEq)] pub enum ParseMimeTypeError { - /// Invalid input string - #[error("Invalid input string")] + /// Invalid MIME type input string + #[error("Invalid MIME type input string")] InvalidInput, /// Unknown MIME type #[error("Unknown MIME type")] @@ -817,7 +833,7 @@ impl RtpParameters { .map(|rtcp_feedback| { RtcpFeedback::from_type_parameter( &rtcp_feedback.type_, - &rtcp_feedback.parameter, + &rtcp_feedback.parameter.unwrap_or_default(), ) }) .collect::>()?; @@ -866,8 +882,16 @@ impl RtpParameters { rtx: encoding .rtx .map(|rtx| RtpEncodingParametersRtx { ssrc: rtx.ssrc }), - dtx: Some(encoding.dtx), - scalability_mode: encoding.scalability_mode.unwrap_or_default().parse()?, + dtx: { + match encoding.dtx { + true => Some(true), + false => None, + } + }, + scalability_mode: encoding + .scalability_mode + .unwrap_or(String::from("S1T1")) + .parse()?, max_bitrate: encoding.max_bitrate, }) }) @@ -928,7 +952,7 @@ impl RtpParameters { let (r#type, parameter) = rtcp_feedback.as_type_parameter(); rtp_parameters::RtcpFeedback { type_: r#type.to_string(), - parameter: parameter.to_string(), + parameter: Some(parameter.to_string()), } }) .collect(), diff --git a/rust/src/scalability_modes.rs b/rust/src/scalability_modes.rs index 429802f8cb..de7510f5b4 100644 --- a/rust/src/scalability_modes.rs +++ b/rust/src/scalability_modes.rs @@ -118,7 +118,7 @@ impl Default for ScalabilityMode { #[derive(Debug, Error, Eq, PartialEq)] pub enum ParseScalabilityModeError { /// Invalid input string - #[error("Invalid input string")] + #[error("Invalid Scalability Mode input string")] InvalidInput, } diff --git a/rust/tests/integration/producer.rs b/rust/tests/integration/producer.rs index 0f580aab5b..7b05c34083 100644 --- a/rust/tests/integration/producer.rs +++ b/rust/tests/integration/producer.rs @@ -225,7 +225,6 @@ async fn init() -> (Worker, Router, WebRtcTransport, WebRtcTransport) { } #[test] -#[ignore] fn produce_succeeds_1() { future::block_on(async move { let (_worker, router, transport_1, _transport_2) = init().await; @@ -306,7 +305,6 @@ fn produce_succeeds_1() { } #[test] -#[ignore] fn produce_succeeds_2() { future::block_on(async move { let (_worker, router, _transport_1, transport_2) = init().await; @@ -374,7 +372,6 @@ fn produce_succeeds_2() { } #[test] -#[ignore] fn weak() { future::block_on(async move { let (_worker, _router, transport_1, _transport_2) = init().await; @@ -395,7 +392,6 @@ fn weak() { } #[test] -#[ignore] fn produce_wrong_arguments() { future::block_on(async move { let (_worker, _router, transport_1, _transport_2) = init().await; @@ -498,7 +494,6 @@ fn produce_wrong_arguments() { } #[test] -#[ignore] fn produce_unsupported_codecs() { future::block_on(async move { let (_worker, _router, transport_1, _transport_2) = init().await; @@ -576,7 +571,6 @@ fn produce_unsupported_codecs() { } #[test] -#[ignore] fn produce_already_used_mid_ssrc() { future::block_on(async move { let (_worker, _router, transport_1, transport_2) = init().await; @@ -648,8 +642,7 @@ fn produce_already_used_mid_ssrc() { } #[test] -#[ignore] -fn produce_no_mid_single_encoding_without_dir_or_ssrc() { +fn produce_no_mid_single_encoding_without_rid_or_ssrc() { future::block_on(async move { let (_worker, _router, transport_1, _transport_2) = init().await; @@ -679,7 +672,6 @@ fn produce_no_mid_single_encoding_without_dir_or_ssrc() { } #[test] -#[ignore] fn dump_succeeds() { future::block_on(async move { let (_worker, _router, transport_1, transport_2) = init().await; @@ -788,7 +780,6 @@ fn dump_succeeds() { } #[test] -#[ignore] fn get_stats_succeeds() { future::block_on(async move { let (_worker, _router, transport_1, transport_2) = init().await; @@ -824,7 +815,6 @@ fn get_stats_succeeds() { } #[test] -#[ignore] fn pause_resume_succeeds() { future::block_on(async move { let (_worker, _router, transport_1, _transport_2) = init().await; @@ -869,7 +859,6 @@ fn pause_resume_succeeds() { } #[test] -#[ignore] fn enable_trace_event_succeeds() { future::block_on(async move { let (_worker, _router, transport_1, _transport_2) = init().await; @@ -893,7 +882,10 @@ fn enable_trace_event_succeeds() { .await .expect("Failed to dump audio producer"); - assert_eq!(dump.trace_event_types.as_str(), "rtp,pli"); + assert_eq!( + dump.trace_event_types, + vec![ProducerTraceEventType::Rtp, ProducerTraceEventType::Pli] + ); } { @@ -907,13 +899,12 @@ fn enable_trace_event_succeeds() { .await .expect("Failed to dump audio producer"); - assert_eq!(dump.trace_event_types.as_str(), ""); + assert_eq!(dump.trace_event_types, vec![]); } }); } #[test] -#[ignore] fn close_event() { future::block_on(async move { let (_worker, router, transport_1, _transport_2) = init().await; diff --git a/worker/fbs/producer.fbs b/worker/fbs/producer.fbs index 28babc677f..facd090fa8 100644 --- a/worker/fbs/producer.fbs +++ b/worker/fbs/producer.fbs @@ -3,23 +3,31 @@ include "rtpStream.fbs"; namespace FBS.Producer; +enum TraceEventType: uint8 { + KEYFRAME = 0, + FIR, + NACK, + PLI, + RTP, +} + table EnableTraceEventRequest { - events: [string] (required); + events: [TraceEventType] (required); } table DumpResponse { id: string (required); kind: FBS.RtpParameters.MediaKind; - type: string (required); + type: FBS.RtpParameters.Type; rtp_parameters: FBS.RtpParameters.RtpParameters (required); rtp_mapping: FBS.RtpParameters.RtpMapping (required); - rtp_streams: [FBS.RtpStream.Dump]; - trace_event_types: [string] (required); + rtp_streams: [FBS.RtpStream.Dump] (required); + trace_event_types: [TraceEventType] (required); paused: bool; } table GetStatsResponse { - stats: [FBS.RtpStream.Stats]; + stats: [FBS.RtpStream.Stats] (required); } table SendNotification { @@ -44,14 +52,6 @@ table VideoOrientationChangeNotification { rotation: uint16; } -enum TraceType: uint8 { - KEYFRAME = 0, - FIR, - NACK, - PLI, - RTP, -} - // NOTE (windows): IN|OUT are macros defined in windef.h. enum TraceDirection: uint8 { DIRECTION_IN = 0, @@ -82,7 +82,7 @@ table RtpTraceInfo { } table TraceNotification { - type: TraceType; + type: TraceEventType; timestamp: uint64; direction: TraceDirection; info: TraceInfo; diff --git a/worker/fbs/rtpParameters.fbs b/worker/fbs/rtpParameters.fbs index a102b66cee..8bd8d7066c 100644 --- a/worker/fbs/rtpParameters.fbs +++ b/worker/fbs/rtpParameters.fbs @@ -1,13 +1,11 @@ namespace FBS.RtpParameters; enum MediaKind: uint8 { - ALL = 0, AUDIO, VIDEO } enum Type: uint8 { - NONE = 0, SIMPLE, SIMULCAST, SVC, @@ -49,8 +47,9 @@ table Parameter { } table RtcpFeedback { + // TODO: Create a specifc type. type: string (required); - parameter: string (required); + parameter: string; } table RtpCodecParameters { diff --git a/worker/fbs/rtpStream.fbs b/worker/fbs/rtpStream.fbs index 05496ebafa..e30713ce4a 100644 --- a/worker/fbs/rtpStream.fbs +++ b/worker/fbs/rtpStream.fbs @@ -30,7 +30,7 @@ table Dump { table BitrateByLayer { layer: string (required); - bitrate: uint64; + bitrate: uint32; } union StatsData { @@ -40,7 +40,7 @@ union StatsData { } table Stats { - data: StatsData; + data: StatsData (required); } table BaseStats { @@ -49,7 +49,7 @@ table BaseStats { kind: FBS.RtpParameters.MediaKind; mime_type: string (required); packets_lost: uint64; - fraction_lost: uint64; + fraction_lost: uint8; packets_discarded: uint64; packets_retransmitted: uint64; packets_repaired: uint64; @@ -69,14 +69,14 @@ table RecvStats { jitter: uint32; packet_count: uint64; byte_count: uint64; - bitrate: uint64; - bitrate_by_layer: [BitrateByLayer]; + bitrate: uint32; + bitrate_by_layer: [BitrateByLayer] (required); } table SendStats { base: Stats (required); packet_count: uint64; byte_count: uint64; - bitrate: uint64; + bitrate: uint32; } diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs index 4f21f9cc6c..def56fad5a 100644 --- a/worker/fbs/transport.fbs +++ b/worker/fbs/transport.fbs @@ -32,7 +32,7 @@ table ProduceRequest { kind: FBS.RtpParameters.MediaKind; rtp_parameters: FBS.RtpParameters.RtpParameters (required); rtp_mapping: FBS.RtpParameters.RtpMapping (required); - key_frame_request_delay: uint16; + key_frame_request_delay: uint32; paused: bool = false; } diff --git a/worker/include/RTC/Codecs/Tools.hpp b/worker/include/RTC/Codecs/Tools.hpp index 33c9d0768a..6604e2c86b 100644 --- a/worker/include/RTC/Codecs/Tools.hpp +++ b/worker/include/RTC/Codecs/Tools.hpp @@ -106,11 +106,6 @@ namespace RTC { switch (type) { - case RTC::RtpParameters::Type::NONE: - { - return false; - } - case RTC::RtpParameters::Type::SIMPLE: { return true; @@ -166,11 +161,6 @@ namespace RTC { return true; } - - default: - { - return false; - } } } diff --git a/worker/include/RTC/Consumer.hpp b/worker/include/RTC/Consumer.hpp index 7672c69180..ecb41bc839 100644 --- a/worker/include/RTC/Consumer.hpp +++ b/worker/include/RTC/Consumer.hpp @@ -190,7 +190,7 @@ namespace RTC RTC::Consumer::Listener* listener{ nullptr }; RTC::Media::Kind kind; RTC::RtpParameters rtpParameters; - RTC::RtpParameters::Type type{ RTC::RtpParameters::Type::NONE }; + RTC::RtpParameters::Type type; std::vector consumableRtpEncodings; struct RTC::RtpHeaderExtensionIds rtpHeaderExtensionIds; const std::vector* producerRtpStreamScores{ nullptr }; diff --git a/worker/include/RTC/Producer.hpp b/worker/include/RTC/Producer.hpp index cbb2b8e5ea..59e7ddab00 100644 --- a/worker/include/RTC/Producer.hpp +++ b/worker/include/RTC/Producer.hpp @@ -187,7 +187,7 @@ namespace RTC // Others. RTC::Media::Kind kind; RTC::RtpParameters rtpParameters; - RTC::RtpParameters::Type type{ RTC::RtpParameters::Type::NONE }; + RTC::RtpParameters::Type type; struct RtpMapping rtpMapping; std::vector rtpStreamByEncodingIdx; std::vector rtpStreamScores; diff --git a/worker/include/RTC/RtpDictionaries.hpp b/worker/include/RTC/RtpDictionaries.hpp index 0544d60c85..fc60435758 100644 --- a/worker/include/RTC/RtpDictionaries.hpp +++ b/worker/include/RTC/RtpDictionaries.hpp @@ -15,19 +15,9 @@ namespace RTC public: enum class Kind : uint8_t { - ALL = 0, AUDIO, VIDEO }; - - public: - static Kind GetKind(std::string& str); - static Kind GetKind(std::string&& str); - static const std::string& GetString(Kind kind); - - private: - static absl::flat_hash_map string2Kind; - static absl::flat_hash_map kind2String; }; class RtpCodecMimeType @@ -35,7 +25,6 @@ namespace RTC public: enum class Type : uint8_t { - UNSET = 0, AUDIO, VIDEO }; @@ -43,7 +32,6 @@ namespace RTC public: enum class Subtype : uint16_t { - UNSET = 0, // Audio codecs: OPUS = 100, // Multi-channel Opus. @@ -116,8 +104,8 @@ namespace RTC } public: - Type type{ Type::UNSET }; - Subtype subtype{ Subtype::UNSET }; + Type type; + Subtype subtype; private: std::string mimeType; @@ -212,7 +200,7 @@ namespace RTC uint32_t maxBitrate{ 0u }; double maxFramerate{ 0 }; bool dtx{ false }; - std::string scalabilityMode; + std::string scalabilityMode{ "S1T1" }; uint8_t spatialLayers{ 1u }; uint8_t temporalLayers{ 1u }; bool ksvc{ false }; @@ -254,7 +242,6 @@ namespace RTC public: enum class Type : uint8_t { - NONE = 0, SIMPLE, SIMULCAST, SVC, @@ -262,13 +249,11 @@ namespace RTC }; public: - static Type GetType(const RtpParameters& rtpParameters); - static Type GetType(std::string& str); - static Type GetType(std::string&& str); + static std::optional GetType(const RtpParameters& rtpParameters); static std::string& GetTypeString(Type type); + static FBS::RtpParameters::Type TypeToFbs(Type type); private: - static absl::flat_hash_map string2Type; static absl::flat_hash_map type2String; public: diff --git a/worker/meson.build b/worker/meson.build index 9e7354ebf0..9da9775242 100644 --- a/worker/meson.build +++ b/worker/meson.build @@ -123,7 +123,6 @@ common_sources = [ 'src/RTC/Codecs/VP8.cpp', 'src/RTC/Codecs/VP9.cpp', 'src/RTC/Codecs/Opus.cpp', - 'src/RTC/RtpDictionaries/Media.cpp', 'src/RTC/RtpDictionaries/Parameters.cpp', 'src/RTC/RtpDictionaries/RtcpFeedback.cpp', 'src/RTC/RtpDictionaries/RtcpParameters.cpp', diff --git a/worker/src/RTC/Producer.cpp b/worker/src/RTC/Producer.cpp index 5b67286fd8..342faa6960 100644 --- a/worker/src/RTC/Producer.cpp +++ b/worker/src/RTC/Producer.cpp @@ -39,16 +39,18 @@ namespace RTC // This may throw. this->kind = RTC::Media::Kind(data->kind()); - if (this->kind == RTC::Media::Kind::ALL) - { - MS_THROW_TYPE_ERROR("invalid empty kind"); - } - // This may throw. this->rtpParameters = RTC::RtpParameters(data->rtpParameters()); // Evaluate type. - this->type = RTC::RtpParameters::GetType(this->rtpParameters); + auto type = RTC::RtpParameters::GetType(this->rtpParameters); + + if (!type.has_value()) + { + MS_THROW_TYPE_ERROR("invalid RTP parameters"); + } + + this->type = type.value(); // Reserve a slot in rtpStreamByEncodingIdx and rtpStreamsScores vectors // for each RTP stream. @@ -296,27 +298,27 @@ namespace RTC } // Add traceEventTypes. - std::vector> traceEventTypes; + std::vector traceEventTypes; if (this->traceEventTypes.rtp) { - traceEventTypes.emplace_back(builder.CreateString("rtp")); + traceEventTypes.emplace_back(FBS::Producer::TraceEventType::RTP); } if (this->traceEventTypes.keyframe) { - traceEventTypes.emplace_back(builder.CreateString("keyframe")); + traceEventTypes.emplace_back(FBS::Producer::TraceEventType::KEYFRAME); } if (this->traceEventTypes.nack) { - traceEventTypes.emplace_back(builder.CreateString("nack")); + traceEventTypes.emplace_back(FBS::Producer::TraceEventType::NACK); } if (this->traceEventTypes.pli) { - traceEventTypes.emplace_back(builder.CreateString("pli")); + traceEventTypes.emplace_back(FBS::Producer::TraceEventType::PLI); } if (this->traceEventTypes.fir) { - traceEventTypes.emplace_back(builder.CreateString("fir")); + traceEventTypes.emplace_back(FBS::Producer::TraceEventType::FIR); } return FBS::Producer::CreateDumpResponseDirect( @@ -324,7 +326,7 @@ namespace RTC this->id.c_str(), this->kind == RTC::Media::Kind::AUDIO ? FBS::RtpParameters::MediaKind::AUDIO : FBS::RtpParameters::MediaKind::VIDEO, - RTC::RtpParameters::GetTypeString(this->type).c_str(), + RTC::RtpParameters::TypeToFbs(this->type), rtpParameters, rtpMapping, &rtpStreams, @@ -454,27 +456,38 @@ namespace RTC for (const auto& type : *body->events()) { - const auto typeStr = type->str(); - - if (typeStr == "rtp") - { - newTraceEventTypes.rtp = true; - } - else if (typeStr == "keyframe") - { - newTraceEventTypes.keyframe = true; - } - else if (typeStr == "nack") - { - newTraceEventTypes.nack = true; - } - else if (typeStr == "pli") - { - newTraceEventTypes.pli = true; - } - else if (typeStr == "fir") + switch (type) { - newTraceEventTypes.fir = true; + case FBS::Producer::TraceEventType::KEYFRAME: + { + newTraceEventTypes.keyframe = true; + + break; + } + case FBS::Producer::TraceEventType::FIR: + { + newTraceEventTypes.fir = true; + + break; + } + case FBS::Producer::TraceEventType::NACK: + { + newTraceEventTypes.nack = true; + + break; + } + case FBS::Producer::TraceEventType::PLI: + { + newTraceEventTypes.pli = true; + + break; + } + case FBS::Producer::TraceEventType::RTP: + { + newTraceEventTypes.rtp = true; + + break; + } } } @@ -1463,7 +1476,7 @@ namespace RTC auto notification = FBS::Producer::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), - FBS::Producer::TraceType::KEYFRAME, + FBS::Producer::TraceEventType::KEYFRAME, DepLibUV::GetTimeMs(), FBS::Producer::TraceDirection::DIRECTION_IN, FBS::Producer::TraceInfo::KeyFrameTraceInfo, @@ -1478,7 +1491,7 @@ namespace RTC auto notification = FBS::Producer::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), - FBS::Producer::TraceType::RTP, + FBS::Producer::TraceEventType::RTP, DepLibUV::GetTimeMs(), FBS::Producer::TraceDirection::DIRECTION_IN, FBS::Producer::TraceInfo::RtpTraceInfo, @@ -1502,7 +1515,7 @@ namespace RTC auto notification = FBS::Producer::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), - FBS::Producer::TraceType::PLI, + FBS::Producer::TraceEventType::PLI, DepLibUV::GetTimeMs(), FBS::Producer::TraceDirection::DIRECTION_OUT, FBS::Producer::TraceInfo::PliTraceInfo, @@ -1525,7 +1538,7 @@ namespace RTC auto notification = FBS::Producer::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), - FBS::Producer::TraceType::FIR, + FBS::Producer::TraceEventType::FIR, DepLibUV::GetTimeMs(), FBS::Producer::TraceDirection::DIRECTION_OUT, FBS::Producer::TraceInfo::FirTraceInfo, @@ -1545,7 +1558,7 @@ namespace RTC auto notification = FBS::Producer::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), - FBS::Producer::TraceType::NACK, + FBS::Producer::TraceEventType::NACK, DepLibUV::GetTimeMs(), FBS::Producer::TraceDirection::DIRECTION_OUT); diff --git a/worker/src/RTC/RtpDictionaries/Media.cpp b/worker/src/RTC/RtpDictionaries/Media.cpp deleted file mode 100644 index 35a780546d..0000000000 --- a/worker/src/RTC/RtpDictionaries/Media.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#define MS_CLASS "RTC::Media" -// #define MS_LOG_DEV_LEVEL 3 - -#include "Logger.hpp" -#include "MediaSoupErrors.hpp" -#include "Utils.hpp" -#include "RTC/RtpDictionaries.hpp" - -namespace RTC -{ - /* Class variables. */ - - // clang-format off - absl::flat_hash_map Media::string2Kind = - { - { "", Media::Kind::ALL }, - { "audio", Media::Kind::AUDIO }, - { "video", Media::Kind::VIDEO } - }; - absl::flat_hash_map Media::kind2String = - { - { Media::Kind::ALL, "" }, - { Media::Kind::AUDIO, "audio" }, - { Media::Kind::VIDEO, "video" } - }; - // clang-format on - - /* Class methods. */ - - Media::Kind Media::GetKind(std::string& str) - { - MS_TRACE(); - - // Force lowcase kind. - Utils::String::ToLowerCase(str); - - auto it = Media::string2Kind.find(str); - - if (it == Media::string2Kind.end()) - MS_THROW_TYPE_ERROR("invalid media kind [kind:%s]", str.c_str()); - - return it->second; - } - - Media::Kind Media::GetKind(std::string&& str) - { - MS_TRACE(); - - // Force lowcase kind. - Utils::String::ToLowerCase(str); - - auto it = Media::string2Kind.find(str); - - if (it == Media::string2Kind.end()) - MS_THROW_TYPE_ERROR("invalid media kind [kind:%s]", str.c_str()); - - return it->second; - } - - const std::string& Media::GetString(Media::Kind kind) - { - MS_TRACE(); - - return Media::kind2String.at(kind); - } -} // namespace RTC diff --git a/worker/src/RTC/RtpDictionaries/RtcpFeedback.cpp b/worker/src/RTC/RtpDictionaries/RtcpFeedback.cpp index edf2cf870d..1b735e9c8d 100644 --- a/worker/src/RTC/RtpDictionaries/RtcpFeedback.cpp +++ b/worker/src/RTC/RtpDictionaries/RtcpFeedback.cpp @@ -23,6 +23,6 @@ namespace RTC MS_TRACE(); return FBS::RtpParameters::CreateRtcpFeedbackDirect( - builder, this->type.c_str(), this->parameter.length() > 0 ? this->parameter.c_str() : nullptr); + builder, this->type.c_str(), this->parameter.empty() ? nullptr : this->parameter.c_str()); } } // namespace RTC diff --git a/worker/src/RTC/RtpDictionaries/RtpCodecMimeType.cpp b/worker/src/RTC/RtpDictionaries/RtpCodecMimeType.cpp index 3b5874ef78..b49f42844f 100644 --- a/worker/src/RTC/RtpDictionaries/RtpCodecMimeType.cpp +++ b/worker/src/RTC/RtpDictionaries/RtpCodecMimeType.cpp @@ -128,9 +128,6 @@ namespace RTC { MS_TRACE(); - MS_ASSERT(this->type != Type::UNSET, "type unset"); - MS_ASSERT(this->subtype != Subtype::UNSET, "subtype unset"); - // Set mimeType. this->mimeType = RtpCodecMimeType::type2String[this->type] + "/" + RtpCodecMimeType::subtype2String[this->subtype]; diff --git a/worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp b/worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp index a9326752be..e046c350e6 100644 --- a/worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp +++ b/worker/src/RTC/RtpDictionaries/RtpEncodingParameters.cpp @@ -89,6 +89,6 @@ namespace RTC : flatbuffers::nullopt, this->hasRtx ? this->rtx.FillBuffer(builder) : 0u, this->dtx, - this->scalabilityMode.size() > 0 ? this->scalabilityMode.c_str() : nullptr); + this->scalabilityMode.c_str()); } } // namespace RTC diff --git a/worker/src/RTC/RtpDictionaries/RtpParameters.cpp b/worker/src/RTC/RtpDictionaries/RtpParameters.cpp index d1961b91fb..df62479110 100644 --- a/worker/src/RTC/RtpDictionaries/RtpParameters.cpp +++ b/worker/src/RTC/RtpDictionaries/RtpParameters.cpp @@ -11,31 +11,22 @@ namespace RTC { /* Class variables. */ - // clang-format off - absl::flat_hash_map RtpParameters::string2Type = - { - { "none", RtpParameters::Type::NONE }, - { "simple", RtpParameters::Type::SIMPLE }, - { "simulcast", RtpParameters::Type::SIMULCAST }, - { "svc", RtpParameters::Type::SVC }, - { "pipe", RtpParameters::Type::PIPE } - }; - absl::flat_hash_map RtpParameters::type2String = - { - { RtpParameters::Type::NONE, "none" }, - { RtpParameters::Type::SIMPLE, "simple" }, + absl::flat_hash_map RtpParameters::type2String = { + { RtpParameters::Type::SIMPLE, "simple" }, { RtpParameters::Type::SIMULCAST, "simulcast" }, - { RtpParameters::Type::SVC, "svc" }, - { RtpParameters::Type::PIPE, "pipe" } + { RtpParameters::Type::SVC, "svc" }, + { RtpParameters::Type::PIPE, "pipe" } }; // clang-format on /* Class methods. */ - RtpParameters::Type RtpParameters::GetType(const RtpParameters& rtpParameters) + std::optional RtpParameters::GetType(const RtpParameters& rtpParameters) { MS_TRACE(); + std::optional type; + if (rtpParameters.encodings.size() == 1) { const auto& encoding = rtpParameters.encodings[0]; @@ -46,60 +37,49 @@ namespace RTC { if (RTC::Codecs::Tools::IsValidTypeForCodec(RtpParameters::Type::SVC, mediaCodec->mimeType)) { - return RtpParameters::Type::SVC; + type.emplace(RtpParameters::Type::SVC); } else if (RTC::Codecs::Tools::IsValidTypeForCodec( RtpParameters::Type::SIMULCAST, mediaCodec->mimeType)) { - return RtpParameters::Type::SIMULCAST; - } - else - { - return RtpParameters::Type::NONE; + type.emplace(RtpParameters::Type::SIMULCAST); } } else { - return RtpParameters::Type::SIMPLE; + type.emplace(RtpParameters::Type::SIMPLE); } } else if (rtpParameters.encodings.size() > 1) { - return RtpParameters::Type::SIMULCAST; + type.emplace(RtpParameters::Type::SIMULCAST); } - return RtpParameters::Type::NONE; + return type; } - RtpParameters::Type RtpParameters::GetType(std::string& str) - { - MS_TRACE(); - - auto it = RtpParameters::string2Type.find(str); - - if (it == RtpParameters::string2Type.end()) - MS_THROW_TYPE_ERROR("invalid RtpParameters type [type:%s]", str.c_str()); - - return it->second; - } - - RtpParameters::Type RtpParameters::GetType(std::string&& str) + std::string& RtpParameters::GetTypeString(RtpParameters::Type type) { MS_TRACE(); - auto it = RtpParameters::string2Type.find(str); - - if (it == RtpParameters::string2Type.end()) - MS_THROW_TYPE_ERROR("invalid RtpParameters type [type:%s]", str.c_str()); - - return it->second; + return RtpParameters::type2String.at(type); } - std::string& RtpParameters::GetTypeString(RtpParameters::Type type) + FBS::RtpParameters::Type RtpParameters::TypeToFbs(RtpParameters::Type type) { MS_TRACE(); - return RtpParameters::type2String.at(type); + switch (type) + { + case Type::SIMPLE: + return FBS::RtpParameters::Type::SIMPLE; + case Type::SIMULCAST: + return FBS::RtpParameters::Type::SIMULCAST; + case Type::SVC: + return FBS::RtpParameters::Type::SVC; + case Type::PIPE: + return FBS::RtpParameters::Type::PIPE; + } } /* Instance methods. */ diff --git a/worker/src/RTC/RtpStream.cpp b/worker/src/RTC/RtpStream.cpp index fb5e9e2d69..45add75d99 100644 --- a/worker/src/RTC/RtpStream.cpp +++ b/worker/src/RTC/RtpStream.cpp @@ -54,12 +54,15 @@ namespace RTC MS_TRACE(); const uint64_t nowMs = DepLibUV::GetTimeMs(); + const auto mediaKind = this->params.mimeType.type == RTC::RtpCodecMimeType::Type::AUDIO + ? FBS::RtpParameters::MediaKind::AUDIO + : FBS::RtpParameters::MediaKind::VIDEO; auto baseStats = FBS::RtpStream::CreateBaseStatsDirect( builder, nowMs, this->params.ssrc, - FBS::RtpParameters::MediaKind(this->params.mimeType.type), + mediaKind, this->params.mimeType.ToString().c_str(), this->packetsLost, this->fractionLost, diff --git a/worker/src/RTC/RtpStreamSend.cpp b/worker/src/RTC/RtpStreamSend.cpp index f55a8ac7f7..a76ce3fce4 100644 --- a/worker/src/RTC/RtpStreamSend.cpp +++ b/worker/src/RTC/RtpStreamSend.cpp @@ -51,11 +51,6 @@ namespace RTC break; } - - default: - { - MS_ABORT("codec mimeType not set"); - } } this->retransmissionBuffer = new RTC::RtpRetransmissionBuffer( diff --git a/worker/src/RTC/Transport.cpp b/worker/src/RTC/Transport.cpp index 59d7d0fc7d..bd53a9d39d 100644 --- a/worker/src/RTC/Transport.cpp +++ b/worker/src/RTC/Transport.cpp @@ -763,13 +763,6 @@ namespace RTC switch (type) { - case RTC::RtpParameters::Type::NONE: - { - MS_THROW_TYPE_ERROR("invalid type 'none'"); - - break; - } - case RTC::RtpParameters::Type::SIMPLE: { // This may throw. From 2c40a46c059d94d83919eadef58e16c1a451128f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Mon, 2 Oct 2023 11:36:41 +0200 Subject: [PATCH 31/73] FBS: Consumer (#1165) FBS: Consumer --- node/src/Consumer.ts | 95 +- node/src/Transport.ts | 5 +- rust/src/data_structures.rs | 22 +- rust/src/fbs.rs | 4299 ++++++++------------------ rust/src/messages.rs | 485 ++- rust/src/router/consumer.rs | 373 ++- rust/src/router/consumer/tests.rs | 1 - rust/src/router/producer.rs | 1 + rust/src/router/transport.rs | 2 +- rust/src/rtp_parameters.rs | 43 + rust/tests/integration/consumer.rs | 27 +- worker/fbs/common.fbs | 6 + worker/fbs/consumer.fbs | 89 +- worker/fbs/transport.fbs | 10 +- worker/src/RTC/Consumer.cpp | 84 +- worker/src/RTC/PipeConsumer.cpp | 18 +- worker/src/RTC/SimpleConsumer.cpp | 21 +- worker/src/RTC/SimulcastConsumer.cpp | 14 +- worker/src/RTC/SvcConsumer.cpp | 13 +- worker/src/RTC/Transport.cpp | 4 +- 20 files changed, 2213 insertions(+), 3399 deletions(-) diff --git a/node/src/Consumer.ts b/node/src/Consumer.ts index 4c0aeb1f19..a0ba5662ee 100644 --- a/node/src/Consumer.ts +++ b/node/src/Consumer.ts @@ -15,6 +15,7 @@ import { parseRtpStreamStats, RtpStreamSendStats } from './RtpStream'; import { AppData } from './types'; import * as utils from './utils'; import { Event, Notification } from './fbs/notification'; +import { TraceDirection as FbsTraceDirection } from './fbs/common'; import * as FbsRequest from './fbs/request'; import * as FbsTransport from './fbs/transport'; import * as FbsConsumer from './fbs/consumer'; @@ -789,9 +790,24 @@ export class Consumer throw new TypeError('every type must be a string'); } + // Convert event types. + const fbsEventTypes: FbsConsumer.TraceEventType[] = []; + + for (const eventType of types) + { + try + { + fbsEventTypes.push(consumerTraceEventTypeToFbs(eventType)); + } + catch (error) + { + logger.warn('enableTraceEvent() | [error:${error}]'); + } + } + /* Build Request. */ const requestOffset = new FbsConsumer.EnableTraceEventRequestT( - types + fbsEventTypes ).pack(this.#channel.bufferBuilder); await this.#channel.request( @@ -973,26 +989,47 @@ export function parseTraceEventData( } return { - type : fbstraceType2String(trace.type()), + type : consumerTraceEventTypeFromFbs(trace.type()), timestamp : Number(trace.timestamp()), - direction : trace.direction() === FbsConsumer.TraceDirection.DIRECTION_IN ? 'in' : 'out', + direction : trace.direction() === FbsTraceDirection.DIRECTION_IN ? 'in' : 'out', info : info ? info.unpack() : undefined }; } -function fbstraceType2String(traceType: FbsConsumer.TraceType): ConsumerTraceEventType +function consumerTraceEventTypeToFbs(eventType: ConsumerTraceEventType) + : FbsConsumer.TraceEventType +{ + switch (eventType) + { + case 'keyframe': + return FbsConsumer.TraceEventType.KEYFRAME; + case 'fir': + return FbsConsumer.TraceEventType.FIR; + case 'nack': + return FbsConsumer.TraceEventType.NACK; + case 'pli': + return FbsConsumer.TraceEventType.PLI; + case 'rtp': + return FbsConsumer.TraceEventType.RTP; + default: + throw new TypeError(`invalid eventType: ${eventType}`); + } +} + +function consumerTraceEventTypeFromFbs(traceType: FbsConsumer.TraceEventType) + : ConsumerTraceEventType { switch (traceType) { - case FbsConsumer.TraceType.KEYFRAME: + case FbsConsumer.TraceEventType.KEYFRAME: return 'keyframe'; - case FbsConsumer.TraceType.FIR: + case FbsConsumer.TraceEventType.FIR: return 'fir'; - case FbsConsumer.TraceType.NACK: + case FbsConsumer.TraceEventType.NACK: return 'nack'; - case FbsConsumer.TraceType.PLI: + case FbsConsumer.TraceEventType.PLI: return 'pli'; - case FbsConsumer.TraceType.RTP: + case FbsConsumer.TraceEventType.RTP: return 'rtp'; default: throw new TypeError(`invalid TraceType: ${traceType}`); @@ -1083,7 +1120,7 @@ function parseBaseConsumerDump(data: FbsConsumer.BaseConsumerDump): BaseConsumer consumableRtpEncodings : data.consumableRtpEncodingsLength() > 0 ? utils.parseVector(data, 'consumableRtpEncodings', parseRtpEncodingParameters) : undefined, - traceEventTypes : utils.parseVector(data, 'traceEventTypes'), + traceEventTypes : utils.parseVector(data, 'traceEventTypes', consumerTraceEventTypeFromFbs), supportedCodecPayloadTypes : utils.parseVector(data, 'supportedCodecPayloadTypes'), paused : data.paused(), producerPaused : data.producerPaused(), @@ -1091,10 +1128,10 @@ function parseBaseConsumerDump(data: FbsConsumer.BaseConsumerDump): BaseConsumer }; } -function parseSimpleConsumerDump(data: FbsConsumer.SimpleConsumerDump): SimpleConsumerDump +function parseSimpleConsumerDump(data: FbsConsumer.ConsumerDump): SimpleConsumerDump { const base = parseBaseConsumerDump(data.base()!); - const rtpStream = parseRtpStream(data.rtpStream()!); + const rtpStream = parseRtpStream(data.rtpStreams(0)!); return { ...base, @@ -1104,27 +1141,27 @@ function parseSimpleConsumerDump(data: FbsConsumer.SimpleConsumerDump): SimpleCo } function parseSimulcastConsumerDump( - data: FbsConsumer.SimulcastConsumerDump + data: FbsConsumer.ConsumerDump ) : SimulcastConsumerDump { const base = parseBaseConsumerDump(data.base()!); - const rtpStream = parseRtpStream(data.rtpStream()!); + const rtpStream = parseRtpStream(data.rtpStreams(0)!); return { ...base, type : 'simulcast', rtpStream, - preferredSpatialLayer : data.preferredSpatialLayer(), - targetSpatialLayer : data.targetSpatialLayer(), - currentSpatialLayer : data.currentSpatialLayer(), - preferredTemporalLayer : data.preferredTemporalLayer(), - targetTemporalLayer : data.targetTemporalLayer(), - currentTemporalLayer : data.currentTemporalLayer() + preferredSpatialLayer : data.preferredSpatialLayer()!, + targetSpatialLayer : data.targetSpatialLayer()!, + currentSpatialLayer : data.currentSpatialLayer()!, + preferredTemporalLayer : data.preferredTemporalLayer()!, + targetTemporalLayer : data.targetTemporalLayer()!, + currentTemporalLayer : data.currentTemporalLayer()! }; } function parseSvcConsumerDump( - data: FbsConsumer.SvcConsumerDump + data: FbsConsumer.ConsumerDump ) : SvcConsumerDump { const dump = parseSimulcastConsumerDump(data); @@ -1135,7 +1172,7 @@ function parseSvcConsumerDump( } function parsePipeConsumerDump( - data: FbsConsumer.PipeConsumerDump + data: FbsConsumer.ConsumerDump ) : PipeConsumerDump { const base = parseBaseConsumerDump(data.base()!); @@ -1150,11 +1187,13 @@ function parsePipeConsumerDump( function parseConsumerDumpResponse(data: FbsConsumer.DumpResponse): ConsumerDump { - switch (data.type()) + const type = data.data()!.base()!.type(); + + switch (type) { case FbsRtpParametersType.SIMPLE: { - const dump = new FbsConsumer.SimpleConsumerDump(); + const dump = new FbsConsumer.ConsumerDump(); data.data(dump); @@ -1163,7 +1202,7 @@ function parseConsumerDumpResponse(data: FbsConsumer.DumpResponse): ConsumerDump case FbsRtpParametersType.SIMULCAST: { - const dump = new FbsConsumer.SimulcastConsumerDump(); + const dump = new FbsConsumer.ConsumerDump(); data.data(dump); @@ -1172,7 +1211,7 @@ function parseConsumerDumpResponse(data: FbsConsumer.DumpResponse): ConsumerDump case FbsRtpParametersType.SVC: { - const dump = new FbsConsumer.SvcConsumerDump(); + const dump = new FbsConsumer.ConsumerDump(); data.data(dump); @@ -1181,7 +1220,7 @@ function parseConsumerDumpResponse(data: FbsConsumer.DumpResponse): ConsumerDump case FbsRtpParametersType.PIPE: { - const dump = new FbsConsumer.PipeConsumerDump(); + const dump = new FbsConsumer.ConsumerDump(); data.data(dump); @@ -1190,7 +1229,7 @@ function parseConsumerDumpResponse(data: FbsConsumer.DumpResponse): ConsumerDump default: { - throw new TypeError(`invalid Consumer type: ${data.type()}`); + throw new TypeError(`invalid Consumer type: ${type}`); } } } diff --git a/node/src/Transport.ts b/node/src/Transport.ts index 428c566a9e..51c704a07a 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -38,6 +38,7 @@ import { SctpStreamParameters } from './SctpParameters'; import { AppData } from './types'; +import { TraceDirection as FbsTraceDirection } from './fbs/common'; import * as FbsRequest from './fbs/request'; import { MediaKind as FbsMediaKind } from './fbs/rtp-parameters/media-kind'; import * as FbsConsumer from './fbs/consumer'; @@ -1497,7 +1498,7 @@ export function parseTransportTraceEventData( return { type : 'bwe', timestamp : Number(trace.timestamp()), - direction : trace.direction() === FbsTransport.TraceDirection.DIRECTION_IN ? 'in' : 'out', + direction : trace.direction() === FbsTraceDirection.DIRECTION_IN ? 'in' : 'out', info : parseBweTraceInfo(info!) }; } @@ -1507,7 +1508,7 @@ export function parseTransportTraceEventData( return { type : 'probation', timestamp : Number(trace.timestamp()), - direction : trace.direction() === FbsTransport.TraceDirection.DIRECTION_IN ? 'in' : 'out', + direction : trace.direction() === FbsTraceDirection.DIRECTION_IN ? 'in' : 'out', info : {} }; } diff --git a/rust/src/data_structures.rs b/rust/src/data_structures.rs index 910b11de46..7f0ff55af1 100644 --- a/rust/src/data_structures.rs +++ b/rust/src/data_structures.rs @@ -3,7 +3,7 @@ #[cfg(test)] mod tests; -use crate::fbs::{sctp_association, transport, web_rtc_transport}; +use crate::fbs::{common, sctp_association, transport, web_rtc_transport}; use serde::de::{MapAccess, Visitor}; use serde::ser::SerializeStruct; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; @@ -1034,10 +1034,10 @@ pub enum TraceEventDirection { } impl TraceEventDirection { - pub(crate) fn from_fbs(event_type: transport::TraceDirection) -> Self { + pub(crate) fn from_fbs(event_type: common::TraceDirection) -> Self { match event_type { - transport::TraceDirection::DirectionIn => TraceEventDirection::In, - transport::TraceDirection::DirectionOut => TraceEventDirection::Out, + common::TraceDirection::DirectionIn => TraceEventDirection::In, + common::TraceDirection::DirectionOut => TraceEventDirection::Out, } } } @@ -1117,6 +1117,8 @@ pub enum OwnedWebRtcMessage { EmptyBinary, } +/** + * TODO. Implement FBS conversion. /// RTP packet info in trace event. #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -1153,12 +1155,22 @@ pub struct RtpPacketTraceInfo { #[serde(default)] pub is_rtx: bool, } +*/ + +/// RTP packet info in trace event. +#[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct RtpPacketTraceInfo { + /// Whether this is an RTX packet. + #[serde(default)] + pub is_rtx: bool, +} /// SSRC info in trace event. #[derive(Debug, Copy, Clone, Deserialize, Serialize)] pub struct SsrcTraceInfo { /// RTP stream SSRC. - ssrc: u32, + pub ssrc: u32, } /// Bandwidth estimation type. diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index e4ee2a87ec..5795b8a43a 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -3066,6 +3066,176 @@ mod root { }) } } + + /// 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` /// @@ -3075,7 +3245,7 @@ mod root { /// The table `ConsumerLayers` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `ConsumerLayers` in the file `../worker/fbs/consumer.fbs:6` + /// * Table `ConsumerLayers` in the file `../worker/fbs/consumer.fbs:7` #[derive( Clone, Debug, @@ -3089,9 +3259,9 @@ mod root { )] pub struct ConsumerLayers { /// The field `spatial_layer` in the table `ConsumerLayers` - pub spatial_layer: i16, + pub spatial_layer: u8, /// The field `temporal_layer` in the table `ConsumerLayers` - pub temporal_layer: ::core::option::Option, + pub temporal_layer: ::core::option::Option, } #[allow(clippy::derivable_impls)] @@ -3114,8 +3284,8 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_spatial_layer: impl ::planus::WriteAsDefault, - field_temporal_layer: impl ::planus::WriteAsOptional, + 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); @@ -3123,10 +3293,10 @@ mod root { let mut table_writer: ::planus::table_writer::TableWriter<8> = ::core::default::Default::default(); if prepared_spatial_layer.is_some() { - table_writer.write_entry::(0); + table_writer.write_entry::(0); } if prepared_temporal_layer.is_some() { - table_writer.write_entry::(1); + table_writer.write_entry::(1); } unsafe { @@ -3134,12 +3304,12 @@ mod root { if let ::core::option::Option::Some(prepared_spatial_layer) = prepared_spatial_layer { - object_writer.write::<_, _, 2>(&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::<_, _, 2>(&prepared_temporal_layer); + object_writer.write::<_, _, 1>(&prepared_temporal_layer); } }); } @@ -3194,7 +3364,7 @@ mod root { #[allow(clippy::type_complexity)] pub fn spatial_layer(self, value: T0) -> ConsumerLayersBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, { ConsumerLayersBuilder((value,)) } @@ -3215,7 +3385,7 @@ mod root { #[allow(clippy::type_complexity)] pub fn temporal_layer(self, value: T1) -> ConsumerLayersBuilder<(T0, T1)> where - T1: ::planus::WriteAsOptional, + T1: ::planus::WriteAsOptional, { let (v0,) = self.0; ConsumerLayersBuilder((v0, value)) @@ -3243,7 +3413,7 @@ mod root { } } - impl, T1: ::planus::WriteAsOptional> + impl, T1: ::planus::WriteAsOptional> ::planus::WriteAs<::planus::Offset> for ConsumerLayersBuilder<(T0, T1)> { @@ -3258,7 +3428,7 @@ mod root { } } - impl, T1: ::planus::WriteAsOptional> + impl, T1: ::planus::WriteAsOptional> ::planus::WriteAsOptional<::planus::Offset> for ConsumerLayersBuilder<(T0, T1)> { @@ -3273,7 +3443,7 @@ mod root { } } - impl, T1: ::planus::WriteAsOptional> + impl, T1: ::planus::WriteAsOptional> ::planus::WriteAsOffset for ConsumerLayersBuilder<(T0, T1)> { #[inline] @@ -3293,7 +3463,7 @@ mod root { impl<'a> ConsumerLayersRef<'a> { /// Getter for the [`spatial_layer` field](ConsumerLayers#structfield.spatial_layer). #[inline] - pub fn spatial_layer(&self) -> ::planus::Result { + pub fn spatial_layer(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 .access(0, "ConsumerLayers", "spatial_layer")? @@ -3303,7 +3473,7 @@ mod root { /// Getter for the [`temporal_layer` field](ConsumerLayers#structfield.temporal_layer). #[inline] - pub fn temporal_layer(&self) -> ::planus::Result<::core::option::Option> { + pub fn temporal_layer(&self) -> ::planus::Result<::core::option::Option> { self.0.access(1, "ConsumerLayers", "temporal_layer") } } @@ -3414,7 +3584,7 @@ mod root { /// The table `ConsumerScore` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `ConsumerScore` in the file `../worker/fbs/consumer.fbs:11` + /// * Table `ConsumerScore` in the file `../worker/fbs/consumer.fbs:12` #[derive( Clone, Debug, @@ -3432,18 +3602,7 @@ mod root { /// The field `producer_score` in the table `ConsumerScore` pub producer_score: u8, /// The field `producer_scores` in the table `ConsumerScore` - pub producer_scores: ::core::option::Option<::planus::alloc::vec::Vec>, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for ConsumerScore { - fn default() -> Self { - Self { - score: 0, - producer_score: 0, - producer_scores: ::core::default::Default::default(), - } - } + pub producer_scores: ::planus::alloc::vec::Vec, } impl ConsumerScore { @@ -3458,7 +3617,7 @@ mod root { builder: &mut ::planus::Builder, field_score: impl ::planus::WriteAsDefault, field_producer_score: impl ::planus::WriteAsDefault, - field_producer_scores: impl ::planus::WriteAsOptional<::planus::Offset<[u8]>>, + 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); @@ -3466,9 +3625,7 @@ mod root { let mut table_writer: ::planus::table_writer::TableWriter<10> = ::core::default::Default::default(); - if prepared_producer_scores.is_some() { - table_writer.write_entry::<::planus::Offset<[u8]>>(2); - } + table_writer.write_entry::<::planus::Offset<[u8]>>(2); if prepared_score.is_some() { table_writer.write_entry::(0); } @@ -3478,11 +3635,7 @@ mod root { unsafe { table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_producer_scores) = - prepared_producer_scores - { - object_writer.write::<_, _, 4>(&prepared_producer_scores); - } + object_writer.write::<_, _, 4>(&prepared_producer_scores); if let ::core::option::Option::Some(prepared_score) = prepared_score { object_writer.write::<_, _, 1>(&prepared_score); } @@ -3590,18 +3743,11 @@ mod root { #[allow(clippy::type_complexity)] pub fn producer_scores(self, value: T2) -> ConsumerScoreBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAsOptional<::planus::Offset<[u8]>>, + T2: ::planus::WriteAs<::planus::Offset<[u8]>>, { let (v0, v1) = self.0; ConsumerScoreBuilder((v0, v1, value)) } - - /// Sets the [`producer_scores` field](ConsumerScore#structfield.producer_scores) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn producer_scores_as_null(self) -> ConsumerScoreBuilder<(T0, T1, ())> { - self.producer_scores(()) - } } impl ConsumerScoreBuilder<(T0, T1, T2)> { @@ -3621,7 +3767,7 @@ mod root { impl< T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional<::planus::Offset<[u8]>>, + T2: ::planus::WriteAs<::planus::Offset<[u8]>>, > ::planus::WriteAs<::planus::Offset> for ConsumerScoreBuilder<(T0, T1, T2)> { @@ -3639,7 +3785,7 @@ mod root { impl< T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional<::planus::Offset<[u8]>>, + T2: ::planus::WriteAs<::planus::Offset<[u8]>>, > ::planus::WriteAsOptional<::planus::Offset> for ConsumerScoreBuilder<(T0, T1, T2)> { @@ -3657,7 +3803,7 @@ mod root { impl< T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional<::planus::Offset<[u8]>>, + T2: ::planus::WriteAs<::planus::Offset<[u8]>>, > ::planus::WriteAsOffset for ConsumerScoreBuilder<(T0, T1, T2)> { #[inline] @@ -3695,10 +3841,9 @@ mod root { /// Getter for the [`producer_scores` field](ConsumerScore#structfield.producer_scores). #[inline] - pub fn producer_scores( - &self, - ) -> ::planus::Result<::core::option::Option<&'a [u8]>> { - self.0.access(2, "ConsumerScore", "producer_scores") + pub fn producer_scores(&self) -> ::planus::Result<&'a [u8]> { + self.0 + .access_required(2, "ConsumerScore", "producer_scores") } } @@ -3707,11 +3852,7 @@ mod root { let mut f = f.debug_struct("ConsumerScoreRef"); f.field("score", &self.score()); f.field("producer_score", &self.producer_score()); - if let ::core::option::Option::Some(field_producer_scores) = - self.producer_scores().transpose() - { - f.field("producer_scores", &field_producer_scores); - } + f.field("producer_scores", &self.producer_scores()); f.finish() } } @@ -3726,7 +3867,7 @@ mod root { producer_score: ::core::convert::TryInto::try_into( value.producer_score()?, )?, - producer_scores: value.producer_scores()?.map(|v| v.to_vec()), + producer_scores: value.producer_scores()?.to_vec(), }) } } @@ -3804,7 +3945,7 @@ mod root { /// The table `SetPreferredLayersRequest` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `SetPreferredLayersRequest` in the file `../worker/fbs/consumer.fbs:17` + /// * Table `SetPreferredLayersRequest` in the file `../worker/fbs/consumer.fbs:18` #[derive( Clone, Debug, @@ -4090,7 +4231,7 @@ mod root { /// The table `SetPreferredLayersResponse` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `SetPreferredLayersResponse` in the file `../worker/fbs/consumer.fbs:21` + /// * Table `SetPreferredLayersResponse` in the file `../worker/fbs/consumer.fbs:22` #[derive( Clone, Debug, @@ -4407,7 +4548,7 @@ mod root { /// The table `SetPriorityRequest` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `SetPriorityRequest` in the file `../worker/fbs/consumer.fbs:25` + /// * Table `SetPriorityRequest` in the file `../worker/fbs/consumer.fbs:26` #[derive( Clone, Debug, @@ -4691,7 +4832,7 @@ mod root { /// The table `SetPriorityResponse` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `SetPriorityResponse` in the file `../worker/fbs/consumer.fbs:29` + /// * Table `SetPriorityResponse` in the file `../worker/fbs/consumer.fbs:30` #[derive( Clone, Debug, @@ -4976,10 +5117,193 @@ mod root { } } + /// The enum `TraceEventType` in the namespace `FBS.Consumer` + /// + /// Generated from these locations: + /// * Enum `TraceEventType` in the file `../worker/fbs/consumer.fbs:34` + #[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:33` + /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/consumer.fbs:42` #[derive( Clone, Debug, @@ -4993,7 +5317,7 @@ mod root { )] pub struct EnableTraceEventRequest { /// The field `events` in the table `EnableTraceEventRequest` - pub events: ::planus::alloc::vec::Vec<::planus::alloc::string::String>, + pub events: ::planus::alloc::vec::Vec, } impl EnableTraceEventRequest { @@ -5006,13 +5330,13 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_events: impl ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + 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<[::planus::Offset]>>(0); + table_writer.write_entry::<::planus::Offset<[self::TraceEventType]>>(0); unsafe { table_writer.finish(builder, |object_writer| { @@ -5073,7 +5397,7 @@ mod root { #[allow(clippy::type_complexity)] pub fn events(self, value: T0) -> EnableTraceEventRequestBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T0: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, { EnableTraceEventRequestBuilder((value,)) } @@ -5093,7 +5417,7 @@ mod root { } } - impl]>>> + impl>> ::planus::WriteAs<::planus::Offset> for EnableTraceEventRequestBuilder<(T0,)> { @@ -5108,7 +5432,7 @@ mod root { } } - impl]>>> + impl>> ::planus::WriteAsOptional<::planus::Offset> for EnableTraceEventRequestBuilder<(T0,)> { @@ -5124,7 +5448,7 @@ mod root { } } - impl]>>> + impl>> ::planus::WriteAsOffset for EnableTraceEventRequestBuilder<(T0,)> { @@ -5148,7 +5472,13 @@ mod root { pub fn events( &self, ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + ::planus::Vector< + 'a, + ::core::result::Result< + self::TraceEventType, + ::planus::errors::UnknownEnumTag, + >, + >, > { self.0 .access_required(0, "EnableTraceEventRequest", "events") @@ -5248,358 +5578,16 @@ mod root { } } - /// The union `DumpData` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Union `DumpData` in the file `../worker/fbs/consumer.fbs:37` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub enum DumpData { - /// The variant of type `SimpleConsumerDump` in the union `DumpData` - SimpleConsumerDump(::planus::alloc::boxed::Box), - - /// The variant of type `SimulcastConsumerDump` in the union `DumpData` - SimulcastConsumerDump(::planus::alloc::boxed::Box), - - /// The variant of type `SvcConsumerDump` in the union `DumpData` - SvcConsumerDump(::planus::alloc::boxed::Box), - - /// The variant of type `PipeConsumerDump` in the union `DumpData` - PipeConsumerDump(::planus::alloc::boxed::Box), - } - - impl DumpData { - /// Creates a [DumpDataBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> DumpDataBuilder<::planus::Uninitialized> { - DumpDataBuilder(::planus::Uninitialized) - } - - #[inline] - pub fn create_simple_consumer_dump( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_simulcast_consumer_dump( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_svc_consumer_dump( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(3, value.prepare(builder).downcast()) - } - - #[inline] - pub fn create_pipe_consumer_dump( - builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(4, value.prepare(builder).downcast()) - } - } - - impl ::planus::WriteAsUnion for DumpData { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - match self { - Self::SimpleConsumerDump(value) => { - Self::create_simple_consumer_dump(builder, value) - } - Self::SimulcastConsumerDump(value) => { - Self::create_simulcast_consumer_dump(builder, value) - } - Self::SvcConsumerDump(value) => { - Self::create_svc_consumer_dump(builder, value) - } - Self::PipeConsumerDump(value) => { - Self::create_pipe_consumer_dump(builder, value) - } - } - } - } - - impl ::planus::WriteAsOptionalUnion for DumpData { - #[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 [DumpData] type. - /// - /// Can be created using the [DumpData::builder] method. - #[derive(Debug)] - #[must_use] - pub struct DumpDataBuilder(T); - - impl DumpDataBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`SimpleConsumerDump` variant](DumpData#variant.SimpleConsumerDump). - #[inline] - pub fn simple_consumer_dump( - self, - value: T, - ) -> DumpDataBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - DumpDataBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`SimulcastConsumerDump` variant](DumpData#variant.SimulcastConsumerDump). - #[inline] - pub fn simulcast_consumer_dump( - self, - value: T, - ) -> DumpDataBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, - { - DumpDataBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`SvcConsumerDump` variant](DumpData#variant.SvcConsumerDump). - #[inline] - pub fn svc_consumer_dump( - self, - value: T, - ) -> DumpDataBuilder<::planus::Initialized<3, T>> - where - T: ::planus::WriteAsOffset, - { - DumpDataBuilder(::planus::Initialized(value)) - } - - /// Creates an instance of the [`PipeConsumerDump` variant](DumpData#variant.PipeConsumerDump). - #[inline] - pub fn pipe_consumer_dump( - self, - value: T, - ) -> DumpDataBuilder<::planus::Initialized<4, T>> - where - T: ::planus::WriteAsOffset, - { - DumpDataBuilder(::planus::Initialized(value)) - } - } - - impl DumpDataBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [DumpData]. - #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::UnionOffset - where - Self: ::planus::WriteAsUnion, - { - ::planus::WriteAsUnion::prepare(&self, builder) - } - } - - impl ::planus::WriteAsUnion for DumpDataBuilder<::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 DumpDataBuilder<::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 DumpDataBuilder<::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 DumpDataBuilder<::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 DumpDataBuilder<::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 DumpDataBuilder<::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 DumpDataBuilder<::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 DumpDataBuilder<::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 [DumpData]. - #[derive(Copy, Clone, Debug)] - pub enum DumpDataRef<'a> { - SimpleConsumerDump(self::SimpleConsumerDumpRef<'a>), - SimulcastConsumerDump(self::SimulcastConsumerDumpRef<'a>), - SvcConsumerDump(self::SvcConsumerDumpRef<'a>), - PipeConsumerDump(self::PipeConsumerDumpRef<'a>), - } - - impl<'a> ::core::convert::TryFrom> for DumpData { - type Error = ::planus::Error; - - fn try_from(value: DumpDataRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - DumpDataRef::SimpleConsumerDump(value) => { - Self::SimpleConsumerDump(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - DumpDataRef::SimulcastConsumerDump(value) => { - Self::SimulcastConsumerDump(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - DumpDataRef::SvcConsumerDump(value) => { - Self::SvcConsumerDump(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - - DumpDataRef::PipeConsumerDump(value) => { - Self::PipeConsumerDump(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )) - } - }) - } - } - - impl<'a> ::planus::TableReadUnion<'a> for DumpDataRef<'a> { - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - field_offset: usize, - tag: u8, - ) -> ::core::result::Result { - match tag { - 1 => ::core::result::Result::Ok(Self::SimpleConsumerDump( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::SimulcastConsumerDump( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 3 => ::core::result::Result::Ok(Self::SvcConsumerDump( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 4 => ::core::result::Result::Ok(Self::PipeConsumerDump( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), - } - } - } - /// The table `DumpResponse` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/consumer.fbs:44` + /// * Table `DumpResponse` in the file `../worker/fbs/consumer.fbs:46` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] pub struct DumpResponse { /// The field `data` in the table `DumpResponse` - pub data: ::core::option::Option, - /// The field `type` in the table `DumpResponse` - pub type_: super::rtp_parameters::Type, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for DumpResponse { - fn default() -> Self { - Self { - data: ::core::default::Default::default(), - type_: super::rtp_parameters::Type::Simple, - } - } + pub data: ::planus::alloc::boxed::Box, } impl DumpResponse { @@ -5612,39 +5600,17 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_data: impl ::planus::WriteAsOptionalUnion, - field_type_: impl ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, + field_data: impl ::planus::WriteAs<::planus::Offset>, ) -> ::planus::Offset { let prepared_data = field_data.prepare(builder); - let prepared_type_ = - field_type_.prepare(builder, &super::rtp_parameters::Type::Simple); - let mut table_writer: ::planus::table_writer::TableWriter<10> = + let mut table_writer: ::planus::table_writer::TableWriter<6> = ::core::default::Default::default(); - if prepared_data.is_some() { - table_writer.write_entry::<::planus::Offset>(1); - } - if prepared_data.is_some() { - table_writer.write_entry::(0); - } - if prepared_type_.is_some() { - table_writer.write_entry::(2); - } + table_writer.write_entry::<::planus::Offset>(0); unsafe { table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_data) = prepared_data { - object_writer.write::<_, _, 4>(&prepared_data.offset()); - } - if let ::core::option::Option::Some(prepared_data) = prepared_data { - object_writer.write::<_, _, 1>(&prepared_data.tag()); - } - if let ::core::option::Option::Some(prepared_type_) = prepared_type_ { - object_writer.write::<_, _, 1>(&prepared_type_); - } + object_writer.write::<_, _, 4>(&prepared_data); }); } builder.current_offset() @@ -5681,7 +5647,7 @@ mod root { &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - DumpResponse::create(builder, &self.data, self.type_) + DumpResponse::create(builder, &self.data) } } @@ -5698,43 +5664,13 @@ mod root { #[allow(clippy::type_complexity)] pub fn data(self, value: T0) -> DumpResponseBuilder<(T0,)> where - T0: ::planus::WriteAsOptionalUnion, + T0: ::planus::WriteAs<::planus::Offset>, { DumpResponseBuilder((value,)) } - - /// Sets the [`data` field](DumpResponse#structfield.data) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn data_as_null(self) -> DumpResponseBuilder<((),)> { - self.data(()) - } } 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< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - { - 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)> { /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [DumpResponse]. #[inline] pub fn finish( @@ -5748,14 +5684,8 @@ mod root { } } - impl< - T0: ::planus::WriteAsOptionalUnion, - T1: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - > ::planus::WriteAs<::planus::Offset> - for DumpResponseBuilder<(T0, T1)> + impl>> + ::planus::WriteAs<::planus::Offset> for DumpResponseBuilder<(T0,)> { type Prepared = ::planus::Offset; @@ -5768,14 +5698,9 @@ mod root { } } - impl< - T0: ::planus::WriteAsOptionalUnion, - T1: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - > ::planus::WriteAsOptional<::planus::Offset> - for DumpResponseBuilder<(T0, T1)> + impl>> + ::planus::WriteAsOptional<::planus::Offset> + for DumpResponseBuilder<(T0,)> { type Prepared = ::planus::Offset; @@ -5788,21 +5713,16 @@ mod root { } } - impl< - T0: ::planus::WriteAsOptionalUnion, - T1: ::planus::WriteAsDefault< - super::rtp_parameters::Type, - super::rtp_parameters::Type, - >, - > ::planus::WriteAsOffset for DumpResponseBuilder<(T0, T1)> + impl>> + ::planus::WriteAsOffset for DumpResponseBuilder<(T0,)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - let (v0, v1) = &self.0; - DumpResponse::create(builder, v0, v1) + let (v0,) = &self.0; + DumpResponse::create(builder, v0) } } @@ -5813,31 +5733,15 @@ mod root { impl<'a> DumpResponseRef<'a> { /// Getter for the [`data` field](DumpResponse#structfield.data). #[inline] - pub fn data( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access_union(0, "DumpResponse", "data") - } - - /// 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), - ) + 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"); - if let ::core::option::Option::Some(field_data) = self.data().transpose() { - f.field("data", &field_data); - } - f.field("type_", &self.type_()); + f.field("data", &self.data()); f.finish() } } @@ -5848,12 +5752,9 @@ mod root { #[allow(unreachable_code)] fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - data: if let ::core::option::Option::Some(data) = value.data()? { - ::core::option::Option::Some(::core::convert::TryInto::try_into(data)?) - } else { - ::core::option::Option::None - }, - type_: ::core::convert::TryInto::try_into(value.type_()?)?, + data: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( + value.data()?, + )?), }) } } @@ -5931,13 +5832,15 @@ mod root { /// The table `BaseConsumerDump` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `BaseConsumerDump` in the file `../worker/fbs/consumer.fbs:49` + /// * Table `BaseConsumerDump` in the file `../worker/fbs/consumer.fbs:50` #[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` @@ -5946,14 +5849,12 @@ mod root { pub rtp_parameters: ::planus::alloc::boxed::Box, /// The field `consumable_rtp_encodings` in the table `BaseConsumerDump` - pub consumable_rtp_encodings: ::core::option::Option< + pub consumable_rtp_encodings: ::planus::alloc::vec::Vec, - >, /// The field `supported_codec_payload_types` in the table `BaseConsumerDump` - pub supported_codec_payload_types: - ::core::option::Option<::planus::alloc::vec::Vec>, + 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<::planus::alloc::string::String>, + 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` @@ -5973,6 +5874,10 @@ mod root { 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, @@ -5981,22 +5886,22 @@ mod root { field_rtp_parameters: impl ::planus::WriteAs< ::planus::Offset, >, - field_consumable_rtp_encodings: impl ::planus::WriteAsOptional< + field_consumable_rtp_encodings: impl ::planus::WriteAs< ::planus::Offset< [::planus::Offset], >, >, - field_supported_codec_payload_types: impl ::planus::WriteAsOptional< - ::planus::Offset<[u8]>, - >, + field_supported_codec_payload_types: impl ::planus::WriteAs<::planus::Offset<[u8]>>, field_trace_event_types: impl ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, + ::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); @@ -6010,32 +5915,31 @@ mod root { 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<24> = + 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>(1); + table_writer.write_entry::<::planus::Offset>(2); table_writer - .write_entry::<::planus::Offset>(3); - if prepared_consumable_rtp_encodings.is_some() { - table_writer.write_entry::<::planus::Offset< - [::planus::Offset], - >>(4); - } - if prepared_supported_codec_payload_types.is_some() { - table_writer.write_entry::<::planus::Offset<[u8]>>(5); + .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); } - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(6); if prepared_kind.is_some() { - table_writer.write_entry::(2); + table_writer.write_entry::(3); } if prepared_paused.is_some() { - table_writer.write_entry::(7); + table_writer.write_entry::(8); } if prepared_producer_paused.is_some() { - table_writer.write_entry::(8); + table_writer.write_entry::(9); } if prepared_priority.is_some() { - table_writer.write_entry::(9); + table_writer.write_entry::(10); } unsafe { @@ -6043,19 +5947,12 @@ mod root { object_writer.write::<_, _, 4>(&prepared_id); object_writer.write::<_, _, 4>(&prepared_producer_id); object_writer.write::<_, _, 4>(&prepared_rtp_parameters); - if let ::core::option::Option::Some(prepared_consumable_rtp_encodings) = - prepared_consumable_rtp_encodings - { - object_writer.write::<_, _, 4>(&prepared_consumable_rtp_encodings); - } - if let ::core::option::Option::Some( - prepared_supported_codec_payload_types, - ) = prepared_supported_codec_payload_types - { - object_writer - .write::<_, _, 4>(&prepared_supported_codec_payload_types); - } + 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); } @@ -6111,6 +6008,7 @@ mod root { BaseConsumerDump::create( builder, &self.id, + self.type_, &self.producer_id, self.kind, &self.rtp_parameters, @@ -6144,123 +6042,114 @@ mod root { } impl BaseConsumerDumpBuilder<(T0,)> { - /// Setter for the [`producer_id` field](BaseConsumerDump#structfield.producer_id). + /// Setter for the [`type` field](BaseConsumerDump#structfield.type_). #[inline] #[allow(clippy::type_complexity)] - pub fn producer_id(self, value: T1) -> BaseConsumerDumpBuilder<(T0, T1)> + pub fn type_(self, value: T1) -> BaseConsumerDumpBuilder<(T0, T1)> where - T1: ::planus::WriteAs<::planus::Offset>, + 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 [`kind` field](BaseConsumerDump#structfield.kind). + /// Setter for the [`producer_id` field](BaseConsumerDump#structfield.producer_id). #[inline] #[allow(clippy::type_complexity)] - pub fn kind(self, value: T2) -> BaseConsumerDumpBuilder<(T0, T1, T2)> + pub fn producer_id(self, value: T2) -> BaseConsumerDumpBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAsDefault< - super::rtp_parameters::MediaKind, - super::rtp_parameters::MediaKind, - >, + T2: ::planus::WriteAs<::planus::Offset>, { let (v0, v1) = self.0; BaseConsumerDumpBuilder((v0, v1, 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, ::planus::DefaultValue)> { - self.kind(::planus::DefaultValue) - } } impl BaseConsumerDumpBuilder<(T0, T1, T2)> { - /// Setter for the [`rtp_parameters` field](BaseConsumerDump#structfield.rtp_parameters). + /// Setter for the [`kind` field](BaseConsumerDump#structfield.kind). #[inline] #[allow(clippy::type_complexity)] - pub fn rtp_parameters( - self, - value: T3, - ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3)> + pub fn kind(self, value: T3) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3)> where - T3: ::planus::WriteAs<::planus::Offset>, + 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 [`consumable_rtp_encodings` field](BaseConsumerDump#structfield.consumable_rtp_encodings). + /// Setter for the [`rtp_parameters` field](BaseConsumerDump#structfield.rtp_parameters). #[inline] #[allow(clippy::type_complexity)] - pub fn consumable_rtp_encodings( + pub fn rtp_parameters( self, value: T4, ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4)> where - T4: ::planus::WriteAsOptional< - ::planus::Offset< - [::planus::Offset], - >, - >, + T4: ::planus::WriteAs<::planus::Offset>, { let (v0, v1, v2, v3) = self.0; BaseConsumerDumpBuilder((v0, v1, v2, v3, value)) } - - /// Sets the [`consumable_rtp_encodings` field](BaseConsumerDump#structfield.consumable_rtp_encodings) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn consumable_rtp_encodings_as_null( - self, - ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, ())> { - self.consumable_rtp_encodings(()) - } } impl BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`supported_codec_payload_types` field](BaseConsumerDump#structfield.supported_codec_payload_types). + /// Setter for the [`consumable_rtp_encodings` field](BaseConsumerDump#structfield.consumable_rtp_encodings). #[inline] #[allow(clippy::type_complexity)] - pub fn supported_codec_payload_types( + pub fn consumable_rtp_encodings( self, value: T5, ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> where - T5: ::planus::WriteAsOptional<::planus::Offset<[u8]>>, + T5: ::planus::WriteAs< + ::planus::Offset< + [::planus::Offset], + >, + >, { let (v0, v1, v2, v3, v4) = self.0; BaseConsumerDumpBuilder((v0, v1, v2, v3, v4, value)) } - - /// Sets the [`supported_codec_payload_types` field](BaseConsumerDump#structfield.supported_codec_payload_types) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn supported_codec_payload_types_as_null( - self, - ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, ())> { - self.supported_codec_payload_types(()) - } } impl BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`trace_event_types` field](BaseConsumerDump#structfield.trace_event_types). + /// Setter for the [`supported_codec_payload_types` field](BaseConsumerDump#structfield.supported_codec_payload_types). #[inline] #[allow(clippy::type_complexity)] - pub fn trace_event_types( + pub fn supported_codec_payload_types( self, value: T6, ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> where - T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, + T6: ::planus::WriteAs<::planus::Offset<[u8]>>, { let (v0, v1, v2, v3, v4, v5) = self.0; BaseConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, value)) @@ -6268,36 +6157,26 @@ mod root { } impl BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`paused` field](BaseConsumerDump#structfield.paused). + /// Setter for the [`trace_event_types` field](BaseConsumerDump#structfield.trace_event_types). #[inline] #[allow(clippy::type_complexity)] - pub fn paused( + pub fn trace_event_types( self, value: T7, ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> where - T7: ::planus::WriteAsDefault, + 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)) } - - /// 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, ::planus::DefaultValue)> - { - self.paused(::planus::DefaultValue) - } } impl BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Setter for the [`producer_paused` field](BaseConsumerDump#structfield.producer_paused). + /// Setter for the [`paused` field](BaseConsumerDump#structfield.paused). #[inline] #[allow(clippy::type_complexity)] - pub fn producer_paused( + pub fn paused( self, value: T8, ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> @@ -6308,38 +6187,38 @@ mod root { BaseConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, v6, v7, value)) } - /// Sets the [`producer_paused` field](BaseConsumerDump#structfield.producer_paused) to the default value. + /// Sets the [`paused` field](BaseConsumerDump#structfield.paused) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn producer_paused_as_default( + pub fn paused_as_default( self, ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, ::planus::DefaultValue)> { - self.producer_paused(::planus::DefaultValue) + self.paused(::planus::DefaultValue) } } impl BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> { - /// Setter for the [`priority` field](BaseConsumerDump#structfield.priority). + /// Setter for the [`producer_paused` field](BaseConsumerDump#structfield.producer_paused). #[inline] #[allow(clippy::type_complexity)] - pub fn priority( + pub fn producer_paused( self, value: T9, ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> where - T9: ::planus::WriteAsDefault, + 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 [`priority` field](BaseConsumerDump#structfield.priority) to the default value. + /// Sets the [`producer_paused` field](BaseConsumerDump#structfield.producer_paused) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn priority_as_default( + pub fn producer_paused_as_default( self, ) -> BaseConsumerDumpBuilder<( T0, @@ -6353,47 +6232,90 @@ mod root { T8, ::planus::DefaultValue, )> { - self.priority(::planus::DefaultValue) + self.producer_paused(::planus::DefaultValue) } } impl BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [BaseConsumerDump]. + /// Setter for the [`priority` field](BaseConsumerDump#structfield.priority). #[inline] - pub fn finish( + #[allow(clippy::type_complexity)] + pub fn priority( self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset + value: T10, + ) -> BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> where - Self: ::planus::WriteAsOffset, + T10: ::planus::WriteAsDefault, { - ::planus::WriteAsOffset::prepare(&self, builder) + 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)) } - } - 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::WriteAsOptional< - ::planus::Offset< - [::planus::Offset], - >, - >, - T5: ::planus::WriteAsOptional<::planus::Offset<[u8]>>, - T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> - { + /// 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] @@ -6407,24 +6329,28 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault< + 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, >, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsOptional< + T4: ::planus::WriteAs<::planus::Offset>, + T5: ::planus::WriteAs< ::planus::Offset< [::planus::Offset], >, >, - T5: ::planus::WriteAsOptional<::planus::Offset<[u8]>>, - T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T7: ::planus::WriteAsDefault, + T6: ::planus::WriteAs<::planus::Offset<[u8]>>, + T7: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, + T9: ::planus::WriteAsDefault, + T10: ::planus::WriteAsDefault, > ::planus::WriteAsOptional<::planus::Offset> - for BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> + for BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> { type Prepared = ::planus::Offset; @@ -6439,32 +6365,36 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault< + 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, >, - T3: ::planus::WriteAs<::planus::Offset>, - T4: ::planus::WriteAsOptional< + T4: ::planus::WriteAs<::planus::Offset>, + T5: ::planus::WriteAs< ::planus::Offset< [::planus::Offset], >, >, - T5: ::planus::WriteAsOptional<::planus::Offset<[u8]>>, - T6: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, - T7: ::planus::WriteAsDefault, + T6: ::planus::WriteAs<::planus::Offset<[u8]>>, + T7: ::planus::WriteAs<::planus::Offset<[self::TraceEventType]>>, T8: ::planus::WriteAsDefault, - T9: ::planus::WriteAsDefault, + T9: ::planus::WriteAsDefault, + T10: ::planus::WriteAsDefault, > ::planus::WriteAsOffset - for BaseConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> + 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) = &self.0; - BaseConsumerDump::create(builder, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) + 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) } } @@ -6479,10 +6409,20 @@ mod root { 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(1, "BaseConsumerDump", "producer_id") + self.0.access_required(2, "BaseConsumerDump", "producer_id") } /// Getter for the [`kind` field](BaseConsumerDump#structfield.kind). @@ -6490,7 +6430,7 @@ mod root { pub fn kind(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 - .access(2, "BaseConsumerDump", "kind")? + .access(3, "BaseConsumerDump", "kind")? .unwrap_or(super::rtp_parameters::MediaKind::Audio), ) } @@ -6501,7 +6441,7 @@ mod root { &self, ) -> ::planus::Result> { self.0 - .access_required(3, "BaseConsumerDump", "rtp_parameters") + .access_required(4, "BaseConsumerDump", "rtp_parameters") } /// Getter for the [`consumable_rtp_encodings` field](BaseConsumerDump#structfield.consumable_rtp_encodings). @@ -6509,24 +6449,20 @@ mod root { pub fn consumable_rtp_encodings( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector< - 'a, - ::planus::Result>, - >, + ::planus::Vector< + 'a, + ::planus::Result>, >, > { self.0 - .access(4, "BaseConsumerDump", "consumable_rtp_encodings") + .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<::core::option::Option<&'a [u8]>> { + pub fn supported_codec_payload_types(&self) -> ::planus::Result<&'a [u8]> { self.0 - .access(5, "BaseConsumerDump", "supported_codec_payload_types") + .access_required(6, "BaseConsumerDump", "supported_codec_payload_types") } /// Getter for the [`trace_event_types` field](BaseConsumerDump#structfield.trace_event_types). @@ -6534,10 +6470,16 @@ mod root { pub fn trace_event_types( &self, ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result<&'a ::core::primitive::str>>, + ::planus::Vector< + 'a, + ::core::result::Result< + self::TraceEventType, + ::planus::errors::UnknownEnumTag, + >, + >, > { self.0 - .access_required(6, "BaseConsumerDump", "trace_event_types") + .access_required(7, "BaseConsumerDump", "trace_event_types") } /// Getter for the [`paused` field](BaseConsumerDump#structfield.paused). @@ -6545,7 +6487,7 @@ mod root { pub fn paused(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 - .access(7, "BaseConsumerDump", "paused")? + .access(8, "BaseConsumerDump", "paused")? .unwrap_or(false), ) } @@ -6555,7 +6497,7 @@ mod root { pub fn producer_paused(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 - .access(8, "BaseConsumerDump", "producer_paused")? + .access(9, "BaseConsumerDump", "producer_paused")? .unwrap_or(false), ) } @@ -6565,7 +6507,7 @@ mod root { pub fn priority(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 - .access(9, "BaseConsumerDump", "priority")? + .access(10, "BaseConsumerDump", "priority")? .unwrap_or(0), ) } @@ -6575,22 +6517,15 @@ mod root { 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()); - if let ::core::option::Option::Some(field_consumable_rtp_encodings) = - self.consumable_rtp_encodings().transpose() - { - f.field("consumable_rtp_encodings", &field_consumable_rtp_encodings); - } - if let ::core::option::Option::Some(field_supported_codec_payload_types) = - self.supported_codec_payload_types().transpose() - { - f.field( - "supported_codec_payload_types", - &field_supported_codec_payload_types, - ); - } + 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()); @@ -6606,22 +6541,18 @@ mod root { 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: if let ::core::option::Option::Some( - consumable_rtp_encodings, - ) = value.consumable_rtp_encodings()? - { - ::core::option::Option::Some(consumable_rtp_encodings.to_vec_result()?) - } else { - ::core::option::Option::None - }, + consumable_rtp_encodings: value + .consumable_rtp_encodings()? + .to_vec_result()?, supported_codec_payload_types: value .supported_codec_payload_types()? - .map(|v| v.to_vec()), + .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( @@ -6702,359 +6633,71 @@ mod root { } } - /// The table `SimpleConsumerDump` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `SimpleConsumerDump` in the file `../worker/fbs/consumer.fbs:62` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct SimpleConsumerDump { - /// The field `base` in the table `SimpleConsumerDump` - pub base: ::planus::alloc::boxed::Box, - /// The field `rtp_stream` in the table `SimpleConsumerDump` - pub rtp_stream: ::planus::alloc::boxed::Box, - } - - impl SimpleConsumerDump { - /// Creates a [SimpleConsumerDumpBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SimpleConsumerDumpBuilder<()> { - SimpleConsumerDumpBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_base: impl ::planus::WriteAs<::planus::Offset>, - field_rtp_stream: impl ::planus::WriteAs<::planus::Offset>, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - let prepared_rtp_stream = field_rtp_stream.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_rtp_stream); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for SimpleConsumerDump { - 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 SimpleConsumerDump { - type Prepared = ::planus::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 SimpleConsumerDump { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SimpleConsumerDump::create(builder, &self.base, &self.rtp_stream) - } - } - - /// Builder for serializing an instance of the [SimpleConsumerDump] type. - /// - /// Can be created using the [SimpleConsumerDump::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SimpleConsumerDumpBuilder(State); - - impl SimpleConsumerDumpBuilder<()> { - /// Setter for the [`base` field](SimpleConsumerDump#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> SimpleConsumerDumpBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - SimpleConsumerDumpBuilder((value,)) - } - } - - impl SimpleConsumerDumpBuilder<(T0,)> { - /// Setter for the [`rtp_stream` field](SimpleConsumerDump#structfield.rtp_stream). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_stream(self, value: T1) -> SimpleConsumerDumpBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - SimpleConsumerDumpBuilder((v0, value)) - } - } - - impl SimpleConsumerDumpBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SimpleConsumerDump]. - #[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 SimpleConsumerDumpBuilder<(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 SimpleConsumerDumpBuilder<(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 SimpleConsumerDumpBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - SimpleConsumerDump::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [SimpleConsumerDump]. - #[derive(Copy, Clone)] - pub struct SimpleConsumerDumpRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SimpleConsumerDumpRef<'a> { - /// Getter for the [`base` field](SimpleConsumerDump#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "SimpleConsumerDump", "base") - } - - /// Getter for the [`rtp_stream` field](SimpleConsumerDump#structfield.rtp_stream). - #[inline] - pub fn rtp_stream(&self) -> ::planus::Result> { - self.0 - .access_required(1, "SimpleConsumerDump", "rtp_stream") - } - } - - impl<'a> ::core::fmt::Debug for SimpleConsumerDumpRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SimpleConsumerDumpRef"); - f.field("base", &self.base()); - f.field("rtp_stream", &self.rtp_stream()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for SimpleConsumerDump { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SimpleConsumerDumpRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - rtp_stream: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.rtp_stream()?)?, - ), - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SimpleConsumerDumpRef<'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 SimpleConsumerDumpRef<'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( - "[SimpleConsumerDumpRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for SimpleConsumerDump { - 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 SimpleConsumerDumpRef<'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("[SimpleConsumerDumpRef]", "read_as_root", 0) - }) - } - } - - /// The table `SimulcastConsumerDump` in the namespace `FBS.Consumer` + /// The table `ConsumerDump` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `SimulcastConsumerDump` in the file `../worker/fbs/consumer.fbs:67` + /// * Table `ConsumerDump` in the file `../worker/fbs/consumer.fbs:64` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] - pub struct SimulcastConsumerDump { - /// The field `base` in the table `SimulcastConsumerDump` + pub struct ConsumerDump { + /// The field `base` in the table `ConsumerDump` pub base: ::planus::alloc::boxed::Box, - /// The field `rtp_stream` in the table `SimulcastConsumerDump` - pub rtp_stream: ::planus::alloc::boxed::Box, - /// The field `preferred_spatial_layer` in the table `SimulcastConsumerDump` - pub preferred_spatial_layer: i16, - /// The field `target_spatial_layer` in the table `SimulcastConsumerDump` - pub target_spatial_layer: i16, - /// The field `current_spatial_layer` in the table `SimulcastConsumerDump` - pub current_spatial_layer: i16, - /// The field `preferred_temporal_layer` in the table `SimulcastConsumerDump` - pub preferred_temporal_layer: i16, - /// The field `target_temporal_layer` in the table `SimulcastConsumerDump` - pub target_temporal_layer: i16, - /// The field `current_temporal_layer` in the table `SimulcastConsumerDump` - pub current_temporal_layer: i16, + /// 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 SimulcastConsumerDump { - /// Creates a [SimulcastConsumerDumpBuilder] for serializing an instance of this table. + impl ConsumerDump { + /// Creates a [ConsumerDumpBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> SimulcastConsumerDumpBuilder<()> { - SimulcastConsumerDumpBuilder(()) + 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_stream: impl ::planus::WriteAs<::planus::Offset>, - field_preferred_spatial_layer: impl ::planus::WriteAsDefault, - field_target_spatial_layer: impl ::planus::WriteAsDefault, - field_current_spatial_layer: impl ::planus::WriteAsDefault, - field_preferred_temporal_layer: impl ::planus::WriteAsDefault, - field_target_temporal_layer: impl ::planus::WriteAsDefault, - field_current_temporal_layer: impl ::planus::WriteAsDefault, + 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_stream = field_rtp_stream.prepare(builder); + let prepared_rtp_streams = field_rtp_streams.prepare(builder); let prepared_preferred_spatial_layer = - field_preferred_spatial_layer.prepare(builder, &0); - let prepared_target_spatial_layer = - field_target_spatial_layer.prepare(builder, &0); + 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, &0); + field_current_spatial_layer.prepare(builder); let prepared_preferred_temporal_layer = - field_preferred_temporal_layer.prepare(builder, &0); + field_preferred_temporal_layer.prepare(builder); let prepared_target_temporal_layer = - field_target_temporal_layer.prepare(builder, &0); + field_target_temporal_layer.prepare(builder); let prepared_current_temporal_layer = - field_current_temporal_layer.prepare(builder, &0); + 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>(1); + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(1); if prepared_preferred_spatial_layer.is_some() { table_writer.write_entry::(2); } @@ -7077,7 +6720,7 @@ mod root { unsafe { table_writer.finish(builder, |object_writer| { object_writer.write::<_, _, 4>(&prepared_base); - object_writer.write::<_, _, 4>(&prepared_rtp_stream); + object_writer.write::<_, _, 4>(&prepared_rtp_streams); if let ::core::option::Option::Some(prepared_preferred_spatial_layer) = prepared_preferred_spatial_layer { @@ -7114,41 +6757,40 @@ mod root { } } - impl ::planus::WriteAs<::planus::Offset> for SimulcastConsumerDump { + impl ::planus::WriteAs<::planus::Offset> for ConsumerDump { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for SimulcastConsumerDump { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for SimulcastConsumerDump { + impl ::planus::WriteAsOffset for ConsumerDump { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SimulcastConsumerDump::create( + ) -> ::planus::Offset { + ConsumerDump::create( builder, &self.base, - &self.rtp_stream, + &self.rtp_streams, self.preferred_spatial_layer, self.target_spatial_layer, self.current_spatial_layer, @@ -7159,213 +6801,195 @@ mod root { } } - /// Builder for serializing an instance of the [SimulcastConsumerDump] type. + /// Builder for serializing an instance of the [ConsumerDump] type. /// - /// Can be created using the [SimulcastConsumerDump::builder] method. + /// Can be created using the [ConsumerDump::builder] method. #[derive(Debug)] #[must_use] - pub struct SimulcastConsumerDumpBuilder(State); + pub struct ConsumerDumpBuilder(State); - impl SimulcastConsumerDumpBuilder<()> { - /// Setter for the [`base` field](SimulcastConsumerDump#structfield.base). + impl ConsumerDumpBuilder<()> { + /// Setter for the [`base` field](ConsumerDump#structfield.base). #[inline] #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> SimulcastConsumerDumpBuilder<(T0,)> + pub fn base(self, value: T0) -> ConsumerDumpBuilder<(T0,)> where T0: ::planus::WriteAs<::planus::Offset>, { - SimulcastConsumerDumpBuilder((value,)) + ConsumerDumpBuilder((value,)) } } - impl SimulcastConsumerDumpBuilder<(T0,)> { - /// Setter for the [`rtp_stream` field](SimulcastConsumerDump#structfield.rtp_stream). + impl ConsumerDumpBuilder<(T0,)> { + /// Setter for the [`rtp_streams` field](ConsumerDump#structfield.rtp_streams). #[inline] #[allow(clippy::type_complexity)] - pub fn rtp_stream(self, value: T1) -> SimulcastConsumerDumpBuilder<(T0, T1)> + pub fn rtp_streams(self, value: T1) -> ConsumerDumpBuilder<(T0, T1)> where - T1: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAs< + ::planus::Offset<[::planus::Offset]>, + >, { let (v0,) = self.0; - SimulcastConsumerDumpBuilder((v0, value)) + ConsumerDumpBuilder((v0, value)) } } - impl SimulcastConsumerDumpBuilder<(T0, T1)> { - /// Setter for the [`preferred_spatial_layer` field](SimulcastConsumerDump#structfield.preferred_spatial_layer). + 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, - ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2)> + ) -> ConsumerDumpBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsOptional, { let (v0, v1) = self.0; - SimulcastConsumerDumpBuilder((v0, v1, value)) + ConsumerDumpBuilder((v0, v1, value)) } - /// Sets the [`preferred_spatial_layer` field](SimulcastConsumerDump#structfield.preferred_spatial_layer) to the default 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_default( - self, - ) -> SimulcastConsumerDumpBuilder<(T0, T1, ::planus::DefaultValue)> - { - self.preferred_spatial_layer(::planus::DefaultValue) + pub fn preferred_spatial_layer_as_null(self) -> ConsumerDumpBuilder<(T0, T1, ())> { + self.preferred_spatial_layer(()) } } - impl SimulcastConsumerDumpBuilder<(T0, T1, T2)> { - /// Setter for the [`target_spatial_layer` field](SimulcastConsumerDump#structfield.target_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, - ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, T3)> + ) -> ConsumerDumpBuilder<(T0, T1, T2, T3)> where - T3: ::planus::WriteAsDefault, + T3: ::planus::WriteAsOptional, { let (v0, v1, v2) = self.0; - SimulcastConsumerDumpBuilder((v0, v1, v2, value)) + ConsumerDumpBuilder((v0, v1, v2, value)) } - /// Sets the [`target_spatial_layer` field](SimulcastConsumerDump#structfield.target_spatial_layer) to the default 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_default( - self, - ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, ::planus::DefaultValue)> - { - self.target_spatial_layer(::planus::DefaultValue) + pub fn target_spatial_layer_as_null(self) -> ConsumerDumpBuilder<(T0, T1, T2, ())> { + self.target_spatial_layer(()) } } - impl SimulcastConsumerDumpBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`current_spatial_layer` field](SimulcastConsumerDump#structfield.current_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, - ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4)> + ) -> ConsumerDumpBuilder<(T0, T1, T2, T3, T4)> where - T4: ::planus::WriteAsDefault, + T4: ::planus::WriteAsOptional, { let (v0, v1, v2, v3) = self.0; - SimulcastConsumerDumpBuilder((v0, v1, v2, v3, value)) + ConsumerDumpBuilder((v0, v1, v2, v3, value)) } - /// Sets the [`current_spatial_layer` field](SimulcastConsumerDump#structfield.current_spatial_layer) to the default 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_default( + pub fn current_spatial_layer_as_null( self, - ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> - { - self.current_spatial_layer(::planus::DefaultValue) + ) -> ConsumerDumpBuilder<(T0, T1, T2, T3, ())> { + self.current_spatial_layer(()) } } - impl SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`preferred_temporal_layer` field](SimulcastConsumerDump#structfield.preferred_temporal_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, - ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> + ) -> ConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> where - T5: ::planus::WriteAsDefault, + T5: ::planus::WriteAsOptional, { let (v0, v1, v2, v3, v4) = self.0; - SimulcastConsumerDumpBuilder((v0, v1, v2, v3, v4, value)) + ConsumerDumpBuilder((v0, v1, v2, v3, v4, value)) } - /// Sets the [`preferred_temporal_layer` field](SimulcastConsumerDump#structfield.preferred_temporal_layer) to the default 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_default( + pub fn preferred_temporal_layer_as_null( self, - ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> - { - self.preferred_temporal_layer(::planus::DefaultValue) + ) -> ConsumerDumpBuilder<(T0, T1, T2, T3, T4, ())> { + self.preferred_temporal_layer(()) } } - impl SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`target_temporal_layer` field](SimulcastConsumerDump#structfield.target_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, - ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> + ) -> ConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> where - T6: ::planus::WriteAsDefault, + T6: ::planus::WriteAsOptional, { let (v0, v1, v2, v3, v4, v5) = self.0; - SimulcastConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, value)) + ConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, value)) } - /// Sets the [`target_temporal_layer` field](SimulcastConsumerDump#structfield.target_temporal_layer) to the default 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_default( + pub fn target_temporal_layer_as_null( self, - ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, ::planus::DefaultValue)> - { - self.target_temporal_layer(::planus::DefaultValue) + ) -> ConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, ())> { + self.target_temporal_layer(()) } } - impl SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`current_temporal_layer` field](SimulcastConsumerDump#structfield.current_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, - ) -> SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + ) -> ConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> where - T7: ::planus::WriteAsDefault, + T7: ::planus::WriteAsOptional, { let (v0, v1, v2, v3, v4, v5, v6) = self.0; - SimulcastConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, v6, value)) + ConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, v6, value)) } - /// Sets the [`current_temporal_layer` field](SimulcastConsumerDump#structfield.current_temporal_layer) to the default 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_default( + pub fn current_temporal_layer_as_null( self, - ) -> SimulcastConsumerDumpBuilder<( - T0, - T1, - T2, - T3, - T4, - T5, - T6, - ::planus::DefaultValue, - )> { - self.current_temporal_layer(::planus::DefaultValue) + ) -> ConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, ())> { + self.current_temporal_layer(()) } } - impl - SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SimulcastConsumerDump]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } @@ -7373,202 +6997,262 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAsDefault, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { + ) -> ::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, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for SimulcastConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> + 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 { + ) -> ::planus::Offset { let (v0, v1, v2, v3, v4, v5, v6, v7) = &self.0; - SimulcastConsumerDump::create(builder, v0, v1, v2, v3, v4, v5, v6, v7) + ConsumerDump::create(builder, v0, v1, v2, v3, v4, v5, v6, v7) } } - /// Reference to a deserialized [SimulcastConsumerDump]. + /// Reference to a deserialized [ConsumerDump]. #[derive(Copy, Clone)] - pub struct SimulcastConsumerDumpRef<'a>(::planus::table_reader::Table<'a>); + pub struct ConsumerDumpRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> SimulcastConsumerDumpRef<'a> { - /// Getter for the [`base` field](SimulcastConsumerDump#structfield.base). + impl<'a> ConsumerDumpRef<'a> { + /// Getter for the [`base` field](ConsumerDump#structfield.base). #[inline] pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "SimulcastConsumerDump", "base") + self.0.access_required(0, "ConsumerDump", "base") } - /// Getter for the [`rtp_stream` field](SimulcastConsumerDump#structfield.rtp_stream). + /// Getter for the [`rtp_streams` field](ConsumerDump#structfield.rtp_streams). #[inline] - pub fn rtp_stream(&self) -> ::planus::Result> { - self.0 - .access_required(1, "SimulcastConsumerDump", "rtp_stream") + 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](SimulcastConsumerDump#structfield.preferred_spatial_layer). + /// Getter for the [`preferred_spatial_layer` field](ConsumerDump#structfield.preferred_spatial_layer). #[inline] - pub fn preferred_spatial_layer(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "SimulcastConsumerDump", "preferred_spatial_layer")? - .unwrap_or(0), - ) + 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](SimulcastConsumerDump#structfield.target_spatial_layer). + /// Getter for the [`target_spatial_layer` field](ConsumerDump#structfield.target_spatial_layer). #[inline] - pub fn target_spatial_layer(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(3, "SimulcastConsumerDump", "target_spatial_layer")? - .unwrap_or(0), - ) + 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](SimulcastConsumerDump#structfield.current_spatial_layer). + /// Getter for the [`current_spatial_layer` field](ConsumerDump#structfield.current_spatial_layer). #[inline] - pub fn current_spatial_layer(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "SimulcastConsumerDump", "current_spatial_layer")? - .unwrap_or(0), - ) + 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](SimulcastConsumerDump#structfield.preferred_temporal_layer). + /// Getter for the [`preferred_temporal_layer` field](ConsumerDump#structfield.preferred_temporal_layer). #[inline] - pub fn preferred_temporal_layer(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "SimulcastConsumerDump", "preferred_temporal_layer")? - .unwrap_or(0), - ) + 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](SimulcastConsumerDump#structfield.target_temporal_layer). + /// Getter for the [`target_temporal_layer` field](ConsumerDump#structfield.target_temporal_layer). #[inline] - pub fn target_temporal_layer(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(6, "SimulcastConsumerDump", "target_temporal_layer")? - .unwrap_or(0), - ) + 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](SimulcastConsumerDump#structfield.current_temporal_layer). + /// Getter for the [`current_temporal_layer` field](ConsumerDump#structfield.current_temporal_layer). #[inline] - pub fn current_temporal_layer(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(7, "SimulcastConsumerDump", "current_temporal_layer")? - .unwrap_or(0), - ) + 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 SimulcastConsumerDumpRef<'a> { + 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("SimulcastConsumerDumpRef"); + let mut f = f.debug_struct("ConsumerDumpRef"); f.field("base", &self.base()); - f.field("rtp_stream", &self.rtp_stream()); - f.field("preferred_spatial_layer", &self.preferred_spatial_layer()); - f.field("target_spatial_layer", &self.target_spatial_layer()); - f.field("current_spatial_layer", &self.current_spatial_layer()); - f.field("preferred_temporal_layer", &self.preferred_temporal_layer()); - f.field("target_temporal_layer", &self.target_temporal_layer()); - f.field("current_temporal_layer", &self.current_temporal_layer()); + 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 SimulcastConsumerDump { + impl<'a> ::core::convert::TryFrom> for ConsumerDump { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: SimulcastConsumerDumpRef<'a>) -> ::planus::Result { + 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_stream: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.rtp_stream()?)?, - ), - preferred_spatial_layer: ::core::convert::TryInto::try_into( - value.preferred_spatial_layer()?, - )?, - target_spatial_layer: ::core::convert::TryInto::try_into( - value.target_spatial_layer()?, - )?, - current_spatial_layer: ::core::convert::TryInto::try_into( - value.current_spatial_layer()?, - )?, - preferred_temporal_layer: ::core::convert::TryInto::try_into( - value.preferred_temporal_layer()?, - )?, - target_temporal_layer: ::core::convert::TryInto::try_into( - value.target_temporal_layer()?, - )?, - current_temporal_layer: ::core::convert::TryInto::try_into( - value.current_temporal_layer()?, - )?, + 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 SimulcastConsumerDumpRef<'a> { + impl<'a> ::planus::TableRead<'a> for ConsumerDumpRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -7580,7 +7264,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for SimulcastConsumerDumpRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for ConsumerDumpRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -7590,7 +7274,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[SimulcastConsumerDumpRef]", + "[ConsumerDumpRef]", "get", buffer.offset_from_start, ) @@ -7598,8 +7282,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for SimulcastConsumerDump { - type Value = ::planus::Offset; + 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 { @@ -7608,7 +7292,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -7623,7 +7307,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for SimulcastConsumerDumpRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for ConsumerDumpRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -7633,995 +7317,46 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location( - "[SimulcastConsumerDumpRef]", - "read_as_root", - 0, - ) + error_kind.with_error_location("[ConsumerDumpRef]", "read_as_root", 0) }) } } - /// The table `SvcConsumerDump` in the namespace `FBS.Consumer` + /// The table `GetStatsResponse` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `SvcConsumerDump` in the file `../worker/fbs/consumer.fbs:78` + /// * Table `GetStatsResponse` in the file `../worker/fbs/consumer.fbs:75` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] - pub struct SvcConsumerDump { - /// The field `base` in the table `SvcConsumerDump` - pub base: ::planus::alloc::boxed::Box, - /// The field `rtp_stream` in the table `SvcConsumerDump` - pub rtp_stream: ::planus::alloc::boxed::Box, - /// The field `preferred_spatial_layer` in the table `SvcConsumerDump` - pub preferred_spatial_layer: i16, - /// The field `target_spatial_layer` in the table `SvcConsumerDump` - pub target_spatial_layer: i16, - /// The field `current_spatial_layer` in the table `SvcConsumerDump` - pub current_spatial_layer: i16, - /// The field `preferred_temporal_layer` in the table `SvcConsumerDump` - pub preferred_temporal_layer: i16, - /// The field `target_temporal_layer` in the table `SvcConsumerDump` - pub target_temporal_layer: i16, - /// The field `current_temporal_layer` in the table `SvcConsumerDump` - pub current_temporal_layer: i16, + pub struct GetStatsResponse { + /// The field `stats` in the table `GetStatsResponse` + pub stats: ::planus::alloc::vec::Vec, } - impl SvcConsumerDump { - /// Creates a [SvcConsumerDumpBuilder] for serializing an instance of this table. + impl GetStatsResponse { + /// Creates a [GetStatsResponseBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> SvcConsumerDumpBuilder<()> { - SvcConsumerDumpBuilder(()) + 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_rtp_stream: impl ::planus::WriteAs<::planus::Offset>, - field_preferred_spatial_layer: impl ::planus::WriteAsDefault, - field_target_spatial_layer: impl ::planus::WriteAsDefault, - field_current_spatial_layer: impl ::planus::WriteAsDefault, - field_preferred_temporal_layer: impl ::planus::WriteAsDefault, - field_target_temporal_layer: impl ::planus::WriteAsDefault, - field_current_temporal_layer: impl ::planus::WriteAsDefault, + field_stats: impl ::planus::WriteAs< + ::planus::Offset<[::planus::Offset]>, + >, ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - let prepared_rtp_stream = field_rtp_stream.prepare(builder); - let prepared_preferred_spatial_layer = - field_preferred_spatial_layer.prepare(builder, &0); - let prepared_target_spatial_layer = - field_target_spatial_layer.prepare(builder, &0); - let prepared_current_spatial_layer = - field_current_spatial_layer.prepare(builder, &0); - let prepared_preferred_temporal_layer = - field_preferred_temporal_layer.prepare(builder, &0); - let prepared_target_temporal_layer = - field_target_temporal_layer.prepare(builder, &0); - let prepared_current_temporal_layer = - field_current_temporal_layer.prepare(builder, &0); + let prepared_stats = field_stats.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<20> = + let mut table_writer: ::planus::table_writer::TableWriter<6> = ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); - table_writer.write_entry::<::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_stream); - 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 SvcConsumerDump { - 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 SvcConsumerDump { - type Prepared = ::planus::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 SvcConsumerDump { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SvcConsumerDump::create( - builder, - &self.base, - &self.rtp_stream, - 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 [SvcConsumerDump] type. - /// - /// Can be created using the [SvcConsumerDump::builder] method. - #[derive(Debug)] - #[must_use] - pub struct SvcConsumerDumpBuilder(State); - - impl SvcConsumerDumpBuilder<()> { - /// Setter for the [`base` field](SvcConsumerDump#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> SvcConsumerDumpBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - SvcConsumerDumpBuilder((value,)) - } - } - - impl SvcConsumerDumpBuilder<(T0,)> { - /// Setter for the [`rtp_stream` field](SvcConsumerDump#structfield.rtp_stream). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_stream(self, value: T1) -> SvcConsumerDumpBuilder<(T0, T1)> - where - T1: ::planus::WriteAs<::planus::Offset>, - { - let (v0,) = self.0; - SvcConsumerDumpBuilder((v0, value)) - } - } - - impl SvcConsumerDumpBuilder<(T0, T1)> { - /// Setter for the [`preferred_spatial_layer` field](SvcConsumerDump#structfield.preferred_spatial_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn preferred_spatial_layer( - self, - value: T2, - ) -> SvcConsumerDumpBuilder<(T0, T1, T2)> - where - T2: ::planus::WriteAsDefault, - { - let (v0, v1) = self.0; - SvcConsumerDumpBuilder((v0, v1, value)) - } - - /// Sets the [`preferred_spatial_layer` field](SvcConsumerDump#structfield.preferred_spatial_layer) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn preferred_spatial_layer_as_default( - self, - ) -> SvcConsumerDumpBuilder<(T0, T1, ::planus::DefaultValue)> { - self.preferred_spatial_layer(::planus::DefaultValue) - } - } - - impl SvcConsumerDumpBuilder<(T0, T1, T2)> { - /// Setter for the [`target_spatial_layer` field](SvcConsumerDump#structfield.target_spatial_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn target_spatial_layer( - self, - value: T3, - ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3)> - where - T3: ::planus::WriteAsDefault, - { - let (v0, v1, v2) = self.0; - SvcConsumerDumpBuilder((v0, v1, v2, value)) - } - - /// Sets the [`target_spatial_layer` field](SvcConsumerDump#structfield.target_spatial_layer) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn target_spatial_layer_as_default( - self, - ) -> SvcConsumerDumpBuilder<(T0, T1, T2, ::planus::DefaultValue)> { - self.target_spatial_layer(::planus::DefaultValue) - } - } - - impl SvcConsumerDumpBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`current_spatial_layer` field](SvcConsumerDump#structfield.current_spatial_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn current_spatial_layer( - self, - value: T4, - ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4)> - where - T4: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3) = self.0; - SvcConsumerDumpBuilder((v0, v1, v2, v3, value)) - } - - /// Sets the [`current_spatial_layer` field](SvcConsumerDump#structfield.current_spatial_layer) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn current_spatial_layer_as_default( - self, - ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> - { - self.current_spatial_layer(::planus::DefaultValue) - } - } - - impl SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4)> { - /// Setter for the [`preferred_temporal_layer` field](SvcConsumerDump#structfield.preferred_temporal_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn preferred_temporal_layer( - self, - value: T5, - ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> - where - T5: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4) = self.0; - SvcConsumerDumpBuilder((v0, v1, v2, v3, v4, value)) - } - - /// Sets the [`preferred_temporal_layer` field](SvcConsumerDump#structfield.preferred_temporal_layer) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn preferred_temporal_layer_as_default( - self, - ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> - { - self.preferred_temporal_layer(::planus::DefaultValue) - } - } - - impl SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`target_temporal_layer` field](SvcConsumerDump#structfield.target_temporal_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn target_temporal_layer( - self, - value: T6, - ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> - where - T6: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5) = self.0; - SvcConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, value)) - } - - /// Sets the [`target_temporal_layer` field](SvcConsumerDump#structfield.target_temporal_layer) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn target_temporal_layer_as_default( - self, - ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, ::planus::DefaultValue)> - { - self.target_temporal_layer(::planus::DefaultValue) - } - } - - impl SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`current_temporal_layer` field](SvcConsumerDump#structfield.current_temporal_layer). - #[inline] - #[allow(clippy::type_complexity)] - pub fn current_temporal_layer( - self, - value: T7, - ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> - where - T7: ::planus::WriteAsDefault, - { - let (v0, v1, v2, v3, v4, v5, v6) = self.0; - SvcConsumerDumpBuilder((v0, v1, v2, v3, v4, v5, v6, value)) - } - - /// Sets the [`current_temporal_layer` field](SvcConsumerDump#structfield.current_temporal_layer) to the default value. - #[inline] - #[allow(clippy::type_complexity)] - pub fn current_temporal_layer_as_default( - self, - ) -> SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, ::planus::DefaultValue)> - { - self.current_temporal_layer(::planus::DefaultValue) - } - } - - impl SvcConsumerDumpBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SvcConsumerDump]. - #[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, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> - for SvcConsumerDumpBuilder<(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, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAsOptional<::planus::Offset> - for SvcConsumerDumpBuilder<(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, - T3: ::planus::WriteAsDefault, - T4: ::planus::WriteAsDefault, - T5: ::planus::WriteAsDefault, - T6: ::planus::WriteAsDefault, - T7: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset - for SvcConsumerDumpBuilder<(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; - SvcConsumerDump::create(builder, v0, v1, v2, v3, v4, v5, v6, v7) - } - } - - /// Reference to a deserialized [SvcConsumerDump]. - #[derive(Copy, Clone)] - pub struct SvcConsumerDumpRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> SvcConsumerDumpRef<'a> { - /// Getter for the [`base` field](SvcConsumerDump#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "SvcConsumerDump", "base") - } - - /// Getter for the [`rtp_stream` field](SvcConsumerDump#structfield.rtp_stream). - #[inline] - pub fn rtp_stream(&self) -> ::planus::Result> { - self.0.access_required(1, "SvcConsumerDump", "rtp_stream") - } - - /// Getter for the [`preferred_spatial_layer` field](SvcConsumerDump#structfield.preferred_spatial_layer). - #[inline] - pub fn preferred_spatial_layer(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(2, "SvcConsumerDump", "preferred_spatial_layer")? - .unwrap_or(0), - ) - } - - /// Getter for the [`target_spatial_layer` field](SvcConsumerDump#structfield.target_spatial_layer). - #[inline] - pub fn target_spatial_layer(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(3, "SvcConsumerDump", "target_spatial_layer")? - .unwrap_or(0), - ) - } - - /// Getter for the [`current_spatial_layer` field](SvcConsumerDump#structfield.current_spatial_layer). - #[inline] - pub fn current_spatial_layer(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "SvcConsumerDump", "current_spatial_layer")? - .unwrap_or(0), - ) - } - - /// Getter for the [`preferred_temporal_layer` field](SvcConsumerDump#structfield.preferred_temporal_layer). - #[inline] - pub fn preferred_temporal_layer(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "SvcConsumerDump", "preferred_temporal_layer")? - .unwrap_or(0), - ) - } - - /// Getter for the [`target_temporal_layer` field](SvcConsumerDump#structfield.target_temporal_layer). - #[inline] - pub fn target_temporal_layer(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(6, "SvcConsumerDump", "target_temporal_layer")? - .unwrap_or(0), - ) - } - - /// Getter for the [`current_temporal_layer` field](SvcConsumerDump#structfield.current_temporal_layer). - #[inline] - pub fn current_temporal_layer(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(7, "SvcConsumerDump", "current_temporal_layer")? - .unwrap_or(0), - ) - } - } - - impl<'a> ::core::fmt::Debug for SvcConsumerDumpRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("SvcConsumerDumpRef"); - f.field("base", &self.base()); - f.field("rtp_stream", &self.rtp_stream()); - f.field("preferred_spatial_layer", &self.preferred_spatial_layer()); - f.field("target_spatial_layer", &self.target_spatial_layer()); - f.field("current_spatial_layer", &self.current_spatial_layer()); - f.field("preferred_temporal_layer", &self.preferred_temporal_layer()); - f.field("target_temporal_layer", &self.target_temporal_layer()); - f.field("current_temporal_layer", &self.current_temporal_layer()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for SvcConsumerDump { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: SvcConsumerDumpRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(Self { - base: ::planus::alloc::boxed::Box::new(::core::convert::TryInto::try_into( - value.base()?, - )?), - rtp_stream: ::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(value.rtp_stream()?)?, - ), - preferred_spatial_layer: ::core::convert::TryInto::try_into( - value.preferred_spatial_layer()?, - )?, - target_spatial_layer: ::core::convert::TryInto::try_into( - value.target_spatial_layer()?, - )?, - current_spatial_layer: ::core::convert::TryInto::try_into( - value.current_spatial_layer()?, - )?, - preferred_temporal_layer: ::core::convert::TryInto::try_into( - value.preferred_temporal_layer()?, - )?, - target_temporal_layer: ::core::convert::TryInto::try_into( - value.target_temporal_layer()?, - )?, - current_temporal_layer: ::core::convert::TryInto::try_into( - value.current_temporal_layer()?, - )?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for SvcConsumerDumpRef<'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 SvcConsumerDumpRef<'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( - "[SvcConsumerDumpRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for SvcConsumerDump { - 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 SvcConsumerDumpRef<'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("[SvcConsumerDumpRef]", "read_as_root", 0) - }) - } - } - - /// The table `PipeConsumerDump` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Table `PipeConsumerDump` in the file `../worker/fbs/consumer.fbs:89` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct PipeConsumerDump { - /// The field `base` in the table `PipeConsumerDump` - pub base: ::planus::alloc::boxed::Box, - /// The field `rtp_streams` in the table `PipeConsumerDump` - pub rtp_streams: ::planus::alloc::vec::Vec, - } - - impl PipeConsumerDump { - /// Creates a [PipeConsumerDumpBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> PipeConsumerDumpBuilder<()> { - PipeConsumerDumpBuilder(()) - } - - #[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]>, - >, - ) -> ::planus::Offset { - let prepared_base = field_base.prepare(builder); - let prepared_rtp_streams = field_rtp_streams.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_base); - object_writer.write::<_, _, 4>(&prepared_rtp_streams); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for PipeConsumerDump { - 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 PipeConsumerDump { - type Prepared = ::planus::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 PipeConsumerDump { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - PipeConsumerDump::create(builder, &self.base, &self.rtp_streams) - } - } - - /// Builder for serializing an instance of the [PipeConsumerDump] type. - /// - /// Can be created using the [PipeConsumerDump::builder] method. - #[derive(Debug)] - #[must_use] - pub struct PipeConsumerDumpBuilder(State); - - impl PipeConsumerDumpBuilder<()> { - /// Setter for the [`base` field](PipeConsumerDump#structfield.base). - #[inline] - #[allow(clippy::type_complexity)] - pub fn base(self, value: T0) -> PipeConsumerDumpBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset>, - { - PipeConsumerDumpBuilder((value,)) - } - } - - impl PipeConsumerDumpBuilder<(T0,)> { - /// Setter for the [`rtp_streams` field](PipeConsumerDump#structfield.rtp_streams). - #[inline] - #[allow(clippy::type_complexity)] - pub fn rtp_streams(self, value: T1) -> PipeConsumerDumpBuilder<(T0, T1)> - where - T1: ::planus::WriteAs< - ::planus::Offset<[::planus::Offset]>, - >, - { - let (v0,) = self.0; - PipeConsumerDumpBuilder((v0, value)) - } - } - - impl PipeConsumerDumpBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [PipeConsumerDump]. - #[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 PipeConsumerDumpBuilder<(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 PipeConsumerDumpBuilder<(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 PipeConsumerDumpBuilder<(T0, T1)> - { - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - PipeConsumerDump::create(builder, v0, v1) - } - } - - /// Reference to a deserialized [PipeConsumerDump]. - #[derive(Copy, Clone)] - pub struct PipeConsumerDumpRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> PipeConsumerDumpRef<'a> { - /// Getter for the [`base` field](PipeConsumerDump#structfield.base). - #[inline] - pub fn base(&self) -> ::planus::Result> { - self.0.access_required(0, "PipeConsumerDump", "base") - } - - /// Getter for the [`rtp_streams` field](PipeConsumerDump#structfield.rtp_streams). - #[inline] - pub fn rtp_streams( - &self, - ) -> ::planus::Result< - ::planus::Vector<'a, ::planus::Result>>, - > { - self.0.access_required(1, "PipeConsumerDump", "rtp_streams") - } - } - - impl<'a> ::core::fmt::Debug for PipeConsumerDumpRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("PipeConsumerDumpRef"); - f.field("base", &self.base()); - f.field("rtp_streams", &self.rtp_streams()); - f.finish() - } - } - - impl<'a> ::core::convert::TryFrom> for PipeConsumerDump { - type Error = ::planus::Error; - - #[allow(unreachable_code)] - fn try_from(value: PipeConsumerDumpRef<'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()?, - }) - } - } - - impl<'a> ::planus::TableRead<'a> for PipeConsumerDumpRef<'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 PipeConsumerDumpRef<'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( - "[PipeConsumerDumpRef]", - "get", - buffer.offset_from_start, - ) - }) - } - } - - impl ::planus::VectorWrite<::planus::Offset> for PipeConsumerDump { - 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 PipeConsumerDumpRef<'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("[PipeConsumerDumpRef]", "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:94` - #[derive( - Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, - )] - pub struct GetStatsResponse { - /// The field `stats` in the table `GetStatsResponse` - pub stats: - ::core::option::Option<::planus::alloc::vec::Vec>, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for GetStatsResponse { - fn default() -> Self { - Self { - stats: ::core::default::Default::default(), - } - } - } - - 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::WriteAsOptional< - ::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(); - if prepared_stats.is_some() { - table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(0); - } + table_writer.write_entry::<::planus::Offset<[::planus::Offset]>>(0); unsafe { table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_stats) = prepared_stats { - object_writer.write::<_, _, 4>(&prepared_stats); - } + object_writer.write::<_, _, 4>(&prepared_stats); }); } builder.current_offset() @@ -8675,19 +7410,12 @@ mod root { #[allow(clippy::type_complexity)] pub fn stats(self, value: T0) -> GetStatsResponseBuilder<(T0,)> where - T0: ::planus::WriteAsOptional< + T0: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, { GetStatsResponseBuilder((value,)) } - - /// Sets the [`stats` field](GetStatsResponse#structfield.stats) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn stats_as_null(self) -> GetStatsResponseBuilder<((),)> { - self.stats(()) - } } impl GetStatsResponseBuilder<(T0,)> { @@ -8705,7 +7433,7 @@ mod root { } impl< - T0: ::planus::WriteAsOptional< + T0: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, > ::planus::WriteAs<::planus::Offset> @@ -8723,7 +7451,7 @@ mod root { } impl< - T0: ::planus::WriteAsOptional< + T0: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, > ::planus::WriteAsOptional<::planus::Offset> @@ -8741,7 +7469,7 @@ mod root { } impl< - T0: ::planus::WriteAsOptional< + T0: ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, > ::planus::WriteAsOffset for GetStatsResponseBuilder<(T0,)> @@ -8766,20 +7494,16 @@ mod root { pub fn stats( &self, ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, + ::planus::Vector<'a, ::planus::Result>>, > { - self.0.access(0, "GetStatsResponse", "stats") + 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"); - if let ::core::option::Option::Some(field_stats) = self.stats().transpose() { - f.field("stats", &field_stats); - } + f.field("stats", &self.stats()); f.finish() } } @@ -8790,11 +7514,7 @@ mod root { #[allow(unreachable_code)] fn try_from(value: GetStatsResponseRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - stats: if let ::core::option::Option::Some(stats) = value.stats()? { - ::core::option::Option::Some(stats.to_vec_result()?) - } else { - ::core::option::Option::None - }, + stats: value.stats()?.to_vec_result()?, }) } } @@ -8872,7 +7592,7 @@ mod root { /// The table `LayersChangeNotification` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `LayersChangeNotification` in the file `../worker/fbs/consumer.fbs:100` + /// * Table `LayersChangeNotification` in the file `../worker/fbs/consumer.fbs:81` #[derive( Clone, Debug, @@ -8886,8 +7606,7 @@ mod root { )] pub struct LayersChangeNotification { /// The field `layers` in the table `LayersChangeNotification` - pub layers: - ::core::option::Option<::planus::alloc::boxed::Box>, + pub layers: ::planus::alloc::boxed::Box, } #[allow(clippy::derivable_impls)] @@ -8909,21 +7628,17 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_layers: impl ::planus::WriteAsOptional<::planus::Offset>, + 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(); - if prepared_layers.is_some() { - table_writer.write_entry::<::planus::Offset>(0); - } + table_writer.write_entry::<::planus::Offset>(0); unsafe { table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_layers) = prepared_layers { - object_writer.write::<_, _, 4>(&prepared_layers); - } + object_writer.write::<_, _, 4>(&prepared_layers); }); } builder.current_offset() @@ -8980,17 +7695,10 @@ mod root { #[allow(clippy::type_complexity)] pub fn layers(self, value: T0) -> LayersChangeNotificationBuilder<(T0,)> where - T0: ::planus::WriteAsOptional<::planus::Offset>, + T0: ::planus::WriteAs<::planus::Offset>, { LayersChangeNotificationBuilder((value,)) } - - /// Sets the [`layers` field](LayersChangeNotification#structfield.layers) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn layers_as_null(self) -> LayersChangeNotificationBuilder<((),)> { - self.layers(()) - } } impl LayersChangeNotificationBuilder<(T0,)> { @@ -9007,7 +7715,7 @@ mod root { } } - impl>> + impl>> ::planus::WriteAs<::planus::Offset> for LayersChangeNotificationBuilder<(T0,)> { @@ -9022,7 +7730,7 @@ mod root { } } - impl>> + impl>> ::planus::WriteAsOptional<::planus::Offset> for LayersChangeNotificationBuilder<(T0,)> { @@ -9038,7 +7746,7 @@ mod root { } } - impl>> + impl>> ::planus::WriteAsOffset for LayersChangeNotificationBuilder<(T0,)> { @@ -9059,20 +7767,16 @@ mod root { impl<'a> LayersChangeNotificationRef<'a> { /// Getter for the [`layers` field](LayersChangeNotification#structfield.layers). #[inline] - pub fn layers( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(0, "LayersChangeNotification", "layers") + 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"); - if let ::core::option::Option::Some(field_layers) = self.layers().transpose() { - f.field("layers", &field_layers); - } + f.field("layers", &self.layers()); f.finish() } } @@ -9083,13 +7787,9 @@ mod root { #[allow(unreachable_code)] fn try_from(value: LayersChangeNotificationRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - layers: if let ::core::option::Option::Some(layers) = value.layers()? { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(layers)?, - )) - } else { - ::core::option::Option::None - }, + layers: ::planus::alloc::boxed::Box::new( + ::core::convert::TryInto::try_into(value.layers()?)?, + ), }) } } @@ -9173,7 +7873,7 @@ mod root { /// The table `RtpNotification` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `RtpNotification` in the file `../worker/fbs/consumer.fbs:104` + /// * Table `RtpNotification` in the file `../worker/fbs/consumer.fbs:85` #[derive( Clone, Debug, @@ -9431,7 +8131,7 @@ mod root { /// The table `ScoreNotification` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `ScoreNotification` in the file `../worker/fbs/consumer.fbs:108` + /// * Table `ScoreNotification` in the file `../worker/fbs/consumer.fbs:89` #[derive( Clone, Debug, @@ -9448,15 +8148,6 @@ mod root { pub score: ::planus::alloc::boxed::Box, } - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for ScoreNotification { - fn default() -> Self { - Self { - score: ::core::default::Default::default(), - } - } - } - impl ScoreNotification { /// Creates a [ScoreNotificationBuilder] for serializing an instance of this table. #[inline] @@ -9484,576 +8175,223 @@ mod root { } } - 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 enum `TraceType` in the namespace `FBS.Consumer` - /// - /// Generated from these locations: - /// * Enum `TraceType` in the file `../worker/fbs/consumer.fbs:112` - #[derive( - Copy, - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - #[repr(u8)] - pub enum TraceType { - /// The variant `KEYFRAME` in the enum `TraceType` - Keyframe = 0, - - /// The variant `FIR` in the enum `TraceType` - Fir = 1, - - /// The variant `NACK` in the enum `TraceType` - Nack = 2, - - /// The variant `PLI` in the enum `TraceType` - Pli = 3, - - /// The variant `RTP` in the enum `TraceType` - Rtp = 4, - } - - impl TraceType { - /// Array containing all valid variants of TraceType - pub const ENUM_VALUES: [Self; 5] = - [Self::Keyframe, Self::Fir, Self::Nack, Self::Pli, Self::Rtp]; - } - - impl ::core::convert::TryFrom for TraceType { - 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(TraceType::Keyframe), - 1 => ::core::result::Result::Ok(TraceType::Fir), - 2 => ::core::result::Result::Ok(TraceType::Nack), - 3 => ::core::result::Result::Ok(TraceType::Pli), - 4 => ::core::result::Result::Ok(TraceType::Rtp), - - _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { - tag: value as i128, - }), - } - } - } - - impl ::core::convert::From for u8 { - #[inline] - fn from(value: TraceType) -> Self { - value as u8 - } - } - - impl ::planus::Primitive for TraceType { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } - - impl ::planus::WriteAsPrimitive for TraceType { - #[inline] - fn write( - &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); - } - } - - impl ::planus::WriteAs for TraceType { - type Prepared = Self; - - #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> TraceType { - *self - } - } - - impl ::planus::WriteAsDefault for TraceType { - type Prepared = Self; - - #[inline] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - default: &TraceType, - ) -> ::core::option::Option { - if self == default { - ::core::option::Option::None - } else { - ::core::option::Option::Some(*self) - } - } - } - - impl ::planus::WriteAsOptional for TraceType { - 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 TraceType { - #[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 TraceType { - 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( - "TraceType", - "VectorRead::from_buffer", - buffer.offset_from_start, - ) - }) + 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::VectorWrite for TraceType { - const STRIDE: usize = 1; - - type Value = Self; + impl ::planus::WriteAsOptional<::planus::Offset> for ScoreNotification { + type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self + 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] - 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, - ); - } + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ScoreNotification::create(builder, &self.score) } } - /// The enum `TraceDirection` in the namespace `FBS.Consumer` + /// Builder for serializing an instance of the [ScoreNotification] type. /// - /// Generated from these locations: - /// * Enum `TraceDirection` in the file `../worker/fbs/consumer.fbs:121` - #[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]; - } + /// Can be created using the [ScoreNotification::builder] method. + #[derive(Debug)] + #[must_use] + pub struct ScoreNotificationBuilder(State); - impl ::core::convert::TryFrom for TraceDirection { - type Error = ::planus::errors::UnknownEnumTagKind; + impl ScoreNotificationBuilder<()> { + /// Setter for the [`score` field](ScoreNotification#structfield.score). #[inline] - fn try_from( - value: u8, - ) -> ::core::result::Result + #[allow(clippy::type_complexity)] + pub fn score(self, value: T0) -> ScoreNotificationBuilder<(T0,)> + where + T0: ::planus::WriteAs<::planus::Offset>, { - #[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, - }), - } + ScoreNotificationBuilder((value,)) } } - impl ::core::convert::From for u8 { + impl ScoreNotificationBuilder<(T0,)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [ScoreNotification]. #[inline] - fn from(value: TraceDirection) -> Self { - value as u8 + pub fn finish( + self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset + where + Self: ::planus::WriteAsOffset, + { + ::planus::WriteAsOffset::prepare(&self, builder) } } - impl ::planus::Primitive for TraceDirection { - const ALIGNMENT: usize = 1; - const SIZE: usize = 1; - } + impl>> + ::planus::WriteAs<::planus::Offset> + for ScoreNotificationBuilder<(T0,)> + { + type Prepared = ::planus::Offset; - impl ::planus::WriteAsPrimitive for TraceDirection { #[inline] - fn write( + fn prepare( &self, - cursor: ::planus::Cursor<'_, N>, - buffer_position: u32, - ) { - (*self as u8).write(cursor, buffer_position); + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAs for TraceDirection { - type Prepared = Self; + impl>> + ::planus::WriteAsOptional<::planus::Offset> + for ScoreNotificationBuilder<(T0,)> + { + type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> TraceDirection { - *self + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsDefault for TraceDirection { - type Prepared = Self; - + impl>> + ::planus::WriteAsOffset for ScoreNotificationBuilder<(T0,)> + { #[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) - } + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + let (v0,) = &self.0; + ScoreNotification::create(builder, v0) } } - impl ::planus::WriteAsOptional for TraceDirection { - type Prepared = Self; + /// 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] - fn prepare( - &self, - _builder: &mut ::planus::Builder, - ) -> ::core::option::Option { - ::core::option::Option::Some(*self) + pub fn score(&self) -> ::planus::Result> { + self.0.access_required(0, "ScoreNotification", "score") } } - impl<'buf> ::planus::TableRead<'buf> for TraceDirection { + 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<'buf>, + buffer: ::planus::SliceWithStartOffset<'a>, offset: usize, ) -> ::core::result::Result { - let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; - ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) + ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( + buffer, offset, + )?)) } } - impl<'buf> ::planus::VectorReadInner<'buf> for TraceDirection { - type Error = ::planus::errors::UnknownEnumTag; - const STRIDE: usize = 1; - #[inline] + impl<'a> ::planus::VectorReadInner<'a> for ScoreNotificationRef<'a> { + type Error = ::planus::Error; + const STRIDE: usize = 4; + unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'buf>, + buffer: ::planus::SliceWithStartOffset<'a>, 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| { + ) -> ::planus::Result { + ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "TraceDirection", - "VectorRead::from_buffer", + "[ScoreNotificationRef]", + "get", buffer.offset_from_start, ) }) } } - impl ::planus::VectorWrite for TraceDirection { - const STRIDE: usize = 1; - - type Value = Self; - + impl ::planus::VectorWrite<::planus::Offset> for ScoreNotification { + type Value = ::planus::Offset; + const STRIDE: usize = 4; #[inline] - fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { - *self + fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { + ::planus::WriteAs::prepare(self, builder) } #[inline] unsafe fn write_values( - values: &[Self], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 1]; + 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 - i as u32, + 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:126` + /// * Union `TraceInfo` in the file `../worker/fbs/consumer.fbs:93` #[derive( Clone, Debug, @@ -10385,7 +8723,7 @@ mod root { /// The table `KeyFrameTraceInfo` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/consumer.fbs:133` + /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/consumer.fbs:100` #[derive( Clone, Debug, @@ -10667,7 +9005,7 @@ mod root { /// The table `FirTraceInfo` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `FirTraceInfo` in the file `../worker/fbs/consumer.fbs:137` + /// * Table `FirTraceInfo` in the file `../worker/fbs/consumer.fbs:104` #[derive( Clone, Debug, @@ -10944,7 +9282,7 @@ mod root { /// The table `PliTraceInfo` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `PliTraceInfo` in the file `../worker/fbs/consumer.fbs:141` + /// * Table `PliTraceInfo` in the file `../worker/fbs/consumer.fbs:108` #[derive( Clone, Debug, @@ -11221,7 +9559,7 @@ mod root { /// The table `RtpTraceInfo` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `RtpTraceInfo` in the file `../worker/fbs/consumer.fbs:145` + /// * Table `RtpTraceInfo` in the file `../worker/fbs/consumer.fbs:112` #[derive( Clone, Debug, @@ -11498,7 +9836,7 @@ mod root { /// The table `TraceNotification` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/consumer.fbs:149` + /// * Table `TraceNotification` in the file `../worker/fbs/consumer.fbs:116` #[derive( Clone, Debug, @@ -11512,11 +9850,11 @@ mod root { )] pub struct TraceNotification { /// The field `type` in the table `TraceNotification` - pub type_: self::TraceType, + pub type_: self::TraceEventType, /// The field `timestamp` in the table `TraceNotification` pub timestamp: u64, /// The field `direction` in the table `TraceNotification` - pub direction: self::TraceDirection, + pub direction: super::common::TraceDirection, /// The field `info` in the table `TraceNotification` pub info: ::core::option::Option, } @@ -11525,9 +9863,9 @@ mod root { impl ::core::default::Default for TraceNotification { fn default() -> Self { Self { - type_: self::TraceType::Keyframe, + type_: self::TraceEventType::Keyframe, timestamp: 0, - direction: self::TraceDirection::DirectionIn, + direction: super::common::TraceDirection::DirectionIn, info: ::core::default::Default::default(), } } @@ -11543,18 +9881,22 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_type_: impl ::planus::WriteAsDefault, + field_type_: impl ::planus::WriteAsDefault< + self::TraceEventType, + self::TraceEventType, + >, field_timestamp: impl ::planus::WriteAsDefault, field_direction: impl ::planus::WriteAsDefault< - self::TraceDirection, - self::TraceDirection, + super::common::TraceDirection, + super::common::TraceDirection, >, field_info: impl ::planus::WriteAsOptionalUnion, ) -> ::planus::Offset { - let prepared_type_ = field_type_.prepare(builder, &self::TraceType::Keyframe); + 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, &self::TraceDirection::DirectionIn); + 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> = @@ -11566,10 +9908,10 @@ mod root { table_writer.write_entry::<::planus::Offset>(4); } if prepared_type_.is_some() { - table_writer.write_entry::(0); + table_writer.write_entry::(0); } if prepared_direction.is_some() { - table_writer.write_entry::(2); + table_writer.write_entry::(2); } if prepared_info.is_some() { table_writer.write_entry::(3); @@ -11655,7 +9997,7 @@ mod root { #[allow(clippy::type_complexity)] pub fn type_(self, value: T0) -> TraceNotificationBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, { TraceNotificationBuilder((value,)) } @@ -11698,7 +10040,10 @@ mod root { #[allow(clippy::type_complexity)] pub fn direction(self, value: T2) -> TraceNotificationBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault< + super::common::TraceDirection, + super::common::TraceDirection, + >, { let (v0, v1) = self.0; TraceNotificationBuilder((v0, v1, value)) @@ -11749,9 +10094,12 @@ mod root { } impl< - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault< + super::common::TraceDirection, + super::common::TraceDirection, + >, T3: ::planus::WriteAsOptionalUnion, > ::planus::WriteAs<::planus::Offset> for TraceNotificationBuilder<(T0, T1, T2, T3)> @@ -11768,9 +10116,12 @@ mod root { } impl< - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault< + super::common::TraceDirection, + super::common::TraceDirection, + >, T3: ::planus::WriteAsOptionalUnion, > ::planus::WriteAsOptional<::planus::Offset> for TraceNotificationBuilder<(T0, T1, T2, T3)> @@ -11787,9 +10138,12 @@ mod root { } impl< - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault< + super::common::TraceDirection, + super::common::TraceDirection, + >, T3: ::planus::WriteAsOptionalUnion, > ::planus::WriteAsOffset for TraceNotificationBuilder<(T0, T1, T2, T3)> @@ -11811,11 +10165,11 @@ mod root { impl<'a> TraceNotificationRef<'a> { /// Getter for the [`type` field](TraceNotification#structfield.type_). #[inline] - pub fn type_(&self) -> ::planus::Result { + pub fn type_(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 .access(0, "TraceNotification", "type_")? - .unwrap_or(self::TraceType::Keyframe), + .unwrap_or(self::TraceEventType::Keyframe), ) } @@ -11831,11 +10185,11 @@ mod root { /// Getter for the [`direction` field](TraceNotification#structfield.direction). #[inline] - pub fn direction(&self) -> ::planus::Result { + pub fn direction(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 .access(2, "TraceNotification", "direction")? - .unwrap_or(self::TraceDirection::DirectionIn), + .unwrap_or(super::common::TraceDirection::DirectionIn), ) } @@ -35210,27 +33564,13 @@ mod root { /// The field `producer_paused` in the table `ConsumeResponse` pub producer_paused: bool, /// The field `score` in the table `ConsumeResponse` - pub score: ::core::option::Option< - ::planus::alloc::boxed::Box, - >, + pub score: ::planus::alloc::boxed::Box, /// The field `preferred_layers` in the table `ConsumeResponse` pub preferred_layers: ::core::option::Option< ::planus::alloc::boxed::Box, >, } - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for ConsumeResponse { - fn default() -> Self { - Self { - paused: false, - producer_paused: false, - score: ::core::default::Default::default(), - preferred_layers: ::core::default::Default::default(), - } - } - } - impl ConsumeResponse { /// Creates a [ConsumeResponseBuilder] for serializing an instance of this table. #[inline] @@ -35243,7 +33583,7 @@ mod root { builder: &mut ::planus::Builder, field_paused: impl ::planus::WriteAsDefault, field_producer_paused: impl ::planus::WriteAsDefault, - field_score: impl ::planus::WriteAsOptional< + field_score: impl ::planus::WriteAs< ::planus::Offset, >, field_preferred_layers: impl ::planus::WriteAsOptional< @@ -35257,10 +33597,7 @@ mod root { let mut table_writer: ::planus::table_writer::TableWriter<12> = ::core::default::Default::default(); - if prepared_score.is_some() { - table_writer - .write_entry::<::planus::Offset>(2); - } + table_writer.write_entry::<::planus::Offset>(2); if prepared_preferred_layers.is_some() { table_writer .write_entry::<::planus::Offset>(3); @@ -35274,9 +33611,7 @@ mod root { unsafe { table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_score) = prepared_score { - object_writer.write::<_, _, 4>(&prepared_score); - } + object_writer.write::<_, _, 4>(&prepared_score); if let ::core::option::Option::Some(prepared_preferred_layers) = prepared_preferred_layers { @@ -35392,18 +33727,11 @@ mod root { #[allow(clippy::type_complexity)] pub fn score(self, value: T2) -> ConsumeResponseBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAsOptional<::planus::Offset>, + T2: ::planus::WriteAs<::planus::Offset>, { let (v0, v1) = self.0; ConsumeResponseBuilder((v0, v1, value)) } - - /// Sets the [`score` field](ConsumeResponse#structfield.score) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn score_as_null(self) -> ConsumeResponseBuilder<(T0, T1, ())> { - self.score(()) - } } impl ConsumeResponseBuilder<(T0, T1, T2)> { @@ -35448,7 +33776,7 @@ mod root { impl< T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional<::planus::Offset>, + T2: ::planus::WriteAs<::planus::Offset>, T3: ::planus::WriteAsOptional<::planus::Offset>, > ::planus::WriteAs<::planus::Offset> for ConsumeResponseBuilder<(T0, T1, T2, T3)> @@ -35467,7 +33795,7 @@ mod root { impl< T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional<::planus::Offset>, + T2: ::planus::WriteAs<::planus::Offset>, T3: ::planus::WriteAsOptional<::planus::Offset>, > ::planus::WriteAsOptional<::planus::Offset> for ConsumeResponseBuilder<(T0, T1, T2, T3)> @@ -35486,7 +33814,7 @@ mod root { impl< T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsOptional<::planus::Offset>, + T2: ::planus::WriteAs<::planus::Offset>, T3: ::planus::WriteAsOptional<::planus::Offset>, > ::planus::WriteAsOffset for ConsumeResponseBuilder<(T0, T1, T2, T3)> @@ -35528,11 +33856,8 @@ mod root { /// Getter for the [`score` field](ConsumeResponse#structfield.score). #[inline] - pub fn score( - &self, - ) -> ::planus::Result<::core::option::Option>> - { - self.0.access(2, "ConsumeResponse", "score") + pub fn score(&self) -> ::planus::Result> { + self.0.access_required(2, "ConsumeResponse", "score") } /// Getter for the [`preferred_layers` field](ConsumeResponse#structfield.preferred_layers). @@ -35550,9 +33875,7 @@ mod root { let mut f = f.debug_struct("ConsumeResponseRef"); f.field("paused", &self.paused()); f.field("producer_paused", &self.producer_paused()); - if let ::core::option::Option::Some(field_score) = self.score().transpose() { - f.field("score", &field_score); - } + f.field("score", &self.score()); if let ::core::option::Option::Some(field_preferred_layers) = self.preferred_layers().transpose() { @@ -35572,13 +33895,9 @@ mod root { producer_paused: ::core::convert::TryInto::try_into( value.producer_paused()?, )?, - score: if let ::core::option::Option::Some(score) = value.score()? { - ::core::option::Option::Some(::planus::alloc::boxed::Box::new( - ::core::convert::TryInto::try_into(score)?, - )) - } else { - ::core::option::Option::None - }, + 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()? { @@ -45910,180 +44229,10 @@ mod root { } } - /// The enum `TraceDirection` in the namespace `FBS.Transport` - /// - /// Generated from these locations: - /// * Enum `TraceDirection` in the file `../worker/fbs/transport.fbs:216` - #[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 union `TraceInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:221` + /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:215` #[derive( Clone, Debug, @@ -46236,7 +44385,7 @@ mod root { /// The enum `BweType` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:225` + /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:219` #[derive( Copy, Clone, @@ -46406,7 +44555,7 @@ mod root { /// The table `BweTraceInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:230` + /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:224` #[derive( Clone, Debug, @@ -47084,7 +45233,7 @@ mod root { /// The table `TraceNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:241` + /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:235` #[derive( Clone, Debug, @@ -47102,7 +45251,7 @@ mod root { /// The field `timestamp` in the table `TraceNotification` pub timestamp: u64, /// The field `direction` in the table `TraceNotification` - pub direction: self::TraceDirection, + pub direction: super::common::TraceDirection, /// The field `info` in the table `TraceNotification` pub info: ::core::option::Option, } @@ -47113,7 +45262,7 @@ mod root { Self { type_: self::TraceEventType::Probation, timestamp: 0, - direction: self::TraceDirection::DirectionIn, + direction: super::common::TraceDirection::DirectionIn, info: ::core::default::Default::default(), } } @@ -47135,16 +45284,16 @@ mod root { >, field_timestamp: impl ::planus::WriteAsDefault, field_direction: impl ::planus::WriteAsDefault< - self::TraceDirection, - self::TraceDirection, + 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, &self::TraceDirection::DirectionIn); + 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> = @@ -47159,7 +45308,7 @@ mod root { table_writer.write_entry::(0); } if prepared_direction.is_some() { - table_writer.write_entry::(2); + table_writer.write_entry::(2); } if prepared_info.is_some() { table_writer.write_entry::(3); @@ -47288,7 +45437,10 @@ mod root { #[allow(clippy::type_complexity)] pub fn direction(self, value: T2) -> TraceNotificationBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault< + super::common::TraceDirection, + super::common::TraceDirection, + >, { let (v0, v1) = self.0; TraceNotificationBuilder((v0, v1, value)) @@ -47341,7 +45493,10 @@ mod root { impl< T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault< + super::common::TraceDirection, + super::common::TraceDirection, + >, T3: ::planus::WriteAsOptionalUnion, > ::planus::WriteAs<::planus::Offset> for TraceNotificationBuilder<(T0, T1, T2, T3)> @@ -47360,7 +45515,10 @@ mod root { impl< T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault< + super::common::TraceDirection, + super::common::TraceDirection, + >, T3: ::planus::WriteAsOptionalUnion, > ::planus::WriteAsOptional<::planus::Offset> for TraceNotificationBuilder<(T0, T1, T2, T3)> @@ -47379,7 +45537,10 @@ mod root { impl< T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault< + super::common::TraceDirection, + super::common::TraceDirection, + >, T3: ::planus::WriteAsOptionalUnion, > ::planus::WriteAsOffset for TraceNotificationBuilder<(T0, T1, T2, T3)> @@ -47421,11 +45582,11 @@ mod root { /// Getter for the [`direction` field](TraceNotification#structfield.direction). #[inline] - pub fn direction(&self) -> ::planus::Result { + pub fn direction(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 .access(2, "TraceNotification", "direction")? - .unwrap_or(self::TraceDirection::DirectionIn), + .unwrap_or(super::common::TraceDirection::DirectionIn), ) } diff --git a/rust/src/messages.rs b/rust/src/messages.rs index 5a1a62e8b7..15f8262485 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -1,8 +1,7 @@ use crate::active_speaker_observer::ActiveSpeakerObserverOptions; use crate::audio_level_observer::AudioLevelObserverOptions; use crate::consumer::{ - ConsumerDump, ConsumerId, ConsumerLayers, ConsumerScore, ConsumerStats, ConsumerTraceEventType, - ConsumerType, + ConsumerId, ConsumerLayers, ConsumerScore, ConsumerTraceEventType, ConsumerType, }; use crate::data_consumer::{DataConsumerDump, DataConsumerId, DataConsumerStat, DataConsumerType}; use crate::data_producer::{DataProducerDump, DataProducerId, DataProducerStat, DataProducerType}; @@ -12,8 +11,8 @@ use crate::data_structures::{ }; use crate::direct_transport::DirectTransportOptions; use crate::fbs::{ - direct_transport, message, pipe_transport, plain_transport, producer, request, response, - router, transport, web_rtc_transport, worker, + consumer, direct_transport, message, pipe_transport, plain_transport, producer, request, + response, router, transport, web_rtc_transport, worker, }; use crate::ortc::RtpMapping; use crate::pipe_transport::PipeTransportOptions; @@ -1702,27 +1701,80 @@ impl RequestFbs for TransportProduceRequest { } } -request_response!( - TransportId, - "transport.consume", - TransportConsumeRequest { - consumer_id: ConsumerId, - producer_id: ProducerId, - kind: MediaKind, - rtp_parameters: RtpParameters, - r#type: ConsumerType, - consumable_rtp_encodings: Vec, - paused: bool, - preferred_layers: Option, - ignore_dtx: bool, - }, - TransportConsumeResponse { - paused: bool, - producer_paused: bool, - score: ConsumerScore, - preferred_layers: Option, - }, -); +#[derive(Debug)] +pub(crate) struct TransportConsumeRequest { + pub(crate) consumer_id: ConsumerId, + pub(crate) producer_id: ProducerId, + pub(crate) kind: MediaKind, + pub(crate) rtp_parameters: RtpParameters, + pub(crate) r#type: ConsumerType, + pub(crate) consumable_rtp_encodings: Vec, + pub(crate) paused: bool, + pub(crate) preferred_layers: Option, + pub(crate) ignore_dtx: bool, +} + +#[derive(Debug)] +pub(crate) struct TransportConsumeResponse { + pub(crate) paused: bool, + pub(crate) producer_paused: bool, + pub(crate) score: ConsumerScore, + pub(crate) preferred_layers: Option, +} + +impl RequestFbs for TransportConsumeRequest { + const METHOD: request::Method = request::Method::TransportConsume; + type HandlerId = TransportId; + type Response = TransportConsumeResponse; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = transport::ConsumeRequest::create( + &mut builder, + self.consumer_id.to_string(), + self.producer_id.to_string(), + self.kind.to_fbs(), + Box::new(self.rtp_parameters.into_fbs()), + self.r#type.to_fbs(), + self.consumable_rtp_encodings + .iter() + .map(RtpEncodingParameters::to_fbs) + .collect::>(), + self.paused, + self.preferred_layers.map(ConsumerLayers::to_fbs), + self.ignore_dtx, + ); + let request_body = request::Body::create_transport_consume_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::TransportConsumeResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(TransportConsumeResponse { + paused: data.paused, + producer_paused: data.producer_paused, + score: ConsumerScore::from_fbs(*data.score), + preferred_layers: data + .preferred_layers + .map(|preferred_layers| ConsumerLayers::from_fbs(*preferred_layers)), + }) + } +} request_response!( TransportId, @@ -2042,6 +2094,7 @@ impl RequestFbs for ProducerEnableTraceEventRequest { None } } + #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct ProducerSendNotification {} @@ -2054,64 +2107,346 @@ impl Notification for ProducerSendNotification { } } -request_response!( - TransportId, - "transport.closeConsumer", - ConsumerCloseRequest { - consumer_id: ConsumerId, - }, - (), - Some(()), -); +#[derive(Debug)] +pub(crate) struct ConsumerCloseRequest { + pub(crate) consumer_id: ConsumerId, +} -request_response!( - ConsumerId, - "consumer.dump", - ConsumerDumpRequest {}, - ConsumerDump, -); +impl RequestFbs for ConsumerCloseRequest { + const METHOD: request::Method = request::Method::TransportCloseConsumer; + type HandlerId = TransportId; + type Response = (); -request_response!( - ConsumerId, - "consumer.getStats", - ConsumerGetStatsRequest {}, - ConsumerStats, -); + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = + transport::CloseConsumerRequest::create(&mut builder, self.consumer_id.to_string()); + let request_body = + request::Body::create_transport_close_consumer_request(&mut builder, data); -request_response!(ConsumerId, "consumer.pause", ConsumerPauseRequest {},); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); -request_response!(ConsumerId, "consumer.resume", ConsumerResumeRequest {},); + builder.finish(message, None).to_vec() + } -request_response!( - ConsumerId, - "consumer.setPreferredLayers", - ConsumerSetPreferredLayersRequest { - #[serde(flatten)] - data: ConsumerLayers, - }, - Option, -); + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} -request_response!( - ConsumerId, - "consumer.setPriority", - ConsumerSetPriorityRequest { priority: u8 }, - ConsumerSetPriorityResponse { priority: u8 }, -); +#[derive(Debug)] +pub(crate) struct ConsumerDumpRequest {} -request_response!( - ConsumerId, - "consumer.requestKeyFrame", - ConsumerRequestKeyFrameRequest {}, -); +impl RequestFbs for ConsumerDumpRequest { + const METHOD: request::Method = request::Method::ConsumerDump; + type HandlerId = ConsumerId; + type Response = response::Body; -request_response!( - ConsumerId, - "consumer.enableTraceEvent", - ConsumerEnableTraceEventRequest { - types: Vec, - }, -); + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + match response { + Some(data) => Ok(data), + _ => { + panic!("Wrong message from worker: {response:?}"); + } + } + } +} + +#[derive(Debug)] +pub(crate) struct ConsumerGetStatsRequest {} + +impl RequestFbs for ConsumerGetStatsRequest { + const METHOD: request::Method = request::Method::ConsumerGetStats; + type HandlerId = ConsumerId; + type Response = response::Body; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + match response { + Some(data) => Ok(data), + _ => { + panic!("Wrong message from worker: {response:?}"); + } + } + } +} + +#[derive(Debug)] +pub(crate) struct ConsumerPauseRequest {} + +impl RequestFbs for ConsumerPauseRequest { + const METHOD: request::Method = request::Method::ConsumerPause; + type HandlerId = ConsumerId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug, Serialize)] +pub(crate) struct ConsumerResumeRequest {} + +impl RequestFbs for ConsumerResumeRequest { + const METHOD: request::Method = request::Method::ConsumerResume; + type HandlerId = ConsumerId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug, Serialize)] +pub(crate) struct ConsumerSetPreferredLayersRequest { + pub(crate) data: ConsumerLayers, +} + +impl RequestFbs for ConsumerSetPreferredLayersRequest { + const METHOD: request::Method = request::Method::ConsumerSetPreferredLayers; + type HandlerId = ConsumerId; + type Response = Option; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let data = consumer::SetPreferredLayersRequest::create( + &mut builder, + ConsumerLayers::to_fbs(self.data), + ); + let request_body = + request::Body::create_consumer_set_preferred_layers_request(&mut builder, data); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::ConsumerSetPreferredLayersResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + match data.preferred_layers { + Some(preferred_layers) => Ok(Some(ConsumerLayers::from_fbs(*preferred_layers))), + None => Ok(None), + } + } +} + +#[derive(Debug, Serialize)] +pub(crate) struct ConsumerSetPriorityRequest { + pub(crate) priority: u8, +} + +#[derive(Debug, Serialize)] +pub(crate) struct ConsumerSetPriorityResponse { + pub(crate) priority: u8, +} + +impl RequestFbs for ConsumerSetPriorityRequest { + const METHOD: request::Method = request::Method::ConsumerSetPriority; + type HandlerId = ConsumerId; + type Response = ConsumerSetPriorityResponse; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let data = consumer::SetPriorityRequest::create(&mut builder, self.priority); + let request_body = request::Body::create_consumer_set_priority_request(&mut builder, data); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::ConsumerSetPriorityResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(ConsumerSetPriorityResponse { + priority: data.priority, + }) + } +} + +#[derive(Debug)] +pub(crate) struct ConsumerRequestKeyFrameRequest {} + +impl RequestFbs for ConsumerRequestKeyFrameRequest { + const METHOD: request::Method = request::Method::ConsumerRequestKeyFrame; + type HandlerId = ConsumerId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug)] +pub(crate) struct ConsumerEnableTraceEventRequest { + pub(crate) types: Vec, +} + +impl RequestFbs for ConsumerEnableTraceEventRequest { + const METHOD: request::Method = request::Method::ConsumerEnableTraceEvent; + type HandlerId = ConsumerId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let data = consumer::EnableTraceEventRequest { + events: self + .types + .into_iter() + .map(ConsumerTraceEventType::to_fbs) + .collect(), + }; + + let request_body = request::Body::ConsumerEnableTraceEventRequest(Box::new(data)); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } + + fn default_for_soft_error() -> Option { + None + } +} request_response!( TransportId, diff --git a/rust/src/router/consumer.rs b/rust/src/router/consumer.rs index b8ca36c0cc..199d6b6878 100644 --- a/rust/src/router/consumer.rs +++ b/rust/src/router/consumer.rs @@ -2,23 +2,25 @@ mod tests; use crate::data_structures::{AppData, RtpPacketTraceInfo, SsrcTraceInfo, TraceEventDirection}; -use crate::fbs::{rtp_stream, rtx_stream}; +use crate::fbs::{consumer, notification, response, rtp_parameters, rtp_stream, rtx_stream}; use crate::messages::{ ConsumerCloseRequest, ConsumerDumpRequest, ConsumerEnableTraceEventRequest, ConsumerGetStatsRequest, ConsumerPauseRequest, ConsumerRequestKeyFrameRequest, ConsumerResumeRequest, ConsumerSetPreferredLayersRequest, ConsumerSetPriorityRequest, }; use crate::producer::{Producer, ProducerId, ProducerStat, ProducerType, WeakProducer}; -use crate::rtp_parameters::{MediaKind, MimeType, RtpCapabilities, RtpParameters}; -use crate::scalability_modes::ScalabilityMode; +use crate::rtp_parameters::{ + MediaKind, MimeType, RtpCapabilities, RtpEncodingParameters, RtpParameters, +}; use crate::transport::Transport; use crate::uuid_based_wrapper_type; -use crate::worker::{Channel, RequestError, SubscriptionHandler}; +use crate::worker::{Channel, NotificationParseError, RequestError, SubscriptionHandler}; use async_executor::Executor; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; +use std::error::Error; use std::fmt; use std::fmt::Debug; use std::sync::atomic::{AtomicBool, Ordering}; @@ -39,6 +41,22 @@ pub struct ConsumerLayers { pub temporal_layer: Option, } +impl ConsumerLayers { + pub(crate) fn to_fbs(self) -> consumer::ConsumerLayers { + consumer::ConsumerLayers { + spatial_layer: self.spatial_layer, + temporal_layer: self.temporal_layer, + } + } + + pub(crate) fn from_fbs(consumer_layers: consumer::ConsumerLayers) -> Self { + Self { + spatial_layer: consumer_layers.spatial_layer, + temporal_layer: consumer_layers.temporal_layer, + } + } +} + /// Score of consumer and corresponding producer. #[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -54,6 +72,16 @@ pub struct ConsumerScore { pub producer_scores: Vec, } +impl ConsumerScore { + pub(crate) fn from_fbs(consumer_score: consumer::ConsumerScore) -> Self { + Self { + score: consumer_score.score, + producer_score: consumer_score.producer_score, + producer_scores: consumer_score.producer_scores.into_iter().collect(), + } + } +} + /// [`Consumer`] options. #[derive(Debug, Clone)] #[non_exhaustive] @@ -187,6 +215,15 @@ pub struct RtpStream { pub score: u8, } +impl RtpStream { + pub(crate) fn from_fbs(dump: rtp_stream::Dump) -> Self { + Self { + params: RtpStreamParams::from_fbs(&dump.params), + score: dump.score, + } + } +} + #[derive(Debug, Clone, PartialOrd, Eq, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] #[doc(hidden)] @@ -194,24 +231,6 @@ pub struct RtpRtxParameters { pub ssrc: Option, } -#[derive(Debug, Clone, PartialOrd, PartialEq, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -#[doc(hidden)] -pub struct ConsumableRtpEncoding { - pub ssrc: Option, - pub rid: Option, - pub codec_payload_type: Option, - pub rtx: Option, - pub max_bitrate: Option, - pub max_framerate: Option, - pub dtx: Option, - #[serde(default, skip_serializing_if = "ScalabilityMode::is_none")] - pub scalability_mode: ScalabilityMode, - pub spatial_layers: Option, - pub temporal_layers: Option, - pub ksvc: Option, -} - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] #[doc(hidden)] @@ -225,10 +244,10 @@ pub struct ConsumerDump { pub producer_paused: bool, pub rtp_parameters: RtpParameters, pub supported_codec_payload_types: Vec, - pub trace_event_types: String, + pub trace_event_types: Vec, pub r#type: ConsumerType, - pub consumable_rtp_encodings: Vec, - pub rtp_stream: RtpStream, + pub consumable_rtp_encodings: Vec, + pub rtp_streams: Vec, /// Essentially `Option` or `Option<-1>` pub preferred_spatial_layer: Option, /// Essentially `Option` or `Option<-1>` @@ -243,6 +262,47 @@ pub struct ConsumerDump { pub current_temporal_layer: Option, } +impl ConsumerDump { + pub(crate) fn from_fbs(dump: consumer::DumpResponse) -> Result> { + let dump = dump.data; + + Ok(Self { + id: dump.base.id.parse()?, + kind: MediaKind::from_fbs(dump.base.kind), + paused: dump.base.paused, + priority: dump.base.priority, + producer_id: dump.base.producer_id.parse()?, + producer_paused: dump.base.producer_paused, + rtp_parameters: RtpParameters::from_fbs(*dump.base.rtp_parameters).unwrap(), + supported_codec_payload_types: dump.base.supported_codec_payload_types, + trace_event_types: dump + .base + .trace_event_types + .iter() + .map(ConsumerTraceEventType::from_fbs) + .collect(), + r#type: ConsumerType::from_fbs(dump.base.type_), + consumable_rtp_encodings: dump + .base + .consumable_rtp_encodings + .into_iter() + .map(RtpEncodingParameters::from_fbs) + .collect(), + rtp_streams: dump + .rtp_streams + .into_iter() + .map(RtpStream::from_fbs) + .collect(), + preferred_spatial_layer: dump.preferred_spatial_layer, + target_spatial_layer: dump.target_spatial_layer, + current_spatial_layer: dump.current_spatial_layer, + preferred_temporal_layer: dump.preferred_temporal_layer, + target_temporal_layer: dump.target_temporal_layer, + current_temporal_layer: dump.current_temporal_layer, + }) + } +} + /// Consumer type. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] @@ -268,6 +328,26 @@ impl From for ConsumerType { } } +impl ConsumerType { + pub(crate) fn to_fbs(self) -> rtp_parameters::Type { + match self { + ConsumerType::Simple => rtp_parameters::Type::Simple, + ConsumerType::Simulcast => rtp_parameters::Type::Simulcast, + ConsumerType::Svc => rtp_parameters::Type::Svc, + ConsumerType::Pipe => rtp_parameters::Type::Pipe, + } + } + + pub(crate) fn from_fbs(r#type: rtp_parameters::Type) -> ConsumerType { + match r#type { + rtp_parameters::Type::Simple => ConsumerType::Simple, + rtp_parameters::Type::Simulcast => ConsumerType::Simulcast, + rtp_parameters::Type::Svc => ConsumerType::Svc, + rtp_parameters::Type::Pipe => ConsumerType::Pipe, + } + } +} + /// RTC statistics of the consumer alone. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -281,22 +361,56 @@ pub struct ConsumerStat { pub rtx_ssrc: Option, pub kind: MediaKind, pub mime_type: MimeType, - pub packets_lost: u32, + pub packets_lost: u64, pub fraction_lost: u8, - pub packets_discarded: usize, - pub packets_retransmitted: usize, - pub packets_repaired: usize, - pub nack_count: usize, - pub nack_packet_count: usize, - pub pli_count: usize, - pub fir_count: usize, + pub packets_discarded: u64, + pub packets_retransmitted: u64, + pub packets_repaired: u64, + pub nack_count: u64, + pub nack_packet_count: u64, + pub pli_count: u64, + pub fir_count: u64, pub score: u8, - pub packet_count: usize, - pub byte_count: usize, + pub packet_count: u64, + pub byte_count: u64, pub bitrate: u32, pub round_trip_time: Option, } +impl ConsumerStat { + pub(crate) fn from_fbs(stats: &rtp_stream::Stats) -> Self { + let rtp_stream::StatsData::SendStats(ref stats) = stats.data else { + panic!("Wrong message from worker"); + }; + + let rtp_stream::StatsData::BaseStats(ref base) = stats.base.data else { + panic!("Wrong message from worker"); + }; + + Self { + timestamp: base.timestamp, + ssrc: base.ssrc, + rtx_ssrc: base.rtx_ssrc, + kind: MediaKind::from_fbs(base.kind), + mime_type: base.mime_type.to_string().parse().unwrap(), + packets_lost: base.packets_lost, + fraction_lost: base.fraction_lost, + packets_discarded: base.packets_discarded, + packets_retransmitted: base.packets_retransmitted, + packets_repaired: base.packets_repaired, + nack_count: base.nack_count, + nack_packet_count: base.nack_packet_count, + pli_count: base.pli_count, + fir_count: base.fir_count, + score: base.score, + packet_count: stats.packet_count, + byte_count: stats.byte_count, + bitrate: stats.bitrate, + round_trip_time: Some(base.round_trip_time), + } + } +} + /// RTC statistics of the consumer, may or may not include producer statistics. #[allow(clippy::large_enum_variant)] #[derive(Debug, Deserialize, Serialize)] @@ -367,6 +481,65 @@ pub enum ConsumerTraceEventData { }, } +impl ConsumerTraceEventData { + pub(crate) fn from_fbs(data: consumer::TraceNotification) -> Self { + match data.type_ { + consumer::TraceEventType::Rtp => ConsumerTraceEventData::Rtp { + timestamp: data.timestamp, + direction: TraceEventDirection::from_fbs(data.direction), + info: { + let Some(consumer::TraceInfo::RtpTraceInfo(info)) = data.info else { + panic!("Wrong message from worker: {data:?}"); + }; + + RtpPacketTraceInfo { + is_rtx: info.is_rtx, + } + }, + }, + consumer::TraceEventType::Keyframe => ConsumerTraceEventData::KeyFrame { + timestamp: data.timestamp, + direction: TraceEventDirection::from_fbs(data.direction), + info: { + let Some(consumer::TraceInfo::KeyFrameTraceInfo(info)) = data.info else { + panic!("Wrong message from worker: {data:?}"); + }; + + RtpPacketTraceInfo { + is_rtx: info.is_rtx, + } + }, + }, + consumer::TraceEventType::Nack => ConsumerTraceEventData::Nack { + timestamp: data.timestamp, + direction: TraceEventDirection::from_fbs(data.direction), + }, + consumer::TraceEventType::Pli => ConsumerTraceEventData::Pli { + timestamp: data.timestamp, + direction: TraceEventDirection::from_fbs(data.direction), + info: { + let Some(consumer::TraceInfo::PliTraceInfo(info)) = data.info else { + panic!("Wrong message from worker: {data:?}"); + }; + + SsrcTraceInfo { ssrc: info.ssrc } + }, + }, + consumer::TraceEventType::Fir => ConsumerTraceEventData::Fir { + timestamp: data.timestamp, + direction: TraceEventDirection::from_fbs(data.direction), + info: { + let Some(consumer::TraceInfo::FirTraceInfo(info)) = data.info else { + panic!("Wrong message from worker: {data:?}"); + }; + + SsrcTraceInfo { ssrc: info.ssrc } + }, + }, + } + } +} + /// Types of consumer trace events. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] @@ -383,6 +556,27 @@ pub enum ConsumerTraceEventType { Fir, } +impl ConsumerTraceEventType { + pub(crate) fn to_fbs(self) -> consumer::TraceEventType { + match self { + ConsumerTraceEventType::Rtp => consumer::TraceEventType::Rtp, + ConsumerTraceEventType::KeyFrame => consumer::TraceEventType::Keyframe, + ConsumerTraceEventType::Nack => consumer::TraceEventType::Nack, + ConsumerTraceEventType::Pli => consumer::TraceEventType::Pli, + ConsumerTraceEventType::Fir => consumer::TraceEventType::Fir, + } + } + + pub(crate) fn from_fbs(event_type: &consumer::TraceEventType) -> Self { + match event_type { + consumer::TraceEventType::Rtp => ConsumerTraceEventType::Rtp, + consumer::TraceEventType::Keyframe => ConsumerTraceEventType::KeyFrame, + consumer::TraceEventType::Nack => ConsumerTraceEventType::Nack, + consumer::TraceEventType::Pli => ConsumerTraceEventType::Pli, + consumer::TraceEventType::Fir => ConsumerTraceEventType::Fir, + } + } +} #[derive(Debug, Deserialize)] #[serde(tag = "event", rename_all = "lowercase", content = "data")] enum Notification { @@ -396,6 +590,56 @@ enum Notification { Trace(ConsumerTraceEventData), } +impl Notification { + pub(crate) fn from_fbs( + notification: notification::NotificationRef<'_>, + ) -> Result { + match notification.event().unwrap() { + notification::Event::ConsumerProducerClose => Ok(Notification::ProducerClose), + notification::Event::ConsumerProducerPause => Ok(Notification::ProducerPause), + notification::Event::ConsumerProducerResume => Ok(Notification::ProducerResume), + notification::Event::ConsumerScore => { + let Ok(Some(notification::BodyRef::ConsumerScoreNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let score_fbs = consumer::ConsumerScore::try_from(body.score().unwrap()).unwrap(); + let score = ConsumerScore::from_fbs(score_fbs); + + Ok(Notification::Score(score)) + } + notification::Event::ConsumerLayersChange => { + let Ok(Some(notification::BodyRef::ConsumerLayersChangeNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let layers_fbs = + consumer::ConsumerLayers::try_from(body.layers().unwrap()).unwrap(); + let layers = ConsumerLayers::from_fbs(layers_fbs); + + Ok(Notification::LayersChange(Some(layers))) + } + notification::Event::ConsumerTrace => { + let Ok(Some(notification::BodyRef::ConsumerTraceNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let trace_notification_fbs = consumer::TraceNotification::try_from(body).unwrap(); + let trace_notification = ConsumerTraceEventData::from_fbs(trace_notification_fbs); + + Ok(Notification::Trace(trace_notification)) + } + _ => Err(NotificationParseError::InvalidEvent), + } + } +} + #[derive(Default)] #[allow(clippy::type_complexity)] struct Handlers { @@ -463,7 +707,7 @@ impl Inner { self.executor .spawn(async move { if weak_producer.upgrade().is_some() { - if let Err(error) = channel.request(transport_id, request).await { + if let Err(error) = channel.request_fbs(transport_id, request).await { error!("consumer closing failed on drop: {}", error); } } @@ -539,8 +783,8 @@ impl Consumer { let current_layers = Arc::clone(¤t_layers); let inner_weak = Arc::clone(&inner_weak); - channel.subscribe_to_notifications(id.into(), move |notification| { - match serde_json::from_slice::(notification) { + channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::ProducerClose => { if !closed.load(Ordering::SeqCst) { @@ -746,10 +990,17 @@ impl Consumer { pub async fn dump(&self) -> Result { debug!("dump()"); - self.inner + let response = self + .inner .channel - .request(self.id(), ConsumerDumpRequest {}) - .await + .request_fbs(self.id(), ConsumerDumpRequest {}) + .await?; + + if let response::Body::ConsumerDumpResponse(data) = response { + Ok(ConsumerDump::from_fbs(*data).expect("Error parsing dump response")) + } else { + panic!("Wrong message from worker"); + } } /// Returns current RTC statistics of the consumer. @@ -759,10 +1010,30 @@ impl Consumer { pub async fn get_stats(&self) -> Result { debug!("get_stats()"); - self.inner + let response = self + .inner .channel - .request(self.id(), ConsumerGetStatsRequest {}) - .await + .request_fbs(self.id(), ConsumerGetStatsRequest {}) + .await; + + if let Ok(response::Body::ConsumerGetStatsResponse(data)) = response { + match data.stats.len() { + 0 => panic!("Empty stats response from worker"), + 1 => { + let consumer_stat = ConsumerStat::from_fbs(&data.stats[0]); + + Ok(ConsumerStats::JustConsumer((consumer_stat,))) + } + _ => { + let consumer_stat = ConsumerStat::from_fbs(&data.stats[0]); + let producer_stat = ProducerStat::from_fbs(&data.stats[1]); + + Ok(ConsumerStats::WithProducer((consumer_stat, producer_stat))) + } + } + } else { + panic!("Wrong message from worker"); + } } /// Pauses the consumer (no RTP is sent to the consuming endpoint). @@ -771,7 +1042,7 @@ impl Consumer { self.inner .channel - .request(self.id(), ConsumerPauseRequest {}) + .request_fbs(self.id(), ConsumerPauseRequest {}) .await?; let mut paused = self.inner.paused.lock(); @@ -791,7 +1062,7 @@ impl Consumer { self.inner .channel - .request(self.id(), ConsumerResumeRequest {}) + .request_fbs(self.id(), ConsumerResumeRequest {}) .await?; let mut paused = self.inner.paused.lock(); @@ -816,7 +1087,7 @@ impl Consumer { let consumer_layers = self .inner .channel - .request( + .request_fbs( self.id(), ConsumerSetPreferredLayersRequest { data: consumer_layers, @@ -838,7 +1109,7 @@ impl Consumer { let result = self .inner .channel - .request(self.id(), ConsumerSetPriorityRequest { priority }) + .request_fbs(self.id(), ConsumerSetPriorityRequest { priority }) .await?; *self.inner.priority.lock() = result.priority; @@ -855,7 +1126,7 @@ impl Consumer { let result = self .inner .channel - .request(self.id(), ConsumerSetPriorityRequest { priority }) + .request_fbs(self.id(), ConsumerSetPriorityRequest { priority }) .await?; *self.inner.priority.lock() = result.priority; @@ -869,7 +1140,7 @@ impl Consumer { self.inner .channel - .request(self.id(), ConsumerRequestKeyFrameRequest {}) + .request_fbs(self.id(), ConsumerRequestKeyFrameRequest {}) .await } @@ -882,7 +1153,7 @@ impl Consumer { self.inner .channel - .request(self.id(), ConsumerEnableTraceEventRequest { types }) + .request_fbs(self.id(), ConsumerEnableTraceEventRequest { types }) .await } diff --git a/rust/src/router/consumer/tests.rs b/rust/src/router/consumer/tests.rs index bc2d6d8a11..b85d076a97 100644 --- a/rust/src/router/consumer/tests.rs +++ b/rust/src/router/consumer/tests.rs @@ -146,7 +146,6 @@ fn producer_close_event() { } #[test] -#[ignore] fn transport_close_event() { future::block_on(async move { let (router, transport_1, transport_2) = init().await; diff --git a/rust/src/router/producer.rs b/rust/src/router/producer.rs index 205cf27232..069814ded8 100644 --- a/rust/src/router/producer.rs +++ b/rust/src/router/producer.rs @@ -306,6 +306,7 @@ impl ProducerStat { } } } + /// 'trace' event data. #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(tag = "type", rename_all = "lowercase")] diff --git a/rust/src/router/transport.rs b/rust/src/router/transport.rs index ba22a2fbdb..da4cf14da4 100644 --- a/rust/src/router/transport.rs +++ b/rust/src/router/transport.rs @@ -646,7 +646,7 @@ pub(super) trait TransportImpl: TransportGeneric { let response = self .channel() - .request( + .request_fbs( self.id(), TransportConsumeRequest { consumer_id, diff --git a/rust/src/rtp_parameters.rs b/rust/src/rtp_parameters.rs index cdd782cc5b..7a0aed18b4 100644 --- a/rust/src/rtp_parameters.rs +++ b/rust/src/rtp_parameters.rs @@ -1292,6 +1292,49 @@ pub struct RtpEncodingParameters { pub max_bitrate: Option, } +impl RtpEncodingParameters { + pub(crate) fn to_fbs(&self) -> rtp_parameters::RtpEncodingParameters { + rtp_parameters::RtpEncodingParameters { + ssrc: self.ssrc, + rid: self.rid.clone(), + codec_payload_type: self.codec_payload_type, + rtx: self + .rtx + .map(|rtx| Box::new(rtp_parameters::Rtx { ssrc: rtx.ssrc })), + dtx: self.dtx.unwrap_or_default(), + scalability_mode: if self.scalability_mode.is_none() { + None + } else { + Some(self.scalability_mode.as_str().to_string()) + }, + max_bitrate: self.max_bitrate, + } + } + + pub(crate) fn from_fbs(encoding_parameters: rtp_parameters::RtpEncodingParameters) -> Self { + Self { + ssrc: encoding_parameters.ssrc, + rid: encoding_parameters.rid.clone(), + codec_payload_type: encoding_parameters.codec_payload_type, + rtx: encoding_parameters + .rtx + .map(|rtx| RtpEncodingParametersRtx { ssrc: rtx.ssrc }), + dtx: { + match encoding_parameters.dtx { + true => Some(true), + false => None, + } + }, + scalability_mode: encoding_parameters + .scalability_mode + .unwrap_or(String::from("S1T1")) + .parse() + .unwrap(), + max_bitrate: encoding_parameters.max_bitrate, + } + } +} + /// Defines a RTP header extension within the RTP parameters. The list of RTP /// header extensions supported by mediasoup is defined in the `supported_rtp_capabilities.rs` file. /// diff --git a/rust/tests/integration/consumer.rs b/rust/tests/integration/consumer.rs index 4151e2c42b..d8f29ae90f 100644 --- a/rust/tests/integration/consumer.rs +++ b/rust/tests/integration/consumer.rs @@ -2,9 +2,7 @@ use async_executor::Executor; use async_io::Timer; use futures_lite::future; use hash_hasher::{HashedMap, HashedSet}; -use mediasoup::consumer::{ - ConsumableRtpEncoding, ConsumerLayers, ConsumerOptions, ConsumerScore, ConsumerType, -}; +use mediasoup::consumer::{ConsumerLayers, ConsumerOptions, ConsumerScore, ConsumerType}; use mediasoup::data_structures::{AppData, ListenInfo, Protocol}; use mediasoup::prelude::*; use mediasoup::producer::ProducerOptions; @@ -372,7 +370,6 @@ async fn init() -> ( } #[test] -#[ignore] fn consume_succeeds() { future::block_on(async move { let (_executor_guard, _worker, router, transport_1, transport_2) = init().await; @@ -707,7 +704,6 @@ fn consume_succeeds() { } #[test] -#[ignore] fn consume_with_enable_rtx_succeeds() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -751,7 +747,6 @@ fn consume_with_enable_rtx_succeeds() { } #[test] -#[ignore] fn consumer_with_user_defined_mid() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -805,7 +800,6 @@ fn consumer_with_user_defined_mid() { } #[test] -#[ignore] fn weak() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -836,7 +830,6 @@ fn weak() { } #[test] -#[ignore] fn consume_incompatible_rtp_capabilities() { future::block_on(async move { let (_executor_guard, _worker, router, transport_1, transport_2) = init().await; @@ -894,7 +887,6 @@ fn consume_incompatible_rtp_capabilities() { } #[test] -#[ignore] fn dump_succeeds() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -993,18 +985,14 @@ fn dump_succeeds() { .consumable_rtp_parameters() .encodings .iter() - .map(|encoding| ConsumableRtpEncoding { + .map(|encoding| RtpEncodingParameters { ssrc: encoding.ssrc, rid: None, codec_payload_type: None, rtx: None, max_bitrate: None, - max_framerate: None, dtx: None, scalability_mode: ScalabilityMode::None, - spatial_layers: None, - temporal_layers: None, - ksvc: None }) .collect::>() ); @@ -1114,18 +1102,14 @@ fn dump_succeeds() { .consumable_rtp_parameters() .encodings .iter() - .map(|encoding| ConsumableRtpEncoding { + .map(|encoding| RtpEncodingParameters { ssrc: encoding.ssrc, rid: None, codec_payload_type: None, rtx: None, max_bitrate: None, - max_framerate: None, dtx: None, scalability_mode: ScalabilityMode::None, - spatial_layers: None, - temporal_layers: None, - ksvc: None, }) .collect::>() ); @@ -1138,7 +1122,6 @@ fn dump_succeeds() { } #[test] -#[ignore] fn get_stats_succeeds() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -1235,7 +1218,6 @@ fn get_stats_succeeds() { } #[test] -#[ignore] fn pause_resume_succeeds() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -1278,7 +1260,6 @@ fn pause_resume_succeeds() { } #[test] -#[ignore] fn set_preferred_layers_succeeds() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -1350,7 +1331,6 @@ fn set_preferred_layers_succeeds() { } #[test] -#[ignore] fn set_unset_priority_succeeds() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; @@ -1450,7 +1430,6 @@ fn producer_pause_resume_events() { } #[test] -#[ignore] fn close_event() { future::block_on(async move { let (_executor_guard, _worker, router, transport_1, transport_2) = init().await; diff --git a/worker/fbs/common.fbs b/worker/fbs/common.fbs index 4495033ab7..85093fc747 100644 --- a/worker/fbs/common.fbs +++ b/worker/fbs/common.fbs @@ -25,3 +25,9 @@ table StringStringArray { values: [string] (required); } +// NOTE (windows): IN|OUT are macros defined in windef.h. +enum TraceDirection: uint8 { + DIRECTION_IN = 0, + DIRECTION_OUT +} + diff --git a/worker/fbs/consumer.fbs b/worker/fbs/consumer.fbs index afeada34d5..d1bd4d90e1 100644 --- a/worker/fbs/consumer.fbs +++ b/worker/fbs/consumer.fbs @@ -1,17 +1,18 @@ +include "common.fbs"; include "rtpParameters.fbs"; include "rtpStream.fbs"; namespace FBS.Consumer; table ConsumerLayers { - spatial_layer: int16; - temporal_layer: int16 = null; + spatial_layer: uint8; + temporal_layer: uint8 = null; } table ConsumerScore { score: uint8; producer_score: uint8; - producer_scores: [uint8]; + producer_scores: [uint8] (required); } table SetPreferredLayersRequest { @@ -30,75 +31,55 @@ table SetPriorityResponse { priority: uint8; } -table EnableTraceEventRequest { - events: [string] (required); +enum TraceEventType: uint8 { + KEYFRAME = 0, + FIR, + NACK, + PLI, + RTP, } -union DumpData { - SimpleConsumerDump, - SimulcastConsumerDump, - SvcConsumerDump, - PipeConsumerDump, +table EnableTraceEventRequest { + events: [TraceEventType] (required); } table DumpResponse { - data: DumpData; - type: FBS.RtpParameters.Type; + data: ConsumerDump (required); } table BaseConsumerDump { id: string (required); + type: FBS.RtpParameters.Type; producer_id: string (required); kind: FBS.RtpParameters.MediaKind; rtp_parameters: FBS.RtpParameters.RtpParameters (required); - consumable_rtp_encodings: [FBS.RtpParameters.RtpEncodingParameters]; - supported_codec_payload_types: [uint8]; - trace_event_types: [string] (required); + consumable_rtp_encodings: [FBS.RtpParameters.RtpEncodingParameters] (required); + supported_codec_payload_types: [uint8] (required); + trace_event_types: [TraceEventType] (required); paused: bool; producer_paused: bool; priority: uint8; } -table SimpleConsumerDump { - base: BaseConsumerDump (required); - rtp_stream: FBS.RtpStream.Dump (required); -} - -table SimulcastConsumerDump { - base: BaseConsumerDump (required); - rtp_stream: FBS.RtpStream.Dump (required); - preferred_spatial_layer: int16; - target_spatial_layer: int16; - current_spatial_layer: int16; - preferred_temporal_layer: int16; - target_temporal_layer: int16; - current_temporal_layer: int16; -} - -table SvcConsumerDump { - base: BaseConsumerDump (required); - rtp_stream: FBS.RtpStream.Dump (required); - preferred_spatial_layer: int16; - target_spatial_layer: int16; - current_spatial_layer: int16; - preferred_temporal_layer: int16; - target_temporal_layer: int16; - current_temporal_layer: int16; -} - -table PipeConsumerDump { +table ConsumerDump { base: BaseConsumerDump (required); rtp_streams: [FBS.RtpStream.Dump] (required); + preferred_spatial_layer: int16 = null; + target_spatial_layer: int16 = null; + current_spatial_layer: int16 = null; + preferred_temporal_layer: int16 = null; + target_temporal_layer: int16 = null; + current_temporal_layer: int16 = null; } table GetStatsResponse { - stats: [FBS.RtpStream.Stats]; + stats: [FBS.RtpStream.Stats] (required); } // Notifications from Worker. table LayersChangeNotification { - layers: ConsumerLayers; + layers: ConsumerLayers (required); } table RtpNotification { @@ -109,20 +90,6 @@ table ScoreNotification { score: ConsumerScore (required); } -enum TraceType: uint8 { - KEYFRAME = 0, - FIR, - NACK, - PLI, - RTP, -} - -// NOTE (windows): IN|OUT are macros defined in windef.h. -enum TraceDirection: uint8 { - DIRECTION_IN = 0, - DIRECTION_OUT -} - union TraceInfo { KeyFrameTraceInfo, FirTraceInfo, @@ -147,9 +114,9 @@ table RtpTraceInfo { } table TraceNotification { - type: TraceType; + type: TraceEventType; timestamp: uint64; - direction: TraceDirection; + direction: FBS.Common.TraceDirection; info: TraceInfo; } diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs index def56fad5a..038da3da77 100644 --- a/worker/fbs/transport.fbs +++ b/worker/fbs/transport.fbs @@ -55,7 +55,7 @@ table ConsumeRequest { table ConsumeResponse { paused: bool; producer_paused: bool; - score: FBS.Consumer.ConsumerScore; + score: FBS.Consumer.ConsumerScore (required); preferred_layers: FBS.Consumer.ConsumerLayers; } @@ -212,12 +212,6 @@ table SctpStateChangeNotification { sctp_state: FBS.SctpAssociation.SctpState; } -// NOTE (windows): IN|OUT are macros defined in windef.h. -enum TraceDirection: uint8 { - DIRECTION_IN = 0, - DIRECTION_OUT -} - union TraceInfo { BweTraceInfo, } @@ -241,7 +235,7 @@ table BweTraceInfo { table TraceNotification { type: TraceEventType; timestamp: uint64; - direction: TraceDirection; + direction: FBS.Common.TraceDirection; info: TraceInfo; } diff --git a/worker/src/RTC/Consumer.cpp b/worker/src/RTC/Consumer.cpp index 16a6276261..d7d46cb217 100644 --- a/worker/src/RTC/Consumer.cpp +++ b/worker/src/RTC/Consumer.cpp @@ -186,32 +186,33 @@ namespace RTC } // Add traceEventTypes. - std::vector> traceEventTypes; + std::vector traceEventTypes; if (this->traceEventTypes.rtp) { - traceEventTypes.emplace_back(builder.CreateString("rtp")); + traceEventTypes.emplace_back(FBS::Consumer::TraceEventType::RTP); } if (this->traceEventTypes.keyframe) { - traceEventTypes.emplace_back(builder.CreateString("keyframe")); + traceEventTypes.emplace_back(FBS::Consumer::TraceEventType::KEYFRAME); } if (this->traceEventTypes.nack) { - traceEventTypes.emplace_back(builder.CreateString("nack")); + traceEventTypes.emplace_back(FBS::Consumer::TraceEventType::NACK); } if (this->traceEventTypes.pli) { - traceEventTypes.emplace_back(builder.CreateString("pli")); + traceEventTypes.emplace_back(FBS::Consumer::TraceEventType::PLI); } if (this->traceEventTypes.fir) { - traceEventTypes.emplace_back(builder.CreateString("fir")); + traceEventTypes.emplace_back(FBS::Consumer::TraceEventType::FIR); } return FBS::Consumer::CreateBaseConsumerDumpDirect( builder, this->id.c_str(), + RTC::RtpParameters::TypeToFbs(this->type), this->producerId.c_str(), this->kind == RTC::Media::Kind::AUDIO ? FBS::RtpParameters::MediaKind::AUDIO : FBS::RtpParameters::MediaKind::VIDEO, @@ -315,27 +316,38 @@ namespace RTC for (const auto& type : *body->events()) { - const auto typeStr = type->str(); - - if (typeStr == "rtp") - { - newTraceEventTypes.rtp = true; - } - else if (typeStr == "keyframe") - { - newTraceEventTypes.keyframe = true; - } - else if (typeStr == "nack") - { - newTraceEventTypes.nack = true; - } - else if (typeStr == "pli") - { - newTraceEventTypes.pli = true; - } - else if (typeStr == "fir") + switch (type) { - newTraceEventTypes.fir = true; + case FBS::Consumer::TraceEventType::KEYFRAME: + { + newTraceEventTypes.keyframe = true; + + break; + } + case FBS::Consumer::TraceEventType::FIR: + { + newTraceEventTypes.fir = true; + + break; + } + case FBS::Consumer::TraceEventType::NACK: + { + newTraceEventTypes.nack = true; + + break; + } + case FBS::Consumer::TraceEventType::PLI: + { + newTraceEventTypes.pli = true; + + break; + } + case FBS::Consumer::TraceEventType::RTP: + { + newTraceEventTypes.rtp = true; + + break; + } } } @@ -463,9 +475,9 @@ namespace RTC auto notification = FBS::Consumer::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), - FBS::Consumer::TraceType::KEYFRAME, + FBS::Consumer::TraceEventType::KEYFRAME, DepLibUV::GetTimeMs(), - FBS::Consumer::TraceDirection::DIRECTION_OUT, + FBS::Common::TraceDirection::DIRECTION_OUT, FBS::Consumer::TraceInfo::KeyFrameTraceInfo, traceInfo.Union()); @@ -478,9 +490,9 @@ namespace RTC auto notification = FBS::Consumer::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), - FBS::Consumer::TraceType::RTP, + FBS::Consumer::TraceEventType::RTP, DepLibUV::GetTimeMs(), - FBS::Consumer::TraceDirection::DIRECTION_OUT, + FBS::Common::TraceDirection::DIRECTION_OUT, FBS::Consumer::TraceInfo::RtpTraceInfo, traceInfo.Union()); @@ -502,9 +514,9 @@ namespace RTC auto notification = FBS::Consumer::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), - FBS::Consumer::TraceType::PLI, + FBS::Consumer::TraceEventType::PLI, DepLibUV::GetTimeMs(), - FBS::Consumer::TraceDirection::DIRECTION_IN, + FBS::Common::TraceDirection::DIRECTION_IN, FBS::Consumer::TraceInfo::PliTraceInfo, traceInfo.Union()); @@ -525,9 +537,9 @@ namespace RTC auto notification = FBS::Consumer::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), - FBS::Consumer::TraceType::FIR, + FBS::Consumer::TraceEventType::FIR, DepLibUV::GetTimeMs(), - FBS::Consumer::TraceDirection::DIRECTION_IN, + FBS::Common::TraceDirection::DIRECTION_IN, FBS::Consumer::TraceInfo::FirTraceInfo, traceInfo.Union()); @@ -545,9 +557,9 @@ namespace RTC auto notification = FBS::Consumer::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), - FBS::Consumer::TraceType::NACK, + FBS::Consumer::TraceEventType::NACK, DepLibUV::GetTimeMs(), - FBS::Consumer::TraceDirection::DIRECTION_IN); + FBS::Common::TraceDirection::DIRECTION_IN); EmitTraceEvent(notification); } diff --git a/worker/src/RTC/PipeConsumer.cpp b/worker/src/RTC/PipeConsumer.cpp index 6553282fd3..d5e96f6a74 100644 --- a/worker/src/RTC/PipeConsumer.cpp +++ b/worker/src/RTC/PipeConsumer.cpp @@ -1,11 +1,12 @@ +#include "FBS/consumer_generated.h" #define MS_CLASS "RTC::PipeConsumer" // #define MS_LOG_DEV_LEVEL 3 -#include "RTC/PipeConsumer.hpp" #include "DepLibUV.hpp" #include "Logger.hpp" #include "MediaSoupErrors.hpp" #include "RTC/Codecs/Tools.hpp" +#include "RTC/PipeConsumer.hpp" namespace RTC { @@ -72,13 +73,9 @@ namespace RTC rtpStreams.emplace_back(rtpStream->FillBuffer(builder)); } - auto pipeConsumerDump = FBS::Consumer::CreatePipeConsumerDumpDirect(builder, base, &rtpStreams); + auto dump = FBS::Consumer::CreateConsumerDumpDirect(builder, base, &rtpStreams); - return FBS::Consumer::CreateDumpResponse( - builder, - FBS::Consumer::DumpData::PipeConsumerDump, - pipeConsumerDump.Union(), - FBS::RtpParameters::Type(this->type)); + return FBS::Consumer::CreateDumpResponse(builder, dump); } flatbuffers::Offset PipeConsumer::FillBufferStats( @@ -136,9 +133,12 @@ namespace RTC case Channel::ChannelRequest::Method::CONSUMER_SET_PREFERRED_LAYERS: { - // Do nothing. + // Accept with empty preferred layers object. - request->Accept(); + auto responseOffset = + FBS::Consumer::CreateSetPreferredLayersResponse(request->GetBufferBuilder()); + + request->Accept(FBS::Response::Body::Consumer_SetPreferredLayersResponse, responseOffset); break; } diff --git a/worker/src/RTC/SimpleConsumer.cpp b/worker/src/RTC/SimpleConsumer.cpp index ce25d297e4..96889142f8 100644 --- a/worker/src/RTC/SimpleConsumer.cpp +++ b/worker/src/RTC/SimpleConsumer.cpp @@ -1,11 +1,12 @@ +#include "FBS/consumer_generated.h" #define MS_CLASS "RTC::SimpleConsumer" // #define MS_LOG_DEV_LEVEL 3 -#include "RTC/SimpleConsumer.hpp" #include "DepLibUV.hpp" #include "Logger.hpp" #include "MediaSoupErrors.hpp" #include "RTC/Codecs/Tools.hpp" +#include "RTC/SimpleConsumer.hpp" namespace RTC { @@ -72,15 +73,12 @@ namespace RTC // Call the parent method. auto base = RTC::Consumer::FillBuffer(builder); // Add rtpStream. - auto rtpStream = this->rtpStream->FillBuffer(builder); + std::vector> rtpStreams; + rtpStreams.emplace_back(this->rtpStream->FillBuffer(builder)); - auto simpleConsumerDump = FBS::Consumer::CreateSimpleConsumerDump(builder, base, rtpStream); + auto dump = FBS::Consumer::CreateConsumerDumpDirect(builder, base, &rtpStreams); - return FBS::Consumer::CreateDumpResponse( - builder, - FBS::Consumer::DumpData::SimpleConsumerDump, - simpleConsumerDump.Union(), - FBS::RtpParameters::Type(this->type)); + return FBS::Consumer::CreateDumpResponse(builder, dump); } flatbuffers::Offset SimpleConsumer::FillBufferStats( @@ -145,9 +143,12 @@ namespace RTC case Channel::ChannelRequest::Method::CONSUMER_SET_PREFERRED_LAYERS: { - // Do nothing. + // Accept with empty preferred layers object. - request->Accept(); + auto responseOffset = + FBS::Consumer::CreateSetPreferredLayersResponse(request->GetBufferBuilder()); + + request->Accept(FBS::Response::Body::Consumer_SetPreferredLayersResponse, responseOffset); break; } diff --git a/worker/src/RTC/SimulcastConsumer.cpp b/worker/src/RTC/SimulcastConsumer.cpp index 1bc7d02ed3..20378a69a3 100644 --- a/worker/src/RTC/SimulcastConsumer.cpp +++ b/worker/src/RTC/SimulcastConsumer.cpp @@ -1,4 +1,3 @@ - #define MS_CLASS "RTC::SimulcastConsumer" // #define MS_LOG_DEV_LEVEL 3 @@ -132,12 +131,13 @@ namespace RTC // Call the parent method. auto base = RTC::Consumer::FillBuffer(builder); // Add rtpStream. - auto rtpStream = this->rtpStream->FillBuffer(builder); + std::vector> rtpStreams; + rtpStreams.emplace_back(this->rtpStream->FillBuffer(builder)); - auto simulcastConsumerDump = FBS::Consumer::CreateSimulcastConsumerDump( + auto dump = FBS::Consumer::CreateConsumerDumpDirect( builder, base, - rtpStream, + &rtpStreams, this->preferredSpatialLayer, this->targetSpatialLayer, this->currentSpatialLayer, @@ -145,11 +145,7 @@ namespace RTC this->targetTemporalLayer, this->encodingContext->GetCurrentTemporalLayer()); - return FBS::Consumer::CreateDumpResponse( - builder, - FBS::Consumer::DumpData::SimulcastConsumerDump, - simulcastConsumerDump.Union(), - FBS::RtpParameters::Type(this->type)); + return FBS::Consumer::CreateDumpResponse(builder, dump); } flatbuffers::Offset SimulcastConsumer::FillBufferStats( diff --git a/worker/src/RTC/SvcConsumer.cpp b/worker/src/RTC/SvcConsumer.cpp index 6bae41b5b6..9b3a18101e 100644 --- a/worker/src/RTC/SvcConsumer.cpp +++ b/worker/src/RTC/SvcConsumer.cpp @@ -109,12 +109,13 @@ namespace RTC // Call the parent method. auto base = RTC::Consumer::FillBuffer(builder); // Add rtpStream. - auto rtpStream = this->rtpStream->FillBuffer(builder); + std::vector> rtpStreams; + rtpStreams.emplace_back(this->rtpStream->FillBuffer(builder)); - auto svcConsumerDump = FBS::Consumer::CreateSvcConsumerDump( + auto dump = FBS::Consumer::CreateConsumerDumpDirect( builder, base, - rtpStream, + &rtpStreams, this->preferredSpatialLayer, this->encodingContext->GetTargetSpatialLayer(), this->encodingContext->GetCurrentSpatialLayer(), @@ -122,11 +123,7 @@ namespace RTC this->encodingContext->GetTargetTemporalLayer(), this->encodingContext->GetCurrentTemporalLayer()); - return FBS::Consumer::CreateDumpResponse( - builder, - FBS::Consumer::DumpData::SvcConsumerDump, - svcConsumerDump.Union(), - FBS::RtpParameters::Type(this->type)); + return FBS::Consumer::CreateDumpResponse(builder, dump); } flatbuffers::Offset SvcConsumer::FillBufferStats( diff --git a/worker/src/RTC/Transport.cpp b/worker/src/RTC/Transport.cpp index bd53a9d39d..38e8f35f01 100644 --- a/worker/src/RTC/Transport.cpp +++ b/worker/src/RTC/Transport.cpp @@ -2289,7 +2289,7 @@ namespace RTC this->shared->channelNotifier->GetBufferBuilder(), FBS::Transport::TraceEventType::PROBATION, DepLibUV::GetTimeMs(), - FBS::Transport::TraceDirection::DIRECTION_OUT); + FBS::Common::TraceDirection::DIRECTION_OUT); this->shared->channelNotifier->Emit( this->id, @@ -2325,7 +2325,7 @@ namespace RTC this->shared->channelNotifier->GetBufferBuilder(), FBS::Transport::TraceEventType::BWE, DepLibUV::GetTimeMs(), - FBS::Transport::TraceDirection::DIRECTION_OUT, + FBS::Common::TraceDirection::DIRECTION_OUT, FBS::Transport::TraceInfo::BweTraceInfo, traceInfo.Union()); From e94e499e4bce0a4d20c29ea1b4ce71347987ba8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Mon, 2 Oct 2023 15:07:20 +0200 Subject: [PATCH 32/73] FBS: Producer notifications (#1166) --- node/src/Producer.ts | 3 +- node/src/tests/test-Producer.ts | 4 +- rust/src/fbs.rs | 422 +++++++++++--------------------- rust/src/router/producer.rs | 151 +++++++++++- worker/fbs/producer.fbs | 12 +- worker/src/RTC/Producer.cpp | 11 +- 6 files changed, 300 insertions(+), 303 deletions(-) diff --git a/node/src/Producer.ts b/node/src/Producer.ts index 93e82d11b2..1e49c01931 100644 --- a/node/src/Producer.ts +++ b/node/src/Producer.ts @@ -7,6 +7,7 @@ import { Event, Notification } from './fbs/notification'; import { parseRtpStreamRecvStats, RtpStreamRecvStats } from './RtpStream'; import { AppData } from './types'; import * as utils from './utils'; +import { TraceDirection as FbsTraceDirection } from './fbs/common'; import * as FbsNotification from './fbs/notification'; import * as FbsRequest from './fbs/request'; import * as FbsTransport from './fbs/transport'; @@ -742,7 +743,7 @@ function parseTraceEventData( return { type : producerTraceEventTypeFromFbs(trace.type()), timestamp : Number(trace.timestamp()), - direction : trace.direction() === FbsProducer.TraceDirection.DIRECTION_IN ? 'in' : 'out', + direction : trace.direction() === FbsTraceDirection.DIRECTION_IN ? 'in' : 'out', info : info ? info.unpack() : undefined }; } diff --git a/node/src/tests/test-Producer.ts b/node/src/tests/test-Producer.ts index d87e0a17ab..3784d154b1 100644 --- a/node/src/tests/test-Producer.ts +++ b/node/src/tests/test-Producer.ts @@ -699,8 +699,8 @@ test('Producer emits "score"', async () => // Simulate a 'score' notification coming through the channel. const builder = new flatbuffers.Builder(); const producerScoreNotification = new FbsProducer.ScoreNotificationT([ - new FbsProducer.ScoreT(/* ssrc */ 11, /* rid */ undefined, /* score */ 10), - new FbsProducer.ScoreT(/* ssrc */ 22, /* rid */ undefined, /* score */ 9) + new FbsProducer.ScoreT(/* encodingIdx */ 0, /* ssrc */ 11, /* rid */ undefined, /* score */ 10), + new FbsProducer.ScoreT(/* encodingIdx */ 1, /* ssrc */ 22, /* rid */ undefined, /* score */ 9) ]); const notificationOffset = Notification.createNotification( builder, diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index 5795b8a43a..25d7c15b11 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -63532,7 +63532,7 @@ mod root { /// The enum `TraceEventType` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Enum `TraceEventType` in the file `../worker/fbs/producer.fbs:6` + /// * Enum `TraceEventType` in the file `../worker/fbs/producer.fbs:7` #[derive( Copy, Clone, @@ -63715,7 +63715,7 @@ mod root { /// The table `EnableTraceEventRequest` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/producer.fbs:14` + /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/producer.fbs:15` #[derive( Clone, Debug, @@ -63993,7 +63993,7 @@ mod root { /// The table `DumpResponse` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/producer.fbs:18` + /// * Table `DumpResponse` in the file `../worker/fbs/producer.fbs:19` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -64598,7 +64598,7 @@ mod root { /// The table `GetStatsResponse` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/producer.fbs:29` + /// * Table `GetStatsResponse` in the file `../worker/fbs/producer.fbs:30` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -64865,7 +64865,7 @@ mod root { /// The table `SendNotification` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `SendNotification` in the file `../worker/fbs/producer.fbs:33` + /// * Table `SendNotification` in the file `../worker/fbs/producer.fbs:34` #[derive( Clone, Debug, @@ -65123,7 +65123,7 @@ mod root { /// The table `Score` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `Score` in the file `../worker/fbs/producer.fbs:39` + /// * Table `Score` in the file `../worker/fbs/producer.fbs:40` #[derive( Clone, Debug, @@ -65136,6 +65136,8 @@ mod root { ::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` @@ -65148,6 +65150,7 @@ mod root { impl ::core::default::Default for Score { fn default() -> Self { Self { + encoding_idx: 0, ssrc: 0, rid: ::core::default::Default::default(), score: 0, @@ -65165,28 +65168,38 @@ mod root { #[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<10> = + let mut table_writer: ::planus::table_writer::TableWriter<12> = ::core::default::Default::default(); - if prepared_ssrc.is_some() { + 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>(1); + table_writer.write_entry::<::planus::Offset>(2); } if prepared_score.is_some() { - table_writer.write_entry::(2); + 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); } @@ -65226,7 +65239,7 @@ mod root { impl ::planus::WriteAsOffset for Score { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Score::create(builder, self.ssrc, &self.rid, self.score) + Score::create(builder, self.encoding_idx, self.ssrc, &self.rid, self.score) } } @@ -65238,65 +65251,87 @@ mod root { pub struct ScoreBuilder(State); impl ScoreBuilder<()> { - /// Setter for the [`ssrc` field](Score#structfield.ssrc). + /// Setter for the [`encoding_idx` field](Score#structfield.encoding_idx). #[inline] #[allow(clippy::type_complexity)] - pub fn ssrc(self, value: T0) -> ScoreBuilder<(T0,)> + pub fn encoding_idx(self, value: T0) -> ScoreBuilder<(T0,)> where T0: ::planus::WriteAsDefault, { ScoreBuilder((value,)) } - /// Sets the [`ssrc` field](Score#structfield.ssrc) to the default value. + /// Sets the [`encoding_idx` field](Score#structfield.encoding_idx) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn ssrc_as_default(self) -> ScoreBuilder<(::planus::DefaultValue,)> { - self.ssrc(::planus::DefaultValue) + pub fn encoding_idx_as_default(self) -> ScoreBuilder<(::planus::DefaultValue,)> { + self.encoding_idx(::planus::DefaultValue) } } impl ScoreBuilder<(T0,)> { - /// Setter for the [`rid` field](Score#structfield.rid). + /// Setter for the [`ssrc` field](Score#structfield.ssrc). #[inline] #[allow(clippy::type_complexity)] - pub fn rid(self, value: T1) -> ScoreBuilder<(T0, T1)> + pub fn ssrc(self, value: T1) -> ScoreBuilder<(T0, T1)> where - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, + T1: ::planus::WriteAsDefault, { let (v0,) = self.0; ScoreBuilder((v0, value)) } - /// Sets the [`rid` field](Score#structfield.rid) to null. + /// Sets the [`ssrc` field](Score#structfield.ssrc) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn rid_as_null(self) -> ScoreBuilder<(T0, ())> { - self.rid(()) + pub fn ssrc_as_default(self) -> ScoreBuilder<(T0, ::planus::DefaultValue)> { + self.ssrc(::planus::DefaultValue) } } impl ScoreBuilder<(T0, T1)> { - /// Setter for the [`score` field](Score#structfield.score). + /// Setter for the [`rid` field](Score#structfield.rid). #[inline] #[allow(clippy::type_complexity)] - pub fn score(self, value: T2) -> ScoreBuilder<(T0, T1, T2)> + pub fn rid(self, value: T2) -> ScoreBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAsDefault, + 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, ::planus::DefaultValue)> { + pub fn score_as_default( + self, + ) -> ScoreBuilder<(T0, T1, T2, ::planus::DefaultValue)> { self.score(::planus::DefaultValue) } } - impl ScoreBuilder<(T0, T1, T2)> { + 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 @@ -65309,9 +65344,10 @@ mod root { impl< T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T2: ::planus::WriteAsDefault, - > ::planus::WriteAs<::planus::Offset> for ScoreBuilder<(T0, T1, T2)> + 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; @@ -65323,10 +65359,11 @@ mod root { impl< T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T2: ::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)> + for ScoreBuilder<(T0, T1, T2, T3)> { type Prepared = ::planus::Offset; @@ -65341,14 +65378,15 @@ mod root { impl< T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsOptional<::planus::Offset<::core::primitive::str>>, - T2: ::planus::WriteAsDefault, - > ::planus::WriteAsOffset for ScoreBuilder<(T0, T1, T2)> + 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) = &self.0; - Score::create(builder, v0, v1, v2) + let (v0, v1, v2, v3) = &self.0; + Score::create(builder, v0, v1, v2, v3) } } @@ -65357,10 +65395,18 @@ mod root { 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(0, "Score", "ssrc")?.unwrap_or(0)) + ::core::result::Result::Ok(self.0.access(1, "Score", "ssrc")?.unwrap_or(0)) } /// Getter for the [`rid` field](Score#structfield.rid). @@ -65369,19 +65415,20 @@ mod root { &self, ) -> ::planus::Result<::core::option::Option<&'a ::core::primitive::str>> { - self.0.access(1, "Score", "rid") + 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(2, "Score", "score")?.unwrap_or(0)) + ::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); @@ -65397,6 +65444,7 @@ mod root { #[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)?) @@ -65481,7 +65529,7 @@ mod root { /// The table `ScoreNotification` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `ScoreNotification` in the file `../worker/fbs/producer.fbs:45` + /// * Table `ScoreNotification` in the file `../worker/fbs/producer.fbs:47` #[derive( Clone, Debug, @@ -65495,16 +65543,7 @@ mod root { )] pub struct ScoreNotification { /// The field `scores` in the table `ScoreNotification` - pub scores: ::core::option::Option<::planus::alloc::vec::Vec>, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for ScoreNotification { - fn default() -> Self { - Self { - scores: ::core::default::Default::default(), - } - } + pub scores: ::planus::alloc::vec::Vec, } impl ScoreNotification { @@ -65517,7 +65556,7 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_scores: impl ::planus::WriteAsOptional< + field_scores: impl ::planus::WriteAs< ::planus::Offset<[::planus::Offset]>, >, ) -> ::planus::Offset { @@ -65525,16 +65564,12 @@ mod root { let mut table_writer: ::planus::table_writer::TableWriter<6> = ::core::default::Default::default(); - if prepared_scores.is_some() { - table_writer - .write_entry::<::planus::Offset<[::planus::Offset]>>(0); - } + table_writer + .write_entry::<::planus::Offset<[::planus::Offset]>>(0); unsafe { table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_scores) = prepared_scores { - object_writer.write::<_, _, 4>(&prepared_scores); - } + object_writer.write::<_, _, 4>(&prepared_scores); }); } builder.current_offset() @@ -65588,19 +65623,10 @@ mod root { #[allow(clippy::type_complexity)] pub fn scores(self, value: T0) -> ScoreNotificationBuilder<(T0,)> where - T0: ::planus::WriteAsOptional< - ::planus::Offset<[::planus::Offset]>, - >, + T0: ::planus::WriteAs<::planus::Offset<[::planus::Offset]>>, { ScoreNotificationBuilder((value,)) } - - /// Sets the [`scores` field](ScoreNotification#structfield.scores) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn scores_as_null(self) -> ScoreNotificationBuilder<((),)> { - self.scores(()) - } } impl ScoreNotificationBuilder<(T0,)> { @@ -65617,9 +65643,8 @@ mod root { } } - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAs<::planus::Offset> + impl]>>> + ::planus::WriteAs<::planus::Offset> for ScoreNotificationBuilder<(T0,)> { type Prepared = ::planus::Offset; @@ -65633,9 +65658,8 @@ mod root { } } - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOptional<::planus::Offset> + impl]>>> + ::planus::WriteAsOptional<::planus::Offset> for ScoreNotificationBuilder<(T0,)> { type Prepared = ::planus::Offset; @@ -65649,9 +65673,8 @@ mod root { } } - impl< - T0: ::planus::WriteAsOptional<::planus::Offset<[::planus::Offset]>>, - > ::planus::WriteAsOffset for ScoreNotificationBuilder<(T0,)> + impl]>>> + ::planus::WriteAsOffset for ScoreNotificationBuilder<(T0,)> { #[inline] fn prepare( @@ -65672,21 +65695,16 @@ mod root { #[inline] pub fn scores( &self, - ) -> ::planus::Result< - ::core::option::Option< - ::planus::Vector<'a, ::planus::Result>>, - >, - > { - self.0.access(0, "ScoreNotification", "scores") + ) -> ::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"); - if let ::core::option::Option::Some(field_scores) = self.scores().transpose() { - f.field("scores", &field_scores); - } + f.field("scores", &self.scores()); f.finish() } } @@ -65697,11 +65715,7 @@ mod root { #[allow(unreachable_code)] fn try_from(value: ScoreNotificationRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - scores: if let ::core::option::Option::Some(scores) = value.scores()? { - ::core::option::Option::Some(scores.to_vec_result()?) - } else { - ::core::option::Option::None - }, + scores: value.scores()?.to_vec_result()?, }) } } @@ -65779,7 +65793,7 @@ mod root { /// The table `VideoOrientationChangeNotification` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `VideoOrientationChangeNotification` in the file `../worker/fbs/producer.fbs:49` + /// * Table `VideoOrientationChangeNotification` in the file `../worker/fbs/producer.fbs:51` #[derive( Clone, Debug, @@ -66199,180 +66213,10 @@ mod root { } } - /// The enum `TraceDirection` in the namespace `FBS.Producer` - /// - /// Generated from these locations: - /// * Enum `TraceDirection` in the file `../worker/fbs/producer.fbs:56` - #[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 union `TraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Union `TraceInfo` in the file `../worker/fbs/producer.fbs:61` + /// * Union `TraceInfo` in the file `../worker/fbs/producer.fbs:57` #[derive( Clone, Debug, @@ -66704,7 +66548,7 @@ mod root { /// The table `KeyFrameTraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/producer.fbs:68` + /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/producer.fbs:64` #[derive( Clone, Debug, @@ -66986,7 +66830,7 @@ mod root { /// The table `FirTraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `FirTraceInfo` in the file `../worker/fbs/producer.fbs:72` + /// * Table `FirTraceInfo` in the file `../worker/fbs/producer.fbs:68` #[derive( Clone, Debug, @@ -67263,7 +67107,7 @@ mod root { /// The table `PliTraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `PliTraceInfo` in the file `../worker/fbs/producer.fbs:76` + /// * Table `PliTraceInfo` in the file `../worker/fbs/producer.fbs:72` #[derive( Clone, Debug, @@ -67540,7 +67384,7 @@ mod root { /// The table `RtpTraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `RtpTraceInfo` in the file `../worker/fbs/producer.fbs:80` + /// * Table `RtpTraceInfo` in the file `../worker/fbs/producer.fbs:76` #[derive( Clone, Debug, @@ -67817,7 +67661,7 @@ mod root { /// The table `TraceNotification` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/producer.fbs:84` + /// * Table `TraceNotification` in the file `../worker/fbs/producer.fbs:80` #[derive( Clone, Debug, @@ -67835,7 +67679,7 @@ mod root { /// The field `timestamp` in the table `TraceNotification` pub timestamp: u64, /// The field `direction` in the table `TraceNotification` - pub direction: self::TraceDirection, + pub direction: super::common::TraceDirection, /// The field `info` in the table `TraceNotification` pub info: ::core::option::Option, } @@ -67846,7 +67690,7 @@ mod root { Self { type_: self::TraceEventType::Keyframe, timestamp: 0, - direction: self::TraceDirection::DirectionIn, + direction: super::common::TraceDirection::DirectionIn, info: ::core::default::Default::default(), } } @@ -67868,16 +67712,16 @@ mod root { >, field_timestamp: impl ::planus::WriteAsDefault, field_direction: impl ::planus::WriteAsDefault< - self::TraceDirection, - self::TraceDirection, + 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, &self::TraceDirection::DirectionIn); + 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> = @@ -67892,7 +67736,7 @@ mod root { table_writer.write_entry::(0); } if prepared_direction.is_some() { - table_writer.write_entry::(2); + table_writer.write_entry::(2); } if prepared_info.is_some() { table_writer.write_entry::(3); @@ -68021,7 +67865,10 @@ mod root { #[allow(clippy::type_complexity)] pub fn direction(self, value: T2) -> TraceNotificationBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault< + super::common::TraceDirection, + super::common::TraceDirection, + >, { let (v0, v1) = self.0; TraceNotificationBuilder((v0, v1, value)) @@ -68074,7 +67921,10 @@ mod root { impl< T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault< + super::common::TraceDirection, + super::common::TraceDirection, + >, T3: ::planus::WriteAsOptionalUnion, > ::planus::WriteAs<::planus::Offset> for TraceNotificationBuilder<(T0, T1, T2, T3)> @@ -68093,7 +67943,10 @@ mod root { impl< T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault< + super::common::TraceDirection, + super::common::TraceDirection, + >, T3: ::planus::WriteAsOptionalUnion, > ::planus::WriteAsOptional<::planus::Offset> for TraceNotificationBuilder<(T0, T1, T2, T3)> @@ -68112,7 +67965,10 @@ mod root { impl< T0: ::planus::WriteAsDefault, T1: ::planus::WriteAsDefault, - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsDefault< + super::common::TraceDirection, + super::common::TraceDirection, + >, T3: ::planus::WriteAsOptionalUnion, > ::planus::WriteAsOffset for TraceNotificationBuilder<(T0, T1, T2, T3)> @@ -68154,11 +68010,11 @@ mod root { /// Getter for the [`direction` field](TraceNotification#structfield.direction). #[inline] - pub fn direction(&self) -> ::planus::Result { + pub fn direction(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 .access(2, "TraceNotification", "direction")? - .unwrap_or(self::TraceDirection::DirectionIn), + .unwrap_or(super::common::TraceDirection::DirectionIn), ) } diff --git a/rust/src/router/producer.rs b/rust/src/router/producer.rs index 069814ded8..5aac664ba1 100644 --- a/rust/src/router/producer.rs +++ b/rust/src/router/producer.rs @@ -3,7 +3,7 @@ mod tests; use crate::consumer::{RtpStreamParams, RtxStreamParams}; use crate::data_structures::{AppData, RtpPacketTraceInfo, SsrcTraceInfo, TraceEventDirection}; -use crate::fbs::{producer, response, rtp_parameters, rtp_stream}; +use crate::fbs::{notification, producer, response, rtp_parameters, rtp_stream}; use crate::messages::{ ProducerCloseRequest, ProducerDumpRequest, ProducerEnableTraceEventRequest, ProducerGetStatsRequest, ProducerPauseRequest, ProducerResumeRequest, ProducerSendNotification, @@ -12,7 +12,9 @@ pub use crate::ortc::RtpMapping; use crate::rtp_parameters::{MediaKind, MimeType, RtpParameters}; use crate::transport::Transport; use crate::uuid_based_wrapper_type; -use crate::worker::{Channel, NotificationError, RequestError, SubscriptionHandler}; +use crate::worker::{ + Channel, NotificationError, NotificationParseError, RequestError, SubscriptionHandler, +}; use async_executor::Executor; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; @@ -192,6 +194,17 @@ pub struct ProducerScore { pub score: u8, } +impl ProducerScore { + pub(crate) fn from_fbs(producer_score: &producer::Score) -> Self { + Self { + encoding_idx: producer_score.encoding_idx, + ssrc: producer_score.ssrc, + rid: producer_score.rid.clone(), + score: producer_score.score, + } + } +} + /// Rotation angle #[derive(Debug, Copy, Clone, Eq, PartialEq, Deserialize_repr, Serialize_repr)] #[repr(u16)] @@ -218,6 +231,24 @@ pub struct ProducerVideoOrientation { pub rotation: Rotation, } +impl ProducerVideoOrientation { + pub(crate) fn from_fbs( + video_orientation: producer::VideoOrientationChangeNotification, + ) -> Self { + Self { + camera: video_orientation.camera, + flip: video_orientation.flip, + rotation: match video_orientation.rotation { + 0 => Rotation::None, + 90 => Rotation::Clockwise, + 180 => Rotation::Rotate180, + 270 => Rotation::CounterClockwise, + _ => Rotation::None, + }, + } + } +} + /// Bitrate by layer. #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -356,6 +387,65 @@ pub enum ProducerTraceEventData { }, } +impl ProducerTraceEventData { + pub(crate) fn from_fbs(data: producer::TraceNotification) -> Self { + match data.type_ { + producer::TraceEventType::Rtp => ProducerTraceEventData::Rtp { + timestamp: data.timestamp, + direction: TraceEventDirection::from_fbs(data.direction), + info: { + let Some(producer::TraceInfo::RtpTraceInfo(info)) = data.info else { + panic!("Wrong message from worker: {data:?}"); + }; + + RtpPacketTraceInfo { + is_rtx: info.is_rtx, + } + }, + }, + producer::TraceEventType::Keyframe => ProducerTraceEventData::KeyFrame { + timestamp: data.timestamp, + direction: TraceEventDirection::from_fbs(data.direction), + info: { + let Some(producer::TraceInfo::KeyFrameTraceInfo(info)) = data.info else { + panic!("Wrong message from worker: {data:?}"); + }; + + RtpPacketTraceInfo { + is_rtx: info.is_rtx, + } + }, + }, + producer::TraceEventType::Nack => ProducerTraceEventData::Nack { + timestamp: data.timestamp, + direction: TraceEventDirection::from_fbs(data.direction), + }, + producer::TraceEventType::Pli => ProducerTraceEventData::Pli { + timestamp: data.timestamp, + direction: TraceEventDirection::from_fbs(data.direction), + info: { + let Some(producer::TraceInfo::PliTraceInfo(info)) = data.info else { + panic!("Wrong message from worker: {data:?}"); + }; + + SsrcTraceInfo { ssrc: info.ssrc } + }, + }, + producer::TraceEventType::Fir => ProducerTraceEventData::Fir { + timestamp: data.timestamp, + direction: TraceEventDirection::from_fbs(data.direction), + info: { + let Some(producer::TraceInfo::FirTraceInfo(info)) = data.info else { + panic!("Wrong message from worker: {data:?}"); + }; + + SsrcTraceInfo { ssrc: info.ssrc } + }, + }, + } + } +} + /// Types of consumer trace events. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] @@ -402,6 +492,59 @@ enum Notification { Trace(ProducerTraceEventData), } +impl Notification { + pub(crate) fn from_fbs( + notification: notification::NotificationRef<'_>, + ) -> Result { + match notification.event().unwrap() { + notification::Event::ProducerScore => { + let Ok(Some(notification::BodyRef::ProducerScoreNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let scores_fbs: Vec<_> = body + .scores() + .unwrap() + .iter() + .map(|score| producer::Score::try_from(score.unwrap()).unwrap()) + .collect(); + let scores = scores_fbs.iter().map(ProducerScore::from_fbs).collect(); + + Ok(Notification::Score(scores)) + } + notification::Event::ProducerVideoOrientationChange => { + let Ok(Some(notification::BodyRef::ProducerVideoOrientationChangeNotification( + body, + ))) = notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let video_orientation_fbs = + producer::VideoOrientationChangeNotification::try_from(body).unwrap(); + let video_orientation = ProducerVideoOrientation::from_fbs(video_orientation_fbs); + + Ok(Notification::VideoOrientationChange(video_orientation)) + } + notification::Event::ProducerTrace => { + let Ok(Some(notification::BodyRef::ProducerTraceNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let trace_notification_fbs = producer::TraceNotification::try_from(body).unwrap(); + let trace_notification = ProducerTraceEventData::from_fbs(trace_notification_fbs); + + Ok(Notification::Trace(trace_notification)) + } + _ => Err(NotificationParseError::InvalidEvent), + } + } +} + #[derive(Default)] #[allow(clippy::type_complexity)] struct Handlers { @@ -579,8 +722,8 @@ impl Producer { let handlers = Arc::clone(&handlers); let score = Arc::clone(&score); - channel.subscribe_to_notifications(id.into(), move |notification| { - match serde_json::from_slice::(notification) { + channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::Score(scores) => { *score.lock() = scores.clone(); diff --git a/worker/fbs/producer.fbs b/worker/fbs/producer.fbs index facd090fa8..86b955da73 100644 --- a/worker/fbs/producer.fbs +++ b/worker/fbs/producer.fbs @@ -1,3 +1,4 @@ +include "common.fbs"; include "rtpParameters.fbs"; include "rtpStream.fbs"; @@ -37,13 +38,14 @@ table SendNotification { // Notifications from Worker. table Score { + encoding_idx: uint32; ssrc: uint32; rid: string; score: uint8; } table ScoreNotification { - scores: [Score]; + scores: [Score] (required); } table VideoOrientationChangeNotification { @@ -52,12 +54,6 @@ table VideoOrientationChangeNotification { rotation: uint16; } -// NOTE (windows): IN|OUT are macros defined in windef.h. -enum TraceDirection: uint8 { - DIRECTION_IN = 0, - DIRECTION_OUT -} - union TraceInfo { KeyFrameTraceInfo, FirTraceInfo, @@ -84,7 +80,7 @@ table RtpTraceInfo { table TraceNotification { type: TraceEventType; timestamp: uint64; - direction: TraceDirection; + direction: FBS.Common.TraceDirection; info: TraceInfo; } diff --git a/worker/src/RTC/Producer.cpp b/worker/src/RTC/Producer.cpp index 342faa6960..02845e7b10 100644 --- a/worker/src/RTC/Producer.cpp +++ b/worker/src/RTC/Producer.cpp @@ -1450,6 +1450,7 @@ namespace RTC scores.emplace_back(FBS::Producer::CreateScoreDirect( this->shared->channelNotifier->GetBufferBuilder(), + rtpStream->GetEncodingIdx(), rtpStream->GetSsrc(), !rtpStream->GetRid().empty() ? rtpStream->GetRid().c_str() : nullptr, rtpStream->GetScore())); @@ -1478,7 +1479,7 @@ namespace RTC this->shared->channelNotifier->GetBufferBuilder(), FBS::Producer::TraceEventType::KEYFRAME, DepLibUV::GetTimeMs(), - FBS::Producer::TraceDirection::DIRECTION_IN, + FBS::Common::TraceDirection::DIRECTION_IN, FBS::Producer::TraceInfo::KeyFrameTraceInfo, traceInfo.Union()); @@ -1493,7 +1494,7 @@ namespace RTC this->shared->channelNotifier->GetBufferBuilder(), FBS::Producer::TraceEventType::RTP, DepLibUV::GetTimeMs(), - FBS::Producer::TraceDirection::DIRECTION_IN, + FBS::Common::TraceDirection::DIRECTION_IN, FBS::Producer::TraceInfo::RtpTraceInfo, traceInfo.Union()); @@ -1517,7 +1518,7 @@ namespace RTC this->shared->channelNotifier->GetBufferBuilder(), FBS::Producer::TraceEventType::PLI, DepLibUV::GetTimeMs(), - FBS::Producer::TraceDirection::DIRECTION_OUT, + FBS::Common::TraceDirection::DIRECTION_OUT, FBS::Producer::TraceInfo::PliTraceInfo, traceInfo.Union()); @@ -1540,7 +1541,7 @@ namespace RTC this->shared->channelNotifier->GetBufferBuilder(), FBS::Producer::TraceEventType::FIR, DepLibUV::GetTimeMs(), - FBS::Producer::TraceDirection::DIRECTION_OUT, + FBS::Common::TraceDirection::DIRECTION_OUT, FBS::Producer::TraceInfo::FirTraceInfo, traceInfo.Union()); @@ -1560,7 +1561,7 @@ namespace RTC this->shared->channelNotifier->GetBufferBuilder(), FBS::Producer::TraceEventType::NACK, DepLibUV::GetTimeMs(), - FBS::Producer::TraceDirection::DIRECTION_OUT); + FBS::Common::TraceDirection::DIRECTION_OUT); EmitTraceEvent(notification); } From bb2a21d89dd04d2365dc7d280327a75eb79f970b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Tue, 3 Oct 2023 13:58:34 +0200 Subject: [PATCH 33/73] FBS: RTP observers --- rust/src/fbs.rs | 34 +- rust/src/messages.rs | 415 +++++++++++++++--- rust/src/router.rs | 6 +- rust/src/router/active_speaker_observer.rs | 40 +- .../router/active_speaker_observer/tests.rs | 1 - rust/src/router/audio_level_observer.rs | 51 ++- rust/src/router/audio_level_observer/tests.rs | 1 - worker/fbs/router.fbs | 2 +- worker/src/RTC/PipeTransport.cpp | 7 +- worker/src/RTC/Router.cpp | 2 +- 10 files changed, 449 insertions(+), 110 deletions(-) diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index 25d7c15b11..1ac93f136f 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -61244,8 +61244,8 @@ mod root { ::serde::Deserialize, )] pub struct CreateActiveSpeakerObserverRequest { - /// The field `active_speaker_observer_id` in the table `CreateActiveSpeakerObserverRequest` - pub active_speaker_observer_id: ::planus::alloc::string::String, + /// 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, @@ -61262,15 +61262,14 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_active_speaker_observer_id: impl ::planus::WriteAs<::planus::Offset>, + 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_active_speaker_observer_id = - field_active_speaker_observer_id.prepare(builder); + 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> = @@ -61282,7 +61281,7 @@ mod root { unsafe { table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_active_speaker_observer_id); + object_writer.write::<_, _, 4>(&prepared_rtp_observer_id); object_writer.write::<_, _, 4>(&prepared_options); }); } @@ -61329,7 +61328,7 @@ mod root { ) -> ::planus::Offset { CreateActiveSpeakerObserverRequest::create( builder, - &self.active_speaker_observer_id, + &self.rtp_observer_id, &self.options, ) } @@ -61343,10 +61342,10 @@ mod root { pub struct CreateActiveSpeakerObserverRequestBuilder(State); impl CreateActiveSpeakerObserverRequestBuilder<()> { - /// Setter for the [`active_speaker_observer_id` field](CreateActiveSpeakerObserverRequest#structfield.active_speaker_observer_id). + /// Setter for the [`rtp_observer_id` field](CreateActiveSpeakerObserverRequest#structfield.rtp_observer_id). #[inline] #[allow(clippy::type_complexity)] - pub fn active_speaker_observer_id( + pub fn rtp_observer_id( self, value: T0, ) -> CreateActiveSpeakerObserverRequestBuilder<(T0,)> @@ -61461,15 +61460,13 @@ mod root { pub struct CreateActiveSpeakerObserverRequestRef<'a>(::planus::table_reader::Table<'a>); impl<'a> CreateActiveSpeakerObserverRequestRef<'a> { - /// Getter for the [`active_speaker_observer_id` field](CreateActiveSpeakerObserverRequest#structfield.active_speaker_observer_id). + /// Getter for the [`rtp_observer_id` field](CreateActiveSpeakerObserverRequest#structfield.rtp_observer_id). #[inline] - pub fn active_speaker_observer_id( - &self, - ) -> ::planus::Result<&'a ::core::primitive::str> { + pub fn rtp_observer_id(&self) -> ::planus::Result<&'a ::core::primitive::str> { self.0.access_required( 0, "CreateActiveSpeakerObserverRequest", - "active_speaker_observer_id", + "rtp_observer_id", ) } @@ -61488,10 +61485,7 @@ mod root { 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( - "active_speaker_observer_id", - &self.active_speaker_observer_id(), - ); + f.field("rtp_observer_id", &self.rtp_observer_id()); f.field("options", &self.options()); f.finish() } @@ -61507,8 +61501,8 @@ mod root { value: CreateActiveSpeakerObserverRequestRef<'a>, ) -> ::planus::Result { ::core::result::Result::Ok(Self { - active_speaker_observer_id: ::core::convert::TryInto::try_into( - value.active_speaker_observer_id()?, + 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()?)?, diff --git a/rust/src/messages.rs b/rust/src/messages.rs index 15f8262485..6001bbf715 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -11,8 +11,9 @@ use crate::data_structures::{ }; use crate::direct_transport::DirectTransportOptions; use crate::fbs::{ - consumer, direct_transport, message, pipe_transport, plain_transport, producer, request, - response, router, transport, web_rtc_transport, worker, + active_speaker_observer, audio_level_observer, consumer, direct_transport, message, + pipe_transport, plain_transport, producer, request, response, router, rtp_observer, transport, + web_rtc_transport, worker, }; use crate::ortc::RtpMapping; use crate::pipe_transport::PipeTransportOptions; @@ -1150,23 +1151,98 @@ impl RouterCreatePipeTransportData { is_data_channel: false, } } + + pub(crate) fn to_fbs(&self) -> pipe_transport::PipeTransportOptions { + pipe_transport::PipeTransportOptions { + base: Box::new(transport::Options { + direct: false, + max_message_size: None, + initial_available_outgoing_bitrate: None, + enable_sctp: self.enable_sctp, + num_sctp_streams: Some(Box::new(self.num_sctp_streams.to_fbs())), + max_sctp_message_size: self.max_sctp_message_size, + sctp_send_buffer_size: self.sctp_send_buffer_size, + is_data_channel: self.is_data_channel, + }), + listen_info: Box::new(self.listen_info.to_fbs()), + enable_rtx: self.enable_rtx, + enable_srtp: self.enable_srtp, + } + } } -request_response!( - RouterId, - "router.createPipeTransport", - RouterCreatePipeTransportRequest { - #[serde(flatten)] - data: RouterCreatePipeTransportData, - }, - PipeTransportData { - tuple: Mutex, - sctp_parameters: Option, - sctp_state: Mutex>, - rtx: bool, - srtp_parameters: Mutex>, - }, -); +#[derive(Debug)] +pub(crate) struct RouterCreatePipeTransportRequest { + pub(crate) data: RouterCreatePipeTransportData, +} + +impl RequestFbs for RouterCreatePipeTransportRequest { + const METHOD: request::Method = request::Method::RouterCreatePipetransport; + type HandlerId = RouterId; + type Response = PipeTransportData; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = router::CreatePipeTransportRequest::create( + &mut builder, + self.data.transport_id.to_string(), + self.data.to_fbs(), + ); + let request_body = + request::Body::create_router_create_pipe_transport_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::PipeTransportDumpResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(PipeTransportData { + tuple: Mutex::new(TransportTuple::from_fbs(data.tuple.as_ref())), + sctp_parameters: data + .base + .sctp_parameters + .map(|parameters| SctpParameters::from_fbs(parameters.as_ref())), + sctp_state: Mutex::new( + data.base + .sctp_state + .map(|state| SctpState::from_fbs(&state)), + ), + rtx: data.rtx, + srtp_parameters: Mutex::new( + data.srtp_parameters + .map(|parameters| SrtpParameters::from_fbs(parameters.as_ref())), + ), + }) + } +} + +pub(crate) struct PipeTransportData { + pub(crate) tuple: Mutex, + pub(crate) sctp_parameters: Option, + pub(crate) sctp_state: Mutex>, + pub(crate) rtx: bool, + pub(crate) srtp_parameters: Mutex>, +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct RouterCreateAudioLevelObserverRequest { + pub(crate) data: RouterCreateAudioLevelObserverData, +} #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] @@ -1191,14 +1267,53 @@ impl RouterCreateAudioLevelObserverData { } } -request_response!( - RouterId, - "router.createAudioLevelObserver", - RouterCreateAudioLevelObserverRequest { - #[serde(flatten)] - data: RouterCreateAudioLevelObserverData, - }, -); +impl RequestFbs for RouterCreateAudioLevelObserverRequest { + const METHOD: request::Method = request::Method::RouterCreateAudiolevelobserver; + type HandlerId = RouterId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let options = audio_level_observer::AudioLevelObserverOptions::create( + &mut builder, + u16::from(self.data.max_entries), + self.data.threshold, + self.data.interval, + ); + let data = router::CreateAudioLevelObserverRequest::create( + &mut builder, + self.data.rtp_observer_id.to_string(), + options, + ); + let request_body = + request::Body::create_router_create_audio_level_observer_request(&mut builder, data); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct RouterCreateActiveSpeakerObserverRequest { + pub(crate) data: RouterCreateActiveSpeakerObserverData, +} #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] @@ -1219,14 +1334,45 @@ impl RouterCreateActiveSpeakerObserverData { } } -request_response!( - RouterId, - "router.createActiveSpeakerObserver", - RouterCreateActiveSpeakerObserverRequest { - #[serde(flatten)] - data: RouterCreateActiveSpeakerObserverData, - }, -); +impl RequestFbs for RouterCreateActiveSpeakerObserverRequest { + const METHOD: request::Method = request::Method::RouterCreateActivespeakerobserver; + type HandlerId = RouterId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let options = active_speaker_observer::ActiveSpeakerObserverOptions::create( + &mut builder, + self.data.interval, + ); + let data = router::CreateActiveSpeakerObserverRequest::create( + &mut builder, + self.data.rtp_observer_id.to_string(), + options, + ); + let request_body = + request::Body::create_router_create_active_speaker_observer_request(&mut builder, data); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} #[derive(Debug)] pub(crate) struct TransportDumpRequest {} @@ -2577,40 +2723,177 @@ impl From for u32 { } } -request_response!( - RouterId, - "router.closeRtpObserver", - RtpObserverCloseRequest { - rtp_observer_id: RtpObserverId, - }, - (), - Some(()), -); +#[derive(Debug)] +pub(crate) struct RtpObserverCloseRequest { + pub(crate) rtp_observer_id: RtpObserverId, +} -request_response!( - RtpObserverId, - "rtpObserver.pause", - RtpObserverPauseRequest {}, -); +impl RequestFbs for RtpObserverCloseRequest { + const METHOD: request::Method = request::Method::RouterCloseRtpobserver; + type HandlerId = RouterId; + type Response = (); -request_response!( - RtpObserverId, - "rtpObserver.resume", - RtpObserverResumeRequest {}, -); + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = + router::CloseRtpObserverRequest::create(&mut builder, self.rtp_observer_id.to_string()); + let request_body = + request::Body::create_router_close_rtp_observer_request(&mut builder, data); -request_response!( - RtpObserverId, - "rtpObserver.addProducer", - RtpObserverAddProducerRequest { - producer_id: ProducerId, - }, -); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); -request_response!( - RtpObserverId, - "rtpObserver.removeProducer", - RtpObserverRemoveProducerRequest { - producer_id: ProducerId, - }, -); + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug)] +pub(crate) struct RtpObserverPauseRequest {} + +impl RequestFbs for RtpObserverPauseRequest { + const METHOD: request::Method = request::Method::RtpobserverPause; + type HandlerId = RtpObserverId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug)] +pub(crate) struct RtpObserverResumeRequest {} + +impl RequestFbs for RtpObserverResumeRequest { + const METHOD: request::Method = request::Method::RtpobserverResume; + type HandlerId = RtpObserverId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct RtpObserverAddProducerRequest { + pub(crate) producer_id: ProducerId, +} + +impl RequestFbs for RtpObserverAddProducerRequest { + const METHOD: request::Method = request::Method::RtpobserverAddProducer; + type HandlerId = RtpObserverId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let data = + rtp_observer::AddProducerRequest::create(&mut builder, self.producer_id.to_string()); + let request_body = + request::Body::create_rtp_observer_add_producer_request(&mut builder, data); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug, Serialize)] +#[serde(rename_all = "camelCase")] +pub(crate) struct RtpObserverRemoveProducerRequest { + pub(crate) producer_id: ProducerId, +} + +impl RequestFbs for RtpObserverRemoveProducerRequest { + const METHOD: request::Method = request::Method::RtpobserverRemoveProducer; + type HandlerId = RtpObserverId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let data = + rtp_observer::RemoveProducerRequest::create(&mut builder, self.producer_id.to_string()); + let request_body = + request::Body::create_rtp_observer_remove_producer_request(&mut builder, data); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} diff --git a/rust/src/router.rs b/rust/src/router.rs index c4ce4abc37..65e67b40ff 100644 --- a/rust/src/router.rs +++ b/rust/src/router.rs @@ -698,7 +698,7 @@ impl Router { let data = self .inner .channel - .request( + .request_fbs( self.inner.id, RouterCreatePipeTransportRequest { data: RouterCreatePipeTransportData::from_options( @@ -829,7 +829,7 @@ impl Router { self.inner .channel - .request( + .request_fbs( self.inner.id, RouterCreateAudioLevelObserverRequest { data: RouterCreateAudioLevelObserverData::from_options( @@ -889,7 +889,7 @@ impl Router { self.inner .channel - .request( + .request_fbs( self.inner.id, RouterCreateActiveSpeakerObserverRequest { data: RouterCreateActiveSpeakerObserverData::from_options( diff --git a/rust/src/router/active_speaker_observer.rs b/rust/src/router/active_speaker_observer.rs index 5999f04526..b1676b4bd6 100644 --- a/rust/src/router/active_speaker_observer.rs +++ b/rust/src/router/active_speaker_observer.rs @@ -2,6 +2,7 @@ mod tests; use crate::data_structures::AppData; +use crate::fbs::notification; use crate::messages::{ RtpObserverAddProducerRequest, RtpObserverCloseRequest, RtpObserverPauseRequest, RtpObserverRemoveProducerRequest, RtpObserverResumeRequest, @@ -9,7 +10,7 @@ use crate::messages::{ use crate::producer::{Producer, ProducerId}; use crate::router::Router; use crate::rtp_observer::{RtpObserver, RtpObserverAddProducerOptions, RtpObserverId}; -use crate::worker::{Channel, RequestError, SubscriptionHandler}; +use crate::worker::{Channel, NotificationParseError, RequestError, SubscriptionHandler}; use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::{Bag, BagOnce, HandlerId}; @@ -74,6 +75,29 @@ enum Notification { DominantSpeaker(DominantSpeakerNotification), } +impl Notification { + pub(crate) fn from_fbs( + notification: notification::NotificationRef<'_>, + ) -> Result { + match notification.event().unwrap() { + notification::Event::ActivespeakerobserverDominantSpeaker => { + let Ok(Some( + notification::BodyRef::ActiveSpeakerObserverDominantSpeakerNotification(body), + )) = notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let dominant_speaker_notification = DominantSpeakerNotification { + producer_id: body.producer_id().unwrap().parse().unwrap(), + }; + Ok(Notification::DominantSpeaker(dominant_speaker_notification)) + } + _ => Err(NotificationParseError::InvalidEvent), + } + } +} + struct Inner { id: RtpObserverId, executor: Arc>, @@ -114,7 +138,7 @@ impl Inner { self.executor .spawn(async move { - if let Err(error) = channel.request(router_id, request).await { + if let Err(error) = channel.request_fbs(router_id, request).await { error!("active speaker observer closing failed on drop: {}", error); } }) @@ -175,7 +199,7 @@ impl RtpObserver for ActiveSpeakerObserver { self.inner .channel - .request(self.id(), RtpObserverPauseRequest {}) + .request_fbs(self.id(), RtpObserverPauseRequest {}) .await?; let was_paused = self.inner.paused.swap(true, Ordering::SeqCst); @@ -192,7 +216,7 @@ impl RtpObserver for ActiveSpeakerObserver { self.inner .channel - .request(self.id(), RtpObserverResumeRequest {}) + .request_fbs(self.id(), RtpObserverResumeRequest {}) .await?; let was_paused = self.inner.paused.swap(false, Ordering::SeqCst); @@ -216,7 +240,7 @@ impl RtpObserver for ActiveSpeakerObserver { }; self.inner .channel - .request(self.id(), RtpObserverAddProducerRequest { producer_id }) + .request_fbs(self.id(), RtpObserverAddProducerRequest { producer_id }) .await?; self.inner.handlers.add_producer.call_simple(&producer); @@ -233,7 +257,7 @@ impl RtpObserver for ActiveSpeakerObserver { }; self.inner .channel - .request(self.id(), RtpObserverRemoveProducerRequest { producer_id }) + .request_fbs(self.id(), RtpObserverRemoveProducerRequest { producer_id }) .await?; self.inner.handlers.remove_producer.call_simple(&producer); @@ -293,8 +317,8 @@ impl ActiveSpeakerObserver { let router = router.clone(); let handlers = Arc::clone(&handlers); - channel.subscribe_to_notifications(id.into(), move |notification| { - match serde_json::from_slice::(notification) { + channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::DominantSpeaker(dominant_speaker) => { let DominantSpeakerNotification { producer_id } = dominant_speaker; diff --git a/rust/src/router/active_speaker_observer/tests.rs b/rust/src/router/active_speaker_observer/tests.rs index 4eb3acb31b..2493a8f133 100644 --- a/rust/src/router/active_speaker_observer/tests.rs +++ b/rust/src/router/active_speaker_observer/tests.rs @@ -24,7 +24,6 @@ async fn init() -> Worker { } #[test] -#[ignore] fn router_close_event() { future::block_on(async move { let worker = init().await; diff --git a/rust/src/router/audio_level_observer.rs b/rust/src/router/audio_level_observer.rs index cd55b6adff..abfc09b706 100644 --- a/rust/src/router/audio_level_observer.rs +++ b/rust/src/router/audio_level_observer.rs @@ -2,6 +2,7 @@ mod tests; use crate::data_structures::AppData; +use crate::fbs::{audio_level_observer, notification}; use crate::messages::{ RtpObserverAddProducerRequest, RtpObserverCloseRequest, RtpObserverPauseRequest, RtpObserverRemoveProducerRequest, RtpObserverResumeRequest, @@ -9,7 +10,7 @@ use crate::messages::{ use crate::producer::{Producer, ProducerId}; use crate::router::Router; use crate::rtp_observer::{RtpObserver, RtpObserverAddProducerOptions, RtpObserverId}; -use crate::worker::{Channel, RequestError, SubscriptionHandler}; +use crate::worker::{Channel, NotificationParseError, RequestError, SubscriptionHandler}; use async_executor::Executor; use async_trait::async_trait; use event_listener_primitives::{Bag, BagOnce, HandlerId}; @@ -85,6 +86,40 @@ enum Notification { Silence, } +impl Notification { + pub(crate) fn from_fbs( + notification: notification::NotificationRef<'_>, + ) -> Result { + match notification.event().unwrap() { + notification::Event::AudiolevelobserverVolumes => { + let Ok(Some(notification::BodyRef::AudioLevelObserverVolumesNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + let volumes_fbs: Vec<_> = body + .volumes() + .unwrap() + .iter() + .map(|volume| audio_level_observer::Volume::try_from(volume.unwrap()).unwrap()) + .collect(); + let volumes = volumes_fbs + .iter() + .map(|volume| VolumeNotification { + producer_id: volume.producer_id.parse().unwrap(), + volume: volume.volume, + }) + .collect(); + + Ok(Notification::Volumes(volumes)) + } + notification::Event::AudiolevelobserverSilence => Ok(Notification::Silence), + _ => Err(NotificationParseError::InvalidEvent), + } + } +} + struct Inner { id: RtpObserverId, executor: Arc>, @@ -125,7 +160,7 @@ impl Inner { self.executor .spawn(async move { - if let Err(error) = channel.request(router_id, request).await { + if let Err(error) = channel.request_fbs(router_id, request).await { error!("audio level observer closing failed on drop: {}", error); } }) @@ -186,7 +221,7 @@ impl RtpObserver for AudioLevelObserver { self.inner .channel - .request(self.id(), RtpObserverPauseRequest {}) + .request_fbs(self.id(), RtpObserverPauseRequest {}) .await?; let was_paused = self.inner.paused.swap(true, Ordering::SeqCst); @@ -203,7 +238,7 @@ impl RtpObserver for AudioLevelObserver { self.inner .channel - .request(self.id(), RtpObserverResumeRequest {}) + .request_fbs(self.id(), RtpObserverResumeRequest {}) .await?; let was_paused = self.inner.paused.swap(false, Ordering::SeqCst); @@ -227,7 +262,7 @@ impl RtpObserver for AudioLevelObserver { }; self.inner .channel - .request(self.id(), RtpObserverAddProducerRequest { producer_id }) + .request_fbs(self.id(), RtpObserverAddProducerRequest { producer_id }) .await?; self.inner.handlers.add_producer.call_simple(&producer); @@ -244,7 +279,7 @@ impl RtpObserver for AudioLevelObserver { }; self.inner .channel - .request(self.id(), RtpObserverRemoveProducerRequest { producer_id }) + .request_fbs(self.id(), RtpObserverRemoveProducerRequest { producer_id }) .await?; self.inner.handlers.remove_producer.call_simple(&producer); @@ -304,8 +339,8 @@ impl AudioLevelObserver { let router = router.clone(); let handlers = Arc::clone(&handlers); - channel.subscribe_to_notifications(id.into(), move |notification| { - match serde_json::from_slice::(notification) { + channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::Volumes(volumes) => { let volumes = volumes diff --git a/rust/src/router/audio_level_observer/tests.rs b/rust/src/router/audio_level_observer/tests.rs index a7ba2a0db0..f2f3465e55 100644 --- a/rust/src/router/audio_level_observer/tests.rs +++ b/rust/src/router/audio_level_observer/tests.rs @@ -24,7 +24,6 @@ async fn init() -> Worker { } #[test] -#[ignore] fn router_close_event() { future::block_on(async move { let worker = init().await; diff --git a/worker/fbs/router.fbs b/worker/fbs/router.fbs index d2f95b1376..6c0a34b256 100644 --- a/worker/fbs/router.fbs +++ b/worker/fbs/router.fbs @@ -46,7 +46,7 @@ table CreateAudioLevelObserverRequest { } table CreateActiveSpeakerObserverRequest { - active_speaker_observer_id: string (required); + rtp_observer_id: string (required); options: FBS.ActiveSpeakerObserver.ActiveSpeakerObserverOptions (required); } diff --git a/worker/src/RTC/PipeTransport.cpp b/worker/src/RTC/PipeTransport.cpp index 22ca502d38..9c42fd9e33 100644 --- a/worker/src/RTC/PipeTransport.cpp +++ b/worker/src/RTC/PipeTransport.cpp @@ -168,7 +168,12 @@ namespace RTC } tuple = FBS::Transport::CreateTupleDirect( - builder, localIp.c_str(), this->udpSocket->GetLocalPort(), "", 0, FBS::Transport::Protocol::UDP); + builder, + localIp.c_str(), + this->udpSocket->GetLocalPort(), + nullptr, + 0, + FBS::Transport::Protocol::UDP); } // Add srtpParameters. diff --git a/worker/src/RTC/Router.cpp b/worker/src/RTC/Router.cpp index ca6ccd9ae4..f7b6e2b1ac 100644 --- a/worker/src/RTC/Router.cpp +++ b/worker/src/RTC/Router.cpp @@ -339,7 +339,7 @@ namespace RTC case Channel::ChannelRequest::Method::ROUTER_CREATE_ACTIVESPEAKEROBSERVER: { const auto* body = request->data->body_as(); - auto rtpObserverId = body->activeSpeakerObserverId()->str(); + auto rtpObserverId = body->rtpObserverId()->str(); // This may throw. CheckNoRtpObserver(rtpObserverId); From f878c635a4611ba062bcd829700ee443539dd683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Mon, 9 Oct 2023 10:05:24 +0200 Subject: [PATCH 34/73] FBS: DataProducer, DataConsumer (#1169) --- node/src/Consumer.ts | 4 +- node/src/DataConsumer.ts | 39 +- node/src/DataProducer.ts | 26 +- node/src/Producer.ts | 2 +- node/src/RtpParameters.ts | 2 +- node/src/SrtpParameters.ts | 2 +- node/src/Transport.ts | 21 +- node/src/WebRtcTransport.ts | 4 +- rust/src/data_structures.rs | 3 - rust/src/fbs.rs | 4599 +++++++++++--------- rust/src/messages.rs | 1064 +++-- rust/src/router/data_consumer.rs | 154 +- rust/src/router/data_producer.rs | 77 +- rust/src/router/direct_transport.rs | 4 +- rust/src/router/producer.rs | 4 +- rust/src/router/transport.rs | 4 +- rust/src/rtp_parameters.rs | 8 - rust/src/sctp_parameters.rs | 20 + rust/src/worker/channel.rs | 241 +- rust/src/worker/common.rs | 88 - rust/tests/integration/data_consumer.rs | 8 - rust/tests/integration/data_producer.rs | 8 - rust/tests/integration/direct_transport.rs | 11 +- worker/fbs/dataConsumer.fbs | 10 +- worker/fbs/dataProducer.fbs | 9 +- worker/fbs/directTransport.fbs | 2 +- worker/fbs/transport.fbs | 5 +- worker/include/RTC/DataConsumer.hpp | 1 - worker/include/RTC/DataProducer.hpp | 1 - worker/src/RTC/DataConsumer.cpp | 36 +- worker/src/RTC/DataProducer.cpp | 28 +- 31 files changed, 3547 insertions(+), 2938 deletions(-) diff --git a/node/src/Consumer.ts b/node/src/Consumer.ts index a0ba5662ee..0a9d60d832 100644 --- a/node/src/Consumer.ts +++ b/node/src/Consumer.ts @@ -1012,7 +1012,7 @@ function consumerTraceEventTypeToFbs(eventType: ConsumerTraceEventType) case 'rtp': return FbsConsumer.TraceEventType.RTP; default: - throw new TypeError(`invalid eventType: ${eventType}`); + throw new TypeError(`invalid ConsumerTraceEventType: ${eventType}`); } } @@ -1032,7 +1032,7 @@ function consumerTraceEventTypeFromFbs(traceType: FbsConsumer.TraceEventType) case FbsConsumer.TraceEventType.RTP: return 'rtp'; default: - throw new TypeError(`invalid TraceType: ${traceType}`); + throw new TypeError(`invalid FbsConsumer.TraceEventType: ${traceType}`); } } diff --git a/node/src/DataConsumer.ts b/node/src/DataConsumer.ts index c5d27c759d..41c12e06d2 100644 --- a/node/src/DataConsumer.ts +++ b/node/src/DataConsumer.ts @@ -8,6 +8,7 @@ import { Event, Notification } from './fbs/notification'; import * as FbsTransport from './fbs/transport'; import * as FbsRequest from './fbs/request'; import * as FbsDataConsumer from './fbs/data-consumer'; +import * as FbsDataProducer from './fbs/data-producer'; import * as utils from './utils'; export type DataConsumerOptions = @@ -116,6 +117,7 @@ type DataConsumerData = sctpStreamParameters?: SctpStreamParameters; label: string; protocol: string; + bufferedAmountLowThreshold: number; }; const logger = new Logger('DataConsumer'); @@ -712,6 +714,30 @@ export class DataConsumer } } +export function dataConsumerTypeToFbs(type: DataConsumerType): FbsDataProducer.Type +{ + switch (type) + { + case 'sctp': + return FbsDataProducer.Type.SCTP; + case 'direct': + return FbsDataProducer.Type.DIRECT; + default: + throw new TypeError('invalid DataConsumerType: ${type}'); + } +} + +export function dataConsumerTypeFromFbs(type: FbsDataProducer.Type): DataConsumerType +{ + switch (type) + { + case FbsDataProducer.Type.SCTP: + return 'sctp'; + case FbsDataProducer.Type.DIRECT: + return 'direct'; + } +} + export function parseDataConsumerDumpResponse( data: FbsDataConsumer.DumpResponse ): DataConsumerDump @@ -719,15 +745,16 @@ export function parseDataConsumerDumpResponse( return { id : data.id()!, dataProducerId : data.dataProducerId()!, - type : data.type()! as DataConsumerType, + type : dataConsumerTypeFromFbs(data.type()), sctpStreamParameters : data.sctpStreamParameters() !== null ? parseSctpStreamParameters(data.sctpStreamParameters()!) : undefined, - label : data.label()!, - protocol : data.protocol()!, - paused : data.paused(), - dataProducerPaused : data.dataProducerPaused(), - subchannels : utils.parseVector(data, 'subchannels') + label : data.label()!, + protocol : data.protocol()!, + bufferedAmountLowThreshold : data.bufferedAmountLowThreshold(), + paused : data.paused(), + dataProducerPaused : data.dataProducerPaused(), + subchannels : utils.parseVector(data, 'subchannels') }; } diff --git a/node/src/DataProducer.ts b/node/src/DataProducer.ts index 0e268ac9bb..9a3544bd53 100644 --- a/node/src/DataProducer.ts +++ b/node/src/DataProducer.ts @@ -478,13 +478,37 @@ export class DataProducer } } +export function dataProducerTypeToFbs(type: DataProducerType): FbsDataProducer.Type +{ + switch (type) + { + case 'sctp': + return FbsDataProducer.Type.SCTP; + case 'direct': + return FbsDataProducer.Type.DIRECT; + default: + throw new TypeError('invalid DataConsumerType: ${type}'); + } +} + +export function dataProducerTypeFromFbs(type: FbsDataProducer.Type): DataProducerType +{ + switch (type) + { + case FbsDataProducer.Type.SCTP: + return 'sctp'; + case FbsDataProducer.Type.DIRECT: + return 'direct'; + } +} + export function parseDataProducerDumpResponse( data: FbsDataProducer.DumpResponse ): DataProducerDump { return { id : data.id()!, - type : data.type()! as DataProducerType, + type : dataProducerTypeFromFbs(data.type()), sctpStreamParameters : data.sctpStreamParameters() !== null ? parseSctpStreamParameters(data.sctpStreamParameters()!) : undefined, diff --git a/node/src/Producer.ts b/node/src/Producer.ts index 1e49c01931..d145bcf156 100644 --- a/node/src/Producer.ts +++ b/node/src/Producer.ts @@ -665,7 +665,7 @@ function producerTraceEventTypeToFbs(eventType: ProducerTraceEventType) case 'rtp': return FbsProducer.TraceEventType.RTP; default: - throw new TypeError(`invalid eventType: ${eventType}`); + throw new TypeError(`invalid ProducerTraceEventType: ${eventType}`); } } diff --git a/node/src/RtpParameters.ts b/node/src/RtpParameters.ts index 8791a7d39a..532fb014b2 100644 --- a/node/src/RtpParameters.ts +++ b/node/src/RtpParameters.ts @@ -781,7 +781,7 @@ export function rtpHeaderExtensionUriToFbs(uri: RtpHeaderExtensionUri): FbsRtpHe case 'http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time': return FbsRtpHeaderExtensionUri.AbsCaptureTime; default: - throw new TypeError(`invalid RTP header extension URI: ${uri}`); + throw new TypeError(`invalid RtpHeaderExtensionUri: ${uri}`); } } diff --git a/node/src/SrtpParameters.ts b/node/src/SrtpParameters.ts index 8049964512..7c5937c05e 100644 --- a/node/src/SrtpParameters.ts +++ b/node/src/SrtpParameters.ts @@ -62,7 +62,7 @@ export function cryptoSuiteToFbs(cryptoSuite: SrtpCryptoSuite) return FbsSrtpParameters.SrtpCryptoSuite.AES_CM_128_HMAC_SHA1_32; default: - throw new TypeError(`invalid srtp crypto suite: ${cryptoSuite}`); + throw new TypeError(`invalid SrtpCryptoSuite: ${cryptoSuite}`); } } diff --git a/node/src/Transport.ts b/node/src/Transport.ts index 51c704a07a..0526df7b88 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -16,12 +16,14 @@ import { DataProducer, DataProducerOptions, DataProducerType, + dataProducerTypeToFbs, parseDataProducerDumpResponse } from './DataProducer'; import { DataConsumer, DataConsumerOptions, DataConsumerType, + dataConsumerTypeToFbs, parseDataConsumerDumpResponse } from './DataConsumer'; import { @@ -1193,11 +1195,12 @@ export class Transport }, data : { - dataProducerId : dump.dataProducerId, - type : dump.type, - sctpStreamParameters : dump.sctpStreamParameters, - label : dump.label, - protocol : dump.protocol + dataProducerId : dump.dataProducerId, + type : dump.type, + sctpStreamParameters : dump.sctpStreamParameters, + label : dump.label, + protocol : dump.protocol, + bufferedAmountLowThreshold : dump.bufferedAmountLowThreshold }, channel : this.channel, paused : dump.paused, @@ -1321,7 +1324,7 @@ function transportTraceEventTypeToFbs(eventType: TransportTraceEventType) case 'bwe': return FbsTransport.TraceEventType.BWE; default: - throw new TypeError(`invalid transport event type: ${eventType}`); + throw new TypeError(`invalid TransportTraceEventType: ${eventType}`); } } @@ -1687,7 +1690,6 @@ function createProduceDataRequest({ }): number { const dataProducerIdOffset = builder.createString(dataProducerId); - const typeOffset = builder.createString(type); const labelOffset = builder.createString(label); const protocolOffset = builder.createString(protocol); @@ -1702,7 +1704,7 @@ function createProduceDataRequest({ FbsTransport.ProduceDataRequest.startProduceDataRequest(builder); FbsTransport.ProduceDataRequest.addDataProducerId(builder, dataProducerIdOffset); - FbsTransport.ProduceDataRequest.addType(builder, typeOffset); + FbsTransport.ProduceDataRequest.addType(builder, dataProducerTypeToFbs(type)); if (sctpStreamParametersOffset) { @@ -1742,7 +1744,6 @@ function createConsumeDataRequest({ { const dataConsumerIdOffset = builder.createString(dataConsumerId); const dataProducerIdOffset = builder.createString(dataProducerId); - const typeOffset = builder.createString(type); const labelOffset = builder.createString(label); const protocolOffset = builder.createString(protocol); @@ -1762,7 +1763,7 @@ function createConsumeDataRequest({ FbsTransport.ConsumeDataRequest.startConsumeDataRequest(builder); FbsTransport.ConsumeDataRequest.addDataConsumerId(builder, dataConsumerIdOffset); FbsTransport.ConsumeDataRequest.addDataProducerId(builder, dataProducerIdOffset); - FbsTransport.ConsumeDataRequest.addType(builder, typeOffset); + FbsTransport.ConsumeDataRequest.addType(builder, dataConsumerTypeToFbs(type)); if (sctpStreamParametersOffset) { diff --git a/node/src/WebRtcTransport.ts b/node/src/WebRtcTransport.ts index 719e657026..c78d6d4107 100644 --- a/node/src/WebRtcTransport.ts +++ b/node/src/WebRtcTransport.ts @@ -757,7 +757,7 @@ function fingerprintAlgorithmToFbs(algorithm: FingerprintAlgorithm) case 'sha-512': return FbsFingerprintAlgorithm.SHA512; default: - throw new TypeError(`invalid fingerprint algorithm: ${algorithm}`); + throw new TypeError(`invalid FingerprintAlgorithm: ${algorithm}`); } } @@ -772,7 +772,7 @@ function dtlsRoleToFbs(role: DtlsRole): FbsDtlsRole case 'server': return FbsDtlsRole.SERVER; default: - throw new TypeError(`invalid dtls role: ${role}`); + throw new TypeError(`invalid DtlsRole: ${role}`); } } diff --git a/rust/src/data_structures.rs b/rust/src/data_structures.rs index 7f0ff55af1..0b4a698f38 100644 --- a/rust/src/data_structures.rs +++ b/rust/src/data_structures.rs @@ -1068,8 +1068,6 @@ impl<'a> WebRtcMessage<'a> { // | WebRTC Binary Empty | 57 | // +------------------------------------+-----------+ - /* - * TODO. pub(crate) fn new(ppid: u32, payload: Cow<'a, [u8]>) -> Result { match ppid { 51 => Ok(WebRtcMessage::String( @@ -1081,7 +1079,6 @@ impl<'a> WebRtcMessage<'a> { ppid => Err(ppid), } } - */ pub(crate) fn into_ppid_and_payload(self) -> (u32, Cow<'a, [u8]>) { match self { diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index 1ac93f136f..23d5031f30 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -22461,7 +22461,7 @@ mod root { /// The table `GetBufferedAmountResponse` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `GetBufferedAmountResponse` in the file `../worker/fbs/dataConsumer.fbs:6` + /// * Table `GetBufferedAmountResponse` in the file `../worker/fbs/dataConsumer.fbs:7` #[derive( Clone, Debug, @@ -22761,7 +22761,7 @@ mod root { /// The table `SetBufferedAmountLowThresholdRequest` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `SetBufferedAmountLowThresholdRequest` in the file `../worker/fbs/dataConsumer.fbs:10` + /// * Table `SetBufferedAmountLowThresholdRequest` in the file `../worker/fbs/dataConsumer.fbs:11` #[derive( Clone, Debug, @@ -23070,7 +23070,7 @@ mod root { /// The table `DumpResponse` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/dataConsumer.fbs:14` + /// * Table `DumpResponse` in the file `../worker/fbs/dataConsumer.fbs:15` #[derive( Clone, Debug, @@ -23088,7 +23088,7 @@ mod root { /// 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_: ::planus::alloc::string::String, + 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, @@ -23097,12 +23097,14 @@ mod root { 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: ::core::option::Option<::planus::alloc::vec::Vec>, + pub subchannels: ::planus::alloc::vec::Vec, } impl DumpResponse { @@ -23117,53 +23119,62 @@ mod root { builder: &mut ::planus::Builder, field_id: impl ::planus::WriteAs<::planus::Offset>, field_data_producer_id: impl ::planus::WriteAs<::planus::Offset>, - field_type_: 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::WriteAsOptional<::planus::Offset<[u16]>>, + 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); + 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<22> = + 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); - table_writer.write_entry::<::planus::Offset>(2); 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_subchannels.is_some() { - table_writer.write_entry::<::planus::Offset<[u16]>>(8); + 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::(6); + table_writer.write_entry::(7); } if prepared_data_producer_paused.is_some() { - table_writer.write_entry::(7); + 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); - object_writer.write::<_, _, 4>(&prepared_type_); if let ::core::option::Option::Some(prepared_sctp_stream_parameters) = prepared_sctp_stream_parameters { @@ -23171,10 +23182,16 @@ mod root { } object_writer.write::<_, _, 4>(&prepared_label); object_writer.write::<_, _, 4>(&prepared_protocol); - if let ::core::option::Option::Some(prepared_subchannels) = - prepared_subchannels + if let ::core::option::Option::Some( + prepared_buffered_amount_low_threshold, + ) = prepared_buffered_amount_low_threshold { - object_writer.write::<_, _, 4>(&prepared_subchannels); + 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); @@ -23224,10 +23241,11 @@ mod root { builder, &self.id, &self.data_producer_id, - &self.type_, + self.type_, &self.sctp_stream_parameters, &self.label, &self.protocol, + self.buffered_amount_low_threshold, self.paused, self.data_producer_paused, &self.subchannels, @@ -23273,11 +23291,23 @@ mod root { #[allow(clippy::type_complexity)] pub fn type_(self, value: T2) -> DumpResponseBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAs<::planus::Offset>, + 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)> { @@ -23337,36 +23367,36 @@ mod root { } impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Setter for the [`paused` field](DumpResponse#structfield.paused). + /// Setter for the [`buffered_amount_low_threshold` field](DumpResponse#structfield.buffered_amount_low_threshold). #[inline] #[allow(clippy::type_complexity)] - pub fn paused( + pub fn buffered_amount_low_threshold( self, value: T6, ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> where - T6: ::planus::WriteAsDefault, + T6: ::planus::WriteAsDefault, { let (v0, v1, v2, v3, v4, v5) = self.0; DumpResponseBuilder((v0, v1, v2, v3, v4, v5, value)) } - /// Sets the [`paused` field](DumpResponse#structfield.paused) to the default 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 paused_as_default( + pub fn buffered_amount_low_threshold_as_default( self, ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, ::planus::DefaultValue)> { - self.paused(::planus::DefaultValue) + self.buffered_amount_low_threshold(::planus::DefaultValue) } } impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6)> { - /// Setter for the [`data_producer_paused` field](DumpResponse#structfield.data_producer_paused). + /// Setter for the [`paused` field](DumpResponse#structfield.paused). #[inline] #[allow(clippy::type_complexity)] - pub fn data_producer_paused( + pub fn paused( self, value: T7, ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> @@ -23377,43 +23407,62 @@ mod root { DumpResponseBuilder((v0, v1, v2, v3, v4, v5, v6, value)) } - /// Sets the [`data_producer_paused` field](DumpResponse#structfield.data_producer_paused) to the default value. + /// Sets the [`paused` field](DumpResponse#structfield.paused) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn data_producer_paused_as_default( + pub fn paused_as_default( self, ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, ::planus::DefaultValue)> { - self.data_producer_paused(::planus::DefaultValue) + self.paused(::planus::DefaultValue) } } impl DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7)> { - /// Setter for the [`subchannels` field](DumpResponse#structfield.subchannels). + /// Setter for the [`data_producer_paused` field](DumpResponse#structfield.data_producer_paused). #[inline] #[allow(clippy::type_complexity)] - pub fn subchannels( + pub fn data_producer_paused( self, value: T8, ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> where - T8: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, + 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 [`subchannels` field](DumpResponse#structfield.subchannels) to null. + /// Sets the [`data_producer_paused` field](DumpResponse#structfield.data_producer_paused) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn subchannels_as_null( + pub fn data_producer_paused_as_default( self, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, ())> { - self.subchannels(()) + ) -> 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( @@ -23430,17 +23479,21 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs<::planus::Offset>, - T2: ::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, + T6: ::planus::WriteAsDefault, T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, + T8: ::planus::WriteAsDefault, + T9: ::planus::WriteAs<::planus::Offset<[u16]>>, > ::planus::WriteAs<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> + for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> { type Prepared = ::planus::Offset; @@ -23456,17 +23509,21 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs<::planus::Offset>, - T2: ::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, + T6: ::planus::WriteAsDefault, T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, + T8: ::planus::WriteAsDefault, + T9: ::planus::WriteAs<::planus::Offset<[u16]>>, > ::planus::WriteAsOptional<::planus::Offset> - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> + for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)> { type Prepared = ::planus::Offset; @@ -23482,25 +23539,29 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs<::planus::Offset>, - T2: ::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, + T6: ::planus::WriteAsDefault, T7: ::planus::WriteAsDefault, - T8: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, + T8: ::planus::WriteAsDefault, + T9: ::planus::WriteAs<::planus::Offset<[u16]>>, > ::planus::WriteAsOffset - for DumpResponseBuilder<(T0, T1, T2, T3, T4, T5, T6, T7, T8)> + 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) = &self.0; - DumpResponse::create(builder, v0, v1, v2, v3, v4, v5, v6, v7, v8) + 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) } } @@ -23524,8 +23585,12 @@ mod root { /// Getter for the [`type` field](DumpResponse#structfield.type_). #[inline] - pub fn type_(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(2, "DumpResponse", "type_") + 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). @@ -23550,11 +23615,21 @@ mod root { 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(6, "DumpResponse", "paused")?.unwrap_or(false), + self.0.access(7, "DumpResponse", "paused")?.unwrap_or(false), ) } @@ -23563,18 +23638,15 @@ mod root { pub fn data_producer_paused(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 - .access(7, "DumpResponse", "data_producer_paused")? + .access(8, "DumpResponse", "data_producer_paused")? .unwrap_or(false), ) } /// Getter for the [`subchannels` field](DumpResponse#structfield.subchannels). #[inline] - pub fn subchannels( - &self, - ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, u16>>> - { - self.0.access(8, "DumpResponse", "subchannels") + pub fn subchannels(&self) -> ::planus::Result<::planus::Vector<'a, u16>> { + self.0.access_required(9, "DumpResponse", "subchannels") } } @@ -23591,13 +23663,13 @@ mod root { } 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()); - if let ::core::option::Option::Some(field_subchannels) = - self.subchannels().transpose() - { - f.field("subchannels", &field_subchannels); - } + f.field("subchannels", &self.subchannels()); f.finish() } } @@ -23625,17 +23697,14 @@ mod root { }, 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: if let ::core::option::Option::Some(subchannels) = - value.subchannels()? - { - ::core::option::Option::Some(subchannels.to_vec()?) - } else { - ::core::option::Option::None - }, + subchannels: value.subchannels()?.to_vec()?, }) } } @@ -23713,7 +23782,7 @@ mod root { /// The table `GetStatsResponse` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/dataConsumer.fbs:26` + /// * Table `GetStatsResponse` in the file `../worker/fbs/dataConsumer.fbs:28` #[derive( Clone, Debug, @@ -24222,7 +24291,7 @@ mod root { /// The table `String` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `String` in the file `../worker/fbs/dataConsumer.fbs:35` + /// * Table `String` in the file `../worker/fbs/dataConsumer.fbs:37` #[derive( Clone, Debug, @@ -24463,7 +24532,7 @@ mod root { /// The table `Binary` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `Binary` in the file `../worker/fbs/dataConsumer.fbs:39` + /// * Table `Binary` in the file `../worker/fbs/dataConsumer.fbs:41` #[derive( Clone, Debug, @@ -24704,7 +24773,7 @@ mod root { /// The union `Data` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Union `Data` in the file `../worker/fbs/dataConsumer.fbs:43` + /// * Union `Data` in the file `../worker/fbs/dataConsumer.fbs:45` #[derive( Clone, Debug, @@ -24897,7 +24966,7 @@ mod root { /// The table `SendRequest` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `SendRequest` in the file `../worker/fbs/dataConsumer.fbs:48` + /// * Table `SendRequest` in the file `../worker/fbs/dataConsumer.fbs:50` #[derive( Clone, Debug, @@ -24911,7 +24980,7 @@ mod root { )] pub struct SendRequest { /// The field `ppid` in the table `SendRequest` - pub ppid: u8, + pub ppid: u32, /// The field `data` in the table `SendRequest` pub data: self::Data, } @@ -24926,7 +24995,7 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_ppid: impl ::planus::WriteAsDefault, + field_ppid: impl ::planus::WriteAsDefault, field_data: impl ::planus::WriteAsUnion, ) -> ::planus::Offset { let prepared_ppid = field_ppid.prepare(builder, &0); @@ -24934,18 +25003,18 @@ mod root { let mut table_writer: ::planus::table_writer::TableWriter<10> = ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(2); if prepared_ppid.is_some() { - table_writer.write_entry::(0); + table_writer.write_entry::(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_data.offset()); if let ::core::option::Option::Some(prepared_ppid) = prepared_ppid { - object_writer.write::<_, _, 1>(&prepared_ppid); + object_writer.write::<_, _, 4>(&prepared_ppid); } + object_writer.write::<_, _, 4>(&prepared_data.offset()); object_writer.write::<_, _, 1>(&prepared_data.tag()); }); } @@ -25000,7 +25069,7 @@ mod root { #[allow(clippy::type_complexity)] pub fn ppid(self, value: T0) -> SendRequestBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, { SendRequestBuilder((value,)) } @@ -25040,8 +25109,11 @@ mod root { } } - impl, T1: ::planus::WriteAsUnion> - ::planus::WriteAs<::planus::Offset> for SendRequestBuilder<(T0, T1)> + impl< + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsUnion, + > ::planus::WriteAs<::planus::Offset> + for SendRequestBuilder<(T0, T1)> { type Prepared = ::planus::Offset; @@ -25054,8 +25126,10 @@ mod root { } } - impl, T1: ::planus::WriteAsUnion> - ::planus::WriteAsOptional<::planus::Offset> + impl< + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsUnion, + > ::planus::WriteAsOptional<::planus::Offset> for SendRequestBuilder<(T0, T1)> { type Prepared = ::planus::Offset; @@ -25069,8 +25143,10 @@ mod root { } } - impl, T1: ::planus::WriteAsUnion> - ::planus::WriteAsOffset for SendRequestBuilder<(T0, T1)> + impl< + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsUnion, + > ::planus::WriteAsOffset for SendRequestBuilder<(T0, T1)> { #[inline] fn prepare( @@ -25089,7 +25165,7 @@ mod root { impl<'a> SendRequestRef<'a> { /// Getter for the [`ppid` field](SendRequest#structfield.ppid). #[inline] - pub fn ppid(&self) -> ::planus::Result { + pub fn ppid(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0.access(0, "SendRequest", "ppid")?.unwrap_or(0), ) @@ -25196,7 +25272,7 @@ mod root { /// The table `SetSubchannelsRequest` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `SetSubchannelsRequest` in the file `../worker/fbs/dataConsumer.fbs:53` + /// * Table `SetSubchannelsRequest` in the file `../worker/fbs/dataConsumer.fbs:55` #[derive( Clone, Debug, @@ -25496,7 +25572,7 @@ mod root { /// The table `SetSubchannelsResponse` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `SetSubchannelsResponse` in the file `../worker/fbs/dataConsumer.fbs:57` + /// * Table `SetSubchannelsResponse` in the file `../worker/fbs/dataConsumer.fbs:59` #[derive( Clone, Debug, @@ -25798,7 +25874,7 @@ mod root { /// The table `BufferedAmountLowNotification` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `BufferedAmountLowNotification` in the file `../worker/fbs/dataConsumer.fbs:63` + /// * Table `BufferedAmountLowNotification` in the file `../worker/fbs/dataConsumer.fbs:65` #[derive( Clone, Debug, @@ -26103,7 +26179,7 @@ mod root { /// The table `MessageNotification` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `MessageNotification` in the file `../worker/fbs/dataConsumer.fbs:67` + /// * Table `MessageNotification` in the file `../worker/fbs/dataConsumer.fbs:69` #[derive( Clone, Debug, @@ -26413,342 +26489,185 @@ mod root { } } } - /// The namespace `FBS.SctpParameters` + /// The namespace `FBS.DataProducer` /// /// Generated from these locations: - /// * File `../worker/fbs/sctpParameters.fbs` - pub mod sctp_parameters { - /// The table `NumSctpStreams` in the namespace `FBS.SctpParameters` + /// * File `../worker/fbs/dataProducer.fbs` + pub mod data_producer { + /// The enum `Type` in the namespace `FBS.DataProducer` /// /// Generated from these locations: - /// * Table `NumSctpStreams` in the file `../worker/fbs/sctpParameters.fbs:3` + /// * Enum `Type` in the file `../worker/fbs/dataProducer.fbs:5` #[derive( + Copy, Clone, Debug, PartialEq, - PartialOrd, Eq, + PartialOrd, 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, + #[repr(u8)] + pub enum Type { + /// The variant `SCTP` in the enum `Type` + Sctp = 0, + + /// The variant `DIRECT` in the enum `Type` + Direct = 1, } - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for NumSctpStreams { - fn default() -> Self { - Self { - os: 1024, - mis: 1024, - } - } + impl Type { + /// Array containing all valid variants of Type + pub const ENUM_VALUES: [Self; 2] = [Self::Sctp, Self::Direct]; } - impl NumSctpStreams { - /// Creates a [NumSctpStreamsBuilder] for serializing an instance of this table. + impl ::core::convert::TryFrom for Type { + type Error = ::planus::errors::UnknownEnumTagKind; #[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); + 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), - 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); + _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { + tag: value as i128, + }), } + } + } - 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 ::core::convert::From for u8 { + #[inline] + fn from(value: Type) -> Self { + value as u8 } } - impl ::planus::WriteAs<::planus::Offset> for NumSctpStreams { - type Prepared = ::planus::Offset; + impl ::planus::Primitive for Type { + const ALIGNMENT: usize = 1; + const SIZE: usize = 1; + } + impl ::planus::WriteAsPrimitive for Type { #[inline] - fn prepare( + fn write( &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + cursor: ::planus::Cursor<'_, N>, + buffer_position: u32, + ) { + (*self as u8).write(cursor, buffer_position); } } - impl ::planus::WriteAsOptional<::planus::Offset> for NumSctpStreams { - type Prepared = ::planus::Offset; + impl ::planus::WriteAs for Type { + type Prepared = Self; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + fn prepare(&self, _builder: &mut ::planus::Builder) -> Type { + *self } } - 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; + impl ::planus::WriteAsDefault for Type { + type Prepared = Self; #[inline] fn prepare( &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + _builder: &mut ::planus::Builder, + default: &Type, + ) -> ::core::option::Option { + if self == default { + ::core::option::Option::None + } else { + ::core::option::Option::Some(*self) + } } } - 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 ::planus::WriteAsOptional for Type { + type Prepared = Self; - 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()?)?, - }) + _builder: &mut ::planus::Builder, + ) -> ::core::option::Option { + ::core::option::Option::Some(*self) } } - impl<'a> ::planus::TableRead<'a> for NumSctpStreamsRef<'a> { + impl<'buf> ::planus::TableRead<'buf> for Type { #[inline] fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, + buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) + let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; + ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) } } - impl<'a> ::planus::VectorReadInner<'a> for NumSctpStreamsRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - + impl<'buf> ::planus::VectorReadInner<'buf> for Type { + type Error = ::planus::errors::UnknownEnumTag; + const STRIDE: usize = 1; + #[inline] unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, + buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { + ) -> ::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( - "[NumSctpStreamsRef]", - "get", + "Type", + "VectorRead::from_buffer", buffer.offset_from_start, ) }) } } - impl ::planus::VectorWrite<::planus::Offset> for NumSctpStreams { - type Value = ::planus::Offset; - const STRIDE: usize = 4; + impl ::planus::VectorWrite for Type { + const STRIDE: usize = 1; + + type Value = Self; + #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) + fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { + *self } #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[Self], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; + 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 - (Self::STRIDE * i) as u32, + buffer_position - 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` + /// The table `DumpResponse` in the namespace `FBS.DataProducer` /// /// Generated from these locations: - /// * Table `SctpParameters` in the file `../worker/fbs/sctpParameters.fbs:8` + /// * Table `DumpResponse` in the file `../worker/fbs/dataProducer.fbs:10` #[derive( Clone, Debug, @@ -26760,119 +26679,80 @@ mod root { ::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, - } - } + 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 SctpParameters { - /// Creates a [SctpParametersBuilder] for serializing an instance of this table. + impl DumpResponse { + /// Creates a [DumpResponseBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> SctpParametersBuilder<()> { - SctpParametersBuilder(()) + pub fn builder() -> DumpResponseBuilder<()> { + DumpResponseBuilder(()) } #[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, + 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_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 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<18> = + let mut table_writer: ::planus::table_writer::TableWriter<16> = ::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); + table_writer.write_entry::<::planus::Offset>(0); + if prepared_sctp_stream_parameters.is_some() { + table_writer.write_entry::<::planus::Offset>(2); } - if prepared_mis.is_some() { - table_writer.write_entry::(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_is_data_channel.is_some() { - table_writer.write_entry::(6); + if prepared_paused.is_some() { + table_writer.write_entry::(5); } 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_id); + if let ::core::option::Option::Some(prepared_sctp_stream_parameters) = + prepared_sctp_stream_parameters { - 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); + object_writer.write::<_, _, 4>(&prepared_sctp_stream_parameters); } - if let ::core::option::Option::Some(prepared_mis) = prepared_mis { - object_writer.write::<_, _, 2>(&prepared_mis); + 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_is_data_channel) = - prepared_is_data_channel - { - object_writer.write::<_, _, 1>(&prepared_is_data_channel); + if let ::core::option::Option::Some(prepared_paused) = prepared_paused { + object_writer.write::<_, _, 1>(&prepared_paused); } }); } @@ -26880,409 +26760,338 @@ mod root { } } - impl ::planus::WriteAs<::planus::Offset> for SctpParameters { + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for SctpParameters { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for SctpParameters { + impl ::planus::WriteAsOffset for DumpResponse { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SctpParameters::create( + ) -> ::planus::Offset { + DumpResponse::create( builder, - self.port, - self.os, - self.mis, - self.max_message_size, - self.send_buffer_size, - self.sctp_buffered_amount, - self.is_data_channel, + &self.id, + self.type_, + &self.sctp_stream_parameters, + &self.label, + &self.protocol, + self.paused, ) } } - /// Builder for serializing an instance of the [SctpParameters] type. + /// Builder for serializing an instance of the [DumpResponse] type. /// - /// Can be created using the [SctpParameters::builder] method. + /// Can be created using the [DumpResponse::builder] method. #[derive(Debug)] #[must_use] - pub struct SctpParametersBuilder(State); + pub struct DumpResponseBuilder(State); - impl SctpParametersBuilder<()> { - /// Setter for the [`port` field](SctpParameters#structfield.port). + impl DumpResponseBuilder<()> { + /// Setter for the [`id` field](DumpResponse#structfield.id). #[inline] #[allow(clippy::type_complexity)] - pub fn port(self, value: T0) -> SctpParametersBuilder<(T0,)> + pub fn id(self, value: T0) -> DumpResponseBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAs<::planus::Offset>, { - 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) + DumpResponseBuilder((value,)) } } - impl SctpParametersBuilder<(T0,)> { - /// Setter for the [`os` field](SctpParameters#structfield.os). + impl DumpResponseBuilder<(T0,)> { + /// Setter for the [`type` field](DumpResponse#structfield.type_). #[inline] #[allow(clippy::type_complexity)] - pub fn os(self, value: T1) -> SctpParametersBuilder<(T0, T1)> + pub fn type_(self, value: T1) -> DumpResponseBuilder<(T0, T1)> where - T1: ::planus::WriteAsDefault, + T1: ::planus::WriteAsDefault, { let (v0,) = self.0; - SctpParametersBuilder((v0, value)) + DumpResponseBuilder((v0, value)) } - /// Sets the [`os` field](SctpParameters#structfield.os) to the default value. + /// Sets the [`type` field](DumpResponse#structfield.type_) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn os_as_default(self) -> SctpParametersBuilder<(T0, ::planus::DefaultValue)> { - self.os(::planus::DefaultValue) + pub fn type_as_default(self) -> DumpResponseBuilder<(T0, ::planus::DefaultValue)> { + self.type_(::planus::DefaultValue) } } - impl SctpParametersBuilder<(T0, T1)> { - /// Setter for the [`mis` field](SctpParameters#structfield.mis). + impl DumpResponseBuilder<(T0, T1)> { + /// Setter for the [`sctp_stream_parameters` field](DumpResponse#structfield.sctp_stream_parameters). #[inline] #[allow(clippy::type_complexity)] - pub fn mis(self, value: T2) -> SctpParametersBuilder<(T0, T1, T2)> + pub fn sctp_stream_parameters( + self, + value: T2, + ) -> DumpResponseBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAsDefault, + T2: ::planus::WriteAsOptional< + ::planus::Offset, + >, { let (v0, v1) = self.0; - SctpParametersBuilder((v0, v1, value)) + DumpResponseBuilder((v0, v1, value)) } - /// Sets the [`mis` field](SctpParameters#structfield.mis) to the default value. + /// Sets the [`sctp_stream_parameters` field](DumpResponse#structfield.sctp_stream_parameters) to null. #[inline] #[allow(clippy::type_complexity)] - pub fn mis_as_default( - self, - ) -> SctpParametersBuilder<(T0, T1, ::planus::DefaultValue)> { - self.mis(::planus::DefaultValue) + pub fn sctp_stream_parameters_as_null(self) -> DumpResponseBuilder<(T0, T1, ())> { + self.sctp_stream_parameters(()) } } - impl SctpParametersBuilder<(T0, T1, T2)> { - /// Setter for the [`max_message_size` field](SctpParameters#structfield.max_message_size). + impl DumpResponseBuilder<(T0, T1, T2)> { + /// Setter for the [`label` field](DumpResponse#structfield.label). #[inline] #[allow(clippy::type_complexity)] - pub fn max_message_size( - self, - value: T3, - ) -> SctpParametersBuilder<(T0, T1, T2, T3)> + pub fn label(self, value: T3) -> DumpResponseBuilder<(T0, T1, T2, T3)> where - T3: ::planus::WriteAsDefault, + T3: ::planus::WriteAs<::planus::Offset>, { let (v0, v1, v2) = self.0; - SctpParametersBuilder((v0, v1, v2, value)) + DumpResponseBuilder((v0, v1, v2, value)) } + } - /// Sets the [`max_message_size` field](SctpParameters#structfield.max_message_size) to the default value. + impl DumpResponseBuilder<(T0, T1, T2, T3)> { + /// Setter for the [`protocol` field](DumpResponse#structfield.protocol). #[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) + 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 SctpParametersBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`send_buffer_size` field](SctpParameters#structfield.send_buffer_size). + impl DumpResponseBuilder<(T0, T1, T2, T3, T4)> { + /// Setter for the [`paused` field](DumpResponse#structfield.paused). #[inline] #[allow(clippy::type_complexity)] - pub fn send_buffer_size( - self, - value: T4, - ) -> SctpParametersBuilder<(T0, T1, T2, T3, T4)> + pub fn paused(self, value: T5) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, T5)> where - T4: ::planus::WriteAsDefault, + T5: ::planus::WriteAsDefault, { - let (v0, v1, v2, v3) = self.0; - SctpParametersBuilder((v0, v1, v2, v3, value)) + let (v0, v1, v2, v3, v4) = self.0; + DumpResponseBuilder((v0, v1, v2, v3, v4, value)) } - /// Sets the [`send_buffer_size` field](SctpParameters#structfield.send_buffer_size) to the default value. + /// Sets the [`paused` field](DumpResponse#structfield.paused) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn send_buffer_size_as_default( + pub fn paused_as_default( self, - ) -> SctpParametersBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> + ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> { - self.send_buffer_size(::planus::DefaultValue) + self.paused(::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]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + 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)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::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)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::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)> + 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, v6) = &self.0; - SctpParameters::create(builder, v0, v1, v2, v3, v4, v5, v6) + ) -> ::planus::Offset { + let (v0, v1, v2, v3, v4, v5) = &self.0; + DumpResponse::create(builder, v0, v1, v2, v3, v4, v5) } } - /// Reference to a deserialized [SctpParameters]. + /// Reference to a deserialized [DumpResponse]. #[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), - ) - } + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - /// Getter for the [`os` field](SctpParameters#structfield.os). + impl<'a> DumpResponseRef<'a> { + /// Getter for the [`id` field](DumpResponse#structfield.id). #[inline] - pub fn os(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0.access(1, "SctpParameters", "os")?.unwrap_or(0), - ) + pub fn id(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "DumpResponse", "id") } - /// Getter for the [`mis` field](SctpParameters#structfield.mis). + /// Getter for the [`type` field](DumpResponse#structfield.type_). #[inline] - pub fn mis(&self) -> ::planus::Result { + pub fn type_(&self) -> ::planus::Result { ::core::result::Result::Ok( - self.0.access(2, "SctpParameters", "mis")?.unwrap_or(0), + self.0 + .access(1, "DumpResponse", "type_")? + .unwrap_or(self::Type::Sctp), ) } - /// Getter for the [`max_message_size` field](SctpParameters#structfield.max_message_size). + /// Getter for the [`sctp_stream_parameters` field](DumpResponse#structfield.sctp_stream_parameters). #[inline] - pub fn max_message_size(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(3, "SctpParameters", "max_message_size")? - .unwrap_or(0), - ) + pub fn sctp_stream_parameters( + &self, + ) -> ::planus::Result< + ::core::option::Option>, + > { + self.0.access(2, "DumpResponse", "sctp_stream_parameters") } - /// Getter for the [`send_buffer_size` field](SctpParameters#structfield.send_buffer_size). + /// Getter for the [`label` field](DumpResponse#structfield.label). #[inline] - pub fn send_buffer_size(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(4, "SctpParameters", "send_buffer_size")? - .unwrap_or(0), - ) + pub fn label(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(3, "DumpResponse", "label") } - /// Getter for the [`sctp_buffered_amount` field](SctpParameters#structfield.sctp_buffered_amount). + /// Getter for the [`protocol` field](DumpResponse#structfield.protocol). #[inline] - pub fn sctp_buffered_amount(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "SctpParameters", "sctp_buffered_amount")? - .unwrap_or(0), - ) + pub fn protocol(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(4, "DumpResponse", "protocol") } - /// Getter for the [`is_data_channel` field](SctpParameters#structfield.is_data_channel). + /// Getter for the [`paused` field](DumpResponse#structfield.paused). #[inline] - pub fn is_data_channel(&self) -> ::planus::Result { + pub fn paused(&self) -> ::planus::Result { ::core::result::Result::Ok( - self.0 - .access(6, "SctpParameters", "is_data_channel")? - .unwrap_or(false), + self.0.access(5, "DumpResponse", "paused")?.unwrap_or(false), ) } } - impl<'a> ::core::fmt::Debug for SctpParametersRef<'a> { + 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("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()); + 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 SctpParameters { + impl<'a> ::core::convert::TryFrom> for DumpResponse { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: SctpParametersRef<'a>) -> ::planus::Result { + fn try_from(value: DumpResponseRef<'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()?, - )?, + 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 SctpParametersRef<'a> { + impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -27294,7 +27103,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for SctpParametersRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -27304,7 +27113,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[SctpParametersRef]", + "[DumpResponseRef]", "get", buffer.offset_from_start, ) @@ -27312,8 +27121,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for SctpParameters { - type Value = ::planus::Offset; + 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 { @@ -27322,7 +27131,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -27337,7 +27146,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for SctpParametersRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -27347,15 +27156,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[SctpParametersRef]", "read_as_root", 0) + error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) }) } } - /// The table `SctpStreamParameters` in the namespace `FBS.SctpParameters` + /// The table `GetStatsResponse` in the namespace `FBS.DataProducer` /// /// Generated from these locations: - /// * Table `SctpStreamParameters` in the file `../worker/fbs/sctpParameters.fbs:19` + /// * Table `GetStatsResponse` in the file `../worker/fbs/dataProducer.fbs:19` #[derive( Clone, Debug, @@ -27367,84 +27176,85 @@ mod root { ::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(), - } - } + 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 SctpStreamParameters { - /// Creates a [SctpStreamParametersBuilder] for serializing an instance of this table. + impl GetStatsResponse { + /// Creates a [GetStatsResponseBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> SctpStreamParametersBuilder<()> { - SctpStreamParametersBuilder(()) + pub fn builder() -> GetStatsResponseBuilder<()> { + GetStatsResponseBuilder(()) } #[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, + 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_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 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<12> = + let mut table_writer: ::planus::table_writer::TableWriter<16> = ::core::default::Default::default(); - if prepared_stream_id.is_some() { - table_writer.write_entry::(0); + if prepared_timestamp.is_some() { + table_writer.write_entry::(0); } - if prepared_max_packet_life_time.is_some() { - table_writer.write_entry::(2); + if prepared_messages_received.is_some() { + table_writer.write_entry::(3); } - if prepared_max_retransmits.is_some() { - table_writer.write_entry::(3); + if prepared_bytes_received.is_some() { + table_writer.write_entry::(4); } - if prepared_ordered.is_some() { - table_writer.write_entry::(1); + 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_stream_id) = - prepared_stream_id + if let ::core::option::Option::Some(prepared_timestamp) = + prepared_timestamp { - object_writer.write::<_, _, 2>(&prepared_stream_id); + object_writer.write::<_, _, 8>(&prepared_timestamp); } - if let ::core::option::Option::Some(prepared_max_packet_life_time) = - prepared_max_packet_life_time + if let ::core::option::Option::Some(prepared_messages_received) = + prepared_messages_received { - object_writer.write::<_, _, 2>(&prepared_max_packet_life_time); + object_writer.write::<_, _, 8>(&prepared_messages_received); } - if let ::core::option::Option::Some(prepared_max_retransmits) = - prepared_max_retransmits + if let ::core::option::Option::Some(prepared_bytes_received) = + prepared_bytes_received { - object_writer.write::<_, _, 2>(&prepared_max_retransmits); + object_writer.write::<_, _, 8>(&prepared_bytes_received); } - if let ::core::option::Option::Some(prepared_ordered) = prepared_ordered + 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::<_, _, 1>(&prepared_ordered); + object_writer.write::<_, _, 4>(&prepared_buffered_amount); } }); } @@ -27452,313 +27262,349 @@ mod root { } } - impl ::planus::WriteAs<::planus::Offset> for SctpStreamParameters { + impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for SctpStreamParameters { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for SctpStreamParameters { + impl ::planus::WriteAsOffset for GetStatsResponse { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SctpStreamParameters::create( + ) -> ::planus::Offset { + GetStatsResponse::create( builder, - self.stream_id, - self.ordered, - self.max_packet_life_time, - self.max_retransmits, + self.timestamp, + &self.label, + &self.protocol, + self.messages_received, + self.bytes_received, + self.buffered_amount, ) } } - /// Builder for serializing an instance of the [SctpStreamParameters] type. + /// Builder for serializing an instance of the [GetStatsResponse] type. /// - /// Can be created using the [SctpStreamParameters::builder] method. + /// Can be created using the [GetStatsResponse::builder] method. #[derive(Debug)] #[must_use] - pub struct SctpStreamParametersBuilder(State); + pub struct GetStatsResponseBuilder(State); - impl SctpStreamParametersBuilder<()> { - /// Setter for the [`stream_id` field](SctpStreamParameters#structfield.stream_id). + impl GetStatsResponseBuilder<()> { + /// Setter for the [`timestamp` field](GetStatsResponse#structfield.timestamp). #[inline] #[allow(clippy::type_complexity)] - pub fn stream_id(self, value: T0) -> SctpStreamParametersBuilder<(T0,)> + pub fn timestamp(self, value: T0) -> GetStatsResponseBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, { - SctpStreamParametersBuilder((value,)) + GetStatsResponseBuilder((value,)) } - /// Sets the [`stream_id` field](SctpStreamParameters#structfield.stream_id) to the default value. + /// Sets the [`timestamp` field](GetStatsResponse#structfield.timestamp) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn stream_id_as_default( + pub fn timestamp_as_default( self, - ) -> SctpStreamParametersBuilder<(::planus::DefaultValue,)> { - self.stream_id(::planus::DefaultValue) + ) -> GetStatsResponseBuilder<(::planus::DefaultValue,)> { + self.timestamp(::planus::DefaultValue) } } - impl SctpStreamParametersBuilder<(T0,)> { - /// Setter for the [`ordered` field](SctpStreamParameters#structfield.ordered). + impl GetStatsResponseBuilder<(T0,)> { + /// Setter for the [`label` field](GetStatsResponse#structfield.label). #[inline] #[allow(clippy::type_complexity)] - pub fn ordered(self, value: T1) -> SctpStreamParametersBuilder<(T0, T1)> + pub fn label(self, value: T1) -> GetStatsResponseBuilder<(T0, T1)> where - T1: ::planus::WriteAsOptional, + T1: ::planus::WriteAs<::planus::Offset>, { let (v0,) = self.0; - SctpStreamParametersBuilder((v0, value)) + GetStatsResponseBuilder((v0, value)) } + } - /// Sets the [`ordered` field](SctpStreamParameters#structfield.ordered) to null. + impl GetStatsResponseBuilder<(T0, T1)> { + /// Setter for the [`protocol` field](GetStatsResponse#structfield.protocol). #[inline] #[allow(clippy::type_complexity)] - pub fn ordered_as_null(self) -> SctpStreamParametersBuilder<(T0, ())> { - self.ordered(()) + 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 SctpStreamParametersBuilder<(T0, T1)> { - /// Setter for the [`max_packet_life_time` field](SctpStreamParameters#structfield.max_packet_life_time). + impl GetStatsResponseBuilder<(T0, T1, T2)> { + /// Setter for the [`messages_received` field](GetStatsResponse#structfield.messages_received). #[inline] #[allow(clippy::type_complexity)] - pub fn max_packet_life_time( + pub fn messages_received( self, - value: T2, - ) -> SctpStreamParametersBuilder<(T0, T1, T2)> + value: T3, + ) -> GetStatsResponseBuilder<(T0, T1, T2, T3)> where - T2: ::planus::WriteAsOptional, + T3: ::planus::WriteAsDefault, { - let (v0, v1) = self.0; - SctpStreamParametersBuilder((v0, v1, value)) + let (v0, v1, v2) = self.0; + GetStatsResponseBuilder((v0, v1, v2, value)) } - /// Sets the [`max_packet_life_time` field](SctpStreamParameters#structfield.max_packet_life_time) to null. + /// Sets the [`messages_received` field](GetStatsResponse#structfield.messages_received) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn max_packet_life_time_as_null( + pub fn messages_received_as_default( self, - ) -> SctpStreamParametersBuilder<(T0, T1, ())> { - self.max_packet_life_time(()) + ) -> GetStatsResponseBuilder<(T0, T1, T2, ::planus::DefaultValue)> { + self.messages_received(::planus::DefaultValue) } } - impl SctpStreamParametersBuilder<(T0, T1, T2)> { - /// Setter for the [`max_retransmits` field](SctpStreamParameters#structfield.max_retransmits). + impl GetStatsResponseBuilder<(T0, T1, T2, T3)> { + /// Setter for the [`bytes_received` field](GetStatsResponse#structfield.bytes_received). #[inline] #[allow(clippy::type_complexity)] - pub fn max_retransmits( + pub fn bytes_received( self, - value: T3, - ) -> SctpStreamParametersBuilder<(T0, T1, T2, T3)> + value: T4, + ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> where - T3: ::planus::WriteAsOptional, + T4: ::planus::WriteAsDefault, { - let (v0, v1, v2) = self.0; - SctpStreamParametersBuilder((v0, v1, v2, value)) + let (v0, v1, v2, v3) = self.0; + GetStatsResponseBuilder((v0, v1, v2, v3, value)) } - /// Sets the [`max_retransmits` field](SctpStreamParameters#structfield.max_retransmits) to null. + /// Sets the [`bytes_received` field](GetStatsResponse#structfield.bytes_received) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn max_retransmits_as_null( + pub fn bytes_received_as_default( self, - ) -> SctpStreamParametersBuilder<(T0, T1, T2, ())> { - self.max_retransmits(()) + ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> + { + self.bytes_received(::planus::DefaultValue) } } - impl SctpStreamParametersBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SctpStreamParameters]. + impl GetStatsResponseBuilder<(T0, T1, T2, T3, T4)> { + /// Setter for the [`buffered_amount` field](GetStatsResponse#structfield.buffered_amount). #[inline] - pub fn finish( + #[allow(clippy::type_complexity)] + pub fn buffered_amount( self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset + value: T5, + ) -> GetStatsResponseBuilder<(T0, T1, T2, T3, T4, T5)> where - Self: ::planus::WriteAsOffset, + 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::WriteAsOptional, - T2: ::planus::WriteAsOptional, - T3: ::planus::WriteAsOptional, - > ::planus::WriteAs<::planus::Offset> - for SctpStreamParametersBuilder<(T0, T1, T2, T3)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::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)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { + ) -> ::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)> + 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) = &self.0; - SctpStreamParameters::create(builder, v0, v1, v2, v3) + ) -> ::planus::Offset { + let (v0, v1, v2, v3, v4, v5) = &self.0; + GetStatsResponse::create(builder, v0, v1, v2, v3, v4, v5) } } - /// Reference to a deserialized [SctpStreamParameters]. + /// Reference to a deserialized [GetStatsResponse]. #[derive(Copy, Clone)] - pub struct SctpStreamParametersRef<'a>(::planus::table_reader::Table<'a>); + pub struct GetStatsResponseRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> SctpStreamParametersRef<'a> { - /// Getter for the [`stream_id` field](SctpStreamParameters#structfield.stream_id). + impl<'a> GetStatsResponseRef<'a> { + /// Getter for the [`timestamp` field](GetStatsResponse#structfield.timestamp). #[inline] - pub fn stream_id(&self) -> ::planus::Result { + pub fn timestamp(&self) -> ::planus::Result { ::core::result::Result::Ok( self.0 - .access(0, "SctpStreamParameters", "stream_id")? + .access(0, "GetStatsResponse", "timestamp")? .unwrap_or(0), ) } - /// Getter for the [`ordered` field](SctpStreamParameters#structfield.ordered). + /// Getter for the [`label` field](GetStatsResponse#structfield.label). #[inline] - pub fn ordered(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(1, "SctpStreamParameters", "ordered") + pub fn label(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(1, "GetStatsResponse", "label") } - /// Getter for the [`max_packet_life_time` field](SctpStreamParameters#structfield.max_packet_life_time). + /// Getter for the [`protocol` field](GetStatsResponse#structfield.protocol). #[inline] - pub fn max_packet_life_time( - &self, - ) -> ::planus::Result<::core::option::Option> { - self.0 - .access(2, "SctpStreamParameters", "max_packet_life_time") + pub fn protocol(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(2, "GetStatsResponse", "protocol") } - /// Getter for the [`max_retransmits` field](SctpStreamParameters#structfield.max_retransmits). + /// Getter for the [`messages_received` field](GetStatsResponse#structfield.messages_received). #[inline] - pub fn max_retransmits(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(3, "SctpStreamParameters", "max_retransmits") + 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 SctpStreamParametersRef<'a> { + 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("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); - } + 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 SctpStreamParameters { + impl<'a> ::core::convert::TryFrom> for GetStatsResponse { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: SctpStreamParametersRef<'a>) -> ::planus::Result { + fn try_from(value: GetStatsResponseRef<'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 - }, + 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 SctpStreamParametersRef<'a> { + impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -27770,7 +27616,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for SctpStreamParametersRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for GetStatsResponseRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -27780,7 +27626,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[SctpStreamParametersRef]", + "[GetStatsResponseRef]", "get", buffer.offset_from_start, ) @@ -27788,8 +27634,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for SctpStreamParameters { - type Value = ::planus::Offset; + 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 { @@ -27798,7 +27644,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -27813,7 +27659,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for SctpStreamParametersRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for GetStatsResponseRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -27823,24 +27669,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location( - "[SctpStreamParametersRef]", - "read_as_root", - 0, - ) + error_kind.with_error_location("[GetStatsResponseRef]", "read_as_root", 0) }) } } - } - /// The namespace `FBS.DataProducer` - /// - /// Generated from these locations: - /// * File `../worker/fbs/dataProducer.fbs` - pub mod data_producer { - /// The table `DumpResponse` in the namespace `FBS.DataProducer` + + /// The table `String` in the namespace `FBS.DataProducer` /// /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/dataProducer.fbs:5` + /// * Table `String` in the file `../worker/fbs/dataProducer.fbs:28` #[derive( Clone, Debug, @@ -27852,416 +27689,175 @@ mod root { ::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_: ::planus::alloc::string::String, - /// 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, + pub struct String { + /// The field `value` in the table `String` + pub value: ::planus::alloc::string::String, } - impl DumpResponse { - /// Creates a [DumpResponseBuilder] for serializing an instance of this table. + impl String { + /// Creates a [StringBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> DumpResponseBuilder<()> { - DumpResponseBuilder(()) + pub fn builder() -> StringBuilder<()> { + StringBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_id: impl ::planus::WriteAs<::planus::Offset>, - field_type_: impl ::planus::WriteAs<::planus::Offset>, - 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, + field_value: impl ::planus::WriteAs<::planus::Offset>, ) -> ::planus::Offset { - let prepared_id = field_id.prepare(builder); - let prepared_type_ = field_type_.prepare(builder); - 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_value = field_value.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<16> = + let mut table_writer: ::planus::table_writer::TableWriter<6> = ::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>(2); - } - table_writer.write_entry::<::planus::Offset>(3); - table_writer.write_entry::<::planus::Offset>(4); - if prepared_paused.is_some() { - table_writer.write_entry::(5); - } unsafe { table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_id); - object_writer.write::<_, _, 4>(&prepared_type_); - 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_paused) = prepared_paused { - object_writer.write::<_, _, 1>(&prepared_paused); - } + object_writer.write::<_, _, 4>(&prepared_value); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for DumpResponse { + impl ::planus::WriteAs<::planus::Offset> for String { type Prepared = ::planus::Offset; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for DumpResponse { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for DumpResponse { + impl ::planus::WriteAsOffset for String { #[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, - ) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + String::create(builder, &self.value) } } - /// Builder for serializing an instance of the [DumpResponse] type. + /// Builder for serializing an instance of the [String] type. /// - /// Can be created using the [DumpResponse::builder] method. + /// Can be created using the [String::builder] method. #[derive(Debug)] #[must_use] - pub struct DumpResponseBuilder(State); + pub struct StringBuilder(State); - impl DumpResponseBuilder<()> { - /// Setter for the [`id` field](DumpResponse#structfield.id). + impl StringBuilder<()> { + /// Setter for the [`value` field](String#structfield.value). #[inline] #[allow(clippy::type_complexity)] - pub fn id(self, value: T0) -> DumpResponseBuilder<(T0,)> + pub fn value(self, value: T0) -> StringBuilder<(T0,)> where T0: ::planus::WriteAs<::planus::Offset>, { - DumpResponseBuilder((value,)) + StringBuilder((value,)) } } - impl DumpResponseBuilder<(T0,)> { - /// Setter for the [`type` field](DumpResponse#structfield.type_). + impl StringBuilder<(T0,)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [String]. #[inline] - #[allow(clippy::type_complexity)] - pub fn type_(self, value: T1) -> DumpResponseBuilder<(T0, T1)> + pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset where - T1: ::planus::WriteAs<::planus::Offset>, + Self: ::planus::WriteAsOffset, { - let (v0,) = self.0; - DumpResponseBuilder((v0, value)) + ::planus::WriteAsOffset::prepare(&self, builder) } } - 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)) - } + impl>> + ::planus::WriteAs<::planus::Offset> for StringBuilder<(T0,)> + { + type Prepared = ::planus::Offset; - /// 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(()) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl DumpResponseBuilder<(T0, T1, T2)> { - /// Setter for the [`label` field](DumpResponse#structfield.label). + impl>> + ::planus::WriteAsOptional<::planus::Offset> for StringBuilder<(T0,)> + { + type Prepared = ::planus::Offset; + #[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)) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl DumpResponseBuilder<(T0, T1, T2, T3)> { - /// Setter for the [`protocol` field](DumpResponse#structfield.protocol). + impl>> ::planus::WriteAsOffset + for StringBuilder<(T0,)> + { #[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)) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + let (v0,) = &self.0; + String::create(builder, v0) } } - 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)) - } + /// Reference to a deserialized [String]. + #[derive(Copy, Clone)] + pub struct StringRef<'a>(::planus::table_reader::Table<'a>); - /// Sets the [`paused` field](DumpResponse#structfield.paused) to the default value. + impl<'a> StringRef<'a> { + /// Getter for the [`value` field](String#structfield.value). #[inline] - #[allow(clippy::type_complexity)] - pub fn paused_as_default( - self, - ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> - { - self.paused(::planus::DefaultValue) + pub fn value(&self) -> ::planus::Result<&'a ::core::primitive::str> { + self.0.access_required(0, "String", "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<'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< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - 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; + impl<'a> ::core::convert::TryFrom> for String { + type Error = ::planus::Error; - #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + #[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< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - 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; - + impl<'a> ::planus::TableRead<'a> for StringRef<'a> { #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + 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< - T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, - 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<&'a ::core::primitive::str> { - self.0.access_required(1, "DumpResponse", "type_") - } - - /// 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> { + impl<'a> ::planus::VectorReadInner<'a> for StringRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -28271,7 +27867,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[DumpResponseRef]", + "[StringRef]", "get", buffer.offset_from_start, ) @@ -28279,8 +27875,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for DumpResponse { - type Value = ::planus::Offset; + 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 { @@ -28289,7 +27885,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -28304,7 +27900,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for StringRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -28314,15 +27910,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) + error_kind.with_error_location("[StringRef]", "read_as_root", 0) }) } } - /// The table `GetStatsResponse` in the namespace `FBS.DataProducer` + /// The table `Binary` in the namespace `FBS.DataProducer` /// /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/dataProducer.fbs:14` + /// * Table `Binary` in the file `../worker/fbs/dataProducer.fbs:32` #[derive( Clone, Debug, @@ -28334,435 +27930,163 @@ mod root { ::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, + pub struct Binary { + /// The field `value` in the table `Binary` + pub value: ::planus::alloc::vec::Vec, } - impl GetStatsResponse { - /// Creates a [GetStatsResponseBuilder] for serializing an instance of this table. + impl Binary { + /// Creates a [BinaryBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> GetStatsResponseBuilder<()> { - GetStatsResponseBuilder(()) + pub fn builder() -> BinaryBuilder<()> { + BinaryBuilder(()) } #[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, + field_value: impl ::planus::WriteAs<::planus::Offset<[u8]>>, ) -> ::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 prepared_value = field_value.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<16> = + let mut table_writer: ::planus::table_writer::TableWriter<6> = ::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); - } + table_writer.write_entry::<::planus::Offset<[u8]>>(0); 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); - } + object_writer.write::<_, _, 4>(&prepared_value); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for GetStatsResponse { + impl ::planus::WriteAs<::planus::Offset> for Binary { type Prepared = ::planus::Offset; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { + impl ::planus::WriteAsOptional<::planus::Offset> for Binary { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for GetStatsResponse { + impl ::planus::WriteAsOffset for Binary { #[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, - ) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + Binary::create(builder, &self.value) } } - /// Builder for serializing an instance of the [GetStatsResponse] type. + /// Builder for serializing an instance of the [Binary] type. /// - /// Can be created using the [GetStatsResponse::builder] method. + /// Can be created using the [Binary::builder] method. #[derive(Debug)] #[must_use] - pub struct GetStatsResponseBuilder(State); + pub struct BinaryBuilder(State); - impl GetStatsResponseBuilder<()> { - /// Setter for the [`timestamp` field](GetStatsResponse#structfield.timestamp). + impl BinaryBuilder<()> { + /// Setter for the [`value` field](Binary#structfield.value). #[inline] #[allow(clippy::type_complexity)] - pub fn timestamp(self, value: T0) -> GetStatsResponseBuilder<(T0,)> + pub fn value(self, value: T0) -> BinaryBuilder<(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)> + T0: ::planus::WriteAs<::planus::Offset<[u8]>>, { - self.buffered_amount(::planus::DefaultValue) + BinaryBuilder((value,)) } } - impl GetStatsResponseBuilder<(T0, T1, T2, T3, T4, T5)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [GetStatsResponse]. + impl BinaryBuilder<(T0,)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Binary]. #[inline] - pub fn finish( - self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset + pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + 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)> + impl>> + ::planus::WriteAs<::planus::Offset> for BinaryBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + 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)> + impl>> + ::planus::WriteAsOptional<::planus::Offset> for BinaryBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::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)> + impl>> ::planus::WriteAsOffset + for BinaryBuilder<(T0,)> { #[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) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + let (v0,) = &self.0; + Binary::create(builder, v0) } } - /// Reference to a deserialized [GetStatsResponse]. + /// Reference to a deserialized [Binary]. #[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), - ) - } + pub struct BinaryRef<'a>(::planus::table_reader::Table<'a>); - /// Getter for the [`buffered_amount` field](GetStatsResponse#structfield.buffered_amount). + impl<'a> BinaryRef<'a> { + /// Getter for the [`value` field](Binary#structfield.value). #[inline] - pub fn buffered_amount(&self) -> ::planus::Result { - ::core::result::Result::Ok( - self.0 - .access(5, "GetStatsResponse", "buffered_amount")? - .unwrap_or(0), - ) + pub fn value(&self) -> ::planus::Result<&'a [u8]> { + self.0.access_required(0, "Binary", "value") } } - impl<'a> ::core::fmt::Debug for GetStatsResponseRef<'a> { + impl<'a> ::core::fmt::Debug for BinaryRef<'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()); + let mut f = f.debug_struct("BinaryRef"); + f.field("value", &self.value()); f.finish() } } - impl<'a> ::core::convert::TryFrom> for GetStatsResponse { + impl<'a> ::core::convert::TryFrom> for Binary { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: GetStatsResponseRef<'a>) -> ::planus::Result { + fn try_from(value: BinaryRef<'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()?, - )?, + value: value.value()?.to_vec(), }) } } - impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { + impl<'a> ::planus::TableRead<'a> for BinaryRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -28774,7 +28098,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for GetStatsResponseRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for BinaryRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -28784,7 +28108,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[GetStatsResponseRef]", + "[BinaryRef]", "get", buffer.offset_from_start, ) @@ -28792,8 +28116,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for GetStatsResponse { - type Value = ::planus::Offset; + impl ::planus::VectorWrite<::planus::Offset> for Binary { + type Value = ::planus::Offset; const STRIDE: usize = 4; #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { @@ -28802,7 +28126,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -28817,7 +28141,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for GetStatsResponseRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for BinaryRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -28827,15 +28151,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[GetStatsResponseRef]", "read_as_root", 0) + error_kind.with_error_location("[BinaryRef]", "read_as_root", 0) }) } } - /// The table `String` in the namespace `FBS.DataProducer` + /// The union `Data` in the namespace `FBS.DataProducer` /// /// Generated from these locations: - /// * Table `String` in the file `../worker/fbs/dataProducer.fbs:23` + /// * Union `Data` in the file `../worker/fbs/dataProducer.fbs:36` #[derive( Clone, Debug, @@ -28847,404 +28171,545 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct String { - /// The field `value` in the table `String` - pub value: ::planus::alloc::string::String, + pub enum Data { + /// The variant of type `String` in the union `Data` + String(::planus::alloc::boxed::Box), + + /// The variant of type `Binary` in the union `Data` + Binary(::planus::alloc::boxed::Box), } - impl String { - /// Creates a [StringBuilder] for serializing an instance of this table. + impl Data { + /// Creates a [DataBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> StringBuilder<()> { - StringBuilder(()) + pub fn builder() -> DataBuilder<::planus::Uninitialized> { + DataBuilder(::planus::Uninitialized) } - #[allow(clippy::too_many_arguments)] - pub fn create( + #[inline] + pub fn create_string( 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); + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + } - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_value); - }); - } - builder.current_offset() + #[inline] + pub fn create_binary( + builder: &mut ::planus::Builder, + value: impl ::planus::WriteAsOffset, + ) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) } } - impl ::planus::WriteAs<::planus::Offset> for String { - type Prepared = ::planus::Offset; - + impl ::planus::WriteAsUnion for Data { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + match self { + Self::String(value) => Self::create_string(builder, value), + Self::Binary(value) => Self::create_binary(builder, value), + } } } - impl ::planus::WriteAsOptional<::planus::Offset> for String { - type Prepared = ::planus::Offset; - + impl ::planus::WriteAsOptionalUnion for Data { #[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) + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - /// Builder for serializing an instance of the [String] type. + /// Builder for serializing an instance of the [Data] type. /// - /// Can be created using the [String::builder] method. + /// Can be created using the [Data::builder] method. #[derive(Debug)] #[must_use] - pub struct StringBuilder(State); + pub struct DataBuilder(T); - impl StringBuilder<()> { - /// Setter for the [`value` field](String#structfield.value). + impl DataBuilder<::planus::Uninitialized> { + /// Creates an instance of the [`String` variant](Data#variant.String). #[inline] - #[allow(clippy::type_complexity)] - pub fn value(self, value: T0) -> StringBuilder<(T0,)> + pub fn string(self, value: T) -> DataBuilder<::planus::Initialized<1, T>> where - T0: ::planus::WriteAs<::planus::Offset>, + T: ::planus::WriteAsOffset, { - StringBuilder((value,)) + DataBuilder(::planus::Initialized(value)) + } + + /// Creates an instance of the [`Binary` variant](Data#variant.Binary). + #[inline] + pub fn binary(self, value: T) -> DataBuilder<::planus::Initialized<2, T>> + where + T: ::planus::WriteAsOffset, + { + DataBuilder(::planus::Initialized(value)) } } - impl StringBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [String]. + impl DataBuilder<::planus::Initialized> { + /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Data]. #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset + pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsUnion, { - ::planus::WriteAsOffset::prepare(&self, builder) + ::planus::WriteAsUnion::prepare(&self, builder) } } - impl>> - ::planus::WriteAs<::planus::Offset> for StringBuilder<(T0,)> + impl ::planus::WriteAsUnion for DataBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, { - type Prepared = ::planus::Offset; - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) } } - impl>> - ::planus::WriteAsOptional<::planus::Offset> for StringBuilder<(T0,)> + impl ::planus::WriteAsOptionalUnion for DataBuilder<::planus::Initialized<1, T>> + where + T: ::planus::WriteAsOffset, { - type Prepared = ::planus::Offset; - #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - - impl>> ::planus::WriteAsOffset - for StringBuilder<(T0,)> + impl ::planus::WriteAsUnion for DataBuilder<::planus::Initialized<2, T>> + where + T: ::planus::WriteAsOffset, { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0,) = &self.0; - String::create(builder, v0) + fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { + ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) } } - /// 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). + impl ::planus::WriteAsOptionalUnion for DataBuilder<::planus::Initialized<2, T>> + where + T: ::planus::WriteAsOffset, + { #[inline] - pub fn value(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "String", "value") + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::UnionOffset> { + ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) } } - 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() - } + /// Reference to a deserialized [Data]. + #[derive(Copy, Clone, Debug)] + pub enum DataRef<'a> { + String(self::StringRef<'a>), + Binary(self::BinaryRef<'a>), } - impl<'a> ::core::convert::TryFrom> for String { + impl<'a> ::core::convert::TryFrom> for Data { 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()?)?, + fn try_from(value: DataRef<'a>) -> ::planus::Result { + ::core::result::Result::Ok(match value { + DataRef::String(value) => Self::String(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )), + + DataRef::Binary(value) => Self::Binary(::planus::alloc::boxed::Box::new( + ::core::convert::TryFrom::try_from(value)?, + )), }) } } - impl<'a> ::planus::TableRead<'a> for StringRef<'a> { - #[inline] + impl<'a> ::planus::TableReadUnion<'a> for DataRef<'a> { fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, - offset: usize, + field_offset: usize, + tag: u8, ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) + match tag { + 1 => ::core::result::Result::Ok(Self::String( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + 2 => ::core::result::Result::Ok(Self::Binary( + ::planus::TableRead::from_buffer(buffer, field_offset)?, + )), + _ => ::core::result::Result::Err( + ::planus::errors::ErrorKind::UnknownUnionTag { tag }, + ), + } } } - impl<'a> ::planus::VectorReadInner<'a> for StringRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; + /// The table `SendNotification` in the namespace `FBS.DataProducer` + /// + /// Generated from these locations: + /// * Table `SendNotification` in the file `../worker/fbs/dataProducer.fbs:41` + #[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: self::Data, + /// 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, + } - 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 table `Binary` in the namespace `FBS.DataProducer` - /// - /// Generated from these locations: - /// * Table `Binary` in the file `../worker/fbs/dataProducer.fbs:27` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Binary { - /// The field `value` in the table `Binary` - pub value: ::planus::alloc::vec::Vec, - } - - impl Binary { - /// Creates a [BinaryBuilder] for serializing an instance of this table. + impl SendNotification { + /// Creates a [SendNotificationBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> BinaryBuilder<()> { - BinaryBuilder(()) + pub fn builder() -> SendNotificationBuilder<()> { + SendNotificationBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_value: impl ::planus::WriteAs<::planus::Offset<[u8]>>, + field_ppid: impl ::planus::WriteAsDefault, + field_data: impl ::planus::WriteAsUnion, + field_subchannels: impl ::planus::WriteAsOptional<::planus::Offset<[u16]>>, + field_required_subchannel: impl ::planus::WriteAsOptional, ) -> ::planus::Offset { - let prepared_value = field_value.prepare(builder); + 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<6> = + let mut table_writer: ::planus::table_writer::TableWriter<14> = ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[u8]>>(0); + if prepared_ppid.is_some() { + table_writer.write_entry::(0); + } + table_writer.write_entry::<::planus::Offset>(2); + if prepared_subchannels.is_some() { + table_writer.write_entry::<::planus::Offset<[u16]>>(3); + } + if prepared_required_subchannel.is_some() { + table_writer.write_entry::(4); + } + table_writer.write_entry::(1); unsafe { table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_value); + if let ::core::option::Option::Some(prepared_ppid) = prepared_ppid { + object_writer.write::<_, _, 4>(&prepared_ppid); + } + object_writer.write::<_, _, 4>(&prepared_data.offset()); + 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); + } + object_writer.write::<_, _, 1>(&prepared_data.tag()); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for Binary { + impl ::planus::WriteAs<::planus::Offset> for SendNotification { type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for Binary { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for Binary { + impl ::planus::WriteAsOffset for SendNotification { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Binary::create(builder, &self.value) + 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 [Binary] type. + /// Builder for serializing an instance of the [SendNotification] type. /// - /// Can be created using the [Binary::builder] method. + /// Can be created using the [SendNotification::builder] method. #[derive(Debug)] #[must_use] - pub struct BinaryBuilder(State); + pub struct SendNotificationBuilder(State); - impl BinaryBuilder<()> { - /// Setter for the [`value` field](Binary#structfield.value). + impl SendNotificationBuilder<()> { + /// Setter for the [`ppid` field](SendNotification#structfield.ppid). #[inline] #[allow(clippy::type_complexity)] - pub fn value(self, value: T0) -> BinaryBuilder<(T0,)> + pub fn ppid(self, value: T0) -> SendNotificationBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset<[u8]>>, + T0: ::planus::WriteAsDefault, { - BinaryBuilder((value,)) + 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 BinaryBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Binary]. + impl SendNotificationBuilder<(T0,)> { + /// Setter for the [`data` field](SendNotification#structfield.data). #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset + #[allow(clippy::type_complexity)] + pub fn data(self, value: T1) -> SendNotificationBuilder<(T0, T1)> where - Self: ::planus::WriteAsOffset, + T1: ::planus::WriteAsUnion, { - ::planus::WriteAsOffset::prepare(&self, builder) + let (v0,) = self.0; + SendNotificationBuilder((v0, value)) } } - impl>> - ::planus::WriteAs<::planus::Offset> for BinaryBuilder<(T0,)> - { - type Prepared = ::planus::Offset; + 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] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + #[allow(clippy::type_complexity)] + pub fn subchannels_as_null(self) -> SendNotificationBuilder<(T0, T1, ())> { + self.subchannels(()) } } - impl>> - ::planus::WriteAsOptional<::planus::Offset> for BinaryBuilder<(T0,)> - { - type Prepared = ::planus::Offset; - + impl SendNotificationBuilder<(T0, T1, T2)> { + /// Setter for the [`required_subchannel` field](SendNotification#structfield.required_subchannel). #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { - ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) + #[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)) } - } - impl>> ::planus::WriteAsOffset - for BinaryBuilder<(T0,)> - { + /// Sets the [`required_subchannel` field](SendNotification#structfield.required_subchannel) to null. #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0,) = &self.0; - Binary::create(builder, v0) + #[allow(clippy::type_complexity)] + pub fn required_subchannel_as_null( + self, + ) -> SendNotificationBuilder<(T0, T1, T2, ())> { + self.required_subchannel(()) } } - /// Reference to a deserialized [Binary]. - #[derive(Copy, Clone)] - pub struct BinaryRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> BinaryRef<'a> { - /// Getter for the [`value` field](Binary#structfield.value). + impl SendNotificationBuilder<(T0, T1, T2, T3)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SendNotification]. #[inline] - pub fn value(&self) -> ::planus::Result<&'a [u8]> { - self.0.access_required(0, "Binary", "value") + pub fn finish( + self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset + where + Self: ::planus::WriteAsOffset, + { + ::planus::WriteAsOffset::prepare(&self, builder) } } - impl<'a> ::core::fmt::Debug for BinaryRef<'a> { + impl< + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsUnion, + 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::WriteAsUnion, + 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::WriteAsUnion, + 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> { + self.0.access_union_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(3, "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(4, "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("BinaryRef"); - f.field("value", &self.value()); + 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 Binary { + impl<'a> ::core::convert::TryFrom> for SendNotification { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: BinaryRef<'a>) -> ::planus::Result { + fn try_from(value: SendNotificationRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - value: value.value()?.to_vec(), + ppid: ::core::convert::TryInto::try_into(value.ppid()?)?, + data: ::core::convert::TryInto::try_into(value.data()?)?, + 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 BinaryRef<'a> { + impl<'a> ::planus::TableRead<'a> for SendNotificationRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -29256,7 +28721,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for BinaryRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for SendNotificationRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -29266,7 +28731,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[BinaryRef]", + "[SendNotificationRef]", "get", buffer.offset_from_start, ) @@ -29274,8 +28739,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for Binary { - type Value = ::planus::Offset; + 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 { @@ -29284,7 +28749,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -29299,7 +28764,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for BinaryRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for SendNotificationRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -29309,15 +28774,20 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[BinaryRef]", "read_as_root", 0) + error_kind.with_error_location("[SendNotificationRef]", "read_as_root", 0) }) } } - - /// The union `Data` in the namespace `FBS.DataProducer` + } + /// 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: - /// * Union `Data` in the file `../worker/fbs/dataProducer.fbs:31` + /// * Table `NumSctpStreams` in the file `../worker/fbs/sctpParameters.fbs:3` #[derive( Clone, Debug, @@ -29329,188 +28799,929 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub enum Data { - /// The variant of type `String` in the union `Data` - String(::planus::alloc::boxed::Box), + pub struct NumSctpStreams { + /// The field `os` in the table `NumSctpStreams` + pub os: u16, + /// The field `mis` in the table `NumSctpStreams` + pub mis: u16, + } - /// The variant of type `Binary` in the union `Data` - Binary(::planus::alloc::boxed::Box), + #[allow(clippy::derivable_impls)] + impl ::core::default::Default for NumSctpStreams { + fn default() -> Self { + Self { + os: 1024, + mis: 1024, + } + } } - impl Data { - /// Creates a [DataBuilder] for serializing an instance of this table. + impl NumSctpStreams { + /// Creates a [NumSctpStreamsBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> DataBuilder<::planus::Uninitialized> { - DataBuilder(::planus::Uninitialized) + pub fn builder() -> NumSctpStreamsBuilder<()> { + NumSctpStreamsBuilder(()) } - #[inline] - pub fn create_string( + #[allow(clippy::too_many_arguments)] + pub fn create( builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + 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] - pub fn create_binary( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsUnion for Data { + impl ::planus::WriteAsOptional<::planus::Offset> for NumSctpStreams { + type Prepared = ::planus::Offset; + #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - match self { - Self::String(value) => Self::create_string(builder, value), - Self::Binary(value) => Self::create_binary(builder, value), - } + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOptionalUnion for Data { + impl ::planus::WriteAsOffset for NumSctpStreams { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Offset { + NumSctpStreams::create(builder, self.os, self.mis) } } - /// Builder for serializing an instance of the [Data] type. + /// Builder for serializing an instance of the [NumSctpStreams] type. /// - /// Can be created using the [Data::builder] method. + /// Can be created using the [NumSctpStreams::builder] method. #[derive(Debug)] #[must_use] - pub struct DataBuilder(T); + pub struct NumSctpStreamsBuilder(State); - impl DataBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`String` variant](Data#variant.String). + 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] - pub fn string(self, value: T) -> DataBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, + #[allow(clippy::type_complexity)] + pub fn send_buffer_size_as_default( + self, + ) -> SctpParametersBuilder<(T0, T1, T2, T3, ::planus::DefaultValue)> { - DataBuilder(::planus::Initialized(value)) + self.send_buffer_size(::planus::DefaultValue) } + } - /// Creates an instance of the [`Binary` variant](Data#variant.Binary). + impl SctpParametersBuilder<(T0, T1, T2, T3, T4)> { + /// Setter for the [`sctp_buffered_amount` field](SctpParameters#structfield.sctp_buffered_amount). #[inline] - pub fn binary(self, value: T) -> DataBuilder<::planus::Initialized<2, T>> + #[allow(clippy::type_complexity)] + pub fn sctp_buffered_amount( + self, + value: T5, + ) -> SctpParametersBuilder<(T0, T1, T2, T3, T4, T5)> where - T: ::planus::WriteAsOffset, + T5: ::planus::WriteAsDefault, { - DataBuilder(::planus::Initialized(value)) + 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 DataBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Data]. + impl SctpParametersBuilder<(T0, T1, T2, T3, T4, T5)> { + /// Setter for the [`is_data_channel` field](SctpParameters#structfield.is_data_channel). #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset + #[allow(clippy::type_complexity)] + pub fn is_data_channel( + self, + value: T6, + ) -> SctpParametersBuilder<(T0, T1, T2, T3, T4, T5, T6)> where - Self: ::planus::WriteAsUnion, + T6: ::planus::WriteAsDefault, { - ::planus::WriteAsUnion::prepare(&self, builder) + 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 ::planus::WriteAsUnion for DataBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { + impl SctpParametersBuilder<(T0, T1, T2, T3, T4, T5, T6)> { + /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SctpParameters]. #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) + pub fn finish( + self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset + where + Self: ::planus::WriteAsOffset, + { + ::planus::WriteAsOffset::prepare(&self, builder) } } - impl ::planus::WriteAsOptionalUnion for DataBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, + 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, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsUnion for DataBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, + + 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) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOptionalUnion for DataBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, + 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, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, 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 [Data]. - #[derive(Copy, Clone, Debug)] - pub enum DataRef<'a> { - String(self::StringRef<'a>), - Binary(self::BinaryRef<'a>), + /// 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> ::core::convert::TryFrom> for Data { + impl<'a> ::planus::VectorReadInner<'a> for SctpParametersRef<'a> { type Error = ::planus::Error; + const STRIDE: usize = 4; - fn try_from(value: DataRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - DataRef::String(value) => Self::String(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )), - - DataRef::Binary(value) => Self::Binary(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )), + 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<'a> ::planus::TableReadUnion<'a> for DataRef<'a> { - fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, - field_offset: usize, - tag: u8, - ) -> ::core::result::Result { - match tag { - 1 => ::core::result::Result::Ok(Self::String( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::Binary( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), + 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, + ); } } } - /// The table `SendNotification` in the namespace `FBS.DataProducer` + 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 `SendNotification` in the file `../worker/fbs/dataProducer.fbs:36` + /// * Table `SctpStreamParameters` in the file `../worker/fbs/sctpParameters.fbs:19` #[derive( Clone, Debug, @@ -29522,343 +29733,389 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct SendNotification { - /// The field `ppid` in the table `SendNotification` - pub ppid: u8, - /// The field `data` in the table `SendNotification` - pub data: self::Data, - /// 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, + 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, } - impl SendNotification { - /// Creates a [SendNotificationBuilder] for serializing an instance of this table. + #[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() -> SendNotificationBuilder<()> { - SendNotificationBuilder(()) + pub fn builder() -> SctpStreamParametersBuilder<()> { + SctpStreamParametersBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_ppid: impl ::planus::WriteAsDefault, - field_data: impl ::planus::WriteAsUnion, - field_subchannels: impl ::planus::WriteAsOptional<::planus::Offset<[u16]>>, - field_required_subchannel: impl ::planus::WriteAsOptional, + 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_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 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<14> = + let mut table_writer: ::planus::table_writer::TableWriter<12> = ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(2); - if prepared_subchannels.is_some() { - table_writer.write_entry::<::planus::Offset<[u16]>>(3); + if prepared_stream_id.is_some() { + table_writer.write_entry::(0); } - if prepared_required_subchannel.is_some() { - table_writer.write_entry::(4); + if prepared_max_packet_life_time.is_some() { + table_writer.write_entry::(2); } - if prepared_ppid.is_some() { - table_writer.write_entry::(0); + if prepared_max_retransmits.is_some() { + table_writer.write_entry::(3); + } + if prepared_ordered.is_some() { + table_writer.write_entry::(1); } - 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_subchannels) = - prepared_subchannels + if let ::core::option::Option::Some(prepared_stream_id) = + prepared_stream_id { - object_writer.write::<_, _, 4>(&prepared_subchannels); + object_writer.write::<_, _, 2>(&prepared_stream_id); } - if let ::core::option::Option::Some(prepared_required_subchannel) = - prepared_required_subchannel + if let ::core::option::Option::Some(prepared_max_packet_life_time) = + prepared_max_packet_life_time { - object_writer.write::<_, _, 2>(&prepared_required_subchannel); + object_writer.write::<_, _, 2>(&prepared_max_packet_life_time); } - if let ::core::option::Option::Some(prepared_ppid) = prepared_ppid { - object_writer.write::<_, _, 1>(&prepared_ppid); + 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); } - object_writer.write::<_, _, 1>(&prepared_data.tag()); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for SendNotification { + impl ::planus::WriteAs<::planus::Offset> for SctpStreamParameters { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for SendNotification { + 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<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for SendNotification { + impl ::planus::WriteAsOffset for SctpStreamParameters { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SendNotification::create( + ) -> ::planus::Offset { + SctpStreamParameters::create( builder, - self.ppid, - &self.data, - &self.subchannels, - self.required_subchannel, + self.stream_id, + self.ordered, + self.max_packet_life_time, + self.max_retransmits, ) } } - /// Builder for serializing an instance of the [SendNotification] type. + /// Builder for serializing an instance of the [SctpStreamParameters] type. /// - /// Can be created using the [SendNotification::builder] method. + /// Can be created using the [SctpStreamParameters::builder] method. #[derive(Debug)] #[must_use] - pub struct SendNotificationBuilder(State); + pub struct SctpStreamParametersBuilder(State); - impl SendNotificationBuilder<()> { - /// Setter for the [`ppid` field](SendNotification#structfield.ppid). + impl SctpStreamParametersBuilder<()> { + /// Setter for the [`stream_id` field](SctpStreamParameters#structfield.stream_id). #[inline] #[allow(clippy::type_complexity)] - pub fn ppid(self, value: T0) -> SendNotificationBuilder<(T0,)> + pub fn stream_id(self, value: T0) -> SctpStreamParametersBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + T0: ::planus::WriteAsDefault, { - SendNotificationBuilder((value,)) + SctpStreamParametersBuilder((value,)) } - /// Sets the [`ppid` field](SendNotification#structfield.ppid) to the default value. + /// Sets the [`stream_id` field](SctpStreamParameters#structfield.stream_id) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn ppid_as_default(self) -> SendNotificationBuilder<(::planus::DefaultValue,)> { - self.ppid(::planus::DefaultValue) + pub fn stream_id_as_default( + self, + ) -> SctpStreamParametersBuilder<(::planus::DefaultValue,)> { + self.stream_id(::planus::DefaultValue) } } - impl SendNotificationBuilder<(T0,)> { - /// Setter for the [`data` field](SendNotification#structfield.data). + impl SctpStreamParametersBuilder<(T0,)> { + /// Setter for the [`ordered` field](SctpStreamParameters#structfield.ordered). #[inline] #[allow(clippy::type_complexity)] - pub fn data(self, value: T1) -> SendNotificationBuilder<(T0, T1)> + pub fn ordered(self, value: T1) -> SctpStreamParametersBuilder<(T0, T1)> where - T1: ::planus::WriteAsUnion, + T1: ::planus::WriteAsOptional, { let (v0,) = self.0; - SendNotificationBuilder((v0, value)) + 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 SendNotificationBuilder<(T0, T1)> { - /// Setter for the [`subchannels` field](SendNotification#structfield.subchannels). + 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 subchannels(self, value: T2) -> SendNotificationBuilder<(T0, T1, T2)> + pub fn max_packet_life_time( + self, + value: T2, + ) -> SctpStreamParametersBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, + T2: ::planus::WriteAsOptional, { let (v0, v1) = self.0; - SendNotificationBuilder((v0, v1, value)) + SctpStreamParametersBuilder((v0, v1, value)) } - /// Sets the [`subchannels` field](SendNotification#structfield.subchannels) to null. + /// Sets the [`max_packet_life_time` field](SctpStreamParameters#structfield.max_packet_life_time) to null. #[inline] - #[allow(clippy::type_complexity)] - pub fn subchannels_as_null(self) -> SendNotificationBuilder<(T0, T1, ())> { - self.subchannels(()) + #[allow(clippy::type_complexity)] + pub fn max_packet_life_time_as_null( + self, + ) -> SctpStreamParametersBuilder<(T0, T1, ())> { + self.max_packet_life_time(()) } } - impl SendNotificationBuilder<(T0, T1, T2)> { - /// Setter for the [`required_subchannel` field](SendNotification#structfield.required_subchannel). + impl SctpStreamParametersBuilder<(T0, T1, T2)> { + /// Setter for the [`max_retransmits` field](SctpStreamParameters#structfield.max_retransmits). #[inline] #[allow(clippy::type_complexity)] - pub fn required_subchannel( + pub fn max_retransmits( self, value: T3, - ) -> SendNotificationBuilder<(T0, T1, T2, T3)> + ) -> SctpStreamParametersBuilder<(T0, T1, T2, T3)> where T3: ::planus::WriteAsOptional, { let (v0, v1, v2) = self.0; - SendNotificationBuilder((v0, v1, v2, value)) + SctpStreamParametersBuilder((v0, v1, v2, value)) } - /// Sets the [`required_subchannel` field](SendNotification#structfield.required_subchannel) to null. + /// Sets the [`max_retransmits` field](SctpStreamParameters#structfield.max_retransmits) to null. #[inline] #[allow(clippy::type_complexity)] - pub fn required_subchannel_as_null( + pub fn max_retransmits_as_null( self, - ) -> SendNotificationBuilder<(T0, T1, T2, ())> { - self.required_subchannel(()) + ) -> SctpStreamParametersBuilder<(T0, T1, T2, ())> { + self.max_retransmits(()) } } - impl SendNotificationBuilder<(T0, T1, T2, T3)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SendNotification]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsUnion, - T2: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsOptional, + T2: ::planus::WriteAsOptional, T3: ::planus::WriteAsOptional, - > ::planus::WriteAs<::planus::Offset> - for SendNotificationBuilder<(T0, T1, T2, T3)> + > ::planus::WriteAs<::planus::Offset> + for SctpStreamParametersBuilder<(T0, T1, T2, T3)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsUnion, - T2: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsOptional, + T2: ::planus::WriteAsOptional, T3: ::planus::WriteAsOptional, - > ::planus::WriteAsOptional<::planus::Offset> - for SendNotificationBuilder<(T0, T1, T2, T3)> + > ::planus::WriteAsOptional<::planus::Offset> + for SctpStreamParametersBuilder<(T0, T1, T2, T3)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsUnion, - T2: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAsOptional, + T2: ::planus::WriteAsOptional, T3: ::planus::WriteAsOptional, - > ::planus::WriteAsOffset - for SendNotificationBuilder<(T0, T1, T2, T3)> + > ::planus::WriteAsOffset + for SctpStreamParametersBuilder<(T0, T1, T2, T3)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { let (v0, v1, v2, v3) = &self.0; - SendNotification::create(builder, v0, v1, v2, v3) + SctpStreamParameters::create(builder, v0, v1, v2, v3) } } - /// Reference to a deserialized [SendNotification]. + /// Reference to a deserialized [SctpStreamParameters]. #[derive(Copy, Clone)] - pub struct SendNotificationRef<'a>(::planus::table_reader::Table<'a>); + pub struct SctpStreamParametersRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> SendNotificationRef<'a> { - /// Getter for the [`ppid` field](SendNotification#structfield.ppid). + impl<'a> SctpStreamParametersRef<'a> { + /// Getter for the [`stream_id` field](SctpStreamParameters#structfield.stream_id). #[inline] - pub fn ppid(&self) -> ::planus::Result { + pub fn stream_id(&self) -> ::planus::Result { ::core::result::Result::Ok( - self.0.access(0, "SendNotification", "ppid")?.unwrap_or(0), + self.0 + .access(0, "SctpStreamParameters", "stream_id")? + .unwrap_or(0), ) } - /// Getter for the [`data` field](SendNotification#structfield.data). + /// Getter for the [`ordered` field](SctpStreamParameters#structfield.ordered). #[inline] - pub fn data(&self) -> ::planus::Result> { - self.0.access_union_required(1, "SendNotification", "data") + pub fn ordered(&self) -> ::planus::Result<::core::option::Option> { + self.0.access(1, "SctpStreamParameters", "ordered") } - /// Getter for the [`subchannels` field](SendNotification#structfield.subchannels). + /// Getter for the [`max_packet_life_time` field](SctpStreamParameters#structfield.max_packet_life_time). #[inline] - pub fn subchannels( + pub fn max_packet_life_time( &self, - ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, u16>>> - { - self.0.access(3, "SendNotification", "subchannels") + ) -> ::planus::Result<::core::option::Option> { + self.0 + .access(2, "SctpStreamParameters", "max_packet_life_time") } - /// Getter for the [`required_subchannel` field](SendNotification#structfield.required_subchannel). + /// Getter for the [`max_retransmits` field](SctpStreamParameters#structfield.max_retransmits). #[inline] - pub fn required_subchannel(&self) -> ::planus::Result<::core::option::Option> { - self.0.access(4, "SendNotification", "required_subchannel") + pub fn max_retransmits(&self) -> ::planus::Result<::core::option::Option> { + self.0.access(3, "SctpStreamParameters", "max_retransmits") } } - impl<'a> ::core::fmt::Debug for SendNotificationRef<'a> { + 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("SendNotificationRef"); - f.field("ppid", &self.ppid()); - f.field("data", &self.data()); - if let ::core::option::Option::Some(field_subchannels) = - self.subchannels().transpose() + 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("subchannels", &field_subchannels); + f.field("ordered", &field_ordered); } - if let ::core::option::Option::Some(field_required_subchannel) = - self.required_subchannel().transpose() + if let ::core::option::Option::Some(field_max_packet_life_time) = + self.max_packet_life_time().transpose() { - f.field("required_subchannel", &field_required_subchannel); + 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 SendNotification { + impl<'a> ::core::convert::TryFrom> for SctpStreamParameters { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: SendNotificationRef<'a>) -> ::planus::Result { + fn try_from(value: SctpStreamParametersRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - ppid: ::core::convert::TryInto::try_into(value.ppid()?)?, - data: ::core::convert::TryInto::try_into(value.data()?)?, - subchannels: if let ::core::option::Option::Some(subchannels) = - value.subchannels()? + 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(subchannels.to_vec()?) + ::core::option::Option::Some(::core::convert::TryInto::try_into( + max_packet_life_time, + )?) } else { ::core::option::Option::None }, - required_subchannel: if let ::core::option::Option::Some( - required_subchannel, - ) = value.required_subchannel()? + max_retransmits: if let ::core::option::Option::Some(max_retransmits) = + value.max_retransmits()? { ::core::option::Option::Some(::core::convert::TryInto::try_into( - required_subchannel, + max_retransmits, )?) } else { ::core::option::Option::None @@ -29867,7 +30124,7 @@ mod root { } } - impl<'a> ::planus::TableRead<'a> for SendNotificationRef<'a> { + impl<'a> ::planus::TableRead<'a> for SctpStreamParametersRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -29879,7 +30136,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for SendNotificationRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for SctpStreamParametersRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -29889,7 +30146,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[SendNotificationRef]", + "[SctpStreamParametersRef]", "get", buffer.offset_from_start, ) @@ -29897,8 +30154,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for SendNotification { - type Value = ::planus::Offset; + 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 { @@ -29907,7 +30164,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -29922,7 +30179,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for SendNotificationRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for SctpStreamParametersRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -29932,7 +30189,11 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[SendNotificationRef]", "read_as_root", 0) + error_kind.with_error_location( + "[SctpStreamParametersRef]", + "read_as_root", + 0, + ) }) } } @@ -30997,7 +31258,7 @@ mod root { /// The enum `Protocol` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `Protocol` in the file `../worker/fbs/transport.fbs:10` + /// * Enum `Protocol` in the file `../worker/fbs/transport.fbs:11` #[derive( Copy, Clone, @@ -31167,7 +31428,7 @@ mod root { /// The table `ListenInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ListenInfo` in the file `../worker/fbs/transport.fbs:15` + /// * Table `ListenInfo` in the file `../worker/fbs/transport.fbs:16` #[derive( Clone, Debug, @@ -31681,7 +31942,7 @@ mod root { /// The table `RestartIceResponse` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `RestartIceResponse` in the file `../worker/fbs/transport.fbs:24` + /// * Table `RestartIceResponse` in the file `../worker/fbs/transport.fbs:25` #[derive( Clone, Debug, @@ -32030,7 +32291,7 @@ mod root { /// The table `ProduceRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ProduceRequest` in the file `../worker/fbs/transport.fbs:30` + /// * Table `ProduceRequest` in the file `../worker/fbs/transport.fbs:31` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -32538,7 +32799,7 @@ mod root { /// The table `ProduceResponse` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ProduceResponse` in the file `../worker/fbs/transport.fbs:39` + /// * Table `ProduceResponse` in the file `../worker/fbs/transport.fbs:40` #[derive( Clone, Debug, @@ -32839,7 +33100,7 @@ mod root { /// The table `ConsumeRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ConsumeRequest` in the file `../worker/fbs/transport.fbs:43` + /// * Table `ConsumeRequest` in the file `../worker/fbs/transport.fbs:44` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -33546,7 +33807,7 @@ mod root { /// The table `ConsumeResponse` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ConsumeResponse` in the file `../worker/fbs/transport.fbs:55` + /// * Table `ConsumeResponse` in the file `../worker/fbs/transport.fbs:56` #[derive( Clone, Debug, @@ -33984,7 +34245,7 @@ mod root { /// The table `ProduceDataRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ProduceDataRequest` in the file `../worker/fbs/transport.fbs:62` + /// * Table `ProduceDataRequest` in the file `../worker/fbs/transport.fbs:63` #[derive( Clone, Debug, @@ -34000,7 +34261,7 @@ mod root { /// 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_: ::planus::alloc::string::String, + 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, @@ -34024,7 +34285,10 @@ mod root { pub fn create( builder: &mut ::planus::Builder, field_data_producer_id: impl ::planus::WriteAs<::planus::Offset>, - field_type_: 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, >, @@ -34037,7 +34301,8 @@ mod root { 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); + 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); @@ -34047,7 +34312,6 @@ mod root { 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>(1); if prepared_sctp_stream_parameters.is_some() { table_writer.write_entry::<::planus::Offset>(2); } @@ -34057,6 +34321,9 @@ mod root { 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); } @@ -34064,7 +34331,6 @@ mod root { unsafe { table_writer.finish(builder, |object_writer| { object_writer.write::<_, _, 4>(&prepared_data_producer_id); - object_writer.write::<_, _, 4>(&prepared_type_); if let ::core::option::Option::Some(prepared_sctp_stream_parameters) = prepared_sctp_stream_parameters { @@ -34078,6 +34344,9 @@ mod root { { 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); } @@ -34120,7 +34389,7 @@ mod root { ProduceDataRequest::create( builder, &self.data_producer_id, - &self.type_, + self.type_, &self.sctp_stream_parameters, &self.label, &self.protocol, @@ -34154,11 +34423,23 @@ mod root { #[allow(clippy::type_complexity)] pub fn type_(self, value: T1) -> ProduceDataRequestBuilder<(T0, T1)> where - T1: ::planus::WriteAs<::planus::Offset>, + 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)> { @@ -34273,7 +34554,10 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault< + super::data_producer::Type, + super::data_producer::Type, + >, T2: ::planus::WriteAsOptional< ::planus::Offset, >, @@ -34296,7 +34580,10 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault< + super::data_producer::Type, + super::data_producer::Type, + >, T2: ::planus::WriteAsOptional< ::planus::Offset, >, @@ -34319,7 +34606,10 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, - T1: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault< + super::data_producer::Type, + super::data_producer::Type, + >, T2: ::planus::WriteAsOptional< ::planus::Offset, >, @@ -34353,8 +34643,12 @@ mod root { /// Getter for the [`type` field](ProduceDataRequest#structfield.type_). #[inline] - pub fn type_(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "ProduceDataRequest", "type_") + 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). @@ -34532,7 +34826,7 @@ mod root { /// The table `ConsumeDataRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `ConsumeDataRequest` in the file `../worker/fbs/transport.fbs:71` + /// * Table `ConsumeDataRequest` in the file `../worker/fbs/transport.fbs:72` #[derive( Clone, Debug, @@ -34550,7 +34844,7 @@ mod root { /// 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_: ::planus::alloc::string::String, + 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, @@ -34577,7 +34871,10 @@ mod root { 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::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, >, @@ -34592,7 +34889,8 @@ mod root { ) -> ::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); + 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); @@ -34604,7 +34902,6 @@ mod root { ::core::default::Default::default(); table_writer.write_entry::<::planus::Offset>(0); table_writer.write_entry::<::planus::Offset>(1); - table_writer.write_entry::<::planus::Offset>(2); if prepared_sctp_stream_parameters.is_some() { table_writer.write_entry::<::planus::Offset>(3); } @@ -34617,6 +34914,9 @@ mod root { 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); } @@ -34625,7 +34925,6 @@ mod root { table_writer.finish(builder, |object_writer| { object_writer.write::<_, _, 4>(&prepared_data_consumer_id); object_writer.write::<_, _, 4>(&prepared_data_producer_id); - object_writer.write::<_, _, 4>(&prepared_type_); if let ::core::option::Option::Some(prepared_sctp_stream_parameters) = prepared_sctp_stream_parameters { @@ -34644,6 +34943,9 @@ mod root { { 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); } @@ -34687,7 +34989,7 @@ mod root { builder, &self.data_consumer_id, &self.data_producer_id, - &self.type_, + self.type_, &self.sctp_stream_parameters, &self.label, &self.protocol, @@ -34735,11 +35037,23 @@ mod root { #[allow(clippy::type_complexity)] pub fn type_(self, value: T2) -> ConsumeDataRequestBuilder<(T0, T1, T2)> where - T2: ::planus::WriteAs<::planus::Offset>, + 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)> { @@ -34882,7 +35196,10 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAs<::planus::Offset>, + T2: ::planus::WriteAsDefault< + super::data_producer::Type, + super::data_producer::Type, + >, T3: ::planus::WriteAsOptional< ::planus::Offset, >, @@ -34907,7 +35224,10 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAs<::planus::Offset>, + T2: ::planus::WriteAsDefault< + super::data_producer::Type, + super::data_producer::Type, + >, T3: ::planus::WriteAsOptional< ::planus::Offset, >, @@ -34932,7 +35252,10 @@ mod root { impl< T0: ::planus::WriteAs<::planus::Offset>, T1: ::planus::WriteAs<::planus::Offset>, - T2: ::planus::WriteAs<::planus::Offset>, + T2: ::planus::WriteAsDefault< + super::data_producer::Type, + super::data_producer::Type, + >, T3: ::planus::WriteAsOptional< ::planus::Offset, >, @@ -34974,8 +35297,12 @@ mod root { /// Getter for the [`type` field](ConsumeDataRequest#structfield.type_). #[inline] - pub fn type_(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(2, "ConsumeDataRequest", "type_") + 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). @@ -35178,7 +35505,7 @@ mod root { /// The table `Tuple` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Tuple` in the file `../worker/fbs/transport.fbs:82` + /// * Table `Tuple` in the file `../worker/fbs/transport.fbs:83` #[derive( Clone, Debug, @@ -35632,7 +35959,7 @@ mod root { /// The table `RtpListener` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `RtpListener` in the file `../worker/fbs/transport.fbs:90` + /// * Table `RtpListener` in the file `../worker/fbs/transport.fbs:91` #[derive( Clone, Debug, @@ -35995,7 +36322,7 @@ mod root { /// The table `SctpListener` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SctpListener` in the file `../worker/fbs/transport.fbs:96` + /// * Table `SctpListener` in the file `../worker/fbs/transport.fbs:97` #[derive( Clone, Debug, @@ -36269,7 +36596,7 @@ mod root { /// The table `RecvRtpHeaderExtensions` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `RecvRtpHeaderExtensions` in the file `../worker/fbs/transport.fbs:100` + /// * Table `RecvRtpHeaderExtensions` in the file `../worker/fbs/transport.fbs:101` #[derive( Clone, Debug, @@ -36792,7 +37119,7 @@ mod root { /// The table `Options` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Options` in the file `../worker/fbs/transport.fbs:108` + /// * Table `Options` in the file `../worker/fbs/transport.fbs:109` #[derive( Clone, Debug, @@ -37488,7 +37815,7 @@ mod root { /// The enum `TraceEventType` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `TraceEventType` in the file `../worker/fbs/transport.fbs:121` + /// * Enum `TraceEventType` in the file `../worker/fbs/transport.fbs:122` #[derive( Copy, Clone, @@ -37658,7 +37985,7 @@ mod root { /// The table `Dump` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Dump` in the file `../worker/fbs/transport.fbs:126` + /// * Table `Dump` in the file `../worker/fbs/transport.fbs:127` #[derive( Clone, Debug, @@ -38701,7 +39028,7 @@ mod root { /// The table `Stats` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Stats` in the file `../worker/fbs/transport.fbs:144` + /// * Table `Stats` in the file `../worker/fbs/transport.fbs:145` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -41362,7 +41689,7 @@ mod root { /// The table `SetMaxIncomingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMaxIncomingBitrateRequest` in the file `../worker/fbs/transport.fbs:171` + /// * Table `SetMaxIncomingBitrateRequest` in the file `../worker/fbs/transport.fbs:172` #[derive( Clone, Debug, @@ -41670,7 +41997,7 @@ mod root { /// The table `SetMaxOutgoingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMaxOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:175` + /// * Table `SetMaxOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:176` #[derive( Clone, Debug, @@ -41978,7 +42305,7 @@ mod root { /// The table `SetMinOutgoingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMinOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:179` + /// * Table `SetMinOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:180` #[derive( Clone, Debug, @@ -42286,7 +42613,7 @@ mod root { /// The table `EnableTraceEventRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/transport.fbs:183` + /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/transport.fbs:184` #[derive( Clone, Debug, @@ -42564,7 +42891,7 @@ mod root { /// The table `CloseProducerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseProducerRequest` in the file `../worker/fbs/transport.fbs:187` + /// * Table `CloseProducerRequest` in the file `../worker/fbs/transport.fbs:188` #[derive( Clone, Debug, @@ -42830,7 +43157,7 @@ mod root { /// The table `CloseConsumerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseConsumerRequest` in the file `../worker/fbs/transport.fbs:191` + /// * Table `CloseConsumerRequest` in the file `../worker/fbs/transport.fbs:192` #[derive( Clone, Debug, @@ -43096,7 +43423,7 @@ mod root { /// The table `CloseDataProducerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseDataProducerRequest` in the file `../worker/fbs/transport.fbs:195` + /// * Table `CloseDataProducerRequest` in the file `../worker/fbs/transport.fbs:196` #[derive( Clone, Debug, @@ -43371,7 +43698,7 @@ mod root { /// The table `CloseDataConsumerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseDataConsumerRequest` in the file `../worker/fbs/transport.fbs:199` + /// * Table `CloseDataConsumerRequest` in the file `../worker/fbs/transport.fbs:200` #[derive( Clone, Debug, @@ -43646,7 +43973,7 @@ mod root { /// The table `SendRtcpNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SendRtcpNotification` in the file `../worker/fbs/transport.fbs:205` + /// * Table `SendRtcpNotification` in the file `../worker/fbs/transport.fbs:206` #[derive( Clone, Debug, @@ -43911,7 +44238,7 @@ mod root { /// The table `SctpStateChangeNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SctpStateChangeNotification` in the file `../worker/fbs/transport.fbs:211` + /// * Table `SctpStateChangeNotification` in the file `../worker/fbs/transport.fbs:212` #[derive( Clone, Debug, @@ -44232,7 +44559,7 @@ mod root { /// The union `TraceInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:215` + /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:216` #[derive( Clone, Debug, @@ -44385,7 +44712,7 @@ mod root { /// The enum `BweType` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:219` + /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:220` #[derive( Copy, Clone, @@ -44555,7 +44882,7 @@ mod root { /// The table `BweTraceInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:224` + /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:225` #[derive( Clone, Debug, @@ -45233,7 +45560,7 @@ mod root { /// The table `TraceNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:235` + /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:236` #[derive( Clone, Debug, diff --git a/rust/src/messages.rs b/rust/src/messages.rs index 6001bbf715..441c5c6d43 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -3,17 +3,17 @@ use crate::audio_level_observer::AudioLevelObserverOptions; use crate::consumer::{ ConsumerId, ConsumerLayers, ConsumerScore, ConsumerTraceEventType, ConsumerType, }; -use crate::data_consumer::{DataConsumerDump, DataConsumerId, DataConsumerStat, DataConsumerType}; -use crate::data_producer::{DataProducerDump, DataProducerId, DataProducerStat, DataProducerType}; +use crate::data_consumer::{DataConsumerId, DataConsumerType}; +use crate::data_producer::{DataProducerId, DataProducerType}; use crate::data_structures::{ DtlsParameters, DtlsRole, DtlsState, IceCandidate, IceParameters, IceRole, IceState, ListenInfo, SctpState, TransportTuple, }; use crate::direct_transport::DirectTransportOptions; use crate::fbs::{ - active_speaker_observer, audio_level_observer, consumer, direct_transport, message, - pipe_transport, plain_transport, producer, request, response, router, rtp_observer, transport, - web_rtc_transport, worker, + 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_transport, worker, }; use crate::ortc::RtpMapping; use crate::pipe_transport::PipeTransportOptions; @@ -82,193 +82,13 @@ where -> Result>; } -pub(crate) trait Notification: Debug + Serialize { +pub(crate) trait NotificationFbs: Debug { + /// Notification event to call on worker. + const EVENT: notification::Event; type HandlerId: Display; - /// Request event to call on worker. - fn as_event(&self) -> &'static str; -} - -// macro_rules! request_response_fbs { -// ( -// $handler_id_type: ty, -// $method: literal, -// $request_struct_name: ident { $( $(#[$request_field_name_attributes: meta])? $request_field_name: ident: $request_field_type: ty$(,)? )* }, -// $existing_response_type: ty, -// $default_for_soft_error: expr $(,)? -// ) => { -// #[derive(Debug, Serialize)] -// #[serde(rename_all = "camelCase")] -// pub(crate) struct $request_struct_name { -// $( -// $(#[$request_field_name_attributes])* -// pub(crate) $request_field_name: $request_field_type, -// )* -// } -// -// impl RequestFbs for $request_struct_name { -// type HandlerId = $handler_id_type; -// type Response = $existing_response_type; -// -// fn as_method(&self) -> &'static str { -// $method -// } -// -// fn default_for_soft_error() -> Option { -// $default_for_soft_error -// } -// } -// }; -// // Call above macro with no default for soft error -// ( -// $handler_id_type: ty, -// $method: literal, -// $request_struct_name: ident $request_struct_impl: tt $(,)? -// $existing_response_type: ty $(,)? -// ) => { -// request_response!( -// $handler_id_type, -// $method, -// $request_struct_name $request_struct_impl, -// $existing_response_type, -// None, -// ); -// }; -// // Call above macro with unit type as expected response -// ( -// $handler_id_type: ty, -// $method: literal, -// $request_struct_name: ident $request_struct_impl: tt $(,)? -// ) => { -// request_response!( -// $handler_id_type, -// $method, -// $request_struct_name $request_struct_impl, -// (), -// None, -// ); -// }; -// ( -// $handler_id_type: ty, -// $method: literal, -// $request_struct_name: ident { $( $(#[$request_field_name_attributes: meta])? $request_field_name: ident: $request_field_type: ty$(,)? )* }, -// $response_struct_name: ident { $( $response_field_name: ident: $response_field_type: ty$(,)? )* }, -// ) => { -// #[derive(Debug, Serialize)] -// #[serde(rename_all = "camelCase")] -// pub(crate) struct $request_struct_name { -// $( -// $(#[$request_field_name_attributes])* -// pub(crate) $request_field_name: $request_field_type, -// )* -// } -// -// #[derive(Debug, Deserialize)] -// #[serde(rename_all = "camelCase")] -// pub(crate) struct $response_struct_name { -// $( pub(crate) $response_field_name: $response_field_type, )* -// } -// -// impl RequestFbs for $request_struct_name { -// type HandlerId = $handler_id_type; -// type Response = $response_struct_name; -// -// fn as_method(&self) -> &'static str { -// $method -// } -// } -// }; -// } - -macro_rules! request_response { - ( - $handler_id_type: ty, - $method: literal, - $request_struct_name: ident { $( $(#[$request_field_name_attributes: meta])? $request_field_name: ident: $request_field_type: ty$(,)? )* }, - $existing_response_type: ty, - $default_for_soft_error: expr $(,)? - ) => { - #[derive(Debug, Serialize)] - #[serde(rename_all = "camelCase")] - pub(crate) struct $request_struct_name { - $( - $(#[$request_field_name_attributes])* - pub(crate) $request_field_name: $request_field_type, - )* - } - - impl Request for $request_struct_name { - type HandlerId = $handler_id_type; - type Response = $existing_response_type; - - fn as_method(&self) -> &'static str { - $method - } - - fn default_for_soft_error() -> Option { - $default_for_soft_error - } - } - }; - // Call above macro with no default for soft error - ( - $handler_id_type: ty, - $method: literal, - $request_struct_name: ident $request_struct_impl: tt $(,)? - $existing_response_type: ty $(,)? - ) => { - request_response!( - $handler_id_type, - $method, - $request_struct_name $request_struct_impl, - $existing_response_type, - None, - ); - }; - // Call above macro with unit type as expected response - ( - $handler_id_type: ty, - $method: literal, - $request_struct_name: ident $request_struct_impl: tt $(,)? - ) => { - request_response!( - $handler_id_type, - $method, - $request_struct_name $request_struct_impl, - (), - None, - ); - }; - ( - $handler_id_type: ty, - $method: literal, - $request_struct_name: ident { $( $(#[$request_field_name_attributes: meta])? $request_field_name: ident: $request_field_type: ty$(,)? )* }, - $response_struct_name: ident { $( $response_field_name: ident: $response_field_type: ty$(,)? )* }, - ) => { - #[derive(Debug, Serialize)] - #[serde(rename_all = "camelCase")] - pub(crate) struct $request_struct_name { - $( - $(#[$request_field_name_attributes])* - pub(crate) $request_field_name: $request_field_type, - )* - } - - #[derive(Debug, Deserialize)] - #[serde(rename_all = "camelCase")] - pub(crate) struct $response_struct_name { - $( pub(crate) $response_field_name: $response_field_type, )* - } - - impl Request for $request_struct_name { - type HandlerId = $handler_id_type; - type Response = $response_struct_name; - - fn as_method(&self) -> &'static str { - $method - } - } - }; + /// Get a serialized message out of this notification. + fn into_bytes(self, handler_id: Self::HandlerId) -> Vec; } #[derive(Debug)] @@ -1922,49 +1742,178 @@ impl RequestFbs for TransportConsumeRequest { } } -request_response!( - TransportId, - "transport.produceData", - TransportProduceDataRequest { - data_producer_id: DataProducerId, - r#type: DataProducerType, - #[serde(skip_serializing_if = "Option::is_none")] - sctp_stream_parameters: Option, - label: String, - protocol: String, - paused: bool, - }, - TransportProduceDataResponse { - r#type: DataProducerType, - sctp_stream_parameters: Option, - label: String, - protocol: String, - paused: bool, - }, -); - -request_response!( - TransportId, - "transport.consumeData", - TransportConsumeDataRequest { - data_consumer_id: DataConsumerId, - data_producer_id: DataProducerId, - r#type: DataConsumerType, - #[serde(skip_serializing_if = "Option::is_none")] - sctp_stream_parameters: Option, - label: String, - protocol: String, - paused: bool, - }, - TransportConsumeDataResponse { - r#type: DataConsumerType, - sctp_stream_parameters: Option, - label: String, - protocol: String, - paused: bool, - data_producer_paused: bool, - }, -); +#[derive(Debug)] +pub(crate) struct TransportProduceDataRequest { + pub(crate) data_producer_id: DataProducerId, + pub(crate) r#type: DataProducerType, + // #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) sctp_stream_parameters: Option, + pub(crate) label: String, + pub(crate) protocol: String, + pub(crate) paused: bool, +} + +#[derive(Debug)] +pub(crate) struct TransportProduceDataResponse { + pub(crate) r#type: DataProducerType, + pub(crate) sctp_stream_parameters: Option, + pub(crate) label: String, + pub(crate) protocol: String, + pub(crate) paused: bool, +} + +impl RequestFbs for TransportProduceDataRequest { + const METHOD: request::Method = request::Method::TransportProduceData; + type HandlerId = TransportId; + type Response = TransportProduceDataResponse; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = transport::ProduceDataRequest::create( + &mut builder, + self.data_producer_id.to_string(), + match self.r#type { + DataProducerType::Sctp => data_producer::Type::Sctp, + DataProducerType::Direct => data_producer::Type::Direct, + }, + self.sctp_stream_parameters + .map(SctpStreamParameters::to_fbs), + if self.label.is_empty() { + None + } else { + Some(self.label) + }, + if self.protocol.is_empty() { + None + } else { + Some(self.protocol) + }, + self.paused, + ); + let request_body = request::Body::create_transport_produce_data_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::DataProducerDumpResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(TransportProduceDataResponse { + r#type: match data.type_ { + data_producer::Type::Sctp => DataProducerType::Sctp, + data_producer::Type::Direct => DataProducerType::Direct, + }, + sctp_stream_parameters: data + .sctp_stream_parameters + .map(|stream_parameters| SctpStreamParameters::from_fbs(*stream_parameters)), + label: data.label.to_string(), + protocol: data.protocol.to_string(), + paused: data.paused, + }) + } +} + +#[derive(Debug)] +pub(crate) struct TransportConsumeDataRequest { + pub(crate) data_consumer_id: DataConsumerId, + pub(crate) data_producer_id: DataProducerId, + pub(crate) r#type: DataConsumerType, + pub(crate) sctp_stream_parameters: Option, + pub(crate) label: String, + pub(crate) protocol: String, + pub(crate) paused: bool, +} + +#[derive(Debug)] +pub(crate) struct TransportConsumeDataResponse { + pub(crate) r#type: DataConsumerType, + pub(crate) sctp_stream_parameters: Option, + pub(crate) label: String, + pub(crate) protocol: String, + pub(crate) paused: bool, + pub(crate) data_producer_paused: bool, +} + +impl RequestFbs for TransportConsumeDataRequest { + const METHOD: request::Method = request::Method::TransportConsumeData; + type HandlerId = TransportId; + type Response = TransportConsumeDataResponse; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = transport::ConsumeDataRequest::create( + &mut builder, + self.data_consumer_id.to_string(), + self.data_producer_id.to_string(), + match self.r#type { + DataConsumerType::Sctp => data_producer::Type::Sctp, + DataConsumerType::Direct => data_producer::Type::Direct, + }, + self.sctp_stream_parameters + .map(SctpStreamParameters::to_fbs), + if self.label.is_empty() { + None + } else { + Some(self.label) + }, + if self.protocol.is_empty() { + None + } else { + Some(self.protocol) + }, + self.paused, + // TODO. + None::>, + ); + let request_body = request::Body::create_transport_consume_data_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::DataConsumerDumpResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(TransportConsumeDataResponse { + r#type: match data.type_ { + data_producer::Type::Sctp => DataConsumerType::Sctp, + data_producer::Type::Direct => DataConsumerType::Direct, + }, + sctp_stream_parameters: data + .sctp_stream_parameters + .map(|stream_parameters| SctpStreamParameters::from_fbs(*stream_parameters)), + label: data.label.to_string(), + protocol: data.protocol.to_string(), + paused: data.paused, + data_producer_paused: data.data_producer_paused, + }) + } +} #[derive(Debug)] pub(crate) struct TransportEnableTraceEventRequest { @@ -2014,13 +1963,31 @@ impl RequestFbs for TransportEnableTraceEventRequest { #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] -pub(crate) struct TransportSendRtcpNotification {} +pub(crate) struct TransportSendRtcpNotification { + pub(crate) rtcp_packet: Vec, +} -impl Notification for TransportSendRtcpNotification { +impl NotificationFbs for TransportSendRtcpNotification { + const EVENT: notification::Event = notification::Event::TransportSendRtcp; type HandlerId = TransportId; - fn as_event(&self) -> &'static str { - "transport.sendRtcp" + fn into_bytes(self, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let data = transport::SendRtcpNotification::create(&mut builder, self.rtcp_packet); + let notification_body = + notification::Body::create_transport_send_rtcp_notification(&mut builder, data); + + let notification = notification::Notification::create( + &mut builder, + handler_id.to_string(), + Self::EVENT, + Some(notification_body), + ); + let message_body = message::Body::create_notification(&mut builder, notification); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() } } @@ -2243,13 +2210,31 @@ impl RequestFbs for ProducerEnableTraceEventRequest { #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] -pub(crate) struct ProducerSendNotification {} +pub(crate) struct ProducerSendNotification { + pub(crate) rtp_packet: Vec, +} -impl Notification for ProducerSendNotification { +impl NotificationFbs for ProducerSendNotification { + const EVENT: notification::Event = notification::Event::ProducerSend; type HandlerId = ProducerId; - fn as_event(&self) -> &'static str { - "producer.send" + fn into_bytes(self, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let data = producer::SendNotification::create(&mut builder, self.rtp_packet); + let notification_body = + notification::Body::create_producer_send_notification(&mut builder, data); + + let notification = notification::Notification::create( + &mut builder, + handler_id.to_string(), + Self::EVENT, + Some(notification_body), + ); + let message_body = message::Body::create_notification(&mut builder, notification); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() } } @@ -2594,126 +2579,515 @@ impl RequestFbs for ConsumerEnableTraceEventRequest { } } -request_response!( - TransportId, - "transport.closeDataProducer", - DataProducerCloseRequest { - data_producer_id: DataProducerId, - }, - (), - Some(()), -); - -request_response!( - DataProducerId, - "dataProducer.dump", - DataProducerDumpRequest {}, - DataProducerDump, -); - -request_response!( - DataProducerId, - "dataProducer.getStats", - DataProducerGetStatsRequest {}, - Vec, -); - -request_response!( - DataProducerId, - "dataProducer.pause", - DataProducerPauseRequest {} -); - -request_response!( - DataProducerId, - "dataProducer.resume", - DataProducerResumeRequest {} -); - -#[derive(Debug, Copy, Clone, Serialize)] -#[serde(into = "u32")] -pub(crate) struct DataProducerSendNotification { - #[serde(flatten)] - pub(crate) ppid: u32, +#[derive(Debug)] +pub(crate) struct DataProducerCloseRequest { + pub(crate) data_producer_id: DataProducerId, } -impl From for u32 { - fn from(notification: DataProducerSendNotification) -> Self { - notification.ppid +impl RequestFbs for DataProducerCloseRequest { + const METHOD: request::Method = request::Method::TransportCloseDataproducer; + type HandlerId = TransportId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = transport::CloseDataProducerRequest::create( + &mut builder, + self.data_producer_id.to_string(), + ); + let request_body = + request::Body::create_transport_close_data_producer_request(&mut builder, data); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) } } -impl Notification for DataProducerSendNotification { +#[derive(Debug)] +pub(crate) struct DataProducerDumpRequest {} + +impl RequestFbs for DataProducerDumpRequest { + const METHOD: request::Method = request::Method::DataproducerDump; type HandlerId = DataProducerId; + type Response = response::Body; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } - fn as_event(&self) -> &'static str { - "dataProducer.send" + fn convert_response( + response: Option, + ) -> Result> { + match response { + Some(data) => Ok(data), + _ => { + panic!("Wrong message from worker: {response:?}"); + } + } } } -request_response!( - TransportId, - "transport.closeDataConsumer", - DataConsumerCloseRequest { - data_consumer_id: DataConsumerId, - }, - (), - Some(()), -); - -request_response!( - DataConsumerId, - "dataConsumer.dump", - DataConsumerDumpRequest {}, - DataConsumerDump, -); - -request_response!( - DataConsumerId, - "dataConsumer.getStats", - DataConsumerGetStatsRequest {}, - Vec, -); - -request_response!( - DataConsumerId, - "dataConsumer.pause", - DataConsumerPauseRequest {}, -); - -request_response!( - DataConsumerId, - "dataConsumer.resume", - DataConsumerResumeRequest {}, -); - -request_response!( - DataConsumerId, - "dataConsumer.getBufferedAmount", - DataConsumerGetBufferedAmountRequest {}, - DataConsumerGetBufferedAmountResponse { - buffered_amount: u32, - }, -); +#[derive(Debug)] +pub(crate) struct DataProducerGetStatsRequest {} -request_response!( - DataConsumerId, - "dataConsumer.setBufferedAmountLowThreshold", - DataConsumerSetBufferedAmountLowThresholdRequest { threshold: u32 }, -); +impl RequestFbs for DataProducerGetStatsRequest { + const METHOD: request::Method = request::Method::DataproducerGetStats; + type HandlerId = DataProducerId; + type Response = response::Body; -#[derive(Debug, Copy, Clone, Serialize)] -#[serde(into = "u32")] -pub(crate) struct DataConsumerSendRequest { - pub(crate) ppid: u32, + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + match response { + Some(data) => Ok(data), + _ => { + panic!("Wrong message from worker: {response:?}"); + } + } + } } -impl Request for DataConsumerSendRequest { - type HandlerId = DataConsumerId; +#[derive(Debug, Serialize)] +pub(crate) struct DataProducerPauseRequest {} + +impl RequestFbs for DataProducerPauseRequest { + const METHOD: request::Method = request::Method::DataproducerPause; + type HandlerId = DataProducerId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug, Serialize)] +pub(crate) struct DataProducerResumeRequest {} + +impl RequestFbs for DataProducerResumeRequest { + const METHOD: request::Method = request::Method::DataproducerResume; + type HandlerId = DataProducerId; type Response = (); - fn as_method(&self) -> &'static str { - "dataConsumer.send" + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug)] +pub(crate) struct DataProducerSendNotification { + pub(crate) ppid: u32, + pub(crate) payload: Vec, +} + +impl NotificationFbs for DataProducerSendNotification { + const EVENT: notification::Event = notification::Event::DataproducerSend; + type HandlerId = DataProducerId; + + fn into_bytes(self, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + // TODO: Implement subchannels. + let subchannels: Vec = vec![]; + let required_subchannel: Option = Default::default(); + let binary_data = data_producer::Binary::create(&mut builder, self.payload); + let binary = data_producer::Data::create_binary(&mut builder, binary_data); + let data = data_producer::SendNotification::create( + &mut builder, + self.ppid, + binary, + subchannels, + required_subchannel, + ); + let notification_body = + notification::Body::create_data_producer_send_notification(&mut builder, data); + + let notification = notification::Notification::create( + &mut builder, + handler_id.to_string(), + Self::EVENT, + Some(notification_body), + ); + let message_body = message::Body::create_notification(&mut builder, notification); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } +} + +#[derive(Debug)] +pub(crate) struct DataConsumerCloseRequest { + pub(crate) data_consumer_id: DataConsumerId, +} + +impl RequestFbs for DataConsumerCloseRequest { + const METHOD: request::Method = request::Method::TransportCloseDataconsumer; + type HandlerId = TransportId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + let data = transport::CloseDataConsumerRequest::create( + &mut builder, + self.data_consumer_id.to_string(), + ); + let request_body = + request::Body::create_transport_close_data_consumer_request(&mut builder, data); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug)] +pub(crate) struct DataConsumerDumpRequest {} + +impl RequestFbs for DataConsumerDumpRequest { + const METHOD: request::Method = request::Method::DataconsumerDump; + type HandlerId = DataConsumerId; + type Response = response::Body; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + match response { + Some(data) => Ok(data), + _ => { + panic!("Wrong message from worker: {response:?}"); + } + } + } +} + +#[derive(Debug)] +pub(crate) struct DataConsumerGetStatsRequest {} + +impl RequestFbs for DataConsumerGetStatsRequest { + const METHOD: request::Method = request::Method::DataconsumerGetStats; + type HandlerId = DataConsumerId; + type Response = response::Body; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + match response { + Some(data) => Ok(data), + _ => { + panic!("Wrong message from worker: {response:?}"); + } + } + } +} + +#[derive(Debug, Serialize)] +pub(crate) struct DataConsumerPauseRequest {} + +impl RequestFbs for DataConsumerPauseRequest { + const METHOD: request::Method = request::Method::DataconsumerPause; + type HandlerId = DataConsumerId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug, Serialize)] +pub(crate) struct DataConsumerResumeRequest {} + +impl RequestFbs for DataConsumerResumeRequest { + const METHOD: request::Method = request::Method::DataconsumerResume; + type HandlerId = DataConsumerId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug, Serialize)] +pub(crate) struct DataConsumerGetBufferedAmountRequest {} + +#[derive(Debug, Serialize)] +pub(crate) struct DataConsumerGetBufferedAmountResponse { + pub(crate) buffered_amount: u32, +} + +impl RequestFbs for DataConsumerGetBufferedAmountRequest { + const METHOD: request::Method = request::Method::DataconsumerGetBufferedAmount; + type HandlerId = DataConsumerId; + type Response = DataConsumerGetBufferedAmountResponse; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + None::, + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::DataConsumerGetBufferedAmountResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(DataConsumerGetBufferedAmountResponse { + buffered_amount: data.buffered_amount, + }) + } +} + +#[derive(Debug, Serialize)] +pub(crate) struct DataConsumerSetBufferedAmountLowThresholdRequest { + pub(crate) threshold: u32, +} + +impl RequestFbs for DataConsumerSetBufferedAmountLowThresholdRequest { + const METHOD: request::Method = request::Method::DataconsumerSetBufferedAmountLowThreshold; + type HandlerId = DataConsumerId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let data = data_consumer::SetBufferedAmountLowThresholdRequest::create( + &mut builder, + self.threshold, + ); + let request_body = + request::Body::create_data_consumer_set_buffered_amount_low_threshold_request( + &mut builder, + data, + ); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) + } +} + +#[derive(Debug, Clone, Serialize)] +#[serde(into = "u32")] +pub(crate) struct DataConsumerSendRequest { + pub(crate) ppid: u32, + pub(crate) payload: Vec, +} + +impl RequestFbs for DataConsumerSendRequest { + const METHOD: request::Method = request::Method::DataconsumerSend; + type HandlerId = DataConsumerId; + type Response = (); + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let binary_data = data_consumer::Binary::create(&mut builder, self.payload); + let binary = data_consumer::Data::create_binary(&mut builder, binary_data); + let data = data_consumer::SendRequest::create(&mut builder, self.ppid, binary); + let request_body = request::Body::create_data_consumer_send_request(&mut builder, data); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + _response: Option, + ) -> Result> { + Ok(()) } } diff --git a/rust/src/router/data_consumer.rs b/rust/src/router/data_consumer.rs index 888183ac25..5f72e4209a 100644 --- a/rust/src/router/data_consumer.rs +++ b/rust/src/router/data_consumer.rs @@ -3,6 +3,7 @@ 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, @@ -11,12 +12,14 @@ use crate::messages::{ use crate::sctp_parameters::SctpStreamParameters; use crate::transport::Transport; use crate::uuid_based_wrapper_type; -use crate::worker::{Channel, RequestError, SubscriptionHandler}; +use crate::worker::{Channel, NotificationParseError, RequestError, SubscriptionHandler}; use async_executor::Executor; use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; +use std::borrow::Cow; +use std::error::Error; // TODO. // use std::borrow::Cow; use std::fmt; @@ -148,6 +151,28 @@ pub struct DataConsumerDump { pub data_producer_paused: bool, } +impl DataConsumerDump { + pub(crate) fn from_fbs(dump: data_consumer::DumpResponse) -> Result> { + Ok(Self { + id: dump.id.parse()?, + data_producer_id: dump.data_producer_id.parse()?, + r#type: if dump.type_ == data_producer::Type::Sctp { + DataConsumerType::Sctp + } else { + DataConsumerType::Direct + }, + label: dump.label, + protocol: dump.protocol, + sctp_stream_parameters: dump + .sctp_stream_parameters + .map(|parameters| SctpStreamParameters::from_fbs(*parameters)), + buffered_amount_low_threshold: dump.buffered_amount_low_threshold, + paused: dump.paused, + data_producer_paused: dump.data_producer_paused, + }) + } +} + /// RTC statistics of the data consumer. #[derive(Debug, Clone, PartialOrd, Eq, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -158,11 +183,24 @@ pub struct DataConsumerStat { pub timestamp: u64, pub label: String, pub protocol: String, - pub messages_sent: usize, - pub bytes_sent: usize, + pub messages_sent: u64, + pub bytes_sent: u64, pub buffered_amount: u32, } +impl DataConsumerStat { + pub(crate) fn from_fbs(stats: &data_consumer::GetStatsResponse) -> Self { + Self { + timestamp: stats.timestamp, + label: stats.label.to_string(), + protocol: stats.protocol.to_string(), + messages_sent: stats.messages_sent, + bytes_sent: stats.bytes_sent, + buffered_amount: stats.buffered_amount, + } + } +} + /// Data consumer type. #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] @@ -180,14 +218,62 @@ enum Notification { DataProducerPause, DataProducerResume, SctpSendBufferFull, - // TODO. - // Message { ppid: u32 }, + Message { + ppid: u32, + data: Vec, + }, #[serde(rename_all = "camelCase")] BufferedAmountLow { buffered_amount: u32, }, } +impl Notification { + pub(crate) fn from_fbs( + notification: notification::NotificationRef<'_>, + ) -> Result { + match notification.event().unwrap() { + notification::Event::DataconsumerDataproducerClose => { + Ok(Notification::DataProducerClose) + } + notification::Event::DataconsumerDataproducerPause => { + Ok(Notification::DataProducerPause) + } + notification::Event::DataconsumerDataproducerResume => { + Ok(Notification::DataProducerResume) + } + notification::Event::DataconsumerSctpSendbufferFull => { + Ok(Notification::SctpSendBufferFull) + } + notification::Event::DataconsumerMessage => { + let Ok(Some(notification::BodyRef::DataConsumerMessageNotification(body))) = + notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + Ok(Notification::Message { + ppid: body.ppid().unwrap(), + data: body.data().unwrap().into(), + }) + } + notification::Event::DataconsumerBufferedAmountLow => { + let Ok(Some(notification::BodyRef::DataConsumerBufferedAmountLowNotification( + body, + ))) = notification.body() + else { + panic!("Wrong message from worker: {notification:?}"); + }; + + Ok(Notification::BufferedAmountLow { + buffered_amount: body.buffered_amount().unwrap(), + }) + } + _ => Err(NotificationParseError::InvalidEvent), + } + } +} + #[derive(Default)] #[allow(clippy::type_complexity)] struct Handlers { @@ -252,7 +338,7 @@ impl Inner { self.executor .spawn(async move { if weak_data_producer.upgrade().is_some() { - if let Err(error) = channel.request(transport_id, request).await { + if let Err(error) = channel.request_fbs(transport_id, request).await { error!("consumer closing failed on drop: {}", error); } } @@ -384,8 +470,8 @@ impl DataConsumer { let data_producer_paused = Arc::clone(&data_producer_paused); let inner_weak = Arc::clone(&inner_weak); - channel.subscribe_to_notifications(id.into(), move |notification| { - match serde_json::from_slice::(notification) { + channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::DataProducerClose => { if !closed.load(Ordering::SeqCst) { @@ -432,13 +518,11 @@ impl DataConsumer { Notification::SctpSendBufferFull => { handlers.sctp_send_buffer_full.call_simple(); } - /* - * TODO. - Notification::Message { ppid } => { - match WebRtcMessage::new(ppid, Cow::from(_notification)) { + Notification::Message { ppid, data } => { + match WebRtcMessage::new(ppid, Cow::from(data)) { Ok(message) => { handlers.message.call(|callback| { - callback(&_notification); + callback(&message); }); } Err(ppid) => { @@ -446,7 +530,6 @@ impl DataConsumer { } } } - */ Notification::BufferedAmountLow { buffered_amount } => { handlers.buffered_amount_low.call(|callback| { callback(buffered_amount); @@ -572,10 +655,17 @@ impl DataConsumer { pub async fn dump(&self) -> Result { debug!("dump()"); - self.inner() + let response = self + .inner() .channel - .request(self.id(), DataConsumerDumpRequest {}) - .await + .request_fbs(self.id(), DataConsumerDumpRequest {}) + .await?; + + if let response::Body::DataConsumerDumpResponse(data) = response { + Ok(DataConsumerDump::from_fbs(*data).expect("Error parsing dump response")) + } else { + panic!("Wrong message from worker"); + } } /// Returns current statistics of the data consumer. @@ -585,10 +675,17 @@ impl DataConsumer { pub async fn get_stats(&self) -> Result, RequestError> { debug!("get_stats()"); - self.inner() + let response = self + .inner() .channel - .request(self.id(), DataConsumerGetStatsRequest {}) - .await + .request_fbs(self.id(), DataConsumerGetStatsRequest {}) + .await?; + + if let response::Body::DataConsumerGetStatsResponse(data) = response { + Ok(vec![DataConsumerStat::from_fbs(&data)]) + } else { + panic!("Wrong message from worker"); + } } /// Pauses the data consumer (no mossage is sent to the consuming endpoint). @@ -597,7 +694,7 @@ impl DataConsumer { self.inner() .channel - .request(self.id(), DataConsumerPauseRequest {}) + .request_fbs(self.id(), DataConsumerPauseRequest {}) .await?; let mut paused = self.inner().paused.lock(); @@ -617,7 +714,7 @@ impl DataConsumer { self.inner() .channel - .request(self.id(), DataConsumerResumeRequest {}) + .request_fbs(self.id(), DataConsumerResumeRequest {}) .await?; let mut paused = self.inner().paused.lock(); @@ -644,7 +741,7 @@ impl DataConsumer { let response = self .inner() .channel - .request(self.id(), DataConsumerGetBufferedAmountRequest {}) + .request_fbs(self.id(), DataConsumerGetBufferedAmountRequest {}) .await?; Ok(response.buffered_amount) @@ -663,7 +760,7 @@ impl DataConsumer { self.inner() .channel - .request( + .request_fbs( self.id(), DataConsumerSetBufferedAmountLowThresholdRequest { threshold }, ) @@ -784,7 +881,6 @@ impl DataConsumer { } } -// TODO: used because 'payload' is not being used yet. impl DirectDataConsumer { /// Sends direct messages from the Rust process. pub async fn send(&self, message: WebRtcMessage<'_>) -> Result<(), RequestError> { @@ -792,7 +888,13 @@ impl DirectDataConsumer { self.inner .channel - .request(self.inner.id, DataConsumerSendRequest { ppid }) + .request_fbs( + self.inner.id, + DataConsumerSendRequest { + ppid, + payload: _payload.into_owned(), + }, + ) .await } } diff --git a/rust/src/router/data_producer.rs b/rust/src/router/data_producer.rs index e58e37d1d8..2fe0baa54e 100644 --- a/rust/src/router/data_producer.rs +++ b/rust/src/router/data_producer.rs @@ -2,6 +2,7 @@ mod tests; use crate::data_structures::{AppData, WebRtcMessage}; +use crate::fbs::{data_producer, response}; use crate::messages::{ DataProducerCloseRequest, DataProducerDumpRequest, DataProducerGetStatsRequest, DataProducerPauseRequest, DataProducerResumeRequest, DataProducerSendNotification, @@ -15,6 +16,7 @@ use event_listener_primitives::{Bag, BagOnce, HandlerId}; use log::{debug, error}; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; +use std::error::Error; use std::fmt; use std::fmt::Debug; use std::sync::atomic::{AtomicBool, Ordering}; @@ -113,6 +115,25 @@ pub struct DataProducerDump { pub paused: bool, } +impl DataProducerDump { + pub(crate) fn from_fbs(dump: data_producer::DumpResponse) -> Result> { + Ok(Self { + id: dump.id.parse()?, + r#type: if dump.type_ == data_producer::Type::Sctp { + DataProducerType::Sctp + } else { + DataProducerType::Direct + }, + label: dump.label, + protocol: dump.protocol, + sctp_stream_parameters: dump + .sctp_stream_parameters + .map(|parameters| SctpStreamParameters::from_fbs(*parameters)), + paused: dump.paused, + }) + } +} + /// RTC statistics of the data producer. #[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -123,8 +144,20 @@ pub struct DataProducerStat { pub timestamp: u64, pub label: String, pub protocol: String, - pub messages_received: usize, - pub bytes_received: usize, + pub messages_received: u64, + pub bytes_received: u64, +} + +impl DataProducerStat { + pub(crate) fn from_fbs(stats: &data_producer::GetStatsResponse) -> Self { + Self { + timestamp: stats.timestamp, + label: stats.label.to_string(), + protocol: stats.protocol.to_string(), + messages_received: stats.messages_received, + bytes_received: stats.bytes_received, + } + } } #[derive(Default)] @@ -176,7 +209,7 @@ impl Inner { }; self.executor .spawn(async move { - if let Err(error) = channel.request(transport_id, request).await { + if let Err(error) = channel.request_fbs(transport_id, request).await { error!("data producer closing failed on drop: {}", error); } }) @@ -384,10 +417,17 @@ impl DataProducer { pub async fn dump(&self) -> Result { debug!("dump()"); - self.inner() + let response = self + .inner() .channel - .request(self.id(), DataProducerDumpRequest {}) - .await + .request_fbs(self.id(), DataProducerDumpRequest {}) + .await?; + + if let response::Body::DataProducerDumpResponse(data) = response { + Ok(DataProducerDump::from_fbs(*data).expect("Error parsing dump response")) + } else { + panic!("Wrong message from worker"); + } } /// Returns current statistics of the data producer. @@ -397,10 +437,17 @@ impl DataProducer { pub async fn get_stats(&self) -> Result, RequestError> { debug!("get_stats()"); - self.inner() + let response = self + .inner() .channel - .request(self.id(), DataProducerGetStatsRequest {}) - .await + .request_fbs(self.id(), DataProducerGetStatsRequest {}) + .await?; + + if let response::Body::DataProducerGetStatsResponse(data) = response { + Ok(vec![DataProducerStat::from_fbs(&data)]) + } else { + panic!("Wrong message from worker"); + } } /// Pauses the data producer (no message is sent to its associated data consumers). @@ -411,7 +458,7 @@ impl DataProducer { self.inner() .channel - .request(self.id(), DataProducerPauseRequest {}) + .request_fbs(self.id(), DataProducerPauseRequest {}) .await?; let was_paused = self.inner().paused.swap(true, Ordering::SeqCst); @@ -431,7 +478,7 @@ impl DataProducer { self.inner() .channel - .request(self.id(), DataProducerResumeRequest {}) + .request_fbs(self.id(), DataProducerResumeRequest {}) .await?; let was_paused = self.inner().paused.swap(false, Ordering::SeqCst); @@ -499,10 +546,12 @@ impl DirectDataProducer { pub fn send(&self, message: WebRtcMessage<'_>) -> Result<(), NotificationError> { let (ppid, _payload) = message.into_ppid_and_payload(); - self.inner.channel.notify( + self.inner.channel.notify_fbs( self.inner.id, - DataProducerSendNotification { ppid }, - // payload.into_owned(), + DataProducerSendNotification { + ppid, + payload: _payload.into_owned(), + }, ) } } diff --git a/rust/src/router/direct_transport.rs b/rust/src/router/direct_transport.rs index 0bf490f51a..8ccaf5bed0 100644 --- a/rust/src/router/direct_transport.rs +++ b/rust/src/router/direct_transport.rs @@ -626,10 +626,10 @@ impl DirectTransport { /// Send a RTCP packet from the Rust process. /// /// * `rtcp_packet` - Bytes containing a valid RTCP packet (can be a compound packet). - pub fn send_rtcp(&self, _rtcp_packet: Vec) -> Result<(), NotificationError> { + pub fn send_rtcp(&self, rtcp_packet: Vec) -> Result<(), NotificationError> { self.inner .channel - .notify(self.id(), TransportSendRtcpNotification {}) + .notify_fbs(self.id(), TransportSendRtcpNotification { rtcp_packet }) } /// Callback is called when the direct transport receives a RTCP packet from its router. diff --git a/rust/src/router/producer.rs b/rust/src/router/producer.rs index 5aac664ba1..d897fff776 100644 --- a/rust/src/router/producer.rs +++ b/rust/src/router/producer.rs @@ -1025,10 +1025,10 @@ impl Producer { impl DirectProducer { /// Sends a RTP packet from the Rust process. - pub fn send(&self, _rtp_packet: Vec) -> Result<(), NotificationError> { + pub fn send(&self, rtp_packet: Vec) -> Result<(), NotificationError> { self.inner .channel - .notify(self.inner.id, ProducerSendNotification {}) + .notify_fbs(self.inner.id, ProducerSendNotification { rtp_packet }) } } diff --git a/rust/src/router/transport.rs b/rust/src/router/transport.rs index da4cf14da4..46eab83c5c 100644 --- a/rust/src/router/transport.rs +++ b/rust/src/router/transport.rs @@ -724,7 +724,7 @@ pub(super) trait TransportImpl: TransportGeneric { let response = self .channel() - .request( + .request_fbs( self.id(), TransportProduceDataRequest { data_producer_id, @@ -820,7 +820,7 @@ pub(super) trait TransportImpl: TransportGeneric { let response = self .channel() - .request( + .request_fbs( self.id(), TransportConsumeDataRequest { data_consumer_id, diff --git a/rust/src/rtp_parameters.rs b/rust/src/rtp_parameters.rs index 7a0aed18b4..a4bfa84ae7 100644 --- a/rust/src/rtp_parameters.rs +++ b/rust/src/rtp_parameters.rs @@ -787,9 +787,6 @@ pub struct RtpParameters { } impl RtpParameters { - /// TODO: This is not yet used but will be once flatbuffers is fully - /// implemented in mediasoup-rust. - #[allow(dead_code)] pub(crate) fn from_fbs( rtp_parameters: rtp_parameters::RtpParameters, ) -> Result> { @@ -903,8 +900,6 @@ impl RtpParameters { }) } - /// TODO: This is not yet used but will be once flatbuffers is fully - /// implemented in mediasoup-rust. #[allow(dead_code)] pub(crate) fn into_fbs(self) -> rtp_parameters::RtpParameters { rtp_parameters::RtpParameters { @@ -1108,9 +1103,6 @@ impl RtpCodecParameters { *payload_type } - /// NOTE: This is not used in mediasoup code. However there is no reason to - /// not expose it as public API since it could be used by the user. - #[allow(dead_code)] pub(crate) fn clock_rate(&self) -> NonZeroU32 { let (Self::Audio { clock_rate, .. } | Self::Video { clock_rate, .. }) = self; *clock_rate diff --git a/rust/src/sctp_parameters.rs b/rust/src/sctp_parameters.rs index ce1167bbdf..585369b913 100644 --- a/rust/src/sctp_parameters.rs +++ b/rust/src/sctp_parameters.rs @@ -131,6 +131,26 @@ impl SctpStreamParameters { } } +impl SctpStreamParameters { + pub(crate) fn to_fbs(self) -> sctp_parameters::SctpStreamParameters { + sctp_parameters::SctpStreamParameters { + stream_id: self.stream_id, + ordered: Some(self.ordered), + max_packet_life_time: self.max_packet_life_time, + max_retransmits: self.max_retransmits, + } + } + + pub(crate) fn from_fbs(stream_parameters: sctp_parameters::SctpStreamParameters) -> Self { + Self { + stream_id: stream_parameters.stream_id, + ordered: stream_parameters.ordered.unwrap_or(false), + max_packet_life_time: stream_parameters.max_packet_life_time, + max_retransmits: stream_parameters.max_retransmits, + } + } +} + impl SctpStreamParameters { /// Messages will be sent reliably in order. #[must_use] diff --git a/rust/src/worker/channel.rs b/rust/src/worker/channel.rs index 58478a2b36..0a70088f13 100644 --- a/rust/src/worker/channel.rs +++ b/rust/src/worker/channel.rs @@ -1,8 +1,6 @@ use crate::fbs::{message, notification, request, response}; -use crate::messages::{Notification, Request, RequestFbs, WorkerCloseRequest}; -use crate::worker::common::{ - EventHandlers, FBSEventHandlers, FBSWeakEventHandlers, SubscriptionTarget, WeakEventHandlers, -}; +use crate::messages::{NotificationFbs, RequestFbs}; +use crate::worker::common::{FBSEventHandlers, FBSWeakEventHandlers, SubscriptionTarget}; use crate::worker::utils; use crate::worker::utils::{PreparedChannelRead, PreparedChannelWrite}; use crate::worker::{RequestError, SubscriptionHandler}; @@ -14,8 +12,6 @@ use mediasoup_sys::UvAsyncT; use parking_lot::Mutex; use planus::ReadAsRoot; use serde::Deserialize; -use serde_json::Value; -use std::any::TypeId; use std::collections::VecDeque; use std::fmt::{Debug, Display}; use std::num::NonZeroUsize; @@ -60,9 +56,7 @@ pub enum NotificationParseError { #[allow(clippy::type_complexity)] pub(crate) struct BufferMessagesGuard { target_id: SubscriptionTarget, - buffered_notifications_for: Arc>>>>, fbs_buffered_notifications_for: Arc>>>>, - event_handlers_weak: WeakEventHandlers>, fbs_event_handlers_weak: FBSWeakEventHandlers< Arc) + Send + Sync + 'static>, >, @@ -70,15 +64,6 @@ pub(crate) struct BufferMessagesGuard { impl Drop for BufferMessagesGuard { fn drop(&mut self) { - let mut buffered_notifications_for = self.buffered_notifications_for.lock(); - if let Some(notifications) = buffered_notifications_for.remove(&self.target_id) { - if let Some(event_handlers) = self.event_handlers_weak.upgrade() { - for notification in notifications { - event_handlers.call_callbacks_with_single_value(&self.target_id, ¬ification); - } - } - } - let mut fbs_buffered_notifications_for = self.fbs_buffered_notifications_for.lock(); if let Some(notifications) = fbs_buffered_notifications_for.remove(&self.target_id) { if let Some(event_handlers) = self.fbs_event_handlers_weak.upgrade() { @@ -134,7 +119,6 @@ struct ResponseError { reason: String, } -type ResponseResult = Result, ResponseError>; type FBSResponseResult = Result, ResponseError>; struct RequestDropGuard<'a> { @@ -153,10 +137,6 @@ impl<'a> Drop for RequestDropGuard<'a> { // Drop pending message from memory self.message.take(); // Remove request handler from the container - if let Some(requests_container) = self.channel.inner.requests_container_weak.upgrade() { - requests_container.lock().handlers.remove(&self.id); - } - // Remove request handler from the container if let Some(requests_container) = self.channel.inner.fbs_requests_container_weak.upgrade() { requests_container.lock().handlers.remove(&self.id); } @@ -169,46 +149,24 @@ impl<'a> RequestDropGuard<'a> { } } -#[derive(Default)] -struct RequestsContainer { - next_id: u32, - handlers: HashedMap>>, -} - #[derive(Default)] struct FBSRequestsContainer { next_id: u32, handlers: HashedMap>, } -// TODO: Maybe remove -/* -struct OutgoingMessageRequest { - message: Vec, - payload: Vec, -} - -enum OutgoingMessage { - Request(Arc>), - Notification { message: Vec, payload: Vec }, -} -*/ - struct OutgoingMessageBuffer { handle: Option, messages: VecDeque>>>, - // messages: VecDeque, } -#[allow(clippy::type_complexity)] +// TODO: use 'close' in 'request' method. +#[allow(clippy::type_complexity, dead_code)] struct Inner { outgoing_message_buffer: Arc>, internal_message_receiver: async_channel::Receiver, - requests_container_weak: Weak>, fbs_requests_container_weak: Weak>, - buffered_notifications_for: Arc>>>>, fbs_buffered_notifications_for: Arc>>>>, - event_handlers_weak: WeakEventHandlers>, fbs_event_handlers_weak: FBSWeakEventHandlers< Arc) + Send + Sync + 'static>, >, @@ -235,17 +193,11 @@ impl Channel { handle: None, messages: VecDeque::with_capacity(10), })); - let requests_container = Arc::>::default(); - let requests_container_weak = Arc::downgrade(&requests_container); let fbs_requests_container = Arc::>::default(); let fbs_requests_container_weak = Arc::downgrade(&fbs_requests_container); - let buffered_notifications_for = - Arc::>>>>::default(); let fbs_buffered_notifications_for = Arc::>>>>::default(); - let event_handlers = EventHandlers::new(); let fbs_event_handlers = FBSEventHandlers::new(); - let event_handlers_weak = event_handlers.downgrade(); let fbs_event_handlers_weak = fbs_event_handlers.downgrade(); let prepared_channel_read = utils::prepare_channel_read_fn({ @@ -271,7 +223,6 @@ impl Channel { let (internal_message_sender, internal_message_receiver) = async_channel::unbounded(); let prepared_channel_write = utils::prepare_channel_write_fn({ - let buffered_notifications_for = Arc::clone(&buffered_notifications_for); let fbs_buffered_notifications_for = Arc::clone(&fbs_buffered_notifications_for); // This this contain cache of targets that are known to not have buffering, so // that we can avoid Mutex locking overhead for them @@ -289,13 +240,6 @@ impl Channel { ); if !non_buffered_notifications.contains(&target_id) { - let mut buffer_notifications_for = buffered_notifications_for.lock(); - // Check if we need to buffer notifications for this - // target_id - if let Some(list) = buffer_notifications_for.get_mut(&target_id) { - list.push(Vec::from(message)); - return; - } let mut fbs_buffer_notifications_for = fbs_buffered_notifications_for.lock(); // Check if we need to buffer notifications for this @@ -357,11 +301,8 @@ impl Channel { let inner = Arc::new(Inner { outgoing_message_buffer, internal_message_receiver, - requests_container_weak, fbs_requests_container_weak, - buffered_notifications_for, fbs_buffered_notifications_for, - event_handlers_weak, fbs_event_handlers_weak, worker_closed, closed: AtomicBool::new(false), @@ -381,156 +322,19 @@ impl Channel { /// This allows to enable buffering for messages for specific target while the target itself is /// being created. This allows to avoid missing notifications due to race conditions. pub(crate) fn buffer_messages_for(&self, target_id: SubscriptionTarget) -> BufferMessagesGuard { - let buffered_notifications_for = Arc::clone(&self.inner.buffered_notifications_for); let fbs_buffered_notifications_for = Arc::clone(&self.inner.fbs_buffered_notifications_for); - let event_handlers_weak = self.inner.event_handlers_weak.clone(); let fbs_event_handlers_weak = self.inner.fbs_event_handlers_weak.clone(); - buffered_notifications_for - .lock() - .entry(target_id.clone()) - .or_default(); fbs_buffered_notifications_for .lock() .entry(target_id.clone()) .or_default(); BufferMessagesGuard { target_id, - buffered_notifications_for, fbs_buffered_notifications_for, - event_handlers_weak, fbs_event_handlers_weak, } } - pub(crate) async fn request( - &self, - handler_id: HandlerId, - request: R, - ) -> Result - where - R: Request + 'static, - HandlerId: Display, - { - let method = request.as_method(); - - let id; - let (result_sender, result_receiver) = async_oneshot::oneshot(); - - { - let requests_container = match self.inner.requests_container_weak.upgrade() { - Some(requests_container_lock) => requests_container_lock, - None => { - if let Some(default_response) = R::default_for_soft_error() { - return Ok(default_response); - } - - return Err(RequestError::ChannelClosed); - } - }; - let mut requests_container_lock = requests_container.lock(); - - id = requests_container_lock.next_id; - - requests_container_lock.next_id = requests_container_lock.next_id.wrapping_add(1); - requests_container_lock.handlers.insert(id, result_sender); - } - - debug!("request() [method:{}, id:{}]: {:?}", method, id, request); - - // TODO: Todo pre-allocate fixed size string sufficient for most cases by default - // TODO: Refactor to avoid extra allocation during JSON serialization if possible - let message = Arc::new(AtomicTake::new( - format!( - "{id}:{method}:{handler_id}:{}", - serde_json::to_string(&request).unwrap() - ) - .into_bytes(), - )); - - { - let mut outgoing_message_buffer = self.inner.outgoing_message_buffer.lock(); - outgoing_message_buffer - .messages - .push_back(Arc::clone(&message)); - if let Some(handle) = outgoing_message_buffer.handle { - if self.inner.worker_closed.load(Ordering::Acquire) { - // Forbid all requests after worker closing except one worker closing request - let first_worker_closing = TypeId::of::() - == TypeId::of::() - && !self.inner.closed.swap(true, Ordering::Relaxed); - - if !first_worker_closing { - if let Some(default_response) = R::default_for_soft_error() { - return Ok(default_response); - } - - return Err(RequestError::ChannelClosed); - } - } - unsafe { - // Notify worker that there is something to read - let ret = mediasoup_sys::uv_async_send(handle); - if ret != 0 { - error!("uv_async_send call failed with code {}", ret); - if let Some(default_response) = R::default_for_soft_error() { - return Ok(default_response); - } - - return Err(RequestError::ChannelClosed); - } - } - } - } - - // Drop guard to make sure to drop pending request when future is cancelled - let request_drop_guard = RequestDropGuard { - id, - message, - channel: self, - removed: false, - }; - - let response_result_fut = result_receiver.await; - - request_drop_guard.remove(); - - let response_result = match response_result_fut { - Ok(response_result) => response_result, - Err(_closed) => { - return if let Some(default_response) = R::default_for_soft_error() { - Ok(default_response) - } else { - Err(RequestError::ChannelClosed) - }; - } - }; - - match response_result { - Ok(data) => { - debug!("request succeeded [method:{}, id:{}]", method, id); - - // Default will work for `()` response - serde_json::from_value(data.unwrap_or_default()).map_err(|error| { - RequestError::FailedToParse { - error: error.to_string(), - } - }) - } - Err(ResponseError { reason }) => { - debug!("request failed [method:{}, id:{}]: {}", method, id, reason); - if reason.contains("not found") { - if let Some(default_response) = R::default_for_soft_error() { - Ok(default_response) - } else { - Err(RequestError::ChannelClosed) - } - } else { - Err(RequestError::Response { reason }) - } - } - } - } - pub(crate) async fn request_fbs( &self, handler_id: HandlerId, @@ -572,6 +376,7 @@ impl Channel { if let Some(handle) = outgoing_message_buffer.handle { if self.inner.worker_closed.load(Ordering::Acquire) { // Forbid all requests after worker closing except one worker closing request + // TODO: We were checking before that inner.closed. if R::METHOD != request::Method::WorkerClose { return Err(RequestError::ChannelClosed); } @@ -634,35 +439,26 @@ impl Channel { } } - pub(crate) fn notify( + pub(crate) fn notify_fbs( &self, handler_id: HandlerId, notification: N, - // payload: Vec, ) -> Result<(), NotificationError> where - N: Notification, + N: NotificationFbs, HandlerId: Display, { - debug!("notify() [event:{}]", notification.as_event()); - - // TODO: Todo pre-allocate fixed size string sufficient for most cases by default - // TODO: Refactor to avoid extra allocation during JSON serialization if possible - let message = Arc::new(AtomicTake::new( - format!( - "n:{}:{handler_id}:{}", - notification.as_event(), - serde_json::to_string(¬ification).unwrap() - ) - .into_bytes(), - )); + debug!("notify() [{notification:?}]"); + + let data = notification.into_bytes(handler_id); + + let message = Arc::new(AtomicTake::new(data)); { let mut outgoing_message_buffer = self.inner.outgoing_message_buffer.lock(); outgoing_message_buffer .messages .push_back(Arc::clone(&message)); - // .push_back(OutgoingMessage::Notification { message, payload }); if let Some(handle) = outgoing_message_buffer.handle { if self.inner.worker_closed.load(Ordering::Acquire) { return Err(NotificationError::ChannelClosed); @@ -680,19 +476,6 @@ impl Channel { Ok(()) } - pub(crate) fn subscribe_to_notifications( - &self, - target_id: SubscriptionTarget, - callback: F, - ) -> Option - where - F: Fn(&[u8]) + Send + Sync + 'static, - { - self.inner - .event_handlers_weak - .upgrade() - .map(|event_handlers| event_handlers.add(target_id, Arc::new(callback))) - } pub(crate) fn subscribe_to_fbs_notifications( &self, target_id: SubscriptionTarget, diff --git a/rust/src/worker/common.rs b/rust/src/worker/common.rs index 4af1b551e3..84f20611ba 100644 --- a/rust/src/worker/common.rs +++ b/rust/src/worker/common.rs @@ -20,71 +20,11 @@ impl Default for EventHandlersList { } } -#[derive(Clone)] -pub(super) struct EventHandlers { - handlers: Arc>>>, -} - #[derive(Clone)] pub(super) struct FBSEventHandlers { handlers: Arc>>>, } -impl EventHandlers { - pub(super) fn new() -> Self { - let handlers = Arc::>>>::default(); - Self { handlers } - } - - pub(super) fn add(&self, target_id: SubscriptionTarget, callback: F) -> SubscriptionHandler { - let index; - { - let mut event_handlers = self.handlers.lock(); - let list = event_handlers - .entry(target_id.clone()) - .or_insert_with(EventHandlersList::default); - index = list.index; - list.index += 1; - list.callbacks.insert(index, callback); - drop(event_handlers); - } - - SubscriptionHandler::new({ - let event_handlers_weak = Arc::downgrade(&self.handlers); - - Box::new(move || { - if let Some(event_handlers) = event_handlers_weak.upgrade() { - // We store removed handler here in order to drop after `event_handlers` lock is - // released, otherwise handler will be dropped on removal from callbacks - // immediately and if it happens to hold another entity that held subscription - // handler, we may arrive here again trying to acquire lock that we didn't - // release yet. By dropping callback only when lock is released we avoid - // deadlocking. - let removed_handler; - { - let mut handlers = event_handlers.lock(); - let is_empty = { - let list = handlers.get_mut(&target_id).unwrap(); - removed_handler = list.callbacks.remove(&index); - list.callbacks.is_empty() - }; - if is_empty { - handlers.remove(&target_id); - } - } - drop(removed_handler); - } - }) - }) - } - - pub(super) fn downgrade(&self) -> WeakEventHandlers { - WeakEventHandlers { - handlers: Arc::downgrade(&self.handlers), - } - } -} - impl FBSEventHandlers { pub(super) fn new() -> Self { let handlers = Arc::>>>::default(); @@ -140,21 +80,6 @@ impl FBSEventHandlers { } } -impl EventHandlers> { - pub(super) fn call_callbacks_with_single_value( - &self, - target_id: &SubscriptionTarget, - value: &V, - ) { - let handlers = self.handlers.lock(); - if let Some(list) = handlers.get(target_id) { - for callback in list.callbacks.values() { - callback(value); - } - } - } -} - impl FBSEventHandlers) + Send + Sync + 'static>> { pub(super) fn call_callbacks_with_single_value( &self, @@ -170,19 +95,6 @@ impl FBSEventHandlers) + Send + Syn } } -#[derive(Clone)] -pub(super) struct WeakEventHandlers { - handlers: Weak>>>, -} - -impl WeakEventHandlers { - pub(super) fn upgrade(&self) -> Option> { - self.handlers - .upgrade() - .map(|handlers| EventHandlers { handlers }) - } -} - #[derive(Clone)] pub(super) struct FBSWeakEventHandlers { handlers: Weak>>>, diff --git a/rust/tests/integration/data_consumer.rs b/rust/tests/integration/data_consumer.rs index 85eaaf6a42..30b3688279 100644 --- a/rust/tests/integration/data_consumer.rs +++ b/rust/tests/integration/data_consumer.rs @@ -88,7 +88,6 @@ async fn init() -> (Worker, Router, WebRtcTransport, DataProducer) { } #[test] -#[ignore] fn consume_data_succeeds() { future::block_on(async move { let (_worker, router, _transport1, data_producer) = init().await; @@ -192,7 +191,6 @@ fn consume_data_succeeds() { } #[test] -#[ignore] fn weak() { future::block_on(async move { let (_worker, router, _transport1, data_producer) = init().await; @@ -240,7 +238,6 @@ fn weak() { } #[test] -#[ignore] fn dump_succeeds() { future::block_on(async move { let (_worker, _router, transport, data_producer) = init().await; @@ -287,7 +284,6 @@ fn dump_succeeds() { } #[test] -#[ignore] fn get_stats_succeeds() { future::block_on(async move { let (_worker, _router, transport, data_producer) = init().await; @@ -320,7 +316,6 @@ fn get_stats_succeeds() { } #[test] -#[ignore] fn consume_data_on_direct_transport_succeeds() { future::block_on(async move { let (_worker, router, _transport1, data_producer) = init().await; @@ -380,7 +375,6 @@ fn consume_data_on_direct_transport_succeeds() { } #[test] -#[ignore] fn dump_on_direct_transport_succeeds() { future::block_on(async move { let (_worker, router, _transport1, data_producer) = init().await; @@ -416,7 +410,6 @@ fn dump_on_direct_transport_succeeds() { } #[test] -#[ignore] fn get_stats_on_direct_transport_succeeds() { future::block_on(async move { let (_worker, router, _transport1, data_producer) = init().await; @@ -451,7 +444,6 @@ fn get_stats_on_direct_transport_succeeds() { } #[test] -#[ignore] fn close_event() { future::block_on(async move { let (_worker, router, _transport1, data_producer) = init().await; diff --git a/rust/tests/integration/data_producer.rs b/rust/tests/integration/data_producer.rs index ebcaf59f63..e753ff5eb5 100644 --- a/rust/tests/integration/data_producer.rs +++ b/rust/tests/integration/data_producer.rs @@ -87,7 +87,6 @@ async fn init() -> (Worker, Router, WebRtcTransport, PlainTransport) { } #[test] -#[ignore] fn transport_1_produce_data_succeeds() { future::block_on(async move { let (_worker, router, transport1, _transport2) = init().await; @@ -165,7 +164,6 @@ fn transport_1_produce_data_succeeds() { } #[test] -#[ignore] fn transport_2_produce_data_succeeds() { future::block_on(async move { let (_worker, router, _transport1, transport2) = init().await; @@ -245,7 +243,6 @@ fn transport_2_produce_data_succeeds() { } #[test] -#[ignore] fn weak() { future::block_on(async move { let (_worker, _router, transport1, _transport2) = init().await; @@ -275,7 +272,6 @@ fn weak() { } #[test] -#[ignore] fn produce_data_used_stream_id_rejects() { future::block_on(async move { let (_worker, _router, transport1, _transport2) = init().await; @@ -299,7 +295,6 @@ fn produce_data_used_stream_id_rejects() { } #[test] -#[ignore] fn dump_succeeds() { future::block_on(async move { let (_worker, _router, transport1, transport2) = init().await; @@ -379,7 +374,6 @@ fn dump_succeeds() { } #[test] -#[ignore] fn get_stats_succeeds() { future::block_on(async move { let (_worker, _router, transport1, transport2) = init().await; @@ -442,7 +436,6 @@ fn get_stats_succeeds() { } #[test] -#[ignore] fn pause_and_resume_succeed() { future::block_on(async move { let (_worker, _router, transport1, _) = init().await; @@ -498,7 +491,6 @@ fn pause_and_resume_succeed() { } #[test] -#[ignore] fn close_event() { future::block_on(async move { let (_worker, router, transport1, _transport2) = init().await; diff --git a/rust/tests/integration/direct_transport.rs b/rust/tests/integration/direct_transport.rs index 03de1a2cec..ee80646f2a 100644 --- a/rust/tests/integration/direct_transport.rs +++ b/rust/tests/integration/direct_transport.rs @@ -319,8 +319,8 @@ fn send_succeeds() { assert_eq!(stats.len(), 1); assert_eq!(&stats[0].label, data_producer.label()); assert_eq!(&stats[0].protocol, data_producer.protocol()); - assert_eq!(stats[0].messages_received, num_messages); - assert_eq!(stats[0].bytes_received, sent_message_bytes); + assert_eq!(stats[0].messages_received, num_messages as u64); + assert_eq!(stats[0].bytes_received, sent_message_bytes as u64); } { @@ -332,10 +332,13 @@ fn send_succeeds() { assert_eq!(stats.len(), 1); assert_eq!(&stats[0].label, data_consumer.label()); assert_eq!(&stats[0].protocol, data_consumer.protocol()); - assert_eq!(stats[0].messages_sent, expected_received_num_messages); + assert_eq!( + stats[0].messages_sent, + expected_received_num_messages as u64 + ); assert_eq!( stats[0].bytes_sent, - recv_message_bytes.load(Ordering::SeqCst), + recv_message_bytes.load(Ordering::SeqCst) as u64, ); } }); diff --git a/worker/fbs/dataConsumer.fbs b/worker/fbs/dataConsumer.fbs index 9121de7c84..8adcfdc70f 100644 --- a/worker/fbs/dataConsumer.fbs +++ b/worker/fbs/dataConsumer.fbs @@ -1,4 +1,5 @@ include "common.fbs"; +include "dataProducer.fbs"; include "sctpParameters.fbs"; namespace FBS.DataConsumer; @@ -14,13 +15,14 @@ table SetBufferedAmountLowThresholdRequest { table DumpResponse { id: string (required); data_producer_id: string (required); - type: string (required); + type: FBS.DataProducer.Type; sctp_stream_parameters: FBS.SctpParameters.SctpStreamParameters; label: string (required); protocol: string (required); + buffered_amount_low_threshold: uint32; paused: bool; data_producer_paused: bool; - subchannels: [uint16]; + subchannels: [uint16] (required); } table GetStatsResponse { @@ -46,7 +48,7 @@ union Data { } table SendRequest { - ppid: uint8; + ppid: uint32; data: Data (required); } @@ -66,6 +68,6 @@ table BufferedAmountLowNotification { table MessageNotification { ppid: uint32; - data: [ubyte] (required); + data: [uint8] (required); } diff --git a/worker/fbs/dataProducer.fbs b/worker/fbs/dataProducer.fbs index 658386d17c..cd7657d7ec 100644 --- a/worker/fbs/dataProducer.fbs +++ b/worker/fbs/dataProducer.fbs @@ -2,9 +2,14 @@ include "sctpParameters.fbs"; namespace FBS.DataProducer; +enum Type: uint8 { + SCTP, + DIRECT +} + table DumpResponse { id: string (required); - type: string (required); + type: Type; sctp_stream_parameters: FBS.SctpParameters.SctpStreamParameters; label: string (required); protocol: string (required); @@ -34,7 +39,7 @@ union Data { } table SendNotification { - ppid: uint8; + ppid: uint32; data: Data (required); subchannels: [uint16]; required_subchannel: uint16 = null; diff --git a/worker/fbs/directTransport.fbs b/worker/fbs/directTransport.fbs index 18894d086c..28dd372281 100644 --- a/worker/fbs/directTransport.fbs +++ b/worker/fbs/directTransport.fbs @@ -17,6 +17,6 @@ table GetStatsResponse { // Notifications from Worker. table RtcpNotification { - data: [ubyte] (required); + data: [uint8] (required); } diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs index 038da3da77..d2a77d4ae9 100644 --- a/worker/fbs/transport.fbs +++ b/worker/fbs/transport.fbs @@ -1,5 +1,6 @@ include "common.fbs"; include "consumer.fbs"; +include "dataProducer.fbs"; include "rtpParameters.fbs"; include "sctpAssociation.fbs"; include "sctpParameters.fbs"; @@ -61,7 +62,7 @@ table ConsumeResponse { table ProduceDataRequest { data_producer_id: string (required); - type: string (required); + type: FBS.DataProducer.Type; sctp_stream_parameters: FBS.SctpParameters.SctpStreamParameters; label: string; protocol: string; @@ -71,7 +72,7 @@ table ProduceDataRequest { table ConsumeDataRequest { data_consumer_id: string (required); data_producer_id: string (required); - type: string (required); + type: FBS.DataProducer.Type; sctp_stream_parameters: FBS.SctpParameters.SctpStreamParameters; label: string; protocol: string; diff --git a/worker/include/RTC/DataConsumer.hpp b/worker/include/RTC/DataConsumer.hpp index c7737dbd12..f732726c83 100644 --- a/worker/include/RTC/DataConsumer.hpp +++ b/worker/include/RTC/DataConsumer.hpp @@ -123,7 +123,6 @@ namespace RTC size_t maxMessageSize{ 0u }; // Others. Type type; - std::string typeString; RTC::SctpStreamParameters sctpStreamParameters; std::string label; std::string protocol; diff --git a/worker/include/RTC/DataProducer.hpp b/worker/include/RTC/DataProducer.hpp index e024c6b4d3..474ebb8214 100644 --- a/worker/include/RTC/DataProducer.hpp +++ b/worker/include/RTC/DataProducer.hpp @@ -93,7 +93,6 @@ namespace RTC RTC::DataProducer::Listener* listener{ nullptr }; // Others. Type type; - std::string typeString; RTC::SctpStreamParameters sctpStreamParameters; std::string label; std::string protocol; diff --git a/worker/src/RTC/DataConsumer.cpp b/worker/src/RTC/DataConsumer.cpp index a12d872129..26b18568fd 100644 --- a/worker/src/RTC/DataConsumer.cpp +++ b/worker/src/RTC/DataConsumer.cpp @@ -26,19 +26,20 @@ namespace RTC { MS_TRACE(); - this->typeString = data->type()->str(); - - if (this->typeString == "sctp") - { - this->type = DataConsumer::Type::SCTP; - } - else if (this->typeString == "direct") - { - this->type = DataConsumer::Type::DIRECT; - } - else + switch (data->type()) { - MS_THROW_TYPE_ERROR("invalid type"); + case FBS::DataProducer::Type::SCTP: + { + this->type = DataConsumer::Type::SCTP; + + break; + } + case FBS::DataProducer::Type::DIRECT: + { + this->type = DataConsumer::Type::DIRECT; + + break; + } } if (this->type == DataConsumer::Type::SCTP) @@ -66,9 +67,12 @@ namespace RTC // paused is set to false by default. this->paused = data->paused(); - for (const auto subchannel : *data->subchannels()) + if (flatbuffers::IsFieldPresent(data, FBS::Transport::ConsumeDataRequest::VT_SUBCHANNELS)) { - this->subchannels.insert(subchannel); + for (const auto subchannel : *data->subchannels()) + { + this->subchannels.insert(subchannel); + } } // NOTE: This may throw. @@ -111,10 +115,12 @@ namespace RTC builder, this->id.c_str(), this->dataProducerId.c_str(), - this->typeString.c_str(), + this->type == DataConsumer::Type::SCTP ? FBS::DataProducer::Type::SCTP + : FBS::DataProducer::Type::DIRECT, sctpStreamParameters, this->label.c_str(), this->protocol.c_str(), + this->bufferedAmountLowThreshold, this->paused, this->dataProducerPaused, std::addressof(subchannels)); diff --git a/worker/src/RTC/DataProducer.cpp b/worker/src/RTC/DataProducer.cpp index 2583387885..56a3389e73 100644 --- a/worker/src/RTC/DataProducer.cpp +++ b/worker/src/RTC/DataProducer.cpp @@ -23,19 +23,20 @@ namespace RTC { MS_TRACE(); - this->typeString = data->type()->str(); - - if (this->typeString == "sctp") - { - this->type = DataProducer::Type::SCTP; - } - else if (this->typeString == "direct") + switch (data->type()) { - this->type = DataProducer::Type::DIRECT; - } - else - { - MS_THROW_TYPE_ERROR("invalid type"); + case FBS::DataProducer::Type::SCTP: + { + this->type = DataProducer::Type::SCTP; + + break; + } + case FBS::DataProducer::Type::DIRECT: + { + this->type = DataProducer::Type::DIRECT; + + break; + } } if (this->type == DataProducer::Type::SCTP) @@ -92,7 +93,8 @@ namespace RTC return FBS::DataProducer::CreateDumpResponseDirect( builder, this->id.c_str(), - this->typeString.c_str(), + this->type == DataProducer::Type::SCTP ? FBS::DataProducer::Type::SCTP + : FBS::DataProducer::Type::DIRECT, sctpStreamParametersOffset, this->label.c_str(), this->protocol.c_str(), From eefbeefd41bfe8053d9eb5f72fa4a3d6ff537b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Mon, 9 Oct 2023 10:34:41 +0200 Subject: [PATCH 35/73] Rust: uncomment remanning ignored test (#1170) Few tests already commented since they are being worked out. --- rust/src/router/data_consumer/tests.rs | 1 - rust/src/router/data_producer/tests.rs | 1 - rust/src/router/direct_transport/tests.rs | 1 - rust/src/router/plain_transport/tests.rs | 1 - rust/src/router/webrtc_transport/tests.rs | 1 - rust/tests/integration/active_speaker_observer.rs | 5 ----- rust/tests/integration/audio_level_observer.rs | 5 ----- rust/tests/integration/multiopus.rs | 3 --- rust/tests/integration/pipe_transport.rs | 11 ----------- rust/tests/integration/smoke.rs | 1 - 10 files changed, 30 deletions(-) diff --git a/rust/src/router/data_consumer/tests.rs b/rust/src/router/data_consumer/tests.rs index f9438befed..79c20e407c 100644 --- a/rust/src/router/data_consumer/tests.rs +++ b/rust/src/router/data_consumer/tests.rs @@ -117,7 +117,6 @@ fn data_producer_close_event() { } #[test] -#[ignore] fn transport_close_event() { future::block_on(async move { let (router, data_producer) = init().await; diff --git a/rust/src/router/data_producer/tests.rs b/rust/src/router/data_producer/tests.rs index 968213f8da..3bbb34db02 100644 --- a/rust/src/router/data_producer/tests.rs +++ b/rust/src/router/data_producer/tests.rs @@ -56,7 +56,6 @@ async fn init() -> (Router, WebRtcTransport) { } #[test] -#[ignore] fn transport_close_event() { future::block_on(async move { let (router, transport1) = init().await; diff --git a/rust/src/router/direct_transport/tests.rs b/rust/src/router/direct_transport/tests.rs index 61b75926e3..5e19ed6fc8 100644 --- a/rust/src/router/direct_transport/tests.rs +++ b/rust/src/router/direct_transport/tests.rs @@ -36,7 +36,6 @@ async fn init() -> (Router, DirectTransport) { } #[test] -#[ignore] fn router_close_event() { future::block_on(async move { let (router, transport) = init().await; diff --git a/rust/src/router/plain_transport/tests.rs b/rust/src/router/plain_transport/tests.rs index dcd29c636d..fcff706c5f 100644 --- a/rust/src/router/plain_transport/tests.rs +++ b/rust/src/router/plain_transport/tests.rs @@ -31,7 +31,6 @@ async fn init() -> Router { } #[test] -#[ignore] fn router_close_event() { future::block_on(async move { let router = init().await; diff --git a/rust/src/router/webrtc_transport/tests.rs b/rust/src/router/webrtc_transport/tests.rs index deb8f1f6dd..4e3cca5725 100644 --- a/rust/src/router/webrtc_transport/tests.rs +++ b/rust/src/router/webrtc_transport/tests.rs @@ -213,7 +213,6 @@ fn create_with_webrtc_server_succeeds() { } #[test] -#[ignore] fn router_close_event() { future::block_on(async move { let (_worker, router) = init().await; diff --git a/rust/tests/integration/active_speaker_observer.rs b/rust/tests/integration/active_speaker_observer.rs index 70c3ebac88..65d317d9ec 100644 --- a/rust/tests/integration/active_speaker_observer.rs +++ b/rust/tests/integration/active_speaker_observer.rs @@ -44,7 +44,6 @@ async fn init() -> Worker { } #[test] -#[ignore] fn create() { future::block_on(async move { let worker = init().await; @@ -85,7 +84,6 @@ fn create() { } #[test] -#[ignore] fn weak() { future::block_on(async move { let worker = init().await; @@ -111,7 +109,6 @@ fn weak() { } #[test] -#[ignore] fn pause_resume() { future::block_on(async move { let worker = init().await; @@ -141,7 +138,6 @@ fn pause_resume() { } #[test] -#[ignore] fn close_event() { future::block_on(async move { let worker = init().await; @@ -167,7 +163,6 @@ fn close_event() { } #[test] -#[ignore] fn drop_test() { future::block_on(async move { let worker = init().await; diff --git a/rust/tests/integration/audio_level_observer.rs b/rust/tests/integration/audio_level_observer.rs index 1debee206d..702f2f8e64 100644 --- a/rust/tests/integration/audio_level_observer.rs +++ b/rust/tests/integration/audio_level_observer.rs @@ -44,7 +44,6 @@ async fn init() -> Worker { } #[test] -#[ignore] fn create() { future::block_on(async move { let worker = init().await; @@ -85,7 +84,6 @@ fn create() { } #[test] -#[ignore] fn weak() { future::block_on(async move { let worker = init().await; @@ -111,7 +109,6 @@ fn weak() { } #[test] -#[ignore] fn pause_resume() { future::block_on(async move { let worker = init().await; @@ -138,7 +135,6 @@ fn pause_resume() { } #[test] -#[ignore] fn close_event() { future::block_on(async move { let worker = init().await; @@ -164,7 +160,6 @@ fn close_event() { } #[test] -#[ignore] fn drop_test() { future::block_on(async move { let worker = init().await; diff --git a/rust/tests/integration/multiopus.rs b/rust/tests/integration/multiopus.rs index 30e613c1e9..650b450cd0 100644 --- a/rust/tests/integration/multiopus.rs +++ b/rust/tests/integration/multiopus.rs @@ -148,7 +148,6 @@ async fn init() -> (Router, WebRtcTransport) { } #[test] -#[ignore] fn produce_and_consume_succeeds() { future::block_on(async move { let (router, transport) = init().await; @@ -207,7 +206,6 @@ fn produce_and_consume_succeeds() { } #[test] -#[ignore] fn fails_to_consume_wrong_parameters() { future::block_on(async move { let (_router, transport) = init().await; @@ -261,7 +259,6 @@ fn fails_to_consume_wrong_parameters() { } #[test] -#[ignore] fn fails_to_consume_wrong_channels() { future::block_on(async move { let (router, transport) = init().await; diff --git a/rust/tests/integration/pipe_transport.rs b/rust/tests/integration/pipe_transport.rs index 985e2d1b7b..1268d9a579 100644 --- a/rust/tests/integration/pipe_transport.rs +++ b/rust/tests/integration/pipe_transport.rs @@ -280,7 +280,6 @@ async fn init() -> ( } #[test] -#[ignore] fn pipe_to_router_succeeds_with_audio() { future::block_on(async move { let (_worker1, _worker2, router1, router2, transport1, _transport2) = init().await; @@ -402,7 +401,6 @@ fn pipe_to_router_succeeds_with_audio() { } #[test] -#[ignore] fn pipe_to_router_succeeds_with_video() { future::block_on(async move { let (_worker1, _worker2, router1, router2, transport1, _transport2) = init().await; @@ -597,7 +595,6 @@ fn pipe_to_router_fails_if_both_routers_belong_to_the_same_worker() { } #[test] -#[ignore] fn weak() { future::block_on(async move { let (_worker1, _worker2, router1, _router2, _transport1, _transport2) = init().await; @@ -630,7 +627,6 @@ fn weak() { } #[test] -#[ignore] fn create_with_fixed_port_succeeds() { future::block_on(async move { let (_worker1, _worker2, router1, _router2, _transport1, _transport2) = init().await; @@ -656,7 +652,6 @@ fn create_with_fixed_port_succeeds() { } #[test] -#[ignore] fn create_with_enable_rtx_succeeds() { future::block_on(async move { let (_worker1, _worker2, router1, _router2, transport1, _transport2) = init().await; @@ -769,7 +764,6 @@ fn create_with_enable_rtx_succeeds() { } #[test] -#[ignore] fn create_with_enable_srtp_succeeds() { future::block_on(async move { let (_worker1, _worker2, router1, _router2, _transport1, _transport2) = init().await; @@ -826,7 +820,6 @@ fn create_with_enable_srtp_succeeds() { } #[test] -#[ignore] fn create_with_invalid_srtp_parameters_fails() { future::block_on(async move { let (_worker1, _worker2, router1, _router2, _transport1, _transport2) = init().await; @@ -862,7 +855,6 @@ fn create_with_invalid_srtp_parameters_fails() { } #[test] -#[ignore] fn consume_for_pipe_producer_succeeds() { future::block_on(async move { let (_worker1, _worker2, router1, router2, transport1, transport2) = init().await; @@ -1034,7 +1026,6 @@ fn producer_pause_resume_are_transmitted_to_pipe_consumer() { } #[test] -#[ignore] fn pipe_to_router_succeeds_with_data() { future::block_on(async move { let (_worker1, _worker2, router1, router2, transport1, _transport2) = init().await; @@ -1107,7 +1098,6 @@ fn pipe_to_router_succeeds_with_data() { } #[test] -#[ignore] fn data_consume_for_pipe_data_producer_succeeds() { future::block_on(async move { let (_worker1, _worker2, router1, router2, transport1, transport2) = init().await; @@ -1147,7 +1137,6 @@ fn data_consume_for_pipe_data_producer_succeeds() { } #[test] -#[ignore] fn pipe_to_router_called_twice_generates_single_pair() { future::block_on(async move { let (worker1, worker2, _router1, _router2, _transport1, _transport2) = init().await; diff --git a/rust/tests/integration/smoke.rs b/rust/tests/integration/smoke.rs index 8932aef4c9..2f1a46f658 100644 --- a/rust/tests/integration/smoke.rs +++ b/rust/tests/integration/smoke.rs @@ -35,7 +35,6 @@ fn init() { } #[test] -#[ignore] fn smoke() { init(); From 096ee1ed76cb5e289a2d225831745812aee283d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Mon, 9 Oct 2023 11:03:10 +0200 Subject: [PATCH 36/73] Rust: remove temporal FBS suffixes (#1171) They were temporal until every message was ported to flatbuffers. --- rust/src/messages.rs | 152 +++++++++------------ rust/src/router.rs | 16 +-- rust/src/router/active_speaker_observer.rs | 12 +- rust/src/router/audio_level_observer.rs | 12 +- rust/src/router/consumer.rs | 22 +-- rust/src/router/data_consumer.rs | 18 +-- rust/src/router/data_producer.rs | 12 +- rust/src/router/direct_transport.rs | 6 +- rust/src/router/pipe_transport.rs | 6 +- rust/src/router/plain_transport.rs | 6 +- rust/src/router/producer.rs | 16 +-- rust/src/router/transport.rs | 20 +-- rust/src/router/webrtc_transport.rs | 8 +- rust/src/webrtc_server.rs | 4 +- rust/src/worker.rs | 15 +- rust/src/worker/channel.rs | 82 ++++++----- rust/src/worker/common.rs | 18 +-- 17 files changed, 200 insertions(+), 225 deletions(-) diff --git a/rust/src/messages.rs b/rust/src/messages.rs index 441c5c6d43..5ae6bd603b 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -35,7 +35,6 @@ use crate::webrtc_transport::{ use crate::worker::{ChannelMessageHandlers, WorkerDump, WorkerUpdateSettings}; use parking_lot::Mutex; use planus::Builder; -use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use std::error::Error; use std::fmt::{Debug, Display}; @@ -43,23 +42,6 @@ use std::net::IpAddr; use std::num::NonZeroU16; pub(crate) trait Request -where - Self: Debug + Serialize, -{ - type HandlerId: Display; - type Response: DeserializeOwned; - - /// Request method to call on worker. - fn as_method(&self) -> &'static str; - - /// Default response to return in case of soft error, such as channel already closed, entity - /// doesn't exist on worker during closing. - fn default_for_soft_error() -> Option { - None - } -} - -pub(crate) trait RequestFbs where Self: Debug, { @@ -82,7 +64,7 @@ where -> Result>; } -pub(crate) trait NotificationFbs: Debug { +pub(crate) trait Notification: Debug { /// Notification event to call on worker. const EVENT: notification::Event; type HandlerId: Display; @@ -94,7 +76,7 @@ pub(crate) trait NotificationFbs: Debug { #[derive(Debug)] pub(crate) struct WorkerCloseRequest {} -impl RequestFbs for WorkerCloseRequest { +impl Request for WorkerCloseRequest { const METHOD: request::Method = request::Method::WorkerClose; type HandlerId = &'static str; type Response = (); @@ -125,7 +107,7 @@ impl RequestFbs for WorkerCloseRequest { #[derive(Debug)] pub(crate) struct WorkerDumpRequest {} -impl RequestFbs for WorkerDumpRequest { +impl Request for WorkerDumpRequest { const METHOD: request::Method = request::Method::WorkerDump; type HandlerId = &'static str; type Response = WorkerDump; @@ -187,7 +169,7 @@ pub(crate) struct WorkerUpdateSettingsRequest { pub(crate) data: WorkerUpdateSettings, } -impl RequestFbs for WorkerUpdateSettingsRequest { +impl Request for WorkerUpdateSettingsRequest { const METHOD: request::Method = request::Method::WorkerUpdateSettings; type HandlerId = &'static str; type Response = (); @@ -234,7 +216,7 @@ pub(crate) struct WorkerCreateWebRtcServerRequest { pub(crate) listen_infos: WebRtcServerListenInfos, } -impl RequestFbs for WorkerCreateWebRtcServerRequest { +impl Request for WorkerCreateWebRtcServerRequest { const METHOD: request::Method = request::Method::WorkerCreateWebrtcserver; type HandlerId = &'static str; type Response = (); @@ -273,7 +255,7 @@ pub(crate) struct WebRtcServerCloseRequest { pub(crate) webrtc_server_id: WebRtcServerId, } -impl RequestFbs for WebRtcServerCloseRequest { +impl Request for WebRtcServerCloseRequest { const METHOD: request::Method = request::Method::WorkerWebrtcserverClose; type HandlerId = &'static str; type Response = (); @@ -310,7 +292,7 @@ impl RequestFbs for WebRtcServerCloseRequest { #[derive(Debug)] pub(crate) struct WebRtcServerDumpRequest {} -impl RequestFbs for WebRtcServerDumpRequest { +impl Request for WebRtcServerDumpRequest { const METHOD: request::Method = request::Method::WebrtcserverDump; type HandlerId = WebRtcServerId; type Response = WebRtcServerDump; @@ -389,7 +371,7 @@ pub(crate) struct WorkerCreateRouterRequest { pub(crate) router_id: RouterId, } -impl RequestFbs for WorkerCreateRouterRequest { +impl Request for WorkerCreateRouterRequest { const METHOD: request::Method = request::Method::WorkerCreateRouter; type HandlerId = &'static str; type Response = (); @@ -423,7 +405,7 @@ pub(crate) struct RouterCloseRequest { pub(crate) router_id: RouterId, } -impl RequestFbs for RouterCloseRequest { +impl Request for RouterCloseRequest { const METHOD: request::Method = request::Method::WorkerCloseRouter; type HandlerId = &'static str; type Response = (); @@ -456,7 +438,7 @@ impl RequestFbs for RouterCloseRequest { #[derive(Debug)] pub(crate) struct RouterDumpRequest {} -impl RequestFbs for RouterDumpRequest { +impl Request for RouterDumpRequest { const METHOD: request::Method = request::Method::RouterDump; type HandlerId = RouterId; type Response = RouterDump; @@ -593,7 +575,7 @@ pub(crate) struct RouterCreateDirectTransportRequest { pub(crate) data: RouterCreateDirectTransportData, } -impl RequestFbs for RouterCreateDirectTransportRequest { +impl Request for RouterCreateDirectTransportRequest { const METHOD: request::Method = request::Method::RouterCreateDirecttransport; type HandlerId = RouterId; type Response = (); @@ -742,7 +724,7 @@ pub(crate) struct RouterCreateWebRtcTransportRequest { pub(crate) data: RouterCreateWebrtcTransportData, } -impl RequestFbs for RouterCreateWebRtcTransportRequest { +impl Request for RouterCreateWebRtcTransportRequest { const METHOD: request::Method = request::Method::RouterCreateWebrtctransport; type HandlerId = RouterId; type Response = WebRtcTransportData; @@ -872,7 +854,7 @@ pub(crate) struct RouterCreatePlainTransportRequest { pub(crate) data: RouterCreatePlainTransportData, } -impl RequestFbs for RouterCreatePlainTransportRequest { +impl Request for RouterCreatePlainTransportRequest { const METHOD: request::Method = request::Method::RouterCreatePlaintransport; type HandlerId = RouterId; type Response = PlainTransportData; @@ -996,7 +978,7 @@ pub(crate) struct RouterCreatePipeTransportRequest { pub(crate) data: RouterCreatePipeTransportData, } -impl RequestFbs for RouterCreatePipeTransportRequest { +impl Request for RouterCreatePipeTransportRequest { const METHOD: request::Method = request::Method::RouterCreatePipetransport; type HandlerId = RouterId; type Response = PipeTransportData; @@ -1087,7 +1069,7 @@ impl RouterCreateAudioLevelObserverData { } } -impl RequestFbs for RouterCreateAudioLevelObserverRequest { +impl Request for RouterCreateAudioLevelObserverRequest { const METHOD: request::Method = request::Method::RouterCreateAudiolevelobserver; type HandlerId = RouterId; type Response = (); @@ -1154,7 +1136,7 @@ impl RouterCreateActiveSpeakerObserverData { } } -impl RequestFbs for RouterCreateActiveSpeakerObserverRequest { +impl Request for RouterCreateActiveSpeakerObserverRequest { const METHOD: request::Method = request::Method::RouterCreateActivespeakerobserver; type HandlerId = RouterId; type Response = (); @@ -1197,7 +1179,7 @@ impl RequestFbs for RouterCreateActiveSpeakerObserverRequest { #[derive(Debug)] pub(crate) struct TransportDumpRequest {} -impl RequestFbs for TransportDumpRequest { +impl Request for TransportDumpRequest { const METHOD: request::Method = request::Method::TransportDump; type HandlerId = TransportId; type Response = response::Body; @@ -1232,7 +1214,7 @@ impl RequestFbs for TransportDumpRequest { #[derive(Debug)] pub(crate) struct TransportGetStatsRequest {} -impl RequestFbs for TransportGetStatsRequest { +impl Request for TransportGetStatsRequest { const METHOD: request::Method = request::Method::TransportGetStats; type HandlerId = TransportId; type Response = response::Body; @@ -1270,7 +1252,7 @@ pub(crate) struct TransportCloseRequest { pub(crate) transport_id: TransportId, } -impl RequestFbs for TransportCloseRequest { +impl Request for TransportCloseRequest { const METHOD: request::Method = request::Method::RouterCloseTransport; type HandlerId = RouterId; type Response = (); @@ -1311,7 +1293,7 @@ pub(crate) struct WebRtcTransportConnectRequest { pub(crate) dtls_parameters: DtlsParameters, } -impl RequestFbs for WebRtcTransportConnectRequest { +impl Request for WebRtcTransportConnectRequest { const METHOD: request::Method = request::Method::WebrtctransportConnect; type HandlerId = TransportId; type Response = WebRtcTransportConnectResponse; @@ -1360,7 +1342,7 @@ pub(crate) struct PipeTransportConnectRequest { pub(crate) srtp_parameters: Option, } -impl RequestFbs for PipeTransportConnectRequest { +impl Request for PipeTransportConnectRequest { const METHOD: request::Method = request::Method::PipetransportConnect; type HandlerId = TransportId; type Response = PipeTransportConnectResponse; @@ -1415,7 +1397,7 @@ pub(crate) struct TransportConnectPlainRequest { pub(crate) srtp_parameters: Option, } -impl RequestFbs for TransportConnectPlainRequest { +impl Request for TransportConnectPlainRequest { const METHOD: request::Method = request::Method::PlaintransportConnect; type HandlerId = TransportId; type Response = PlainTransportConnectResponse; @@ -1468,7 +1450,7 @@ pub(crate) struct TransportSetMaxIncomingBitrateRequest { pub(crate) bitrate: u32, } -impl RequestFbs for TransportSetMaxIncomingBitrateRequest { +impl Request for TransportSetMaxIncomingBitrateRequest { const METHOD: request::Method = request::Method::TransportSetMaxIncomingBitrate; type HandlerId = TransportId; type Response = (); @@ -1504,7 +1486,7 @@ pub(crate) struct TransportSetMaxOutgoingBitrateRequest { pub(crate) bitrate: u32, } -impl RequestFbs for TransportSetMaxOutgoingBitrateRequest { +impl Request for TransportSetMaxOutgoingBitrateRequest { const METHOD: request::Method = request::Method::TransportSetMaxOutgoingBitrate; type HandlerId = TransportId; type Response = (); @@ -1540,7 +1522,7 @@ pub(crate) struct TransportSetMinOutgoingBitrateRequest { pub(crate) bitrate: u32, } -impl RequestFbs for TransportSetMinOutgoingBitrateRequest { +impl Request for TransportSetMinOutgoingBitrateRequest { const METHOD: request::Method = request::Method::TransportSetMinOutgoingBitrate; type HandlerId = TransportId; type Response = (); @@ -1574,7 +1556,7 @@ impl RequestFbs for TransportSetMinOutgoingBitrateRequest { #[derive(Debug)] pub(crate) struct TransportRestartIceRequest {} -impl RequestFbs for TransportRestartIceRequest { +impl Request for TransportRestartIceRequest { const METHOD: request::Method = request::Method::TransportRestartIce; type HandlerId = TransportId; type Response = IceParameters; @@ -1624,7 +1606,7 @@ pub(crate) struct TransportProduceResponse { pub(crate) r#type: ProducerType, } -impl RequestFbs for TransportProduceRequest { +impl Request for TransportProduceRequest { const METHOD: request::Method = request::Method::TransportProduce; type HandlerId = TransportId; type Response = TransportProduceResponse; @@ -1688,7 +1670,7 @@ pub(crate) struct TransportConsumeResponse { pub(crate) preferred_layers: Option, } -impl RequestFbs for TransportConsumeRequest { +impl Request for TransportConsumeRequest { const METHOD: request::Method = request::Method::TransportConsume; type HandlerId = TransportId; type Response = TransportConsumeResponse; @@ -1762,7 +1744,7 @@ pub(crate) struct TransportProduceDataResponse { pub(crate) paused: bool, } -impl RequestFbs for TransportProduceDataRequest { +impl Request for TransportProduceDataRequest { const METHOD: request::Method = request::Method::TransportProduceData; type HandlerId = TransportId; type Response = TransportProduceDataResponse; @@ -1847,7 +1829,7 @@ pub(crate) struct TransportConsumeDataResponse { pub(crate) data_producer_paused: bool, } -impl RequestFbs for TransportConsumeDataRequest { +impl Request for TransportConsumeDataRequest { const METHOD: request::Method = request::Method::TransportConsumeData; type HandlerId = TransportId; type Response = TransportConsumeDataResponse; @@ -1920,7 +1902,7 @@ pub(crate) struct TransportEnableTraceEventRequest { pub(crate) types: Vec, } -impl RequestFbs for TransportEnableTraceEventRequest { +impl Request for TransportEnableTraceEventRequest { const METHOD: request::Method = request::Method::TransportEnableTraceEvent; type HandlerId = TransportId; type Response = (); @@ -1967,7 +1949,7 @@ pub(crate) struct TransportSendRtcpNotification { pub(crate) rtcp_packet: Vec, } -impl NotificationFbs for TransportSendRtcpNotification { +impl Notification for TransportSendRtcpNotification { const EVENT: notification::Event = notification::Event::TransportSendRtcp; type HandlerId = TransportId; @@ -1996,7 +1978,7 @@ pub(crate) struct ProducerCloseRequest { pub(crate) producer_id: ProducerId, } -impl RequestFbs for ProducerCloseRequest { +impl Request for ProducerCloseRequest { const METHOD: request::Method = request::Method::TransportCloseProducer; type HandlerId = TransportId; type Response = (); @@ -2031,7 +2013,7 @@ impl RequestFbs for ProducerCloseRequest { #[derive(Debug)] pub(crate) struct ProducerDumpRequest {} -impl RequestFbs for ProducerDumpRequest { +impl Request for ProducerDumpRequest { const METHOD: request::Method = request::Method::ProducerDump; type HandlerId = ProducerId; type Response = response::Body; @@ -2067,7 +2049,7 @@ impl RequestFbs for ProducerDumpRequest { #[derive(Debug)] pub(crate) struct ProducerGetStatsRequest {} -impl RequestFbs for ProducerGetStatsRequest { +impl Request for ProducerGetStatsRequest { const METHOD: request::Method = request::Method::ProducerGetStats; type HandlerId = ProducerId; type Response = response::Body; @@ -2103,7 +2085,7 @@ impl RequestFbs for ProducerGetStatsRequest { #[derive(Debug, Serialize)] pub(crate) struct ProducerPauseRequest {} -impl RequestFbs for ProducerPauseRequest { +impl Request for ProducerPauseRequest { const METHOD: request::Method = request::Method::ProducerPause; type HandlerId = ProducerId; type Response = (); @@ -2134,7 +2116,7 @@ impl RequestFbs for ProducerPauseRequest { #[derive(Debug, Serialize)] pub(crate) struct ProducerResumeRequest {} -impl RequestFbs for ProducerResumeRequest { +impl Request for ProducerResumeRequest { const METHOD: request::Method = request::Method::ProducerResume; type HandlerId = ProducerId; type Response = (); @@ -2167,7 +2149,7 @@ pub(crate) struct ProducerEnableTraceEventRequest { pub(crate) types: Vec, } -impl RequestFbs for ProducerEnableTraceEventRequest { +impl Request for ProducerEnableTraceEventRequest { const METHOD: request::Method = request::Method::ProducerEnableTraceEvent; type HandlerId = ProducerId; type Response = (); @@ -2214,7 +2196,7 @@ pub(crate) struct ProducerSendNotification { pub(crate) rtp_packet: Vec, } -impl NotificationFbs for ProducerSendNotification { +impl Notification for ProducerSendNotification { const EVENT: notification::Event = notification::Event::ProducerSend; type HandlerId = ProducerId; @@ -2243,7 +2225,7 @@ pub(crate) struct ConsumerCloseRequest { pub(crate) consumer_id: ConsumerId, } -impl RequestFbs for ConsumerCloseRequest { +impl Request for ConsumerCloseRequest { const METHOD: request::Method = request::Method::TransportCloseConsumer; type HandlerId = TransportId; type Response = (); @@ -2278,7 +2260,7 @@ impl RequestFbs for ConsumerCloseRequest { #[derive(Debug)] pub(crate) struct ConsumerDumpRequest {} -impl RequestFbs for ConsumerDumpRequest { +impl Request for ConsumerDumpRequest { const METHOD: request::Method = request::Method::ConsumerDump; type HandlerId = ConsumerId; type Response = response::Body; @@ -2314,7 +2296,7 @@ impl RequestFbs for ConsumerDumpRequest { #[derive(Debug)] pub(crate) struct ConsumerGetStatsRequest {} -impl RequestFbs for ConsumerGetStatsRequest { +impl Request for ConsumerGetStatsRequest { const METHOD: request::Method = request::Method::ConsumerGetStats; type HandlerId = ConsumerId; type Response = response::Body; @@ -2350,7 +2332,7 @@ impl RequestFbs for ConsumerGetStatsRequest { #[derive(Debug)] pub(crate) struct ConsumerPauseRequest {} -impl RequestFbs for ConsumerPauseRequest { +impl Request for ConsumerPauseRequest { const METHOD: request::Method = request::Method::ConsumerPause; type HandlerId = ConsumerId; type Response = (); @@ -2381,7 +2363,7 @@ impl RequestFbs for ConsumerPauseRequest { #[derive(Debug, Serialize)] pub(crate) struct ConsumerResumeRequest {} -impl RequestFbs for ConsumerResumeRequest { +impl Request for ConsumerResumeRequest { const METHOD: request::Method = request::Method::ConsumerResume; type HandlerId = ConsumerId; type Response = (); @@ -2414,7 +2396,7 @@ pub(crate) struct ConsumerSetPreferredLayersRequest { pub(crate) data: ConsumerLayers, } -impl RequestFbs for ConsumerSetPreferredLayersRequest { +impl Request for ConsumerSetPreferredLayersRequest { const METHOD: request::Method = request::Method::ConsumerSetPreferredLayers; type HandlerId = ConsumerId; type Response = Option; @@ -2466,7 +2448,7 @@ pub(crate) struct ConsumerSetPriorityResponse { pub(crate) priority: u8, } -impl RequestFbs for ConsumerSetPriorityRequest { +impl Request for ConsumerSetPriorityRequest { const METHOD: request::Method = request::Method::ConsumerSetPriority; type HandlerId = ConsumerId; type Response = ConsumerSetPriorityResponse; @@ -2506,7 +2488,7 @@ impl RequestFbs for ConsumerSetPriorityRequest { #[derive(Debug)] pub(crate) struct ConsumerRequestKeyFrameRequest {} -impl RequestFbs for ConsumerRequestKeyFrameRequest { +impl Request for ConsumerRequestKeyFrameRequest { const METHOD: request::Method = request::Method::ConsumerRequestKeyFrame; type HandlerId = ConsumerId; type Response = (); @@ -2538,7 +2520,7 @@ pub(crate) struct ConsumerEnableTraceEventRequest { pub(crate) types: Vec, } -impl RequestFbs for ConsumerEnableTraceEventRequest { +impl Request for ConsumerEnableTraceEventRequest { const METHOD: request::Method = request::Method::ConsumerEnableTraceEvent; type HandlerId = ConsumerId; type Response = (); @@ -2584,7 +2566,7 @@ pub(crate) struct DataProducerCloseRequest { pub(crate) data_producer_id: DataProducerId, } -impl RequestFbs for DataProducerCloseRequest { +impl Request for DataProducerCloseRequest { const METHOD: request::Method = request::Method::TransportCloseDataproducer; type HandlerId = TransportId; type Response = (); @@ -2621,7 +2603,7 @@ impl RequestFbs for DataProducerCloseRequest { #[derive(Debug)] pub(crate) struct DataProducerDumpRequest {} -impl RequestFbs for DataProducerDumpRequest { +impl Request for DataProducerDumpRequest { const METHOD: request::Method = request::Method::DataproducerDump; type HandlerId = DataProducerId; type Response = response::Body; @@ -2657,7 +2639,7 @@ impl RequestFbs for DataProducerDumpRequest { #[derive(Debug)] pub(crate) struct DataProducerGetStatsRequest {} -impl RequestFbs for DataProducerGetStatsRequest { +impl Request for DataProducerGetStatsRequest { const METHOD: request::Method = request::Method::DataproducerGetStats; type HandlerId = DataProducerId; type Response = response::Body; @@ -2693,7 +2675,7 @@ impl RequestFbs for DataProducerGetStatsRequest { #[derive(Debug, Serialize)] pub(crate) struct DataProducerPauseRequest {} -impl RequestFbs for DataProducerPauseRequest { +impl Request for DataProducerPauseRequest { const METHOD: request::Method = request::Method::DataproducerPause; type HandlerId = DataProducerId; type Response = (); @@ -2724,7 +2706,7 @@ impl RequestFbs for DataProducerPauseRequest { #[derive(Debug, Serialize)] pub(crate) struct DataProducerResumeRequest {} -impl RequestFbs for DataProducerResumeRequest { +impl Request for DataProducerResumeRequest { const METHOD: request::Method = request::Method::DataproducerResume; type HandlerId = DataProducerId; type Response = (); @@ -2758,7 +2740,7 @@ pub(crate) struct DataProducerSendNotification { pub(crate) payload: Vec, } -impl NotificationFbs for DataProducerSendNotification { +impl Notification for DataProducerSendNotification { const EVENT: notification::Event = notification::Event::DataproducerSend; type HandlerId = DataProducerId; @@ -2798,7 +2780,7 @@ pub(crate) struct DataConsumerCloseRequest { pub(crate) data_consumer_id: DataConsumerId, } -impl RequestFbs for DataConsumerCloseRequest { +impl Request for DataConsumerCloseRequest { const METHOD: request::Method = request::Method::TransportCloseDataconsumer; type HandlerId = TransportId; type Response = (); @@ -2835,7 +2817,7 @@ impl RequestFbs for DataConsumerCloseRequest { #[derive(Debug)] pub(crate) struct DataConsumerDumpRequest {} -impl RequestFbs for DataConsumerDumpRequest { +impl Request for DataConsumerDumpRequest { const METHOD: request::Method = request::Method::DataconsumerDump; type HandlerId = DataConsumerId; type Response = response::Body; @@ -2871,7 +2853,7 @@ impl RequestFbs for DataConsumerDumpRequest { #[derive(Debug)] pub(crate) struct DataConsumerGetStatsRequest {} -impl RequestFbs for DataConsumerGetStatsRequest { +impl Request for DataConsumerGetStatsRequest { const METHOD: request::Method = request::Method::DataconsumerGetStats; type HandlerId = DataConsumerId; type Response = response::Body; @@ -2907,7 +2889,7 @@ impl RequestFbs for DataConsumerGetStatsRequest { #[derive(Debug, Serialize)] pub(crate) struct DataConsumerPauseRequest {} -impl RequestFbs for DataConsumerPauseRequest { +impl Request for DataConsumerPauseRequest { const METHOD: request::Method = request::Method::DataconsumerPause; type HandlerId = DataConsumerId; type Response = (); @@ -2938,7 +2920,7 @@ impl RequestFbs for DataConsumerPauseRequest { #[derive(Debug, Serialize)] pub(crate) struct DataConsumerResumeRequest {} -impl RequestFbs for DataConsumerResumeRequest { +impl Request for DataConsumerResumeRequest { const METHOD: request::Method = request::Method::DataconsumerResume; type HandlerId = DataConsumerId; type Response = (); @@ -2974,7 +2956,7 @@ pub(crate) struct DataConsumerGetBufferedAmountResponse { pub(crate) buffered_amount: u32, } -impl RequestFbs for DataConsumerGetBufferedAmountRequest { +impl Request for DataConsumerGetBufferedAmountRequest { const METHOD: request::Method = request::Method::DataconsumerGetBufferedAmount; type HandlerId = DataConsumerId; type Response = DataConsumerGetBufferedAmountResponse; @@ -3013,7 +2995,7 @@ pub(crate) struct DataConsumerSetBufferedAmountLowThresholdRequest { pub(crate) threshold: u32, } -impl RequestFbs for DataConsumerSetBufferedAmountLowThresholdRequest { +impl Request for DataConsumerSetBufferedAmountLowThresholdRequest { const METHOD: request::Method = request::Method::DataconsumerSetBufferedAmountLowThreshold; type HandlerId = DataConsumerId; type Response = (); @@ -3058,7 +3040,7 @@ pub(crate) struct DataConsumerSendRequest { pub(crate) payload: Vec, } -impl RequestFbs for DataConsumerSendRequest { +impl Request for DataConsumerSendRequest { const METHOD: request::Method = request::Method::DataconsumerSend; type HandlerId = DataConsumerId; type Response = (); @@ -3102,7 +3084,7 @@ pub(crate) struct RtpObserverCloseRequest { pub(crate) rtp_observer_id: RtpObserverId, } -impl RequestFbs for RtpObserverCloseRequest { +impl Request for RtpObserverCloseRequest { const METHOD: request::Method = request::Method::RouterCloseRtpobserver; type HandlerId = RouterId; type Response = (); @@ -3137,7 +3119,7 @@ impl RequestFbs for RtpObserverCloseRequest { #[derive(Debug)] pub(crate) struct RtpObserverPauseRequest {} -impl RequestFbs for RtpObserverPauseRequest { +impl Request for RtpObserverPauseRequest { const METHOD: request::Method = request::Method::RtpobserverPause; type HandlerId = RtpObserverId; type Response = (); @@ -3167,7 +3149,7 @@ impl RequestFbs for RtpObserverPauseRequest { #[derive(Debug)] pub(crate) struct RtpObserverResumeRequest {} -impl RequestFbs for RtpObserverResumeRequest { +impl Request for RtpObserverResumeRequest { const METHOD: request::Method = request::Method::RtpobserverResume; type HandlerId = RtpObserverId; type Response = (); @@ -3200,7 +3182,7 @@ pub(crate) struct RtpObserverAddProducerRequest { pub(crate) producer_id: ProducerId, } -impl RequestFbs for RtpObserverAddProducerRequest { +impl Request for RtpObserverAddProducerRequest { const METHOD: request::Method = request::Method::RtpobserverAddProducer; type HandlerId = RtpObserverId; type Response = (); @@ -3239,7 +3221,7 @@ pub(crate) struct RtpObserverRemoveProducerRequest { pub(crate) producer_id: ProducerId, } -impl RequestFbs for RtpObserverRemoveProducerRequest { +impl Request for RtpObserverRemoveProducerRequest { const METHOD: request::Method = request::Method::RtpobserverRemoveProducer; type HandlerId = RtpObserverId; type Response = (); diff --git a/rust/src/router.rs b/rust/src/router.rs index 65e67b40ff..21ac35e13e 100644 --- a/rust/src/router.rs +++ b/rust/src/router.rs @@ -403,7 +403,7 @@ impl Inner { let request = RouterCloseRequest { router_id: self.id }; self.executor .spawn(async move { - if let Err(error) = channel.request_fbs("", request).await { + if let Err(error) = channel.request("", request).await { error!("router closing failed on drop: {}", error); } }) @@ -534,7 +534,7 @@ impl Router { self.inner .channel - .request_fbs(self.inner.id, RouterDumpRequest {}) + .request(self.inner.id, RouterDumpRequest {}) .await } @@ -563,7 +563,7 @@ impl Router { self.inner .channel - .request_fbs( + .request( self.inner.id, RouterCreateDirectTransportRequest { data: RouterCreateDirectTransportData::from_options( @@ -629,7 +629,7 @@ impl Router { let data = self .inner .channel - .request_fbs( + .request( self.inner.id, RouterCreateWebRtcTransportRequest { data: RouterCreateWebrtcTransportData::from_options( @@ -698,7 +698,7 @@ impl Router { let data = self .inner .channel - .request_fbs( + .request( self.inner.id, RouterCreatePipeTransportRequest { data: RouterCreatePipeTransportData::from_options( @@ -763,7 +763,7 @@ impl Router { let data = self .inner .channel - .request_fbs( + .request( self.inner.id, RouterCreatePlainTransportRequest { data: RouterCreatePlainTransportData::from_options( @@ -829,7 +829,7 @@ impl Router { self.inner .channel - .request_fbs( + .request( self.inner.id, RouterCreateAudioLevelObserverRequest { data: RouterCreateAudioLevelObserverData::from_options( @@ -889,7 +889,7 @@ impl Router { self.inner .channel - .request_fbs( + .request( self.inner.id, RouterCreateActiveSpeakerObserverRequest { data: RouterCreateActiveSpeakerObserverData::from_options( diff --git a/rust/src/router/active_speaker_observer.rs b/rust/src/router/active_speaker_observer.rs index b1676b4bd6..e7dd9a5207 100644 --- a/rust/src/router/active_speaker_observer.rs +++ b/rust/src/router/active_speaker_observer.rs @@ -138,7 +138,7 @@ impl Inner { self.executor .spawn(async move { - if let Err(error) = channel.request_fbs(router_id, request).await { + if let Err(error) = channel.request(router_id, request).await { error!("active speaker observer closing failed on drop: {}", error); } }) @@ -199,7 +199,7 @@ impl RtpObserver for ActiveSpeakerObserver { self.inner .channel - .request_fbs(self.id(), RtpObserverPauseRequest {}) + .request(self.id(), RtpObserverPauseRequest {}) .await?; let was_paused = self.inner.paused.swap(true, Ordering::SeqCst); @@ -216,7 +216,7 @@ impl RtpObserver for ActiveSpeakerObserver { self.inner .channel - .request_fbs(self.id(), RtpObserverResumeRequest {}) + .request(self.id(), RtpObserverResumeRequest {}) .await?; let was_paused = self.inner.paused.swap(false, Ordering::SeqCst); @@ -240,7 +240,7 @@ impl RtpObserver for ActiveSpeakerObserver { }; self.inner .channel - .request_fbs(self.id(), RtpObserverAddProducerRequest { producer_id }) + .request(self.id(), RtpObserverAddProducerRequest { producer_id }) .await?; self.inner.handlers.add_producer.call_simple(&producer); @@ -257,7 +257,7 @@ impl RtpObserver for ActiveSpeakerObserver { }; self.inner .channel - .request_fbs(self.id(), RtpObserverRemoveProducerRequest { producer_id }) + .request(self.id(), RtpObserverRemoveProducerRequest { producer_id }) .await?; self.inner.handlers.remove_producer.call_simple(&producer); @@ -317,7 +317,7 @@ impl ActiveSpeakerObserver { let router = router.clone(); let handlers = Arc::clone(&handlers); - channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + channel.subscribe_to_notifications(id.into(), move |notification| { match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::DominantSpeaker(dominant_speaker) => { diff --git a/rust/src/router/audio_level_observer.rs b/rust/src/router/audio_level_observer.rs index abfc09b706..0e174c9b39 100644 --- a/rust/src/router/audio_level_observer.rs +++ b/rust/src/router/audio_level_observer.rs @@ -160,7 +160,7 @@ impl Inner { self.executor .spawn(async move { - if let Err(error) = channel.request_fbs(router_id, request).await { + if let Err(error) = channel.request(router_id, request).await { error!("audio level observer closing failed on drop: {}", error); } }) @@ -221,7 +221,7 @@ impl RtpObserver for AudioLevelObserver { self.inner .channel - .request_fbs(self.id(), RtpObserverPauseRequest {}) + .request(self.id(), RtpObserverPauseRequest {}) .await?; let was_paused = self.inner.paused.swap(true, Ordering::SeqCst); @@ -238,7 +238,7 @@ impl RtpObserver for AudioLevelObserver { self.inner .channel - .request_fbs(self.id(), RtpObserverResumeRequest {}) + .request(self.id(), RtpObserverResumeRequest {}) .await?; let was_paused = self.inner.paused.swap(false, Ordering::SeqCst); @@ -262,7 +262,7 @@ impl RtpObserver for AudioLevelObserver { }; self.inner .channel - .request_fbs(self.id(), RtpObserverAddProducerRequest { producer_id }) + .request(self.id(), RtpObserverAddProducerRequest { producer_id }) .await?; self.inner.handlers.add_producer.call_simple(&producer); @@ -279,7 +279,7 @@ impl RtpObserver for AudioLevelObserver { }; self.inner .channel - .request_fbs(self.id(), RtpObserverRemoveProducerRequest { producer_id }) + .request(self.id(), RtpObserverRemoveProducerRequest { producer_id }) .await?; self.inner.handlers.remove_producer.call_simple(&producer); @@ -339,7 +339,7 @@ impl AudioLevelObserver { let router = router.clone(); let handlers = Arc::clone(&handlers); - channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + channel.subscribe_to_notifications(id.into(), move |notification| { match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::Volumes(volumes) => { diff --git a/rust/src/router/consumer.rs b/rust/src/router/consumer.rs index 199d6b6878..6110998303 100644 --- a/rust/src/router/consumer.rs +++ b/rust/src/router/consumer.rs @@ -707,7 +707,7 @@ impl Inner { self.executor .spawn(async move { if weak_producer.upgrade().is_some() { - if let Err(error) = channel.request_fbs(transport_id, request).await { + if let Err(error) = channel.request(transport_id, request).await { error!("consumer closing failed on drop: {}", error); } } @@ -783,7 +783,7 @@ impl Consumer { let current_layers = Arc::clone(¤t_layers); let inner_weak = Arc::clone(&inner_weak); - channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + channel.subscribe_to_notifications(id.into(), move |notification| { match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::ProducerClose => { @@ -993,7 +993,7 @@ impl Consumer { let response = self .inner .channel - .request_fbs(self.id(), ConsumerDumpRequest {}) + .request(self.id(), ConsumerDumpRequest {}) .await?; if let response::Body::ConsumerDumpResponse(data) = response { @@ -1013,7 +1013,7 @@ impl Consumer { let response = self .inner .channel - .request_fbs(self.id(), ConsumerGetStatsRequest {}) + .request(self.id(), ConsumerGetStatsRequest {}) .await; if let Ok(response::Body::ConsumerGetStatsResponse(data)) = response { @@ -1042,7 +1042,7 @@ impl Consumer { self.inner .channel - .request_fbs(self.id(), ConsumerPauseRequest {}) + .request(self.id(), ConsumerPauseRequest {}) .await?; let mut paused = self.inner.paused.lock(); @@ -1062,7 +1062,7 @@ impl Consumer { self.inner .channel - .request_fbs(self.id(), ConsumerResumeRequest {}) + .request(self.id(), ConsumerResumeRequest {}) .await?; let mut paused = self.inner.paused.lock(); @@ -1087,7 +1087,7 @@ impl Consumer { let consumer_layers = self .inner .channel - .request_fbs( + .request( self.id(), ConsumerSetPreferredLayersRequest { data: consumer_layers, @@ -1109,7 +1109,7 @@ impl Consumer { let result = self .inner .channel - .request_fbs(self.id(), ConsumerSetPriorityRequest { priority }) + .request(self.id(), ConsumerSetPriorityRequest { priority }) .await?; *self.inner.priority.lock() = result.priority; @@ -1126,7 +1126,7 @@ impl Consumer { let result = self .inner .channel - .request_fbs(self.id(), ConsumerSetPriorityRequest { priority }) + .request(self.id(), ConsumerSetPriorityRequest { priority }) .await?; *self.inner.priority.lock() = result.priority; @@ -1140,7 +1140,7 @@ impl Consumer { self.inner .channel - .request_fbs(self.id(), ConsumerRequestKeyFrameRequest {}) + .request(self.id(), ConsumerRequestKeyFrameRequest {}) .await } @@ -1153,7 +1153,7 @@ impl Consumer { self.inner .channel - .request_fbs(self.id(), ConsumerEnableTraceEventRequest { types }) + .request(self.id(), ConsumerEnableTraceEventRequest { types }) .await } diff --git a/rust/src/router/data_consumer.rs b/rust/src/router/data_consumer.rs index 5f72e4209a..401eec52da 100644 --- a/rust/src/router/data_consumer.rs +++ b/rust/src/router/data_consumer.rs @@ -338,7 +338,7 @@ impl Inner { self.executor .spawn(async move { if weak_data_producer.upgrade().is_some() { - if let Err(error) = channel.request_fbs(transport_id, request).await { + if let Err(error) = channel.request(transport_id, request).await { error!("consumer closing failed on drop: {}", error); } } @@ -470,7 +470,7 @@ impl DataConsumer { let data_producer_paused = Arc::clone(&data_producer_paused); let inner_weak = Arc::clone(&inner_weak); - channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + channel.subscribe_to_notifications(id.into(), move |notification| { match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::DataProducerClose => { @@ -658,7 +658,7 @@ impl DataConsumer { let response = self .inner() .channel - .request_fbs(self.id(), DataConsumerDumpRequest {}) + .request(self.id(), DataConsumerDumpRequest {}) .await?; if let response::Body::DataConsumerDumpResponse(data) = response { @@ -678,7 +678,7 @@ impl DataConsumer { let response = self .inner() .channel - .request_fbs(self.id(), DataConsumerGetStatsRequest {}) + .request(self.id(), DataConsumerGetStatsRequest {}) .await?; if let response::Body::DataConsumerGetStatsResponse(data) = response { @@ -694,7 +694,7 @@ impl DataConsumer { self.inner() .channel - .request_fbs(self.id(), DataConsumerPauseRequest {}) + .request(self.id(), DataConsumerPauseRequest {}) .await?; let mut paused = self.inner().paused.lock(); @@ -714,7 +714,7 @@ impl DataConsumer { self.inner() .channel - .request_fbs(self.id(), DataConsumerResumeRequest {}) + .request(self.id(), DataConsumerResumeRequest {}) .await?; let mut paused = self.inner().paused.lock(); @@ -741,7 +741,7 @@ impl DataConsumer { let response = self .inner() .channel - .request_fbs(self.id(), DataConsumerGetBufferedAmountRequest {}) + .request(self.id(), DataConsumerGetBufferedAmountRequest {}) .await?; Ok(response.buffered_amount) @@ -760,7 +760,7 @@ impl DataConsumer { self.inner() .channel - .request_fbs( + .request( self.id(), DataConsumerSetBufferedAmountLowThresholdRequest { threshold }, ) @@ -888,7 +888,7 @@ impl DirectDataConsumer { self.inner .channel - .request_fbs( + .request( self.inner.id, DataConsumerSendRequest { ppid, diff --git a/rust/src/router/data_producer.rs b/rust/src/router/data_producer.rs index 2fe0baa54e..409b372400 100644 --- a/rust/src/router/data_producer.rs +++ b/rust/src/router/data_producer.rs @@ -209,7 +209,7 @@ impl Inner { }; self.executor .spawn(async move { - if let Err(error) = channel.request_fbs(transport_id, request).await { + if let Err(error) = channel.request(transport_id, request).await { error!("data producer closing failed on drop: {}", error); } }) @@ -420,7 +420,7 @@ impl DataProducer { let response = self .inner() .channel - .request_fbs(self.id(), DataProducerDumpRequest {}) + .request(self.id(), DataProducerDumpRequest {}) .await?; if let response::Body::DataProducerDumpResponse(data) = response { @@ -440,7 +440,7 @@ impl DataProducer { let response = self .inner() .channel - .request_fbs(self.id(), DataProducerGetStatsRequest {}) + .request(self.id(), DataProducerGetStatsRequest {}) .await?; if let response::Body::DataProducerGetStatsResponse(data) = response { @@ -458,7 +458,7 @@ impl DataProducer { self.inner() .channel - .request_fbs(self.id(), DataProducerPauseRequest {}) + .request(self.id(), DataProducerPauseRequest {}) .await?; let was_paused = self.inner().paused.swap(true, Ordering::SeqCst); @@ -478,7 +478,7 @@ impl DataProducer { self.inner() .channel - .request_fbs(self.id(), DataProducerResumeRequest {}) + .request(self.id(), DataProducerResumeRequest {}) .await?; let was_paused = self.inner().paused.swap(false, Ordering::SeqCst); @@ -546,7 +546,7 @@ impl DirectDataProducer { pub fn send(&self, message: WebRtcMessage<'_>) -> Result<(), NotificationError> { let (ppid, _payload) = message.into_ppid_and_payload(); - self.inner.channel.notify_fbs( + self.inner.channel.notify( self.inner.id, DataProducerSendNotification { ppid, diff --git a/rust/src/router/direct_transport.rs b/rust/src/router/direct_transport.rs index 8ccaf5bed0..0098c28bef 100644 --- a/rust/src/router/direct_transport.rs +++ b/rust/src/router/direct_transport.rs @@ -307,7 +307,7 @@ impl Inner { self.executor .spawn(async move { - if let Err(error) = channel.request_fbs(router_id, request).await { + if let Err(error) = channel.request(router_id, request).await { error!("transport closing failed on drop: {}", error); } }) @@ -567,7 +567,7 @@ impl DirectTransport { let subscription_handler = { let handlers = Arc::clone(&handlers); - channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + channel.subscribe_to_notifications(id.into(), move |notification| { match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::Trace(trace_event_data) => { @@ -629,7 +629,7 @@ impl DirectTransport { pub fn send_rtcp(&self, rtcp_packet: Vec) -> Result<(), NotificationError> { self.inner .channel - .notify_fbs(self.id(), TransportSendRtcpNotification { rtcp_packet }) + .notify(self.id(), TransportSendRtcpNotification { rtcp_packet }) } /// Callback is called when the direct transport receives a RTCP packet from its router. diff --git a/rust/src/router/pipe_transport.rs b/rust/src/router/pipe_transport.rs index 45adb1eb10..3461a47cc4 100644 --- a/rust/src/router/pipe_transport.rs +++ b/rust/src/router/pipe_transport.rs @@ -366,7 +366,7 @@ impl Inner { self.executor .spawn(async move { - if let Err(error) = channel.request_fbs(router_id, request).await { + if let Err(error) = channel.request(router_id, request).await { error!("transport closing failed on drop: {}", error); } }) @@ -616,7 +616,7 @@ impl PipeTransport { let handlers = Arc::clone(&handlers); let data = Arc::clone(&data); - channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + channel.subscribe_to_notifications(id.into(), move |notification| { match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::SctpStateChange { sctp_state } => { @@ -691,7 +691,7 @@ impl PipeTransport { let response = self .inner .channel - .request_fbs( + .request( self.id(), PipeTransportConnectRequest { ip: remote_parameters.ip, diff --git a/rust/src/router/plain_transport.rs b/rust/src/router/plain_transport.rs index e10859be72..d29d2adfcd 100644 --- a/rust/src/router/plain_transport.rs +++ b/rust/src/router/plain_transport.rs @@ -439,7 +439,7 @@ impl Inner { self.executor .spawn(async move { - if let Err(error) = channel.request_fbs(router_id, request).await { + if let Err(error) = channel.request(router_id, request).await { error!("transport closing failed on drop: {}", error); } }) @@ -682,7 +682,7 @@ impl PlainTransport { let handlers = Arc::clone(&handlers); let data = Arc::clone(&data); - channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + channel.subscribe_to_notifications(id.into(), move |notification| { match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::Tuple { tuple } => { @@ -862,7 +862,7 @@ impl PlainTransport { let response = self .inner .channel - .request_fbs( + .request( self.inner.id, TransportConnectPlainRequest { ip: remote_parameters.ip, diff --git a/rust/src/router/producer.rs b/rust/src/router/producer.rs index d897fff776..d447703f14 100644 --- a/rust/src/router/producer.rs +++ b/rust/src/router/producer.rs @@ -601,7 +601,7 @@ impl Inner { self.executor .spawn(async move { - if let Err(error) = channel.request_fbs(transport_id, request).await { + if let Err(error) = channel.request(transport_id, request).await { error!("producer closing failed on drop: {}", error); } }) @@ -722,7 +722,7 @@ impl Producer { let handlers = Arc::clone(&handlers); let score = Arc::clone(&score); - channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + channel.subscribe_to_notifications(id.into(), move |notification| { match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::Score(scores) => { @@ -852,7 +852,7 @@ impl Producer { let response = self .inner() .channel - .request_fbs(self.id(), ProducerDumpRequest {}) + .request(self.id(), ProducerDumpRequest {}) .await?; if let response::Body::ProducerDumpResponse(data) = response { @@ -872,7 +872,7 @@ impl Producer { let response = self .inner() .channel - .request_fbs(self.id(), ProducerGetStatsRequest {}) + .request(self.id(), ProducerGetStatsRequest {}) .await; if let Ok(response::Body::ProducerGetStatsResponse(data)) = response { @@ -890,7 +890,7 @@ impl Producer { self.inner() .channel - .request_fbs(self.id(), ProducerPauseRequest {}) + .request(self.id(), ProducerPauseRequest {}) .await?; let was_paused = self.inner().paused.swap(true, Ordering::SeqCst); @@ -910,7 +910,7 @@ impl Producer { self.inner() .channel - .request_fbs(self.id(), ProducerResumeRequest {}) + .request(self.id(), ProducerResumeRequest {}) .await?; let was_paused = self.inner().paused.swap(false, Ordering::SeqCst); @@ -931,7 +931,7 @@ impl Producer { self.inner() .channel - .request_fbs(self.id(), ProducerEnableTraceEventRequest { types }) + .request(self.id(), ProducerEnableTraceEventRequest { types }) .await } @@ -1028,7 +1028,7 @@ impl DirectProducer { pub fn send(&self, rtp_packet: Vec) -> Result<(), NotificationError> { self.inner .channel - .notify_fbs(self.inner.id, ProducerSendNotification { rtp_packet }) + .notify(self.inner.id, ProducerSendNotification { rtp_packet }) } } diff --git a/rust/src/router/transport.rs b/rust/src/router/transport.rs index 46eab83c5c..7e4a35b0e0 100644 --- a/rust/src/router/transport.rs +++ b/rust/src/router/transport.rs @@ -443,25 +443,25 @@ pub(super) trait TransportImpl: TransportGeneric { async fn dump_impl(&self) -> Result { self.channel() - .request_fbs(self.id(), TransportDumpRequest {}) + .request(self.id(), TransportDumpRequest {}) .await } async fn get_stats_impl(&self) -> Result { self.channel() - .request_fbs(self.id(), TransportGetStatsRequest {}) + .request(self.id(), TransportGetStatsRequest {}) .await } async fn set_max_incoming_bitrate_impl(&self, bitrate: u32) -> Result<(), RequestError> { self.channel() - .request_fbs(self.id(), TransportSetMaxIncomingBitrateRequest { bitrate }) + .request(self.id(), TransportSetMaxIncomingBitrateRequest { bitrate }) .await } async fn set_max_outgoing_bitrate_impl(&self, bitrate: u32) -> Result<(), RequestError> { self.channel() - .request_fbs(self.id(), TransportSetMaxOutgoingBitrateRequest { bitrate }) + .request(self.id(), TransportSetMaxOutgoingBitrateRequest { bitrate }) .await } @@ -470,13 +470,13 @@ pub(super) trait TransportImpl: TransportGeneric { types: Vec, ) -> Result<(), RequestError> { self.channel() - .request_fbs(self.id(), TransportEnableTraceEventRequest { types }) + .request(self.id(), TransportEnableTraceEventRequest { types }) .await } async fn set_min_outgoing_bitrate_impl(&self, bitrate: u32) -> Result<(), RequestError> { self.channel() - .request_fbs(self.id(), TransportSetMinOutgoingBitrateRequest { bitrate }) + .request(self.id(), TransportSetMinOutgoingBitrateRequest { bitrate }) .await } @@ -548,7 +548,7 @@ pub(super) trait TransportImpl: TransportGeneric { let response = self .channel() - .request_fbs( + .request( self.id(), TransportProduceRequest { producer_id, @@ -646,7 +646,7 @@ pub(super) trait TransportImpl: TransportGeneric { let response = self .channel() - .request_fbs( + .request( self.id(), TransportConsumeRequest { consumer_id, @@ -724,7 +724,7 @@ pub(super) trait TransportImpl: TransportGeneric { let response = self .channel() - .request_fbs( + .request( self.id(), TransportProduceDataRequest { data_producer_id, @@ -820,7 +820,7 @@ pub(super) trait TransportImpl: TransportGeneric { let response = self .channel() - .request_fbs( + .request( self.id(), TransportConsumeDataRequest { data_consumer_id, diff --git a/rust/src/router/webrtc_transport.rs b/rust/src/router/webrtc_transport.rs index f66623cc18..46836995ec 100644 --- a/rust/src/router/webrtc_transport.rs +++ b/rust/src/router/webrtc_transport.rs @@ -525,7 +525,7 @@ impl Inner { self.executor .spawn(async move { - if let Err(error) = channel.request_fbs(router_id, request).await { + if let Err(error) = channel.request(router_id, request).await { error!("transport closing failed on drop: {}", error); } }) @@ -779,7 +779,7 @@ impl WebRtcTransport { let handlers = Arc::clone(&handlers); let data = Arc::clone(&data); - channel.subscribe_to_fbs_notifications(id.into(), move |notification| { + channel.subscribe_to_notifications(id.into(), move |notification| { match Notification::from_fbs(notification) { Ok(notification) => match notification { Notification::IceStateChange { ice_state } => { @@ -931,7 +931,7 @@ impl WebRtcTransport { let response = self .inner .channel - .request_fbs( + .request( self.id(), WebRtcTransportConnectRequest { dtls_parameters: remote_parameters.dtls_parameters, @@ -1045,7 +1045,7 @@ impl WebRtcTransport { self.inner .channel - .request_fbs(self.id(), TransportRestartIceRequest {}) + .request(self.id(), TransportRestartIceRequest {}) .await } diff --git a/rust/src/webrtc_server.rs b/rust/src/webrtc_server.rs index f4fb0da2bb..fe323d30ba 100644 --- a/rust/src/webrtc_server.rs +++ b/rust/src/webrtc_server.rs @@ -184,7 +184,7 @@ impl Inner { }; self.executor .spawn(async move { - if let Err(error) = channel.request_fbs("", request).await { + if let Err(error) = channel.request("", request).await { error!("WebRTC server closing failed on drop: {}", error); } }) @@ -286,7 +286,7 @@ impl WebRtcServer { self.inner .channel - .request_fbs(self.id(), WebRtcServerDumpRequest {}) + .request(self.id(), WebRtcServerDumpRequest {}) .await } diff --git a/rust/src/worker.rs b/rust/src/worker.rs index e28b0cd6fc..32c473488f 100644 --- a/rust/src/worker.rs +++ b/rust/src/worker.rs @@ -488,7 +488,7 @@ impl Inner { let (sender, receiver) = async_oneshot::oneshot(); let id = self.id; let sender = Mutex::new(Some(sender)); - let _handler = self.channel.subscribe_to_fbs_notifications( + let _handler = self.channel.subscribe_to_notifications( SubscriptionTarget::String(std::process::id().to_string()), move |notification| { let result = match notification.event().unwrap() { @@ -553,7 +553,7 @@ impl Inner { self.executor .spawn(async move { - let _ = channel.request_fbs("", WorkerCloseRequest {}).await; + let _ = channel.request("", WorkerCloseRequest {}).await; // Drop channels in here after response from worker drop(channel); @@ -622,10 +622,7 @@ impl Worker { pub async fn dump(&self) -> Result { debug!("dump()"); - self.inner - .channel - .request_fbs("", WorkerDumpRequest {}) - .await + self.inner.channel.request("", WorkerDumpRequest {}).await } /// Updates the worker settings in runtime. Just a subset of the worker settings can be updated. @@ -635,7 +632,7 @@ impl Worker { match self .inner .channel - .request_fbs("", WorkerUpdateSettingsRequest { data }) + .request("", WorkerUpdateSettingsRequest { data }) .await { Ok(_) => Ok(()), @@ -666,7 +663,7 @@ impl Worker { self.inner .channel - .request_fbs( + .request( "", WorkerCreateWebRtcServerRequest { webrtc_server_id, @@ -715,7 +712,7 @@ impl Worker { self.inner .channel - .request_fbs("", WorkerCreateRouterRequest { router_id }) + .request("", WorkerCreateRouterRequest { router_id }) .await .map_err(CreateRouterError::Request)?; diff --git a/rust/src/worker/channel.rs b/rust/src/worker/channel.rs index 0a70088f13..b04c1e0cdb 100644 --- a/rust/src/worker/channel.rs +++ b/rust/src/worker/channel.rs @@ -1,6 +1,6 @@ use crate::fbs::{message, notification, request, response}; -use crate::messages::{NotificationFbs, RequestFbs}; -use crate::worker::common::{FBSEventHandlers, FBSWeakEventHandlers, SubscriptionTarget}; +use crate::messages::{Notification, Request}; +use crate::worker::common::{EventHandlers, SubscriptionTarget, WeakEventHandlers}; use crate::worker::utils; use crate::worker::utils::{PreparedChannelRead, PreparedChannelWrite}; use crate::worker::{RequestError, SubscriptionHandler}; @@ -56,17 +56,16 @@ pub enum NotificationParseError { #[allow(clippy::type_complexity)] pub(crate) struct BufferMessagesGuard { target_id: SubscriptionTarget, - fbs_buffered_notifications_for: Arc>>>>, - fbs_event_handlers_weak: FBSWeakEventHandlers< - Arc) + Send + Sync + 'static>, - >, + buffered_notifications_for: Arc>>>>, + event_handlers_weak: + WeakEventHandlers) + Send + Sync + 'static>>, } impl Drop for BufferMessagesGuard { fn drop(&mut self) { - let mut fbs_buffered_notifications_for = self.fbs_buffered_notifications_for.lock(); - if let Some(notifications) = fbs_buffered_notifications_for.remove(&self.target_id) { - if let Some(event_handlers) = self.fbs_event_handlers_weak.upgrade() { + let mut buffered_notifications_for = self.buffered_notifications_for.lock(); + if let Some(notifications) = buffered_notifications_for.remove(&self.target_id) { + if let Some(event_handlers) = self.event_handlers_weak.upgrade() { for notification in notifications { let notification = notification::NotificationRef::read_as_root(¬ification).unwrap(); @@ -137,7 +136,7 @@ impl<'a> Drop for RequestDropGuard<'a> { // Drop pending message from memory self.message.take(); // Remove request handler from the container - if let Some(requests_container) = self.channel.inner.fbs_requests_container_weak.upgrade() { + if let Some(requests_container) = self.channel.inner.requests_container_weak.upgrade() { requests_container.lock().handlers.remove(&self.id); } } @@ -165,11 +164,10 @@ struct OutgoingMessageBuffer { struct Inner { outgoing_message_buffer: Arc>, internal_message_receiver: async_channel::Receiver, - fbs_requests_container_weak: Weak>, - fbs_buffered_notifications_for: Arc>>>>, - fbs_event_handlers_weak: FBSWeakEventHandlers< - Arc) + Send + Sync + 'static>, - >, + requests_container_weak: Weak>, + buffered_notifications_for: Arc>>>>, + event_handlers_weak: + WeakEventHandlers) + Send + Sync + 'static>>, worker_closed: Arc, closed: AtomicBool, } @@ -193,12 +191,12 @@ impl Channel { handle: None, messages: VecDeque::with_capacity(10), })); - let fbs_requests_container = Arc::>::default(); - let fbs_requests_container_weak = Arc::downgrade(&fbs_requests_container); - let fbs_buffered_notifications_for = + let requests_container = Arc::>::default(); + let requests_container_weak = Arc::downgrade(&requests_container); + let buffered_notifications_for = Arc::>>>>::default(); - let fbs_event_handlers = FBSEventHandlers::new(); - let fbs_event_handlers_weak = fbs_event_handlers.downgrade(); + let event_handlers = EventHandlers::new(); + let event_handlers_weak = event_handlers.downgrade(); let prepared_channel_read = utils::prepare_channel_read_fn({ let outgoing_message_buffer = Arc::clone(&outgoing_message_buffer); @@ -223,7 +221,7 @@ impl Channel { let (internal_message_sender, internal_message_receiver) = async_channel::unbounded(); let prepared_channel_write = utils::prepare_channel_write_fn({ - let fbs_buffered_notifications_for = Arc::clone(&fbs_buffered_notifications_for); + let buffered_notifications_for = Arc::clone(&buffered_notifications_for); // This this contain cache of targets that are known to not have buffering, so // that we can avoid Mutex locking overhead for them let mut non_buffered_notifications = LruCache::::new( @@ -240,11 +238,10 @@ impl Channel { ); if !non_buffered_notifications.contains(&target_id) { - let mut fbs_buffer_notifications_for = - fbs_buffered_notifications_for.lock(); + let mut buffer_notifications_for = buffered_notifications_for.lock(); // Check if we need to buffer notifications for this // target_id - if let Some(list) = fbs_buffer_notifications_for.get_mut(&target_id) { + if let Some(list) = buffer_notifications_for.get_mut(&target_id) { list.push(Vec::from(message)); return; } @@ -252,11 +249,10 @@ impl Channel { // Remember we don't need to buffer these non_buffered_notifications.put(target_id.clone(), ()); } - fbs_event_handlers - .call_callbacks_with_single_value(&target_id, notification); + event_handlers.call_callbacks_with_single_value(&target_id, notification); } ChannelReceiveMessage::Response(response) => { - let sender = fbs_requests_container + let sender = requests_container .lock() .handlers .remove(&response.id().unwrap()); @@ -301,9 +297,9 @@ impl Channel { let inner = Arc::new(Inner { outgoing_message_buffer, internal_message_receiver, - fbs_requests_container_weak, - fbs_buffered_notifications_for, - fbs_event_handlers_weak, + requests_container_weak, + buffered_notifications_for, + event_handlers_weak, worker_closed, closed: AtomicBool::new(false), }); @@ -322,33 +318,33 @@ impl Channel { /// This allows to enable buffering for messages for specific target while the target itself is /// being created. This allows to avoid missing notifications due to race conditions. pub(crate) fn buffer_messages_for(&self, target_id: SubscriptionTarget) -> BufferMessagesGuard { - let fbs_buffered_notifications_for = Arc::clone(&self.inner.fbs_buffered_notifications_for); - let fbs_event_handlers_weak = self.inner.fbs_event_handlers_weak.clone(); - fbs_buffered_notifications_for + let buffered_notifications_for = Arc::clone(&self.inner.buffered_notifications_for); + let event_handlers_weak = self.inner.event_handlers_weak.clone(); + buffered_notifications_for .lock() .entry(target_id.clone()) .or_default(); BufferMessagesGuard { target_id, - fbs_buffered_notifications_for, - fbs_event_handlers_weak, + buffered_notifications_for, + event_handlers_weak, } } - pub(crate) async fn request_fbs( + pub(crate) async fn request( &self, handler_id: HandlerId, request: R, ) -> Result where - R: RequestFbs + 'static, + R: Request + 'static, HandlerId: Display, { let id; let (result_sender, result_receiver) = async_oneshot::oneshot(); { - let requests_container = match self.inner.fbs_requests_container_weak.upgrade() { + let requests_container = match self.inner.requests_container_weak.upgrade() { Some(requests_container_lock) => requests_container_lock, None => { return Err(RequestError::ChannelClosed); @@ -439,13 +435,13 @@ impl Channel { } } - pub(crate) fn notify_fbs( + pub(crate) fn notify( &self, handler_id: HandlerId, notification: N, ) -> Result<(), NotificationError> where - N: NotificationFbs, + N: Notification, HandlerId: Display, { debug!("notify() [{notification:?}]"); @@ -476,7 +472,7 @@ impl Channel { Ok(()) } - pub(crate) fn subscribe_to_fbs_notifications( + pub(crate) fn subscribe_to_notifications( &self, target_id: SubscriptionTarget, callback: F, @@ -485,8 +481,8 @@ impl Channel { F: Fn(notification::NotificationRef<'_>) + Send + Sync + 'static, { self.inner - .fbs_event_handlers_weak + .event_handlers_weak .upgrade() - .map(|fbs_event_handlers| fbs_event_handlers.add(target_id, Arc::new(callback))) + .map(|event_handlers| event_handlers.add(target_id, Arc::new(callback))) } } diff --git a/rust/src/worker/common.rs b/rust/src/worker/common.rs index 84f20611ba..f6ef339ea8 100644 --- a/rust/src/worker/common.rs +++ b/rust/src/worker/common.rs @@ -21,11 +21,11 @@ impl Default for EventHandlersList { } #[derive(Clone)] -pub(super) struct FBSEventHandlers { +pub(super) struct EventHandlers { handlers: Arc>>>, } -impl FBSEventHandlers { +impl EventHandlers { pub(super) fn new() -> Self { let handlers = Arc::>>>::default(); Self { handlers } @@ -73,14 +73,14 @@ impl FBSEventHandlers { }) } - pub(super) fn downgrade(&self) -> FBSWeakEventHandlers { - FBSWeakEventHandlers { + pub(super) fn downgrade(&self) -> WeakEventHandlers { + WeakEventHandlers { handlers: Arc::downgrade(&self.handlers), } } } -impl FBSEventHandlers) + Send + Sync + 'static>> { +impl EventHandlers) + Send + Sync + 'static>> { pub(super) fn call_callbacks_with_single_value( &self, target_id: &SubscriptionTarget, @@ -96,15 +96,15 @@ impl FBSEventHandlers) + Send + Syn } #[derive(Clone)] -pub(super) struct FBSWeakEventHandlers { +pub(super) struct WeakEventHandlers { handlers: Weak>>>, } -impl FBSWeakEventHandlers { - pub(super) fn upgrade(&self) -> Option> { +impl WeakEventHandlers { + pub(super) fn upgrade(&self) -> Option> { self.handlers .upgrade() - .map(|handlers| FBSEventHandlers { handlers }) + .map(|handlers| EventHandlers { handlers }) } } From a8cf41d953bd604a1b773a900326e18c64a296ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Tue, 10 Oct 2023 10:39:43 +0200 Subject: [PATCH 37/73] Rust: properly store incoming notifications (#1172) Store the whole binary message and retrieve the notification reference before calling the handler. --- rust/src/router/consumer/tests.rs | 1 - rust/src/router/data_consumer/tests.rs | 1 - rust/src/router/pipe_transport/tests.rs | 2 -- rust/src/worker/channel.rs | 28 ++++++++++++++++++------- rust/tests/integration/consumer.rs | 1 - 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/rust/src/router/consumer/tests.rs b/rust/src/router/consumer/tests.rs index b85d076a97..8f4fe2a74a 100644 --- a/rust/src/router/consumer/tests.rs +++ b/rust/src/router/consumer/tests.rs @@ -105,7 +105,6 @@ async fn init() -> (Router, WebRtcTransport, WebRtcTransport) { } #[test] -#[ignore] fn producer_close_event() { future::block_on(async move { let (_router, transport_1, transport_2) = init().await; diff --git a/rust/src/router/data_consumer/tests.rs b/rust/src/router/data_consumer/tests.rs index 79c20e407c..7ef9a80588 100644 --- a/rust/src/router/data_consumer/tests.rs +++ b/rust/src/router/data_consumer/tests.rs @@ -63,7 +63,6 @@ async fn init() -> (Router, DataProducer) { } #[test] -#[ignore] fn data_producer_close_event() { future::block_on(async move { let (router, data_producer) = init().await; diff --git a/rust/src/router/pipe_transport/tests.rs b/rust/src/router/pipe_transport/tests.rs index ab93ff3097..54a1f22a48 100644 --- a/rust/src/router/pipe_transport/tests.rs +++ b/rust/src/router/pipe_transport/tests.rs @@ -122,7 +122,6 @@ async fn init() -> (Router, Router, WebRtcTransport, WebRtcTransport) { } #[test] -#[ignore] fn producer_close_is_transmitted_to_pipe_consumer() { future::block_on(async move { let (router1, router2, transport1, transport2) = init().await; @@ -162,7 +161,6 @@ fn producer_close_is_transmitted_to_pipe_consumer() { } #[test] -#[ignore] fn data_producer_close_is_transmitted_to_pipe_data_consumer() { future::block_on(async move { let (router1, router2, transport1, transport2) = init().await; diff --git a/rust/src/worker/channel.rs b/rust/src/worker/channel.rs index b04c1e0cdb..85b5d9cfdd 100644 --- a/rust/src/worker/channel.rs +++ b/rust/src/worker/channel.rs @@ -18,6 +18,7 @@ use std::num::NonZeroUsize; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Weak}; use thiserror::Error; +use uuid::Uuid; #[derive(Debug, Deserialize)] #[serde(untagged)] @@ -66,10 +67,17 @@ impl Drop for BufferMessagesGuard { let mut buffered_notifications_for = self.buffered_notifications_for.lock(); if let Some(notifications) = buffered_notifications_for.remove(&self.target_id) { if let Some(event_handlers) = self.event_handlers_weak.upgrade() { - for notification in notifications { - let notification = - notification::NotificationRef::read_as_root(¬ification).unwrap(); - event_handlers.call_callbacks_with_single_value(&self.target_id, notification); + for bytes in notifications { + let message_ref = message::MessageRef::read_as_root(&bytes).unwrap(); + + let message::BodyRef::Notification(notification_ref) = + message_ref.data().unwrap() + else { + panic!("Wrong notification stored: {message_ref:?}"); + }; + + event_handlers + .call_callbacks_with_single_value(&self.target_id, notification_ref); } } } @@ -233,16 +241,20 @@ impl Channel { match deserialize_message(message) { ChannelReceiveMessage::Notification(notification) => { - let target_id: SubscriptionTarget = SubscriptionTarget::String( - notification.handler_id().unwrap().to_string(), - ); + let target_id = notification.handler_id().unwrap(); + // Target id can be either the worker PID or a UUID. + let target_id = match target_id.parse::() { + Ok(_) => SubscriptionTarget::String(target_id.to_string()), + Err(_) => SubscriptionTarget::Uuid(Uuid::parse_str(target_id).unwrap()), + }; if !non_buffered_notifications.contains(&target_id) { let mut buffer_notifications_for = buffered_notifications_for.lock(); // Check if we need to buffer notifications for this // target_id if let Some(list) = buffer_notifications_for.get_mut(&target_id) { - list.push(Vec::from(message)); + // Store the whole message removing the size prefix. + list.push(Vec::from(&message[4..])); return; } diff --git a/rust/tests/integration/consumer.rs b/rust/tests/integration/consumer.rs index d8f29ae90f..8a4746365b 100644 --- a/rust/tests/integration/consumer.rs +++ b/rust/tests/integration/consumer.rs @@ -1371,7 +1371,6 @@ fn set_unset_priority_succeeds() { } #[test] -#[ignore] fn producer_pause_resume_events() { future::block_on(async move { let (_executor_guard, _worker, _router, transport_1, transport_2) = init().await; From 7e5c18a62c0ef97337786dbe518bae1b5ebd750b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Tue, 10 Oct 2023 13:05:36 +0200 Subject: [PATCH 38/73] Rust: add missing request (#1173) Bonus: fix test. --- rust/src/messages.rs | 80 +++++++++++++++++++++++ rust/src/router.rs | 36 +++++++++- rust/src/router/webrtc_transport/tests.rs | 16 +++-- 3 files changed, 127 insertions(+), 5 deletions(-) diff --git a/rust/src/messages.rs b/rust/src/messages.rs index 5ae6bd603b..46ada2f2a3 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -730,6 +730,86 @@ impl Request for RouterCreateWebRtcTransportRequest { type Response = WebRtcTransportData; fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let RouterCreateWebrtcTransportListen::Individual { listen_infos: _ } = self.data.listen + else { + panic!("RouterCreateWebrtcTransportListen variant must be Individual"); + }; + + let mut builder = Builder::new(); + let data = router::CreateWebRtcTransportRequest::create( + &mut builder, + self.data.transport_id.to_string(), + self.data.to_fbs(), + ); + let request_body = + request::Body::create_router_create_web_rtc_transport_request(&mut builder, data); + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::WebRtcTransportDumpResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(WebRtcTransportData { + ice_role: IceRole::from_fbs(data.ice_role), + ice_parameters: IceParameters::from_fbs(*data.ice_parameters), + ice_candidates: data + .ice_candidates + .iter() + .map(IceCandidate::from_fbs) + .collect(), + ice_state: Mutex::new(IceState::from_fbs(data.ice_state)), + ice_selected_tuple: Mutex::new( + data.ice_selected_tuple + .map(|tuple| TransportTuple::from_fbs(tuple.as_ref())), + ), + dtls_parameters: Mutex::new(DtlsParameters::from_fbs(*data.dtls_parameters)), + dtls_state: Mutex::new(DtlsState::from_fbs(data.dtls_state)), + dtls_remote_cert: Mutex::new(None), + sctp_parameters: data + .base + .sctp_parameters + .map(|parameters| SctpParameters::from_fbs(parameters.as_ref())), + sctp_state: Mutex::new( + data.base + .sctp_state + .map(|state| SctpState::from_fbs(&state)), + ), + }) + } +} + +#[derive(Debug)] +pub(crate) struct RouterCreateWebRtcTransportWithServerRequest { + pub(crate) data: RouterCreateWebrtcTransportData, +} + +impl Request for RouterCreateWebRtcTransportWithServerRequest { + const METHOD: request::Method = request::Method::RouterCreateWebrtctransportWithServer; + type HandlerId = RouterId; + type Response = WebRtcTransportData; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let RouterCreateWebrtcTransportListen::Server { + webrtc_server_id: _, + } = self.data.listen + else { + panic!("RouterCreateWebrtcTransportListen variant must be Server"); + }; + let mut builder = Builder::new(); let data = router::CreateWebRtcTransportRequest::create( &mut builder, diff --git a/rust/src/router.rs b/rust/src/router.rs index 21ac35e13e..4c1925e603 100644 --- a/rust/src/router.rs +++ b/rust/src/router.rs @@ -37,7 +37,8 @@ use crate::messages::{ RouterCreateDirectTransportRequest, RouterCreatePipeTransportData, RouterCreatePipeTransportRequest, RouterCreatePlainTransportData, RouterCreatePlainTransportRequest, RouterCreateWebRtcTransportRequest, - RouterCreateWebrtcTransportData, RouterDumpRequest, + RouterCreateWebRtcTransportWithServerRequest, RouterCreateWebrtcTransportData, + RouterDumpRequest, }; use crate::pipe_transport::{ PipeTransport, PipeTransportOptions, PipeTransportRemoteParameters, WeakPipeTransport, @@ -626,6 +627,38 @@ impl Router { let _buffer_guard = self.inner.channel.buffer_messages_for(transport_id.into()); + let data = match webrtc_transport_options.listen { + WebRtcTransportListen::Individual { listen_infos: _ } => { + self.inner + .channel + .request( + self.inner.id, + RouterCreateWebRtcTransportRequest { + data: RouterCreateWebrtcTransportData::from_options( + transport_id, + &webrtc_transport_options, + ), + }, + ) + .await? + } + WebRtcTransportListen::Server { webrtc_server: _ } => { + self.inner + .channel + .request( + self.inner.id, + RouterCreateWebRtcTransportWithServerRequest { + data: RouterCreateWebrtcTransportData::from_options( + transport_id, + &webrtc_transport_options, + ), + }, + ) + .await? + } + }; + + /* let data = self .inner .channel @@ -639,6 +672,7 @@ impl Router { }, ) .await?; + */ let transport = WebRtcTransport::new( transport_id, diff --git a/rust/src/router/webrtc_transport/tests.rs b/rust/src/router/webrtc_transport/tests.rs index 4e3cca5725..844555be4e 100644 --- a/rust/src/router/webrtc_transport/tests.rs +++ b/rust/src/router/webrtc_transport/tests.rs @@ -1,4 +1,6 @@ -use crate::data_structures::{IceCandidateType, IceState, ListenInfo, Protocol}; +use crate::data_structures::{ + IceCandidateTcpType, IceCandidateType, IceState, ListenInfo, Protocol, +}; use crate::prelude::WebRtcTransport; use crate::router::{NewTransport, Router, RouterOptions}; use crate::transport::Transport; @@ -41,7 +43,6 @@ async fn init() -> (Worker, Router) { } #[test] -#[ignore] fn create_with_webrtc_server_succeeds() { future::block_on(async move { let (worker, router) = init().await; @@ -123,12 +124,20 @@ fn create_with_webrtc_server_succeeds() { { let ice_candidates = transport.ice_candidates(); - assert_eq!(ice_candidates.len(), 1); + assert_eq!(ice_candidates.len(), 2); assert_eq!(ice_candidates[0].ip, IpAddr::V4(Ipv4Addr::LOCALHOST)); assert_eq!(ice_candidates[0].protocol, Protocol::Udp); assert_eq!(ice_candidates[0].port, port1); assert_eq!(ice_candidates[0].r#type, IceCandidateType::Host); assert_eq!(ice_candidates[0].tcp_type, None); + assert_eq!(ice_candidates[1].ip, IpAddr::V4(Ipv4Addr::LOCALHOST)); + assert_eq!(ice_candidates[1].protocol, Protocol::Tcp); + assert_eq!(ice_candidates[1].port, port2); + assert_eq!(ice_candidates[1].r#type, IceCandidateType::Host); + assert_eq!( + ice_candidates[1].tcp_type, + Some(IceCandidateTcpType::Passive) + ); } assert_eq!(transport.ice_state(), IceState::New); @@ -251,7 +260,6 @@ fn router_close_event() { } #[test] -#[ignore] fn webrtc_server_close_event() { future::block_on(async move { let (worker, router) = init().await; From 0a41ef6fcccc8b66e0d33311b2255b2128aeb61b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Tue, 10 Oct 2023 17:49:27 +0200 Subject: [PATCH 39/73] Rust: messages, fix DataProducerSendNotification --- rust/src/messages.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rust/src/messages.rs b/rust/src/messages.rs index 46ada2f2a3..32f29821bf 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -2849,7 +2849,8 @@ impl Notification for DataProducerSendNotification { Some(notification_body), ); let message_body = message::Body::create_notification(&mut builder, notification); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = + message::Message::create(&mut builder, message::Type::Notification, message_body); builder.finish(message, None).to_vec() } From 70e435513ca99610bbe788f75dfc974c99716c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Wed, 18 Oct 2023 16:16:30 +0200 Subject: [PATCH 40/73] Fix webRtcServer.dump() Fixes #1180 --- node/src/DataProducer.ts | 2 +- node/src/WebRtcServer.ts | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/node/src/DataProducer.ts b/node/src/DataProducer.ts index 9a3544bd53..43f48a09bd 100644 --- a/node/src/DataProducer.ts +++ b/node/src/DataProducer.ts @@ -520,7 +520,7 @@ export function parseDataProducerDumpResponse( function parseDataProducerStats( binary: FbsDataProducer.GetStatsResponse -):DataProducerStat +): DataProducerStat { return { type : 'data-producer', diff --git a/node/src/WebRtcServer.ts b/node/src/WebRtcServer.ts index 171299ebc4..8e1547a8be 100644 --- a/node/src/WebRtcServer.ts +++ b/node/src/WebRtcServer.ts @@ -4,6 +4,7 @@ import { Channel } from './Channel'; import { TransportListenInfo } from './Transport'; import { WebRtcTransport } from './WebRtcTransport'; import { AppData } from './types'; +import * as utils from './utils'; import { Body as RequestBody, Method } from './fbs/request'; import * as FbsWorker from './fbs/worker'; import * as FbsWebRtcServer from './fbs/web-rtc-server'; @@ -224,7 +225,7 @@ export class WebRtcServer response.body(dump); - return dump.unpack(); + return parseWebRtcServerDump(dump); } /** @@ -246,3 +247,33 @@ export class WebRtcServer }); } } + +// TODO: This function should return WebRtcServerDump TypeScript type but we +// don't have it yet (same for many other dump() methods everywhere). +function parseWebRtcServerDump( + data: FbsWebRtcServer.DumpResponse +): any +{ + return { + id : data.id(), + udpSockets : utils.parseVector( + data, 'udpSockets', (udpSocket: any) => udpSocket.unpack() + ), + tcpServers : utils.parseVector( + data, 'tcpServers', (tcpServer: any) => tcpServer.unpack() + ), + webRtcTransportIds : utils.parseVector(data, 'webRtcTransportIds'), + localIceUsernameFragments : utils.parseVector( + data, 'localIceUsernameFragments', (localIceUsernameFragment: any) => localIceUsernameFragment.unpack() + ), + tupleHashes : utils.parseVector( + data, 'tupleHashes', (tupleHash: any) => + { + return { + localIceUsernameFragment : Number(tupleHash.localIceUsernameFragment()), + webRtcTransportId : tupleHash.webRtcTransportId() + }; + } + ) + }; +} From 7f07c5110439883b3d715311b7b9e6cd723d2b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 19 Oct 2023 10:54:23 +0200 Subject: [PATCH 41/73] Enhance flatc build system (#1174) Meson: properly generate C++ flatbuffers header files - Do only generate them when the flatbuffer schemas change - Make generated FBS files a worker dependency - Create a meson.build for 'fbs' directory - Remove _generated suffix to generated fbs files --- npm-scripts.mjs | 2 +- rust/crypto_suite_fbs.patch | 53 ------------------- worker/Makefile | 16 +----- worker/fbs/meson.build | 53 +++++++++++++++++++ .../include/Channel/ChannelNotification.hpp | 2 +- worker/include/Channel/ChannelRequest.hpp | 6 +-- worker/include/RTC/Consumer.hpp | 2 +- worker/include/RTC/DtlsTransport.hpp | 2 +- worker/include/RTC/IceCandidate.hpp | 2 +- worker/include/RTC/IceServer.hpp | 2 +- worker/include/RTC/Parameters.hpp | 2 +- worker/include/RTC/PipeTransport.hpp | 2 +- worker/include/RTC/PlainTransport.hpp | 2 +- worker/include/RTC/RtpDictionaries.hpp | 2 +- worker/include/RTC/RtpStream.hpp | 2 +- worker/include/RTC/RtxStream.hpp | 2 +- worker/include/RTC/SctpDictionaries.hpp | 2 +- worker/include/RTC/SimpleConsumer.hpp | 2 +- worker/include/RTC/SimulcastConsumer.hpp | 2 +- worker/include/RTC/SrtpSession.hpp | 2 +- worker/include/RTC/Transport.hpp | 2 +- worker/include/RTC/TransportTuple.hpp | 2 +- worker/include/Worker.hpp | 2 +- worker/meson.build | 6 ++- worker/src/RTC/PipeConsumer.cpp | 2 +- worker/src/RTC/SimpleConsumer.cpp | 2 +- worker/src/RTC/Transport.cpp | 2 +- worker/src/RTC/WebRtcTransport.cpp | 2 +- worker/src/Worker.cpp | 4 +- 29 files changed, 88 insertions(+), 96 deletions(-) delete mode 100644 rust/crypto_suite_fbs.patch create mode 100644 worker/fbs/meson.build diff --git a/npm-scripts.mjs b/npm-scripts.mjs index a526283aaa..a390672051 100644 --- a/npm-scripts.mjs +++ b/npm-scripts.mjs @@ -391,7 +391,7 @@ function flatcNode(clean = false) logInfo('flatcNode()'); // Build flatc if needed. - executeCmd(`${MAKE} -C worker flatc-all`); + executeCmd(`${MAKE} -C worker flatc`); const buildType = process.env.MEDIASOUP_BUILDTYPE || 'Release'; const extension = IS_WINDOWS ? '.exe' : ''; diff --git a/rust/crypto_suite_fbs.patch b/rust/crypto_suite_fbs.patch deleted file mode 100644 index 0fe4a70870..0000000000 --- a/rust/crypto_suite_fbs.patch +++ /dev/null @@ -1,53 +0,0 @@ -diff --git a/worker/src/RTC/SrtpSession.cpp b/worker/src/RTC/SrtpSession.cpp -index 97051e0cf..d87f03ae4 100644 ---- a/worker/src/RTC/SrtpSession.cpp -+++ b/worker/src/RTC/SrtpSession.cpp -@@ -1,3 +1,4 @@ -+#include "FBS/srtpParameters_generated.h" - #define MS_CLASS "RTC::SrtpSession" - // #define MS_LOG_DEV_LEVEL 3 - -@@ -28,6 +29,43 @@ namespace RTC - } - } - -+ FBS::SrtpParameters::SrtpCryptoSuite SrtpSession::CryptoSuiteToFbs(CryptoSuite cryptoSuite) -+ { -+ switch (cryptoSuite) -+ { -+ case SrtpSession::CryptoSuite::AEAD_AES_256_GCM: -+ return FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_256_GCM; -+ -+ case SrtpSession::CryptoSuite::AEAD_AES_128_GCM: -+ return FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_128_GCM; -+ -+ case SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_80: -+ return FBS::SrtpParameters::SrtpCryptoSuite::AES_CM_128_HMAC_SHA1_80; -+ -+ case SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_32: -+ return FBS::SrtpParameters::SrtpCryptoSuite::AES_CM_128_HMAC_SHA1_32; -+ } -+ } -+ -+ SrtpSession::CryptoSuite SrtpSession::CryptoSuiteFromFbs(FBS::SrtpParameters::SrtpCryptoSuite cryptoSuite) -+ { -+ switch (cryptoSuite) -+ { -+ case FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_256_GCM: -+ return SrtpSession::CryptoSuite::AEAD_AES_256_GCM; -+ -+ case FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_128_GCM: -+ return SrtpSession::CryptoSuite::AEAD_AES_128_GCM; -+ -+ case FBS::SrtpParameters::SrtpCryptoSuite::AES_CM_128_HMAC_SHA1_80: -+ return SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_80; -+ -+ case FBS::SrtpParameters::SrtpCryptoSuite::AES_CM_128_HMAC_SHA1_32: -+ return SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_32; -+ } -+ -+ } -+ - void SrtpSession::OnSrtpEvent(srtp_event_data_t* data) - { - MS_TRACE(); diff --git a/worker/Makefile b/worker/Makefile index 90cb17f565..be41dd515f 100644 --- a/worker/Makefile +++ b/worker/Makefile @@ -21,8 +21,6 @@ INSTALL_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) BUILD_DIR ?= $(INSTALL_DIR)/build MESON ?= $(PIP_DIR)/bin/meson MESON_VERSION ?= 1.2.1 -FLATC ?= $(BUILD_DIR)/subprojects/flatbuffers-23.3.3/flatc -FLATC_OUT_DIR ?= ./include/FBS # `MESON_ARGS` can be used to provide extra configuration parameters to Meson, # such as adding defines or changing optimization options. For instance, use # `MESON_ARGS="-Dms_log_trace=true -Dms_log_file_line=true" npm i` to compile @@ -209,17 +207,7 @@ libmediasoup-worker: setup flatc $(MESON) install -C $(BUILD_DIR) --no-rebuild --tags libmediasoup-worker flatc: setup - $(MESON) compile -C $(BUILD_DIR) flatc - [ -d $(FLATC_OUT_DIR) ] || \ - $(FLATC) --cpp --cpp-field-case-style lower --reflect-names --scoped-enums \ - -o $(FLATC_OUT_DIR) ./fbs/* - -flatc-clean: - $(RM) -rf $(FLATC_OUT_DIR) - -flatc-force: flatc-clean flatc - -flatc-all: setup flatc + $(MESON) compile -C $(BUILD_DIR) flatbuffers-generator xcode: setup $(MESON) setup --buildtype debug --backend xcode $(MEDIASOUP_OUT_DIR)/xcode @@ -230,7 +218,7 @@ lint: format: $(GULP) --gulpfile ./scripts/gulpfile.mjs format:worker -test: setup +test: setup flatc $(MESON) compile -C $(BUILD_DIR) -j $(CORES) mediasoup-worker-test $(MESON) install -C $(BUILD_DIR) --no-rebuild --tags mediasoup-worker-test ifeq ($(OS),Windows_NT) diff --git a/worker/fbs/meson.build b/worker/fbs/meson.build new file mode 100644 index 0000000000..5394c8bddf --- /dev/null +++ b/worker/fbs/meson.build @@ -0,0 +1,53 @@ +flatbuffers_schemas = [ + 'activeSpeakerObserver.fbs', + 'audioLevelObserver.fbs', + 'common.fbs', + 'consumer.fbs', + 'dataConsumer.fbs', + 'dataProducer.fbs', + 'directTransport.fbs', + 'log.fbs', + 'message.fbs', + 'notification.fbs', + 'pipeTransport.fbs', + 'plainTransport.fbs', + 'producer.fbs', + 'request.fbs', + 'response.fbs', + 'router.fbs', + 'rtpObserver.fbs', + 'rtpParameters.fbs', + 'rtpStream.fbs', + 'rtxStream.fbs', + 'sctpAssociation.fbs', + 'sctpParameters.fbs', + 'srtpParameters.fbs', + 'transport.fbs', + 'webRtcServer.fbs', + 'webRtcTransport.fbs', + 'worker.fbs', +] + +# Directory from which worker code will include the header files. +flatbuffers_cpp_out_dir = 'FBS' + +flatc = find_program('flatc') +flatbuffers_generator = custom_target('flatbuffers-generator', + output: flatbuffers_cpp_out_dir, + input: flatbuffers_schemas, + command : [ + flatc, + '--cpp', + '--cpp-field-case-style', 'lower', + '--reflect-names', + '--scoped-enums', + '--filename-suffix', '', + '-o', '@OUTPUT@', + '@INPUT@' + ], + build_by_default: true, +) + +flatbuffers_generator_dep = declare_dependency( + include_directories: '.', +) diff --git a/worker/include/Channel/ChannelNotification.hpp b/worker/include/Channel/ChannelNotification.hpp index 05fdf7d290..2aa940656d 100644 --- a/worker/include/Channel/ChannelNotification.hpp +++ b/worker/include/Channel/ChannelNotification.hpp @@ -2,7 +2,7 @@ #define MS_CHANNEL_NOTIFICATION_HPP #include "common.hpp" -#include "FBS/notification_generated.h" +#include "FBS/notification.h" #include #include diff --git a/worker/include/Channel/ChannelRequest.hpp b/worker/include/Channel/ChannelRequest.hpp index d718d9aaa2..0351204362 100644 --- a/worker/include/Channel/ChannelRequest.hpp +++ b/worker/include/Channel/ChannelRequest.hpp @@ -2,9 +2,9 @@ #define MS_CHANNEL_REQUEST_HPP #include "common.hpp" -#include "FBS/message_generated.h" -#include "FBS/request_generated.h" -#include "FBS/response_generated.h" +#include "FBS/message.h" +#include "FBS/request.h" +#include "FBS/response.h" #include #include #include diff --git a/worker/include/RTC/Consumer.hpp b/worker/include/RTC/Consumer.hpp index ecb41bc839..8d3a25c95e 100644 --- a/worker/include/RTC/Consumer.hpp +++ b/worker/include/RTC/Consumer.hpp @@ -4,7 +4,7 @@ #include "common.hpp" #include "Channel/ChannelRequest.hpp" #include "Channel/ChannelSocket.hpp" -#include "FBS/consumer_generated.h" +#include "FBS/consumer.h" #include "RTC/RTCP/CompoundPacket.hpp" #include "RTC/RTCP/FeedbackPs.hpp" #include "RTC/RTCP/FeedbackPsFir.hpp" diff --git a/worker/include/RTC/DtlsTransport.hpp b/worker/include/RTC/DtlsTransport.hpp index 93b81bbd7c..bb635ea42f 100644 --- a/worker/include/RTC/DtlsTransport.hpp +++ b/worker/include/RTC/DtlsTransport.hpp @@ -2,7 +2,7 @@ #define MS_RTC_DTLS_TRANSPORT_HPP #include "common.hpp" -#include "FBS/webRtcTransport_generated.h" +#include "FBS/webRtcTransport.h" #include "RTC/SrtpSession.hpp" #include "handles/TimerHandle.hpp" #include diff --git a/worker/include/RTC/IceCandidate.hpp b/worker/include/RTC/IceCandidate.hpp index db1a9e047b..3993b9bef1 100644 --- a/worker/include/RTC/IceCandidate.hpp +++ b/worker/include/RTC/IceCandidate.hpp @@ -2,7 +2,7 @@ #define MS_RTC_ICE_CANDIDATE_HPP #include "common.hpp" -#include "FBS/webRtcTransport_generated.h" +#include "FBS/webRtcTransport.h" #include "RTC/TcpServer.hpp" #include "RTC/TransportTuple.hpp" #include "RTC/UdpSocket.hpp" diff --git a/worker/include/RTC/IceServer.hpp b/worker/include/RTC/IceServer.hpp index acbdea2909..35aa636d99 100644 --- a/worker/include/RTC/IceServer.hpp +++ b/worker/include/RTC/IceServer.hpp @@ -2,7 +2,7 @@ #define MS_RTC_ICE_SERVER_HPP #include "common.hpp" -#include "FBS/webRtcTransport_generated.h" +#include "FBS/webRtcTransport.h" #include "RTC/StunPacket.hpp" #include "RTC/TransportTuple.hpp" #include diff --git a/worker/include/RTC/Parameters.hpp b/worker/include/RTC/Parameters.hpp index c0ac24b049..0bbd89cde6 100644 --- a/worker/include/RTC/Parameters.hpp +++ b/worker/include/RTC/Parameters.hpp @@ -2,7 +2,7 @@ #define MS_RTC_PARAMETERS_HPP #include "common.hpp" -#include "FBS/rtpParameters_generated.h" +#include "FBS/rtpParameters.h" #include #include #include diff --git a/worker/include/RTC/PipeTransport.hpp b/worker/include/RTC/PipeTransport.hpp index 6a2d803648..1c08492a42 100644 --- a/worker/include/RTC/PipeTransport.hpp +++ b/worker/include/RTC/PipeTransport.hpp @@ -1,7 +1,7 @@ #ifndef MS_RTC_PIPE_TRANSPORT_HPP #define MS_RTC_PIPE_TRANSPORT_HPP -#include "FBS/pipeTransport_generated.h" +#include "FBS/pipeTransport.h" #include "RTC/Shared.hpp" #include "RTC/SrtpSession.hpp" #include "RTC/Transport.hpp" diff --git a/worker/include/RTC/PlainTransport.hpp b/worker/include/RTC/PlainTransport.hpp index 5b728a406a..ad9783618f 100644 --- a/worker/include/RTC/PlainTransport.hpp +++ b/worker/include/RTC/PlainTransport.hpp @@ -1,7 +1,7 @@ #ifndef MS_RTC_PLAIN_TRANSPORT_HPP #define MS_RTC_PLAIN_TRANSPORT_HPP -#include "FBS/plainTransport_generated.h" +#include "FBS/plainTransport.h" #include "RTC/Shared.hpp" #include "RTC/SrtpSession.hpp" #include "RTC/Transport.hpp" diff --git a/worker/include/RTC/RtpDictionaries.hpp b/worker/include/RTC/RtpDictionaries.hpp index fc60435758..caf3211f1a 100644 --- a/worker/include/RTC/RtpDictionaries.hpp +++ b/worker/include/RTC/RtpDictionaries.hpp @@ -2,7 +2,7 @@ #define MS_RTC_RTP_DICTIONARIES_HPP #include "common.hpp" -#include "FBS/rtpParameters_generated.h" +#include "FBS/rtpParameters.h" #include "RTC/Parameters.hpp" #include #include diff --git a/worker/include/RTC/RtpStream.hpp b/worker/include/RTC/RtpStream.hpp index 5a3224fdcd..80e86a0dd5 100644 --- a/worker/include/RTC/RtpStream.hpp +++ b/worker/include/RTC/RtpStream.hpp @@ -3,7 +3,7 @@ #include "common.hpp" #include "DepLibUV.hpp" -#include "FBS/rtpStream_generated.h" +#include "FBS/rtpStream.h" #include "RTC/RTCP/FeedbackPsFir.hpp" #include "RTC/RTCP/FeedbackPsPli.hpp" #include "RTC/RTCP/FeedbackRtpNack.hpp" diff --git a/worker/include/RTC/RtxStream.hpp b/worker/include/RTC/RtxStream.hpp index c0d862b063..e8c312ab92 100644 --- a/worker/include/RTC/RtxStream.hpp +++ b/worker/include/RTC/RtxStream.hpp @@ -3,7 +3,7 @@ #include "common.hpp" #include "DepLibUV.hpp" -#include "FBS/rtxStream_generated.h" +#include "FBS/rtxStream.h" #include "RTC/RTCP/Packet.hpp" #include "RTC/RTCP/ReceiverReport.hpp" #include "RTC/RTCP/SenderReport.hpp" diff --git a/worker/include/RTC/SctpDictionaries.hpp b/worker/include/RTC/SctpDictionaries.hpp index 162d26b830..25862a70a1 100644 --- a/worker/include/RTC/SctpDictionaries.hpp +++ b/worker/include/RTC/SctpDictionaries.hpp @@ -2,7 +2,7 @@ #define MS_RTC_SCTP_DICTIONARIES_HPP #include "common.hpp" -#include +#include namespace RTC { diff --git a/worker/include/RTC/SimpleConsumer.hpp b/worker/include/RTC/SimpleConsumer.hpp index 7421256eef..d502801e9b 100644 --- a/worker/include/RTC/SimpleConsumer.hpp +++ b/worker/include/RTC/SimpleConsumer.hpp @@ -1,7 +1,7 @@ #ifndef MS_RTC_SIMPLE_CONSUMER_HPP #define MS_RTC_SIMPLE_CONSUMER_HPP -#include "FBS/transport_generated.h" +#include "FBS/transport.h" #include "RTC/Consumer.hpp" #include "RTC/SeqManager.hpp" #include "RTC/Shared.hpp" diff --git a/worker/include/RTC/SimulcastConsumer.hpp b/worker/include/RTC/SimulcastConsumer.hpp index 981a304418..fcce57adb4 100644 --- a/worker/include/RTC/SimulcastConsumer.hpp +++ b/worker/include/RTC/SimulcastConsumer.hpp @@ -1,7 +1,7 @@ #ifndef MS_RTC_SIMULCAST_CONSUMER_HPP #define MS_RTC_SIMULCAST_CONSUMER_HPP -#include "FBS/consumer_generated.h" +#include "FBS/consumer.h" #include "RTC/Codecs/PayloadDescriptorHandler.hpp" #include "RTC/Consumer.hpp" #include "RTC/SeqManager.hpp" diff --git a/worker/include/RTC/SrtpSession.hpp b/worker/include/RTC/SrtpSession.hpp index 61108b6cee..fa14a14760 100644 --- a/worker/include/RTC/SrtpSession.hpp +++ b/worker/include/RTC/SrtpSession.hpp @@ -2,7 +2,7 @@ #define MS_RTC_SRTP_SESSION_HPP #include "common.hpp" -#include "FBS/srtpParameters_generated.h" +#include "FBS/srtpParameters.h" #include namespace RTC diff --git a/worker/include/RTC/Transport.hpp b/worker/include/RTC/Transport.hpp index eb0013677b..61bdd3ec65 100644 --- a/worker/include/RTC/Transport.hpp +++ b/worker/include/RTC/Transport.hpp @@ -7,7 +7,7 @@ #include "Channel/ChannelNotification.hpp" #include "Channel/ChannelRequest.hpp" #include "Channel/ChannelSocket.hpp" -#include "FBS/transport_generated.h" +#include "FBS/transport.h" #include "RTC/Consumer.hpp" #include "RTC/DataConsumer.hpp" #include "RTC/DataProducer.hpp" diff --git a/worker/include/RTC/TransportTuple.hpp b/worker/include/RTC/TransportTuple.hpp index efc37ad2bf..75c124ecd4 100644 --- a/worker/include/RTC/TransportTuple.hpp +++ b/worker/include/RTC/TransportTuple.hpp @@ -3,7 +3,7 @@ #include "common.hpp" #include "Utils.hpp" -#include "FBS/transport_generated.h" +#include "FBS/transport.h" #include "RTC/TcpConnection.hpp" #include "RTC/UdpSocket.hpp" #include diff --git a/worker/include/Worker.hpp b/worker/include/Worker.hpp index 90f75bf600..b5d5b79024 100644 --- a/worker/include/Worker.hpp +++ b/worker/include/Worker.hpp @@ -4,7 +4,7 @@ #include "common.hpp" #include "Channel/ChannelRequest.hpp" #include "Channel/ChannelSocket.hpp" -#include "FBS/worker_generated.h" +#include "FBS/worker.h" #include "RTC/Router.hpp" #include "RTC/Shared.hpp" #include "RTC/WebRtcServer.hpp" diff --git a/worker/meson.build b/worker/meson.build index 9da9775242..52c2244af4 100644 --- a/worker/meson.build +++ b/worker/meson.build @@ -213,7 +213,10 @@ flatbuffers_proj = subproject( 'warning_level=0', ], ) -libwebrtc_include_directories = include_directories('include') +# flatbuffers schemas subdirectory. +subdir('fbs') +# Add current build directory so libwebrtc has access to FBS folder. +libwebrtc_include_directories = include_directories('include', 'fbs') subdir('deps/libwebrtc') dependencies = [ @@ -223,6 +226,7 @@ dependencies = [ libsrtp2_proj.get_variable('libsrtp2_dep'), usrsctp_proj.get_variable('usrsctp_dep'), flatbuffers_proj.get_variable('flatbuffers_dep'), + flatbuffers_generator_dep, libwebrtc_dep, ] diff --git a/worker/src/RTC/PipeConsumer.cpp b/worker/src/RTC/PipeConsumer.cpp index d5e96f6a74..3af878f6db 100644 --- a/worker/src/RTC/PipeConsumer.cpp +++ b/worker/src/RTC/PipeConsumer.cpp @@ -1,4 +1,4 @@ -#include "FBS/consumer_generated.h" +#include "FBS/consumer.h" #define MS_CLASS "RTC::PipeConsumer" // #define MS_LOG_DEV_LEVEL 3 diff --git a/worker/src/RTC/SimpleConsumer.cpp b/worker/src/RTC/SimpleConsumer.cpp index 96889142f8..9f05f36dfe 100644 --- a/worker/src/RTC/SimpleConsumer.cpp +++ b/worker/src/RTC/SimpleConsumer.cpp @@ -1,4 +1,4 @@ -#include "FBS/consumer_generated.h" +#include "FBS/consumer.h" #define MS_CLASS "RTC::SimpleConsumer" // #define MS_LOG_DEV_LEVEL 3 diff --git a/worker/src/RTC/Transport.cpp b/worker/src/RTC/Transport.cpp index 38e8f35f01..e4c39263ff 100644 --- a/worker/src/RTC/Transport.cpp +++ b/worker/src/RTC/Transport.cpp @@ -5,7 +5,7 @@ #include "Logger.hpp" #include "MediaSoupErrors.hpp" #include "Utils.hpp" -#include "FBS/transport_generated.h" +#include "FBS/transport.h" #include "RTC/BweType.hpp" #include "RTC/PipeConsumer.hpp" #include "RTC/RTCP/FeedbackPs.hpp" diff --git a/worker/src/RTC/WebRtcTransport.cpp b/worker/src/RTC/WebRtcTransport.cpp index 9aabf97ab7..b28effdb0d 100644 --- a/worker/src/RTC/WebRtcTransport.cpp +++ b/worker/src/RTC/WebRtcTransport.cpp @@ -5,7 +5,7 @@ #include "Logger.hpp" #include "MediaSoupErrors.hpp" #include "Utils.hpp" -#include "FBS/webRtcTransport_generated.h" +#include "FBS/webRtcTransport.h" #include // std::pow() namespace RTC diff --git a/worker/src/Worker.cpp b/worker/src/Worker.cpp index 5a0b42e372..46c63d4215 100644 --- a/worker/src/Worker.cpp +++ b/worker/src/Worker.cpp @@ -9,8 +9,8 @@ #include "MediaSoupErrors.hpp" #include "Settings.hpp" #include "Channel/ChannelNotifier.hpp" -#include "FBS/response_generated.h" -#include "FBS/worker_generated.h" +#include "FBS/response.h" +#include "FBS/worker.h" /* Instance methods. */ From 5574b11529a0b95243a40620266550b4828e56ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 19 Oct 2023 18:20:54 +0200 Subject: [PATCH 42/73] Fbs RTP trace info (#1183) FBS: RTP trace info Also fix flatbuffers include statement order --- npm-scripts.mjs | 2 +- rust/src/data_structures.rs | 36 +- rust/src/fbs.rs | 1351 +++++++++++++++++++-- rust/src/router/consumer.rs | 8 +- rust/src/router/producer.rs | 8 +- worker/.clang-format | 2 +- worker/fbs/consumer.fbs | 3 + worker/fbs/meson.build | 1 + worker/fbs/producer.fbs | 3 + worker/fbs/rtpPacket.fbs | 20 + worker/include/Channel/ChannelRequest.hpp | 2 +- worker/include/RTC/RtpPacket.hpp | 3 + worker/include/RTC/WebRtcServer.hpp | 2 +- worker/include/Worker.hpp | 2 +- worker/src/RTC/Consumer.cpp | 10 +- worker/src/RTC/Producer.cpp | 10 +- worker/src/RTC/RtpPacket.cpp | 56 + worker/src/Settings.cpp | 2 +- 18 files changed, 1369 insertions(+), 152 deletions(-) create mode 100644 worker/fbs/rtpPacket.fbs diff --git a/npm-scripts.mjs b/npm-scripts.mjs index 6ca1442f5b..23fc6ac535 100644 --- a/npm-scripts.mjs +++ b/npm-scripts.mjs @@ -397,7 +397,7 @@ function flatcNode(clean = false) const extension = IS_WINDOWS ? '.exe' : ''; const flatc = path.resolve(path.join( 'worker', 'out', buildType, 'build', 'subprojects', `flatbuffers-${FLATBUFFERS_VERSION}`, `flatc${extension}`)); - const src = path.resolve(path.join('worker', 'fbs', '*')); + const src = path.resolve(path.join('worker', 'fbs', '*.fbs')); const out = path.resolve(path.join('node', 'src')); const options = '--ts-no-import-ext --gen-object-api'; const command = `${flatc} --ts ${options} -o ${out} `; diff --git a/rust/src/data_structures.rs b/rust/src/data_structures.rs index 0b4a698f38..512165fc26 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, sctp_association, transport, web_rtc_transport}; +use crate::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}; @@ -1114,8 +1114,6 @@ pub enum OwnedWebRtcMessage { EmptyBinary, } -/** - * TODO. Implement FBS conversion. /// RTP packet info in trace event. #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] @@ -1133,9 +1131,9 @@ pub struct RtpPacketTraceInfo { /// Whether packet contains a key frame. pub is_key_frame: bool, /// Packet size. - pub size: usize, + pub size: u64, /// Payload size. - pub payload_size: usize, + pub payload_size: u64, /// The spatial layer index (from 0 to N). pub spatial_layer: u8, /// The temporal layer index (from 0 to N). @@ -1152,15 +1150,27 @@ pub struct RtpPacketTraceInfo { #[serde(default)] pub is_rtx: bool, } -*/ -/// RTP packet info in trace event. -#[derive(Debug, Clone, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct RtpPacketTraceInfo { - /// Whether this is an RTX packet. - #[serde(default)] - pub is_rtx: bool, +impl RtpPacketTraceInfo { + pub(crate) fn from_fbs(rtp_packet: rtp_packet::Dump, is_rtx: bool) -> Self { + Self { + payload_type: rtp_packet.payload_type, + sequence_number: rtp_packet.sequence_number, + timestamp: rtp_packet.timestamp, + marker: rtp_packet.marker, + ssrc: rtp_packet.ssrc, + is_key_frame: rtp_packet.is_key_frame, + size: rtp_packet.size, + payload_size: rtp_packet.payload_size, + spatial_layer: rtp_packet.spatial_layer, + temporal_layer: rtp_packet.temporal_layer, + mid: rtp_packet.mid, + rid: rtp_packet.rid, + rrid: rtp_packet.rrid, + wide_sequence_number: rtp_packet.wide_sequence_number, + is_rtx, + } + } } /// SSRC info in trace event. diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index 23d5031f30..088a38fb0e 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -3245,7 +3245,7 @@ mod root { /// The table `ConsumerLayers` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `ConsumerLayers` in the file `../worker/fbs/consumer.fbs:7` + /// * Table `ConsumerLayers` in the file `../worker/fbs/consumer.fbs:8` #[derive( Clone, Debug, @@ -3584,7 +3584,7 @@ mod root { /// The table `ConsumerScore` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `ConsumerScore` in the file `../worker/fbs/consumer.fbs:12` + /// * Table `ConsumerScore` in the file `../worker/fbs/consumer.fbs:13` #[derive( Clone, Debug, @@ -3945,7 +3945,7 @@ mod root { /// The table `SetPreferredLayersRequest` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `SetPreferredLayersRequest` in the file `../worker/fbs/consumer.fbs:18` + /// * Table `SetPreferredLayersRequest` in the file `../worker/fbs/consumer.fbs:19` #[derive( Clone, Debug, @@ -4231,7 +4231,7 @@ mod root { /// The table `SetPreferredLayersResponse` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `SetPreferredLayersResponse` in the file `../worker/fbs/consumer.fbs:22` + /// * Table `SetPreferredLayersResponse` in the file `../worker/fbs/consumer.fbs:23` #[derive( Clone, Debug, @@ -4548,7 +4548,7 @@ mod root { /// The table `SetPriorityRequest` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `SetPriorityRequest` in the file `../worker/fbs/consumer.fbs:26` + /// * Table `SetPriorityRequest` in the file `../worker/fbs/consumer.fbs:27` #[derive( Clone, Debug, @@ -4832,7 +4832,7 @@ mod root { /// The table `SetPriorityResponse` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `SetPriorityResponse` in the file `../worker/fbs/consumer.fbs:30` + /// * Table `SetPriorityResponse` in the file `../worker/fbs/consumer.fbs:31` #[derive( Clone, Debug, @@ -5120,7 +5120,7 @@ mod root { /// The enum `TraceEventType` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Enum `TraceEventType` in the file `../worker/fbs/consumer.fbs:34` + /// * Enum `TraceEventType` in the file `../worker/fbs/consumer.fbs:35` #[derive( Copy, Clone, @@ -5303,7 +5303,7 @@ mod root { /// The table `EnableTraceEventRequest` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/consumer.fbs:42` + /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/consumer.fbs:43` #[derive( Clone, Debug, @@ -5581,7 +5581,7 @@ mod root { /// The table `DumpResponse` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/consumer.fbs:46` + /// * Table `DumpResponse` in the file `../worker/fbs/consumer.fbs:47` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -5832,7 +5832,7 @@ mod root { /// The table `BaseConsumerDump` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `BaseConsumerDump` in the file `../worker/fbs/consumer.fbs:50` + /// * Table `BaseConsumerDump` in the file `../worker/fbs/consumer.fbs:51` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -6636,7 +6636,7 @@ mod root { /// The table `ConsumerDump` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `ConsumerDump` in the file `../worker/fbs/consumer.fbs:64` + /// * Table `ConsumerDump` in the file `../worker/fbs/consumer.fbs:65` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -7325,7 +7325,7 @@ mod root { /// The table `GetStatsResponse` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/consumer.fbs:75` + /// * Table `GetStatsResponse` in the file `../worker/fbs/consumer.fbs:76` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -7592,7 +7592,7 @@ mod root { /// The table `LayersChangeNotification` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `LayersChangeNotification` in the file `../worker/fbs/consumer.fbs:81` + /// * Table `LayersChangeNotification` in the file `../worker/fbs/consumer.fbs:82` #[derive( Clone, Debug, @@ -7873,7 +7873,7 @@ mod root { /// The table `RtpNotification` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `RtpNotification` in the file `../worker/fbs/consumer.fbs:85` + /// * Table `RtpNotification` in the file `../worker/fbs/consumer.fbs:86` #[derive( Clone, Debug, @@ -8131,7 +8131,7 @@ mod root { /// The table `ScoreNotification` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `ScoreNotification` in the file `../worker/fbs/consumer.fbs:89` + /// * Table `ScoreNotification` in the file `../worker/fbs/consumer.fbs:90` #[derive( Clone, Debug, @@ -8391,7 +8391,7 @@ mod root { /// The union `TraceInfo` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Union `TraceInfo` in the file `../worker/fbs/consumer.fbs:93` + /// * Union `TraceInfo` in the file `../worker/fbs/consumer.fbs:94` #[derive( Clone, Debug, @@ -8723,7 +8723,7 @@ mod root { /// The table `KeyFrameTraceInfo` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/consumer.fbs:100` + /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/consumer.fbs:101` #[derive( Clone, Debug, @@ -8736,6 +8736,8 @@ mod root { ::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, } @@ -8743,7 +8745,10 @@ mod root { #[allow(clippy::derivable_impls)] impl ::core::default::Default for KeyFrameTraceInfo { fn default() -> Self { - Self { is_rtx: false } + Self { + rtp_packet: ::core::default::Default::default(), + is_rtx: false, + } } } @@ -8757,18 +8762,22 @@ mod root { #[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<6> = + 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::(0); + 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); } @@ -8808,7 +8817,7 @@ mod root { &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - KeyFrameTraceInfo::create(builder, self.is_rtx) + KeyFrameTraceInfo::create(builder, &self.rtp_packet, self.is_rtx) } } @@ -8820,27 +8829,40 @@ mod root { pub struct KeyFrameTraceInfoBuilder(State); impl KeyFrameTraceInfoBuilder<()> { - /// Setter for the [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx). + /// Setter for the [`rtp_packet` field](KeyFrameTraceInfo#structfield.rtp_packet). #[inline] #[allow(clippy::type_complexity)] - pub fn is_rtx(self, value: T0) -> KeyFrameTraceInfoBuilder<(T0,)> + pub fn rtp_packet(self, value: T0) -> KeyFrameTraceInfoBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + 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<(::planus::DefaultValue,)> { + ) -> KeyFrameTraceInfoBuilder<(T0, ::planus::DefaultValue)> { self.is_rtx(::planus::DefaultValue) } } - impl KeyFrameTraceInfoBuilder<(T0,)> { + impl KeyFrameTraceInfoBuilder<(T0, T1)> { /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [KeyFrameTraceInfo]. #[inline] pub fn finish( @@ -8854,9 +8876,11 @@ mod root { } } - impl> - ::planus::WriteAs<::planus::Offset> - for KeyFrameTraceInfoBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, + > ::planus::WriteAs<::planus::Offset> + for KeyFrameTraceInfoBuilder<(T0, T1)> { type Prepared = ::planus::Offset; @@ -8869,9 +8893,11 @@ mod root { } } - impl> - ::planus::WriteAsOptional<::planus::Offset> - for KeyFrameTraceInfoBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, + > ::planus::WriteAsOptional<::planus::Offset> + for KeyFrameTraceInfoBuilder<(T0, T1)> { type Prepared = ::planus::Offset; @@ -8884,16 +8910,19 @@ mod root { } } - impl> - ::planus::WriteAsOffset for KeyFrameTraceInfoBuilder<(T0,)> + 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,) = &self.0; - KeyFrameTraceInfo::create(builder, v0) + let (v0, v1) = &self.0; + KeyFrameTraceInfo::create(builder, v0, v1) } } @@ -8902,12 +8931,18 @@ mod root { 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(0, "KeyFrameTraceInfo", "is_rtx")? + .access(1, "KeyFrameTraceInfo", "is_rtx")? .unwrap_or(false), ) } @@ -8916,6 +8951,7 @@ mod root { 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() } @@ -8927,6 +8963,9 @@ mod root { #[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()?)?, }) } @@ -9005,7 +9044,7 @@ mod root { /// The table `FirTraceInfo` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `FirTraceInfo` in the file `../worker/fbs/consumer.fbs:104` + /// * Table `FirTraceInfo` in the file `../worker/fbs/consumer.fbs:106` #[derive( Clone, Debug, @@ -9282,7 +9321,7 @@ mod root { /// The table `PliTraceInfo` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `PliTraceInfo` in the file `../worker/fbs/consumer.fbs:108` + /// * Table `PliTraceInfo` in the file `../worker/fbs/consumer.fbs:110` #[derive( Clone, Debug, @@ -9559,7 +9598,7 @@ mod root { /// The table `RtpTraceInfo` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `RtpTraceInfo` in the file `../worker/fbs/consumer.fbs:112` + /// * Table `RtpTraceInfo` in the file `../worker/fbs/consumer.fbs:114` #[derive( Clone, Debug, @@ -9572,6 +9611,8 @@ mod root { ::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, } @@ -9579,7 +9620,10 @@ mod root { #[allow(clippy::derivable_impls)] impl ::core::default::Default for RtpTraceInfo { fn default() -> Self { - Self { is_rtx: false } + Self { + rtp_packet: ::core::default::Default::default(), + is_rtx: false, + } } } @@ -9593,18 +9637,22 @@ mod root { #[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<6> = + 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::(0); + 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); } @@ -9644,7 +9692,7 @@ mod root { &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - RtpTraceInfo::create(builder, self.is_rtx) + RtpTraceInfo::create(builder, &self.rtp_packet, self.is_rtx) } } @@ -9656,25 +9704,40 @@ mod root { pub struct RtpTraceInfoBuilder(State); impl RtpTraceInfoBuilder<()> { - /// Setter for the [`is_rtx` field](RtpTraceInfo#structfield.is_rtx). + /// Setter for the [`rtp_packet` field](RtpTraceInfo#structfield.rtp_packet). #[inline] #[allow(clippy::type_complexity)] - pub fn is_rtx(self, value: T0) -> RtpTraceInfoBuilder<(T0,)> + pub fn rtp_packet(self, value: T0) -> RtpTraceInfoBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + 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<(::planus::DefaultValue,)> { + pub fn is_rtx_as_default( + self, + ) -> RtpTraceInfoBuilder<(T0, ::planus::DefaultValue)> { self.is_rtx(::planus::DefaultValue) } } - impl RtpTraceInfoBuilder<(T0,)> { + impl RtpTraceInfoBuilder<(T0, T1)> { /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtpTraceInfo]. #[inline] pub fn finish( @@ -9688,8 +9751,11 @@ mod root { } } - impl> - ::planus::WriteAs<::planus::Offset> for RtpTraceInfoBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, + > ::planus::WriteAs<::planus::Offset> + for RtpTraceInfoBuilder<(T0, T1)> { type Prepared = ::planus::Offset; @@ -9702,9 +9768,11 @@ mod root { } } - impl> - ::planus::WriteAsOptional<::planus::Offset> - for RtpTraceInfoBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, + > ::planus::WriteAsOptional<::planus::Offset> + for RtpTraceInfoBuilder<(T0, T1)> { type Prepared = ::planus::Offset; @@ -9717,16 +9785,18 @@ mod root { } } - impl> ::planus::WriteAsOffset - for RtpTraceInfoBuilder<(T0,)> + 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,) = &self.0; - RtpTraceInfo::create(builder, v0) + let (v0, v1) = &self.0; + RtpTraceInfo::create(builder, v0, v1) } } @@ -9735,11 +9805,17 @@ mod root { 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(0, "RtpTraceInfo", "is_rtx")?.unwrap_or(false), + self.0.access(1, "RtpTraceInfo", "is_rtx")?.unwrap_or(false), ) } } @@ -9747,6 +9823,7 @@ mod root { 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() } @@ -9758,6 +9835,9 @@ mod root { #[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()?)?, }) } @@ -9836,7 +9916,7 @@ mod root { /// The table `TraceNotification` in the namespace `FBS.Consumer` /// /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/consumer.fbs:116` + /// * Table `TraceNotification` in the file `../worker/fbs/consumer.fbs:119` #[derive( Clone, Debug, @@ -10304,6 +10384,971 @@ mod root { } } } + /// 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: @@ -63853,7 +64898,7 @@ mod root { /// The enum `TraceEventType` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Enum `TraceEventType` in the file `../worker/fbs/producer.fbs:7` + /// * Enum `TraceEventType` in the file `../worker/fbs/producer.fbs:8` #[derive( Copy, Clone, @@ -64036,7 +65081,7 @@ mod root { /// The table `EnableTraceEventRequest` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/producer.fbs:15` + /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/producer.fbs:16` #[derive( Clone, Debug, @@ -64314,7 +65359,7 @@ mod root { /// The table `DumpResponse` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/producer.fbs:19` + /// * Table `DumpResponse` in the file `../worker/fbs/producer.fbs:20` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -64919,7 +65964,7 @@ mod root { /// The table `GetStatsResponse` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/producer.fbs:30` + /// * Table `GetStatsResponse` in the file `../worker/fbs/producer.fbs:31` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -65186,7 +66231,7 @@ mod root { /// The table `SendNotification` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `SendNotification` in the file `../worker/fbs/producer.fbs:34` + /// * Table `SendNotification` in the file `../worker/fbs/producer.fbs:35` #[derive( Clone, Debug, @@ -65444,7 +66489,7 @@ mod root { /// The table `Score` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `Score` in the file `../worker/fbs/producer.fbs:40` + /// * Table `Score` in the file `../worker/fbs/producer.fbs:41` #[derive( Clone, Debug, @@ -65850,7 +66895,7 @@ mod root { /// The table `ScoreNotification` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `ScoreNotification` in the file `../worker/fbs/producer.fbs:47` + /// * Table `ScoreNotification` in the file `../worker/fbs/producer.fbs:48` #[derive( Clone, Debug, @@ -66114,7 +67159,7 @@ mod root { /// The table `VideoOrientationChangeNotification` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `VideoOrientationChangeNotification` in the file `../worker/fbs/producer.fbs:51` + /// * Table `VideoOrientationChangeNotification` in the file `../worker/fbs/producer.fbs:52` #[derive( Clone, Debug, @@ -66537,7 +67582,7 @@ mod root { /// The union `TraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Union `TraceInfo` in the file `../worker/fbs/producer.fbs:57` + /// * Union `TraceInfo` in the file `../worker/fbs/producer.fbs:58` #[derive( Clone, Debug, @@ -66869,7 +67914,7 @@ mod root { /// The table `KeyFrameTraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/producer.fbs:64` + /// * Table `KeyFrameTraceInfo` in the file `../worker/fbs/producer.fbs:65` #[derive( Clone, Debug, @@ -66882,6 +67927,8 @@ mod root { ::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, } @@ -66889,7 +67936,10 @@ mod root { #[allow(clippy::derivable_impls)] impl ::core::default::Default for KeyFrameTraceInfo { fn default() -> Self { - Self { is_rtx: false } + Self { + rtp_packet: ::core::default::Default::default(), + is_rtx: false, + } } } @@ -66903,18 +67953,22 @@ mod root { #[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<6> = + 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::(0); + 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); } @@ -66954,7 +68008,7 @@ mod root { &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - KeyFrameTraceInfo::create(builder, self.is_rtx) + KeyFrameTraceInfo::create(builder, &self.rtp_packet, self.is_rtx) } } @@ -66966,27 +68020,40 @@ mod root { pub struct KeyFrameTraceInfoBuilder(State); impl KeyFrameTraceInfoBuilder<()> { - /// Setter for the [`is_rtx` field](KeyFrameTraceInfo#structfield.is_rtx). + /// Setter for the [`rtp_packet` field](KeyFrameTraceInfo#structfield.rtp_packet). #[inline] #[allow(clippy::type_complexity)] - pub fn is_rtx(self, value: T0) -> KeyFrameTraceInfoBuilder<(T0,)> + pub fn rtp_packet(self, value: T0) -> KeyFrameTraceInfoBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + 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<(::planus::DefaultValue,)> { + ) -> KeyFrameTraceInfoBuilder<(T0, ::planus::DefaultValue)> { self.is_rtx(::planus::DefaultValue) } } - impl KeyFrameTraceInfoBuilder<(T0,)> { + impl KeyFrameTraceInfoBuilder<(T0, T1)> { /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [KeyFrameTraceInfo]. #[inline] pub fn finish( @@ -67000,9 +68067,11 @@ mod root { } } - impl> - ::planus::WriteAs<::planus::Offset> - for KeyFrameTraceInfoBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, + > ::planus::WriteAs<::planus::Offset> + for KeyFrameTraceInfoBuilder<(T0, T1)> { type Prepared = ::planus::Offset; @@ -67015,9 +68084,11 @@ mod root { } } - impl> - ::planus::WriteAsOptional<::planus::Offset> - for KeyFrameTraceInfoBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, + > ::planus::WriteAsOptional<::planus::Offset> + for KeyFrameTraceInfoBuilder<(T0, T1)> { type Prepared = ::planus::Offset; @@ -67030,16 +68101,19 @@ mod root { } } - impl> - ::planus::WriteAsOffset for KeyFrameTraceInfoBuilder<(T0,)> + 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,) = &self.0; - KeyFrameTraceInfo::create(builder, v0) + let (v0, v1) = &self.0; + KeyFrameTraceInfo::create(builder, v0, v1) } } @@ -67048,12 +68122,18 @@ mod root { 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(0, "KeyFrameTraceInfo", "is_rtx")? + .access(1, "KeyFrameTraceInfo", "is_rtx")? .unwrap_or(false), ) } @@ -67062,6 +68142,7 @@ mod root { 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() } @@ -67073,6 +68154,9 @@ mod root { #[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()?)?, }) } @@ -67151,7 +68235,7 @@ mod root { /// The table `FirTraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `FirTraceInfo` in the file `../worker/fbs/producer.fbs:68` + /// * Table `FirTraceInfo` in the file `../worker/fbs/producer.fbs:70` #[derive( Clone, Debug, @@ -67428,7 +68512,7 @@ mod root { /// The table `PliTraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `PliTraceInfo` in the file `../worker/fbs/producer.fbs:72` + /// * Table `PliTraceInfo` in the file `../worker/fbs/producer.fbs:74` #[derive( Clone, Debug, @@ -67705,7 +68789,7 @@ mod root { /// The table `RtpTraceInfo` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `RtpTraceInfo` in the file `../worker/fbs/producer.fbs:76` + /// * Table `RtpTraceInfo` in the file `../worker/fbs/producer.fbs:78` #[derive( Clone, Debug, @@ -67718,6 +68802,8 @@ mod root { ::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, } @@ -67725,7 +68811,10 @@ mod root { #[allow(clippy::derivable_impls)] impl ::core::default::Default for RtpTraceInfo { fn default() -> Self { - Self { is_rtx: false } + Self { + rtp_packet: ::core::default::Default::default(), + is_rtx: false, + } } } @@ -67739,18 +68828,22 @@ mod root { #[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<6> = + 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::(0); + 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); } @@ -67790,7 +68883,7 @@ mod root { &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - RtpTraceInfo::create(builder, self.is_rtx) + RtpTraceInfo::create(builder, &self.rtp_packet, self.is_rtx) } } @@ -67802,25 +68895,40 @@ mod root { pub struct RtpTraceInfoBuilder(State); impl RtpTraceInfoBuilder<()> { - /// Setter for the [`is_rtx` field](RtpTraceInfo#structfield.is_rtx). + /// Setter for the [`rtp_packet` field](RtpTraceInfo#structfield.rtp_packet). #[inline] #[allow(clippy::type_complexity)] - pub fn is_rtx(self, value: T0) -> RtpTraceInfoBuilder<(T0,)> + pub fn rtp_packet(self, value: T0) -> RtpTraceInfoBuilder<(T0,)> where - T0: ::planus::WriteAsDefault, + 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<(::planus::DefaultValue,)> { + pub fn is_rtx_as_default( + self, + ) -> RtpTraceInfoBuilder<(T0, ::planus::DefaultValue)> { self.is_rtx(::planus::DefaultValue) } } - impl RtpTraceInfoBuilder<(T0,)> { + impl RtpTraceInfoBuilder<(T0, T1)> { /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [RtpTraceInfo]. #[inline] pub fn finish( @@ -67834,8 +68942,11 @@ mod root { } } - impl> - ::planus::WriteAs<::planus::Offset> for RtpTraceInfoBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, + > ::planus::WriteAs<::planus::Offset> + for RtpTraceInfoBuilder<(T0, T1)> { type Prepared = ::planus::Offset; @@ -67848,9 +68959,11 @@ mod root { } } - impl> - ::planus::WriteAsOptional<::planus::Offset> - for RtpTraceInfoBuilder<(T0,)> + impl< + T0: ::planus::WriteAs<::planus::Offset>, + T1: ::planus::WriteAsDefault, + > ::planus::WriteAsOptional<::planus::Offset> + for RtpTraceInfoBuilder<(T0, T1)> { type Prepared = ::planus::Offset; @@ -67863,16 +68976,18 @@ mod root { } } - impl> ::planus::WriteAsOffset - for RtpTraceInfoBuilder<(T0,)> + 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,) = &self.0; - RtpTraceInfo::create(builder, v0) + let (v0, v1) = &self.0; + RtpTraceInfo::create(builder, v0, v1) } } @@ -67881,11 +68996,17 @@ mod root { 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(0, "RtpTraceInfo", "is_rtx")?.unwrap_or(false), + self.0.access(1, "RtpTraceInfo", "is_rtx")?.unwrap_or(false), ) } } @@ -67893,6 +69014,7 @@ mod root { 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() } @@ -67904,6 +69026,9 @@ mod root { #[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()?)?, }) } @@ -67982,7 +69107,7 @@ mod root { /// The table `TraceNotification` in the namespace `FBS.Producer` /// /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/producer.fbs:80` + /// * Table `TraceNotification` in the file `../worker/fbs/producer.fbs:83` #[derive( Clone, Debug, diff --git a/rust/src/router/consumer.rs b/rust/src/router/consumer.rs index 6110998303..eaff8b425e 100644 --- a/rust/src/router/consumer.rs +++ b/rust/src/router/consumer.rs @@ -492,9 +492,7 @@ impl ConsumerTraceEventData { panic!("Wrong message from worker: {data:?}"); }; - RtpPacketTraceInfo { - is_rtx: info.is_rtx, - } + RtpPacketTraceInfo::from_fbs(*info.rtp_packet, info.is_rtx) }, }, consumer::TraceEventType::Keyframe => ConsumerTraceEventData::KeyFrame { @@ -505,9 +503,7 @@ impl ConsumerTraceEventData { panic!("Wrong message from worker: {data:?}"); }; - RtpPacketTraceInfo { - is_rtx: info.is_rtx, - } + RtpPacketTraceInfo::from_fbs(*info.rtp_packet, info.is_rtx) }, }, consumer::TraceEventType::Nack => ConsumerTraceEventData::Nack { diff --git a/rust/src/router/producer.rs b/rust/src/router/producer.rs index d447703f14..4bfde5a99c 100644 --- a/rust/src/router/producer.rs +++ b/rust/src/router/producer.rs @@ -398,9 +398,7 @@ impl ProducerTraceEventData { panic!("Wrong message from worker: {data:?}"); }; - RtpPacketTraceInfo { - is_rtx: info.is_rtx, - } + RtpPacketTraceInfo::from_fbs(*info.rtp_packet, info.is_rtx) }, }, producer::TraceEventType::Keyframe => ProducerTraceEventData::KeyFrame { @@ -411,9 +409,7 @@ impl ProducerTraceEventData { panic!("Wrong message from worker: {data:?}"); }; - RtpPacketTraceInfo { - is_rtx: info.is_rtx, - } + RtpPacketTraceInfo::from_fbs(*info.rtp_packet, info.is_rtx) }, }, producer::TraceEventType::Nack => ProducerTraceEventData::Nack { diff --git a/worker/.clang-format b/worker/.clang-format index 8e9955b0d2..e4b051bfbe 100644 --- a/worker/.clang-format +++ b/worker/.clang-format @@ -53,7 +53,7 @@ IncludeCategories: Priority: 3 - Regex: '"*"' Priority: 2 - - Regex: '^<(json|uv|openssl|srtp|usrsctp|libwebrtc)(.|/)' + - Regex: '^<(flatbuffers|uv|openssl|srtp|usrsctp|libwebrtc)(.|/)' Priority: 4 - Regex: '<*>' Priority: 5 diff --git a/worker/fbs/consumer.fbs b/worker/fbs/consumer.fbs index d1bd4d90e1..660e1dedc9 100644 --- a/worker/fbs/consumer.fbs +++ b/worker/fbs/consumer.fbs @@ -1,4 +1,5 @@ include "common.fbs"; +include "rtpPacket.fbs"; include "rtpParameters.fbs"; include "rtpStream.fbs"; @@ -98,6 +99,7 @@ union TraceInfo { } table KeyFrameTraceInfo { + rtp_packet: FBS.RtpPacket.Dump (required); is_rtx: bool; } @@ -110,6 +112,7 @@ table PliTraceInfo { } table RtpTraceInfo { + rtp_packet: FBS.RtpPacket.Dump (required); is_rtx: bool; } diff --git a/worker/fbs/meson.build b/worker/fbs/meson.build index 5394c8bddf..6ef2c022d6 100644 --- a/worker/fbs/meson.build +++ b/worker/fbs/meson.build @@ -16,6 +16,7 @@ flatbuffers_schemas = [ 'response.fbs', 'router.fbs', 'rtpObserver.fbs', + 'rtpPacket.fbs', 'rtpParameters.fbs', 'rtpStream.fbs', 'rtxStream.fbs', diff --git a/worker/fbs/producer.fbs b/worker/fbs/producer.fbs index 86b955da73..d3ec14a7b8 100644 --- a/worker/fbs/producer.fbs +++ b/worker/fbs/producer.fbs @@ -1,4 +1,5 @@ include "common.fbs"; +include "rtpPacket.fbs"; include "rtpParameters.fbs"; include "rtpStream.fbs"; @@ -62,6 +63,7 @@ union TraceInfo { } table KeyFrameTraceInfo { + rtp_packet: FBS.RtpPacket.Dump (required); is_rtx: bool; } @@ -74,6 +76,7 @@ table PliTraceInfo { } table RtpTraceInfo { + rtp_packet: FBS.RtpPacket.Dump (required); is_rtx: bool; } diff --git a/worker/fbs/rtpPacket.fbs b/worker/fbs/rtpPacket.fbs new file mode 100644 index 0000000000..a724ea67bb --- /dev/null +++ b/worker/fbs/rtpPacket.fbs @@ -0,0 +1,20 @@ +include "common.fbs"; + +namespace FBS.RtpPacket; + +table Dump { + payload_type: uint8; + sequence_number: uint16; + timestamp: uint32; + marker: bool; + ssrc: uint32; + is_key_frame: bool; + size: uint64; + payload_size: uint64; + spatial_layer: uint8; + temporal_layer: uint8; + mid: string; + rid: string; + rrid: string; + wide_sequence_number: uint16 = null; +} diff --git a/worker/include/Channel/ChannelRequest.hpp b/worker/include/Channel/ChannelRequest.hpp index 0351204362..96f960f7d4 100644 --- a/worker/include/Channel/ChannelRequest.hpp +++ b/worker/include/Channel/ChannelRequest.hpp @@ -5,8 +5,8 @@ #include "FBS/message.h" #include "FBS/request.h" #include "FBS/response.h" -#include #include +#include #include namespace Channel diff --git a/worker/include/RTC/RtpPacket.hpp b/worker/include/RTC/RtpPacket.hpp index f851bab3d5..0f555c4320 100644 --- a/worker/include/RTC/RtpPacket.hpp +++ b/worker/include/RTC/RtpPacket.hpp @@ -3,8 +3,10 @@ #include "common.hpp" #include "Utils.hpp" +#include "FBS/rtpPacket.h" #include "RTC/Codecs/PayloadDescriptorHandler.hpp" #include "RTC/RtcLogger.hpp" +#include #include #include #include @@ -144,6 +146,7 @@ namespace RTC ~RtpPacket(); void Dump() const; + flatbuffers::Offset FillBuffer(flatbuffers::FlatBufferBuilder& builder) const; const uint8_t* GetData() const { diff --git a/worker/include/RTC/WebRtcServer.hpp b/worker/include/RTC/WebRtcServer.hpp index d14b240b4e..8fede51c82 100644 --- a/worker/include/RTC/WebRtcServer.hpp +++ b/worker/include/RTC/WebRtcServer.hpp @@ -10,9 +10,9 @@ #include "RTC/TransportTuple.hpp" #include "RTC/UdpSocket.hpp" #include "RTC/WebRtcTransport.hpp" +#include #include #include -#include #include #include diff --git a/worker/include/Worker.hpp b/worker/include/Worker.hpp index b5d5b79024..9bb91b8fed 100644 --- a/worker/include/Worker.hpp +++ b/worker/include/Worker.hpp @@ -9,8 +9,8 @@ #include "RTC/Shared.hpp" #include "RTC/WebRtcServer.hpp" #include "handles/SignalHandle.hpp" -#include #include +#include #include class Worker : public Channel::ChannelSocket::Listener, diff --git a/worker/src/RTC/Consumer.cpp b/worker/src/RTC/Consumer.cpp index d7d46cb217..796924f795 100644 --- a/worker/src/RTC/Consumer.cpp +++ b/worker/src/RTC/Consumer.cpp @@ -470,8 +470,9 @@ namespace RTC if (this->traceEventTypes.keyframe && packet->IsKeyFrame()) { - auto traceInfo = FBS::Consumer::CreateKeyFrameTraceInfo( - this->shared->channelNotifier->GetBufferBuilder(), isRtx); + auto rtpPacketDump = packet->FillBuffer(this->shared->channelNotifier->GetBufferBuilder()); + auto traceInfo = FBS::Consumer::CreateKeyFrameTraceInfo( + this->shared->channelNotifier->GetBufferBuilder(), rtpPacketDump, isRtx); auto notification = FBS::Consumer::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), @@ -485,8 +486,9 @@ namespace RTC } else if (this->traceEventTypes.rtp) { - auto traceInfo = - FBS::Consumer::CreateRtpTraceInfo(this->shared->channelNotifier->GetBufferBuilder(), isRtx); + auto rtpPacketDump = packet->FillBuffer(this->shared->channelNotifier->GetBufferBuilder()); + auto traceInfo = FBS::Consumer::CreateRtpTraceInfo( + this->shared->channelNotifier->GetBufferBuilder(), rtpPacketDump, isRtx); auto notification = FBS::Consumer::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), diff --git a/worker/src/RTC/Producer.cpp b/worker/src/RTC/Producer.cpp index 02845e7b10..6c5f7a8951 100644 --- a/worker/src/RTC/Producer.cpp +++ b/worker/src/RTC/Producer.cpp @@ -1472,8 +1472,9 @@ namespace RTC if (this->traceEventTypes.keyframe && packet->IsKeyFrame()) { - auto traceInfo = FBS::Producer::CreateKeyFrameTraceInfo( - this->shared->channelNotifier->GetBufferBuilder(), isRtx); + auto rtpPacketDump = packet->FillBuffer(this->shared->channelNotifier->GetBufferBuilder()); + auto traceInfo = FBS::Producer::CreateKeyFrameTraceInfo( + this->shared->channelNotifier->GetBufferBuilder(), rtpPacketDump, isRtx); auto notification = FBS::Producer::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), @@ -1487,8 +1488,9 @@ namespace RTC } else if (this->traceEventTypes.rtp) { - auto traceInfo = - FBS::Producer::CreateRtpTraceInfo(this->shared->channelNotifier->GetBufferBuilder(), isRtx); + auto rtpPacketDump = packet->FillBuffer(this->shared->channelNotifier->GetBufferBuilder()); + auto traceInfo = FBS::Producer::CreateRtpTraceInfo( + this->shared->channelNotifier->GetBufferBuilder(), rtpPacketDump, isRtx); auto notification = FBS::Producer::CreateTraceNotification( this->shared->channelNotifier->GetBufferBuilder(), diff --git a/worker/src/RTC/RtpPacket.cpp b/worker/src/RTC/RtpPacket.cpp index 64a2b5a55d..dae9b41e10 100644 --- a/worker/src/RTC/RtpPacket.cpp +++ b/worker/src/RTC/RtpPacket.cpp @@ -317,6 +317,62 @@ namespace RTC MS_DUMP(""); } + flatbuffers::Offset RtpPacket::FillBuffer( + flatbuffers::FlatBufferBuilder& builder) const + { + // Add mid. + std::string mid; + + if (this->midExtensionId != 0u) + { + ReadMid(mid); + } + + // Add rid. + std::string rid; + + if (this->ridExtensionId != 0u) + { + ReadRid(rid); + } + + // Add rrid. + std::string rrid; + + if (this->rridExtensionId != 0u) + { + ReadRid(rrid); + } + + // Add wideSequenceNumber. + uint16_t wideSequenceNumber; + bool wideSequenceNumberSet = false; + + if (this->transportWideCc01ExtensionId != 0u) + { + wideSequenceNumberSet = true; + ReadTransportWideCc01(wideSequenceNumber); + } + + return FBS::RtpPacket::CreateDumpDirect( + builder, + this->GetPayloadType(), + this->GetSequenceNumber(), + this->GetTimestamp(), + this->HasMarker(), + this->GetSsrc(), + this->IsKeyFrame(), + this->GetSize(), + this->GetPayloadLength(), + this->GetSpatialLayer(), + this->GetTemporalLayer(), + mid.empty() ? nullptr : mid.c_str(), + rid.empty() ? nullptr : rid.c_str(), + rrid.empty() ? nullptr : rrid.c_str(), + wideSequenceNumberSet ? flatbuffers::Optional(wideSequenceNumber) + : flatbuffers::nullopt); + } + void RtpPacket::SetExtensions(uint8_t type, const std::vector& extensions) { MS_ASSERT(type == 1u || type == 2u, "type must be 1 or 2"); diff --git a/worker/src/Settings.cpp b/worker/src/Settings.cpp index c890b7361c..41a91f1592 100644 --- a/worker/src/Settings.cpp +++ b/worker/src/Settings.cpp @@ -5,8 +5,8 @@ #include "Logger.hpp" #include "MediaSoupErrors.hpp" #include "Utils.hpp" -#include // isprint() #include +#include // isprint() #include // std::ostream_iterator #include #include // std::ostringstream From b706ae7730128ef6b5d4d79202b3c4b748f6d142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Thu, 19 Oct 2023 20:35:49 +0200 Subject: [PATCH 43/73] [flatbuffers] Fix missing options in router.createWebRtcTransport() (#1185) --- node/src/Router.ts | 23 +- node/src/WebRtcTransport.ts | 6 +- node/src/tests/test-WebRtcServer.ts | 17 +- rust/src/fbs.rs | 304 ++++++++++++++++++--- rust/src/messages.rs | 12 + rust/src/router/webrtc_transport.rs | 22 +- rust/src/router/webrtc_transport/tests.rs | 24 +- rust/tests/integration/webrtc_transport.rs | 1 - worker/fbs/transport.fbs | 1 - worker/fbs/webRtcTransport.fbs | 4 + worker/include/RTC/WebRtcServer.hpp | 5 +- worker/src/RTC/Router.cpp | 3 +- worker/src/RTC/WebRtcServer.cpp | 86 +++--- worker/src/RTC/WebRtcTransport.cpp | 3 + 14 files changed, 401 insertions(+), 110 deletions(-) diff --git a/node/src/Router.ts b/node/src/Router.ts index 965f6905ff..a45bc5e0f6 100644 --- a/node/src/Router.ts +++ b/node/src/Router.ts @@ -405,8 +405,8 @@ export class Router listenInfos, listenIps, port, - enableUdp = true, - enableTcp = false, + enableUdp, + enableTcp, preferUdp = false, preferTcp = false, initialAvailableOutgoingBitrate = 600000, @@ -440,6 +440,19 @@ export class Router throw new TypeError('if given, appData must be an object'); } + // If webRtcServer is given, then do not force default values for enableUdp + // and enableTcp. Otherwise set them if unset. + if (webRtcServer) + { + enableUdp ??= true; + enableTcp ??= true; + } + else + { + enableUdp ??= true; + enableTcp ??= false; + } + // Convert deprecated TransportListenIps to TransportListenInfos. if (listenIps) { @@ -545,7 +558,11 @@ export class Router webRtcServer ? FbsWebRtcTransport.Listen.ListenServer : FbsWebRtcTransport.Listen.ListenIndividual, - webRtcServer ? webRtcTransportListenServer : webRtcTransportListenIndividual + webRtcServer ? webRtcTransportListenServer : webRtcTransportListenIndividual, + enableUdp, + enableTcp, + preferUdp, + preferTcp ); const requestOffset = new FbsRouter.CreateWebRtcTransportRequestT( diff --git a/node/src/WebRtcTransport.ts b/node/src/WebRtcTransport.ts index c78d6d4107..9ef9b49b57 100644 --- a/node/src/WebRtcTransport.ts +++ b/node/src/WebRtcTransport.ts @@ -78,25 +78,21 @@ export type WebRtcTransportOptionsBase = { /** * Listen in UDP. Default true. - * @deprecated */ enableUdp?: boolean; /** - * Listen in TCP. Default false. - * @deprecated + * Listen in TCP. Default true if webrtcServer is given, false otherwise. */ enableTcp?: boolean; /** * Prefer UDP. Default false. - * @deprecated */ preferUdp?: boolean; /** * Prefer TCP. Default false. - * @deprecated */ preferTcp?: boolean; diff --git a/node/src/tests/test-WebRtcServer.ts b/node/src/tests/test-WebRtcServer.ts index 3d1bc52855..796c923d5b 100644 --- a/node/src/tests/test-WebRtcServer.ts +++ b/node/src/tests/test-WebRtcServer.ts @@ -356,7 +356,9 @@ test('router.createWebRtcTransport() with webRtcServer succeeds and transport is const transport = await router.createWebRtcTransport( { webRtcServer, - appData : { foo: 'bar' } + // Let's disable UDP so resulting ICE candidates should only contain TCP. + enableUdp : false, + appData : { foo: 'bar' } }); await expect(router.dump()) @@ -373,17 +375,12 @@ test('router.createWebRtcTransport() with webRtcServer succeeds and transport is const iceCandidates = transport.iceCandidates; - expect(iceCandidates.length).toBe(2); + expect(iceCandidates.length).toBe(1); expect(iceCandidates[0].ip).toBe('127.0.0.1'); - expect(iceCandidates[0].port).toBe(port1); - expect(iceCandidates[0].protocol).toBe('udp'); + expect(iceCandidates[0].port).toBe(port2); + expect(iceCandidates[0].protocol).toBe('tcp'); expect(iceCandidates[0].type).toBe('host'); - expect(iceCandidates[0].tcpType).toBeUndefined(); - expect(iceCandidates[1].ip).toBe('127.0.0.1'); - expect(iceCandidates[1].port).toBe(port2); - expect(iceCandidates[1].protocol).toBe('tcp'); - expect(iceCandidates[1].type).toBe('host'); - expect(iceCandidates[1].tcpType).toBe('passive'); + expect(iceCandidates[0].tcpType).toBe('passive'); expect(transport.iceState).toBe('new'); expect(transport.iceSelectedTuple).toBeUndefined(); diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index 088a38fb0e..b923e88d4f 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -38860,7 +38860,7 @@ mod root { /// The enum `TraceEventType` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `TraceEventType` in the file `../worker/fbs/transport.fbs:122` + /// * Enum `TraceEventType` in the file `../worker/fbs/transport.fbs:121` #[derive( Copy, Clone, @@ -39030,7 +39030,7 @@ mod root { /// The table `Dump` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Dump` in the file `../worker/fbs/transport.fbs:127` + /// * Table `Dump` in the file `../worker/fbs/transport.fbs:126` #[derive( Clone, Debug, @@ -40073,7 +40073,7 @@ mod root { /// The table `Stats` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Stats` in the file `../worker/fbs/transport.fbs:145` + /// * Table `Stats` in the file `../worker/fbs/transport.fbs:144` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -42734,7 +42734,7 @@ mod root { /// The table `SetMaxIncomingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMaxIncomingBitrateRequest` in the file `../worker/fbs/transport.fbs:172` + /// * Table `SetMaxIncomingBitrateRequest` in the file `../worker/fbs/transport.fbs:171` #[derive( Clone, Debug, @@ -43042,7 +43042,7 @@ mod root { /// The table `SetMaxOutgoingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMaxOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:176` + /// * Table `SetMaxOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:175` #[derive( Clone, Debug, @@ -43350,7 +43350,7 @@ mod root { /// The table `SetMinOutgoingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMinOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:180` + /// * Table `SetMinOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:179` #[derive( Clone, Debug, @@ -43658,7 +43658,7 @@ mod root { /// The table `EnableTraceEventRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/transport.fbs:184` + /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/transport.fbs:183` #[derive( Clone, Debug, @@ -43936,7 +43936,7 @@ mod root { /// The table `CloseProducerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseProducerRequest` in the file `../worker/fbs/transport.fbs:188` + /// * Table `CloseProducerRequest` in the file `../worker/fbs/transport.fbs:187` #[derive( Clone, Debug, @@ -44202,7 +44202,7 @@ mod root { /// The table `CloseConsumerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseConsumerRequest` in the file `../worker/fbs/transport.fbs:192` + /// * Table `CloseConsumerRequest` in the file `../worker/fbs/transport.fbs:191` #[derive( Clone, Debug, @@ -44468,7 +44468,7 @@ mod root { /// The table `CloseDataProducerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseDataProducerRequest` in the file `../worker/fbs/transport.fbs:196` + /// * Table `CloseDataProducerRequest` in the file `../worker/fbs/transport.fbs:195` #[derive( Clone, Debug, @@ -44743,7 +44743,7 @@ mod root { /// The table `CloseDataConsumerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseDataConsumerRequest` in the file `../worker/fbs/transport.fbs:200` + /// * Table `CloseDataConsumerRequest` in the file `../worker/fbs/transport.fbs:199` #[derive( Clone, Debug, @@ -45018,7 +45018,7 @@ mod root { /// The table `SendRtcpNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SendRtcpNotification` in the file `../worker/fbs/transport.fbs:206` + /// * Table `SendRtcpNotification` in the file `../worker/fbs/transport.fbs:205` #[derive( Clone, Debug, @@ -45283,7 +45283,7 @@ mod root { /// The table `SctpStateChangeNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SctpStateChangeNotification` in the file `../worker/fbs/transport.fbs:212` + /// * Table `SctpStateChangeNotification` in the file `../worker/fbs/transport.fbs:211` #[derive( Clone, Debug, @@ -45604,7 +45604,7 @@ mod root { /// The union `TraceInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:216` + /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:215` #[derive( Clone, Debug, @@ -45757,7 +45757,7 @@ mod root { /// The enum `BweType` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:220` + /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:219` #[derive( Copy, Clone, @@ -45927,7 +45927,7 @@ mod root { /// The table `BweTraceInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:225` + /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:224` #[derive( Clone, Debug, @@ -46605,7 +46605,7 @@ mod root { /// The table `TraceNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:236` + /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:235` #[derive( Clone, Debug, @@ -75122,6 +75122,14 @@ mod root { 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 { @@ -75136,21 +75144,61 @@ mod root { 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<10> = + 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() @@ -75190,7 +75238,15 @@ mod root { &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - WebRtcTransportOptions::create(builder, &self.base, &self.listen) + WebRtcTransportOptions::create( + builder, + &self.base, + &self.listen, + self.enable_udp, + self.enable_tcp, + self.prefer_udp, + self.prefer_tcp, + ) } } @@ -75227,6 +75283,110 @@ mod root { } 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( @@ -75243,8 +75403,12 @@ mod root { 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)> + for WebRtcTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5)> { type Prepared = ::planus::Offset; @@ -75260,8 +75424,12 @@ mod root { 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)> + for WebRtcTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5)> { type Prepared = ::planus::Offset; @@ -75278,16 +75446,20 @@ mod root { 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)> + for WebRtcTransportOptionsBuilder<(T0, T1, T2, T3, T4, T5)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, ) -> ::planus::Offset { - let (v0, v1) = &self.0; - WebRtcTransportOptions::create(builder, v0, v1) + let (v0, v1, v2, v3, v4, v5) = &self.0; + WebRtcTransportOptions::create(builder, v0, v1, v2, v3, v4, v5) } } @@ -75308,6 +75480,46 @@ mod root { 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> { @@ -75315,6 +75527,10 @@ mod root { 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() } } @@ -75329,6 +75545,10 @@ mod root { 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()?)?, }) } } @@ -75410,7 +75630,7 @@ mod root { /// The enum `FingerprintAlgorithm` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Enum `FingerprintAlgorithm` in the file `../worker/fbs/webRtcTransport.fbs:24` + /// * Enum `FingerprintAlgorithm` in the file `../worker/fbs/webRtcTransport.fbs:28` #[derive( Copy, Clone, @@ -75598,7 +75818,7 @@ mod root { /// The table `Fingerprint` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `Fingerprint` in the file `../worker/fbs/webRtcTransport.fbs:32` + /// * Table `Fingerprint` in the file `../worker/fbs/webRtcTransport.fbs:36` #[derive( Clone, Debug, @@ -75922,7 +76142,7 @@ mod root { /// The enum `DtlsRole` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Enum `DtlsRole` in the file `../worker/fbs/webRtcTransport.fbs:37` + /// * Enum `DtlsRole` in the file `../worker/fbs/webRtcTransport.fbs:41` #[derive( Copy, Clone, @@ -76096,7 +76316,7 @@ mod root { /// The enum `DtlsState` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Enum `DtlsState` in the file `../worker/fbs/webRtcTransport.fbs:43` + /// * Enum `DtlsState` in the file `../worker/fbs/webRtcTransport.fbs:47` #[derive( Copy, Clone, @@ -76284,7 +76504,7 @@ mod root { /// The table `DtlsParameters` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `DtlsParameters` in the file `../worker/fbs/webRtcTransport.fbs:51` + /// * Table `DtlsParameters` in the file `../worker/fbs/webRtcTransport.fbs:55` #[derive( Clone, Debug, @@ -76599,7 +76819,7 @@ mod root { /// The table `IceParameters` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `IceParameters` in the file `../worker/fbs/webRtcTransport.fbs:56` + /// * Table `IceParameters` in the file `../worker/fbs/webRtcTransport.fbs:60` #[derive( Clone, Debug, @@ -76947,7 +77167,7 @@ mod root { /// The enum `IceCandidateType` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Enum `IceCandidateType` in the file `../worker/fbs/webRtcTransport.fbs:62` + /// * Enum `IceCandidateType` in the file `../worker/fbs/webRtcTransport.fbs:66` #[derive( Copy, Clone, @@ -77113,7 +77333,7 @@ mod root { /// The enum `IceCandidateTcpType` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Enum `IceCandidateTcpType` in the file `../worker/fbs/webRtcTransport.fbs:66` + /// * Enum `IceCandidateTcpType` in the file `../worker/fbs/webRtcTransport.fbs:70` #[derive( Copy, Clone, @@ -77279,7 +77499,7 @@ mod root { /// The enum `IceRole` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Enum `IceRole` in the file `../worker/fbs/webRtcTransport.fbs:70` + /// * Enum `IceRole` in the file `../worker/fbs/webRtcTransport.fbs:74` #[derive( Copy, Clone, @@ -77449,7 +77669,7 @@ mod root { /// The enum `IceState` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Enum `IceState` in the file `../worker/fbs/webRtcTransport.fbs:75` + /// * Enum `IceState` in the file `../worker/fbs/webRtcTransport.fbs:79` #[derive( Copy, Clone, @@ -77632,7 +77852,7 @@ mod root { /// The table `IceCandidate` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `IceCandidate` in the file `../worker/fbs/webRtcTransport.fbs:82` + /// * Table `IceCandidate` in the file `../worker/fbs/webRtcTransport.fbs:86` #[derive( Clone, Debug, @@ -78203,7 +78423,7 @@ mod root { /// The table `ConnectRequest` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `ConnectRequest` in the file `../worker/fbs/webRtcTransport.fbs:92` + /// * Table `ConnectRequest` in the file `../worker/fbs/webRtcTransport.fbs:96` #[derive( Clone, Debug, @@ -78466,7 +78686,7 @@ mod root { /// The table `ConnectResponse` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `ConnectResponse` in the file `../worker/fbs/webRtcTransport.fbs:96` + /// * Table `ConnectResponse` in the file `../worker/fbs/webRtcTransport.fbs:100` #[derive( Clone, Debug, @@ -78755,7 +78975,7 @@ mod root { /// The table `DumpResponse` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `DumpResponse` in the file `../worker/fbs/webRtcTransport.fbs:100` + /// * Table `DumpResponse` in the file `../worker/fbs/webRtcTransport.fbs:104` #[derive( Clone, Debug, @@ -79355,7 +79575,7 @@ mod root { /// The table `GetStatsResponse` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `GetStatsResponse` in the file `../worker/fbs/webRtcTransport.fbs:111` + /// * Table `GetStatsResponse` in the file `../worker/fbs/webRtcTransport.fbs:115` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -79838,7 +80058,7 @@ mod root { /// The table `IceSelectedTupleChangeNotification` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `IceSelectedTupleChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:121` + /// * Table `IceSelectedTupleChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:125` #[derive( Clone, Debug, @@ -80121,7 +80341,7 @@ mod root { /// The table `IceStateChangeNotification` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `IceStateChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:125` + /// * Table `IceStateChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:129` #[derive( Clone, Debug, @@ -80422,7 +80642,7 @@ mod root { /// The table `DtlsStateChangeNotification` in the namespace `FBS.WebRtcTransport` /// /// Generated from these locations: - /// * Table `DtlsStateChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:129` + /// * Table `DtlsStateChangeNotification` in the file `../worker/fbs/webRtcTransport.fbs:133` #[derive( Clone, Debug, diff --git a/rust/src/messages.rs b/rust/src/messages.rs index 32f29821bf..327a82eb84 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -651,6 +651,10 @@ pub(crate) struct RouterCreateWebrtcTransportData { #[serde(flatten)] listen: RouterCreateWebrtcTransportListen, initial_available_outgoing_bitrate: u32, + enable_udp: bool, + enable_tcp: bool, + prefer_udp: bool, + prefer_tcp: bool, enable_sctp: bool, num_sctp_streams: NumSctpStreams, max_sctp_message_size: u32, @@ -679,6 +683,10 @@ impl RouterCreateWebrtcTransportData { }, initial_available_outgoing_bitrate: webrtc_transport_options .initial_available_outgoing_bitrate, + enable_udp: webrtc_transport_options.enable_udp, + enable_tcp: webrtc_transport_options.enable_tcp, + prefer_udp: webrtc_transport_options.prefer_udp, + prefer_tcp: webrtc_transport_options.prefer_tcp, enable_sctp: webrtc_transport_options.enable_sctp, num_sctp_streams: webrtc_transport_options.num_sctp_streams, max_sctp_message_size: webrtc_transport_options.max_sctp_message_size, @@ -700,6 +708,10 @@ impl RouterCreateWebrtcTransportData { is_data_channel: true, }), listen: self.listen.to_fbs(), + enable_udp: self.enable_udp, + enable_tcp: self.enable_tcp, + prefer_udp: self.prefer_udp, + prefer_tcp: self.prefer_tcp, } } } diff --git a/rust/src/router/webrtc_transport.rs b/rust/src/router/webrtc_transport.rs index 46836995ec..ff9630c751 100644 --- a/rust/src/router/webrtc_transport.rs +++ b/rust/src/router/webrtc_transport.rs @@ -117,6 +117,18 @@ pub struct WebRtcTransportOptions { /// Initial available outgoing bitrate (in bps). /// Default 600000. pub initial_available_outgoing_bitrate: u32, + /// Enable UDP. + /// Default true. + pub enable_udp: bool, + /// Enable TCP. + /// Default true if webrtc_server is given, false otherwise. + pub enable_tcp: bool, + /// Prefer UDP. + /// Default false. + pub prefer_udp: bool, + /// Prefer TCP. + /// Default false. + pub prefer_tcp: bool, /// Create a SCTP association. /// Default false. pub enable_sctp: bool, @@ -133,12 +145,16 @@ pub struct WebRtcTransportOptions { } impl WebRtcTransportOptions { - /// Create [`WebRtcTransport`] options with given listen IPs. + /// Create [`WebRtcTransport`] options with given listen infos. #[must_use] pub fn new(listen_infos: WebRtcTransportListenInfos) -> Self { Self { listen: WebRtcTransportListen::Individual { listen_infos }, initial_available_outgoing_bitrate: 600_000, + enable_udp: true, + enable_tcp: false, + prefer_udp: false, + prefer_tcp: false, enable_sctp: false, num_sctp_streams: NumSctpStreams::default(), max_sctp_message_size: 262_144, @@ -152,6 +168,10 @@ impl WebRtcTransportOptions { Self { listen: WebRtcTransportListen::Server { webrtc_server }, initial_available_outgoing_bitrate: 600_000, + enable_udp: true, + enable_tcp: true, + prefer_udp: false, + prefer_tcp: false, enable_sctp: false, num_sctp_streams: NumSctpStreams::default(), max_sctp_message_size: 262_144, diff --git a/rust/src/router/webrtc_transport/tests.rs b/rust/src/router/webrtc_transport/tests.rs index 844555be4e..42d54678ee 100644 --- a/rust/src/router/webrtc_transport/tests.rs +++ b/rust/src/router/webrtc_transport/tests.rs @@ -104,9 +104,14 @@ fn create_with_webrtc_server_succeeds() { }); let transport = router - .create_webrtc_transport(WebRtcTransportOptions::new_with_server( - webrtc_server.clone(), - )) + .create_webrtc_transport({ + let mut webrtc_transport_options = + WebRtcTransportOptions::new_with_server(webrtc_server.clone()); + // Let's disable UDP so resulting ICE candidates should only contain TCP. + webrtc_transport_options.enable_udp = false; + + webrtc_transport_options + }) .await .expect("Failed to create WebRTC transport"); @@ -124,18 +129,13 @@ fn create_with_webrtc_server_succeeds() { { let ice_candidates = transport.ice_candidates(); - assert_eq!(ice_candidates.len(), 2); + assert_eq!(ice_candidates.len(), 1); assert_eq!(ice_candidates[0].ip, IpAddr::V4(Ipv4Addr::LOCALHOST)); - assert_eq!(ice_candidates[0].protocol, Protocol::Udp); - assert_eq!(ice_candidates[0].port, port1); + assert_eq!(ice_candidates[0].protocol, Protocol::Tcp); + assert_eq!(ice_candidates[0].port, port2); assert_eq!(ice_candidates[0].r#type, IceCandidateType::Host); - assert_eq!(ice_candidates[0].tcp_type, None); - assert_eq!(ice_candidates[1].ip, IpAddr::V4(Ipv4Addr::LOCALHOST)); - assert_eq!(ice_candidates[1].protocol, Protocol::Tcp); - assert_eq!(ice_candidates[1].port, port2); - assert_eq!(ice_candidates[1].r#type, IceCandidateType::Host); assert_eq!( - ice_candidates[1].tcp_type, + ice_candidates[0].tcp_type, Some(IceCandidateTcpType::Passive) ); } diff --git a/rust/tests/integration/webrtc_transport.rs b/rust/tests/integration/webrtc_transport.rs index 90707e41eb..e8c45b6761 100644 --- a/rust/tests/integration/webrtc_transport.rs +++ b/rust/tests/integration/webrtc_transport.rs @@ -160,7 +160,6 @@ fn create_succeeds() { .try_into() .unwrap(), ); - // TODO: I wonder how this was not needed before... webrtc_transport_options.enable_sctp = true; webrtc_transport_options.num_sctp_streams = NumSctpStreams { os: 2048, diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs index d2a77d4ae9..f86af45913 100644 --- a/worker/fbs/transport.fbs +++ b/worker/fbs/transport.fbs @@ -108,7 +108,6 @@ table RecvRtpHeaderExtensions { table Options { direct: bool = false; - /// Only needed for DirectTransport. This value is handled by base Transport. max_message_size: uint32 = null; initial_available_outgoing_bitrate: uint32 = null; diff --git a/worker/fbs/webRtcTransport.fbs b/worker/fbs/webRtcTransport.fbs index 7af0c308b8..ad0a8e0fc8 100644 --- a/worker/fbs/webRtcTransport.fbs +++ b/worker/fbs/webRtcTransport.fbs @@ -19,6 +19,10 @@ union Listen { table WebRtcTransportOptions { base: FBS.Transport.Options (required); listen: Listen (required); + enable_udp: bool = true; + enable_tcp: bool = true; + prefer_udp: bool = false; + prefer_tcp: bool = false; } enum FingerprintAlgorithm: uint8 { diff --git a/worker/include/RTC/WebRtcServer.hpp b/worker/include/RTC/WebRtcServer.hpp index 8fede51c82..49803dd6ec 100644 --- a/worker/include/RTC/WebRtcServer.hpp +++ b/worker/include/RTC/WebRtcServer.hpp @@ -48,7 +48,8 @@ namespace RTC public: flatbuffers::Offset FillBuffer( flatbuffers::FlatBufferBuilder& builder) const; - const std::vector& GetIceCandidates() const; + const std::vector GetIceCandidates( + bool enableUdp, bool enableTcp, bool preferUdp, bool preferTcp) const; /* Methods inherited from Channel::ChannelSocket::RequestHandler. */ public: @@ -102,8 +103,6 @@ namespace RTC absl::flat_hash_map mapLocalIceUsernameFragmentWebRtcTransport; // Map of WebRtcTransports indexed by TransportTuple.hash. absl::flat_hash_map mapTupleWebRtcTransport; - // ICE candidates. - std::vector iceCandidates; }; } // namespace RTC diff --git a/worker/src/RTC/Router.cpp b/worker/src/RTC/Router.cpp index f7b6e2b1ac..33e543909b 100644 --- a/worker/src/RTC/Router.cpp +++ b/worker/src/RTC/Router.cpp @@ -248,7 +248,8 @@ namespace RTC if (!webRtcServer) MS_THROW_ERROR("wrong webRtcServerId (no associated WebRtcServer found)"); - auto& iceCandidates = webRtcServer->GetIceCandidates(); + auto iceCandidates = webRtcServer->GetIceCandidates( + options->enableUdp(), options->enableTcp(), options->preferUdp(), options->preferTcp()); // This may throw. auto* webRtcTransport = new RTC::WebRtcTransport( diff --git a/worker/src/RTC/WebRtcServer.cpp b/worker/src/RTC/WebRtcServer.cpp index b878a90ddb..8fe9f760a3 100644 --- a/worker/src/RTC/WebRtcServer.cpp +++ b/worker/src/RTC/WebRtcServer.cpp @@ -46,10 +46,6 @@ namespace RTC try { - uint16_t iceLocalPreferenceDecrement{ 0u }; - - this->iceCandidates.reserve(listenInfos->size()); - for (const auto* listenInfo : *listenInfos) { auto ip = listenInfo->ip()->str(); @@ -64,10 +60,6 @@ namespace RTC announcedIp = listenInfo->announcedIp()->str(); } - const uint16_t iceLocalPreference = - IceCandidateDefaultLocalPriority - iceLocalPreferenceDecrement; - const uint32_t icePriority = generateIceCandidatePriority(iceLocalPreference); - if (listenInfo->protocol() == FBS::Transport::Protocol::UDP) { // This may throw. @@ -84,15 +76,6 @@ namespace RTC this->udpSocketOrTcpServers.emplace_back(udpSocket, nullptr, announcedIp); - if (announcedIp.size() == 0) - { - this->iceCandidates.emplace_back(udpSocket, icePriority); - } - else - { - this->iceCandidates.emplace_back(udpSocket, icePriority, announcedIp); - } - if (listenInfo->sendBufferSize() != 0) { udpSocket->SetSendBufferSize(listenInfo->sendBufferSize()); @@ -125,15 +108,6 @@ namespace RTC this->udpSocketOrTcpServers.emplace_back(nullptr, tcpServer, announcedIp); - if (announcedIp.size() == 0) - { - this->iceCandidates.emplace_back(tcpServer, icePriority); - } - else - { - this->iceCandidates.emplace_back(tcpServer, icePriority, announcedIp); - } - if (listenInfo->sendBufferSize() != 0) { tcpServer->SetSendBufferSize(listenInfo->sendBufferSize()); @@ -150,9 +124,6 @@ namespace RTC tcpServer->GetSendBufferSize(), tcpServer->GetRecvBufferSize()); } - - // Decrement initial ICE local preference for next IP. - iceLocalPreferenceDecrement += 100; } // NOTE: This may throw. @@ -289,11 +260,64 @@ namespace RTC } } - const std::vector& WebRtcServer::GetIceCandidates() const + const std::vector WebRtcServer::GetIceCandidates( + bool enableUdp, bool enableTcp, bool preferUdp, bool preferTcp) const { MS_TRACE(); - return this->iceCandidates; + std::vector iceCandidates; + uint16_t iceLocalPreferenceDecrement{ 0 }; + + for (auto& item : this->udpSocketOrTcpServers) + { + if (item.udpSocket && enableUdp) + { + uint16_t iceLocalPreference = IceCandidateDefaultLocalPriority - iceLocalPreferenceDecrement; + + if (preferUdp) + { + iceLocalPreference += 1000; + } + + uint32_t icePriority = generateIceCandidatePriority(iceLocalPreference); + + if (item.announcedIp.empty()) + { + iceCandidates.emplace_back(item.udpSocket, icePriority); + } + else + { + iceCandidates.emplace_back( + item.udpSocket, icePriority, const_cast(item.announcedIp)); + } + } + else if (item.tcpServer && enableTcp) + { + uint16_t iceLocalPreference = IceCandidateDefaultLocalPriority - iceLocalPreferenceDecrement; + + if (preferTcp) + { + iceLocalPreference += 1000; + } + + uint32_t icePriority = generateIceCandidatePriority(iceLocalPreference); + + if (item.announcedIp.empty()) + { + iceCandidates.emplace_back(item.tcpServer, icePriority); + } + else + { + iceCandidates.emplace_back( + item.tcpServer, icePriority, const_cast(item.announcedIp)); + } + } + + // Decrement initial ICE local preference for next IP. + iceLocalPreferenceDecrement += 100; + } + + return iceCandidates; } inline std::string WebRtcServer::GetLocalIceUsernameFragmentFromReceivedStunPacket( diff --git a/worker/src/RTC/WebRtcTransport.cpp b/worker/src/RTC/WebRtcTransport.cpp index b28effdb0d..ed7700ffdc 100644 --- a/worker/src/RTC/WebRtcTransport.cpp +++ b/worker/src/RTC/WebRtcTransport.cpp @@ -28,6 +28,9 @@ namespace RTC /* Instance methods. */ + /** + * This constructor is used when the WebRtcTransport doesn't use a WebRtcServer. + */ WebRtcTransport::WebRtcTransport( RTC::Shared* shared, const std::string& id, From c889e1a4490a665a675d845488b11b30d86cea26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Fri, 20 Oct 2023 14:51:38 +0200 Subject: [PATCH 44/73] C++: Fix DataProducer::Send invalid memory access (#1190) 'subchannels' are optional and hence they need to be checked before accessing them. Remove test expectation that assumed we were receiving all messages in incremental mode. TS tests failure was being masked by [1], I don't know why Rust wasn't failing but definitely consumers are not receiving everything sent by the producer since in the tests both are paused at some time. [1]: https://github.com/versatica/mediasoup/issues/1188 --- node/src/tests/test-DirectTransport.ts | 2 +- rust/tests/integration/direct_transport.rs | 2 -- worker/src/RTC/DataProducer.cpp | 11 +++++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/node/src/tests/test-DirectTransport.ts b/node/src/tests/test-DirectTransport.ts index 580185d96d..60034008fd 100644 --- a/node/src/tests/test-DirectTransport.ts +++ b/node/src/tests/test-DirectTransport.ts @@ -211,7 +211,7 @@ test('dataProducer.send() succeeds', async () => expect(ppid).toBe(53); // PPID of WebRTC DataChannel binary. } - expect(id).toBe(++lastRecvMessageId); + ++lastRecvMessageId; }); }); diff --git a/rust/tests/integration/direct_transport.rs b/rust/tests/integration/direct_transport.rs index ee80646f2a..290136f241 100644 --- a/rust/tests/integration/direct_transport.rs +++ b/rust/tests/integration/direct_transport.rs @@ -157,7 +157,6 @@ fn get_stats_succeeds() { } #[test] -#[ignore] fn send_succeeds() { future::block_on(async move { let (_worker, _router, transport) = init().await; @@ -226,7 +225,6 @@ fn send_succeeds() { } last_recv_message_id.fetch_add(1, Ordering::SeqCst); - assert_eq!(id, last_recv_message_id.load(Ordering::SeqCst)); if id == num_messages { let _ = received_messages_tx.lock().take().unwrap().send(()); diff --git a/worker/src/RTC/DataProducer.cpp b/worker/src/RTC/DataProducer.cpp index 56a3389e73..a55b58f6a9 100644 --- a/worker/src/RTC/DataProducer.cpp +++ b/worker/src/RTC/DataProducer.cpp @@ -224,11 +224,14 @@ namespace RTC std::vector subchannels; - subchannels.reserve(body->subchannels()->size()); - - for (const auto subchannel : *body->subchannels()) + if (flatbuffers::IsFieldPresent(body, FBS::DataProducer::SendNotification::VT_SUBCHANNELS)) { - subchannels.emplace_back(subchannel); + subchannels.reserve(body->subchannels()->size()); + + for (const auto subchannel : *body->subchannels()) + { + subchannels.emplace_back(subchannel); + } } std::optional requiredSubchannel{ std::nullopt }; From 6e1684cb2c7af4569b268df21d62c448606f24c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Mon, 23 Oct 2023 11:26:55 +0200 Subject: [PATCH 45/73] Rust: Fix worker error handling Properly retrieve the error reason. --- rust/src/worker/channel.rs | 4 ++-- rust/tests/integration/pipe_transport.rs | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/rust/src/worker/channel.rs b/rust/src/worker/channel.rs index 85b5d9cfdd..a0dd9f8b08 100644 --- a/rust/src/worker/channel.rs +++ b/rust/src/worker/channel.rs @@ -270,9 +270,9 @@ impl Channel { .remove(&response.id().unwrap()); if let Some(mut sender) = sender { // Request did not succeed. - if let Ok(Some(error)) = response.error() { + if let Ok(Some(reason)) = response.reason() { let _ = sender.send(Err(ResponseError { - reason: error.to_string(), + reason: reason.to_string(), })); } // Request succeeded. diff --git a/rust/tests/integration/pipe_transport.rs b/rust/tests/integration/pipe_transport.rs index 1268d9a579..242c37a483 100644 --- a/rust/tests/integration/pipe_transport.rs +++ b/rust/tests/integration/pipe_transport.rs @@ -561,7 +561,6 @@ fn pipe_to_router_succeeds_with_video() { } #[test] -#[ignore] fn pipe_to_router_fails_if_both_routers_belong_to_the_same_worker() { future::block_on(async move { let (worker1, _worker2, router1, _router2, transport1, _transport2) = init().await; @@ -945,7 +944,6 @@ fn consume_for_pipe_producer_succeeds() { } #[test] -#[ignore] fn producer_pause_resume_are_transmitted_to_pipe_consumer() { future::block_on(async move { let (_worker1, _worker2, router1, router2, transport1, transport2) = init().await; From 860014c2384b427d745dc271f3b60f395609dde0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Mon, 23 Oct 2023 12:30:36 +0200 Subject: [PATCH 46/73] Rust: Data[Producer|Consumer] subchannels (#1191) Rust: Data[Producer|Consumer] subchannels --- node/src/tests/test-DirectTransport.ts | 2 + rust/benches/direct_data.rs | 5 +- rust/src/fbs.rs | 120 +++--------- rust/src/messages.rs | 63 ++++++- rust/src/router.rs | 16 -- rust/src/router/data_consumer.rs | 40 +++- rust/src/router/data_producer.rs | 9 +- rust/src/router/transport.rs | 3 + rust/tests/integration/data_consumer.rs | 12 +- rust/tests/integration/direct_transport.rs | 210 ++++++++++++++++++++- worker/.clang-tidy | 1 + worker/fbs/dataConsumer.fbs | 4 +- 12 files changed, 357 insertions(+), 128 deletions(-) diff --git a/node/src/tests/test-DirectTransport.ts b/node/src/tests/test-DirectTransport.ts index 60034008fd..eadb37a0e8 100644 --- a/node/src/tests/test-DirectTransport.ts +++ b/node/src/tests/test-DirectTransport.ts @@ -385,11 +385,13 @@ test('dataProducer.send() with subchannels succeeds', async () => for (const message of receivedMessages1) { expect([ 'both', 'dc1' ].includes(message)).toBe(true); + expect([ 'dc2' ].includes(message)).toBe(false); } for (const message of receivedMessages2) { expect([ 'both', 'dc2' ].includes(message)).toBe(true); + expect([ 'dc1' ].includes(message)).toBe(false); } }, 5000); diff --git a/rust/benches/direct_data.rs b/rust/benches/direct_data.rs index 8406a7acd3..0cea4d8fe0 100644 --- a/rust/benches/direct_data.rs +++ b/rust/benches/direct_data.rs @@ -19,7 +19,7 @@ async fn create_data_producer_consumer_pair( .produce_data(DataProducerOptions::new_direct()) .await?; let data_consumer = direct_transport - .consume_data(DataConsumerOptions::new_direct(data_producer.id())) + .consume_data(DataConsumerOptions::new_direct(data_producer.id(), None)) .await?; Ok((data_producer, data_consumer)) @@ -51,7 +51,8 @@ pub fn criterion_benchmark(c: &mut Criterion) { let _ = sender.send(()); }); - let _ = direct_data_producer.send(WebRtcMessage::Binary(Cow::from(data))); + let _ = + direct_data_producer.send(WebRtcMessage::Binary(Cow::from(data)), None, None); let _ = receiver.recv(); }) diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index b923e88d4f..e883f180e0 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -26331,16 +26331,7 @@ mod root { )] pub struct SetSubchannelsRequest { /// The field `subchannels` in the table `SetSubchannelsRequest` - pub subchannels: ::core::option::Option<::planus::alloc::vec::Vec>, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for SetSubchannelsRequest { - fn default() -> Self { - Self { - subchannels: ::core::default::Default::default(), - } - } + pub subchannels: ::planus::alloc::vec::Vec, } impl SetSubchannelsRequest { @@ -26353,23 +26344,17 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_subchannels: impl ::planus::WriteAsOptional<::planus::Offset<[u16]>>, + 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(); - if prepared_subchannels.is_some() { - table_writer.write_entry::<::planus::Offset<[u16]>>(0); - } + table_writer.write_entry::<::planus::Offset<[u16]>>(0); unsafe { table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_subchannels) = - prepared_subchannels - { - object_writer.write::<_, _, 4>(&prepared_subchannels); - } + object_writer.write::<_, _, 4>(&prepared_subchannels); }); } builder.current_offset() @@ -26424,17 +26409,10 @@ mod root { #[allow(clippy::type_complexity)] pub fn subchannels(self, value: T0) -> SetSubchannelsRequestBuilder<(T0,)> where - T0: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, + T0: ::planus::WriteAs<::planus::Offset<[u16]>>, { SetSubchannelsRequestBuilder((value,)) } - - /// Sets the [`subchannels` field](SetSubchannelsRequest#structfield.subchannels) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn subchannels_as_null(self) -> SetSubchannelsRequestBuilder<((),)> { - self.subchannels(()) - } } impl SetSubchannelsRequestBuilder<(T0,)> { @@ -26451,7 +26429,7 @@ mod root { } } - impl>> + impl>> ::planus::WriteAs<::planus::Offset> for SetSubchannelsRequestBuilder<(T0,)> { @@ -26466,7 +26444,7 @@ mod root { } } - impl>> + impl>> ::planus::WriteAsOptional<::planus::Offset> for SetSubchannelsRequestBuilder<(T0,)> { @@ -26482,7 +26460,7 @@ mod root { } } - impl>> + impl>> ::planus::WriteAsOffset for SetSubchannelsRequestBuilder<(T0,)> { @@ -26503,22 +26481,16 @@ mod root { impl<'a> SetSubchannelsRequestRef<'a> { /// Getter for the [`subchannels` field](SetSubchannelsRequest#structfield.subchannels). #[inline] - pub fn subchannels( - &self, - ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, u16>>> - { - self.0.access(0, "SetSubchannelsRequest", "subchannels") + 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"); - if let ::core::option::Option::Some(field_subchannels) = - self.subchannels().transpose() - { - f.field("subchannels", &field_subchannels); - } + f.field("subchannels", &self.subchannels()); f.finish() } } @@ -26529,13 +26501,7 @@ mod root { #[allow(unreachable_code)] fn try_from(value: SetSubchannelsRequestRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - subchannels: if let ::core::option::Option::Some(subchannels) = - value.subchannels()? - { - ::core::option::Option::Some(subchannels.to_vec()?) - } else { - ::core::option::Option::None - }, + subchannels: value.subchannels()?.to_vec()?, }) } } @@ -26631,16 +26597,7 @@ mod root { )] pub struct SetSubchannelsResponse { /// The field `subchannels` in the table `SetSubchannelsResponse` - pub subchannels: ::core::option::Option<::planus::alloc::vec::Vec>, - } - - #[allow(clippy::derivable_impls)] - impl ::core::default::Default for SetSubchannelsResponse { - fn default() -> Self { - Self { - subchannels: ::core::default::Default::default(), - } - } + pub subchannels: ::planus::alloc::vec::Vec, } impl SetSubchannelsResponse { @@ -26653,23 +26610,17 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_subchannels: impl ::planus::WriteAsOptional<::planus::Offset<[u16]>>, + 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(); - if prepared_subchannels.is_some() { - table_writer.write_entry::<::planus::Offset<[u16]>>(0); - } + table_writer.write_entry::<::planus::Offset<[u16]>>(0); unsafe { table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_subchannels) = - prepared_subchannels - { - object_writer.write::<_, _, 4>(&prepared_subchannels); - } + object_writer.write::<_, _, 4>(&prepared_subchannels); }); } builder.current_offset() @@ -26726,17 +26677,10 @@ mod root { #[allow(clippy::type_complexity)] pub fn subchannels(self, value: T0) -> SetSubchannelsResponseBuilder<(T0,)> where - T0: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, + T0: ::planus::WriteAs<::planus::Offset<[u16]>>, { SetSubchannelsResponseBuilder((value,)) } - - /// Sets the [`subchannels` field](SetSubchannelsResponse#structfield.subchannels) to null. - #[inline] - #[allow(clippy::type_complexity)] - pub fn subchannels_as_null(self) -> SetSubchannelsResponseBuilder<((),)> { - self.subchannels(()) - } } impl SetSubchannelsResponseBuilder<(T0,)> { @@ -26753,7 +26697,7 @@ mod root { } } - impl>> + impl>> ::planus::WriteAs<::planus::Offset> for SetSubchannelsResponseBuilder<(T0,)> { @@ -26768,7 +26712,7 @@ mod root { } } - impl>> + impl>> ::planus::WriteAsOptional<::planus::Offset> for SetSubchannelsResponseBuilder<(T0,)> { @@ -26784,7 +26728,7 @@ mod root { } } - impl>> + impl>> ::planus::WriteAsOffset for SetSubchannelsResponseBuilder<(T0,)> { @@ -26805,22 +26749,16 @@ mod root { impl<'a> SetSubchannelsResponseRef<'a> { /// Getter for the [`subchannels` field](SetSubchannelsResponse#structfield.subchannels). #[inline] - pub fn subchannels( - &self, - ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, u16>>> - { - self.0.access(0, "SetSubchannelsResponse", "subchannels") + 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"); - if let ::core::option::Option::Some(field_subchannels) = - self.subchannels().transpose() - { - f.field("subchannels", &field_subchannels); - } + f.field("subchannels", &self.subchannels()); f.finish() } } @@ -26831,13 +26769,7 @@ mod root { #[allow(unreachable_code)] fn try_from(value: SetSubchannelsResponseRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - subchannels: if let ::core::option::Option::Some(subchannels) = - value.subchannels()? - { - ::core::option::Option::Some(subchannels.to_vec()?) - } else { - ::core::option::Option::None - }, + subchannels: value.subchannels()?.to_vec()?, }) } } diff --git a/rust/src/messages.rs b/rust/src/messages.rs index 327a82eb84..86ad756298 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -1909,6 +1909,7 @@ pub(crate) struct TransportConsumeDataRequest { pub(crate) label: String, pub(crate) protocol: String, pub(crate) paused: bool, + pub(crate) subchannels: Option>, } #[derive(Debug)] @@ -1919,6 +1920,7 @@ pub(crate) struct TransportConsumeDataResponse { pub(crate) protocol: String, pub(crate) paused: bool, pub(crate) data_producer_paused: bool, + pub(crate) subchannels: Vec, } impl Request for TransportConsumeDataRequest { @@ -1949,8 +1951,7 @@ impl Request for TransportConsumeDataRequest { Some(self.protocol) }, self.paused, - // TODO. - None::>, + self.subchannels, ); let request_body = request::Body::create_transport_consume_data_request(&mut builder, data); let request = request::Request::create( @@ -1985,6 +1986,7 @@ impl Request for TransportConsumeDataRequest { protocol: data.protocol.to_string(), paused: data.paused, data_producer_paused: data.data_producer_paused, + subchannels: data.subchannels, }) } } @@ -2830,6 +2832,8 @@ impl Request for DataProducerResumeRequest { pub(crate) struct DataProducerSendNotification { pub(crate) ppid: u32, pub(crate) payload: Vec, + pub(crate) subchannels: Option>, + pub(crate) required_subchannel: Option, } impl Notification for DataProducerSendNotification { @@ -2839,17 +2843,14 @@ impl Notification for DataProducerSendNotification { fn into_bytes(self, handler_id: Self::HandlerId) -> Vec { let mut builder = Builder::new(); - // TODO: Implement subchannels. - let subchannels: Vec = vec![]; - let required_subchannel: Option = Default::default(); let binary_data = data_producer::Binary::create(&mut builder, self.payload); let binary = data_producer::Data::create_binary(&mut builder, binary_data); let data = data_producer::SendNotification::create( &mut builder, self.ppid, binary, - subchannels, - required_subchannel, + self.subchannels, + self.required_subchannel, ); let notification_body = notification::Body::create_data_producer_send_notification(&mut builder, data); @@ -3172,6 +3173,54 @@ impl From for u32 { } } +#[derive(Debug, Clone, Serialize)] +pub(crate) struct DataConsumerSetSubchannelsRequest { + pub(crate) subchannels: Vec, +} + +#[derive(Debug, Clone, Serialize)] +pub(crate) struct DataConsumerSetSubchannelsResponse { + pub(crate) subchannels: Vec, +} + +impl Request for DataConsumerSetSubchannelsRequest { + const METHOD: request::Method = request::Method::DataconsumerSetSubchannels; + type HandlerId = DataConsumerId; + type Response = DataConsumerSetSubchannelsResponse; + + fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { + let mut builder = Builder::new(); + + let data = data_consumer::SetSubchannelsRequest::create(&mut builder, self.subchannels); + let request_body = + request::Body::create_data_consumer_set_subchannels_request(&mut builder, data); + + let request = request::Request::create( + &mut builder, + id, + Self::METHOD, + handler_id.to_string(), + Some(request_body), + ); + let message_body = message::Body::create_request(&mut builder, request); + let message = message::Message::create(&mut builder, message::Type::Request, message_body); + + builder.finish(message, None).to_vec() + } + + fn convert_response( + response: Option, + ) -> Result> { + let Some(response::Body::DataConsumerSetSubchannelsResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + Ok(DataConsumerSetSubchannelsResponse { + subchannels: data.subchannels, + }) + } +} + #[derive(Debug)] pub(crate) struct RtpObserverCloseRequest { pub(crate) rtp_observer_id: RtpObserverId, diff --git a/rust/src/router.rs b/rust/src/router.rs index 4c1925e603..c2d09a0228 100644 --- a/rust/src/router.rs +++ b/rust/src/router.rs @@ -658,22 +658,6 @@ impl Router { } }; - /* - let data = self - .inner - .channel - .request( - self.inner.id, - RouterCreateWebRtcTransportRequest { - data: RouterCreateWebrtcTransportData::from_options( - transport_id, - &webrtc_transport_options, - ), - }, - ) - .await?; - */ - let transport = WebRtcTransport::new( transport_id, Arc::clone(&self.inner.executor), diff --git a/rust/src/router/data_consumer.rs b/rust/src/router/data_consumer.rs index 401eec52da..7d8b2bc828 100644 --- a/rust/src/router/data_consumer.rs +++ b/rust/src/router/data_consumer.rs @@ -8,6 +8,7 @@ use crate::messages::{ DataConsumerCloseRequest, DataConsumerDumpRequest, DataConsumerGetBufferedAmountRequest, DataConsumerGetStatsRequest, DataConsumerPauseRequest, DataConsumerResumeRequest, DataConsumerSendRequest, DataConsumerSetBufferedAmountLowThresholdRequest, + DataConsumerSetSubchannelsRequest, }; use crate::sctp_parameters::SctpStreamParameters; use crate::transport::Transport; @@ -56,6 +57,10 @@ pub struct DataConsumerOptions { pub(super) max_retransmits: Option, /// Whether the DataConsumer must start in paused mode. Default false. pub paused: bool, + /// Subchannels this DataConsumer initially subscribes to. + /// Only used in case this DataConsumer receives messages from a local DataProducer + /// that specifies subchannel(s) when calling send(). + pub subchannels: Option>, /// Custom application data. pub app_data: AppData, } @@ -70,6 +75,7 @@ impl DataConsumerOptions { ordered: None, max_packet_life_time: None, max_retransmits: None, + subchannels: None, paused: false, app_data: AppData::default(), } @@ -77,13 +83,14 @@ impl DataConsumerOptions { /// For [`DirectTransport`](crate::direct_transport::DirectTransport). #[must_use] - pub fn new_direct(data_producer_id: DataProducerId) -> Self { + pub fn new_direct(data_producer_id: DataProducerId, subchannels: Option>) -> Self { Self { data_producer_id, ordered: Some(true), max_packet_life_time: None, max_retransmits: None, paused: false, + subchannels, app_data: AppData::default(), } } @@ -97,6 +104,7 @@ impl DataConsumerOptions { max_packet_life_time: None, max_retransmits: None, paused: false, + subchannels: None, app_data: AppData::default(), } } @@ -114,6 +122,7 @@ impl DataConsumerOptions { max_packet_life_time: Some(max_packet_life_time), max_retransmits: None, paused: false, + subchannels: None, app_data: AppData::default(), } } @@ -130,6 +139,7 @@ impl DataConsumerOptions { max_packet_life_time: None, max_retransmits: Some(max_retransmits), paused: false, + subchannels: None, app_data: AppData::default(), } } @@ -148,6 +158,7 @@ pub struct DataConsumerDump { pub sctp_stream_parameters: Option, pub buffered_amount_low_threshold: u32, pub paused: bool, + pub subchannels: Vec, pub data_producer_paused: bool, } @@ -168,6 +179,7 @@ impl DataConsumerDump { .map(|parameters| SctpStreamParameters::from_fbs(*parameters)), buffered_amount_low_threshold: dump.buffered_amount_low_threshold, paused: dump.paused, + subchannels: dump.subchannels, data_producer_paused: dump.data_producer_paused, }) } @@ -298,6 +310,7 @@ struct Inner { data_producer_id: DataProducerId, direct: bool, paused: Arc>, + subchannels: Arc>>, data_producer_paused: Arc>, executor: Arc>, channel: Channel, @@ -450,6 +463,7 @@ impl DataConsumer { executor: Arc>, channel: Channel, data_producer_paused: bool, + subchannels: Vec, app_data: AppData, transport: Arc, direct: bool, @@ -461,6 +475,7 @@ impl DataConsumer { let paused = Arc::new(Mutex::new(paused)); #[allow(clippy::mutex_atomic)] let data_producer_paused = Arc::new(Mutex::new(data_producer_paused)); + let subchannels = Arc::new(Mutex::new(subchannels)); let inner_weak = Arc::>>>::default(); let subscription_handler = { @@ -567,6 +582,7 @@ impl DataConsumer { executor, channel, handlers, + subchannels, app_data, transport, weak_data_producer: data_producer.downgrade(), @@ -638,6 +654,12 @@ impl DataConsumer { &self.inner().protocol } + /// The data consumer subchannels. + #[must_use] + pub fn subchannels(&self) -> Vec { + self.inner().subchannels.lock().clone() + } + /// Custom application data. #[must_use] pub fn app_data(&self) -> &AppData { @@ -897,6 +919,22 @@ impl DirectDataConsumer { ) .await } + + /// Sets subchannels to the worker DataConsumer. + pub async fn set_subchannels(&self, subchannels: Vec) -> Result<(), RequestError> { + let response = self + .inner + .channel + .request( + self.inner.id, + DataConsumerSetSubchannelsRequest { subchannels }, + ) + .await?; + + *self.inner.subchannels.lock() = response.subchannels; + + Ok(()) + } } /// [`WeakDataConsumer`] doesn't own data consumer instance on mediasoup-worker and will not prevent diff --git a/rust/src/router/data_producer.rs b/rust/src/router/data_producer.rs index 409b372400..baef69427e 100644 --- a/rust/src/router/data_producer.rs +++ b/rust/src/router/data_producer.rs @@ -543,7 +543,12 @@ impl DataProducer { impl DirectDataProducer { /// Sends direct messages from the Rust to the worker. - pub fn send(&self, message: WebRtcMessage<'_>) -> Result<(), NotificationError> { + pub fn send( + &self, + message: WebRtcMessage<'_>, + subchannels: Option>, + required_subchannel: Option, + ) -> Result<(), NotificationError> { let (ppid, _payload) = message.into_ppid_and_payload(); self.inner.channel.notify( @@ -551,6 +556,8 @@ impl DirectDataProducer { DataProducerSendNotification { ppid, payload: _payload.into_owned(), + subchannels, + required_subchannel, }, ) } diff --git a/rust/src/router/transport.rs b/rust/src/router/transport.rs index 7e4a35b0e0..cbab16ca27 100644 --- a/rust/src/router/transport.rs +++ b/rust/src/router/transport.rs @@ -765,6 +765,7 @@ pub(super) trait TransportImpl: TransportGeneric { max_packet_life_time, max_retransmits, paused, + subchannels, app_data, } = data_consumer_options; @@ -829,6 +830,7 @@ pub(super) trait TransportImpl: TransportGeneric { sctp_stream_parameters, label: data_producer.label().clone(), protocol: data_producer.protocol().clone(), + subchannels, paused, }, ) @@ -846,6 +848,7 @@ pub(super) trait TransportImpl: TransportGeneric { Arc::clone(self.executor()), self.channel().clone(), response.data_producer_paused, + response.subchannels, app_data, Arc::new(self.clone()), transport_type == TransportType::Direct, diff --git a/rust/tests/integration/data_consumer.rs b/rust/tests/integration/data_consumer.rs index 30b3688279..3d0894fcc7 100644 --- a/rust/tests/integration/data_consumer.rs +++ b/rust/tests/integration/data_consumer.rs @@ -129,6 +129,7 @@ fn consume_data_succeeds() { 4000, ); + options.subchannels = Some(vec![0, 1, 1, 1, 2, 65535, 100]); options.app_data = AppData::new(CustomAppData { baz: "LOL" }); options @@ -152,6 +153,11 @@ fn consume_data_succeeds() { } assert_eq!(data_consumer.label().as_str(), "foo"); assert_eq!(data_consumer.protocol().as_str(), "bar"); + + let mut sorted_subchannels = data_consumer.subchannels(); + sorted_subchannels.sort(); + + assert_eq!(sorted_subchannels, [0, 1, 2, 100, 65535]); assert_eq!( data_consumer .app_data() @@ -339,7 +345,7 @@ fn consume_data_on_direct_transport_succeeds() { let data_consumer = transport3 .consume_data({ - let mut options = DataConsumerOptions::new_direct(data_producer.id()); + let mut options = DataConsumerOptions::new_direct(data_producer.id(), None); options.app_data = AppData::new(CustomAppData2 { hehe: "HEHE" }); @@ -386,7 +392,7 @@ fn dump_on_direct_transport_succeeds() { let data_consumer = transport3 .consume_data({ - let mut options = DataConsumerOptions::new_direct(data_producer.id()); + let mut options = DataConsumerOptions::new_direct(data_producer.id(), None); options.app_data = AppData::new(CustomAppData2 { hehe: "HEHE" }); @@ -421,7 +427,7 @@ fn get_stats_on_direct_transport_succeeds() { let data_consumer = transport3 .consume_data({ - let mut options = DataConsumerOptions::new_direct(data_producer.id()); + let mut options = DataConsumerOptions::new_direct(data_producer.id(), None); options.app_data = AppData::new(CustomAppData2 { hehe: "HEHE" }); diff --git a/rust/tests/integration/direct_transport.rs b/rust/tests/integration/direct_transport.rs index 290136f241..380f3e1b3e 100644 --- a/rust/tests/integration/direct_transport.rs +++ b/rust/tests/integration/direct_transport.rs @@ -175,7 +175,7 @@ fn send_succeeds() { .expect("Failed to produce data"); let data_consumer = transport - .consume_data(DataConsumerOptions::new_direct(data_producer.id())) + .consume_data(DataConsumerOptions::new_direct(data_producer.id(), None)) .await .expect("Failed to consume data"); @@ -286,7 +286,7 @@ fn send_succeeds() { }; direct_data_producer - .send(message) + .send(message, None, None) .expect("Failed to send message"); if id == num_messages { @@ -342,6 +342,212 @@ fn send_succeeds() { }); } +#[test] +fn send_with_subchannels_succeeds() { + future::block_on(async move { + let (_worker, _router, transport) = init().await; + + let data_producer = transport + .produce_data({ + let mut options = DataProducerOptions::new_direct(); + + options.label = "foo".to_string(); + options.protocol = "bar".to_string(); + options.app_data = AppData::new(CustomAppData { foo: "bar" }); + + options + }) + .await + .expect("Failed to produce data"); + + let data_consumer_1 = transport + .consume_data(DataConsumerOptions::new_direct( + data_producer.id(), + Some(vec![1, 11, 666]), + )) + .await + .expect("Failed to consume data"); + + let data_consumer_2 = transport + .consume_data(DataConsumerOptions::new_direct( + data_producer.id(), + Some(vec![2, 22, 666]), + )) + .await + .expect("Failed to consume data"); + + let expected_received_num_messages_1 = 7; + let expected_received_num_messages_2 = 5; + let received_messages_1: Arc>> = Arc::new(Mutex::new(vec![])); + let received_messages_2: Arc>> = Arc::new(Mutex::new(vec![])); + + let (received_messages_tx_1, received_messages_rx_1) = async_oneshot::oneshot::<()>(); + let _handler_1 = data_consumer_1.on_message({ + let received_messages_tx_1 = Mutex::new(Some(received_messages_tx_1)); + let received_messages_1 = Arc::clone(&received_messages_1); + + move |message| { + let text: String = match message { + WebRtcMessage::String(string) => string.parse().unwrap(), + _ => { + panic!("Unexpected empty messages!"); + } + }; + + received_messages_1.lock().push(text); + + if received_messages_1.lock().len() == expected_received_num_messages_1 { + let _ = received_messages_tx_1.lock().take().unwrap().send(()); + } + } + }); + + let (received_messages_tx_2, received_messages_rx_2) = async_oneshot::oneshot::<()>(); + let _handler_2 = data_consumer_2.on_message({ + let received_messages_tx_2 = Mutex::new(Some(received_messages_tx_2)); + let received_messages_2 = Arc::clone(&received_messages_2); + + move |message| { + let text: String = match message { + WebRtcMessage::String(string) => string.parse().unwrap(), + _ => { + panic!("Unexpected empty messages!"); + } + }; + + received_messages_2.lock().push(text); + + if received_messages_2.lock().len() == expected_received_num_messages_2 { + let _ = received_messages_tx_2.lock().take().unwrap().send(()); + } + } + }); + + let direct_data_producer = match &data_producer { + DataProducer::Direct(direct_data_producer) => direct_data_producer, + _ => { + panic!("Expected direct data producer") + } + }; + + let direct_data_consumer_2 = match &data_consumer_2 { + DataConsumer::Direct(direct_data_consumer) => direct_data_consumer, + _ => { + panic!("Expected direct data consumer") + } + }; + + let both: &'static str = "both"; + let none: &'static str = "none"; + let dc1: &'static str = "dc1"; + let dc2: &'static str = "dc2"; + + // Must be received by dataConsumer1 and dataConsumer2. + direct_data_producer + .send(WebRtcMessage::String(both.to_string()), None, None) + .expect("Failed to send message"); + + // Must be received by dataConsumer1 and dataConsumer2. + direct_data_producer + .send( + WebRtcMessage::String(both.to_string()), + Some(vec![1, 2]), + None, + ) + .expect("Failed to send message"); + + // Must be received by dataConsumer1 and dataConsumer2. + direct_data_producer + .send( + WebRtcMessage::String(both.to_string()), + Some(vec![11, 22, 33]), + Some(666), + ) + .expect("Failed to send message"); + + // Must not be received by neither dataConsumer1 nor dataConsumer2. + direct_data_producer + .send( + WebRtcMessage::String(none.to_string()), + Some(vec![3]), + Some(666), + ) + .expect("Failed to send message"); + + // Must not be received by neither dataConsumer1 nor dataConsumer2. + direct_data_producer + .send( + WebRtcMessage::String(none.to_string()), + Some(vec![666]), + Some(3), + ) + .expect("Failed to send message"); + + // Must be received by dataConsumer1. + direct_data_producer + .send(WebRtcMessage::String(dc1.to_string()), Some(vec![1]), None) + .expect("Failed to send message"); + + // Must be received by dataConsumer1. + direct_data_producer + .send(WebRtcMessage::String(dc1.to_string()), Some(vec![11]), None) + .expect("Failed to send message"); + + // Must be received by dataConsumer1. + direct_data_producer + .send( + WebRtcMessage::String(dc1.to_string()), + Some(vec![666]), + Some(11), + ) + .expect("Failed to send message"); + + // Must be received by dataConsumer2. + direct_data_producer + .send( + WebRtcMessage::String(dc2.to_string()), + Some(vec![666]), + Some(2), + ) + .expect("Failed to send message"); + + let mut subchannels = data_consumer_2.subchannels(); + subchannels.push(1); + + direct_data_consumer_2 + .set_subchannels(subchannels) + .await + .expect("Failed to set subchannels"); + + // Must be received by dataConsumer2. + direct_data_producer + .send( + WebRtcMessage::String(both.to_string()), + Some(vec![1]), + Some(666), + ) + .expect("Failed to send message"); + + received_messages_rx_1 + .await + .expect("Failed tor receive all messages"); + + received_messages_rx_2 + .await + .expect("Failed tor receive all messages"); + + let received_messages_1 = received_messages_1.lock().clone(); + assert!(received_messages_1.contains(&both.to_string())); + assert!(received_messages_1.contains(&dc1.to_string())); + assert!(!received_messages_1.contains(&dc2.to_string())); + + let received_messages_2 = received_messages_2.lock().clone(); + assert!(received_messages_2.contains(&both.to_string())); + assert!(!received_messages_2.contains(&dc1.to_string())); + assert!(received_messages_2.contains(&dc2.to_string())); + }); +} + #[test] fn close_event() { future::block_on(async move { diff --git a/worker/.clang-tidy b/worker/.clang-tidy index f3ade0aca9..ec3efa87e8 100644 --- a/worker/.clang-tidy +++ b/worker/.clang-tidy @@ -2,6 +2,7 @@ Checks: "*,\ -altera*,\ -boost-use-to-string,\ + -bugprone-easily-swappable-parameters,\ -cert-*,\ -clang-analyzer-optin.osx.*,\ -clang-analyzer-osx.*,\ diff --git a/worker/fbs/dataConsumer.fbs b/worker/fbs/dataConsumer.fbs index 8adcfdc70f..a458b2cdd3 100644 --- a/worker/fbs/dataConsumer.fbs +++ b/worker/fbs/dataConsumer.fbs @@ -53,11 +53,11 @@ table SendRequest { } table SetSubchannelsRequest { - subchannels: [uint16]; + subchannels: [uint16] (required); } table SetSubchannelsResponse { - subchannels: [uint16]; + subchannels: [uint16] (required); } // Notifications from Worker. From 33a76c36cb3b5f472eebb9637f4b8fface1a72dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Mon, 23 Oct 2023 17:16:39 +0200 Subject: [PATCH 47/73] format fbs files --- worker/fbs/rtpPacket.fbs | 1 + worker/fbs/transport.fbs | 1 + 2 files changed, 2 insertions(+) diff --git a/worker/fbs/rtpPacket.fbs b/worker/fbs/rtpPacket.fbs index a724ea67bb..3975d9d748 100644 --- a/worker/fbs/rtpPacket.fbs +++ b/worker/fbs/rtpPacket.fbs @@ -18,3 +18,4 @@ table Dump { rrid: string; wide_sequence_number: uint16 = null; } + diff --git a/worker/fbs/transport.fbs b/worker/fbs/transport.fbs index f86af45913..d2a77d4ae9 100644 --- a/worker/fbs/transport.fbs +++ b/worker/fbs/transport.fbs @@ -108,6 +108,7 @@ table RecvRtpHeaderExtensions { table Options { direct: bool = false; + /// Only needed for DirectTransport. This value is handled by base Transport. max_message_size: uint32 = null; initial_available_outgoing_bitrate: uint32 = null; From b4c80d8c8f0ea781a45422aa2aef045ff6a82ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Wed, 25 Oct 2023 10:31:05 +0200 Subject: [PATCH 48/73] Update NPM dev deps --- package-lock.json | 346 +++++++++++++++++++++++----------------------- package.json | 6 +- 2 files changed, 176 insertions(+), 176 deletions(-) diff --git a/package-lock.json b/package-lock.json index b4496e7c09..b6425743f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,10 +22,10 @@ "@octokit/rest": "^20.0.2", "@types/debug": "^4.1.10", "@types/jest": "^29.5.6", - "@types/node": "^20.8.7", + "@types/node": "^20.8.8", "@types/uuid": "^9.0.6", - "@typescript-eslint/eslint-plugin": "^6.8.0", - "@typescript-eslint/parser": "^6.8.0", + "@typescript-eslint/eslint-plugin": "^6.9.0", + "@typescript-eslint/parser": "^6.9.0", "eslint": "^8.52.0", "eslint-plugin-jest": "^27.4.3", "jest": "^29.7.0", @@ -1621,9 +1621,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.8.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.7.tgz", - "integrity": "sha512-21TKHHh3eUHIi2MloeptJWALuCu5H7HQTdTrWIFReA8ad+aggoX+lRes3ex7/FtpC+sVUpFMQ+QTfYr74mruiQ==", + "version": "20.8.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.8.tgz", + "integrity": "sha512-YRsdVxq6OaLfmR9Hy816IMp33xOBjfyOgUd77ehqg96CFywxAPbDbXvAsuN2KVg2HOT8Eh6uAfU+l4WffwPVrQ==", "dev": true, "dependencies": { "undici-types": "~5.25.1" @@ -1669,16 +1669,16 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.8.0.tgz", - "integrity": "sha512-GosF4238Tkes2SHPQ1i8f6rMtG6zlKwMEB0abqSJ3Npvos+doIlc/ATG+vX1G9coDF3Ex78zM3heXHLyWEwLUw==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.9.0.tgz", + "integrity": "sha512-lgX7F0azQwRPB7t7WAyeHWVfW1YJ9NIgd9mvGhfQpRY56X6AVf8mwM8Wol+0z4liE7XX3QOt8MN1rUKCfSjRIA==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.8.0", - "@typescript-eslint/type-utils": "6.8.0", - "@typescript-eslint/utils": "6.8.0", - "@typescript-eslint/visitor-keys": "6.8.0", + "@typescript-eslint/scope-manager": "6.9.0", + "@typescript-eslint/type-utils": "6.9.0", + "@typescript-eslint/utils": "6.9.0", + "@typescript-eslint/visitor-keys": "6.9.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -1704,13 +1704,13 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.8.0.tgz", - "integrity": "sha512-xe0HNBVwCph7rak+ZHcFD6A+q50SMsFwcmfdjs9Kz4qDh5hWhaPhFjRs/SODEhroBI5Ruyvyz9LfwUJ624O40g==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz", + "integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/visitor-keys": "6.8.0" + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/visitor-keys": "6.9.0" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1721,9 +1721,9 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.8.0.tgz", - "integrity": "sha512-p5qOxSum7W3k+llc7owEStXlGmSl8FcGvhYt8Vjy7FqEnmkCVlM3P57XQEGj58oqaBWDQXbJDZxwUWMS/EAPNQ==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz", + "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1734,13 +1734,13 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/typescript-estree": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.8.0.tgz", - "integrity": "sha512-ISgV0lQ8XgW+mvv5My/+iTUdRmGspducmQcDw5JxznasXNnZn3SKNrTRuMsEXv+V/O+Lw9AGcQCfVaOPCAk/Zg==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz", + "integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/visitor-keys": "6.8.0", + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/visitor-keys": "6.9.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -1761,17 +1761,17 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/utils": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.8.0.tgz", - "integrity": "sha512-dKs1itdE2qFG4jr0dlYLQVppqTE+Itt7GmIf/vX6CSvsW+3ov8PbWauVKyyfNngokhIO9sKZeRGCUo1+N7U98Q==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.0.tgz", + "integrity": "sha512-5Wf+Jsqya7WcCO8me504FBigeQKVLAMPmUzYgDbWchINNh1KJbxCgVya3EQ2MjvJMVeXl3pofRmprqX6mfQkjQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.8.0", - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/typescript-estree": "6.8.0", + "@typescript-eslint/scope-manager": "6.9.0", + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/typescript-estree": "6.9.0", "semver": "^7.5.4" }, "engines": { @@ -1786,12 +1786,12 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.8.0.tgz", - "integrity": "sha512-oqAnbA7c+pgOhW2OhGvxm0t1BULX5peQI/rLsNDpGM78EebV3C9IGbX5HNZabuZ6UQrYveCLjKo8Iy/lLlBkkg==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz", + "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.8.0", + "@typescript-eslint/types": "6.9.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -1803,15 +1803,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.8.0.tgz", - "integrity": "sha512-5tNs6Bw0j6BdWuP8Fx+VH4G9fEPDxnVI7yH1IAPkQH5RUtvKwRoqdecAPdQXv4rSOADAaz1LFBZvZG7VbXivSg==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.9.0.tgz", + "integrity": "sha512-GZmjMh4AJ/5gaH4XF2eXA8tMnHWP+Pm1mjQR2QN4Iz+j/zO04b9TOvJYOX2sCNIQHtRStKTxRY1FX7LhpJT4Gw==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "6.8.0", - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/typescript-estree": "6.8.0", - "@typescript-eslint/visitor-keys": "6.8.0", + "@typescript-eslint/scope-manager": "6.9.0", + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/typescript-estree": "6.9.0", + "@typescript-eslint/visitor-keys": "6.9.0", "debug": "^4.3.4" }, "engines": { @@ -1831,13 +1831,13 @@ } }, "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.8.0.tgz", - "integrity": "sha512-xe0HNBVwCph7rak+ZHcFD6A+q50SMsFwcmfdjs9Kz4qDh5hWhaPhFjRs/SODEhroBI5Ruyvyz9LfwUJ624O40g==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz", + "integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/visitor-keys": "6.8.0" + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/visitor-keys": "6.9.0" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1848,9 +1848,9 @@ } }, "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.8.0.tgz", - "integrity": "sha512-p5qOxSum7W3k+llc7owEStXlGmSl8FcGvhYt8Vjy7FqEnmkCVlM3P57XQEGj58oqaBWDQXbJDZxwUWMS/EAPNQ==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz", + "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1861,13 +1861,13 @@ } }, "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.8.0.tgz", - "integrity": "sha512-ISgV0lQ8XgW+mvv5My/+iTUdRmGspducmQcDw5JxznasXNnZn3SKNrTRuMsEXv+V/O+Lw9AGcQCfVaOPCAk/Zg==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz", + "integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/visitor-keys": "6.8.0", + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/visitor-keys": "6.9.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -1888,12 +1888,12 @@ } }, "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.8.0.tgz", - "integrity": "sha512-oqAnbA7c+pgOhW2OhGvxm0t1BULX5peQI/rLsNDpGM78EebV3C9IGbX5HNZabuZ6UQrYveCLjKo8Iy/lLlBkkg==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz", + "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.8.0", + "@typescript-eslint/types": "6.9.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -1922,13 +1922,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.8.0.tgz", - "integrity": "sha512-RYOJdlkTJIXW7GSldUIHqc/Hkto8E+fZN96dMIFhuTJcQwdRoGN2rEWA8U6oXbLo0qufH7NPElUb+MceHtz54g==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.9.0.tgz", + "integrity": "sha512-XXeahmfbpuhVbhSOROIzJ+b13krFmgtc4GlEuu1WBT+RpyGPIA4Y/eGnXzjbDj5gZLzpAXO/sj+IF/x2GtTMjQ==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "6.8.0", - "@typescript-eslint/utils": "6.8.0", + "@typescript-eslint/typescript-estree": "6.9.0", + "@typescript-eslint/utils": "6.9.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -1949,13 +1949,13 @@ } }, "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/scope-manager": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.8.0.tgz", - "integrity": "sha512-xe0HNBVwCph7rak+ZHcFD6A+q50SMsFwcmfdjs9Kz4qDh5hWhaPhFjRs/SODEhroBI5Ruyvyz9LfwUJ624O40g==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz", + "integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/visitor-keys": "6.8.0" + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/visitor-keys": "6.9.0" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1966,9 +1966,9 @@ } }, "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/types": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.8.0.tgz", - "integrity": "sha512-p5qOxSum7W3k+llc7owEStXlGmSl8FcGvhYt8Vjy7FqEnmkCVlM3P57XQEGj58oqaBWDQXbJDZxwUWMS/EAPNQ==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz", + "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1979,13 +1979,13 @@ } }, "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/typescript-estree": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.8.0.tgz", - "integrity": "sha512-ISgV0lQ8XgW+mvv5My/+iTUdRmGspducmQcDw5JxznasXNnZn3SKNrTRuMsEXv+V/O+Lw9AGcQCfVaOPCAk/Zg==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz", + "integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/visitor-keys": "6.8.0", + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/visitor-keys": "6.9.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -2006,17 +2006,17 @@ } }, "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/utils": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.8.0.tgz", - "integrity": "sha512-dKs1itdE2qFG4jr0dlYLQVppqTE+Itt7GmIf/vX6CSvsW+3ov8PbWauVKyyfNngokhIO9sKZeRGCUo1+N7U98Q==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.0.tgz", + "integrity": "sha512-5Wf+Jsqya7WcCO8me504FBigeQKVLAMPmUzYgDbWchINNh1KJbxCgVya3EQ2MjvJMVeXl3pofRmprqX6mfQkjQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.8.0", - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/typescript-estree": "6.8.0", + "@typescript-eslint/scope-manager": "6.9.0", + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/typescript-estree": "6.9.0", "semver": "^7.5.4" }, "engines": { @@ -2031,12 +2031,12 @@ } }, "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/visitor-keys": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.8.0.tgz", - "integrity": "sha512-oqAnbA7c+pgOhW2OhGvxm0t1BULX5peQI/rLsNDpGM78EebV3C9IGbX5HNZabuZ6UQrYveCLjKo8Iy/lLlBkkg==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz", + "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.8.0", + "@typescript-eslint/types": "6.9.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -8026,9 +8026,9 @@ "dev": true }, "@types/node": { - "version": "20.8.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.7.tgz", - "integrity": "sha512-21TKHHh3eUHIi2MloeptJWALuCu5H7HQTdTrWIFReA8ad+aggoX+lRes3ex7/FtpC+sVUpFMQ+QTfYr74mruiQ==", + "version": "20.8.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.8.tgz", + "integrity": "sha512-YRsdVxq6OaLfmR9Hy816IMp33xOBjfyOgUd77ehqg96CFywxAPbDbXvAsuN2KVg2HOT8Eh6uAfU+l4WffwPVrQ==", "dev": true, "requires": { "undici-types": "~5.25.1" @@ -8074,16 +8074,16 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.8.0.tgz", - "integrity": "sha512-GosF4238Tkes2SHPQ1i8f6rMtG6zlKwMEB0abqSJ3Npvos+doIlc/ATG+vX1G9coDF3Ex78zM3heXHLyWEwLUw==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.9.0.tgz", + "integrity": "sha512-lgX7F0azQwRPB7t7WAyeHWVfW1YJ9NIgd9mvGhfQpRY56X6AVf8mwM8Wol+0z4liE7XX3QOt8MN1rUKCfSjRIA==", "dev": true, "requires": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.8.0", - "@typescript-eslint/type-utils": "6.8.0", - "@typescript-eslint/utils": "6.8.0", - "@typescript-eslint/visitor-keys": "6.8.0", + "@typescript-eslint/scope-manager": "6.9.0", + "@typescript-eslint/type-utils": "6.9.0", + "@typescript-eslint/utils": "6.9.0", + "@typescript-eslint/visitor-keys": "6.9.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -8093,29 +8093,29 @@ }, "dependencies": { "@typescript-eslint/scope-manager": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.8.0.tgz", - "integrity": "sha512-xe0HNBVwCph7rak+ZHcFD6A+q50SMsFwcmfdjs9Kz4qDh5hWhaPhFjRs/SODEhroBI5Ruyvyz9LfwUJ624O40g==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz", + "integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==", "dev": true, "requires": { - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/visitor-keys": "6.8.0" + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/visitor-keys": "6.9.0" } }, "@typescript-eslint/types": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.8.0.tgz", - "integrity": "sha512-p5qOxSum7W3k+llc7owEStXlGmSl8FcGvhYt8Vjy7FqEnmkCVlM3P57XQEGj58oqaBWDQXbJDZxwUWMS/EAPNQ==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz", + "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.8.0.tgz", - "integrity": "sha512-ISgV0lQ8XgW+mvv5My/+iTUdRmGspducmQcDw5JxznasXNnZn3SKNrTRuMsEXv+V/O+Lw9AGcQCfVaOPCAk/Zg==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz", + "integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==", "dev": true, "requires": { - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/visitor-keys": "6.8.0", + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/visitor-keys": "6.9.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -8124,69 +8124,69 @@ } }, "@typescript-eslint/utils": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.8.0.tgz", - "integrity": "sha512-dKs1itdE2qFG4jr0dlYLQVppqTE+Itt7GmIf/vX6CSvsW+3ov8PbWauVKyyfNngokhIO9sKZeRGCUo1+N7U98Q==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.0.tgz", + "integrity": "sha512-5Wf+Jsqya7WcCO8me504FBigeQKVLAMPmUzYgDbWchINNh1KJbxCgVya3EQ2MjvJMVeXl3pofRmprqX6mfQkjQ==", "dev": true, "requires": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.8.0", - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/typescript-estree": "6.8.0", + "@typescript-eslint/scope-manager": "6.9.0", + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/typescript-estree": "6.9.0", "semver": "^7.5.4" } }, "@typescript-eslint/visitor-keys": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.8.0.tgz", - "integrity": "sha512-oqAnbA7c+pgOhW2OhGvxm0t1BULX5peQI/rLsNDpGM78EebV3C9IGbX5HNZabuZ6UQrYveCLjKo8Iy/lLlBkkg==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz", + "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==", "dev": true, "requires": { - "@typescript-eslint/types": "6.8.0", + "@typescript-eslint/types": "6.9.0", "eslint-visitor-keys": "^3.4.1" } } } }, "@typescript-eslint/parser": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.8.0.tgz", - "integrity": "sha512-5tNs6Bw0j6BdWuP8Fx+VH4G9fEPDxnVI7yH1IAPkQH5RUtvKwRoqdecAPdQXv4rSOADAaz1LFBZvZG7VbXivSg==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.9.0.tgz", + "integrity": "sha512-GZmjMh4AJ/5gaH4XF2eXA8tMnHWP+Pm1mjQR2QN4Iz+j/zO04b9TOvJYOX2sCNIQHtRStKTxRY1FX7LhpJT4Gw==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "6.8.0", - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/typescript-estree": "6.8.0", - "@typescript-eslint/visitor-keys": "6.8.0", + "@typescript-eslint/scope-manager": "6.9.0", + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/typescript-estree": "6.9.0", + "@typescript-eslint/visitor-keys": "6.9.0", "debug": "^4.3.4" }, "dependencies": { "@typescript-eslint/scope-manager": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.8.0.tgz", - "integrity": "sha512-xe0HNBVwCph7rak+ZHcFD6A+q50SMsFwcmfdjs9Kz4qDh5hWhaPhFjRs/SODEhroBI5Ruyvyz9LfwUJ624O40g==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz", + "integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==", "dev": true, "requires": { - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/visitor-keys": "6.8.0" + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/visitor-keys": "6.9.0" } }, "@typescript-eslint/types": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.8.0.tgz", - "integrity": "sha512-p5qOxSum7W3k+llc7owEStXlGmSl8FcGvhYt8Vjy7FqEnmkCVlM3P57XQEGj58oqaBWDQXbJDZxwUWMS/EAPNQ==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz", + "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.8.0.tgz", - "integrity": "sha512-ISgV0lQ8XgW+mvv5My/+iTUdRmGspducmQcDw5JxznasXNnZn3SKNrTRuMsEXv+V/O+Lw9AGcQCfVaOPCAk/Zg==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz", + "integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==", "dev": true, "requires": { - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/visitor-keys": "6.8.0", + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/visitor-keys": "6.9.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -8195,12 +8195,12 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.8.0.tgz", - "integrity": "sha512-oqAnbA7c+pgOhW2OhGvxm0t1BULX5peQI/rLsNDpGM78EebV3C9IGbX5HNZabuZ6UQrYveCLjKo8Iy/lLlBkkg==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz", + "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==", "dev": true, "requires": { - "@typescript-eslint/types": "6.8.0", + "@typescript-eslint/types": "6.9.0", "eslint-visitor-keys": "^3.4.1" } } @@ -8217,41 +8217,41 @@ } }, "@typescript-eslint/type-utils": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.8.0.tgz", - "integrity": "sha512-RYOJdlkTJIXW7GSldUIHqc/Hkto8E+fZN96dMIFhuTJcQwdRoGN2rEWA8U6oXbLo0qufH7NPElUb+MceHtz54g==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.9.0.tgz", + "integrity": "sha512-XXeahmfbpuhVbhSOROIzJ+b13krFmgtc4GlEuu1WBT+RpyGPIA4Y/eGnXzjbDj5gZLzpAXO/sj+IF/x2GtTMjQ==", "dev": true, "requires": { - "@typescript-eslint/typescript-estree": "6.8.0", - "@typescript-eslint/utils": "6.8.0", + "@typescript-eslint/typescript-estree": "6.9.0", + "@typescript-eslint/utils": "6.9.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, "dependencies": { "@typescript-eslint/scope-manager": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.8.0.tgz", - "integrity": "sha512-xe0HNBVwCph7rak+ZHcFD6A+q50SMsFwcmfdjs9Kz4qDh5hWhaPhFjRs/SODEhroBI5Ruyvyz9LfwUJ624O40g==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz", + "integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==", "dev": true, "requires": { - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/visitor-keys": "6.8.0" + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/visitor-keys": "6.9.0" } }, "@typescript-eslint/types": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.8.0.tgz", - "integrity": "sha512-p5qOxSum7W3k+llc7owEStXlGmSl8FcGvhYt8Vjy7FqEnmkCVlM3P57XQEGj58oqaBWDQXbJDZxwUWMS/EAPNQ==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz", + "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.8.0.tgz", - "integrity": "sha512-ISgV0lQ8XgW+mvv5My/+iTUdRmGspducmQcDw5JxznasXNnZn3SKNrTRuMsEXv+V/O+Lw9AGcQCfVaOPCAk/Zg==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz", + "integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==", "dev": true, "requires": { - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/visitor-keys": "6.8.0", + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/visitor-keys": "6.9.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -8260,27 +8260,27 @@ } }, "@typescript-eslint/utils": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.8.0.tgz", - "integrity": "sha512-dKs1itdE2qFG4jr0dlYLQVppqTE+Itt7GmIf/vX6CSvsW+3ov8PbWauVKyyfNngokhIO9sKZeRGCUo1+N7U98Q==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.0.tgz", + "integrity": "sha512-5Wf+Jsqya7WcCO8me504FBigeQKVLAMPmUzYgDbWchINNh1KJbxCgVya3EQ2MjvJMVeXl3pofRmprqX6mfQkjQ==", "dev": true, "requires": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.8.0", - "@typescript-eslint/types": "6.8.0", - "@typescript-eslint/typescript-estree": "6.8.0", + "@typescript-eslint/scope-manager": "6.9.0", + "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/typescript-estree": "6.9.0", "semver": "^7.5.4" } }, "@typescript-eslint/visitor-keys": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.8.0.tgz", - "integrity": "sha512-oqAnbA7c+pgOhW2OhGvxm0t1BULX5peQI/rLsNDpGM78EebV3C9IGbX5HNZabuZ6UQrYveCLjKo8Iy/lLlBkkg==", + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz", + "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==", "dev": true, "requires": { - "@typescript-eslint/types": "6.8.0", + "@typescript-eslint/types": "6.9.0", "eslint-visitor-keys": "^3.4.1" } } diff --git a/package.json b/package.json index 0b681a93c4..07eee6775b 100644 --- a/package.json +++ b/package.json @@ -107,10 +107,10 @@ "@octokit/rest": "^20.0.2", "@types/debug": "^4.1.10", "@types/jest": "^29.5.6", - "@types/node": "^20.8.7", + "@types/node": "^20.8.8", "@types/uuid": "^9.0.6", - "@typescript-eslint/eslint-plugin": "^6.8.0", - "@typescript-eslint/parser": "^6.8.0", + "@typescript-eslint/eslint-plugin": "^6.9.0", + "@typescript-eslint/parser": "^6.9.0", "eslint": "^8.52.0", "eslint-plugin-jest": "^27.4.3", "jest": "^29.7.0", From 53dbfce7584cb3bc479fffdd22fe947d4da5dc8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Wed, 25 Oct 2023 12:05:11 +0200 Subject: [PATCH 49/73] [flatbuffers] Improve Node imports (#1193) - Add `node:` prefix to all built-in Node imports (replaces PR #1142). - Replace `uuid` package with built-in `crypto.randomUUID()`(replaces PR #1140). - Cosmetic changes in TS files: - Avoid unnecessary `const { createWorker } = mediasoup` in almost all tests. - Move all FBS related imports to the bottom. - Some formating fixes that bypassed our ESLint rules. --- node/src/Channel.ts | 9 ++-- node/src/DataConsumer.ts | 2 +- node/src/EnhancedEventEmitter.ts | 2 +- node/src/PipeTransport.ts | 4 +- node/src/Router.ts | 16 +++---- node/src/RtpStream.ts | 11 +++-- node/src/Transport.ts | 20 ++++---- node/src/Worker.ts | 12 ++--- node/src/index.ts | 3 +- node/src/ortc.ts | 4 +- node/src/tests/test-ActiveSpeakerObserver.ts | 4 +- node/src/tests/test-AudioLevelObserver.ts | 4 +- node/src/tests/test-Consumer.ts | 4 +- node/src/tests/test-DataConsumer.ts | 4 +- node/src/tests/test-DataProducer.ts | 4 +- node/src/tests/test-DirectTransport.ts | 4 +- node/src/tests/test-PipeTransport.ts | 6 +-- node/src/tests/test-PlainTransport.ts | 4 +- node/src/tests/test-Producer.ts | 4 +- node/src/tests/test-Router.ts | 12 ++--- node/src/tests/test-WebRtcServer.ts | 22 ++++----- node/src/tests/test-WebRtcTransport.ts | 4 +- node/src/tests/test-Worker.ts | 48 ++++++++++---------- node/src/tests/test-multiopus.ts | 4 +- node/src/tests/test-node-sctp.ts | 6 +-- node/src/utils.ts | 10 +++- npm-scripts.mjs | 10 ++-- package-lock.json | 33 +------------- package.json | 4 +- worker/scripts/package-lock.json | 7 +-- worker/scripts/package.json | 3 ++ 31 files changed, 118 insertions(+), 166 deletions(-) diff --git a/node/src/Channel.ts b/node/src/Channel.ts index 56944985c9..0a69f99916 100644 --- a/node/src/Channel.ts +++ b/node/src/Channel.ts @@ -1,5 +1,5 @@ -import * as os from 'os'; -import { Duplex } from 'stream'; +import * as os from 'node:os'; +import { Duplex } from 'node:stream'; import * as flatbuffers from 'flatbuffers'; import { Logger } from './Logger'; import { EnhancedEventEmitter } from './EnhancedEventEmitter'; @@ -10,7 +10,8 @@ import { Message, Type as MessageType, Body as MessageBody } from './fbs/message import { Notification, Body as NotificationBody, Event } from './fbs/notification'; import { Log } from './fbs/log'; -const littleEndian = os.endianness() == 'LE'; +const IS_LITTLE_ENDIAN = os.endianness() === 'LE'; + const logger = new Logger('Channel'); type Sent = @@ -110,7 +111,7 @@ export class Channel extends EnhancedEventEmitter const dataView = new DataView( this.#recvBuffer.buffer, this.#recvBuffer.byteOffset + msgStart); - const msgLen = dataView.getUint32(0, littleEndian); + const msgLen = dataView.getUint32(0, IS_LITTLE_ENDIAN); if (readLen < 4 + msgLen) { diff --git a/node/src/DataConsumer.ts b/node/src/DataConsumer.ts index 41c12e06d2..9d257ab7b5 100644 --- a/node/src/DataConsumer.ts +++ b/node/src/DataConsumer.ts @@ -4,12 +4,12 @@ import { Channel } from './Channel'; import { TransportInternal } from './Transport'; import { parseSctpStreamParameters, SctpStreamParameters } from './SctpParameters'; import { AppData } from './types'; +import * as utils from './utils'; import { Event, Notification } from './fbs/notification'; import * as FbsTransport from './fbs/transport'; import * as FbsRequest from './fbs/request'; import * as FbsDataConsumer from './fbs/data-consumer'; import * as FbsDataProducer from './fbs/data-producer'; -import * as utils from './utils'; export type DataConsumerOptions = { diff --git a/node/src/EnhancedEventEmitter.ts b/node/src/EnhancedEventEmitter.ts index b6b1dc0eab..f2e3a057d5 100644 --- a/node/src/EnhancedEventEmitter.ts +++ b/node/src/EnhancedEventEmitter.ts @@ -1,4 +1,4 @@ -import { EventEmitter } from 'events'; +import { EventEmitter } from 'node:events'; import { Logger } from './Logger'; const logger = new Logger('EnhancedEventEmitter'); diff --git a/node/src/PipeTransport.ts b/node/src/PipeTransport.ts index 6dfead6a0c..d0cd72d8cd 100644 --- a/node/src/PipeTransport.ts +++ b/node/src/PipeTransport.ts @@ -1,4 +1,3 @@ -import { v4 as uuidv4 } from 'uuid'; import * as flatbuffers from 'flatbuffers'; import { Logger } from './Logger'; import * as ortc from './ortc'; @@ -29,6 +28,7 @@ import { SrtpParameters } from './SrtpParameters'; import { AppData, Either } from './types'; +import { generateUUIDv4 } from './utils'; import { MediaKind as FbsMediaKind } from './fbs/rtp-parameters/media-kind'; import * as FbsRtpParameters from './fbs/rtp-parameters'; import { Event, Notification } from './fbs/notification'; @@ -368,7 +368,7 @@ export class PipeTransport } ); - const consumerId = uuidv4(); + const consumerId = generateUUIDv4(); const consumeRequestOffset = createConsumeRequest({ builder : this.channel.bufferBuilder, diff --git a/node/src/Router.ts b/node/src/Router.ts index a45bc5e0f6..839aa06d0e 100644 --- a/node/src/Router.ts +++ b/node/src/Router.ts @@ -1,4 +1,3 @@ -import { v4 as uuidv4 } from 'uuid'; import { Logger } from './Logger'; import { EnhancedEventEmitter } from './EnhancedEventEmitter'; import * as ortc from './ortc'; @@ -22,9 +21,10 @@ import { RtpObserver } from './RtpObserver'; import { ActiveSpeakerObserver, ActiveSpeakerObserverOptions } from './ActiveSpeakerObserver'; import { AudioLevelObserver, AudioLevelObserverOptions } from './AudioLevelObserver'; import { RtpCapabilities, RtpCodecCapability } from './RtpParameters'; +import { cryptoSuiteToFbs } from './SrtpParameters'; import { NumSctpStreams } from './SctpParameters'; import { AppData, Either } from './types'; -import { cryptoSuiteToFbs } from './SrtpParameters'; +import { generateUUIDv4 } from './utils'; import * as FbsActiveSpeakerObserver from './fbs/active-speaker-observer'; import * as FbsAudioLevelObserver from './fbs/audio-level-observer'; import * as FbsRequest from './fbs/request'; @@ -507,7 +507,7 @@ export class Router } } - const transportId = uuidv4(); + const transportId = generateUUIDv4(); /* Build Request. */ let webRtcTransportListenServer: @@ -689,7 +689,7 @@ export class Router }; } - const transportId = uuidv4(); + const transportId = generateUUIDv4(); /* Build Request. */ const baseTransportOptions = new FbsTransport.OptionsT( @@ -837,7 +837,7 @@ export class Router }; } - const transportId = uuidv4(); + const transportId = generateUUIDv4(); /* Build Request. */ const baseTransportOptions = new FbsTransport.OptionsT( @@ -946,7 +946,7 @@ export class Router throw new TypeError('if given, appData must be an object'); } - const transportId = uuidv4(); + const transportId = generateUUIDv4(); /* Build Request. */ const baseTransportOptions = new FbsTransport.OptionsT( @@ -1404,7 +1404,7 @@ export class Router throw new TypeError('if given, appData must be an object'); } - const rtpObserverId = uuidv4(); + const rtpObserverId = generateUUIDv4(); /* Build Request. */ const activeRtpObserverOptions = @@ -1482,7 +1482,7 @@ export class Router throw new TypeError('if given, appData must be an object'); } - const rtpObserverId = uuidv4(); + const rtpObserverId = generateUUIDv4(); /* Build Request. */ const audioLevelObserverOptions = diff --git a/node/src/RtpStream.ts b/node/src/RtpStream.ts index aa986cd46c..ad863b19c2 100644 --- a/node/src/RtpStream.ts +++ b/node/src/RtpStream.ts @@ -1,7 +1,8 @@ import * as FbsRtpStream from './fbs/rtp-stream'; import * as FbsRtpParameters from './fbs/rtp-parameters'; -export type RtpStreamRecvStats = BaseRtpStreamStats & { +export type RtpStreamRecvStats = BaseRtpStreamStats & +{ type: string; jitter: number; packetCount: number; @@ -10,14 +11,16 @@ export type RtpStreamRecvStats = BaseRtpStreamStats & { bitrateByLayer?: any; }; -export type RtpStreamSendStats = BaseRtpStreamStats & { +export type RtpStreamSendStats = BaseRtpStreamStats & +{ type: string; packetCount: number; byteCount: number; bitrate: number; }; -type BaseRtpStreamStats = { +type BaseRtpStreamStats = +{ timestamp: number; ssrc: number; rtxSsrc?: number; @@ -128,7 +131,7 @@ function parseBitrateByLayer(binary: FbsRtpStream.RecvStats): any const bitRateByLayer: {[key: string]: number} = {}; - for (let i=0; i < binary.bitrateByLayerLength(); ++i) + for (let i = 0; i < binary.bitrateByLayerLength(); ++i) { const layer: string = binary.bitrateByLayer(i)!.layer()!; const bitrate = binary.bitrateByLayer(i)!.bitrate(); diff --git a/node/src/Transport.ts b/node/src/Transport.ts index 0526df7b88..586a5c600c 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -1,8 +1,6 @@ -import { v4 as uuidv4 } from 'uuid'; import * as flatbuffers from 'flatbuffers'; import { Logger } from './Logger'; import { EnhancedEventEmitter } from './EnhancedEventEmitter'; -import * as utils from './utils'; import * as ortc from './ortc'; import { Channel } from './Channel'; import { RouterInternal } from './Router'; @@ -40,6 +38,7 @@ import { SctpStreamParameters } from './SctpParameters'; import { AppData } from './types'; +import * as utils from './utils'; import { TraceDirection as FbsTraceDirection } from './fbs/common'; import * as FbsRequest from './fbs/request'; import { MediaKind as FbsMediaKind } from './fbs/rtp-parameters/media-kind'; @@ -251,7 +250,8 @@ type SctpListenerDump = streamIdTable : {key: number; value: string}[]; }; -type RecvRtpHeaderExtensions = { +type RecvRtpHeaderExtensions = +{ mid?: number; rid?: number; rrid?: number; @@ -736,11 +736,11 @@ export class Transport { this.#cnameForProducers = rtpParameters.rtcp.cname; } - // Otherwise if we don't have yet a CNAME for Producers and the RTP parameters - // do not include CNAME, create a random one. + // Otherwise if we don't have yet a CNAME for Producers and the RTP + // parameters do not include CNAME, create a random one. else if (!this.#cnameForProducers) { - this.#cnameForProducers = uuidv4().substr(0, 8); + this.#cnameForProducers = utils.generateUUIDv4().substr(0, 8); } // Override Producer's CNAME. @@ -758,7 +758,7 @@ export class Transport const consumableRtpParameters = ortc.getConsumableRtpParameters( kind, rtpParameters, routerRtpCapabilities, rtpMapping); - const producerId = id || uuidv4(); + const producerId = id || utils.generateUUIDv4(); const requestOffset = createProduceRequest({ builder : this.channel.bufferBuilder, producerId, @@ -901,7 +901,7 @@ export class Transport } } - const consumerId = uuidv4(); + const consumerId = utils.generateUUIDv4(); const requestOffset = createConsumeRequest({ builder : this.channel.bufferBuilder, producer, @@ -1015,7 +1015,7 @@ export class Transport } } - const dataProducerId = id || uuidv4(); + const dataProducerId = id || utils.generateUUIDv4(); const requestOffset = createProduceDataRequest({ builder : this.channel.bufferBuilder, dataProducerId, @@ -1158,7 +1158,7 @@ export class Transport } const { label, protocol } = dataProducer; - const dataConsumerId = uuidv4(); + const dataConsumerId = utils.generateUUIDv4(); const requestOffset = createConsumeDataRequest({ builder : this.channel.bufferBuilder, diff --git a/node/src/Worker.ts b/node/src/Worker.ts index 349fb9a054..3c8ff24edb 100644 --- a/node/src/Worker.ts +++ b/node/src/Worker.ts @@ -1,7 +1,6 @@ -import * as process from 'process'; -import * as path from 'path'; -import { spawn, ChildProcess } from 'child_process'; -import { v4 as uuidv4 } from 'uuid'; +import * as process from 'node:process'; +import * as path from 'node:path'; +import { spawn, ChildProcess } from 'node:child_process'; import { Logger } from './Logger'; import { EnhancedEventEmitter } from './EnhancedEventEmitter'; import * as ortc from './ortc'; @@ -9,6 +8,7 @@ import { Channel } from './Channel'; import { Router, RouterOptions } from './Router'; import { WebRtcServer, WebRtcServerOptions } from './WebRtcServer'; import { AppData } from './types'; +import { generateUUIDv4 } from './utils'; import { Event } from './fbs/notification'; import * as FbsRequest from './fbs/request'; import * as FbsWorker from './fbs/worker'; @@ -695,7 +695,7 @@ export class Worker ); } - const webRtcServerId = uuidv4(); + const webRtcServerId = generateUUIDv4(); const createWebRtcServerRequestOffset = new FbsWorker.CreateWebRtcServerRequestT( webRtcServerId, fbsListenInfos @@ -742,7 +742,7 @@ export class Worker // This may throw. const rtpCapabilities = ortc.generateRouterRtpCapabilities(mediaCodecs); - const routerId = uuidv4(); + const routerId = generateUUIDv4(); // Get flatbuffer builder. const createRouterRequestOffset = diff --git a/node/src/index.ts b/node/src/index.ts index 06f30f7008..c0cf76ba4d 100644 --- a/node/src/index.ts +++ b/node/src/index.ts @@ -5,7 +5,6 @@ import * as utils from './utils'; import { supportedRtpCapabilities } from './supportedRtpCapabilities'; import { RtpCapabilities } from './RtpParameters'; import * as types from './types'; -import { AppData } from './types'; /** * Expose all types. @@ -44,7 +43,7 @@ export { workerBin }; /** * Create a Worker. */ -export async function createWorker( +export async function createWorker( { logLevel = 'error', logTags, diff --git a/node/src/ortc.ts b/node/src/ortc.ts index ee0ef59324..ba8d5f772a 100644 --- a/node/src/ortc.ts +++ b/node/src/ortc.ts @@ -1,7 +1,5 @@ import * as h264 from 'h264-profile-level-id'; import * as flatbuffers from 'flatbuffers'; -import * as utils from './utils'; -import { UnsupportedError } from './errors'; import { supportedRtpCapabilities } from './supportedRtpCapabilities'; import { parse as parseScalabilityMode } from './scalabilityModes'; import { @@ -22,6 +20,8 @@ import { SctpParameters, SctpStreamParameters } from './SctpParameters'; +import * as utils from './utils'; +import { UnsupportedError } from './errors'; import * as FbsRtpParameters from './fbs/rtp-parameters'; export type RtpMapping = diff --git a/node/src/tests/test-ActiveSpeakerObserver.ts b/node/src/tests/test-ActiveSpeakerObserver.ts index 248b8bf0d5..4da61e1753 100644 --- a/node/src/tests/test-ActiveSpeakerObserver.ts +++ b/node/src/tests/test-ActiveSpeakerObserver.ts @@ -1,7 +1,5 @@ import * as mediasoup from '../'; -const { createWorker } = mediasoup; - let worker: mediasoup.types.Worker; let router: mediasoup.types.Router; let activeSpeakerObserver: mediasoup.types.ActiveSpeakerObserver; @@ -23,7 +21,7 @@ const mediaCodecs: mediasoup.types.RtpCodecCapability[] = beforeAll(async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); router = await worker.createRouter({ mediaCodecs }); }); diff --git a/node/src/tests/test-AudioLevelObserver.ts b/node/src/tests/test-AudioLevelObserver.ts index e82be0c7dd..77487218b8 100644 --- a/node/src/tests/test-AudioLevelObserver.ts +++ b/node/src/tests/test-AudioLevelObserver.ts @@ -1,7 +1,5 @@ import * as mediasoup from '../'; -const { createWorker } = mediasoup; - let worker: mediasoup.types.Worker; let router: mediasoup.types.Router; let audioLevelObserver: mediasoup.types.AudioLevelObserver; @@ -23,7 +21,7 @@ const mediaCodecs: mediasoup.types.RtpCodecCapability[] = beforeAll(async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); router = await worker.createRouter({ mediaCodecs }); }); diff --git a/node/src/tests/test-Consumer.ts b/node/src/tests/test-Consumer.ts index bc443382bc..642db30836 100644 --- a/node/src/tests/test-Consumer.ts +++ b/node/src/tests/test-Consumer.ts @@ -4,8 +4,6 @@ import { UnsupportedError } from '../errors'; import { Notification, Body as NotificationBody, Event } from '../fbs/notification'; import * as FbsConsumer from '../fbs/consumer'; -const { createWorker } = mediasoup; - let worker: mediasoup.types.Worker; let router: mediasoup.types.Router; let transport1: mediasoup.types.WebRtcTransport; @@ -247,7 +245,7 @@ const consumerDeviceCapabilities: mediasoup.types.RtpCapabilities = beforeAll(async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); router = await worker.createRouter({ mediaCodecs }); transport1 = await router.createWebRtcTransport( { diff --git a/node/src/tests/test-DataConsumer.ts b/node/src/tests/test-DataConsumer.ts index 7f13b1aab8..b8a7181ed1 100644 --- a/node/src/tests/test-DataConsumer.ts +++ b/node/src/tests/test-DataConsumer.ts @@ -1,7 +1,5 @@ import * as mediasoup from '../'; -const { createWorker } = mediasoup; - let worker: mediasoup.types.Worker; let router: mediasoup.types.Router; let transport1: mediasoup.types.WebRtcTransport; @@ -25,7 +23,7 @@ const dataProducerParameters: mediasoup.types.DataProducerOptions = beforeAll(async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); router = await worker.createRouter(); transport1 = await router.createWebRtcTransport( { diff --git a/node/src/tests/test-DataProducer.ts b/node/src/tests/test-DataProducer.ts index fecdca315d..3918d20263 100644 --- a/node/src/tests/test-DataProducer.ts +++ b/node/src/tests/test-DataProducer.ts @@ -1,7 +1,5 @@ import * as mediasoup from '../'; -const { createWorker } = mediasoup; - let worker: mediasoup.types.Worker; let router: mediasoup.types.Router; let transport1: mediasoup.types.WebRtcTransport; @@ -11,7 +9,7 @@ let dataProducer2: mediasoup.types.DataProducer; beforeAll(async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); router = await worker.createRouter(); transport1 = await router.createWebRtcTransport( { diff --git a/node/src/tests/test-DirectTransport.ts b/node/src/tests/test-DirectTransport.ts index eadb37a0e8..2a8431ddc3 100644 --- a/node/src/tests/test-DirectTransport.ts +++ b/node/src/tests/test-DirectTransport.ts @@ -1,14 +1,12 @@ import * as mediasoup from '../'; -const { createWorker } = mediasoup; - let worker: mediasoup.types.Worker; let router: mediasoup.types.Router; let transport: mediasoup.types.DirectTransport; beforeAll(async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); router = await worker.createRouter(); }); diff --git a/node/src/tests/test-PipeTransport.ts b/node/src/tests/test-PipeTransport.ts index 6686e6a5e6..af8dc9d06a 100644 --- a/node/src/tests/test-PipeTransport.ts +++ b/node/src/tests/test-PipeTransport.ts @@ -2,8 +2,6 @@ import * as pickPort from 'pick-port'; import * as mediasoup from '../'; -const { createWorker } = mediasoup; - let worker1: mediasoup.types.Worker; let worker2: mediasoup.types.Worker; let router1: mediasoup.types.Router; @@ -190,8 +188,8 @@ const consumerDeviceCapabilities: mediasoup.types.RtpCapabilities = beforeAll(async () => { - worker1 = await createWorker(); - worker2 = await createWorker(); + worker1 = await mediasoup.createWorker(); + worker2 = await mediasoup.createWorker(); router1 = await worker1.createRouter({ mediaCodecs }); router2 = await worker2.createRouter({ mediaCodecs }); transport1 = await router1.createWebRtcTransport( diff --git a/node/src/tests/test-PlainTransport.ts b/node/src/tests/test-PlainTransport.ts index a90badc801..3e75c50586 100644 --- a/node/src/tests/test-PlainTransport.ts +++ b/node/src/tests/test-PlainTransport.ts @@ -2,8 +2,6 @@ import * as pickPort from 'pick-port'; import * as mediasoup from '../'; -const { createWorker } = mediasoup; - let worker: mediasoup.types.Worker; let router: mediasoup.types.Router; let transport: mediasoup.types.PlainTransport; @@ -43,7 +41,7 @@ const mediaCodecs: mediasoup.types.RtpCodecCapability[] = beforeAll(async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); router = await worker.createRouter({ mediaCodecs }); }); diff --git a/node/src/tests/test-Producer.ts b/node/src/tests/test-Producer.ts index 3784d154b1..603e14281c 100644 --- a/node/src/tests/test-Producer.ts +++ b/node/src/tests/test-Producer.ts @@ -4,8 +4,6 @@ import { UnsupportedError } from '../errors'; import { Notification, Body as NotificationBody, Event } from '../fbs/notification'; import * as FbsProducer from '../fbs/producer'; -const { createWorker } = mediasoup; - let worker: mediasoup.types.Worker; let router: mediasoup.types.Router; let transport1: mediasoup.types.WebRtcTransport; @@ -47,7 +45,7 @@ const mediaCodecs: mediasoup.types.RtpCodecCapability[] = beforeAll(async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); router = await worker.createRouter({ mediaCodecs }); transport1 = await router.createWebRtcTransport( { diff --git a/node/src/tests/test-Router.ts b/node/src/tests/test-Router.ts index e133efbf68..d639115d57 100644 --- a/node/src/tests/test-Router.ts +++ b/node/src/tests/test-Router.ts @@ -1,8 +1,6 @@ import * as mediasoup from '../'; import { InvalidStateError } from '../errors'; -const { createWorker } = mediasoup; - let worker: mediasoup.types.Worker; beforeEach(() => worker && !worker.closed && worker.close()); @@ -42,7 +40,7 @@ const mediaCodecs: mediasoup.types.RtpCodecCapability[] = test('worker.createRouter() succeeds', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); const onObserverNewRouter = jest.fn(); @@ -106,7 +104,7 @@ test('worker.createRouter() succeeds', async () => test('worker.createRouter() with wrong arguments rejects with TypeError', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); // @ts-ignore await expect(worker.createRouter({ mediaCodecs: {} })) @@ -123,7 +121,7 @@ test('worker.createRouter() with wrong arguments rejects with TypeError', async test('worker.createRouter() rejects with InvalidStateError if Worker is closed', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); worker.close(); @@ -134,7 +132,7 @@ test('worker.createRouter() rejects with InvalidStateError if Worker is closed', test('router.close() succeeds', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); const router = await worker.createRouter({ mediaCodecs }); const onObserverClose = jest.fn(); @@ -148,7 +146,7 @@ test('router.close() succeeds', async () => test('Router emits "workerclose" if Worker is closed', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); const router = await worker.createRouter({ mediaCodecs }); const onObserverClose = jest.fn(); diff --git a/node/src/tests/test-WebRtcServer.ts b/node/src/tests/test-WebRtcServer.ts index 796c923d5b..db5a6b2f2f 100644 --- a/node/src/tests/test-WebRtcServer.ts +++ b/node/src/tests/test-WebRtcServer.ts @@ -3,8 +3,6 @@ import * as pickPort from 'pick-port'; import * as mediasoup from '../'; import { InvalidStateError } from '../errors'; -const { createWorker } = mediasoup; - let worker: mediasoup.types.Worker; beforeEach(() => worker && !worker.closed && worker.close()); @@ -12,7 +10,7 @@ afterEach(() => worker && !worker.closed && worker.close()); test('worker.createWebRtcServer() succeeds', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); const onObserverNewWebRtcServer = jest.fn(); @@ -91,7 +89,7 @@ test('worker.createWebRtcServer() succeeds', async () => test('worker.createWebRtcServer() without specifying port succeeds', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); const onObserverNewWebRtcServer = jest.fn(); @@ -165,7 +163,7 @@ test('worker.createWebRtcServer() without specifying port succeeds', async () => test('worker.createWebRtcServer() with wrong arguments rejects with TypeError', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); // @ts-ignore await expect(worker.createWebRtcServer({})) @@ -192,8 +190,8 @@ test('worker.createWebRtcServer() with wrong arguments rejects with TypeError', test('worker.createWebRtcServer() with unavailable listenInfos rejects with Error', async () => { - const worker1 = await createWorker(); - const worker2 = await createWorker(); + const worker1 = await mediasoup.createWorker(); + const worker2 = await mediasoup.createWorker(); const port1 = await pickPort({ ip: '127.0.0.1', reserveTimeout: 0 }); const port2 = await pickPort({ ip: '127.0.0.1', reserveTimeout: 0 }); @@ -271,7 +269,7 @@ test('worker.createWebRtcServer() with unavailable listenInfos rejects with Erro test('worker.createWebRtcServer() rejects with InvalidStateError if Worker is closed', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); worker.close(); @@ -287,7 +285,7 @@ test('worker.createWebRtcServer() rejects with InvalidStateError if Worker is cl test('webRtcServer.close() succeeds', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); const port = await pickPort({ ip: '127.0.0.1', reserveTimeout: 0 }); const webRtcServer = await worker.createWebRtcServer( @@ -305,7 +303,7 @@ test('webRtcServer.close() succeeds', async () => test('WebRtcServer emits "workerclose" if Worker is closed', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); const port = await pickPort({ ip: '127.0.0.1', reserveTimeout: 0 }); const webRtcServer = await worker.createWebRtcServer( @@ -328,7 +326,7 @@ test('WebRtcServer emits "workerclose" if Worker is closed', async () => test('router.createWebRtcTransport() with webRtcServer succeeds and transport is closed', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); const port1 = await pickPort({ ip: '127.0.0.1', reserveTimeout: 0 }); const port2 = await pickPort({ type: 'tcp', ip: '127.0.0.1', reserveTimeout: 0 }); @@ -438,7 +436,7 @@ test('router.createWebRtcTransport() with webRtcServer succeeds and transport is test('router.createWebRtcTransport() with webRtcServer succeeds and webRtcServer is closed', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); const port1 = await pickPort({ ip: '127.0.0.1', reserveTimeout: 0 }); const port2 = await pickPort({ type: 'tcp', ip: '127.0.0.1', reserveTimeout: 0 }); diff --git a/node/src/tests/test-WebRtcTransport.ts b/node/src/tests/test-WebRtcTransport.ts index 91987cccfe..7bb950eb08 100644 --- a/node/src/tests/test-WebRtcTransport.ts +++ b/node/src/tests/test-WebRtcTransport.ts @@ -7,8 +7,6 @@ import * as FbsTransport from '../fbs/transport'; import * as FbsWebRtcTransport from '../fbs/web-rtc-transport'; import { serializeProtocol, TransportTuple } from '../Transport'; -const { createWorker } = mediasoup; - let worker: mediasoup.types.Worker; let router: mediasoup.types.Router; let transport: mediasoup.types.WebRtcTransport; @@ -47,7 +45,7 @@ const mediaCodecs: mediasoup.types.RtpCodecCapability[] = beforeAll(async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); router = await worker.createRouter({ mediaCodecs }); }); diff --git a/node/src/tests/test-Worker.ts b/node/src/tests/test-Worker.ts index 449098ee85..65dd889f18 100644 --- a/node/src/tests/test-Worker.ts +++ b/node/src/tests/test-Worker.ts @@ -1,11 +1,9 @@ -import * as os from 'os'; -import * as process from 'process'; -import * as path from 'path'; +import * as os from 'node:os'; +import * as process from 'node:process'; +import * as path from 'node:path'; import * as mediasoup from '../'; import { InvalidStateError } from '../errors'; -const { createWorker, observer } = mediasoup; - let worker: mediasoup.types.Worker; beforeEach(() => worker && !worker.closed && worker.close()); @@ -26,9 +24,9 @@ test('createWorker() succeeds', async () => { const onObserverNewWorker = jest.fn(); - observer.once('newworker', onObserverNewWorker); + mediasoup.observer.once('newworker', onObserverNewWorker); - worker = await createWorker(); + worker = await mediasoup.createWorker(); expect(onObserverNewWorker).toHaveBeenCalledTimes(1); expect(onObserverNewWorker).toHaveBeenCalledWith(worker); @@ -43,7 +41,7 @@ test('createWorker() succeeds', async () => expect(worker.died).toBe(false); // eslint-disable-next-line require-atomic-updates - worker = await createWorker<{ foo: number; bar?: string }>( + worker = await mediasoup.createWorker<{ foo: number; bar?: string }>( { logLevel : 'debug', logTags : [ 'info' ], @@ -69,36 +67,36 @@ test('createWorker() succeeds', async () => test('createWorker() with wrong settings rejects with TypeError', async () => { // @ts-ignore - await expect(createWorker({ logLevel: 'chicken' })) + await expect(mediasoup.createWorker({ logLevel: 'chicken' })) .rejects .toThrow(TypeError); - await expect(createWorker({ rtcMinPort: 1000, rtcMaxPort: 999 })) + await expect(mediasoup.createWorker({ rtcMinPort: 1000, rtcMaxPort: 999 })) .rejects .toThrow(TypeError); // Port is from 0 to 65535. - await expect(createWorker({ rtcMinPort: 1000, rtcMaxPort: 65536 })) + await expect(mediasoup.createWorker({ rtcMinPort: 1000, rtcMaxPort: 65536 })) .rejects .toThrow(TypeError); - await expect(createWorker({ dtlsCertificateFile: '/notfound/cert.pem' })) + await expect(mediasoup.createWorker({ dtlsCertificateFile: '/notfound/cert.pem' })) .rejects .toThrow(TypeError); - await expect(createWorker({ dtlsPrivateKeyFile: '/notfound/priv.pem' })) + await expect(mediasoup.createWorker({ dtlsPrivateKeyFile: '/notfound/priv.pem' })) .rejects .toThrow(TypeError); // @ts-ignore - await expect(createWorker({ appData: 'NOT-AN-OBJECT' })) + await expect(mediasoup.createWorker({ appData: 'NOT-AN-OBJECT' })) .rejects .toThrow(TypeError); }, 2000); test('worker.updateSettings() succeeds', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); await expect(worker.updateSettings({ logLevel: 'debug', logTags: [ 'ice' ] })) .resolves @@ -109,7 +107,7 @@ test('worker.updateSettings() succeeds', async () => test('worker.updateSettings() with wrong settings rejects with TypeError', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); // @ts-ignore await expect(worker.updateSettings({ logLevel: 'chicken' })) @@ -121,7 +119,7 @@ test('worker.updateSettings() with wrong settings rejects with TypeError', async test('worker.updateSettings() rejects with InvalidStateError if closed', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); worker.close(); await expect(worker.updateSettings({ logLevel: 'error' })) @@ -133,7 +131,7 @@ test('worker.updateSettings() rejects with InvalidStateError if closed', async ( test('worker.dump() succeeds', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); await expect(worker.dump()) .resolves @@ -154,7 +152,7 @@ test('worker.dump() succeeds', async () => test('worker.dump() rejects with InvalidStateError if closed', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); worker.close(); await expect(worker.dump()) @@ -166,7 +164,7 @@ test('worker.dump() rejects with InvalidStateError if closed', async () => test('worker.getResourceUsage() succeeds', async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); await expect(worker.getResourceUsage()) .resolves @@ -177,7 +175,7 @@ test('worker.getResourceUsage() succeeds', async () => test('worker.close() succeeds', async () => { - worker = await createWorker({ logLevel: 'warn' }); + worker = await mediasoup.createWorker({ logLevel: 'warn' }); const onObserverClose = jest.fn(); @@ -194,7 +192,7 @@ test('Worker emits "died" if worker process died unexpectedly', async () => let onDied: ReturnType; let onObserverClose: ReturnType; - worker = await createWorker({ logLevel: 'warn' }); + worker = await mediasoup.createWorker({ logLevel: 'warn' }); onDied = jest.fn(); onObserverClose = jest.fn(); @@ -230,7 +228,7 @@ test('Worker emits "died" if worker process died unexpectedly', async () => expect(worker.died).toBe(true); // eslint-disable-next-line require-atomic-updates - worker = await createWorker({ logLevel: 'warn' }); + worker = await mediasoup.createWorker({ logLevel: 'warn' }); onDied = jest.fn(); onObserverClose = jest.fn(); @@ -266,7 +264,7 @@ test('Worker emits "died" if worker process died unexpectedly', async () => expect(worker.died).toBe(true); // eslint-disable-next-line require-atomic-updates - worker = await createWorker({ logLevel: 'warn' }); + worker = await mediasoup.createWorker({ logLevel: 'warn' }); onDied = jest.fn(); onObserverClose = jest.fn(); @@ -311,7 +309,7 @@ test('worker process ignores PIPE, HUP, ALRM, USR1 and USR2 signals', async () = return; } - worker = await createWorker({ logLevel: 'warn' }); + worker = await mediasoup.createWorker({ logLevel: 'warn' }); await new Promise((resolve, reject) => { diff --git a/node/src/tests/test-multiopus.ts b/node/src/tests/test-multiopus.ts index b1e3a260ed..0cb4991239 100644 --- a/node/src/tests/test-multiopus.ts +++ b/node/src/tests/test-multiopus.ts @@ -1,8 +1,6 @@ import * as mediasoup from '../'; import { UnsupportedError } from '../errors'; -const { createWorker } = mediasoup; - let worker: mediasoup.types.Worker; let router: mediasoup.types.Router; let transport: mediasoup.types.WebRtcTransport; @@ -103,7 +101,7 @@ const consumerDeviceCapabilities: mediasoup.types.RtpCapabilities = beforeAll(async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); router = await worker.createRouter({ mediaCodecs }); transport = await router.createWebRtcTransport( { diff --git a/node/src/tests/test-node-sctp.ts b/node/src/tests/test-node-sctp.ts index ae58c95ea7..8354a2fbf8 100644 --- a/node/src/tests/test-node-sctp.ts +++ b/node/src/tests/test-node-sctp.ts @@ -1,10 +1,8 @@ -import * as dgram from 'dgram'; +import * as dgram from 'node:dgram'; // @ts-ignore import * as sctp from 'sctp'; import * as mediasoup from '../'; -const { createWorker } = mediasoup; - // Set node-sctp default PMTU to 1200. sctp.defaults({ PMTU: 1200 }); @@ -20,7 +18,7 @@ let sctpSendStream: any; beforeAll(async () => { - worker = await createWorker(); + worker = await mediasoup.createWorker(); router = await worker.createRouter(); transport = await router.createPlainTransport( { diff --git a/node/src/utils.ts b/node/src/utils.ts index b24713e833..72c736e03d 100644 --- a/node/src/utils.ts +++ b/node/src/utils.ts @@ -1,4 +1,4 @@ -import { randomInt } from 'crypto'; +import { randomUUID, randomInt } from 'node:crypto'; import { ProducerType } from './Producer'; import { Type as FbsRtpParametersType } from './fbs/rtp-parameters'; @@ -26,6 +26,14 @@ export function clone(value: T): T } } +/** + * Generates a random UUID v4. + */ +export function generateUUIDv4(): string +{ + return randomUUID(); +} + /** * Generates a random positive integer. */ diff --git a/npm-scripts.mjs b/npm-scripts.mjs index a12f1e6a41..2a32a16886 100644 --- a/npm-scripts.mjs +++ b/npm-scripts.mjs @@ -1,8 +1,8 @@ -import process from 'process'; -import os from 'os'; -import fs from 'fs'; -import path from 'path'; -import { execSync, spawnSync } from 'child_process'; +import process from 'node:process'; +import os from 'node:os'; +import fs from 'node:fs'; +import path from 'node:path'; +import { execSync, spawnSync } from 'node:child_process'; import fetch from 'node-fetch'; import tar from 'tar'; diff --git a/package-lock.json b/package-lock.json index b6425743f4..dbf6d506f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,15 +15,13 @@ "h264-profile-level-id": "^1.0.1", "node-fetch": "^3.3.2", "supports-color": "^9.4.0", - "tar": "^6.2.0", - "uuid": "^9.0.1" + "tar": "^6.2.0" }, "devDependencies": { "@octokit/rest": "^20.0.2", "@types/debug": "^4.1.10", "@types/jest": "^29.5.6", "@types/node": "^20.8.8", - "@types/uuid": "^9.0.6", "@typescript-eslint/eslint-plugin": "^6.9.0", "@typescript-eslint/parser": "^6.9.0", "eslint": "^8.52.0", @@ -1647,12 +1645,6 @@ "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", "dev": true }, - "node_modules/@types/uuid": { - "version": "9.0.6", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.6.tgz", - "integrity": "sha512-BT2Krtx4xaO6iwzwMFUYvWBWkV2pr37zD68Vmp1CDV196MzczBRxuEpD6Pr395HAgebC/co7hOphs53r8V7jew==", - "dev": true - }, "node_modules/@types/yargs": { "version": "17.0.13", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.13.tgz", @@ -6555,18 +6547,6 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true }, - "node_modules/uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/v8-to-istanbul": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz", @@ -8052,12 +8032,6 @@ "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", "dev": true }, - "@types/uuid": { - "version": "9.0.6", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.6.tgz", - "integrity": "sha512-BT2Krtx4xaO6iwzwMFUYvWBWkV2pr37zD68Vmp1CDV196MzczBRxuEpD6Pr395HAgebC/co7hOphs53r8V7jew==", - "dev": true - }, "@types/yargs": { "version": "17.0.13", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.13.tgz", @@ -11446,11 +11420,6 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true }, - "uuid": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", - "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==" - }, "v8-to-istanbul": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz", diff --git a/package.json b/package.json index 07eee6775b..194fd8316d 100644 --- a/package.json +++ b/package.json @@ -100,15 +100,13 @@ "h264-profile-level-id": "^1.0.1", "node-fetch": "^3.3.2", "supports-color": "^9.4.0", - "tar": "^6.2.0", - "uuid": "^9.0.1" + "tar": "^6.2.0" }, "devDependencies": { "@octokit/rest": "^20.0.2", "@types/debug": "^4.1.10", "@types/jest": "^29.5.6", "@types/node": "^20.8.8", - "@types/uuid": "^9.0.6", "@typescript-eslint/eslint-plugin": "^6.9.0", "@typescript-eslint/parser": "^6.9.0", "eslint": "^8.52.0", diff --git a/worker/scripts/package-lock.json b/worker/scripts/package-lock.json index 6d187c60d3..67dcc5cdc0 100644 --- a/worker/scripts/package-lock.json +++ b/worker/scripts/package-lock.json @@ -11,6 +11,9 @@ "clang-tools-prebuilt": "^0.1.4", "gulp": "^4.0.2", "gulp-clang-format": "^1.0.27" + }, + "peerDependencies": { + "uuid": "^3.3.2" } }, "node_modules/ajv": { @@ -5123,7 +5126,6 @@ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", - "dev": true, "bin": { "uuid": "bin/uuid" } @@ -9644,8 +9646,7 @@ "uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "dev": true + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" }, "v8flags": { "version": "3.2.0", diff --git a/worker/scripts/package.json b/worker/scripts/package.json index c6d17b7639..24b90f7874 100644 --- a/worker/scripts/package.json +++ b/worker/scripts/package.json @@ -6,5 +6,8 @@ "clang-tools-prebuilt": "^0.1.4", "gulp": "^4.0.2", "gulp-clang-format": "^1.0.27" + }, + "peerDependencies": { + "uuid": "^3.3.2" } } From 2b6c5ee97cf2193de696ceae3104fd9e19d17343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Wed, 25 Oct 2023 12:07:00 +0200 Subject: [PATCH 50/73] Add Node 16 in CI workflows/mediasoup-node.yaml (since we do support Node 16) --- .github/workflows/mediasoup-node.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/mediasoup-node.yaml b/.github/workflows/mediasoup-node.yaml index 401e8def2a..da27b8514e 100644 --- a/.github/workflows/mediasoup-node.yaml +++ b/.github/workflows/mediasoup-node.yaml @@ -13,6 +13,8 @@ jobs: strategy: matrix: ci: + - os: ubuntu-20.04 + node: 16 - os: ubuntu-20.04 node: 18 - os: ubuntu-22.04 From 5c0e5052dbf6ab99500a54fa11a766396f841386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Wed, 25 Oct 2023 12:13:34 +0200 Subject: [PATCH 51/73] Rust: add bench for producer creation/dump (#1192) Rust: add bench for producer creation/dump --- rust/Cargo.toml | 3 + rust/benches/producer.rs | 166 +++++++++++++++++++++++++++++++++++++++ rust/src/prelude.rs | 5 +- 3 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 rust/benches/producer.rs diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 1760125b11..f884cf9dad 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -81,3 +81,6 @@ version = "4.2.1" [[bench]] name = "direct_data" harness = false +[[bench]] +name = "producer" +harness = false diff --git a/rust/benches/producer.rs b/rust/benches/producer.rs new file mode 100644 index 0000000000..18493d9c93 --- /dev/null +++ b/rust/benches/producer.rs @@ -0,0 +1,166 @@ +use criterion::{criterion_group, criterion_main, Criterion}; +use mediasoup::prelude::*; +use std::env; +use std::net::{IpAddr, Ipv4Addr}; +use std::num::{NonZeroU32, NonZeroU8}; + +fn media_codecs() -> Vec { + vec![ + RtpCodecCapability::Audio { + mime_type: MimeTypeAudio::Opus, + preferred_payload_type: None, + clock_rate: NonZeroU32::new(48000).unwrap(), + channels: NonZeroU8::new(2).unwrap(), + parameters: RtpCodecParametersParameters::from([("foo", "111".into())]), + rtcp_feedback: vec![], + }, + RtpCodecCapability::Video { + mime_type: MimeTypeVideo::Vp8, + preferred_payload_type: None, + clock_rate: NonZeroU32::new(90000).unwrap(), + parameters: RtpCodecParametersParameters::default(), + rtcp_feedback: vec![], + }, + RtpCodecCapability::Video { + mime_type: MimeTypeVideo::H264, + preferred_payload_type: None, + clock_rate: NonZeroU32::new(90000).unwrap(), + parameters: RtpCodecParametersParameters::from([ + ("level-asymmetry-allowed", 1_u32.into()), + ("packetization-mode", 1_u32.into()), + ("profile-level-id", "4d0032".into()), + ("foo", "bar".into()), + ]), + rtcp_feedback: vec![], + }, + ] +} + +async fn init() -> (Worker, Router, WebRtcTransport, WebRtcTransport) { + { + let mut builder = env_logger::builder(); + if env::var(env_logger::DEFAULT_FILTER_ENV).is_err() { + builder.filter_level(log::LevelFilter::Off); + } + let _ = builder.is_test(true).try_init(); + } + + let worker_manager = WorkerManager::new(); + + let worker = worker_manager + .create_worker(WorkerSettings::default()) + .await + .expect("Failed to create worker"); + + let router = worker + .create_router(RouterOptions::new(media_codecs())) + .await + .expect("Failed to create router"); + + let transport_options = + WebRtcTransportOptions::new(WebRtcTransportListenInfos::new(ListenInfo { + protocol: Protocol::Udp, + ip: IpAddr::V4(Ipv4Addr::LOCALHOST), + announced_ip: None, + port: None, + send_buffer_size: None, + recv_buffer_size: None, + })); + + let transport_1 = router + .create_webrtc_transport(transport_options.clone()) + .await + .expect("Failed to create transport1"); + + let transport_2 = router + .create_webrtc_transport(transport_options) + .await + .expect("Failed to create transport2"); + + (worker, router, transport_1, transport_2) +} + +fn audio_producer_options() -> ProducerOptions { + ProducerOptions::new( + MediaKind::Audio, + RtpParameters { + mid: Some(fastrand::u32(100_000_000..999_999_999).to_string()), + codecs: vec![RtpCodecParameters::Audio { + mime_type: MimeTypeAudio::Opus, + payload_type: 0, + clock_rate: NonZeroU32::new(48000).unwrap(), + channels: NonZeroU8::new(2).unwrap(), + parameters: RtpCodecParametersParameters::from([ + ("useinbandfec", 1_u32.into()), + ("usedtx", 1_u32.into()), + ("foo", "222.222".into()), + ("bar", "333".into()), + ]), + rtcp_feedback: vec![], + }], + header_extensions: vec![ + RtpHeaderExtensionParameters { + uri: RtpHeaderExtensionUri::Mid, + id: 10, + encrypt: false, + }, + RtpHeaderExtensionParameters { + uri: RtpHeaderExtensionUri::AudioLevel, + id: 12, + encrypt: false, + }, + ], + // Missing encodings on purpose. + encodings: vec![], + rtcp: RtcpParameters { + cname: Some("audio-1".to_string()), + ..RtcpParameters::default() + }, + }, + ) +} + +pub fn criterion_benchmark(c: &mut Criterion) { + let mut group = c.benchmark_group("producer"); + + { + let (_worker, _router, transport_1, _transport_2) = + futures_lite::future::block_on(async { init().await }); + + let producer = futures_lite::future::block_on(async { + let (_worker, _router, transport_1, _transport_2) = init().await; + transport_1 + .produce(audio_producer_options()) + .await + .expect("Failed to produce audio") + }); + + group.bench_function("create", |b| { + b.iter(|| { + let _ = futures_lite::future::block_on(async { + transport_1 + .produce(audio_producer_options()) + .await + .expect("Failed to produce audio") + }); + }) + }); + + group.bench_function("dump", |b| { + b.iter(|| { + let _ = futures_lite::future::block_on(async { producer.dump().await }); + }) + }); + + group.bench_function("stats", |b| { + b.iter(|| { + let _ = futures_lite::future::block_on(async { producer.get_stats().await }); + }) + }); + } + + group.finish(); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches); diff --git a/rust/src/prelude.rs b/rust/src/prelude.rs index 62953870e5..9195a393b4 100644 --- a/rust/src/prelude.rs +++ b/rust/src/prelude.rs @@ -63,8 +63,9 @@ pub use crate::data_structures::{ AppData, DtlsParameters, IceCandidate, IceParameters, ListenInfo, Protocol, WebRtcMessage, }; pub use crate::rtp_parameters::{ - MediaKind, MimeTypeAudio, MimeTypeVideo, RtcpFeedback, RtpCapabilities, - RtpCapabilitiesFinalized, RtpCodecCapability, RtpCodecParametersParameters, RtpParameters, + MediaKind, MimeTypeAudio, MimeTypeVideo, RtcpFeedback, RtcpParameters, RtpCapabilities, + RtpCapabilitiesFinalized, RtpCodecCapability, RtpCodecParameters, RtpCodecParametersParameters, + RtpHeaderExtensionParameters, RtpHeaderExtensionUri, RtpParameters, }; pub use crate::sctp_parameters::SctpStreamParameters; pub use crate::srtp_parameters::SrtpCryptoSuite; From be38184a671e39bf0d44e272ce62f15df3e7d058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Wed, 25 Oct 2023 12:59:33 +0200 Subject: [PATCH 52/73] Use `npm ci --force` to make CI work in Node 16 --- .github/workflows/mediasoup-node.yaml | 4 +++- npm-scripts.mjs | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mediasoup-node.yaml b/.github/workflows/mediasoup-node.yaml index da27b8514e..7fdfaef856 100644 --- a/.github/workflows/mediasoup-node.yaml +++ b/.github/workflows/mediasoup-node.yaml @@ -47,6 +47,8 @@ jobs: restore-keys: | ${{ matrix.ci.os }}-node- - - run: npm ci + # NOTE: Add --force since otherwise `npm ci` fails in Node 26 because + # @octokit/auth-token dev dependency requires Node >= 16. + - run: npm ci --force - run: npm run lint:node - run: npm run test:node diff --git a/npm-scripts.mjs b/npm-scripts.mjs index 2a32a16886..de080af5b1 100644 --- a/npm-scripts.mjs +++ b/npm-scripts.mjs @@ -631,6 +631,10 @@ async function downloadPrebuiltWorker() env : {} } ); + + logInfo( + 'downloadPrebuiltWorker() | fetched mediasoup-worker prebuilt binary is valid for current host' + ); } catch (error) { From 3dd69b5367aaa7fcac04a6f361c6a7d081701ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 26 Oct 2023 12:52:25 +0200 Subject: [PATCH 53/73] Rust: FBS do not use heap to process responses (#1194) * Rust: FBS do not use heap to process responses Avoid heap allocations. Provides 10% of performance improvement[*]. This is a test bed for rewritting the rest of `from_fbs` to `from_fbs_ref`. NOTE: Once all `from_fbs` are moved to `from_fbs_ref`, rename the methods back to `from_fbs` [*]: benched producer::dump() --- rust/benches/producer.rs | 168 ++++++++++++++++++----- rust/src/messages.rs | 257 +++++++++++++++++++++--------------- rust/src/ortc.rs | 46 ++++--- rust/src/prelude.rs | 3 +- rust/src/router/consumer.rs | 149 +++++++++++---------- rust/src/router/producer.rs | 60 +++++---- rust/src/rtp_parameters.rs | 137 ++++++++++--------- rust/src/worker/channel.rs | 42 ++++-- 8 files changed, 522 insertions(+), 340 deletions(-) diff --git a/rust/benches/producer.rs b/rust/benches/producer.rs index 18493d9c93..b573896980 100644 --- a/rust/benches/producer.rs +++ b/rust/benches/producer.rs @@ -120,6 +120,77 @@ fn audio_producer_options() -> ProducerOptions { ) } +fn video_producer_options() -> ProducerOptions { + ProducerOptions::new( + MediaKind::Video, + RtpParameters { + mid: Some(fastrand::u32(100_000_000..999_999_999).to_string()), + codecs: vec![ + RtpCodecParameters::Video { + mime_type: MimeTypeVideo::H264, + payload_type: 112, + clock_rate: NonZeroU32::new(90000).unwrap(), + parameters: RtpCodecParametersParameters::from([ + ("packetization-mode", 1_u32.into()), + ("profile-level-id", "4d0032".into()), + ]), + rtcp_feedback: vec![ + RtcpFeedback::Nack, + RtcpFeedback::NackPli, + RtcpFeedback::GoogRemb, + ], + }, + RtpCodecParameters::Video { + mime_type: MimeTypeVideo::Rtx, + payload_type: 113, + clock_rate: NonZeroU32::new(90000).unwrap(), + parameters: RtpCodecParametersParameters::from([("apt", 112u32.into())]), + rtcp_feedback: vec![], + }, + ], + header_extensions: vec![ + RtpHeaderExtensionParameters { + uri: RtpHeaderExtensionUri::Mid, + id: 10, + encrypt: false, + }, + RtpHeaderExtensionParameters { + uri: RtpHeaderExtensionUri::VideoOrientation, + id: 13, + encrypt: false, + }, + ], + encodings: vec![ + RtpEncodingParameters { + ssrc: Some(22222222), + rtx: Some(RtpEncodingParametersRtx { ssrc: 22222223 }), + scalability_mode: "L1T3".parse().unwrap(), + ..RtpEncodingParameters::default() + }, + RtpEncodingParameters { + ssrc: Some(22222224), + rtx: Some(RtpEncodingParametersRtx { ssrc: 22222225 }), + ..RtpEncodingParameters::default() + }, + RtpEncodingParameters { + ssrc: Some(22222226), + rtx: Some(RtpEncodingParametersRtx { ssrc: 22222227 }), + ..RtpEncodingParameters::default() + }, + RtpEncodingParameters { + ssrc: Some(22222228), + rtx: Some(RtpEncodingParametersRtx { ssrc: 22222229 }), + ..RtpEncodingParameters::default() + }, + ], + rtcp: RtcpParameters { + cname: Some("video-1".to_string()), + ..RtcpParameters::default() + }, + }, + ) +} + pub fn criterion_benchmark(c: &mut Criterion) { let mut group = c.benchmark_group("producer"); @@ -127,36 +198,73 @@ pub fn criterion_benchmark(c: &mut Criterion) { let (_worker, _router, transport_1, _transport_2) = futures_lite::future::block_on(async { init().await }); - let producer = futures_lite::future::block_on(async { - let (_worker, _router, transport_1, _transport_2) = init().await; - transport_1 - .produce(audio_producer_options()) - .await - .expect("Failed to produce audio") - }); - - group.bench_function("create", |b| { - b.iter(|| { - let _ = futures_lite::future::block_on(async { - transport_1 - .produce(audio_producer_options()) - .await - .expect("Failed to produce audio") - }); - }) - }); - - group.bench_function("dump", |b| { - b.iter(|| { - let _ = futures_lite::future::block_on(async { producer.dump().await }); - }) - }); - - group.bench_function("stats", |b| { - b.iter(|| { - let _ = futures_lite::future::block_on(async { producer.get_stats().await }); - }) - }); + { + let audio_producer = futures_lite::future::block_on(async { + let (_worker, _router, transport_1, _transport_2) = init().await; + transport_1 + .produce(audio_producer_options()) + .await + .expect("Failed to produce audio") + }); + + group.bench_function("create/audio", |b| { + b.iter(|| { + let _ = futures_lite::future::block_on(async { + transport_1 + .produce(audio_producer_options()) + .await + .expect("Failed to produce audio") + }); + }) + }); + + group.bench_function("dump/audio", |b| { + b.iter(|| { + let _ = futures_lite::future::block_on(async { audio_producer.dump().await }); + }) + }); + + group.bench_function("stats/audio", |b| { + b.iter(|| { + let _ = + futures_lite::future::block_on(async { audio_producer.get_stats().await }); + }) + }); + } + + { + let video_producer = futures_lite::future::block_on(async { + let (_worker, _router, transport_1, _transport_2) = init().await; + transport_1 + .produce(video_producer_options()) + .await + .expect("Failed to produce video") + }); + + group.bench_function("create/video", |b| { + b.iter(|| { + let _ = futures_lite::future::block_on(async { + transport_1 + .produce(video_producer_options()) + .await + .expect("Failed to produce video") + }); + }) + }); + + group.bench_function("dump/video", |b| { + b.iter(|| { + let _ = futures_lite::future::block_on(async { video_producer.dump().await }); + }) + }); + + group.bench_function("stats/video", |b| { + b.iter(|| { + let _ = + futures_lite::future::block_on(async { video_producer.get_stats().await }); + }) + }); + } } group.finish(); diff --git a/rust/src/messages.rs b/rust/src/messages.rs index 86ad756298..5e6f3b808f 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -13,12 +13,14 @@ 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_transport, worker, + 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; use crate::producer::{ProducerId, ProducerTraceEventType, ProducerType}; +use crate::router::consumer::ConsumerDump; +use crate::router::producer::ProducerDump; use crate::router::{RouterDump, RouterId}; use crate::rtp_observer::RtpObserverId; use crate::rtp_parameters::{MediaKind, RtpEncodingParameters, RtpParameters}; @@ -60,8 +62,9 @@ where } /// Convert generic response into specific type of this request. - fn convert_response(response: Option) - -> Result>; + fn convert_response( + response: Option>, + ) -> Result>; } pub(crate) trait Notification: Debug { @@ -98,7 +101,7 @@ impl Request for WorkerCloseRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -129,12 +132,14 @@ impl Request for WorkerDumpRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::WorkerDumpResponse(data)) = response else { + let Some(response::BodyRef::WorkerDumpResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = worker::DumpResponse::try_from(data)?; + Ok(WorkerDump { router_ids: data .router_ids @@ -204,7 +209,7 @@ impl Request for WorkerUpdateSettingsRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -244,7 +249,7 @@ impl Request for WorkerCreateWebRtcServerRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -283,7 +288,7 @@ impl Request for WebRtcServerCloseRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -314,12 +319,14 @@ impl Request for WebRtcServerDumpRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::WebRtcServerDumpResponse(data)) = response else { + let Some(response::BodyRef::WebRtcServerDumpResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = web_rtc_server::DumpResponse::try_from(data)?; + Ok(WebRtcServerDump { id: data.id.parse()?, udp_sockets: data @@ -394,7 +401,7 @@ impl Request for WorkerCreateRouterRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -429,7 +436,7 @@ impl Request for RouterCloseRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -460,12 +467,14 @@ impl Request for RouterDumpRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::RouterDumpResponse(data)) = response else { + let Some(response::BodyRef::RouterDumpResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = router::DumpResponse::try_from(data)?; + Ok(RouterDump { id: data.id.parse()?, map_consumer_id_producer_id: data @@ -603,7 +612,7 @@ impl Request for RouterCreateDirectTransportRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -769,12 +778,14 @@ impl Request for RouterCreateWebRtcTransportRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::WebRtcTransportDumpResponse(data)) = response else { + let Some(response::BodyRef::WebRtcTransportDumpResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = web_rtc_transport::DumpResponse::try_from(data)?; + Ok(WebRtcTransportData { ice_role: IceRole::from_fbs(data.ice_role), ice_parameters: IceParameters::from_fbs(*data.ice_parameters), @@ -844,12 +855,14 @@ impl Request for RouterCreateWebRtcTransportWithServerRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::WebRtcTransportDumpResponse(data)) = response else { + let Some(response::BodyRef::WebRtcTransportDumpResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = web_rtc_transport::DumpResponse::try_from(data)?; + Ok(WebRtcTransportData { ice_role: IceRole::from_fbs(data.ice_role), ice_parameters: IceParameters::from_fbs(*data.ice_parameters), @@ -974,12 +987,14 @@ impl Request for RouterCreatePlainTransportRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::PlainTransportDumpResponse(data)) = response else { + let Some(response::BodyRef::PlainTransportDumpResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = plain_transport::DumpResponse::try_from(data)?; + Ok(PlainTransportData { tuple: Mutex::new(TransportTuple::from_fbs(data.tuple.as_ref())), rtcp_tuple: Mutex::new( @@ -1098,12 +1113,14 @@ impl Request for RouterCreatePipeTransportRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::PipeTransportDumpResponse(data)) = response else { + let Some(response::BodyRef::PipeTransportDumpResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = pipe_transport::DumpResponse::try_from(data)?; + Ok(PipeTransportData { tuple: Mutex::new(TransportTuple::from_fbs(data.tuple.as_ref())), sctp_parameters: data @@ -1197,7 +1214,7 @@ impl Request for RouterCreateAudioLevelObserverRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -1262,7 +1279,7 @@ impl Request for RouterCreateActiveSpeakerObserverRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -1293,10 +1310,10 @@ impl Request for TransportDumpRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { match response { - Some(data) => Ok(data), + Some(data) => Ok(data.try_into().unwrap()), _ => { panic!("Wrong message from worker: {response:?}"); } @@ -1328,10 +1345,10 @@ impl Request for TransportGetStatsRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { match response { - Some(data) => Ok(data), + Some(data) => Ok(data.try_into().unwrap()), _ => { panic!("Wrong message from worker: {response:?}"); } @@ -1369,7 +1386,7 @@ impl Request for TransportCloseRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -1410,12 +1427,14 @@ impl Request for WebRtcTransportConnectRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::WebRtcTransportConnectResponse(data)) = response else { + let Some(response::BodyRef::WebRtcTransportConnectResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = web_rtc_transport::ConnectResponse::try_from(data)?; + Ok(WebRtcTransportConnectResponse { dtls_local_role: DtlsRole::from_fbs(data.dtls_local_role), }) @@ -1462,12 +1481,14 @@ impl Request for PipeTransportConnectRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::PipeTransportConnectResponse(data)) = response else { + let Some(response::BodyRef::PipeTransportConnectResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = pipe_transport::ConnectResponse::try_from(data)?; + Ok(PipeTransportConnectResponse { tuple: TransportTuple::from_fbs(data.tuple.as_ref()), }) @@ -1519,12 +1540,14 @@ impl Request for TransportConnectPlainRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::PlainTransportConnectResponse(data)) = response else { + let Some(response::BodyRef::PlainTransportConnectResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = plain_transport::ConnectResponse::try_from(data)?; + Ok(PlainTransportConnectResponse { tuple: TransportTuple::from_fbs(data.tuple.as_ref()), rtcp_tuple: data @@ -1567,7 +1590,7 @@ impl Request for TransportSetMaxIncomingBitrateRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -1603,7 +1626,7 @@ impl Request for TransportSetMaxOutgoingBitrateRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -1639,7 +1662,7 @@ impl Request for TransportSetMinOutgoingBitrateRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -1669,12 +1692,14 @@ impl Request for TransportRestartIceRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::TransportRestartIceResponse(data)) = response else { + let Some(response::BodyRef::TransportRestartIceResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = transport::RestartIceResponse::try_from(data)?; + Ok(IceParameters::from_fbs(web_rtc_transport::IceParameters { username_fragment: data.username_fragment, password: data.password, @@ -1729,12 +1754,14 @@ impl Request for TransportProduceRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::TransportProduceResponse(data)) = response else { + let Some(response::BodyRef::TransportProduceResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = transport::ProduceResponse::try_from(data)?; + Ok(TransportProduceResponse { r#type: ProducerType::from_fbs(data.type_), }) @@ -1799,12 +1826,14 @@ impl Request for TransportConsumeRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::TransportConsumeResponse(data)) = response else { + let Some(response::BodyRef::TransportConsumeResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = transport::ConsumeResponse::try_from(data)?; + Ok(TransportConsumeResponse { paused: data.paused, producer_paused: data.producer_paused, @@ -1879,12 +1908,14 @@ impl Request for TransportProduceDataRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::DataProducerDumpResponse(data)) = response else { + let Some(response::BodyRef::DataProducerDumpResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = data_producer::DumpResponse::try_from(data)?; + Ok(TransportProduceDataResponse { r#type: match data.type_ { data_producer::Type::Sctp => DataProducerType::Sctp, @@ -1968,12 +1999,14 @@ impl Request for TransportConsumeDataRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::DataConsumerDumpResponse(data)) = response else { + let Some(response::BodyRef::DataConsumerDumpResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = data_consumer::DumpResponse::try_from(data)?; + Ok(TransportConsumeDataResponse { r#type: match data.type_ { data_producer::Type::Sctp => DataConsumerType::Sctp, @@ -2027,7 +2060,7 @@ impl Request for TransportEnableTraceEventRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -2098,7 +2131,7 @@ impl Request for ProducerCloseRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -2110,7 +2143,7 @@ pub(crate) struct ProducerDumpRequest {} impl Request for ProducerDumpRequest { const METHOD: request::Method = request::Method::ProducerDump; type HandlerId = ProducerId; - type Response = response::Body; + type Response = ProducerDump; fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { let mut builder = Builder::new(); @@ -2129,14 +2162,13 @@ impl Request for ProducerDumpRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - match response { - Some(data) => Ok(data), - _ => { - panic!("Wrong message from worker: {response:?}"); - } - } + let Some(response::BodyRef::ProducerDumpResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + ProducerDump::from_fbs_ref(data) } } @@ -2165,10 +2197,10 @@ impl Request for ProducerGetStatsRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { match response { - Some(data) => Ok(data), + Some(data) => Ok(data.try_into().unwrap()), _ => { panic!("Wrong message from worker: {response:?}"); } @@ -2201,7 +2233,7 @@ impl Request for ProducerPauseRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -2232,7 +2264,7 @@ impl Request for ProducerResumeRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -2274,7 +2306,7 @@ impl Request for ProducerEnableTraceEventRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -2345,7 +2377,7 @@ impl Request for ConsumerCloseRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -2357,7 +2389,7 @@ pub(crate) struct ConsumerDumpRequest {} impl Request for ConsumerDumpRequest { const METHOD: request::Method = request::Method::ConsumerDump; type HandlerId = ConsumerId; - type Response = response::Body; + type Response = ConsumerDump; fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { let mut builder = Builder::new(); @@ -2376,14 +2408,13 @@ impl Request for ConsumerDumpRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - match response { - Some(data) => Ok(data), - _ => { - panic!("Wrong message from worker: {response:?}"); - } - } + let Some(response::BodyRef::ConsumerDumpResponse(data)) = response else { + panic!("Wrong message from worker: {response:?}"); + }; + + ConsumerDump::from_fbs_ref(data) } } @@ -2412,10 +2443,10 @@ impl Request for ConsumerGetStatsRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { match response { - Some(data) => Ok(data), + Some(data) => Ok(data.try_into().unwrap()), _ => { panic!("Wrong message from worker: {response:?}"); } @@ -2448,7 +2479,7 @@ impl Request for ConsumerPauseRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -2479,7 +2510,7 @@ impl Request for ConsumerResumeRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -2519,12 +2550,14 @@ impl Request for ConsumerSetPreferredLayersRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::ConsumerSetPreferredLayersResponse(data)) = response else { + let Some(response::BodyRef::ConsumerSetPreferredLayersResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = consumer::SetPreferredLayersResponse::try_from(data)?; + match data.preferred_layers { Some(preferred_layers) => Ok(Some(ConsumerLayers::from_fbs(*preferred_layers))), None => Ok(None), @@ -2567,12 +2600,14 @@ impl Request for ConsumerSetPriorityRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::ConsumerSetPriorityResponse(data)) = response else { + let Some(response::BodyRef::ConsumerSetPriorityResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = consumer::SetPriorityResponse::try_from(data)?; + Ok(ConsumerSetPriorityResponse { priority: data.priority, }) @@ -2603,7 +2638,7 @@ impl Request for ConsumerRequestKeyFrameRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -2645,7 +2680,7 @@ impl Request for ConsumerEnableTraceEventRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -2688,7 +2723,7 @@ impl Request for DataProducerCloseRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -2719,10 +2754,10 @@ impl Request for DataProducerDumpRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { match response { - Some(data) => Ok(data), + Some(data) => Ok(data.try_into().unwrap()), _ => { panic!("Wrong message from worker: {response:?}"); } @@ -2755,10 +2790,10 @@ impl Request for DataProducerGetStatsRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { match response { - Some(data) => Ok(data), + Some(data) => Ok(data.try_into().unwrap()), _ => { panic!("Wrong message from worker: {response:?}"); } @@ -2791,7 +2826,7 @@ impl Request for DataProducerPauseRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -2822,7 +2857,7 @@ impl Request for DataProducerResumeRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -2902,7 +2937,7 @@ impl Request for DataConsumerCloseRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -2933,10 +2968,10 @@ impl Request for DataConsumerDumpRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { match response { - Some(data) => Ok(data), + Some(data) => Ok(data.try_into().unwrap()), _ => { panic!("Wrong message from worker: {response:?}"); } @@ -2969,10 +3004,10 @@ impl Request for DataConsumerGetStatsRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { match response { - Some(data) => Ok(data), + Some(data) => Ok(data.try_into().unwrap()), _ => { panic!("Wrong message from worker: {response:?}"); } @@ -3005,7 +3040,7 @@ impl Request for DataConsumerPauseRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -3036,7 +3071,7 @@ impl Request for DataConsumerResumeRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -3072,12 +3107,14 @@ impl Request for DataConsumerGetBufferedAmountRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::DataConsumerGetBufferedAmountResponse(data)) = response else { + let Some(response::BodyRef::DataConsumerGetBufferedAmountResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = data_consumer::GetBufferedAmountResponse::try_from(data)?; + Ok(DataConsumerGetBufferedAmountResponse { buffered_amount: data.buffered_amount, }) @@ -3121,7 +3158,7 @@ impl Request for DataConsumerSetBufferedAmountLowThresholdRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -3161,7 +3198,7 @@ impl Request for DataConsumerSendRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -3209,12 +3246,14 @@ impl Request for DataConsumerSetSubchannelsRequest { } fn convert_response( - response: Option, + response: Option>, ) -> Result> { - let Some(response::Body::DataConsumerSetSubchannelsResponse(data)) = response else { + let Some(response::BodyRef::DataConsumerSetSubchannelsResponse(data)) = response else { panic!("Wrong message from worker: {response:?}"); }; + let data = data_consumer::SetSubchannelsResponse::try_from(data)?; + Ok(DataConsumerSetSubchannelsResponse { subchannels: data.subchannels, }) @@ -3252,7 +3291,7 @@ impl Request for RtpObserverCloseRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -3282,7 +3321,7 @@ impl Request for RtpObserverPauseRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -3312,7 +3351,7 @@ impl Request for RtpObserverResumeRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -3351,7 +3390,7 @@ impl Request for RtpObserverAddProducerRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } @@ -3390,7 +3429,7 @@ impl Request for RtpObserverRemoveProducerRequest { } fn convert_response( - _response: Option, + _response: Option>, ) -> Result> { Ok(()) } diff --git a/rust/src/ortc.rs b/rust/src/ortc.rs index 03f6726cb3..f176e477f6 100644 --- a/rust/src/ortc.rs +++ b/rust/src/ortc.rs @@ -12,6 +12,7 @@ use serde::{Deserialize, Serialize}; use std::borrow::Cow; use std::collections::BTreeMap; use std::convert::TryFrom; +use std::error::Error; use std::mem; use std::num::{NonZeroU32, NonZeroU8}; use std::ops::Deref; @@ -77,32 +78,37 @@ impl RtpMapping { } } - pub(crate) fn from_fbs(mapping: rtp_parameters::RtpMapping) -> Self { - Self { + pub(crate) fn from_fbs_ref( + mapping: rtp_parameters::RtpMappingRef<'_>, + ) -> Result> { + Ok(Self { codecs: mapping - .codecs + .codecs()? .iter() - .map(|mapping| RtpMappingCodec { - payload_type: mapping.payload_type, - mapped_payload_type: mapping.mapped_payload_type, + .map(|mapping| { + Ok(RtpMappingCodec { + payload_type: mapping?.payload_type()?, + mapped_payload_type: mapping?.mapped_payload_type()?, + }) }) - .collect(), + .collect::, Box>>()?, encodings: mapping - .encodings + .encodings()? .iter() - .map(|mapping| RtpMappingEncoding { - rid: mapping.rid.clone().map(|rid| rid.to_string()), - ssrc: mapping.ssrc, - scalability_mode: mapping - .scalability_mode - .clone() - .unwrap_or(String::from("S1T1")) - .parse() - .unwrap(), - mapped_ssrc: mapping.mapped_ssrc, + .map(|mapping| { + Ok(RtpMappingEncoding { + rid: mapping?.rid()?.map(|rid| rid.to_string()), + ssrc: mapping?.ssrc()?, + scalability_mode: mapping? + .scalability_mode()? + .map(|maybe_scalability_mode| maybe_scalability_mode.parse()) + .transpose()? + .unwrap_or_default(), + mapped_ssrc: mapping?.mapped_ssrc()?, + }) }) - .collect(), - } + .collect::, Box>>()?, + }) } } diff --git a/rust/src/prelude.rs b/rust/src/prelude.rs index 9195a393b4..63a010fd5c 100644 --- a/rust/src/prelude.rs +++ b/rust/src/prelude.rs @@ -65,7 +65,8 @@ pub use crate::data_structures::{ pub use crate::rtp_parameters::{ MediaKind, MimeTypeAudio, MimeTypeVideo, RtcpFeedback, RtcpParameters, RtpCapabilities, RtpCapabilitiesFinalized, RtpCodecCapability, RtpCodecParameters, RtpCodecParametersParameters, - RtpHeaderExtensionParameters, RtpHeaderExtensionUri, RtpParameters, + RtpEncodingParameters, RtpEncodingParametersRtx, RtpHeaderExtensionParameters, + RtpHeaderExtensionUri, RtpParameters, }; pub use crate::sctp_parameters::SctpStreamParameters; pub use crate::srtp_parameters::SrtpCryptoSuite; diff --git a/rust/src/router/consumer.rs b/rust/src/router/consumer.rs index eaff8b425e..8280bc8614 100644 --- a/rust/src/router/consumer.rs +++ b/rust/src/router/consumer.rs @@ -161,24 +161,24 @@ pub struct RtpStreamParams { } impl RtpStreamParams { - pub(crate) fn from_fbs(params: &rtp_stream::Params) -> Self { - Self { - clock_rate: params.clock_rate, - cname: params.cname.clone(), - encoding_idx: params.encoding_idx, - mime_type: params.mime_type.clone().parse().unwrap(), - payload_type: params.payload_type, - spatial_layers: params.spatial_layers, - ssrc: params.ssrc, - temporal_layers: params.temporal_layers, - use_dtx: params.use_dtx, - use_in_band_fec: params.use_in_band_fec, - use_nack: params.use_nack, - use_pli: params.use_pli, - rid: params.rid.clone(), - rtx_ssrc: params.rtx_ssrc, - rtx_payload_type: params.rtx_payload_type, - } + pub(crate) fn from_fbs_ref(params: rtp_stream::ParamsRef<'_>) -> Result> { + Ok(Self { + clock_rate: params.clock_rate()?, + cname: params.cname()?.to_string(), + encoding_idx: params.encoding_idx()?, + mime_type: params.mime_type()?.parse()?, + payload_type: params.payload_type()?, + spatial_layers: params.spatial_layers()?, + ssrc: params.ssrc()?, + temporal_layers: params.temporal_layers()?, + use_dtx: params.use_dtx()?, + use_in_band_fec: params.use_in_band_fec()?, + use_nack: params.use_nack()?, + use_pli: params.use_pli()?, + rid: params.rid()?.map(|rid| rid.to_string()), + rtx_ssrc: params.rtx_ssrc()?, + rtx_payload_type: params.rtx_payload_type()?, + }) } } @@ -195,15 +195,15 @@ pub struct RtxStreamParams { } impl RtxStreamParams { - pub(crate) fn from_fbs(params: &rtx_stream::Params) -> Self { - Self { - clock_rate: params.clock_rate, - cname: params.cname.clone(), - mime_type: params.mime_type.clone().parse().unwrap(), - payload_type: params.payload_type, - ssrc: params.ssrc, - rrid: params.rrid.clone(), - } + pub(crate) fn from_fbs_ref(params: rtx_stream::ParamsRef<'_>) -> Result> { + Ok(Self { + clock_rate: params.clock_rate()?, + cname: params.cname()?.to_string(), + mime_type: params.mime_type()?.parse()?, + payload_type: params.payload_type()?, + ssrc: params.ssrc()?, + rrid: params.rrid()?.map(|rrid| rrid.to_string()), + }) } } @@ -216,11 +216,11 @@ pub struct RtpStream { } impl RtpStream { - pub(crate) fn from_fbs(dump: rtp_stream::Dump) -> Self { - Self { - params: RtpStreamParams::from_fbs(&dump.params), - score: dump.score, - } + pub(crate) fn from_fbs_ref(dump: rtp_stream::DumpRef<'_>) -> Result> { + Ok(Self { + params: RtpStreamParams::from_fbs_ref(dump.params()?)?, + score: dump.score()?, + }) } } @@ -263,42 +263,48 @@ pub struct ConsumerDump { } impl ConsumerDump { - pub(crate) fn from_fbs(dump: consumer::DumpResponse) -> Result> { - let dump = dump.data; + pub(crate) fn from_fbs_ref( + dump: consumer::DumpResponseRef<'_>, + ) -> Result> { + let dump = dump.data(); Ok(Self { - id: dump.base.id.parse()?, - kind: MediaKind::from_fbs(dump.base.kind), - paused: dump.base.paused, - priority: dump.base.priority, - producer_id: dump.base.producer_id.parse()?, - producer_paused: dump.base.producer_paused, - rtp_parameters: RtpParameters::from_fbs(*dump.base.rtp_parameters).unwrap(), - supported_codec_payload_types: dump.base.supported_codec_payload_types, - trace_event_types: dump - .base - .trace_event_types + id: dump?.base()?.id()?.parse()?, + kind: MediaKind::from_fbs(dump?.base()?.kind()?), + paused: dump?.base()?.paused()?, + priority: dump?.base()?.priority()?, + producer_id: dump?.base()?.producer_id()?.parse()?, + producer_paused: dump?.base()?.producer_paused()?, + rtp_parameters: RtpParameters::from_fbs_ref(dump?.base()?.rtp_parameters()?)?, + supported_codec_payload_types: Vec::from( + dump?.base()?.supported_codec_payload_types()?, + ), + trace_event_types: dump? + .base()? + .trace_event_types()? .iter() - .map(ConsumerTraceEventType::from_fbs) - .collect(), - r#type: ConsumerType::from_fbs(dump.base.type_), - consumable_rtp_encodings: dump - .base - .consumable_rtp_encodings - .into_iter() - .map(RtpEncodingParameters::from_fbs) - .collect(), - rtp_streams: dump - .rtp_streams - .into_iter() - .map(RtpStream::from_fbs) - .collect(), - preferred_spatial_layer: dump.preferred_spatial_layer, - target_spatial_layer: dump.target_spatial_layer, - current_spatial_layer: dump.current_spatial_layer, - preferred_temporal_layer: dump.preferred_temporal_layer, - target_temporal_layer: dump.target_temporal_layer, - current_temporal_layer: dump.current_temporal_layer, + .map(|trace_event_type| Ok(ConsumerTraceEventType::from_fbs(trace_event_type?))) + .collect::>>()?, + r#type: ConsumerType::from_fbs(dump?.base()?.type_()?), + consumable_rtp_encodings: dump? + .base()? + .consumable_rtp_encodings()? + .iter() + .map(|encoding_parameters| { + RtpEncodingParameters::from_fbs_ref(encoding_parameters?) + }) + .collect::>>()?, + rtp_streams: dump? + .rtp_streams()? + .iter() + .map(|stream| RtpStream::from_fbs_ref(stream?)) + .collect::>>()?, + preferred_spatial_layer: dump?.preferred_spatial_layer()?, + target_spatial_layer: dump?.target_spatial_layer()?, + current_spatial_layer: dump?.current_spatial_layer()?, + preferred_temporal_layer: dump?.preferred_temporal_layer()?, + target_temporal_layer: dump?.target_temporal_layer()?, + current_temporal_layer: dump?.current_temporal_layer()?, }) } } @@ -563,7 +569,7 @@ impl ConsumerTraceEventType { } } - pub(crate) fn from_fbs(event_type: &consumer::TraceEventType) -> Self { + pub(crate) fn from_fbs(event_type: consumer::TraceEventType) -> Self { match event_type { consumer::TraceEventType::Rtp => ConsumerTraceEventType::Rtp, consumer::TraceEventType::Keyframe => ConsumerTraceEventType::KeyFrame, @@ -986,17 +992,10 @@ impl Consumer { pub async fn dump(&self) -> Result { debug!("dump()"); - let response = self - .inner + self.inner .channel .request(self.id(), ConsumerDumpRequest {}) - .await?; - - if let response::Body::ConsumerDumpResponse(data) = response { - Ok(ConsumerDump::from_fbs(*data).expect("Error parsing dump response")) - } else { - panic!("Wrong message from worker"); - } + .await } /// Returns current RTC statistics of the consumer. diff --git a/rust/src/router/producer.rs b/rust/src/router/producer.rs index 4bfde5a99c..5b0e1b68fd 100644 --- a/rust/src/router/producer.rs +++ b/rust/src/router/producer.rs @@ -106,14 +106,18 @@ pub struct RtpStreamRecv { } impl RtpStreamRecv { - pub(crate) fn from_fbs(dump: &rtp_stream::Dump) -> Self { - Self { - params: RtpStreamParams::from_fbs(&dump.params), - score: dump.score, - rtx_stream: dump.rtx_stream.clone().map(|stream| RtxStream { - params: RtxStreamParams::from_fbs(&stream.params), - }), - } + pub(crate) fn from_fbs_ref(dump: rtp_stream::DumpRef<'_>) -> Result> { + Ok(Self { + params: RtpStreamParams::from_fbs_ref(dump.params()?)?, + score: dump.score()?, + rtx_stream: if let Some(rtx_stream) = dump.rtx_stream()? { + Some(RtxStream { + params: RtxStreamParams::from_fbs_ref(rtx_stream.params()?)?, + }) + } else { + None + }, + }) } } @@ -133,24 +137,29 @@ pub struct ProducerDump { } impl ProducerDump { - pub(crate) fn from_fbs(dump: producer::DumpResponse) -> Result> { + pub(crate) fn from_fbs_ref( + dump: producer::DumpResponseRef<'_>, + ) -> Result> { Ok(Self { - id: dump.id.parse()?, - kind: MediaKind::from_fbs(dump.kind), - paused: dump.paused, - rtp_mapping: RtpMapping::from_fbs(*dump.rtp_mapping), - rtp_parameters: RtpParameters::from_fbs(*dump.rtp_parameters).unwrap(), + id: dump.id()?.parse()?, + kind: MediaKind::from_fbs(dump.kind()?), + paused: dump.paused()?, + rtp_mapping: RtpMapping::from_fbs_ref(dump.rtp_mapping()?)?, + rtp_parameters: RtpParameters::from_fbs_ref(dump.rtp_parameters()?)?, rtp_streams: dump - .rtp_streams + .rtp_streams()? .iter() - .map(RtpStreamRecv::from_fbs) - .collect(), + .map(|rtp_stream| RtpStreamRecv::from_fbs_ref(rtp_stream?)) + .collect::>>()?, trace_event_types: dump - .trace_event_types + .trace_event_types()? .iter() - .map(ProducerTraceEventType::from_fbs) + .map(|trace_event_type| { + ProducerTraceEventType::from_fbs(&trace_event_type.unwrap()) + }) .collect(), - r#type: ProducerType::from_fbs(dump.type_), + + r#type: ProducerType::from_fbs(dump.type_()?), }) } } @@ -845,17 +854,10 @@ impl Producer { pub async fn dump(&self) -> Result { debug!("dump()"); - let response = self - .inner() + self.inner() .channel .request(self.id(), ProducerDumpRequest {}) - .await?; - - if let response::Body::ProducerDumpResponse(data) = response { - Ok(ProducerDump::from_fbs(*data).expect("Error parsing dump response")) - } else { - panic!("Wrong message from worker"); - } + .await } /// Returns current RTC statistics of the producer. diff --git a/rust/src/rtp_parameters.rs b/rust/src/rtp_parameters.rs index a4bfa84ae7..e063baa242 100644 --- a/rust/src/rtp_parameters.rs +++ b/rust/src/rtp_parameters.rs @@ -787,61 +787,63 @@ pub struct RtpParameters { } impl RtpParameters { - pub(crate) fn from_fbs( - rtp_parameters: rtp_parameters::RtpParameters, + pub(crate) fn from_fbs_ref( + rtp_parameters: rtp_parameters::RtpParametersRef<'_>, ) -> Result> { Ok(Self { - mid: rtp_parameters.mid, + mid: rtp_parameters.mid()?.map(|mid| mid.to_string()), codecs: rtp_parameters - .codecs + .codecs()? .into_iter() .map(|codec| { - let parameters = codec - .parameters - .unwrap_or_default() + let parameters = codec? + .parameters()? + .unwrap_or(planus::Vector::new_empty()) .into_iter() .map(|parameters| { Ok(( - Cow::Owned(parameters.name), - match parameters.value { - rtp_parameters::Value::Boolean(_) - | rtp_parameters::Value::Double(_) - | rtp_parameters::Value::Integer32Array(_) => { + Cow::Owned(parameters?.name()?.to_string()), + match parameters?.value()? { + rtp_parameters::ValueRef::Boolean(_) + | rtp_parameters::ValueRef::Double(_) + | rtp_parameters::ValueRef::Integer32Array(_) => { // TODO: Above value variant should not exist in the // first place panic!("Invalid parameter") } - rtp_parameters::Value::Integer32(n) => { + rtp_parameters::ValueRef::Integer32(n) => { RtpCodecParametersParametersValue::Number( - n.value.try_into()?, + n.value()?.try_into()?, ) } - rtp_parameters::Value::String(s) => { - RtpCodecParametersParametersValue::String(s.value.into()) + rtp_parameters::ValueRef::String(s) => { + RtpCodecParametersParametersValue::String( + s.value()?.to_string().into(), + ) } }, )) }) .collect::>>()?; - let rtcp_feedback = codec - .rtcp_feedback - .unwrap_or_default() + let rtcp_feedback = codec? + .rtcp_feedback()? + .unwrap_or(planus::Vector::new_empty()) .into_iter() .map(|rtcp_feedback| { - RtcpFeedback::from_type_parameter( - &rtcp_feedback.type_, - &rtcp_feedback.parameter.unwrap_or_default(), - ) + Ok(RtcpFeedback::from_type_parameter( + rtcp_feedback?.type_()?, + rtcp_feedback?.parameter()?.unwrap_or_default(), + )?) }) - .collect::>()?; + .collect::>>()?; - Ok(match MimeType::from_str(&codec.mime_type)? { + Ok(match MimeType::from_str(codec?.mime_type()?)? { MimeType::Audio(mime_type) => RtpCodecParameters::Audio { mime_type, - payload_type: codec.payload_type, - clock_rate: codec.clock_rate.try_into()?, - channels: codec - .channels + payload_type: codec?.payload_type()?, + clock_rate: codec?.clock_rate()?.try_into()?, + channels: codec? + .channels()? .ok_or("Audio must have channels specified")? .try_into()?, parameters, @@ -849,8 +851,8 @@ impl RtpParameters { }, MimeType::Video(mime_type) => RtpCodecParameters::Video { mime_type, - payload_type: codec.payload_type, - clock_rate: codec.clock_rate.try_into()?, + payload_type: codec?.payload_type()?, + clock_rate: codec?.clock_rate()?.try_into()?, parameters, rtcp_feedback, }, @@ -858,44 +860,47 @@ impl RtpParameters { }) .collect::>>()?, header_extensions: rtp_parameters - .header_extensions + .header_extensions()? .into_iter() .map(|header_extension_parameters| { Ok(RtpHeaderExtensionParameters { - uri: RtpHeaderExtensionUri::from_fbs(header_extension_parameters.uri), - id: u16::from(header_extension_parameters.id), - encrypt: header_extension_parameters.encrypt, + uri: RtpHeaderExtensionUri::from_fbs(header_extension_parameters?.uri()?), + id: u16::from(header_extension_parameters?.id()?), + encrypt: header_extension_parameters?.encrypt()?, }) }) .collect::>>()?, encodings: rtp_parameters - .encodings + .encodings()? .into_iter() .map(|encoding| { Ok(RtpEncodingParameters { - ssrc: encoding.ssrc, - rid: encoding.rid, - codec_payload_type: encoding.codec_payload_type, - rtx: encoding - .rtx - .map(|rtx| RtpEncodingParametersRtx { ssrc: rtx.ssrc }), + ssrc: encoding?.ssrc()?, + rid: encoding?.rid()?.map(|rid| rid.to_string()), + codec_payload_type: encoding?.codec_payload_type()?, + rtx: encoding?.rtx()?.map(|rtx| RtpEncodingParametersRtx { + ssrc: rtx.ssrc().unwrap(), + }), dtx: { - match encoding.dtx { + match encoding?.dtx()? { true => Some(true), false => None, } }, - scalability_mode: encoding - .scalability_mode - .unwrap_or(String::from("S1T1")) + scalability_mode: encoding? + .scalability_mode()? + .unwrap_or(String::from("S1T1").as_str()) .parse()?, - max_bitrate: encoding.max_bitrate, + max_bitrate: encoding?.max_bitrate()?, }) }) .collect::>>()?, rtcp: RtcpParameters { - cname: rtp_parameters.rtcp.cname, - reduced_size: rtp_parameters.rtcp.reduced_size, + cname: rtp_parameters + .rtcp()? + .cname()? + .map(|cname| cname.to_string()), + reduced_size: rtp_parameters.rtcp()?.reduced_size()?, }, }) } @@ -1303,27 +1308,31 @@ impl RtpEncodingParameters { } } - pub(crate) fn from_fbs(encoding_parameters: rtp_parameters::RtpEncodingParameters) -> Self { - Self { - ssrc: encoding_parameters.ssrc, - rid: encoding_parameters.rid.clone(), - codec_payload_type: encoding_parameters.codec_payload_type, - rtx: encoding_parameters - .rtx - .map(|rtx| RtpEncodingParametersRtx { ssrc: rtx.ssrc }), + pub(crate) fn from_fbs_ref( + encoding_parameters: rtp_parameters::RtpEncodingParametersRef<'_>, + ) -> Result> { + Ok(Self { + ssrc: encoding_parameters.ssrc()?, + rid: encoding_parameters.rid()?.map(|rid| rid.to_string()), + codec_payload_type: encoding_parameters.codec_payload_type()?, + rtx: if let Some(rtx) = encoding_parameters.rtx()? { + Some(RtpEncodingParametersRtx { ssrc: rtx.ssrc()? }) + } else { + None + }, dtx: { - match encoding_parameters.dtx { + match encoding_parameters.dtx()? { true => Some(true), false => None, } }, scalability_mode: encoding_parameters - .scalability_mode - .unwrap_or(String::from("S1T1")) - .parse() - .unwrap(), - max_bitrate: encoding_parameters.max_bitrate, - } + .scalability_mode()? + .map(|maybe_scalability_mode| maybe_scalability_mode.parse()) + .transpose()? + .unwrap_or_default(), + max_bitrate: encoding_parameters.max_bitrate()?, + }) } } diff --git a/rust/src/worker/channel.rs b/rust/src/worker/channel.rs index a0dd9f8b08..ea24ebe8c3 100644 --- a/rust/src/worker/channel.rs +++ b/rust/src/worker/channel.rs @@ -91,8 +91,14 @@ enum ChannelReceiveMessage<'a> { Event(InternalMessage), } +// Remove the first 4 bytes which represent the buffer size. +// NOTE: The prefix is only needed for NodeJS. +fn unprefix_message(bytes: &[u8]) -> &[u8] { + &bytes[4..] +} + fn deserialize_message(bytes: &[u8]) -> ChannelReceiveMessage<'_> { - let message_ref = message::MessageRef::read_as_root(&bytes[4..]).unwrap(); + let message_ref = message::MessageRef::read_as_root(bytes).unwrap(); match message_ref.data().unwrap() { message::BodyRef::Log(data) => match data.data().unwrap().chars().next() { @@ -126,7 +132,7 @@ struct ResponseError { reason: String, } -type FBSResponseResult = Result, ResponseError>; +type FBSResponseResult = Result>, ResponseError>; struct RequestDropGuard<'a> { id: u32, @@ -239,6 +245,8 @@ impl Channel { move |message| { trace!("received raw message: {}", String::from_utf8_lossy(message)); + let message = unprefix_message(message); + match deserialize_message(message) { ChannelReceiveMessage::Notification(notification) => { let target_id = notification.handler_id().unwrap(); @@ -254,7 +262,7 @@ impl Channel { // target_id if let Some(list) = buffer_notifications_for.get_mut(&target_id) { // Store the whole message removing the size prefix. - list.push(Vec::from(&message[4..])); + list.push(Vec::from(message)); return; } @@ -279,12 +287,8 @@ impl Channel { else { match response.body().expect("failed accessing response body") { // Response has body. - Some(body_ref) => { - let _ = sender.send(Ok(Some( - body_ref - .try_into() - .expect("failed to retrieve response body"), - ))); + Some(_) => { + let _ = sender.send(Ok(Some(Vec::from(message)))); } // Response does not have body. None => { @@ -421,11 +425,25 @@ impl Channel { }; match response_result { - Ok(data) => { + Ok(bytes) => { debug!("request succeeded [method:{:?}, id:{}]", R::METHOD, id); - trace!("{data:?}"); - Ok(R::convert_response(data).map_err(RequestError::ResponseConversion)?) + match bytes { + Some(bytes) => { + let message_ref = message::MessageRef::read_as_root(&bytes).unwrap(); + + let message::BodyRef::Response(response_ref) = message_ref.data().unwrap() + else { + panic!("Wrong response stored: {message_ref:?}"); + }; + + Ok(R::convert_response(response_ref.body().unwrap()) + .map_err(RequestError::ResponseConversion)?) + } + None => { + Ok(R::convert_response(None).map_err(RequestError::ResponseConversion)?) + } + } } Err(ResponseError { reason }) => { debug!( From 7703488fb0dc250bac45fb6b404a553c31d83012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 26 Oct 2023 16:56:45 +0200 Subject: [PATCH 54/73] Node: Add RouterDump and DirectTransportDump types (#1195) Node: Add missing method return types --- node/.eslintrc.js | 1 + node/src/DirectTransport.ts | 4 +- node/src/Router.ts | 58 +++++++++++++++++++++++-- node/src/RtpParameters.ts | 6 +-- node/src/Transport.ts | 6 +-- node/src/WebRtcServer.ts | 76 ++++++++++++++++++++++++++------- node/src/WebRtcTransport.ts | 4 +- node/src/Worker.ts | 24 +++++++++-- node/src/ortc.ts | 2 +- node/src/tests/test-Consumer.ts | 14 +++--- node/src/utils.ts | 56 +++++++++++++++++++++--- worker/fbs/webRtcServer.fbs | 2 +- 12 files changed, 206 insertions(+), 47 deletions(-) diff --git a/node/.eslintrc.js b/node/.eslintrc.js index 61a42372e6..e541c5acd6 100644 --- a/node/.eslintrc.js +++ b/node/.eslintrc.js @@ -183,6 +183,7 @@ const eslintConfig = } ], 'space-in-parens' : [ 2, 'never' ], + 'space-infix-ops' : [ 2, { 'int32Hint': false } ], 'spaced-comment' : [ 2, 'always' ], 'strict' : 2, 'valid-typeof' : 2, diff --git a/node/src/DirectTransport.ts b/node/src/DirectTransport.ts index d5ee0b85fc..99da02ede9 100644 --- a/node/src/DirectTransport.ts +++ b/node/src/DirectTransport.ts @@ -33,6 +33,8 @@ export type DirectTransportOptions /** * Dump Transport. */ - async dump(): Promise + async dump(): Promise { logger.debug('dump()'); diff --git a/node/src/Router.ts b/node/src/Router.ts index 839aa06d0e..edecf0ce4b 100644 --- a/node/src/Router.ts +++ b/node/src/Router.ts @@ -24,7 +24,7 @@ import { RtpCapabilities, RtpCodecCapability } from './RtpParameters'; import { cryptoSuiteToFbs } from './SrtpParameters'; import { NumSctpStreams } from './SctpParameters'; import { AppData, Either } from './types'; -import { generateUUIDv4 } from './utils'; +import { generateUUIDv4, parseVector, parseStringStringVector, parseStringStringArrayVector } from './utils'; import * as FbsActiveSpeakerObserver from './fbs/active-speaker-observer'; import * as FbsAudioLevelObserver from './fbs/audio-level-observer'; import * as FbsRequest from './fbs/request'; @@ -128,6 +128,42 @@ export type PipeToRouterResult = pipeDataProducer?: DataProducer; }; +export type RouterDump = +{ + /** + * The Router id. + */ + id: string; + /** + * Id of Transports. + */ + transportIds: string[]; + /** + * Id of RtpObservers. + */ + rtpObserverIds: string[]; + /** + * Array of Producer id and its respective Consumer ids. + */ + mapProducerIdConsumerIds: { key: string; values: string[] }[]; + /** + * Array of Consumer id and its Producer id. + */ + mapConsumerIdProducerId: {key: string; value: string}[]; + /** + * Array of Producer id and its respective Observer ids. + */ + mapProducerIdObserverIds: {key: string; values: string[]}[]; + /** + * Array of Producer id and its respective DataConsumer ids. + */ + mapDataProducerIdDataConsumerIds: {key: string; values: string[]}[]; + /** + * Array of DataConsumer id and its DataProducer id. + */ + mapDataConsumerIdDataProducerId: {key: string; value: string}[]; +}; + type PipeTransportPair = { [key: string]: PipeTransport; @@ -376,7 +412,7 @@ export class Router /** * Dump Router. */ - async dump(): Promise + async dump(): Promise { logger.debug('dump()'); @@ -393,7 +429,7 @@ export class Router response.body(dump); - return dump.unpack(); + return parseRouterDumpResponse(dump); } /** @@ -1566,3 +1602,19 @@ export class Router } } } + +export function parseRouterDumpResponse( + binary: FbsRouter.DumpResponse +): RouterDump +{ + return { + id : binary.id()!, + transportIds : parseVector(binary, 'transportIds'), + rtpObserverIds : parseVector(binary, 'rtpObserverIds'), + mapProducerIdConsumerIds : parseStringStringArrayVector(binary, 'mapProducerIdConsumerIds'), + mapConsumerIdProducerId : parseStringStringVector(binary, 'mapConsumerIdProducerId'), + mapProducerIdObserverIds : parseStringStringArrayVector(binary, 'mapProducerIdObserverIds'), + mapDataProducerIdDataConsumerIds : parseStringStringArrayVector(binary, 'mapDataProducerIdDataConsumerIds'), + mapDataConsumerIdDataProducerId : parseStringStringVector(binary, 'mapDataConsumerIdDataProducerId') + }; +} diff --git a/node/src/RtpParameters.ts b/node/src/RtpParameters.ts index 532fb014b2..760aaa15c8 100644 --- a/node/src/RtpParameters.ts +++ b/node/src/RtpParameters.ts @@ -396,7 +396,7 @@ export function serializeRtpParameters( const rtcpFeedback: number[] = []; - for (const rtcp of codec.rtcpFeedback?? []) + for (const rtcp of codec.rtcpFeedback ?? []) { const typeOffset = builder.createString(rtcp.type); const rtcpParametersOffset = builder.createString(rtcp.parameter); @@ -575,7 +575,7 @@ export function serializeParameters( if (typeof value === 'boolean') { parameterOffset = FbsParameter.createParameter( - builder, keyOffset, FbsValue.Boolean, value === true ? 1:0 + builder, keyOffset, FbsValue.Boolean, value === true ? 1 : 0 ); } else if (typeof value === 'number') @@ -638,7 +638,7 @@ export function parseParameters(data: any): any { const parameters: any = {}; - for (let i=0; i { // Should not happen. - throw new Error('method not implemented in the subclass'); + throw new Error('method implemented in the subclass'); } /** @@ -610,7 +610,7 @@ export class Transport async getStats(): Promise { // Should not happen. - throw new Error('method not implemented in the subclass'); + throw new Error('method implemented in the subclass'); } /** @@ -622,7 +622,7 @@ export class Transport async connect(params: any): Promise { // Should not happen. - throw new Error('method not implemented in the subclass'); + throw new Error('method implemented in the subclass'); } /** diff --git a/node/src/WebRtcServer.ts b/node/src/WebRtcServer.ts index 8e1547a8be..ad45f9e179 100644 --- a/node/src/WebRtcServer.ts +++ b/node/src/WebRtcServer.ts @@ -29,7 +29,7 @@ export type WebRtcServerOptions = export type WebRtcServerListenInfo = TransportListenInfo; export type WebRtcServerEvents = -{ +{ workerclose: []; // Private events. '@close': []; @@ -42,6 +42,34 @@ export type WebRtcServerObserverEvents = webrtctransportunhandled: [WebRtcTransport]; }; +export type WebRtcServerDump = +{ + id: string; + udpSockets: IpPort[]; + tcpServers: IpPort[]; + webRtcTransportIds: string[]; + localIceUsernameFragments: IceUserNameFragment[]; + tupleHashes: TupleHash[]; +}; + +type IpPort = +{ + ip: string; + port: number; +}; + +type IceUserNameFragment = +{ + localIceUsernameFragment: string; + webRtcTransportId: string; +}; + +type TupleHash = +{ + tupleHash: number; + webRtcTransportId: string; +}; + type WebRtcServerInternal = { webRtcServerId: string; @@ -213,7 +241,7 @@ export class WebRtcServer /** * Dump WebRtcServer. */ - async dump(): Promise + async dump(): Promise { logger.debug('dump()'); @@ -248,32 +276,48 @@ export class WebRtcServer } } -// TODO: This function should return WebRtcServerDump TypeScript type but we -// don't have it yet (same for many other dump() methods everywhere). +function parseIpPort(binary: FbsWebRtcServer.IpPort): IpPort +{ + return { + ip : binary.ip()!, + port : binary.port() + }; +} + +function parseIceUserNameFragment(binary: FbsWebRtcServer.IceUserNameFragment): IceUserNameFragment +{ + return { + localIceUsernameFragment : binary.localIceUsernameFragment()!, + webRtcTransportId : binary.webRtcTransportId()! + }; +} + +function parseTupleHash(binary: FbsWebRtcServer.TupleHash): TupleHash +{ + return { + tupleHash : Number(binary.tupleHash()!), + webRtcTransportId : binary.webRtcTransportId()! + }; +} + function parseWebRtcServerDump( data: FbsWebRtcServer.DumpResponse -): any +): WebRtcServerDump { return { - id : data.id(), + id : data.id()!, udpSockets : utils.parseVector( - data, 'udpSockets', (udpSocket: any) => udpSocket.unpack() + data, 'udpSockets', parseIpPort ), tcpServers : utils.parseVector( - data, 'tcpServers', (tcpServer: any) => tcpServer.unpack() + data, 'tcpServers', parseIpPort ), webRtcTransportIds : utils.parseVector(data, 'webRtcTransportIds'), localIceUsernameFragments : utils.parseVector( - data, 'localIceUsernameFragments', (localIceUsernameFragment: any) => localIceUsernameFragment.unpack() + data, 'localIceUsernameFragments', parseIceUserNameFragment ), tupleHashes : utils.parseVector( - data, 'tupleHashes', (tupleHash: any) => - { - return { - localIceUsernameFragment : Number(tupleHash.localIceUsernameFragment()), - webRtcTransportId : tupleHash.webRtcTransportId() - }; - } + data, 'tupleHashes', parseTupleHash ) }; } diff --git a/node/src/WebRtcTransport.ts b/node/src/WebRtcTransport.ts index 9ef9b49b57..96b5165035 100644 --- a/node/src/WebRtcTransport.ts +++ b/node/src/WebRtcTransport.ts @@ -864,7 +864,7 @@ function parseDtlsParameters(binary: FbsWebRtcTransport.DtlsParameters): DtlsPar { const fingerprints: DtlsFingerprint[] = []; - for (let i=0; i /** * Dump Worker. */ - async dump(): Promise + async dump(): Promise { logger.debug('dump()'); @@ -595,7 +595,7 @@ export class Worker response.body(dump); - return dump.unpack(); + return parseWorkerDumpResponse(dump); } /** @@ -807,3 +807,19 @@ export class Worker this.#observer.safeEmit('close'); } } + +export function parseWorkerDumpResponse( + binary: FbsWorker.DumpResponse +): WorkerDump +{ + return { + pid : binary.pid()!, + webRtcServerIds : parseVector(binary, 'webRtcServerIds'), + routerIds : parseVector(binary, 'routerIds'), + channelMessageHandlers : + { + channelRequestHandlers : parseVector(binary.channelMessageHandlers()!, 'channelRequestHandlers'), + channelNotificationHandlers : parseVector(binary.channelMessageHandlers()!, 'channelNotificationHandlers') + } + }; +} diff --git a/node/src/ortc.ts b/node/src/ortc.ts index ba8d5f772a..dad1cf9c1b 100644 --- a/node/src/ortc.ts +++ b/node/src/ortc.ts @@ -1169,7 +1169,7 @@ export function getConsumerRtpParameters( } // Must sanitize the list of matched codecs by removing useless RTX codecs. - for (let idx = consumerParams.codecs.length -1; idx >= 0; --idx) + for (let idx = consumerParams.codecs.length - 1; idx >= 0; --idx) { const codec = consumerParams.codecs[idx]; diff --git a/node/src/tests/test-Consumer.ts b/node/src/tests/test-Consumer.ts index 642db30836..3723019460 100644 --- a/node/src/tests/test-Consumer.ts +++ b/node/src/tests/test-Consumer.ts @@ -1009,27 +1009,27 @@ test('consumer.close() succeeds', async () => expect(onObserverClose).toHaveBeenCalledTimes(1); expect(audioConsumer.closed).toBe(true); - let dump = await router.dump(); + const routerDump = await router.dump(); - expect(dump.mapProducerIdConsumerIds) + expect(routerDump.mapProducerIdConsumerIds) .toEqual(expect.arrayContaining([ { key: audioProducer.id, values: [ ] } ])); - expect(dump.mapConsumerIdProducerId) + expect(routerDump.mapConsumerIdProducerId) .toEqual(expect.arrayContaining([ { key: videoConsumer.id, value: videoProducer.id } ])); - expect(dump.mapConsumerIdProducerId) + expect(routerDump.mapConsumerIdProducerId) .toEqual(expect.arrayContaining([ { key: videoPipeConsumer.id, value: videoProducer.id } ])); - dump = await transport2.dump(); + const transportDump = await transport2.dump(); - dump.consumerIds = dump.consumerIds.sort(); + transportDump.consumerIds = transportDump.consumerIds.sort(); - expect(dump) + expect(transportDump) .toMatchObject( { id : transport2.id, diff --git a/node/src/utils.ts b/node/src/utils.ts index 72c736e03d..6f9ad900d2 100644 --- a/node/src/utils.ts +++ b/node/src/utils.ts @@ -76,7 +76,7 @@ export function parseVector( { const array: Type[] = []; - for (let i=0; i( return array; } +/** + * Parse flatbuffers vector of StringString into the corresponding array. + */ +export function parseStringStringVector( + binary: any, methodName: string +): { key: string; value: string }[] +{ + const array: { key: string; value: string }[] = []; + + for (let i = 0; i < binary[`${methodName}Length`](); ++i) + { + const kv = binary[methodName](i)!; + + array.push({ key: kv.key(), value: kv.value() }); + } + + return array; +} + /** * Parse flatbuffers vector of StringUint8 into the corresponding array. */ @@ -100,7 +119,7 @@ export function parseStringUint8Vector( { const array: {key: string; value: number}[] = []; - for (let i=0; i Date: Thu, 26 Oct 2023 17:13:50 +0200 Subject: [PATCH 55/73] [flatbuffers] Fix wrong usage of fs.readdirSync() in Node 20 (#1197) Same as https://github.com/versatica/mediasoup-client/pull/283 --- npm-scripts.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/npm-scripts.mjs b/npm-scripts.mjs index de080af5b1..6403f1adc9 100644 --- a/npm-scripts.mjs +++ b/npm-scripts.mjs @@ -279,7 +279,7 @@ function replaceVersion() const files = fs.readdirSync('node/lib', { withFileTypes : true, - recursive : false + recursive : true }); for (const file of files) @@ -289,7 +289,8 @@ function replaceVersion() continue; } - const filePath = path.join('node/lib', file.name); + // NOTE: dirent.path is only available in Node >= 20. + const filePath = path.join(file.path ?? 'node/lib', file.name); const text = fs.readFileSync(filePath, { encoding: 'utf8' }); const result = text.replace(/__MEDIASOUP_VERSION__/g, PKG.version); From 5870f7e0c0654213346ae97ce1aaf07f0214a6e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Fri, 27 Oct 2023 12:17:03 +0200 Subject: [PATCH 56/73] [flatbuffers] Remove '__MEDIASOUP_VERSION__' replacement in JS transpiled files (#1198) - Instead of writing into all transpiled JS files in `node/lib/`, read `package.json` just once in launch time and read "version" from it. - I'm not happy with this, not sure if better than before. But clearly we are gonna remove this useless `mediasoup.version` public getter in v4. --- node/src/Worker.ts | 3 ++- node/src/index.ts | 10 +++++++--- node/src/tests/test-mediasoup.ts | 12 ++++++++++++ npm-scripts.mjs | 30 ------------------------------ 4 files changed, 21 insertions(+), 34 deletions(-) diff --git a/node/src/Worker.ts b/node/src/Worker.ts index 5e4f5f7805..d4e930970c 100644 --- a/node/src/Worker.ts +++ b/node/src/Worker.ts @@ -1,6 +1,7 @@ import * as process from 'node:process'; import * as path from 'node:path'; import { spawn, ChildProcess } from 'node:child_process'; +import { version } from './'; import { Logger } from './Logger'; import { EnhancedEventEmitter } from './EnhancedEventEmitter'; import * as ortc from './ortc'; @@ -334,7 +335,7 @@ export class Worker { env : { - MEDIASOUP_VERSION : '__MEDIASOUP_VERSION__', + MEDIASOUP_VERSION : version, // Let the worker process inherit all environment variables, useful // if a custom and not in the path GCC is used so the user can set // LD_LIBRARY_PATH environment variable for runtime. diff --git a/node/src/index.ts b/node/src/index.ts index c0cf76ba4d..4277b665d9 100644 --- a/node/src/index.ts +++ b/node/src/index.ts @@ -1,3 +1,5 @@ +import * as fs from 'node:fs'; +import * as path from 'node:path'; import { Logger } from './Logger'; import { EnhancedEventEmitter } from './EnhancedEventEmitter'; import { workerBin, Worker, WorkerSettings } from './Worker'; @@ -14,15 +16,15 @@ export { types }; /** * Expose mediasoup version. */ -export const version = '__MEDIASOUP_VERSION__'; +export const { version } = JSON.parse(fs.readFileSync( + path.join(__dirname, '..', '..', 'package.json'), { encoding: 'utf-8' } +)); /** * Expose parseScalabilityMode() function. */ export { parse as parseScalabilityMode } from './scalabilityModes'; -const logger = new Logger(); - export type ObserverEvents = { newworker: [Worker]; @@ -40,6 +42,8 @@ export { observer }; */ export { workerBin }; +const logger = new Logger(); + /** * Create a Worker. */ diff --git a/node/src/tests/test-mediasoup.ts b/node/src/tests/test-mediasoup.ts index ea080b7bb6..0032e49322 100644 --- a/node/src/tests/test-mediasoup.ts +++ b/node/src/tests/test-mediasoup.ts @@ -1,10 +1,22 @@ +import * as fs from 'node:fs'; +import * as path from 'node:path'; import * as mediasoup from '../'; +const PKG = JSON.parse(fs.readFileSync( + path.join(__dirname, '..', '..', '..', 'package.json'), { encoding: 'utf-8' }) +); + const { + version, getSupportedRtpCapabilities, parseScalabilityMode } = mediasoup; +test('mediasoup.version matches version field in package.json', () => +{ + expect(version).toBe(PKG.version); +}); + test('mediasoup.getSupportedRtpCapabilities() returns the mediasoup RTP capabilities', () => { const rtpCapabilities = getSupportedRtpCapabilities(); diff --git a/npm-scripts.mjs b/npm-scripts.mjs index 6403f1adc9..290a4b3a5d 100644 --- a/npm-scripts.mjs +++ b/npm-scripts.mjs @@ -96,7 +96,6 @@ async function run() { installNodeDeps(); buildTypescript(/* force */ true); - replaceVersion(); break; } @@ -161,7 +160,6 @@ async function run() case 'test:node': { buildTypescript(/* force */ false); - replaceVersion(); testNode(); break; @@ -177,7 +175,6 @@ async function run() case 'coverage:node': { buildTypescript(/* force */ false); - replaceVersion(); executeCmd('jest --coverage'); executeCmd('open-cli coverage/lcov-report/index.html'); @@ -272,32 +269,6 @@ async function run() } } -function replaceVersion() -{ - logInfo('replaceVersion()'); - - const files = fs.readdirSync('node/lib', - { - withFileTypes : true, - recursive : true - }); - - for (const file of files) - { - if (!file.isFile()) - { - continue; - } - - // NOTE: dirent.path is only available in Node >= 20. - const filePath = path.join(file.path ?? 'node/lib', file.name); - const text = fs.readFileSync(filePath, { encoding: 'utf8' }); - const result = text.replace(/__MEDIASOUP_VERSION__/g, PKG.version); - - fs.writeFileSync(filePath, result, { encoding: 'utf8' }); - } -} - function deleteNodeLib() { if (!fs.existsSync('node/lib')) @@ -463,7 +434,6 @@ function checkRelease() installNodeDeps(); flatcNode(); buildTypescript(/* force */ true); - replaceVersion(); buildWorker(); lintNode(); lintWorker(); From 19c5f9472602dffdda12179331a42ebc7e2a8c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Fri, 27 Oct 2023 12:52:51 +0200 Subject: [PATCH 57/73] art/mediasoup-v3-architecture-01.svg: rename PlainRtpTransport to PlainTransport --- art/mediasoup-v3-architecture-01.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/art/mediasoup-v3-architecture-01.svg b/art/mediasoup-v3-architecture-01.svg index 9613ddb17f..89966d0f70 100644 --- a/art/mediasoup-v3-architecture-01.svg +++ b/art/mediasoup-v3-architecture-01.svg @@ -1,2 +1,2 @@ -
Host
Host
Worker 1
Worker 1
WebRtcTransport
WebRtcTransport
Audio Producer
Audio Producer
Video Producer
Video Producer
PlainRtpTransport
PlainRtpTransport
Video Producer
Video Producer
PipeTransport
PipeTransport
Video Consumer
Video Consumer
SRTPSRTP
Participant
(mic/webcam on)
Participant<br>(mic/webcam on)<br>
Participant
(viewer)
[Not supported by viewer]
RTP
FFmpeg
(recording)
[Not supported by viewer]
GStreamer
(mp4 broadcaster)
GStreamer<br>(mp4 broadcaster)<br>
RTP
Router 2
Router 2
Router 1
Router 1
Worker 2
Worker 2
PipeTransport
PipeTransport
Video Consumer
Video Consumer
Router 3
Router 3
PipeTransport
PipeTransport
Video Producer
Video Producer
Worker 3
Worker 3
PipeTransport
PipeTransport
Video Producer
Video Producer
Router 4
Router 4
RTPRTP
Participant
(viewer)
[Not supported by viewer]
Participant
(viewer)
[Not supported by viewer]
SRTPSRTPSRTP
Participant
(viewer)
[Not supported by viewer]
WebRtcTransport
WebRtcTransport
Video Consumer
Video Consumer
WebRtcTransport
WebRtcTransport
Video Consumer
Video Consumer
WebRtcTransport
WebRtcTransport
Video Consumer
Video Consumer
WebRtcTransport
WebRtcTransport
Video Consumer
Video Consumer
Participant
(viewer)
[Not supported by viewer]
SRTP
WebRtcTransport
WebRtcTransport
Audio Consumer
Audio Consumer
Video Consumer
Video Consumer
PlainRtpTransport
PlainRtpTransport
Audio Consumer
Audio Consumer
\ No newline at end of file +
Host
Host
Worker 1
Worker 1
WebRtcTransport
WebRtcTransport
Audio Producer
Audio Producer
Video Producer
Video Producer
PlainTransport
PlainTransport
Video Producer
Video Producer
PipeTransport
PipeTransport
Video Consumer
Video Consumer
SRTPSRTP
Participant
(mic/webcam on)
Participant<br>(mic/webcam on)<br>
Participant
(viewer)
[Not supported by viewer]
RTP
FFmpeg
(recording)
[Not supported by viewer]
GStreamer
(mp4 broadcaster)
GStreamer<br>(mp4 broadcaster)<br>
RTP
Router 2
Router 2
Router 1
Router 1
Worker 2
Worker 2
PipeTransport
PipeTransport
Video Consumer
Video Consumer
Router 3
Router 3
PipeTransport
PipeTransport
Video Producer
Video Producer
Worker 3
Worker 3
PipeTransport
PipeTransport
Video Producer
Video Producer
Router 4
Router 4
RTPRTP
Participant
(viewer)
[Not supported by viewer]
Participant
(viewer)
[Not supported by viewer]
SRTPSRTPSRTP
Participant
(viewer)
[Not supported by viewer]
WebRtcTransport
WebRtcTransport
Video Consumer
Video Consumer
WebRtcTransport
WebRtcTransport
Video Consumer
Video Consumer
WebRtcTransport
WebRtcTransport
Video Consumer
Video Consumer
WebRtcTransport
WebRtcTransport
Video Consumer
Video Consumer
Participant
(viewer)
[Not supported by viewer]
SRTP
WebRtcTransport
WebRtcTransport
Audio Consumer
Audio Consumer
Video Consumer
Video Consumer
PlainTransport
PlainTransport
Audio Consumer
Audio Consumer
From b7363fdc3bd0f7894880fd040d5c27010e466c58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Fri, 27 Oct 2023 14:04:38 +0200 Subject: [PATCH 58/73] Fix unfortunate name in worker/scripts/package.json --- worker/scripts/package-lock.json | 4 ++-- worker/scripts/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/worker/scripts/package-lock.json b/worker/scripts/package-lock.json index 67dcc5cdc0..be2dde4032 100644 --- a/worker/scripts/package-lock.json +++ b/worker/scripts/package-lock.json @@ -1,11 +1,11 @@ { - "name": "clang-tools", + "name": "mediasoup-worker-dev-tools", "version": "0.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "clang-tools", + "name": "mediasoup-worker-dev-tools", "version": "0.0.1", "devDependencies": { "clang-tools-prebuilt": "^0.1.4", diff --git a/worker/scripts/package.json b/worker/scripts/package.json index 24b90f7874..fc42fde271 100644 --- a/worker/scripts/package.json +++ b/worker/scripts/package.json @@ -1,5 +1,5 @@ { - "name": "clang-tools", + "name": "mediasoup-worker-dev-tools", "version": "0.0.1", "description": "mediasoup worker dev tools", "devDependencies": { From 1f0f4a1b29914ebe5005b5c351d5bf3674982ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Fri, 27 Oct 2023 15:27:58 +0200 Subject: [PATCH 59/73] FBS: Data[Consumer|Producer] Send() simplifyfication (#1199) FBS: Simplify Data[Consumer|Producer] send messages For some reason we were not sending everything as binary in this branch. --- node/src/DataConsumer.ts | 13 +- node/src/DataProducer.ts | 13 +- rust/src/fbs.rs | 4324 +++++++++++-------------------- rust/src/messages.rs | 10 +- worker/fbs/dataConsumer.fbs | 15 +- worker/fbs/dataProducer.fbs | 15 +- worker/src/RTC/DataConsumer.cpp | 21 +- worker/src/RTC/DataProducer.cpp | 17 +- 8 files changed, 1493 insertions(+), 2935 deletions(-) diff --git a/node/src/DataConsumer.ts b/node/src/DataConsumer.ts index 9d257ab7b5..17a41dd41d 100644 --- a/node/src/DataConsumer.ts +++ b/node/src/DataConsumer.ts @@ -517,23 +517,14 @@ export class DataConsumer if (typeof message === 'string') { - const messageOffset = builder.createString(message); - - dataOffset = FbsDataConsumer.String.createString(builder, messageOffset); + message = Buffer.from(message); } - else - { - const messageOffset = FbsDataConsumer.Binary.createValueVector(builder, message); - dataOffset = FbsDataConsumer.Binary.createBinary(builder, messageOffset); - } + dataOffset = FbsDataConsumer.SendRequest.createDataVector(builder, message); const requestOffset = FbsDataConsumer.SendRequest.createSendRequest( builder, ppid, - typeof message === 'string' ? - FbsDataConsumer.Data.String : - FbsDataConsumer.Data.Binary, dataOffset ); diff --git a/node/src/DataProducer.ts b/node/src/DataProducer.ts index 43f48a09bd..26fc8efd81 100644 --- a/node/src/DataProducer.ts +++ b/node/src/DataProducer.ts @@ -442,23 +442,14 @@ export class DataProducer if (typeof message === 'string') { - const messageOffset = builder.createString(message); - - dataOffset = FbsDataProducer.String.createString(builder, messageOffset); + message = Buffer.from(message); } - else - { - const messageOffset = FbsDataProducer.Binary.createValueVector(builder, message); - dataOffset = FbsDataProducer.Binary.createBinary(builder, messageOffset); - } + dataOffset = FbsDataProducer.SendNotification.createDataVector(builder, message); const notificationOffset = FbsDataProducer.SendNotification.createSendNotification( builder, ppid, - typeof message === 'string' ? - FbsDataProducer.Data.String : - FbsDataProducer.Data.Binary, dataOffset, subchannelsOffset, requiredSubchannel ?? null diff --git a/rust/src/fbs.rs b/rust/src/fbs.rs index e883f180e0..3438014f03 100644 --- a/rust/src/fbs.rs +++ b/rust/src/fbs.rs @@ -25333,10 +25333,10 @@ mod root { } } - /// The table `String` in the namespace `FBS.DataConsumer` + /// The table `SendRequest` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `String` in the file `../worker/fbs/dataConsumer.fbs:37` + /// * Table `SendRequest` in the file `../worker/fbs/dataConsumer.fbs:37` #[derive( Clone, Debug, @@ -25348,163 +25348,226 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct String { - /// The field `value` in the table `String` - pub value: ::planus::alloc::string::String, + 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 String { - /// Creates a [StringBuilder] for serializing an instance of this table. + impl SendRequest { + /// Creates a [SendRequestBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> StringBuilder<()> { - StringBuilder(()) + pub fn builder() -> SendRequestBuilder<()> { + SendRequestBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_value: impl ::planus::WriteAs<::planus::Offset>, + field_ppid: impl ::planus::WriteAsDefault, + field_data: impl ::planus::WriteAs<::planus::Offset<[u8]>>, ) -> ::planus::Offset { - let prepared_value = field_value.prepare(builder); + let prepared_ppid = field_ppid.prepare(builder, &0); + let prepared_data = field_data.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<6> = + let mut table_writer: ::planus::table_writer::TableWriter<8> = ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset>(0); + 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| { - object_writer.write::<_, _, 4>(&prepared_value); + 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 String { + impl ::planus::WriteAs<::planus::Offset> for SendRequest { type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for String { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for String { + impl ::planus::WriteAsOffset for SendRequest { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - String::create(builder, &self.value) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SendRequest::create(builder, self.ppid, &self.data) } } - /// Builder for serializing an instance of the [String] type. + /// Builder for serializing an instance of the [SendRequest] type. /// - /// Can be created using the [String::builder] method. + /// Can be created using the [SendRequest::builder] method. #[derive(Debug)] #[must_use] - pub struct StringBuilder(State); + pub struct SendRequestBuilder(State); - impl StringBuilder<()> { - /// Setter for the [`value` field](String#structfield.value). + impl SendRequestBuilder<()> { + /// Setter for the [`ppid` field](SendRequest#structfield.ppid). #[inline] #[allow(clippy::type_complexity)] - pub fn value(self, value: T0) -> StringBuilder<(T0,)> + pub fn ppid(self, value: T0) -> SendRequestBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset>, + T0: ::planus::WriteAsDefault, { - StringBuilder((value,)) + 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 StringBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [String]. + impl SendRequestBuilder<(T0,)> { + /// Setter for the [`data` field](SendRequest#structfield.data). #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::Offset + #[allow(clippy::type_complexity)] + pub fn data(self, value: T1) -> SendRequestBuilder<(T0, T1)> where - Self: ::planus::WriteAsOffset, + 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>> - ::planus::WriteAs<::planus::Offset> for StringBuilder<(T0,)> + impl< + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAs<::planus::Offset<[u8]>>, + > ::planus::WriteAs<::planus::Offset> + for SendRequestBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl>> - ::planus::WriteAsOptional<::planus::Offset> for StringBuilder<(T0,)> + impl< + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAs<::planus::Offset<[u8]>>, + > ::planus::WriteAsOptional<::planus::Offset> + for SendRequestBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl>> ::planus::WriteAsOffset - for StringBuilder<(T0,)> + 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,) = &self.0; - String::create(builder, v0) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + let (v0, v1) = &self.0; + SendRequest::create(builder, v0, v1) } } - /// Reference to a deserialized [String]. + /// Reference to a deserialized [SendRequest]. #[derive(Copy, Clone)] - pub struct StringRef<'a>(::planus::table_reader::Table<'a>); + pub struct SendRequestRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> StringRef<'a> { - /// Getter for the [`value` field](String#structfield.value). + impl<'a> SendRequestRef<'a> { + /// Getter for the [`ppid` field](SendRequest#structfield.ppid). #[inline] - pub fn value(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(0, "String", "value") + 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 StringRef<'a> { + 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("StringRef"); - f.field("value", &self.value()); + 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 String { + impl<'a> ::core::convert::TryFrom> for SendRequest { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: StringRef<'a>) -> ::planus::Result { + fn try_from(value: SendRequestRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - value: ::core::convert::TryInto::try_into(value.value()?)?, + ppid: ::core::convert::TryInto::try_into(value.ppid()?)?, + data: value.data()?.to_vec(), }) } } - impl<'a> ::planus::TableRead<'a> for StringRef<'a> { + impl<'a> ::planus::TableRead<'a> for SendRequestRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -25516,7 +25579,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for StringRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for SendRequestRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -25526,7 +25589,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[StringRef]", + "[SendRequestRef]", "get", buffer.offset_from_start, ) @@ -25534,8 +25597,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for String { - type Value = ::planus::Offset; + 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 { @@ -25544,7 +25607,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -25559,7 +25622,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for StringRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for SendRequestRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -25569,15 +25632,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[StringRef]", "read_as_root", 0) + error_kind.with_error_location("[SendRequestRef]", "read_as_root", 0) }) } } - /// The table `Binary` in the namespace `FBS.DataConsumer` + /// The table `SetSubchannelsRequest` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `Binary` in the file `../worker/fbs/dataConsumer.fbs:41` + /// * Table `SetSubchannelsRequest` in the file `../worker/fbs/dataConsumer.fbs:42` #[derive( Clone, Debug, @@ -25589,163 +25652,184 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct Binary { - /// The field `value` in the table `Binary` - pub value: ::planus::alloc::vec::Vec, + pub struct SetSubchannelsRequest { + /// The field `subchannels` in the table `SetSubchannelsRequest` + pub subchannels: ::planus::alloc::vec::Vec, } - impl Binary { - /// Creates a [BinaryBuilder] for serializing an instance of this table. + impl SetSubchannelsRequest { + /// Creates a [SetSubchannelsRequestBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> BinaryBuilder<()> { - BinaryBuilder(()) + pub fn builder() -> SetSubchannelsRequestBuilder<()> { + SetSubchannelsRequestBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_value: impl ::planus::WriteAs<::planus::Offset<[u8]>>, + field_subchannels: impl ::planus::WriteAs<::planus::Offset<[u16]>>, ) -> ::planus::Offset { - let prepared_value = field_value.prepare(builder); + 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<[u8]>>(0); + table_writer.write_entry::<::planus::Offset<[u16]>>(0); unsafe { table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_value); + object_writer.write::<_, _, 4>(&prepared_subchannels); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for Binary { + impl ::planus::WriteAs<::planus::Offset> for SetSubchannelsRequest { type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for Binary { + 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<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for Binary { + impl ::planus::WriteAsOffset for SetSubchannelsRequest { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Binary::create(builder, &self.value) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { + SetSubchannelsRequest::create(builder, &self.subchannels) } } - /// Builder for serializing an instance of the [Binary] type. + /// Builder for serializing an instance of the [SetSubchannelsRequest] type. /// - /// Can be created using the [Binary::builder] method. + /// Can be created using the [SetSubchannelsRequest::builder] method. #[derive(Debug)] #[must_use] - pub struct BinaryBuilder(State); + pub struct SetSubchannelsRequestBuilder(State); - impl BinaryBuilder<()> { - /// Setter for the [`value` field](Binary#structfield.value). + impl SetSubchannelsRequestBuilder<()> { + /// Setter for the [`subchannels` field](SetSubchannelsRequest#structfield.subchannels). #[inline] #[allow(clippy::type_complexity)] - pub fn value(self, value: T0) -> BinaryBuilder<(T0,)> + pub fn subchannels(self, value: T0) -> SetSubchannelsRequestBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset<[u8]>>, + T0: ::planus::WriteAs<::planus::Offset<[u16]>>, { - BinaryBuilder((value,)) + SetSubchannelsRequestBuilder((value,)) } } - impl BinaryBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Binary]. + 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 + pub fn finish( + self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl>> - ::planus::WriteAs<::planus::Offset> for BinaryBuilder<(T0,)> + impl>> + ::planus::WriteAs<::planus::Offset> + for SetSubchannelsRequestBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl>> - ::planus::WriteAsOptional<::planus::Offset> for BinaryBuilder<(T0,)> + impl>> + ::planus::WriteAsOptional<::planus::Offset> + for SetSubchannelsRequestBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl>> ::planus::WriteAsOffset - for BinaryBuilder<(T0,)> + impl>> + ::planus::WriteAsOffset + for SetSubchannelsRequestBuilder<(T0,)> { #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset { let (v0,) = &self.0; - Binary::create(builder, v0) + SetSubchannelsRequest::create(builder, v0) } } - /// Reference to a deserialized [Binary]. + /// Reference to a deserialized [SetSubchannelsRequest]. #[derive(Copy, Clone)] - pub struct BinaryRef<'a>(::planus::table_reader::Table<'a>); + pub struct SetSubchannelsRequestRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> BinaryRef<'a> { - /// Getter for the [`value` field](Binary#structfield.value). + impl<'a> SetSubchannelsRequestRef<'a> { + /// Getter for the [`subchannels` field](SetSubchannelsRequest#structfield.subchannels). #[inline] - pub fn value(&self) -> ::planus::Result<&'a [u8]> { - self.0.access_required(0, "Binary", "value") + pub fn subchannels(&self) -> ::planus::Result<::planus::Vector<'a, u16>> { + self.0 + .access_required(0, "SetSubchannelsRequest", "subchannels") } } - impl<'a> ::core::fmt::Debug for BinaryRef<'a> { + 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("BinaryRef"); - f.field("value", &self.value()); + let mut f = f.debug_struct("SetSubchannelsRequestRef"); + f.field("subchannels", &self.subchannels()); f.finish() } } - impl<'a> ::core::convert::TryFrom> for Binary { + impl<'a> ::core::convert::TryFrom> for SetSubchannelsRequest { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: BinaryRef<'a>) -> ::planus::Result { + fn try_from(value: SetSubchannelsRequestRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - value: value.value()?.to_vec(), + subchannels: value.subchannels()?.to_vec()?, }) } } - impl<'a> ::planus::TableRead<'a> for BinaryRef<'a> { + impl<'a> ::planus::TableRead<'a> for SetSubchannelsRequestRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -25757,7 +25841,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for BinaryRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for SetSubchannelsRequestRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -25767,7 +25851,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[BinaryRef]", + "[SetSubchannelsRequestRef]", "get", buffer.offset_from_start, ) @@ -25775,8 +25859,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for Binary { - type Value = ::planus::Offset; + 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 { @@ -25785,7 +25869,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -25800,7 +25884,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for BinaryRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for SetSubchannelsRequestRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -25810,15 +25894,19 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[BinaryRef]", "read_as_root", 0) + error_kind.with_error_location( + "[SetSubchannelsRequestRef]", + "read_as_root", + 0, + ) }) } } - /// The union `Data` in the namespace `FBS.DataConsumer` + /// The table `SetSubchannelsResponse` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Union `Data` in the file `../worker/fbs/dataConsumer.fbs:45` + /// * Table `SetSubchannelsResponse` in the file `../worker/fbs/dataConsumer.fbs:46` #[derive( Clone, Debug, @@ -25830,421 +25918,489 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub enum Data { - /// The variant of type `String` in the union `Data` - String(::planus::alloc::boxed::Box), - - /// The variant of type `Binary` in the union `Data` - Binary(::planus::alloc::boxed::Box), + pub struct SetSubchannelsResponse { + /// The field `subchannels` in the table `SetSubchannelsResponse` + pub subchannels: ::planus::alloc::vec::Vec, } - impl Data { - /// Creates a [DataBuilder] for serializing an instance of this table. + impl SetSubchannelsResponse { + /// Creates a [SetSubchannelsResponseBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> DataBuilder<::planus::Uninitialized> { - DataBuilder(::planus::Uninitialized) + pub fn builder() -> SetSubchannelsResponseBuilder<()> { + SetSubchannelsResponseBuilder(()) } - #[inline] - pub fn create_string( + #[allow(clippy::too_many_arguments)] + pub fn create( builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + 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] - pub fn create_binary( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsUnion for Data { + impl ::planus::WriteAsOptional<::planus::Offset> + for SetSubchannelsResponse + { + type Prepared = ::planus::Offset; + #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - match self { - Self::String(value) => Self::create_string(builder, value), - Self::Binary(value) => Self::create_binary(builder, value), - } + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> + { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOptionalUnion for Data { + impl ::planus::WriteAsOffset for SetSubchannelsResponse { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Offset { + SetSubchannelsResponse::create(builder, &self.subchannels) } } - /// Builder for serializing an instance of the [Data] type. + /// Builder for serializing an instance of the [SetSubchannelsResponse] type. /// - /// Can be created using the [Data::builder] method. + /// Can be created using the [SetSubchannelsResponse::builder] method. #[derive(Debug)] #[must_use] - pub struct DataBuilder(T); - - impl DataBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`String` variant](Data#variant.String). - #[inline] - pub fn string(self, value: T) -> DataBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { - DataBuilder(::planus::Initialized(value)) - } + pub struct SetSubchannelsResponseBuilder(State); - /// Creates an instance of the [`Binary` variant](Data#variant.Binary). + impl SetSubchannelsResponseBuilder<()> { + /// Setter for the [`subchannels` field](SetSubchannelsResponse#structfield.subchannels). #[inline] - pub fn binary(self, value: T) -> DataBuilder<::planus::Initialized<2, T>> + #[allow(clippy::type_complexity)] + pub fn subchannels(self, value: T0) -> SetSubchannelsResponseBuilder<(T0,)> where - T: ::planus::WriteAsOffset, + T0: ::planus::WriteAs<::planus::Offset<[u16]>>, { - DataBuilder(::planus::Initialized(value)) + SetSubchannelsResponseBuilder((value,)) } } - impl DataBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Data]. + 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::UnionOffset + pub fn finish( + self, + builder: &mut ::planus::Builder, + ) -> ::planus::Offset where - Self: ::planus::WriteAsUnion, + Self: ::planus::WriteAsOffset, { - ::planus::WriteAsUnion::prepare(&self, builder) + ::planus::WriteAsOffset::prepare(&self, builder) } } - impl ::planus::WriteAsUnion for DataBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, + impl>> + ::planus::WriteAs<::planus::Offset> + for SetSubchannelsResponseBuilder<(T0,)> { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) - } - } + type Prepared = ::planus::Offset; - impl ::planus::WriteAsOptionalUnion for DataBuilder<::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)) + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsUnion for DataBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, + + impl>> + ::planus::WriteAsOptional<::planus::Offset> + for SetSubchannelsResponseBuilder<(T0,)> { + type Prepared = ::planus::Offset; + #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> + { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOptionalUnion for DataBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, + impl>> + ::planus::WriteAsOffset + for SetSubchannelsResponseBuilder<(T0,)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Offset { + let (v0,) = &self.0; + SetSubchannelsResponse::create(builder, v0) } } - /// Reference to a deserialized [Data]. - #[derive(Copy, Clone, Debug)] - pub enum DataRef<'a> { - String(self::StringRef<'a>), - Binary(self::BinaryRef<'a>), + /// 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::convert::TryFrom> for Data { - type Error = ::planus::Error; + 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() + } + } - fn try_from(value: DataRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - DataRef::String(value) => Self::String(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )), + impl<'a> ::core::convert::TryFrom> for SetSubchannelsResponse { + type Error = ::planus::Error; - DataRef::Binary(value) => Self::Binary(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )), + #[allow(unreachable_code)] + fn try_from(value: SetSubchannelsResponseRef<'a>) -> ::planus::Result { + ::core::result::Result::Ok(Self { + subchannels: value.subchannels()?.to_vec()?, }) } } - impl<'a> ::planus::TableReadUnion<'a> for DataRef<'a> { + impl<'a> ::planus::TableRead<'a> for SetSubchannelsResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, - field_offset: usize, - tag: u8, + offset: usize, ) -> ::core::result::Result { - match tag { - 1 => ::core::result::Result::Ok(Self::String( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::Binary( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), - } + ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( + buffer, offset, + )?)) } } - /// The table `SendRequest` in the namespace `FBS.DataConsumer` - /// - /// Generated from these locations: - /// * Table `SendRequest` in the file `../worker/fbs/dataConsumer.fbs:50` - #[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: self::Data, + 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 SendRequest { - /// Creates a [SendRequestBuilder] for serializing an instance of this table. + impl ::planus::VectorWrite<::planus::Offset> for SetSubchannelsResponse { + type Value = ::planus::Offset; + const STRIDE: usize = 4; #[inline] - pub fn builder() -> SendRequestBuilder<()> { - SendRequestBuilder(()) + fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { + ::planus::WriteAs::prepare(self, builder) } - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_ppid: impl ::planus::WriteAsDefault, - field_data: impl ::planus::WriteAsUnion, - ) -> ::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<10> = - ::core::default::Default::default(); - if prepared_ppid.is_some() { + #[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); } - table_writer.write_entry::<::planus::Offset>(2); - table_writer.write_entry::(1); unsafe { table_writer.finish(builder, |object_writer| { - if let ::core::option::Option::Some(prepared_ppid) = prepared_ppid { - object_writer.write::<_, _, 4>(&prepared_ppid); + if let ::core::option::Option::Some(prepared_buffered_amount) = + prepared_buffered_amount + { + object_writer.write::<_, _, 4>(&prepared_buffered_amount); } - object_writer.write::<_, _, 4>(&prepared_data.offset()); - object_writer.write::<_, _, 1>(&prepared_data.tag()); }); } builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for SendRequest { + impl ::planus::WriteAs<::planus::Offset> + for BufferedAmountLowNotification + { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for SendRequest { + 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<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for SendRequest { + impl ::planus::WriteAsOffset for BufferedAmountLowNotification { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SendRequest::create(builder, self.ppid, &self.data) + ) -> ::planus::Offset { + BufferedAmountLowNotification::create(builder, self.buffered_amount) } } - /// Builder for serializing an instance of the [SendRequest] type. + /// Builder for serializing an instance of the [BufferedAmountLowNotification] type. /// - /// Can be created using the [SendRequest::builder] method. + /// Can be created using the [BufferedAmountLowNotification::builder] method. #[derive(Debug)] #[must_use] - pub struct SendRequestBuilder(State); + pub struct BufferedAmountLowNotificationBuilder(State); - impl SendRequestBuilder<()> { - /// Setter for the [`ppid` field](SendRequest#structfield.ppid). + impl BufferedAmountLowNotificationBuilder<()> { + /// Setter for the [`buffered_amount` field](BufferedAmountLowNotification#structfield.buffered_amount). #[inline] #[allow(clippy::type_complexity)] - pub fn ppid(self, value: T0) -> SendRequestBuilder<(T0,)> + pub fn buffered_amount( + self, + value: T0, + ) -> BufferedAmountLowNotificationBuilder<(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) + BufferedAmountLowNotificationBuilder((value,)) } - } - impl SendRequestBuilder<(T0,)> { - /// Setter for the [`data` field](SendRequest#structfield.data). + /// Sets the [`buffered_amount` field](BufferedAmountLowNotification#structfield.buffered_amount) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn data(self, value: T1) -> SendRequestBuilder<(T0, T1)> - where - T1: ::planus::WriteAsUnion, + pub fn buffered_amount_as_default( + self, + ) -> BufferedAmountLowNotificationBuilder<(::planus::DefaultValue,)> { - let (v0,) = self.0; - SendRequestBuilder((v0, value)) + self.buffered_amount(::planus::DefaultValue) } } - impl SendRequestBuilder<(T0, T1)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SendRequest]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsUnion, - > ::planus::WriteAs<::planus::Offset> - for SendRequestBuilder<(T0, T1)> + impl> + ::planus::WriteAs<::planus::Offset> + for BufferedAmountLowNotificationBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsUnion, - > ::planus::WriteAsOptional<::planus::Offset> - for SendRequestBuilder<(T0, T1)> + impl> + ::planus::WriteAsOptional<::planus::Offset> + for BufferedAmountLowNotificationBuilder<(T0,)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> { + ) -> ::core::option::Option<::planus::Offset> + { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl< - T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsUnion, - > ::planus::WriteAsOffset for SendRequestBuilder<(T0, T1)> + impl> + ::planus::WriteAsOffset + for BufferedAmountLowNotificationBuilder<(T0,)> { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - let (v0, v1) = &self.0; - SendRequest::create(builder, v0, v1) + ) -> ::planus::Offset { + let (v0,) = &self.0; + BufferedAmountLowNotification::create(builder, v0) } } - /// Reference to a deserialized [SendRequest]. + /// Reference to a deserialized [BufferedAmountLowNotification]. #[derive(Copy, Clone)] - pub struct SendRequestRef<'a>(::planus::table_reader::Table<'a>); + pub struct BufferedAmountLowNotificationRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> SendRequestRef<'a> { - /// Getter for the [`ppid` field](SendRequest#structfield.ppid). + impl<'a> BufferedAmountLowNotificationRef<'a> { + /// Getter for the [`buffered_amount` field](BufferedAmountLowNotification#structfield.buffered_amount). #[inline] - pub fn ppid(&self) -> ::planus::Result { + pub fn buffered_amount(&self) -> ::planus::Result { ::core::result::Result::Ok( - self.0.access(0, "SendRequest", "ppid")?.unwrap_or(0), + self.0 + .access(0, "BufferedAmountLowNotification", "buffered_amount")? + .unwrap_or(0), ) } - - /// Getter for the [`data` field](SendRequest#structfield.data). - #[inline] - pub fn data(&self) -> ::planus::Result> { - self.0.access_union_required(1, "SendRequest", "data") - } } - impl<'a> ::core::fmt::Debug for SendRequestRef<'a> { + 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("SendRequestRef"); - f.field("ppid", &self.ppid()); - f.field("data", &self.data()); + let mut f = f.debug_struct("BufferedAmountLowNotificationRef"); + f.field("buffered_amount", &self.buffered_amount()); f.finish() } } - impl<'a> ::core::convert::TryFrom> for SendRequest { + impl<'a> ::core::convert::TryFrom> + for BufferedAmountLowNotification + { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: SendRequestRef<'a>) -> ::planus::Result { + fn try_from(value: BufferedAmountLowNotificationRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - ppid: ::core::convert::TryInto::try_into(value.ppid()?)?, - data: ::core::convert::TryInto::try_into(value.data()?)?, + buffered_amount: ::core::convert::TryInto::try_into( + value.buffered_amount()?, + )?, }) } } - impl<'a> ::planus::TableRead<'a> for SendRequestRef<'a> { + impl<'a> ::planus::TableRead<'a> for BufferedAmountLowNotificationRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -26256,7 +26412,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for SendRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for BufferedAmountLowNotificationRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -26266,7 +26422,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[SendRequestRef]", + "[BufferedAmountLowNotificationRef]", "get", buffer.offset_from_start, ) @@ -26274,8 +26430,10 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for SendRequest { - type Value = ::planus::Offset; + 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 { @@ -26284,7 +26442,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -26299,7 +26457,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for SendRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for BufferedAmountLowNotificationRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -26309,15 +26467,19 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[SendRequestRef]", "read_as_root", 0) + error_kind.with_error_location( + "[BufferedAmountLowNotificationRef]", + "read_as_root", + 0, + ) }) } } - /// The table `SetSubchannelsRequest` in the namespace `FBS.DataConsumer` + /// The table `MessageNotification` in the namespace `FBS.DataConsumer` /// /// Generated from these locations: - /// * Table `SetSubchannelsRequest` in the file `../worker/fbs/dataConsumer.fbs:55` + /// * Table `MessageNotification` in the file `../worker/fbs/dataConsumer.fbs:56` #[derive( Clone, Debug, @@ -26329,184 +26491,231 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub struct SetSubchannelsRequest { - /// The field `subchannels` in the table `SetSubchannelsRequest` - pub subchannels: ::planus::alloc::vec::Vec, + 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 SetSubchannelsRequest { - /// Creates a [SetSubchannelsRequestBuilder] for serializing an instance of this table. + impl MessageNotification { + /// Creates a [MessageNotificationBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> SetSubchannelsRequestBuilder<()> { - SetSubchannelsRequestBuilder(()) + pub fn builder() -> MessageNotificationBuilder<()> { + MessageNotificationBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_subchannels: impl ::planus::WriteAs<::planus::Offset<[u16]>>, + field_ppid: impl ::planus::WriteAsDefault, + field_data: impl ::planus::WriteAs<::planus::Offset<[u8]>>, ) -> ::planus::Offset { - let prepared_subchannels = field_subchannels.prepare(builder); + let prepared_ppid = field_ppid.prepare(builder, &0); + let prepared_data = field_data.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<6> = + let mut table_writer: ::planus::table_writer::TableWriter<8> = ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[u16]>>(0); + 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| { - object_writer.write::<_, _, 4>(&prepared_subchannels); + 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 SetSubchannelsRequest { + impl ::planus::WriteAs<::planus::Offset> for MessageNotification { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> for SetSubchannelsRequest { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for SetSubchannelsRequest { + impl ::planus::WriteAsOffset for MessageNotification { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SetSubchannelsRequest::create(builder, &self.subchannels) + ) -> ::planus::Offset { + MessageNotification::create(builder, self.ppid, &self.data) } } - /// Builder for serializing an instance of the [SetSubchannelsRequest] type. + /// Builder for serializing an instance of the [MessageNotification] type. /// - /// Can be created using the [SetSubchannelsRequest::builder] method. + /// Can be created using the [MessageNotification::builder] method. #[derive(Debug)] #[must_use] - pub struct SetSubchannelsRequestBuilder(State); + pub struct MessageNotificationBuilder(State); - impl SetSubchannelsRequestBuilder<()> { - /// Setter for the [`subchannels` field](SetSubchannelsRequest#structfield.subchannels). + impl MessageNotificationBuilder<()> { + /// Setter for the [`ppid` field](MessageNotification#structfield.ppid). #[inline] #[allow(clippy::type_complexity)] - pub fn subchannels(self, value: T0) -> SetSubchannelsRequestBuilder<(T0,)> + pub fn ppid(self, value: T0) -> MessageNotificationBuilder<(T0,)> where - T0: ::planus::WriteAs<::planus::Offset<[u16]>>, + T0: ::planus::WriteAsDefault, { - SetSubchannelsRequestBuilder((value,)) + 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 SetSubchannelsRequestBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [SetSubchannelsRequest]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl>> - ::planus::WriteAs<::planus::Offset> - for SetSubchannelsRequestBuilder<(T0,)> + impl< + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAs<::planus::Offset<[u8]>>, + > ::planus::WriteAs<::planus::Offset> + for MessageNotificationBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl>> - ::planus::WriteAsOptional<::planus::Offset> - for SetSubchannelsRequestBuilder<(T0,)> + impl< + T0: ::planus::WriteAsDefault, + T1: ::planus::WriteAs<::planus::Offset<[u8]>>, + > ::planus::WriteAsOptional<::planus::Offset> + for MessageNotificationBuilder<(T0, T1)> { - type Prepared = ::planus::Offset; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl>> - ::planus::WriteAsOffset - for SetSubchannelsRequestBuilder<(T0,)> + 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,) = &self.0; - SetSubchannelsRequest::create(builder, v0) + ) -> ::planus::Offset { + let (v0, v1) = &self.0; + MessageNotification::create(builder, v0, v1) } } - /// Reference to a deserialized [SetSubchannelsRequest]. + /// Reference to a deserialized [MessageNotification]. #[derive(Copy, Clone)] - pub struct SetSubchannelsRequestRef<'a>(::planus::table_reader::Table<'a>); + pub struct MessageNotificationRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> SetSubchannelsRequestRef<'a> { - /// Getter for the [`subchannels` field](SetSubchannelsRequest#structfield.subchannels). + impl<'a> MessageNotificationRef<'a> { + /// Getter for the [`ppid` field](MessageNotification#structfield.ppid). #[inline] - pub fn subchannels(&self) -> ::planus::Result<::planus::Vector<'a, u16>> { - self.0 - .access_required(0, "SetSubchannelsRequest", "subchannels") + 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 SetSubchannelsRequestRef<'a> { + 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("SetSubchannelsRequestRef"); - f.field("subchannels", &self.subchannels()); + 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 SetSubchannelsRequest { + impl<'a> ::core::convert::TryFrom> for MessageNotification { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: SetSubchannelsRequestRef<'a>) -> ::planus::Result { + fn try_from(value: MessageNotificationRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - subchannels: value.subchannels()?.to_vec()?, + ppid: ::core::convert::TryInto::try_into(value.ppid()?)?, + data: value.data()?.to_vec(), }) } } - impl<'a> ::planus::TableRead<'a> for SetSubchannelsRequestRef<'a> { + impl<'a> ::planus::TableRead<'a> for MessageNotificationRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -26518,7 +26727,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for SetSubchannelsRequestRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for MessageNotificationRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -26528,7 +26737,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[SetSubchannelsRequestRef]", + "[MessageNotificationRef]", "get", buffer.offset_from_start, ) @@ -26536,8 +26745,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for SetSubchannelsRequest { - type Value = ::planus::Offset; + 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 { @@ -26546,7 +26755,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -26561,7 +26770,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for SetSubchannelsRequestRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for MessageNotificationRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -26572,286 +26781,193 @@ mod root { ) .map_err(|error_kind| { error_kind.with_error_location( - "[SetSubchannelsRequestRef]", + "[MessageNotificationRef]", "read_as_root", 0, ) }) } } - - /// The table `SetSubchannelsResponse` in the namespace `FBS.DataConsumer` + } + /// 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: - /// * Table `SetSubchannelsResponse` in the file `../worker/fbs/dataConsumer.fbs:59` + /// * Enum `Type` in the file `../worker/fbs/dataProducer.fbs:5` #[derive( + Copy, Clone, Debug, PartialEq, - PartialOrd, Eq, + PartialOrd, Ord, Hash, ::serde::Serialize, ::serde::Deserialize, )] - pub struct SetSubchannelsResponse { - /// The field `subchannels` in the table `SetSubchannelsResponse` - pub subchannels: ::planus::alloc::vec::Vec, - } + #[repr(u8)] + pub enum Type { + /// The variant `SCTP` in the enum `Type` + Sctp = 0, - impl SetSubchannelsResponse { - /// Creates a [SetSubchannelsResponseBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> SetSubchannelsResponseBuilder<()> { - SetSubchannelsResponseBuilder(()) - } + /// The variant `DIRECT` in the enum `Type` + Direct = 1, + } - #[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); + impl Type { + /// Array containing all valid variants of Type + pub const ENUM_VALUES: [Self; 2] = [Self::Sctp, Self::Direct]; + } - let mut table_writer: ::planus::table_writer::TableWriter<6> = - ::core::default::Default::default(); - table_writer.write_entry::<::planus::Offset<[u16]>>(0); + 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), - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_subchannels); - }); + _ => ::core::result::Result::Err(::planus::errors::UnknownEnumTagKind { + tag: value as i128, + }), } - builder.current_offset() } } - impl ::planus::WriteAs<::planus::Offset> for SetSubchannelsResponse { - type Prepared = ::planus::Offset; - + impl ::core::convert::From for u8 { #[inline] - fn prepare( - &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + fn from(value: Type) -> Self { + value as u8 } } - 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::Primitive for Type { + const ALIGNMENT: usize = 1; + const SIZE: usize = 1; } - impl ::planus::WriteAsOffset for SetSubchannelsResponse { + impl ::planus::WriteAsPrimitive for Type { #[inline] - fn prepare( + fn write( &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - SetSubchannelsResponse::create(builder, &self.subchannels) + cursor: ::planus::Cursor<'_, N>, + buffer_position: u32, + ) { + (*self as u8).write(cursor, buffer_position); } } - /// 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 ::planus::WriteAs for Type { + type Prepared = Self; - 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) + fn prepare(&self, _builder: &mut ::planus::Builder) -> Type { + *self } } - impl>> - ::planus::WriteAs<::planus::Offset> - for SetSubchannelsResponseBuilder<(T0,)> - { - type Prepared = ::planus::Offset; + impl ::planus::WriteAsDefault for Type { + type Prepared = Self; #[inline] fn prepare( &self, - builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - ::planus::WriteAsOffset::prepare(self, builder) + _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<::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::WriteAsOptional for Type { + type Prepared = Self; - 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()?, - }) + _builder: &mut ::planus::Builder, + ) -> ::core::option::Option { + ::core::option::Option::Some(*self) } } - impl<'a> ::planus::TableRead<'a> for SetSubchannelsResponseRef<'a> { + impl<'buf> ::planus::TableRead<'buf> for Type { #[inline] fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, + buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, ) -> ::core::result::Result { - ::core::result::Result::Ok(Self(::planus::table_reader::Table::from_buffer( - buffer, offset, - )?)) + let n: u8 = ::planus::TableRead::from_buffer(buffer, offset)?; + ::core::result::Result::Ok(::core::convert::TryInto::try_into(n)?) } } - impl<'a> ::planus::VectorReadInner<'a> for SetSubchannelsResponseRef<'a> { - type Error = ::planus::Error; - const STRIDE: usize = 4; - + impl<'buf> ::planus::VectorReadInner<'buf> for Type { + type Error = ::planus::errors::UnknownEnumTag; + const STRIDE: usize = 1; + #[inline] unsafe fn from_buffer( - buffer: ::planus::SliceWithStartOffset<'a>, + buffer: ::planus::SliceWithStartOffset<'buf>, offset: usize, - ) -> ::planus::Result { - ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { + ) -> ::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( - "[SetSubchannelsResponseRef]", - "get", + "Type", + "VectorRead::from_buffer", buffer.offset_from_start, ) }) } } - impl ::planus::VectorWrite<::planus::Offset> for SetSubchannelsResponse { - type Value = ::planus::Offset; - const STRIDE: usize = 4; + impl ::planus::VectorWrite for Type { + const STRIDE: usize = 1; + + type Value = Self; + #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> Self::Value { - ::planus::WriteAs::prepare(self, builder) + fn prepare(&self, _builder: &mut ::planus::Builder) -> Self { + *self } #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[Self], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { - let bytes = bytes as *mut [::core::mem::MaybeUninit; 4]; + 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 - (Self::STRIDE * i) as u32, + buffer_position - 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` + /// The table `DumpResponse` in the namespace `FBS.DataProducer` /// /// Generated from these locations: - /// * Table `BufferedAmountLowNotification` in the file `../worker/fbs/dataConsumer.fbs:65` + /// * Table `DumpResponse` in the file `../worker/fbs/dataProducer.fbs:10` #[derive( Clone, Debug, @@ -26863,44 +26979,80 @@ mod root { ::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 } - } + 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 BufferedAmountLowNotification { - /// Creates a [BufferedAmountLowNotificationBuilder] for serializing an instance of this table. + impl DumpResponse { + /// Creates a [DumpResponseBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> BufferedAmountLowNotificationBuilder<()> { - BufferedAmountLowNotificationBuilder(()) + pub fn builder() -> DumpResponseBuilder<()> { + DumpResponseBuilder(()) } #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_buffered_amount: impl ::planus::WriteAsDefault, + 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_buffered_amount = field_buffered_amount.prepare(builder, &0); + 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<6> = + let mut table_writer: ::planus::table_writer::TableWriter<16> = ::core::default::Default::default(); - if prepared_buffered_amount.is_some() { - table_writer.write_entry::(0); + 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| { - if let ::core::option::Option::Some(prepared_buffered_amount) = - prepared_buffered_amount + 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_buffered_amount); + 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); } }); } @@ -26908,2162 +27060,338 @@ mod root { } } - impl ::planus::WriteAs<::planus::Offset> - for BufferedAmountLowNotification - { + impl ::planus::WriteAs<::planus::Offset> for DumpResponse { type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsOptional<::planus::Offset> - for BufferedAmountLowNotification - { + 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<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOffset for BufferedAmountLowNotification { + impl ::planus::WriteAsOffset for DumpResponse { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { - BufferedAmountLowNotification::create(builder, self.buffered_amount) + ) -> ::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 [BufferedAmountLowNotification] type. + /// Builder for serializing an instance of the [DumpResponse] type. /// - /// Can be created using the [BufferedAmountLowNotification::builder] method. + /// Can be created using the [DumpResponse::builder] method. #[derive(Debug)] #[must_use] - pub struct BufferedAmountLowNotificationBuilder(State); + pub struct DumpResponseBuilder(State); - impl BufferedAmountLowNotificationBuilder<()> { - /// Setter for the [`buffered_amount` field](BufferedAmountLowNotification#structfield.buffered_amount). + impl DumpResponseBuilder<()> { + /// Setter for the [`id` field](DumpResponse#structfield.id). #[inline] #[allow(clippy::type_complexity)] - pub fn buffered_amount( + 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: T0, - ) -> BufferedAmountLowNotificationBuilder<(T0,)> + value: T2, + ) -> DumpResponseBuilder<(T0, T1, T2)> where - T0: ::planus::WriteAsDefault, + T2: ::planus::WriteAsOptional< + ::planus::Offset, + >, { - BufferedAmountLowNotificationBuilder((value,)) + let (v0, v1) = self.0; + DumpResponseBuilder((v0, v1, value)) } - /// Sets the [`buffered_amount` field](BufferedAmountLowNotification#structfield.buffered_amount) to the default value. + /// Sets the [`sctp_stream_parameters` field](DumpResponse#structfield.sctp_stream_parameters) to null. #[inline] #[allow(clippy::type_complexity)] - pub fn buffered_amount_as_default( + 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, - ) -> BufferedAmountLowNotificationBuilder<(::planus::DefaultValue,)> + ) -> DumpResponseBuilder<(T0, T1, T2, T3, T4, ::planus::DefaultValue)> { - self.buffered_amount(::planus::DefaultValue) + self.paused(::planus::DefaultValue) } } - impl BufferedAmountLowNotificationBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [BufferedAmountLowNotification]. + 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 + ) -> ::planus::Offset where - Self: ::planus::WriteAsOffset, + Self: ::planus::WriteAsOffset, { ::planus::WriteAsOffset::prepare(&self, builder) } } - impl> - ::planus::WriteAs<::planus::Offset> - for BufferedAmountLowNotificationBuilder<(T0,)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::planus::Offset { + ) -> ::planus::Offset { ::planus::WriteAsOffset::prepare(self, builder) } } - impl> - ::planus::WriteAsOptional<::planus::Offset> - for BufferedAmountLowNotificationBuilder<(T0,)> + 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; + type Prepared = ::planus::Offset; #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::Offset> - { + ) -> ::core::option::Option<::planus::Offset> { ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl> - ::planus::WriteAsOffset - for BufferedAmountLowNotificationBuilder<(T0,)> + 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,) = &self.0; - BufferedAmountLowNotification::create(builder, v0) + ) -> ::planus::Offset { + let (v0, v1, v2, v3, v4, v5) = &self.0; + DumpResponse::create(builder, v0, v1, v2, v3, v4, v5) } } - /// Reference to a deserialized [BufferedAmountLowNotification]. + /// Reference to a deserialized [DumpResponse]. #[derive(Copy, Clone)] - pub struct BufferedAmountLowNotificationRef<'a>(::planus::table_reader::Table<'a>); + pub struct DumpResponseRef<'a>(::planus::table_reader::Table<'a>); - impl<'a> BufferedAmountLowNotificationRef<'a> { - /// Getter for the [`buffered_amount` field](BufferedAmountLowNotification#structfield.buffered_amount). + impl<'a> DumpResponseRef<'a> { + /// Getter for the [`id` field](DumpResponse#structfield.id). #[inline] - pub fn buffered_amount(&self) -> ::planus::Result { + 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(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:69` - #[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), + .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), - ) + pub fn sctp_stream_parameters( + &self, + ) -> ::planus::Result< + ::core::option::Option>, + > { + self.0.access(2, "DumpResponse", "sctp_stream_parameters") } - /// Getter for the [`label` field](GetStatsResponse#structfield.label). + /// Getter for the [`label` field](DumpResponse#structfield.label). #[inline] pub fn label(&self) -> ::planus::Result<&'a ::core::primitive::str> { - self.0.access_required(1, "GetStatsResponse", "label") + self.0.access_required(3, "DumpResponse", "label") } - /// Getter for the [`protocol` field](GetStatsResponse#structfield.protocol). + /// Getter for the [`protocol` field](DumpResponse#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), - ) + self.0.access_required(4, "DumpResponse", "protocol") } - /// Getter for the [`buffered_amount` field](GetStatsResponse#structfield.buffered_amount). + /// Getter for the [`paused` field](DumpResponse#structfield.paused). #[inline] - pub fn buffered_amount(&self) -> ::planus::Result { + pub fn paused(&self) -> ::planus::Result { ::core::result::Result::Ok( - self.0 - .access(5, "GetStatsResponse", "buffered_amount")? - .unwrap_or(0), + self.0.access(5, "DumpResponse", "paused")?.unwrap_or(false), ) } } - impl<'a> ::core::fmt::Debug for GetStatsResponseRef<'a> { + 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("GetStatsResponseRef"); - f.field("timestamp", &self.timestamp()); + 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("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 `String` in the namespace `FBS.DataProducer` - /// - /// Generated from these locations: - /// * Table `String` in the file `../worker/fbs/dataProducer.fbs:28` - #[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 table `Binary` in the namespace `FBS.DataProducer` - /// - /// Generated from these locations: - /// * Table `Binary` in the file `../worker/fbs/dataProducer.fbs:32` - #[derive( - Clone, - Debug, - PartialEq, - PartialOrd, - Eq, - Ord, - Hash, - ::serde::Serialize, - ::serde::Deserialize, - )] - pub struct Binary { - /// The field `value` in the table `Binary` - pub value: ::planus::alloc::vec::Vec, - } - - impl Binary { - /// Creates a [BinaryBuilder] for serializing an instance of this table. - #[inline] - pub fn builder() -> BinaryBuilder<()> { - BinaryBuilder(()) - } - - #[allow(clippy::too_many_arguments)] - pub fn create( - builder: &mut ::planus::Builder, - field_value: impl ::planus::WriteAs<::planus::Offset<[u8]>>, - ) -> ::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<[u8]>>(0); - - unsafe { - table_writer.finish(builder, |object_writer| { - object_writer.write::<_, _, 4>(&prepared_value); - }); - } - builder.current_offset() - } - } - - impl ::planus::WriteAs<::planus::Offset> for Binary { - 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 Binary { - type Prepared = ::planus::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 Binary { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - Binary::create(builder, &self.value) - } - } - - /// Builder for serializing an instance of the [Binary] type. - /// - /// Can be created using the [Binary::builder] method. - #[derive(Debug)] - #[must_use] - pub struct BinaryBuilder(State); - - impl BinaryBuilder<()> { - /// Setter for the [`value` field](Binary#structfield.value). - #[inline] - #[allow(clippy::type_complexity)] - pub fn value(self, value: T0) -> BinaryBuilder<(T0,)> - where - T0: ::planus::WriteAs<::planus::Offset<[u8]>>, - { - BinaryBuilder((value,)) - } - } - - impl BinaryBuilder<(T0,)> { - /// Finish writing the builder to get an [Offset](::planus::Offset) to a serialized [Binary]. - #[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 BinaryBuilder<(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 BinaryBuilder<(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 BinaryBuilder<(T0,)> - { - #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - let (v0,) = &self.0; - Binary::create(builder, v0) - } - } - - /// Reference to a deserialized [Binary]. - #[derive(Copy, Clone)] - pub struct BinaryRef<'a>(::planus::table_reader::Table<'a>); - - impl<'a> BinaryRef<'a> { - /// Getter for the [`value` field](Binary#structfield.value). - #[inline] - pub fn value(&self) -> ::planus::Result<&'a [u8]> { - self.0.access_required(0, "Binary", "value") - } - } - - impl<'a> ::core::fmt::Debug for BinaryRef<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut f = f.debug_struct("BinaryRef"); - f.field("value", &self.value()); + f.field("paused", &self.paused()); f.finish() } } - impl<'a> ::core::convert::TryFrom> for Binary { + impl<'a> ::core::convert::TryFrom> for DumpResponse { type Error = ::planus::Error; #[allow(unreachable_code)] - fn try_from(value: BinaryRef<'a>) -> ::planus::Result { + fn try_from(value: DumpResponseRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - value: value.value()?.to_vec(), + 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 BinaryRef<'a> { + impl<'a> ::planus::TableRead<'a> for DumpResponseRef<'a> { #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, @@ -29075,7 +27403,7 @@ mod root { } } - impl<'a> ::planus::VectorReadInner<'a> for BinaryRef<'a> { + impl<'a> ::planus::VectorReadInner<'a> for DumpResponseRef<'a> { type Error = ::planus::Error; const STRIDE: usize = 4; @@ -29085,7 +27413,7 @@ mod root { ) -> ::planus::Result { ::planus::TableRead::from_buffer(buffer, offset).map_err(|error_kind| { error_kind.with_error_location( - "[BinaryRef]", + "[DumpResponseRef]", "get", buffer.offset_from_start, ) @@ -29093,8 +27421,8 @@ mod root { } } - impl ::planus::VectorWrite<::planus::Offset> for Binary { - type Value = ::planus::Offset; + 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 { @@ -29103,7 +27431,7 @@ mod root { #[inline] unsafe fn write_values( - values: &[::planus::Offset], + values: &[::planus::Offset], bytes: *mut ::core::mem::MaybeUninit, buffer_position: u32, ) { @@ -29118,7 +27446,7 @@ mod root { } } - impl<'a> ::planus::ReadAsRoot<'a> for BinaryRef<'a> { + impl<'a> ::planus::ReadAsRoot<'a> for DumpResponseRef<'a> { fn read_as_root(slice: &'a [u8]) -> ::planus::Result { ::planus::TableRead::from_buffer( ::planus::SliceWithStartOffset { @@ -29128,15 +27456,15 @@ mod root { 0, ) .map_err(|error_kind| { - error_kind.with_error_location("[BinaryRef]", "read_as_root", 0) + error_kind.with_error_location("[DumpResponseRef]", "read_as_root", 0) }) } } - /// The union `Data` in the namespace `FBS.DataProducer` + /// The table `GetStatsResponse` in the namespace `FBS.DataProducer` /// /// Generated from these locations: - /// * Union `Data` in the file `../worker/fbs/dataProducer.fbs:36` + /// * Table `GetStatsResponse` in the file `../worker/fbs/dataProducer.fbs:19` #[derive( Clone, Debug, @@ -29148,188 +27476,508 @@ mod root { ::serde::Serialize, ::serde::Deserialize, )] - pub enum Data { - /// The variant of type `String` in the union `Data` - String(::planus::alloc::boxed::Box), - - /// The variant of type `Binary` in the union `Data` - Binary(::planus::alloc::boxed::Box), + 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 Data { - /// Creates a [DataBuilder] for serializing an instance of this table. + impl GetStatsResponse { + /// Creates a [GetStatsResponseBuilder] for serializing an instance of this table. #[inline] - pub fn builder() -> DataBuilder<::planus::Uninitialized> { - DataBuilder(::planus::Uninitialized) + pub fn builder() -> GetStatsResponseBuilder<()> { + GetStatsResponseBuilder(()) } - #[inline] - pub fn create_string( + #[allow(clippy::too_many_arguments)] + pub fn create( builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, value.prepare(builder).downcast()) + 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] - pub fn create_binary( + fn prepare( + &self, builder: &mut ::planus::Builder, - value: impl ::planus::WriteAsOffset, - ) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, value.prepare(builder).downcast()) + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsUnion for Data { + impl ::planus::WriteAsOptional<::planus::Offset> for GetStatsResponse { + type Prepared = ::planus::Offset; + #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - match self { - Self::String(value) => Self::create_string(builder, value), - Self::Binary(value) => Self::create_binary(builder, value), - } + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOptionalUnion for Data { + impl ::planus::WriteAsOffset for GetStatsResponse { #[inline] fn prepare( &self, builder: &mut ::planus::Builder, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, 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 [Data] type. + /// Builder for serializing an instance of the [GetStatsResponse] type. /// - /// Can be created using the [Data::builder] method. + /// Can be created using the [GetStatsResponse::builder] method. #[derive(Debug)] #[must_use] - pub struct DataBuilder(T); + pub struct GetStatsResponseBuilder(State); - impl DataBuilder<::planus::Uninitialized> { - /// Creates an instance of the [`String` variant](Data#variant.String). + impl GetStatsResponseBuilder<()> { + /// Setter for the [`timestamp` field](GetStatsResponse#structfield.timestamp). #[inline] - pub fn string(self, value: T) -> DataBuilder<::planus::Initialized<1, T>> + #[allow(clippy::type_complexity)] + pub fn timestamp(self, value: T0) -> GetStatsResponseBuilder<(T0,)> where - T: ::planus::WriteAsOffset, + T0: ::planus::WriteAsDefault, { - DataBuilder(::planus::Initialized(value)) + 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) } + } - /// Creates an instance of the [`Binary` variant](Data#variant.Binary). + impl GetStatsResponseBuilder<(T0,)> { + /// Setter for the [`label` field](GetStatsResponse#structfield.label). #[inline] - pub fn binary(self, value: T) -> DataBuilder<::planus::Initialized<2, T>> + #[allow(clippy::type_complexity)] + pub fn label(self, value: T1) -> GetStatsResponseBuilder<(T0, T1)> where - T: ::planus::WriteAsOffset, + T1: ::planus::WriteAs<::planus::Offset>, { - DataBuilder(::planus::Initialized(value)) + let (v0,) = self.0; + GetStatsResponseBuilder((v0, value)) } } - impl DataBuilder<::planus::Initialized> { - /// Finish writing the builder to get an [UnionOffset](::planus::UnionOffset) to a serialized [Data]. + impl GetStatsResponseBuilder<(T0, T1)> { + /// Setter for the [`protocol` field](GetStatsResponse#structfield.protocol). #[inline] - pub fn finish(self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset + #[allow(clippy::type_complexity)] + pub fn protocol(self, value: T2) -> GetStatsResponseBuilder<(T0, T1, T2)> where - Self: ::planus::WriteAsUnion, + T2: ::planus::WriteAs<::planus::Offset>, { - ::planus::WriteAsUnion::prepare(&self, builder) + let (v0, v1) = self.0; + GetStatsResponseBuilder((v0, v1, value)) } } - impl ::planus::WriteAsUnion for DataBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, - { + impl GetStatsResponseBuilder<(T0, T1, T2)> { + /// Setter for the [`messages_received` field](GetStatsResponse#structfield.messages_received). #[inline] - fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(1, (self.0).0.prepare(builder).downcast()) + #[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 ::planus::WriteAsOptionalUnion for DataBuilder<::planus::Initialized<1, T>> - where - T: ::planus::WriteAsOffset, + 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, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, builder)) + ) -> ::planus::Offset { + ::planus::WriteAsOffset::prepare(self, builder) } } - impl ::planus::WriteAsUnion for DataBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, + + 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) -> ::planus::UnionOffset { - ::planus::UnionOffset::new(2, (self.0).0.prepare(builder).downcast()) + fn prepare( + &self, + builder: &mut ::planus::Builder, + ) -> ::core::option::Option<::planus::Offset> { + ::core::option::Option::Some(::planus::WriteAsOffset::prepare(self, builder)) } } - impl ::planus::WriteAsOptionalUnion for DataBuilder<::planus::Initialized<2, T>> - where - T: ::planus::WriteAsOffset, + 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, - ) -> ::core::option::Option<::planus::UnionOffset> { - ::core::option::Option::Some(::planus::WriteAsUnion::prepare(self, 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 [Data]. - #[derive(Copy, Clone, Debug)] - pub enum DataRef<'a> { - String(self::StringRef<'a>), - Binary(self::BinaryRef<'a>), + /// 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::convert::TryFrom> for Data { - type Error = ::planus::Error; + 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() + } + } - fn try_from(value: DataRef<'a>) -> ::planus::Result { - ::core::result::Result::Ok(match value { - DataRef::String(value) => Self::String(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )), + impl<'a> ::core::convert::TryFrom> for GetStatsResponse { + type Error = ::planus::Error; - DataRef::Binary(value) => Self::Binary(::planus::alloc::boxed::Box::new( - ::core::convert::TryFrom::try_from(value)?, - )), + #[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::TableReadUnion<'a> for DataRef<'a> { + impl<'a> ::planus::TableRead<'a> for GetStatsResponseRef<'a> { + #[inline] fn from_buffer( buffer: ::planus::SliceWithStartOffset<'a>, - field_offset: usize, - tag: u8, + offset: usize, ) -> ::core::result::Result { - match tag { - 1 => ::core::result::Result::Ok(Self::String( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - 2 => ::core::result::Result::Ok(Self::Binary( - ::planus::TableRead::from_buffer(buffer, field_offset)?, - )), - _ => ::core::result::Result::Err( - ::planus::errors::ErrorKind::UnknownUnionTag { tag }, - ), + ::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:41` + /// * Table `SendNotification` in the file `../worker/fbs/dataProducer.fbs:28` #[derive( Clone, Debug, @@ -29345,7 +27993,7 @@ mod root { /// The field `ppid` in the table `SendNotification` pub ppid: u32, /// The field `data` in the table `SendNotification` - pub data: self::Data, + 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` @@ -29363,7 +28011,7 @@ mod root { pub fn create( builder: &mut ::planus::Builder, field_ppid: impl ::planus::WriteAsDefault, - field_data: impl ::planus::WriteAsUnion, + field_data: impl ::planus::WriteAs<::planus::Offset<[u8]>>, field_subchannels: impl ::planus::WriteAsOptional<::planus::Offset<[u16]>>, field_required_subchannel: impl ::planus::WriteAsOptional, ) -> ::planus::Offset { @@ -29372,26 +28020,25 @@ mod root { let prepared_subchannels = field_subchannels.prepare(builder); let prepared_required_subchannel = field_required_subchannel.prepare(builder); - let mut table_writer: ::planus::table_writer::TableWriter<14> = + 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>(2); + table_writer.write_entry::<::planus::Offset<[u8]>>(1); if prepared_subchannels.is_some() { - table_writer.write_entry::<::planus::Offset<[u16]>>(3); + table_writer.write_entry::<::planus::Offset<[u16]>>(2); } if prepared_required_subchannel.is_some() { - table_writer.write_entry::(4); + table_writer.write_entry::(3); } - table_writer.write_entry::(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.offset()); + object_writer.write::<_, _, 4>(&prepared_data); if let ::core::option::Option::Some(prepared_subchannels) = prepared_subchannels { @@ -29402,7 +28049,6 @@ mod root { { object_writer.write::<_, _, 2>(&prepared_required_subchannel); } - object_writer.write::<_, _, 1>(&prepared_data.tag()); }); } builder.current_offset() @@ -29481,7 +28127,7 @@ mod root { #[allow(clippy::type_complexity)] pub fn data(self, value: T1) -> SendNotificationBuilder<(T0, T1)> where - T1: ::planus::WriteAsUnion, + T1: ::planus::WriteAs<::planus::Offset<[u8]>>, { let (v0,) = self.0; SendNotificationBuilder((v0, value)) @@ -29549,7 +28195,7 @@ mod root { impl< T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsUnion, + T1: ::planus::WriteAs<::planus::Offset<[u8]>>, T2: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, T3: ::planus::WriteAsOptional, > ::planus::WriteAs<::planus::Offset> @@ -29568,7 +28214,7 @@ mod root { impl< T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsUnion, + T1: ::planus::WriteAs<::planus::Offset<[u8]>>, T2: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, T3: ::planus::WriteAsOptional, > ::planus::WriteAsOptional<::planus::Offset> @@ -29587,7 +28233,7 @@ mod root { impl< T0: ::planus::WriteAsDefault, - T1: ::planus::WriteAsUnion, + T1: ::planus::WriteAs<::planus::Offset<[u8]>>, T2: ::planus::WriteAsOptional<::planus::Offset<[u16]>>, T3: ::planus::WriteAsOptional, > ::planus::WriteAsOffset @@ -29618,8 +28264,8 @@ mod root { /// Getter for the [`data` field](SendNotification#structfield.data). #[inline] - pub fn data(&self) -> ::planus::Result> { - self.0.access_union_required(1, "SendNotification", "data") + pub fn data(&self) -> ::planus::Result<&'a [u8]> { + self.0.access_required(1, "SendNotification", "data") } /// Getter for the [`subchannels` field](SendNotification#structfield.subchannels). @@ -29628,13 +28274,13 @@ mod root { &self, ) -> ::planus::Result<::core::option::Option<::planus::Vector<'a, u16>>> { - self.0.access(3, "SendNotification", "subchannels") + 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(4, "SendNotification", "required_subchannel") + self.0.access(3, "SendNotification", "required_subchannel") } } @@ -29664,7 +28310,7 @@ mod root { fn try_from(value: SendNotificationRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { ppid: ::core::convert::TryInto::try_into(value.ppid()?)?, - data: ::core::convert::TryInto::try_into(value.data()?)?, + data: value.data()?.to_vec(), subchannels: if let ::core::option::Option::Some(subchannels) = value.subchannels()? { @@ -38792,7 +37438,7 @@ mod root { /// The enum `TraceEventType` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `TraceEventType` in the file `../worker/fbs/transport.fbs:121` + /// * Enum `TraceEventType` in the file `../worker/fbs/transport.fbs:122` #[derive( Copy, Clone, @@ -38962,7 +37608,7 @@ mod root { /// The table `Dump` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Dump` in the file `../worker/fbs/transport.fbs:126` + /// * Table `Dump` in the file `../worker/fbs/transport.fbs:127` #[derive( Clone, Debug, @@ -40005,7 +38651,7 @@ mod root { /// The table `Stats` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `Stats` in the file `../worker/fbs/transport.fbs:144` + /// * Table `Stats` in the file `../worker/fbs/transport.fbs:145` #[derive( Clone, Debug, PartialEq, PartialOrd, ::serde::Serialize, ::serde::Deserialize, )] @@ -42666,7 +41312,7 @@ mod root { /// The table `SetMaxIncomingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMaxIncomingBitrateRequest` in the file `../worker/fbs/transport.fbs:171` + /// * Table `SetMaxIncomingBitrateRequest` in the file `../worker/fbs/transport.fbs:172` #[derive( Clone, Debug, @@ -42974,7 +41620,7 @@ mod root { /// The table `SetMaxOutgoingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMaxOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:175` + /// * Table `SetMaxOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:176` #[derive( Clone, Debug, @@ -43282,7 +41928,7 @@ mod root { /// The table `SetMinOutgoingBitrateRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SetMinOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:179` + /// * Table `SetMinOutgoingBitrateRequest` in the file `../worker/fbs/transport.fbs:180` #[derive( Clone, Debug, @@ -43590,7 +42236,7 @@ mod root { /// The table `EnableTraceEventRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/transport.fbs:183` + /// * Table `EnableTraceEventRequest` in the file `../worker/fbs/transport.fbs:184` #[derive( Clone, Debug, @@ -43868,7 +42514,7 @@ mod root { /// The table `CloseProducerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseProducerRequest` in the file `../worker/fbs/transport.fbs:187` + /// * Table `CloseProducerRequest` in the file `../worker/fbs/transport.fbs:188` #[derive( Clone, Debug, @@ -44134,7 +42780,7 @@ mod root { /// The table `CloseConsumerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseConsumerRequest` in the file `../worker/fbs/transport.fbs:191` + /// * Table `CloseConsumerRequest` in the file `../worker/fbs/transport.fbs:192` #[derive( Clone, Debug, @@ -44400,7 +43046,7 @@ mod root { /// The table `CloseDataProducerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseDataProducerRequest` in the file `../worker/fbs/transport.fbs:195` + /// * Table `CloseDataProducerRequest` in the file `../worker/fbs/transport.fbs:196` #[derive( Clone, Debug, @@ -44675,7 +43321,7 @@ mod root { /// The table `CloseDataConsumerRequest` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `CloseDataConsumerRequest` in the file `../worker/fbs/transport.fbs:199` + /// * Table `CloseDataConsumerRequest` in the file `../worker/fbs/transport.fbs:200` #[derive( Clone, Debug, @@ -44950,7 +43596,7 @@ mod root { /// The table `SendRtcpNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SendRtcpNotification` in the file `../worker/fbs/transport.fbs:205` + /// * Table `SendRtcpNotification` in the file `../worker/fbs/transport.fbs:206` #[derive( Clone, Debug, @@ -45215,7 +43861,7 @@ mod root { /// The table `SctpStateChangeNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `SctpStateChangeNotification` in the file `../worker/fbs/transport.fbs:211` + /// * Table `SctpStateChangeNotification` in the file `../worker/fbs/transport.fbs:212` #[derive( Clone, Debug, @@ -45536,7 +44182,7 @@ mod root { /// The union `TraceInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:215` + /// * Union `TraceInfo` in the file `../worker/fbs/transport.fbs:216` #[derive( Clone, Debug, @@ -45689,7 +44335,7 @@ mod root { /// The enum `BweType` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:219` + /// * Enum `BweType` in the file `../worker/fbs/transport.fbs:220` #[derive( Copy, Clone, @@ -45859,7 +44505,7 @@ mod root { /// The table `BweTraceInfo` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:224` + /// * Table `BweTraceInfo` in the file `../worker/fbs/transport.fbs:225` #[derive( Clone, Debug, @@ -46537,7 +45183,7 @@ mod root { /// The table `TraceNotification` in the namespace `FBS.Transport` /// /// Generated from these locations: - /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:235` + /// * Table `TraceNotification` in the file `../worker/fbs/transport.fbs:236` #[derive( Clone, Debug, @@ -64051,8 +62697,8 @@ mod root { ::serde::Deserialize, )] pub struct TupleHash { - /// The field `local_ice_username_fragment` in the table `TupleHash` - pub local_ice_username_fragment: u64, + /// 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, } @@ -64067,28 +62713,25 @@ mod root { #[allow(clippy::too_many_arguments)] pub fn create( builder: &mut ::planus::Builder, - field_local_ice_username_fragment: impl ::planus::WriteAsDefault, + field_tuple_hash: impl ::planus::WriteAsDefault, 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, &0); + 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_local_ice_username_fragment.is_some() { + 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_local_ice_username_fragment, - ) = prepared_local_ice_username_fragment + if let ::core::option::Option::Some(prepared_tuple_hash) = + prepared_tuple_hash { - object_writer - .write::<_, _, 8>(&prepared_local_ice_username_fragment); + object_writer.write::<_, _, 8>(&prepared_tuple_hash); } object_writer.write::<_, _, 4>(&prepared_web_rtc_transport_id); }); @@ -64121,11 +62764,7 @@ mod root { impl ::planus::WriteAsOffset for TupleHash { #[inline] fn prepare(&self, builder: &mut ::planus::Builder) -> ::planus::Offset { - TupleHash::create( - builder, - self.local_ice_username_fragment, - &self.web_rtc_transport_id, - ) + TupleHash::create(builder, self.tuple_hash, &self.web_rtc_transport_id) } } @@ -64137,23 +62776,21 @@ mod root { pub struct TupleHashBuilder(State); impl TupleHashBuilder<()> { - /// Setter for the [`local_ice_username_fragment` field](TupleHash#structfield.local_ice_username_fragment). + /// Setter for the [`tuple_hash` field](TupleHash#structfield.tuple_hash). #[inline] #[allow(clippy::type_complexity)] - pub fn local_ice_username_fragment(self, value: T0) -> TupleHashBuilder<(T0,)> + pub fn tuple_hash(self, value: T0) -> TupleHashBuilder<(T0,)> where T0: ::planus::WriteAsDefault, { TupleHashBuilder((value,)) } - /// Sets the [`local_ice_username_fragment` field](TupleHash#structfield.local_ice_username_fragment) to the default value. + /// Sets the [`tuple_hash` field](TupleHash#structfield.tuple_hash) to the default value. #[inline] #[allow(clippy::type_complexity)] - pub fn local_ice_username_fragment_as_default( - self, - ) -> TupleHashBuilder<(::planus::DefaultValue,)> { - self.local_ice_username_fragment(::planus::DefaultValue) + pub fn tuple_hash_as_default(self) -> TupleHashBuilder<(::planus::DefaultValue,)> { + self.tuple_hash(::planus::DefaultValue) } } @@ -64228,13 +62865,11 @@ mod root { pub struct TupleHashRef<'a>(::planus::table_reader::Table<'a>); impl<'a> TupleHashRef<'a> { - /// Getter for the [`local_ice_username_fragment` field](TupleHash#structfield.local_ice_username_fragment). + /// Getter for the [`tuple_hash` field](TupleHash#structfield.tuple_hash). #[inline] - pub fn local_ice_username_fragment(&self) -> ::planus::Result { + pub fn tuple_hash(&self) -> ::planus::Result { ::core::result::Result::Ok( - self.0 - .access(0, "TupleHash", "local_ice_username_fragment")? - .unwrap_or(0), + self.0.access(0, "TupleHash", "tuple_hash")?.unwrap_or(0), ) } @@ -64249,10 +62884,7 @@ mod root { 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( - "local_ice_username_fragment", - &self.local_ice_username_fragment(), - ); + f.field("tuple_hash", &self.tuple_hash()); f.field("web_rtc_transport_id", &self.web_rtc_transport_id()); f.finish() } @@ -64264,9 +62896,7 @@ mod root { #[allow(unreachable_code)] fn try_from(value: TupleHashRef<'a>) -> ::planus::Result { ::core::result::Result::Ok(Self { - local_ice_username_fragment: ::core::convert::TryInto::try_into( - value.local_ice_username_fragment()?, - )?, + tuple_hash: ::core::convert::TryInto::try_into(value.tuple_hash()?)?, web_rtc_transport_id: ::core::convert::TryInto::try_into( value.web_rtc_transport_id()?, )?, diff --git a/rust/src/messages.rs b/rust/src/messages.rs index 5e6f3b808f..a6c09b43df 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -365,7 +365,7 @@ impl Request for WebRtcServerDumpRequest { .tuple_hashes .into_iter() .map(|tuple_hash| WebRtcServerTupleHash { - tuple_hash: tuple_hash.local_ice_username_fragment, + tuple_hash: tuple_hash.tuple_hash, webrtc_transport_id: tuple_hash.web_rtc_transport_id.parse().unwrap(), }) .collect(), @@ -2878,12 +2878,10 @@ impl Notification for DataProducerSendNotification { fn into_bytes(self, handler_id: Self::HandlerId) -> Vec { let mut builder = Builder::new(); - let binary_data = data_producer::Binary::create(&mut builder, self.payload); - let binary = data_producer::Data::create_binary(&mut builder, binary_data); let data = data_producer::SendNotification::create( &mut builder, self.ppid, - binary, + self.payload, self.subchannels, self.required_subchannel, ); @@ -3179,9 +3177,7 @@ impl Request for DataConsumerSendRequest { fn into_bytes(self, id: u32, handler_id: Self::HandlerId) -> Vec { let mut builder = Builder::new(); - let binary_data = data_consumer::Binary::create(&mut builder, self.payload); - let binary = data_consumer::Data::create_binary(&mut builder, binary_data); - let data = data_consumer::SendRequest::create(&mut builder, self.ppid, binary); + let data = data_consumer::SendRequest::create(&mut builder, self.ppid, self.payload); let request_body = request::Body::create_data_consumer_send_request(&mut builder, data); let request = request::Request::create( diff --git a/worker/fbs/dataConsumer.fbs b/worker/fbs/dataConsumer.fbs index a458b2cdd3..2bebe33191 100644 --- a/worker/fbs/dataConsumer.fbs +++ b/worker/fbs/dataConsumer.fbs @@ -34,22 +34,9 @@ table GetStatsResponse { buffered_amount: uint32; } -table String { - value: string (required); -} - -table Binary { - value: [uint8] (required); -} - -union Data { - String, - Binary -} - table SendRequest { ppid: uint32; - data: Data (required); + data: [uint8] (required); } table SetSubchannelsRequest { diff --git a/worker/fbs/dataProducer.fbs b/worker/fbs/dataProducer.fbs index cd7657d7ec..3d8dbd367b 100644 --- a/worker/fbs/dataProducer.fbs +++ b/worker/fbs/dataProducer.fbs @@ -25,22 +25,9 @@ table GetStatsResponse { buffered_amount: uint32; } -table String { - value: string (required); -} - -table Binary { - value: [uint8] (required); -} - -union Data { - String, - Binary -} - table SendNotification { ppid: uint32; - data: Data (required); + data: [uint8] (required); subchannels: [uint16]; required_subchannel: uint16 = null; } diff --git a/worker/src/RTC/DataConsumer.cpp b/worker/src/RTC/DataConsumer.cpp index 26b18568fd..3f5fd69ffd 100644 --- a/worker/src/RTC/DataConsumer.cpp +++ b/worker/src/RTC/DataConsumer.cpp @@ -278,22 +278,9 @@ namespace RTC MS_THROW_ERROR("no SCTP association present"); } - const auto* body = request->data->body_as(); - const uint8_t* data{ nullptr }; - size_t len{ 0 }; - - if (body->data_type() == FBS::DataConsumer::Data::String) - { - data = body->data_as_String()->value()->Data(); - len = body->data_as_String()->value()->size(); - } - else - { - data = body->data_as_Binary()->value()->Data(); - len = body->data_as_Binary()->value()->size(); - } - - const int ppid = body->ppid(); + const auto* body = request->data->body_as(); + const uint8_t* data = body->data()->Data(); + size_t len = body->data()->size(); if (len > this->maxMessageSize) { @@ -318,7 +305,7 @@ namespace RTC static std::vector EmptySubchannels; - SendMessage(data, len, ppid, EmptySubchannels, std::nullopt, cb); + SendMessage(data, len, body->ppid(), EmptySubchannels, std::nullopt, cb); break; } diff --git a/worker/src/RTC/DataProducer.cpp b/worker/src/RTC/DataProducer.cpp index a55b58f6a9..34c9efc525 100644 --- a/worker/src/RTC/DataProducer.cpp +++ b/worker/src/RTC/DataProducer.cpp @@ -199,20 +199,9 @@ namespace RTC { case Channel::ChannelNotification::Event::DATAPRODUCER_SEND: { - const auto* body = notification->data->body_as(); - const uint8_t* data{ nullptr }; - size_t len{ 0 }; - - if (body->data_type() == FBS::DataProducer::Data::String) - { - data = body->data_as_String()->value()->Data(); - len = body->data_as_String()->value()->size(); - } - else - { - data = body->data_as_Binary()->value()->Data(); - len = body->data_as_Binary()->value()->size(); - } + const auto* body = notification->data->body_as(); + const uint8_t* data = body->data()->Data(); + size_t len = body->data()->size(); if (len > this->maxMessageSize) { From 4b1ba623748c21ef53a4ec99e7c1c9af7873e85d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Fri, 27 Oct 2023 17:07:26 +0200 Subject: [PATCH 60/73] Rust: fix bench Update Cargo.lock which was missing. --- Cargo.lock | 4 ++-- rust/benches/producer.rs | 28 ++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f2d3f71493..ad04b8a1a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1057,7 +1057,7 @@ checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" [[package]] name = "mediasoup" -version = "0.11.4" +version = "0.12.0" dependencies = [ "actix", "actix-web", @@ -1094,7 +1094,7 @@ dependencies = [ [[package]] name = "mediasoup-sys" -version = "0.5.4" +version = "0.6.0" [[package]] name = "memchr" diff --git a/rust/benches/producer.rs b/rust/benches/producer.rs index b573896980..a6a5e87c64 100644 --- a/rust/benches/producer.rs +++ b/rust/benches/producer.rs @@ -4,6 +4,10 @@ use std::env; use std::net::{IpAddr, Ipv4Addr}; use std::num::{NonZeroU32, NonZeroU8}; +fn create_ssrc() -> u32 { + fastrand::u32(100_000_000..999_999_999) +} + fn media_codecs() -> Vec { vec![ RtpCodecCapability::Audio { @@ -162,24 +166,32 @@ fn video_producer_options() -> ProducerOptions { ], encodings: vec![ RtpEncodingParameters { - ssrc: Some(22222222), - rtx: Some(RtpEncodingParametersRtx { ssrc: 22222223 }), + ssrc: Some(create_ssrc()), + rtx: Some(RtpEncodingParametersRtx { + ssrc: create_ssrc(), + }), scalability_mode: "L1T3".parse().unwrap(), ..RtpEncodingParameters::default() }, RtpEncodingParameters { - ssrc: Some(22222224), - rtx: Some(RtpEncodingParametersRtx { ssrc: 22222225 }), + ssrc: Some(create_ssrc()), + rtx: Some(RtpEncodingParametersRtx { + ssrc: create_ssrc(), + }), ..RtpEncodingParameters::default() }, RtpEncodingParameters { - ssrc: Some(22222226), - rtx: Some(RtpEncodingParametersRtx { ssrc: 22222227 }), + ssrc: Some(create_ssrc()), + rtx: Some(RtpEncodingParametersRtx { + ssrc: create_ssrc(), + }), ..RtpEncodingParameters::default() }, RtpEncodingParameters { - ssrc: Some(22222228), - rtx: Some(RtpEncodingParametersRtx { ssrc: 22222229 }), + ssrc: Some(create_ssrc()), + rtx: Some(RtpEncodingParametersRtx { + ssrc: create_ssrc(), + }), ..RtpEncodingParameters::default() }, ], From e8d100733dfa5666ce5a65d702d8e700fc310e1b Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Sun, 29 Oct 2023 21:35:32 +0200 Subject: [PATCH 61/73] Compile flatbuffers for Rust in build.rs --- Cargo.lock | 657 +- rust/Cargo.toml | 2 +- rust/src/data_structures.rs | 2 +- rust/src/fbs.rs | 80106 ------------------- rust/src/lib.rs | 1 - rust/src/messages.rs | 10 +- rust/src/ortc.rs | 2 +- rust/src/router/active_speaker_observer.rs | 2 +- rust/src/router/audio_level_observer.rs | 2 +- rust/src/router/consumer.rs | 4 +- rust/src/router/data_consumer.rs | 2 +- rust/src/router/data_producer.rs | 2 +- rust/src/router/direct_transport.rs | 2 +- rust/src/router/pipe_transport.rs | 2 +- rust/src/router/plain_transport.rs | 2 +- rust/src/router/producer.rs | 2 +- rust/src/router/transport.rs | 2 +- rust/src/router/webrtc_transport.rs | 2 +- rust/src/rtp_parameters.rs | 2 +- rust/src/sctp_parameters.rs | 2 +- rust/src/srtp_parameters.rs | 2 +- rust/src/webrtc_server.rs | 2 +- rust/src/worker.rs | 2 +- rust/src/worker/channel.rs | 2 +- rust/src/worker/common.rs | 2 +- worker/Cargo.toml | 12 + worker/build.rs | 31 +- worker/src/lib.rs | 2 + 28 files changed, 707 insertions(+), 80156 deletions(-) delete mode 100644 rust/src/fbs.rs 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); From 66e014ec6f0427aa47f906bf668f2ad05c780310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Mon, 30 Oct 2023 16:58:55 +0100 Subject: [PATCH 62/73] FBS: Remove unneeded message type member (#1203) FBS: Remove unneeded message type member It's not needed since the body contained in the message is aleady typed. --- node/src/Channel.ts | 12 +- rust/src/messages.rs | 137 ++++++++++----------- worker/fbs/message.fbs | 8 -- worker/include/Channel/ChannelNotifier.hpp | 14 +-- worker/include/Channel/ChannelRequest.hpp | 4 +- worker/src/Channel/ChannelRequest.cpp | 4 +- worker/src/Channel/ChannelSocket.cpp | 14 +-- 7 files changed, 88 insertions(+), 105 deletions(-) diff --git a/node/src/Channel.ts b/node/src/Channel.ts index 0a69f99916..654c588b32 100644 --- a/node/src/Channel.ts +++ b/node/src/Channel.ts @@ -6,7 +6,7 @@ import { EnhancedEventEmitter } from './EnhancedEventEmitter'; import { InvalidStateError } from './errors'; import { Body as RequestBody, Method, Request } from './fbs/request'; import { Response } from './fbs/response'; -import { Message, Type as MessageType, Body as MessageBody } from './fbs/message'; +import { Message, Body as MessageBody } from './fbs/message'; import { Notification, Body as NotificationBody, Event } from './fbs/notification'; import { Log } from './fbs/log'; @@ -128,9 +128,9 @@ export class Channel extends EnhancedEventEmitter try { - switch (message.type()) + switch (message.dataType()) { - case MessageType.RESPONSE: + case MessageBody.Response: { const response = new Response(); @@ -141,7 +141,7 @@ export class Channel extends EnhancedEventEmitter break; } - case MessageType.NOTIFICATION: + case MessageBody.Notification: { const notification = new Notification(); @@ -152,7 +152,7 @@ export class Channel extends EnhancedEventEmitter break; } - case MessageType.LOG: + case MessageBody.Log: { const log = new Log(); @@ -283,7 +283,6 @@ export class Channel extends EnhancedEventEmitter const messageOffset = Message.createMessage( this.#bufferBuilder, - MessageType.NOTIFICATION, MessageBody.Notification, notificationOffset ); @@ -348,7 +347,6 @@ export class Channel extends EnhancedEventEmitter const messageOffset = Message.createMessage( this.#bufferBuilder, - MessageType.REQUEST, MessageBody.Request, requestOffset ); diff --git a/rust/src/messages.rs b/rust/src/messages.rs index 204ac53b53..1d38d9d9f8 100644 --- a/rust/src/messages.rs +++ b/rust/src/messages.rs @@ -95,7 +95,7 @@ impl Request for WorkerCloseRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -126,7 +126,7 @@ impl Request for WorkerDumpRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -203,7 +203,7 @@ impl Request for WorkerUpdateSettingsRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -243,7 +243,7 @@ impl Request for WorkerCreateWebRtcServerRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -282,7 +282,7 @@ impl Request for WebRtcServerCloseRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -313,7 +313,7 @@ impl Request for WebRtcServerDumpRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -395,7 +395,7 @@ impl Request for WorkerCreateRouterRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -430,7 +430,7 @@ impl Request for RouterCloseRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -461,7 +461,7 @@ impl Request for RouterDumpRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -606,7 +606,7 @@ impl Request for RouterCreateDirectTransportRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -772,7 +772,7 @@ impl Request for RouterCreateWebRtcTransportRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -849,7 +849,7 @@ impl Request for RouterCreateWebRtcTransportWithServerRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -981,7 +981,7 @@ impl Request for RouterCreatePlainTransportRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1107,7 +1107,7 @@ impl Request for RouterCreatePipeTransportRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1208,7 +1208,7 @@ impl Request for RouterCreateAudioLevelObserverRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1273,7 +1273,7 @@ impl Request for RouterCreateActiveSpeakerObserverRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1304,7 +1304,7 @@ impl Request for TransportDumpRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1339,7 +1339,7 @@ impl Request for TransportGetStatsRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1380,7 +1380,7 @@ impl Request for TransportCloseRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1421,7 +1421,7 @@ impl Request for WebRtcTransportConnectRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1475,7 +1475,7 @@ impl Request for PipeTransportConnectRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1534,7 +1534,7 @@ impl Request for TransportConnectPlainRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1584,7 +1584,7 @@ impl Request for TransportSetMaxIncomingBitrateRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1620,7 +1620,7 @@ impl Request for TransportSetMaxOutgoingBitrateRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1656,7 +1656,7 @@ impl Request for TransportSetMinOutgoingBitrateRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1686,7 +1686,7 @@ impl Request for TransportRestartIceRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1748,7 +1748,7 @@ impl Request for TransportProduceRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1820,7 +1820,7 @@ impl Request for TransportConsumeRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1902,7 +1902,7 @@ impl Request for TransportProduceDataRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -1993,7 +1993,7 @@ impl Request for TransportConsumeDataRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2054,7 +2054,7 @@ impl Request for TransportEnableTraceEventRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2094,7 +2094,7 @@ impl Notification for TransportSendRtcpNotification { Some(notification_body), ); let message_body = message::Body::create_notification(&mut builder, notification); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2125,7 +2125,7 @@ impl Request for ProducerCloseRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2156,7 +2156,7 @@ impl Request for ProducerDumpRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2191,7 +2191,7 @@ impl Request for ProducerGetStatsRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2227,7 +2227,7 @@ impl Request for ProducerPauseRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2258,7 +2258,7 @@ impl Request for ProducerResumeRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2300,7 +2300,7 @@ impl Request for ProducerEnableTraceEventRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2340,7 +2340,7 @@ impl Notification for ProducerSendNotification { Some(notification_body), ); let message_body = message::Body::create_notification(&mut builder, notification); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2371,7 +2371,7 @@ impl Request for ConsumerCloseRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2402,7 +2402,7 @@ impl Request for ConsumerDumpRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2437,7 +2437,7 @@ impl Request for ConsumerGetStatsRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2473,7 +2473,7 @@ impl Request for ConsumerPauseRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2504,7 +2504,7 @@ impl Request for ConsumerResumeRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2544,7 +2544,7 @@ impl Request for ConsumerSetPreferredLayersRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2594,7 +2594,7 @@ impl Request for ConsumerSetPriorityRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2632,7 +2632,7 @@ impl Request for ConsumerRequestKeyFrameRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2674,7 +2674,7 @@ impl Request for ConsumerEnableTraceEventRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2717,7 +2717,7 @@ impl Request for DataProducerCloseRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2748,7 +2748,7 @@ impl Request for DataProducerDumpRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2784,7 +2784,7 @@ impl Request for DataProducerGetStatsRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2820,7 +2820,7 @@ impl Request for DataProducerPauseRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2851,7 +2851,7 @@ impl Request for DataProducerResumeRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2895,8 +2895,7 @@ impl Notification for DataProducerSendNotification { Some(notification_body), ); let message_body = message::Body::create_notification(&mut builder, notification); - let message = - message::Message::create(&mut builder, message::Type::Notification, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2929,7 +2928,7 @@ impl Request for DataConsumerCloseRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2960,7 +2959,7 @@ impl Request for DataConsumerDumpRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -2996,7 +2995,7 @@ impl Request for DataConsumerGetStatsRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -3032,7 +3031,7 @@ impl Request for DataConsumerPauseRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -3063,7 +3062,7 @@ impl Request for DataConsumerResumeRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -3099,7 +3098,7 @@ impl Request for DataConsumerGetBufferedAmountRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -3150,7 +3149,7 @@ impl Request for DataConsumerSetBufferedAmountLowThresholdRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -3188,7 +3187,7 @@ impl Request for DataConsumerSendRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -3236,7 +3235,7 @@ impl Request for DataConsumerSetSubchannelsRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -3281,7 +3280,7 @@ impl Request for RtpObserverCloseRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -3311,7 +3310,7 @@ impl Request for RtpObserverPauseRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -3341,7 +3340,7 @@ impl Request for RtpObserverResumeRequest { None::, ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -3380,7 +3379,7 @@ impl Request for RtpObserverAddProducerRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } @@ -3419,7 +3418,7 @@ impl Request for RtpObserverRemoveProducerRequest { Some(request_body), ); let message_body = message::Body::create_request(&mut builder, request); - let message = message::Message::create(&mut builder, message::Type::Request, message_body); + let message = message::Message::create(&mut builder, message_body); builder.finish(message, None).to_vec() } diff --git a/worker/fbs/message.fbs b/worker/fbs/message.fbs index 0e01a809d6..233ff28b08 100644 --- a/worker/fbs/message.fbs +++ b/worker/fbs/message.fbs @@ -5,13 +5,6 @@ include "response.fbs"; namespace FBS.Message; -enum Type: uint8 { - REQUEST = 0, - RESPONSE, - NOTIFICATION, - LOG, -} - union Body { Request: FBS.Request.Request, Response: FBS.Response.Response, @@ -20,7 +13,6 @@ union Body { } table Message { - type: Type; data: Body (required); } diff --git a/worker/include/Channel/ChannelNotifier.hpp b/worker/include/Channel/ChannelNotifier.hpp index 4c16204feb..098b4366df 100644 --- a/worker/include/Channel/ChannelNotifier.hpp +++ b/worker/include/Channel/ChannelNotifier.hpp @@ -29,11 +29,8 @@ namespace Channel auto notification = FBS::Notification::CreateNotificationDirect( builder, targetId.c_str(), event, type, body.Union()); - auto message = FBS::Message::CreateMessage( - builder, - FBS::Message::Type::NOTIFICATION, - FBS::Message::Body::Notification, - notification.Union()); + auto message = + FBS::Message::CreateMessage(builder, FBS::Message::Body::Notification, notification.Union()); builder.FinishSizePrefixed(message); this->channel->Send(builder.GetBufferPointer(), builder.GetSize()); @@ -46,11 +43,8 @@ namespace Channel auto notification = FBS::Notification::CreateNotificationDirect(builder, targetId.c_str(), event); - auto message = FBS::Message::CreateMessage( - builder, - FBS::Message::Type::NOTIFICATION, - FBS::Message::Body::Notification, - notification.Union()); + auto message = + FBS::Message::CreateMessage(builder, FBS::Message::Body::Notification, notification.Union()); builder.FinishSizePrefixed(message); this->channel->Send(builder.GetBufferPointer(), builder.GetSize()); diff --git a/worker/include/Channel/ChannelRequest.hpp b/worker/include/Channel/ChannelRequest.hpp index 96f960f7d4..5ae484798e 100644 --- a/worker/include/Channel/ChannelRequest.hpp +++ b/worker/include/Channel/ChannelRequest.hpp @@ -42,8 +42,8 @@ namespace Channel auto& builder = this->bufferBuilder; auto response = FBS::Response::CreateResponse(builder, this->id, true, type, body.Union()); - auto message = FBS::Message::CreateMessage( - builder, FBS::Message::Type::RESPONSE, FBS::Message::Body::Response, response.Union()); + auto message = + FBS::Message::CreateMessage(builder, FBS::Message::Body::Response, response.Union()); builder.FinishSizePrefixed(message); this->Send(builder.GetBufferPointer(), builder.GetSize()); diff --git a/worker/src/Channel/ChannelRequest.cpp b/worker/src/Channel/ChannelRequest.cpp index f70619c642..3c97af5f05 100644 --- a/worker/src/Channel/ChannelRequest.cpp +++ b/worker/src/Channel/ChannelRequest.cpp @@ -165,8 +165,8 @@ namespace Channel void ChannelRequest::SendResponse(const flatbuffers::Offset& response) { auto& builder = this->bufferBuilder; - auto message = FBS::Message::CreateMessage( - builder, FBS::Message::Type::RESPONSE, FBS::Message::Body::Response, response.Union()); + auto message = + FBS::Message::CreateMessage(builder, FBS::Message::Body::Response, response.Union()); builder.FinishSizePrefixed(message); this->Send(builder.GetBufferPointer(), builder.GetSize()); diff --git a/worker/src/Channel/ChannelSocket.cpp b/worker/src/Channel/ChannelSocket.cpp index a38670b34a..570bc6c2f5 100644 --- a/worker/src/Channel/ChannelSocket.cpp +++ b/worker/src/Channel/ChannelSocket.cpp @@ -149,9 +149,9 @@ namespace Channel return; } - auto log = FBS::Log::CreateLogDirect(this->bufferBuilder, msg); - auto message = FBS::Message::CreateMessage( - this->bufferBuilder, FBS::Message::Type::LOG, FBS::Message::Body::Log, log.Union()); + auto log = FBS::Log::CreateLogDirect(this->bufferBuilder, msg); + auto message = + FBS::Message::CreateMessage(this->bufferBuilder, FBS::Message::Body::Log, log.Union()); this->bufferBuilder.FinishSizePrefixed(message); this->Send(this->bufferBuilder.GetBufferPointer(), this->bufferBuilder.GetSize()); @@ -185,7 +185,7 @@ namespace Channel MS_DUMP("%s", s.c_str()); #endif - if (message->type() == FBS::Message::Type::REQUEST) + if (message->data_type() == FBS::Message::Body::Request) { ChannelRequest* request; @@ -207,7 +207,7 @@ namespace Channel delete request; } - else if (message->type() == FBS::Message::Type::NOTIFICATION) + else if (message->data_type() == FBS::Message::Body::Notification) { ChannelNotification* notification; @@ -265,7 +265,7 @@ namespace Channel MS_DUMP("%s", s.c_str()); #endif - if (message->type() == FBS::Message::Type::REQUEST) + if (message->data_type() == FBS::Message::Body::Request) { ChannelRequest* request; @@ -287,7 +287,7 @@ namespace Channel delete request; } - else if (message->type() == FBS::Message::Type::NOTIFICATION) + else if (message->data_type() == FBS::Message::Body::Notification) { ChannelNotification* notification; From e81b8ebbe06e432b13425ca2a25994e29a6d57fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Tue, 31 Oct 2023 13:07:59 +0100 Subject: [PATCH 63/73] gitignore .nvmrc file --- .gitignore | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 4c488de2f1..befa25fdc1 100644 --- a/.gitignore +++ b/.gitignore @@ -7,8 +7,10 @@ ## Node. /node_modules /node/lib -# Flatc generated files. +# flatc generated files. /node/src/fbs +# nvm version file. +/.nvmrc ## Rust. /rust/examples-frontend/*/node_modules @@ -41,6 +43,5 @@ /.vscode # JetBrains IDE stuff. /.idea - # Packaged module. *.tgz From e5dbc9a60d4ccf459bf80be85c521fd4b6081041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Tue, 31 Oct 2023 13:13:33 +0100 Subject: [PATCH 64/73] Update Node deps --- package-lock.json | 404 +++++++++++++++++++++++----------------------- package.json | 12 +- 2 files changed, 208 insertions(+), 208 deletions(-) diff --git a/package-lock.json b/package-lock.json index dbf6d506f9..66731eb964 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,14 +20,14 @@ "devDependencies": { "@octokit/rest": "^20.0.2", "@types/debug": "^4.1.10", - "@types/jest": "^29.5.6", - "@types/node": "^20.8.8", - "@typescript-eslint/eslint-plugin": "^6.9.0", - "@typescript-eslint/parser": "^6.9.0", + "@types/jest": "^29.5.7", + "@types/node": "^20.8.10", + "@typescript-eslint/eslint-plugin": "^6.9.1", + "@typescript-eslint/parser": "^6.9.1", "eslint": "^8.52.0", - "eslint-plugin-jest": "^27.4.3", + "eslint-plugin-jest": "^27.6.0", "jest": "^29.7.0", - "marked": "^9.1.2", + "marked": "^9.1.4", "open-cli": "^7.2.0", "pick-port": "^1.0.1", "sctp": "^1.0.0", @@ -1591,9 +1591,9 @@ } }, "node_modules/@types/jest": { - "version": "29.5.6", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.6.tgz", - "integrity": "sha512-/t9NnzkOpXb4Nfvg17ieHE6EeSjDS2SGSpNYfoLbUAeL/EOueU/RSdOWFpfQTXBEM7BguYW1XQ0EbM+6RlIh6w==", + "version": "29.5.7", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.7.tgz", + "integrity": "sha512-HLyetab6KVPSiF+7pFcUyMeLsx25LDNDemw9mGsJBkai/oouwrjTycocSDYopMEwFhN2Y4s9oPyOCZNofgSt2g==", "dev": true, "dependencies": { "expect": "^29.0.0", @@ -1619,12 +1619,12 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.8.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.8.tgz", - "integrity": "sha512-YRsdVxq6OaLfmR9Hy816IMp33xOBjfyOgUd77ehqg96CFywxAPbDbXvAsuN2KVg2HOT8Eh6uAfU+l4WffwPVrQ==", + "version": "20.8.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.10.tgz", + "integrity": "sha512-TlgT8JntpcbmKUFzjhsyhGfP2fsiz1Mv56im6enJ905xG1DAYesxJaeSbGqQmAw8OWPdhyJGhGSQGKRNJ45u9w==", "dev": true, "dependencies": { - "undici-types": "~5.25.1" + "undici-types": "~5.26.4" } }, "node_modules/@types/normalize-package-data": { @@ -1661,16 +1661,16 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.9.0.tgz", - "integrity": "sha512-lgX7F0azQwRPB7t7WAyeHWVfW1YJ9NIgd9mvGhfQpRY56X6AVf8mwM8Wol+0z4liE7XX3QOt8MN1rUKCfSjRIA==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.9.1.tgz", + "integrity": "sha512-w0tiiRc9I4S5XSXXrMHOWgHgxbrBn1Ro+PmiYhSg2ZVdxrAJtQgzU5o2m1BfP6UOn7Vxcc6152vFjQfmZR4xEg==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.9.0", - "@typescript-eslint/type-utils": "6.9.0", - "@typescript-eslint/utils": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0", + "@typescript-eslint/scope-manager": "6.9.1", + "@typescript-eslint/type-utils": "6.9.1", + "@typescript-eslint/utils": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -1696,13 +1696,13 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz", - "integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.1.tgz", + "integrity": "sha512-38IxvKB6NAne3g/+MyXMs2Cda/Sz+CEpmm+KLGEM8hx/CvnSRuw51i8ukfwB/B/sESdeTGet1NH1Wj7I0YXswg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0" + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1713,9 +1713,9 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz", - "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.1.tgz", + "integrity": "sha512-BUGslGOb14zUHOUmDB2FfT6SI1CcZEJYfF3qFwBeUrU6srJfzANonwRYHDpLBuzbq3HaoF2XL2hcr01c8f8OaQ==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1726,13 +1726,13 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/typescript-estree": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz", - "integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.1.tgz", + "integrity": "sha512-U+mUylTHfcqeO7mLWVQ5W/tMLXqVpRv61wm9ZtfE5egz7gtnmqVIw9ryh0mgIlkKk9rZLY3UHygsBSdB9/ftyw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -1753,17 +1753,17 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/utils": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.0.tgz", - "integrity": "sha512-5Wf+Jsqya7WcCO8me504FBigeQKVLAMPmUzYgDbWchINNh1KJbxCgVya3EQ2MjvJMVeXl3pofRmprqX6mfQkjQ==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.1.tgz", + "integrity": "sha512-L1T0A5nFdQrMVunpZgzqPL6y2wVreSyHhKGZryS6jrEN7bD9NplVAyMryUhXsQ4TWLnZmxc2ekar/lSGIlprCA==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.9.0", - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/typescript-estree": "6.9.0", + "@typescript-eslint/scope-manager": "6.9.1", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/typescript-estree": "6.9.1", "semver": "^7.5.4" }, "engines": { @@ -1778,12 +1778,12 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz", - "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.1.tgz", + "integrity": "sha512-MUaPUe/QRLEffARsmNfmpghuQkW436DvESW+h+M52w0coICHRfD6Np9/K6PdACwnrq1HmuLl+cSPZaJmeVPkSw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/types": "6.9.1", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -1795,15 +1795,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.9.0.tgz", - "integrity": "sha512-GZmjMh4AJ/5gaH4XF2eXA8tMnHWP+Pm1mjQR2QN4Iz+j/zO04b9TOvJYOX2sCNIQHtRStKTxRY1FX7LhpJT4Gw==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.9.1.tgz", + "integrity": "sha512-C7AK2wn43GSaCUZ9do6Ksgi2g3mwFkMO3Cis96kzmgudoVaKyt62yNzJOktP0HDLb/iO2O0n2lBOzJgr6Q/cyg==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "6.9.0", - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/typescript-estree": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0", + "@typescript-eslint/scope-manager": "6.9.1", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/typescript-estree": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1", "debug": "^4.3.4" }, "engines": { @@ -1823,13 +1823,13 @@ } }, "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz", - "integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.1.tgz", + "integrity": "sha512-38IxvKB6NAne3g/+MyXMs2Cda/Sz+CEpmm+KLGEM8hx/CvnSRuw51i8ukfwB/B/sESdeTGet1NH1Wj7I0YXswg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0" + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1840,9 +1840,9 @@ } }, "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz", - "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.1.tgz", + "integrity": "sha512-BUGslGOb14zUHOUmDB2FfT6SI1CcZEJYfF3qFwBeUrU6srJfzANonwRYHDpLBuzbq3HaoF2XL2hcr01c8f8OaQ==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1853,13 +1853,13 @@ } }, "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz", - "integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.1.tgz", + "integrity": "sha512-U+mUylTHfcqeO7mLWVQ5W/tMLXqVpRv61wm9ZtfE5egz7gtnmqVIw9ryh0mgIlkKk9rZLY3UHygsBSdB9/ftyw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -1880,12 +1880,12 @@ } }, "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz", - "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.1.tgz", + "integrity": "sha512-MUaPUe/QRLEffARsmNfmpghuQkW436DvESW+h+M52w0coICHRfD6Np9/K6PdACwnrq1HmuLl+cSPZaJmeVPkSw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/types": "6.9.1", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -1914,13 +1914,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.9.0.tgz", - "integrity": "sha512-XXeahmfbpuhVbhSOROIzJ+b13krFmgtc4GlEuu1WBT+RpyGPIA4Y/eGnXzjbDj5gZLzpAXO/sj+IF/x2GtTMjQ==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.9.1.tgz", + "integrity": "sha512-eh2oHaUKCK58qIeYp19F5V5TbpM52680sB4zNSz29VBQPTWIlE/hCj5P5B1AChxECe/fmZlspAWFuRniep1Skg==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "6.9.0", - "@typescript-eslint/utils": "6.9.0", + "@typescript-eslint/typescript-estree": "6.9.1", + "@typescript-eslint/utils": "6.9.1", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -1941,13 +1941,13 @@ } }, "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/scope-manager": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz", - "integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.1.tgz", + "integrity": "sha512-38IxvKB6NAne3g/+MyXMs2Cda/Sz+CEpmm+KLGEM8hx/CvnSRuw51i8ukfwB/B/sESdeTGet1NH1Wj7I0YXswg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0" + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1958,9 +1958,9 @@ } }, "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/types": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz", - "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.1.tgz", + "integrity": "sha512-BUGslGOb14zUHOUmDB2FfT6SI1CcZEJYfF3qFwBeUrU6srJfzANonwRYHDpLBuzbq3HaoF2XL2hcr01c8f8OaQ==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1971,13 +1971,13 @@ } }, "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/typescript-estree": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz", - "integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.1.tgz", + "integrity": "sha512-U+mUylTHfcqeO7mLWVQ5W/tMLXqVpRv61wm9ZtfE5egz7gtnmqVIw9ryh0mgIlkKk9rZLY3UHygsBSdB9/ftyw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -1998,17 +1998,17 @@ } }, "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/utils": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.0.tgz", - "integrity": "sha512-5Wf+Jsqya7WcCO8me504FBigeQKVLAMPmUzYgDbWchINNh1KJbxCgVya3EQ2MjvJMVeXl3pofRmprqX6mfQkjQ==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.1.tgz", + "integrity": "sha512-L1T0A5nFdQrMVunpZgzqPL6y2wVreSyHhKGZryS6jrEN7bD9NplVAyMryUhXsQ4TWLnZmxc2ekar/lSGIlprCA==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.9.0", - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/typescript-estree": "6.9.0", + "@typescript-eslint/scope-manager": "6.9.1", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/typescript-estree": "6.9.1", "semver": "^7.5.4" }, "engines": { @@ -2023,12 +2023,12 @@ } }, "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/visitor-keys": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz", - "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.1.tgz", + "integrity": "sha512-MUaPUe/QRLEffARsmNfmpghuQkW436DvESW+h+M52w0coICHRfD6Np9/K6PdACwnrq1HmuLl+cSPZaJmeVPkSw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/types": "6.9.1", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -3078,9 +3078,9 @@ } }, "node_modules/eslint-plugin-jest": { - "version": "27.4.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.4.3.tgz", - "integrity": "sha512-7S6SmmsHsgIm06BAGCAxL+ABd9/IB3MWkz2pudj6Qqor2y1qQpWPfuFU4SG9pWj4xDjF0e+D7Llh5useuSzAZw==", + "version": "27.6.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.6.0.tgz", + "integrity": "sha512-MTlusnnDMChbElsszJvrwD1dN3x6nZl//s4JD23BxB6MgR66TZlL064su24xEIS3VACfAoHV1vgyMgPw8nkdng==", "dev": true, "dependencies": { "@typescript-eslint/utils": "^5.10.0" @@ -4849,9 +4849,9 @@ } }, "node_modules/marked": { - "version": "9.1.2", - "resolved": "https://registry.npmjs.org/marked/-/marked-9.1.2.tgz", - "integrity": "sha512-qoKMJqK0w6vkLk8+KnKZAH6neUZSNaQqVZ/h2yZ9S7CbLuFHyS2viB0jnqcWF9UKjwsAbMrQtnQhdmdvOVOw9w==", + "version": "9.1.4", + "resolved": "https://registry.npmjs.org/marked/-/marked-9.1.4.tgz", + "integrity": "sha512-Mq83CCaClhXqhf8sLQ57c1unNelHEuFadK36ga+GeXR4FeT/5ssaC5PaCRVqMA74VYorzYRqdAaxxteIanh3Kw==", "dev": true, "bin": { "marked": "bin/marked.js" @@ -6471,9 +6471,9 @@ } }, "node_modules/undici-types": { - "version": "5.25.3", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz", - "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==", + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "dev": true }, "node_modules/unique-string": { @@ -7978,9 +7978,9 @@ } }, "@types/jest": { - "version": "29.5.6", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.6.tgz", - "integrity": "sha512-/t9NnzkOpXb4Nfvg17ieHE6EeSjDS2SGSpNYfoLbUAeL/EOueU/RSdOWFpfQTXBEM7BguYW1XQ0EbM+6RlIh6w==", + "version": "29.5.7", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.7.tgz", + "integrity": "sha512-HLyetab6KVPSiF+7pFcUyMeLsx25LDNDemw9mGsJBkai/oouwrjTycocSDYopMEwFhN2Y4s9oPyOCZNofgSt2g==", "dev": true, "requires": { "expect": "^29.0.0", @@ -8006,12 +8006,12 @@ "dev": true }, "@types/node": { - "version": "20.8.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.8.tgz", - "integrity": "sha512-YRsdVxq6OaLfmR9Hy816IMp33xOBjfyOgUd77ehqg96CFywxAPbDbXvAsuN2KVg2HOT8Eh6uAfU+l4WffwPVrQ==", + "version": "20.8.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.10.tgz", + "integrity": "sha512-TlgT8JntpcbmKUFzjhsyhGfP2fsiz1Mv56im6enJ905xG1DAYesxJaeSbGqQmAw8OWPdhyJGhGSQGKRNJ45u9w==", "dev": true, "requires": { - "undici-types": "~5.25.1" + "undici-types": "~5.26.4" } }, "@types/normalize-package-data": { @@ -8048,16 +8048,16 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.9.0.tgz", - "integrity": "sha512-lgX7F0azQwRPB7t7WAyeHWVfW1YJ9NIgd9mvGhfQpRY56X6AVf8mwM8Wol+0z4liE7XX3QOt8MN1rUKCfSjRIA==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.9.1.tgz", + "integrity": "sha512-w0tiiRc9I4S5XSXXrMHOWgHgxbrBn1Ro+PmiYhSg2ZVdxrAJtQgzU5o2m1BfP6UOn7Vxcc6152vFjQfmZR4xEg==", "dev": true, "requires": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.9.0", - "@typescript-eslint/type-utils": "6.9.0", - "@typescript-eslint/utils": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0", + "@typescript-eslint/scope-manager": "6.9.1", + "@typescript-eslint/type-utils": "6.9.1", + "@typescript-eslint/utils": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -8067,29 +8067,29 @@ }, "dependencies": { "@typescript-eslint/scope-manager": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz", - "integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.1.tgz", + "integrity": "sha512-38IxvKB6NAne3g/+MyXMs2Cda/Sz+CEpmm+KLGEM8hx/CvnSRuw51i8ukfwB/B/sESdeTGet1NH1Wj7I0YXswg==", "dev": true, "requires": { - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0" + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1" } }, "@typescript-eslint/types": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz", - "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.1.tgz", + "integrity": "sha512-BUGslGOb14zUHOUmDB2FfT6SI1CcZEJYfF3qFwBeUrU6srJfzANonwRYHDpLBuzbq3HaoF2XL2hcr01c8f8OaQ==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz", - "integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.1.tgz", + "integrity": "sha512-U+mUylTHfcqeO7mLWVQ5W/tMLXqVpRv61wm9ZtfE5egz7gtnmqVIw9ryh0mgIlkKk9rZLY3UHygsBSdB9/ftyw==", "dev": true, "requires": { - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -8098,69 +8098,69 @@ } }, "@typescript-eslint/utils": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.0.tgz", - "integrity": "sha512-5Wf+Jsqya7WcCO8me504FBigeQKVLAMPmUzYgDbWchINNh1KJbxCgVya3EQ2MjvJMVeXl3pofRmprqX6mfQkjQ==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.1.tgz", + "integrity": "sha512-L1T0A5nFdQrMVunpZgzqPL6y2wVreSyHhKGZryS6jrEN7bD9NplVAyMryUhXsQ4TWLnZmxc2ekar/lSGIlprCA==", "dev": true, "requires": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.9.0", - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/typescript-estree": "6.9.0", + "@typescript-eslint/scope-manager": "6.9.1", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/typescript-estree": "6.9.1", "semver": "^7.5.4" } }, "@typescript-eslint/visitor-keys": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz", - "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.1.tgz", + "integrity": "sha512-MUaPUe/QRLEffARsmNfmpghuQkW436DvESW+h+M52w0coICHRfD6Np9/K6PdACwnrq1HmuLl+cSPZaJmeVPkSw==", "dev": true, "requires": { - "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/types": "6.9.1", "eslint-visitor-keys": "^3.4.1" } } } }, "@typescript-eslint/parser": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.9.0.tgz", - "integrity": "sha512-GZmjMh4AJ/5gaH4XF2eXA8tMnHWP+Pm1mjQR2QN4Iz+j/zO04b9TOvJYOX2sCNIQHtRStKTxRY1FX7LhpJT4Gw==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.9.1.tgz", + "integrity": "sha512-C7AK2wn43GSaCUZ9do6Ksgi2g3mwFkMO3Cis96kzmgudoVaKyt62yNzJOktP0HDLb/iO2O0n2lBOzJgr6Q/cyg==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "6.9.0", - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/typescript-estree": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0", + "@typescript-eslint/scope-manager": "6.9.1", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/typescript-estree": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1", "debug": "^4.3.4" }, "dependencies": { "@typescript-eslint/scope-manager": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz", - "integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.1.tgz", + "integrity": "sha512-38IxvKB6NAne3g/+MyXMs2Cda/Sz+CEpmm+KLGEM8hx/CvnSRuw51i8ukfwB/B/sESdeTGet1NH1Wj7I0YXswg==", "dev": true, "requires": { - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0" + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1" } }, "@typescript-eslint/types": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz", - "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.1.tgz", + "integrity": "sha512-BUGslGOb14zUHOUmDB2FfT6SI1CcZEJYfF3qFwBeUrU6srJfzANonwRYHDpLBuzbq3HaoF2XL2hcr01c8f8OaQ==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz", - "integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.1.tgz", + "integrity": "sha512-U+mUylTHfcqeO7mLWVQ5W/tMLXqVpRv61wm9ZtfE5egz7gtnmqVIw9ryh0mgIlkKk9rZLY3UHygsBSdB9/ftyw==", "dev": true, "requires": { - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -8169,12 +8169,12 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz", - "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.1.tgz", + "integrity": "sha512-MUaPUe/QRLEffARsmNfmpghuQkW436DvESW+h+M52w0coICHRfD6Np9/K6PdACwnrq1HmuLl+cSPZaJmeVPkSw==", "dev": true, "requires": { - "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/types": "6.9.1", "eslint-visitor-keys": "^3.4.1" } } @@ -8191,41 +8191,41 @@ } }, "@typescript-eslint/type-utils": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.9.0.tgz", - "integrity": "sha512-XXeahmfbpuhVbhSOROIzJ+b13krFmgtc4GlEuu1WBT+RpyGPIA4Y/eGnXzjbDj5gZLzpAXO/sj+IF/x2GtTMjQ==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.9.1.tgz", + "integrity": "sha512-eh2oHaUKCK58qIeYp19F5V5TbpM52680sB4zNSz29VBQPTWIlE/hCj5P5B1AChxECe/fmZlspAWFuRniep1Skg==", "dev": true, "requires": { - "@typescript-eslint/typescript-estree": "6.9.0", - "@typescript-eslint/utils": "6.9.0", + "@typescript-eslint/typescript-estree": "6.9.1", + "@typescript-eslint/utils": "6.9.1", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, "dependencies": { "@typescript-eslint/scope-manager": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz", - "integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.1.tgz", + "integrity": "sha512-38IxvKB6NAne3g/+MyXMs2Cda/Sz+CEpmm+KLGEM8hx/CvnSRuw51i8ukfwB/B/sESdeTGet1NH1Wj7I0YXswg==", "dev": true, "requires": { - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0" + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1" } }, "@typescript-eslint/types": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz", - "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.1.tgz", + "integrity": "sha512-BUGslGOb14zUHOUmDB2FfT6SI1CcZEJYfF3qFwBeUrU6srJfzANonwRYHDpLBuzbq3HaoF2XL2hcr01c8f8OaQ==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz", - "integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.1.tgz", + "integrity": "sha512-U+mUylTHfcqeO7mLWVQ5W/tMLXqVpRv61wm9ZtfE5egz7gtnmqVIw9ryh0mgIlkKk9rZLY3UHygsBSdB9/ftyw==", "dev": true, "requires": { - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/visitor-keys": "6.9.0", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/visitor-keys": "6.9.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -8234,27 +8234,27 @@ } }, "@typescript-eslint/utils": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.0.tgz", - "integrity": "sha512-5Wf+Jsqya7WcCO8me504FBigeQKVLAMPmUzYgDbWchINNh1KJbxCgVya3EQ2MjvJMVeXl3pofRmprqX6mfQkjQ==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.1.tgz", + "integrity": "sha512-L1T0A5nFdQrMVunpZgzqPL6y2wVreSyHhKGZryS6jrEN7bD9NplVAyMryUhXsQ4TWLnZmxc2ekar/lSGIlprCA==", "dev": true, "requires": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.9.0", - "@typescript-eslint/types": "6.9.0", - "@typescript-eslint/typescript-estree": "6.9.0", + "@typescript-eslint/scope-manager": "6.9.1", + "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/typescript-estree": "6.9.1", "semver": "^7.5.4" } }, "@typescript-eslint/visitor-keys": { - "version": "6.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz", - "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==", + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.1.tgz", + "integrity": "sha512-MUaPUe/QRLEffARsmNfmpghuQkW436DvESW+h+M52w0coICHRfD6Np9/K6PdACwnrq1HmuLl+cSPZaJmeVPkSw==", "dev": true, "requires": { - "@typescript-eslint/types": "6.9.0", + "@typescript-eslint/types": "6.9.1", "eslint-visitor-keys": "^3.4.1" } } @@ -9013,9 +9013,9 @@ } }, "eslint-plugin-jest": { - "version": "27.4.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.4.3.tgz", - "integrity": "sha512-7S6SmmsHsgIm06BAGCAxL+ABd9/IB3MWkz2pudj6Qqor2y1qQpWPfuFU4SG9pWj4xDjF0e+D7Llh5useuSzAZw==", + "version": "27.6.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.6.0.tgz", + "integrity": "sha512-MTlusnnDMChbElsszJvrwD1dN3x6nZl//s4JD23BxB6MgR66TZlL064su24xEIS3VACfAoHV1vgyMgPw8nkdng==", "dev": true, "requires": { "@typescript-eslint/utils": "^5.10.0" @@ -10280,9 +10280,9 @@ "dev": true }, "marked": { - "version": "9.1.2", - "resolved": "https://registry.npmjs.org/marked/-/marked-9.1.2.tgz", - "integrity": "sha512-qoKMJqK0w6vkLk8+KnKZAH6neUZSNaQqVZ/h2yZ9S7CbLuFHyS2viB0jnqcWF9UKjwsAbMrQtnQhdmdvOVOw9w==", + "version": "9.1.4", + "resolved": "https://registry.npmjs.org/marked/-/marked-9.1.4.tgz", + "integrity": "sha512-Mq83CCaClhXqhf8sLQ57c1unNelHEuFadK36ga+GeXR4FeT/5ssaC5PaCRVqMA74VYorzYRqdAaxxteIanh3Kw==", "dev": true }, "meow": { @@ -11369,9 +11369,9 @@ "dev": true }, "undici-types": { - "version": "5.25.3", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz", - "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==", + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "dev": true }, "unique-string": { diff --git a/package.json b/package.json index 194fd8316d..42aeaa942d 100644 --- a/package.json +++ b/package.json @@ -105,14 +105,14 @@ "devDependencies": { "@octokit/rest": "^20.0.2", "@types/debug": "^4.1.10", - "@types/jest": "^29.5.6", - "@types/node": "^20.8.8", - "@typescript-eslint/eslint-plugin": "^6.9.0", - "@typescript-eslint/parser": "^6.9.0", + "@types/jest": "^29.5.7", + "@types/node": "^20.8.10", + "@typescript-eslint/eslint-plugin": "^6.9.1", + "@typescript-eslint/parser": "^6.9.1", "eslint": "^8.52.0", - "eslint-plugin-jest": "^27.4.3", + "eslint-plugin-jest": "^27.6.0", "jest": "^29.7.0", - "marked": "^9.1.2", + "marked": "^9.1.4", "open-cli": "^7.2.0", "pick-port": "^1.0.1", "sctp": "^1.0.0", From 96f0f45a3d3478e4f1d815f84b06da9b8b0cff75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Tue, 31 Oct 2023 17:01:44 +0100 Subject: [PATCH 65/73] Clean .gitignore Do not put there anything that it's not related to the project (such as files autogenerated by project tasks/scripts). Everything else (`.vscode`, `.idea`, `.DS_Store`, etc) can be individually added to our local `.git/info/exclude` file). --- .gitignore | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.gitignore b/.gitignore index befa25fdc1..abbaa0f7f2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,8 +9,6 @@ /node/lib # flatc generated files. /node/src/fbs -# nvm version file. -/.nvmrc ## Rust. /rust/examples-frontend/*/node_modules @@ -35,13 +33,5 @@ ## Others. /coverage /.cache -/NO_GIT -*.swp -*.swo -.DS_Store -# Vistual Studio Code stuff. -/.vscode -# JetBrains IDE stuff. -/.idea # Packaged module. *.tgz From 5ef6c2356105942346339c69d6e9f6f5eeb32ee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Tue, 31 Oct 2023 17:10:55 +0100 Subject: [PATCH 66/73] Transport.ts: ConsumerAppData => DataConsumerAppData --- node/src/Transport.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/node/src/Transport.ts b/node/src/Transport.ts index eae0cca9a8..7486cf8065 100644 --- a/node/src/Transport.ts +++ b/node/src/Transport.ts @@ -1077,7 +1077,7 @@ export class Transport /** * Create a DataConsumer. */ - async consumeData( + async consumeData( { dataProducerId, ordered, @@ -1086,8 +1086,8 @@ export class Transport paused = false, subchannels, appData - }: DataConsumerOptions - ): Promise> + }: DataConsumerOptions + ): Promise> { logger.debug('consumeData()'); @@ -1186,7 +1186,7 @@ export class Transport const dump = parseDataConsumerDumpResponse(consumeDataResponse); - const dataConsumer = new DataConsumer( + const dataConsumer = new DataConsumer( { internal : { From 0600cd8c45b1a0179dbab3f19b69582e9ab485e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Thu, 2 Nov 2023 12:34:28 +0100 Subject: [PATCH 67/73] FBS: Node, Fix RtpParameters (#1205) * FBS: Node, Fix RtpParameters Always pass encodings, header extensions and rtcp. --- node/src/RtpParameters.ts | 43 ++++++---------------- node/src/tests/test-Producer.ts | 63 +++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 32 deletions(-) diff --git a/node/src/RtpParameters.ts b/node/src/RtpParameters.ts index 760aaa15c8..95308b7a29 100644 --- a/node/src/RtpParameters.ts +++ b/node/src/RtpParameters.ts @@ -440,25 +440,15 @@ export function serializeRtpParameters( FbsRtpParameters.createHeaderExtensionsVector(builder, headerExtensions); // RtpEncodingParameters. - let encodingsOffset: number | undefined; - - if (rtpParameters.encodings) - { - encodingsOffset = serializeRtpEncodingParameters(builder, rtpParameters.encodings); - } + const encodingsOffset = serializeRtpEncodingParameters(builder, rtpParameters.encodings ?? []); // RtcpParameters. - let rtcpOffset: number | undefined; + const { cname, reducedSize } = rtpParameters.rtcp ?? { reducedSize: true }; + const cnameOffset = builder.createString(cname); - if (rtpParameters.rtcp) - { - const { cname, reducedSize } = rtpParameters.rtcp; - const cnameOffset = builder.createString(cname); - - rtcpOffset = FbsRtcpParameters.createRtcpParameters( - builder, cnameOffset, Boolean(reducedSize) - ); - } + const rtcpOffset = FbsRtcpParameters.createRtcpParameters( + builder, cnameOffset, Boolean(reducedSize) + ); const midOffset = builder.createString(rtpParameters.mid); @@ -466,31 +456,20 @@ export function serializeRtpParameters( FbsRtpParameters.addMid(builder, midOffset); FbsRtpParameters.addCodecs(builder, codecsOffset); - if (headerExtensions.length > 0) - { - FbsRtpParameters.addHeaderExtensions(builder, headerExtensionsOffset); - } - - if (encodingsOffset) - { - FbsRtpParameters.addEncodings(builder, encodingsOffset); - } - - if (rtcpOffset) - { - FbsRtpParameters.addRtcp(builder, rtcpOffset); - } + FbsRtpParameters.addHeaderExtensions(builder, headerExtensionsOffset); + FbsRtpParameters.addEncodings(builder, encodingsOffset); + FbsRtpParameters.addRtcp(builder, rtcpOffset); return FbsRtpParameters.endRtpParameters(builder); } export function serializeRtpEncodingParameters( - builder: flatbuffers.Builder, rtpEncodingParameters: RtpEncodingParameters[] + builder: flatbuffers.Builder, rtpEncodingParameters: RtpEncodingParameters[] = [] ): number { const encodings: number[] = []; - for (const encoding of rtpEncodingParameters ?? []) + for (const encoding of rtpEncodingParameters) { // Prepare Rid. const ridOffset = builder.createString(encoding.rid); diff --git a/node/src/tests/test-Producer.ts b/node/src/tests/test-Producer.ts index 603e14281c..05b2a515f3 100644 --- a/node/src/tests/test-Producer.ts +++ b/node/src/tests/test-Producer.ts @@ -235,6 +235,69 @@ test('transport2.produce() succeeds', async () => }); }, 2000); +test.only('transport1.produce() without header extensions and rtcp succeeds', async () => +{ + const onObserverNewProducer = jest.fn(); + + transport1.observer.once('newproducer', onObserverNewProducer); + + audioProducer = await transport1.produce( + { + kind : 'audio', + rtpParameters : + { + mid : 'AUDIO', + codecs : + [ + { + mimeType : 'audio/opus', + payloadType : 0, + clockRate : 48000, + channels : 2, + parameters : + { + useinbandfec : 1, + usedtx : 1, + foo : 222.222, + bar : '333' + } + } + ] + }, + appData : { foo: 1, bar: '2' } + }); + + expect(onObserverNewProducer).toHaveBeenCalledTimes(1); + expect(onObserverNewProducer).toHaveBeenCalledWith(audioProducer); + expect(typeof audioProducer.id).toBe('string'); + expect(audioProducer.closed).toBe(false); + expect(audioProducer.kind).toBe('audio'); + expect(typeof audioProducer.rtpParameters).toBe('object'); + expect(audioProducer.type).toBe('simple'); + // Private API. + expect(typeof audioProducer.consumableRtpParameters).toBe('object'); + expect(audioProducer.paused).toBe(false); + expect(audioProducer.score).toEqual([]); + expect(audioProducer.appData).toEqual({ foo: 1, bar: '2' }); + + await expect(router.dump()) + .resolves + .toMatchObject( + { + mapProducerIdConsumerIds : [ { key: audioProducer.id, values: [] } ], + mapConsumerIdProducerId : [] + }); + + await expect(transport1.dump()) + .resolves + .toMatchObject( + { + id : transport1.id, + producerIds : [ audioProducer.id ], + consumerIds : [] + }); +}, 2000); + test('transport1.produce() with wrong arguments rejects with TypeError', async () => { await expect(transport1.produce( From 325f0bd84ffb15947434ac845d9ee69bbd10fe09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Fri, 3 Nov 2023 11:08:02 +0100 Subject: [PATCH 68/73] clang-tidy: exclude cppcoreguidelines-avoid-do-while It makes it complain for every log or assert macro. --- worker/.clang-tidy | 1 + 1 file changed, 1 insertion(+) diff --git a/worker/.clang-tidy b/worker/.clang-tidy index ec3efa87e8..2394ea1409 100644 --- a/worker/.clang-tidy +++ b/worker/.clang-tidy @@ -7,6 +7,7 @@ Checks: "*,\ -clang-analyzer-optin.osx.*,\ -clang-analyzer-osx.*,\ -cppcoreguidelines-avoid-c-arrays,\ + -cppcoreguidelines-avoid-do-while,\ -cppcoreguidelines-avoid-goto,\ -cppcoreguidelines-avoid-magic-numbers,\ -cppcoreguidelines-init-variables,\ From f7e7fce47331dc690c79eb9f533d4a77ec9dffa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Fri, 3 Nov 2023 12:07:22 +0100 Subject: [PATCH 69/73] Improve npm-scripts (#1207) - Do not call `cleanWorkerArtifacts()` in `flatcNode()`. No reason for that plus it is bypassing the `MEDIASOUP_LOCAL_DEV` env purpose. - Use more readable object arguments. --- npm-scripts.mjs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/npm-scripts.mjs b/npm-scripts.mjs index 290a4b3a5d..42b07a6b10 100644 --- a/npm-scripts.mjs +++ b/npm-scripts.mjs @@ -42,8 +42,8 @@ async function run() // TypeScript to JavaScript. case 'prepare': { - flatcNode(/* clean */ true); - buildTypescript(/* force */ false); + flatcNode(); + buildTypescript({ force: false }); break; } @@ -86,7 +86,11 @@ async function run() logInfo(`couldn't fetch any mediasoup-worker prebuilt binary, building it locally`); buildWorker(); - cleanWorkerArtifacts(); + + if (!process.env.MEDIASOUP_LOCAL_DEV) + { + cleanWorkerArtifacts(); + } } break; @@ -95,7 +99,7 @@ async function run() case 'typescript:build': { installNodeDeps(); - buildTypescript(/* force */ true); + buildTypescript({ force: true }); break; } @@ -159,7 +163,7 @@ async function run() case 'test:node': { - buildTypescript(/* force */ false); + buildTypescript({ force: false }); testNode(); break; @@ -174,7 +178,7 @@ async function run() case 'coverage:node': { - buildTypescript(/* force */ false); + buildTypescript({ force: false }); executeCmd('jest --coverage'); executeCmd('open-cli coverage/lcov-report/index.html'); @@ -289,7 +293,7 @@ function deleteNodeLib() } } -function buildTypescript(force = false) +function buildTypescript({ force = false } = { force: false }) { if (!force && fs.existsSync('node/lib')) { @@ -358,7 +362,7 @@ function lintWorker() executeCmd(`${MAKE} lint -C worker`); } -function flatcNode(clean = false) +function flatcNode() { logInfo('flatcNode()'); @@ -382,11 +386,6 @@ function flatcNode(clean = false) { executeCmd(`for file in ${src}; do ${command} \$\{file\}; done`); } - - if (clean) - { - cleanWorkerArtifacts(); - } } function flatcWorker() @@ -433,7 +432,7 @@ function checkRelease() installNodeDeps(); flatcNode(); - buildTypescript(/* force */ true); + buildTypescript({ force: true }); buildWorker(); lintNode(); lintWorker(); From 8f081ef8dd7a3559e6ea61fde951bfd58596b40a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Fri, 3 Nov 2023 12:44:24 +0100 Subject: [PATCH 70/73] Remove GCC warnings (#1208) Fixes #1206 --- worker/src/Channel/ChannelNotification.cpp | 6 +++++- worker/src/Channel/ChannelRequest.cpp | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/worker/src/Channel/ChannelNotification.cpp b/worker/src/Channel/ChannelNotification.cpp index 4603622ead..6dc4d2a89c 100644 --- a/worker/src/Channel/ChannelNotification.cpp +++ b/worker/src/Channel/ChannelNotification.cpp @@ -30,12 +30,16 @@ namespace Channel auto eventCStrIt = ChannelNotification::event2String.find(this->event); if (eventCStrIt == ChannelNotification::event2String.end()) - MS_THROW_ERROR("unknown event '%" PRIu8 "'", this->event); + { + MS_THROW_ERROR("unknown event '%" PRIu8 "'", static_cast(this->event)); + } this->eventCStr = eventCStrIt->second; // Handler ID is optional. if (flatbuffers::IsFieldPresent(this->data, FBS::Notification::Notification::VT_HANDLERID)) + { this->handlerId = this->data->handlerId()->str(); + } } } // namespace Channel diff --git a/worker/src/Channel/ChannelRequest.cpp b/worker/src/Channel/ChannelRequest.cpp index 3c97af5f05..01b56cf5de 100644 --- a/worker/src/Channel/ChannelRequest.cpp +++ b/worker/src/Channel/ChannelRequest.cpp @@ -102,14 +102,16 @@ namespace Channel { Error("unknown method"); - MS_THROW_ERROR("unknown method '%" PRIu8 "'", this->method); + MS_THROW_ERROR("unknown method '%" PRIu8 "'", static_cast(this->method)); } this->methodCStr = methodCStrIt->second; // Handler ID is optional. if (flatbuffers::IsFieldPresent(this->data, FBS::Request::Request::VT_HANDLERID)) + { this->handlerId = this->data->handlerId()->str(); + } } void ChannelRequest::Accept() From 73b3d84e26be003cf8cf1314b79ca20ffe6eca75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?= Date: Mon, 6 Nov 2023 12:52:31 +0100 Subject: [PATCH 71/73] FBS: Fix DtlsTransport regression (#1210) Do not process handshake if there is no remote fingerprint. --- worker/src/RTC/DtlsTransport.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/src/RTC/DtlsTransport.cpp b/worker/src/RTC/DtlsTransport.cpp index 8d4d5895fb..40612ea4ca 100644 --- a/worker/src/RTC/DtlsTransport.cpp +++ b/worker/src/RTC/DtlsTransport.cpp @@ -1033,7 +1033,7 @@ namespace RTC this->timer->Stop(); // Process the handshake just once (ignore if DTLS renegotiation). - if (!wasHandshakeDone) + if (!wasHandshakeDone && this->remoteFingerprint.has_value()) return ProcessHandshake(); return true; From 9fa1695091c3e30a6cc9d2b81b3a6fec2d48151c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Mon, 6 Nov 2023 12:53:42 +0100 Subject: [PATCH 72/73] Update Node deps --- package-lock.json | 96 +++++++++++++++++++++++------------------------ package.json | 4 +- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/package-lock.json b/package-lock.json index 66731eb964..8a46af3217 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,10 +24,10 @@ "@types/node": "^20.8.10", "@typescript-eslint/eslint-plugin": "^6.9.1", "@typescript-eslint/parser": "^6.9.1", - "eslint": "^8.52.0", + "eslint": "^8.53.0", "eslint-plugin-jest": "^27.6.0", "jest": "^29.7.0", - "marked": "^9.1.4", + "marked": "^9.1.5", "open-cli": "^7.2.0", "pick-port": "^1.0.1", "sctp": "^1.0.0", @@ -742,9 +742,9 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.2.tgz", - "integrity": "sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.3.tgz", + "integrity": "sha512-yZzuIG+jnVu6hNSzFEN07e8BxF3uAzYtQb6uDkaYZLo6oYZDCq454c5kB8zxnzfCYyP4MIuyBn10L0DqwujTmA==", "dev": true, "dependencies": { "ajv": "^6.12.4", @@ -765,9 +765,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.52.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.52.0.tgz", - "integrity": "sha512-mjZVbpaeMZludF2fsWLD0Z9gCref1Tk4i9+wddjRvpUNqqcndPkBD09N/Mapey0b3jaXbLm2kICwFv2E64QinA==", + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.53.0.tgz", + "integrity": "sha512-Kn7K8dx/5U6+cT1yEhpX1w4PCSg0M+XyRILPgvwcEBjerFWCwQj5sbr3/VmxqV0JGHCBCzyd6LxypEuehypY1w==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -2129,9 +2129,9 @@ "dev": true }, "node_modules/acorn": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", - "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", + "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -3023,15 +3023,15 @@ } }, "node_modules/eslint": { - "version": "8.52.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.52.0.tgz", - "integrity": "sha512-zh/JHnaixqHZsolRB/w9/02akBk9EPrOs9JwcTP2ek7yL5bVvXuRariiaAjjoJ5DvuwQ1WAE/HsMz+w17YgBCg==", + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.53.0.tgz", + "integrity": "sha512-N4VuiPjXDUa4xVeV/GC/RV3hQW9Nw+Y463lkWaKKXKYMvmRiRDAtfpuPFLN+E1/6ZhyR8J2ig+eVREnYgUsiag==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.2", - "@eslint/js": "8.52.0", + "@eslint/eslintrc": "^2.1.3", + "@eslint/js": "8.53.0", "@humanwhocodes/config-array": "^0.11.13", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", @@ -3600,9 +3600,9 @@ } }, "node_modules/globals": { - "version": "13.21.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.21.0.tgz", - "integrity": "sha512-ybyme3s4yy/t/3s35bewwXKOf7cvzfreG2lH0lZl0JB7I4GxRP2ghxOK/Nb9EkRXdbBXZLfq/p/0W2JUONB/Gg==", + "version": "13.23.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.23.0.tgz", + "integrity": "sha512-XAmF0RjlrjY23MA51q3HltdlGxUpXPvg0GioKiD9X6HD28iMjo2dKC8Vqwm7lne4GNr78+RHTfliktR6ZH09wA==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -4849,9 +4849,9 @@ } }, "node_modules/marked": { - "version": "9.1.4", - "resolved": "https://registry.npmjs.org/marked/-/marked-9.1.4.tgz", - "integrity": "sha512-Mq83CCaClhXqhf8sLQ57c1unNelHEuFadK36ga+GeXR4FeT/5ssaC5PaCRVqMA74VYorzYRqdAaxxteIanh3Kw==", + "version": "9.1.5", + "resolved": "https://registry.npmjs.org/marked/-/marked-9.1.5.tgz", + "integrity": "sha512-14QG3shv8Kg/xc0Yh6TNkMj90wXH9mmldi5941I2OevfJ/FQAFLEwtwU2/FfgSAOMlWHrEukWSGQf8MiVYNG2A==", "dev": true, "bin": { "marked": "bin/marked.js" @@ -5481,9 +5481,9 @@ "dev": true }, "node_modules/punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true, "engines": { "node": ">=6" @@ -7284,9 +7284,9 @@ "dev": true }, "@eslint/eslintrc": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.2.tgz", - "integrity": "sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.3.tgz", + "integrity": "sha512-yZzuIG+jnVu6hNSzFEN07e8BxF3uAzYtQb6uDkaYZLo6oYZDCq454c5kB8zxnzfCYyP4MIuyBn10L0DqwujTmA==", "dev": true, "requires": { "ajv": "^6.12.4", @@ -7301,9 +7301,9 @@ } }, "@eslint/js": { - "version": "8.52.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.52.0.tgz", - "integrity": "sha512-mjZVbpaeMZludF2fsWLD0Z9gCref1Tk4i9+wddjRvpUNqqcndPkBD09N/Mapey0b3jaXbLm2kICwFv2E64QinA==", + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.53.0.tgz", + "integrity": "sha512-Kn7K8dx/5U6+cT1yEhpX1w4PCSg0M+XyRILPgvwcEBjerFWCwQj5sbr3/VmxqV0JGHCBCzyd6LxypEuehypY1w==", "dev": true }, "@humanwhocodes/config-array": { @@ -8314,9 +8314,9 @@ "dev": true }, "acorn": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", - "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", + "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==", "dev": true }, "acorn-jsx": { @@ -8949,15 +8949,15 @@ "dev": true }, "eslint": { - "version": "8.52.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.52.0.tgz", - "integrity": "sha512-zh/JHnaixqHZsolRB/w9/02akBk9EPrOs9JwcTP2ek7yL5bVvXuRariiaAjjoJ5DvuwQ1WAE/HsMz+w17YgBCg==", + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.53.0.tgz", + "integrity": "sha512-N4VuiPjXDUa4xVeV/GC/RV3hQW9Nw+Y463lkWaKKXKYMvmRiRDAtfpuPFLN+E1/6ZhyR8J2ig+eVREnYgUsiag==", "dev": true, "requires": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.2", - "@eslint/js": "8.52.0", + "@eslint/eslintrc": "^2.1.3", + "@eslint/js": "8.53.0", "@humanwhocodes/config-array": "^0.11.13", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", @@ -9364,9 +9364,9 @@ } }, "globals": { - "version": "13.21.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.21.0.tgz", - "integrity": "sha512-ybyme3s4yy/t/3s35bewwXKOf7cvzfreG2lH0lZl0JB7I4GxRP2ghxOK/Nb9EkRXdbBXZLfq/p/0W2JUONB/Gg==", + "version": "13.23.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.23.0.tgz", + "integrity": "sha512-XAmF0RjlrjY23MA51q3HltdlGxUpXPvg0GioKiD9X6HD28iMjo2dKC8Vqwm7lne4GNr78+RHTfliktR6ZH09wA==", "dev": true, "requires": { "type-fest": "^0.20.2" @@ -10280,9 +10280,9 @@ "dev": true }, "marked": { - "version": "9.1.4", - "resolved": "https://registry.npmjs.org/marked/-/marked-9.1.4.tgz", - "integrity": "sha512-Mq83CCaClhXqhf8sLQ57c1unNelHEuFadK36ga+GeXR4FeT/5ssaC5PaCRVqMA74VYorzYRqdAaxxteIanh3Kw==", + "version": "9.1.5", + "resolved": "https://registry.npmjs.org/marked/-/marked-9.1.5.tgz", + "integrity": "sha512-14QG3shv8Kg/xc0Yh6TNkMj90wXH9mmldi5941I2OevfJ/FQAFLEwtwU2/FfgSAOMlWHrEukWSGQf8MiVYNG2A==", "dev": true }, "meow": { @@ -10728,9 +10728,9 @@ "dev": true }, "punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true }, "pure-rand": { diff --git a/package.json b/package.json index 42aeaa942d..b7af4b973b 100644 --- a/package.json +++ b/package.json @@ -109,10 +109,10 @@ "@types/node": "^20.8.10", "@typescript-eslint/eslint-plugin": "^6.9.1", "@typescript-eslint/parser": "^6.9.1", - "eslint": "^8.52.0", + "eslint": "^8.53.0", "eslint-plugin-jest": "^27.6.0", "jest": "^29.7.0", - "marked": "^9.1.4", + "marked": "^9.1.5", "open-cli": "^7.2.0", "pick-port": "^1.0.1", "sctp": "^1.0.0", From faf419d9e7ca81c5c24c53dddd4f2c53930a5133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Mon, 6 Nov 2023 13:01:39 +0100 Subject: [PATCH 73/73] DtlsTransport.cpp: cosmetic, add braces in if/else and case statements --- worker/src/RTC/DtlsTransport.cpp | 162 +++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) diff --git a/worker/src/RTC/DtlsTransport.cpp b/worker/src/RTC/DtlsTransport.cpp index 40612ea4ca..adada495d3 100644 --- a/worker/src/RTC/DtlsTransport.cpp +++ b/worker/src/RTC/DtlsTransport.cpp @@ -16,7 +16,9 @@ do \ { \ if (ERR_peek_error() == 0) \ + { \ MS_ERROR("OpenSSL error [desc:'%s']", desc); \ + } \ else \ { \ int64_t err; \ @@ -46,11 +48,17 @@ inline static void onSslInfo(const SSL* ssl, int where, int ret) inline static unsigned int onSslDtlsTimer(SSL* /*ssl*/, unsigned int timerUs) { if (timerUs == 0) + { return 100000; + } else if (timerUs >= 4000000) + { return 4000000; + } else + { return 2 * timerUs; + } } inline static long onSslBioOut( @@ -167,11 +175,19 @@ namespace RTC MS_TRACE(); if (DtlsTransport::privateKey) + { EVP_PKEY_free(DtlsTransport::privateKey); + } + if (DtlsTransport::certificate) + { X509_free(DtlsTransport::certificate); + } + if (DtlsTransport::sslCtx) + { SSL_CTX_free(DtlsTransport::sslCtx); + } } DtlsTransport::Role DtlsTransport::RoleFromFbs(FBS::WebRtcTransport::DtlsRole role) @@ -179,13 +195,19 @@ namespace RTC switch (role) { case FBS::WebRtcTransport::DtlsRole::AUTO: + { return DtlsTransport::Role::AUTO; + } case FBS::WebRtcTransport::DtlsRole::CLIENT: + { return DtlsTransport::Role::CLIENT; + } case FBS::WebRtcTransport::DtlsRole::SERVER: + { return DtlsTransport::Role::SERVER; + } } } @@ -194,13 +216,19 @@ namespace RTC switch (role) { case DtlsTransport::Role::AUTO: + { return FBS::WebRtcTransport::DtlsRole::AUTO; + } case DtlsTransport::Role::CLIENT: + { return FBS::WebRtcTransport::DtlsRole::CLIENT; + } case DtlsTransport::Role::SERVER: + { return FBS::WebRtcTransport::DtlsRole::SERVER; + } } } @@ -209,19 +237,29 @@ namespace RTC switch (state) { case DtlsTransport::DtlsState::NEW: + { return FBS::WebRtcTransport::DtlsState::NEW; + } case DtlsTransport::DtlsState::CONNECTING: + { return FBS::WebRtcTransport::DtlsState::CONNECTING; + } case DtlsTransport::DtlsState::CONNECTED: + { return FBS::WebRtcTransport::DtlsState::CONNECTED; + } case DtlsTransport::DtlsState::FAILED: + { return FBS::WebRtcTransport::DtlsState::FAILED; + } case DtlsTransport::DtlsState::CLOSED: + { return FBS::WebRtcTransport::DtlsState::CLOSED; + } } } @@ -231,19 +269,29 @@ namespace RTC switch (algorithm) { case FBS::WebRtcTransport::FingerprintAlgorithm::SHA1: + { return DtlsTransport::FingerprintAlgorithm::SHA1; + } case FBS::WebRtcTransport::FingerprintAlgorithm::SHA224: + { return DtlsTransport::FingerprintAlgorithm::SHA224; + } case FBS::WebRtcTransport::FingerprintAlgorithm::SHA256: + { return DtlsTransport::FingerprintAlgorithm::SHA256; + } case FBS::WebRtcTransport::FingerprintAlgorithm::SHA384: + { return DtlsTransport::FingerprintAlgorithm::SHA384; + } case FBS::WebRtcTransport::FingerprintAlgorithm::SHA512: + { return DtlsTransport::FingerprintAlgorithm::SHA512; + } } } @@ -253,19 +301,29 @@ namespace RTC switch (algorithm) { case DtlsTransport::FingerprintAlgorithm::SHA1: + { return FBS::WebRtcTransport::FingerprintAlgorithm::SHA1; + } case DtlsTransport::FingerprintAlgorithm::SHA224: + { return FBS::WebRtcTransport::FingerprintAlgorithm::SHA224; + } case DtlsTransport::FingerprintAlgorithm::SHA256: + { return FBS::WebRtcTransport::FingerprintAlgorithm::SHA256; + } case DtlsTransport::FingerprintAlgorithm::SHA384: + { return FBS::WebRtcTransport::FingerprintAlgorithm::SHA384; + } case DtlsTransport::FingerprintAlgorithm::SHA512: + { return FBS::WebRtcTransport::FingerprintAlgorithm::SHA512; + } } } @@ -360,10 +418,14 @@ namespace RTC error: if (DtlsTransport::privateKey) + { EVP_PKEY_free(DtlsTransport::privateKey); + } if (DtlsTransport::certificate) + { X509_free(DtlsTransport::certificate); + } MS_THROW_ERROR("DTLS certificate and private key generation failed"); } @@ -515,7 +577,9 @@ namespace RTC ++it) { if (it != DtlsTransport::srtpCryptoSuites.begin()) + { dtlsSrtpCryptoSuites += ":"; + } SrtpCryptoSuiteMapEntry* cryptoSuiteEntry = std::addressof(*it); dtlsSrtpCryptoSuites += cryptoSuiteEntry->name; @@ -565,27 +629,39 @@ namespace RTC switch (algorithm) { case FingerprintAlgorithm::SHA1: + { hashFunction = EVP_sha1(); break; + } case FingerprintAlgorithm::SHA224: + { hashFunction = EVP_sha224(); break; + } case FingerprintAlgorithm::SHA256: + { hashFunction = EVP_sha256(); break; + } case FingerprintAlgorithm::SHA384: + { hashFunction = EVP_sha384(); break; + } case FingerprintAlgorithm::SHA512: + { hashFunction = EVP_sha512(); break; + } default: + { MS_THROW_ERROR("unknown algorithm"); + } } ret = X509_digest(DtlsTransport::certificate, hashFunction, binaryFingerprint, &size); @@ -679,13 +755,19 @@ namespace RTC // NOTE: At this point SSL_set_bio() was not called so we must free BIOs as // well. if (this->sslBioFromNetwork) + { BIO_free(this->sslBioFromNetwork); + } if (this->sslBioToNetwork) + { BIO_free(this->sslBioToNetwork); + } if (this->ssl) + { SSL_free(this->ssl); + } // NOTE: If this is not catched by the caller the program will abort, but // this should never happen. @@ -725,17 +807,29 @@ namespace RTC switch (this->state) { case DtlsState::CONNECTING: + { state = "connecting"; break; + } + case DtlsState::CONNECTED: + { state = "connected"; break; + } + case DtlsState::FAILED: + { state = "failed"; break; + } + case DtlsState::CLOSED: + { state = "closed"; break; + } + default:; } @@ -744,14 +838,22 @@ namespace RTC switch (this->localRole.value()) { case Role::AUTO: + { role = "auto"; break; + } + case Role::SERVER: + { role = "server"; break; + } + case Role::CLIENT: + { role = "client"; break; + } } } @@ -874,11 +976,15 @@ namespace RTC // Check SSL status and return if it is bad/closed. if (!CheckStatus(read)) + { return; + } // Set/update the DTLS timeout. if (!SetTimeout()) + { return; + } // Application data received. Notify to the listener. if (read > 0) @@ -925,7 +1031,9 @@ namespace RTC LOG_OPENSSL_ERROR("SSL_write() failed"); if (!CheckStatus(written)) + { return; + } } else if (written != static_cast(len)) { @@ -949,7 +1057,9 @@ namespace RTC int ret; if (!IsRunning()) + { return; + } MS_WARN_TAG(dtls, "resetting DTLS transport"); @@ -972,7 +1082,9 @@ namespace RTC ret = SSL_clear(this->ssl); if (ret == 0) + { ERR_clear_error(); + } } inline bool DtlsTransport::CheckStatus(int returnCode) @@ -987,40 +1099,60 @@ namespace RTC switch (err) { case SSL_ERROR_NONE: + { break; + } case SSL_ERROR_SSL: + { LOG_OPENSSL_ERROR("SSL status: SSL_ERROR_SSL"); break; + } case SSL_ERROR_WANT_READ: + { break; + } case SSL_ERROR_WANT_WRITE: + { MS_WARN_TAG(dtls, "SSL status: SSL_ERROR_WANT_WRITE"); break; + } case SSL_ERROR_WANT_X509_LOOKUP: + { MS_DEBUG_TAG(dtls, "SSL status: SSL_ERROR_WANT_X509_LOOKUP"); break; + } case SSL_ERROR_SYSCALL: + { LOG_OPENSSL_ERROR("SSL status: SSL_ERROR_SYSCALL"); break; + } case SSL_ERROR_ZERO_RETURN: + { break; + } case SSL_ERROR_WANT_CONNECT: + { MS_WARN_TAG(dtls, "SSL status: SSL_ERROR_WANT_CONNECT"); break; + } case SSL_ERROR_WANT_ACCEPT: + { MS_WARN_TAG(dtls, "SSL status: SSL_ERROR_WANT_ACCEPT"); break; + } default: + { MS_WARN_TAG(dtls, "SSL status: unknown error"); + } } // Check if the handshake (or re-handshake) has been done right now. @@ -1034,7 +1166,9 @@ namespace RTC // Process the handshake just once (ignore if DTLS renegotiation). if (!wasHandshakeDone && this->remoteFingerprint.has_value()) + { return ProcessHandshake(); + } return true; } @@ -1187,24 +1321,34 @@ namespace RTC switch (this->remoteFingerprint->algorithm) { case FingerprintAlgorithm::SHA1: + { hashFunction = EVP_sha1(); break; + } case FingerprintAlgorithm::SHA224: + { hashFunction = EVP_sha224(); break; + } case FingerprintAlgorithm::SHA256: + { hashFunction = EVP_sha256(); break; + } case FingerprintAlgorithm::SHA384: + { hashFunction = EVP_sha384(); break; + } case FingerprintAlgorithm::SHA512: + { hashFunction = EVP_sha512(); break; + } } // Compare the remote fingerprint with the value given via signaling. @@ -1400,7 +1544,9 @@ namespace RTC SRTP_PROTECTION_PROFILE* sslSrtpCryptoSuite = SSL_get_selected_srtp_profile(this->ssl); if (!sslSrtpCryptoSuite) + { return negotiatedSrtpCryptoSuite; + } // Get the negotiated SRTP crypto suite. for (auto& srtpCryptoSuite : DtlsTransport::srtpCryptoSuites) @@ -1429,11 +1575,17 @@ namespace RTC const char* role; if ((w & SSL_ST_CONNECT) != 0) + { role = "client"; + } else if ((w & SSL_ST_ACCEPT) != 0) + { role = "server"; + } else + { role = "undefined"; + } if ((where & SSL_CB_LOOP) != 0) { @@ -1446,15 +1598,21 @@ namespace RTC switch (*SSL_alert_type_string(ret)) { case 'W': + { alertType = "warning"; break; + } case 'F': + { alertType = "fatal"; break; + } default: + { alertType = "undefined"; + } } if ((where & SSL_CB_READ) != 0) @@ -1473,9 +1631,13 @@ namespace RTC else if ((where & SSL_CB_EXIT) != 0) { if (ret == 0) + { MS_DEBUG_TAG(dtls, "[role:%s, failed:'%s']", role, SSL_state_string_long(this->ssl)); + } else if (ret < 0) + { MS_DEBUG_TAG(dtls, "role: %s, waiting:'%s']", role, SSL_state_string_long(this->ssl)); + } } else if ((where & SSL_CB_HANDSHAKE_START) != 0) {