diff --git a/rust/bindings/dart/lib/errors.dart b/rust/bindings/dart/lib/errors.dart index b924664..ade1d97 100644 --- a/rust/bindings/dart/lib/errors.dart +++ b/rust/bindings/dart/lib/errors.dart @@ -2,10 +2,29 @@ export 'src/generated/api/client.dart' show ConnectionError, ConnectionError_Failed, + PersistError, + PersistError_Open, + PersistError_Serialize, + PersistError_Set, + ReceiveError, RequestError, - RequestError_Send, RequestError_Receive, + RequestError_Send, RequestError_Timeout, - ReceiveError, SendError, SendError_PipeBroken; + +export 'src/generated/api/driver_client.dart' + show + AddModeError, + AddModeError_ModeExists, + AddModeError_MonitorNotFound, + AddModeError_RefreshRateExists, + DuplicateError, + DuplicateError_Monitor, + DuplicateError_Mode, + DuplicateError_RefreshRate, + InitError, + InitError_Connect, + InitError_RequestState, + MonitorNotFoundError; diff --git a/rust/bindings/dart/lib/src/generated/api/client.dart b/rust/bindings/dart/lib/src/generated/api/client.dart index 1ffbf9c..9c7957a 100644 --- a/rust/bindings/dart/lib/src/generated/api/client.dart +++ b/rust/bindings/dart/lib/src/generated/api/client.dart @@ -9,7 +9,7 @@ import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; import 'package:freezed_annotation/freezed_annotation.dart' hide protected; part 'client.freezed.dart'; -// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `from`, `from`, `from`, `from` +// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `from`, `from`, `from`, `from`, `from` // Rust type: RustOpaqueMoi> abstract class Client implements RustOpaqueInterface { @@ -23,6 +23,13 @@ abstract class Client implements RustOpaqueInterface { /// Send new state to the driver. Future notify({required List monitors}); + /// Write `monitors` to the registry for current user. + /// + /// Next time the driver is started, it will load this state from the + /// registry. This might be after a reboot or a driver restart. + static Future persist({required List monitors}) => + RustLib.instance.api.crateApiClientClientPersist(monitors: monitors); + /// Receive continuous events from the driver. /// /// Only new events after calling this method are received. @@ -58,6 +65,31 @@ sealed class ConnectionError with _$ConnectionError implements FrbException { }; } +@freezed +sealed class PersistError with _$PersistError implements FrbException { + const PersistError._(); + + const factory PersistError.open({ + required String message, + }) = PersistError_Open; + const factory PersistError.set_({ + required String message, + }) = PersistError_Set; + const factory PersistError.serialize({ + required String message, + }) = PersistError_Serialize; + + @override + String toString() => switch (this) { + PersistError_Open(:final message) => + 'Failed to open registry key: $message', + PersistError_Set(:final message) => + 'Failed to set registry key: $message', + PersistError_Serialize(:final message) => + 'Failed to serialize data: $message', + }; +} + class ReceiveError implements FrbException { final String message; diff --git a/rust/bindings/dart/lib/src/generated/api/client.freezed.dart b/rust/bindings/dart/lib/src/generated/api/client.freezed.dart index 2d227a2..36b6764 100644 --- a/rust/bindings/dart/lib/src/generated/api/client.freezed.dart +++ b/rust/bindings/dart/lib/src/generated/api/client.freezed.dart @@ -230,6 +230,542 @@ abstract class ConnectionError_Failed extends ConnectionError { get copyWith => throw _privateConstructorUsedError; } +/// @nodoc +mixin _$PersistError { + String get message => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult when({ + required TResult Function(String message) open, + required TResult Function(String message) set_, + required TResult Function(String message) serialize, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String message)? open, + TResult? Function(String message)? set_, + TResult? Function(String message)? serialize, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String message)? open, + TResult Function(String message)? set_, + TResult Function(String message)? serialize, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(PersistError_Open value) open, + required TResult Function(PersistError_Set value) set_, + required TResult Function(PersistError_Serialize value) serialize, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(PersistError_Open value)? open, + TResult? Function(PersistError_Set value)? set_, + TResult? Function(PersistError_Serialize value)? serialize, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(PersistError_Open value)? open, + TResult Function(PersistError_Set value)? set_, + TResult Function(PersistError_Serialize value)? serialize, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PersistErrorCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PersistErrorCopyWith<$Res> { + factory $PersistErrorCopyWith( + PersistError value, $Res Function(PersistError) then) = + _$PersistErrorCopyWithImpl<$Res, PersistError>; + @useResult + $Res call({String message}); +} + +/// @nodoc +class _$PersistErrorCopyWithImpl<$Res, $Val extends PersistError> + implements $PersistErrorCopyWith<$Res> { + _$PersistErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_value.copyWith( + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$PersistError_OpenImplCopyWith<$Res> + implements $PersistErrorCopyWith<$Res> { + factory _$$PersistError_OpenImplCopyWith(_$PersistError_OpenImpl value, + $Res Function(_$PersistError_OpenImpl) then) = + __$$PersistError_OpenImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String message}); +} + +/// @nodoc +class __$$PersistError_OpenImplCopyWithImpl<$Res> + extends _$PersistErrorCopyWithImpl<$Res, _$PersistError_OpenImpl> + implements _$$PersistError_OpenImplCopyWith<$Res> { + __$$PersistError_OpenImplCopyWithImpl(_$PersistError_OpenImpl _value, + $Res Function(_$PersistError_OpenImpl) _then) + : super(_value, _then); + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_$PersistError_OpenImpl( + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$PersistError_OpenImpl extends PersistError_Open { + const _$PersistError_OpenImpl({required this.message}) : super._(); + + @override + final String message; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PersistError_OpenImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PersistError_OpenImplCopyWith<_$PersistError_OpenImpl> get copyWith => + __$$PersistError_OpenImplCopyWithImpl<_$PersistError_OpenImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String message) open, + required TResult Function(String message) set_, + required TResult Function(String message) serialize, + }) { + return open(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String message)? open, + TResult? Function(String message)? set_, + TResult? Function(String message)? serialize, + }) { + return open?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String message)? open, + TResult Function(String message)? set_, + TResult Function(String message)? serialize, + required TResult orElse(), + }) { + if (open != null) { + return open(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(PersistError_Open value) open, + required TResult Function(PersistError_Set value) set_, + required TResult Function(PersistError_Serialize value) serialize, + }) { + return open(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(PersistError_Open value)? open, + TResult? Function(PersistError_Set value)? set_, + TResult? Function(PersistError_Serialize value)? serialize, + }) { + return open?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(PersistError_Open value)? open, + TResult Function(PersistError_Set value)? set_, + TResult Function(PersistError_Serialize value)? serialize, + required TResult orElse(), + }) { + if (open != null) { + return open(this); + } + return orElse(); + } +} + +abstract class PersistError_Open extends PersistError { + const factory PersistError_Open({required final String message}) = + _$PersistError_OpenImpl; + const PersistError_Open._() : super._(); + + @override + String get message; + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PersistError_OpenImplCopyWith<_$PersistError_OpenImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$PersistError_SetImplCopyWith<$Res> + implements $PersistErrorCopyWith<$Res> { + factory _$$PersistError_SetImplCopyWith(_$PersistError_SetImpl value, + $Res Function(_$PersistError_SetImpl) then) = + __$$PersistError_SetImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String message}); +} + +/// @nodoc +class __$$PersistError_SetImplCopyWithImpl<$Res> + extends _$PersistErrorCopyWithImpl<$Res, _$PersistError_SetImpl> + implements _$$PersistError_SetImplCopyWith<$Res> { + __$$PersistError_SetImplCopyWithImpl(_$PersistError_SetImpl _value, + $Res Function(_$PersistError_SetImpl) _then) + : super(_value, _then); + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_$PersistError_SetImpl( + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$PersistError_SetImpl extends PersistError_Set { + const _$PersistError_SetImpl({required this.message}) : super._(); + + @override + final String message; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PersistError_SetImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PersistError_SetImplCopyWith<_$PersistError_SetImpl> get copyWith => + __$$PersistError_SetImplCopyWithImpl<_$PersistError_SetImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String message) open, + required TResult Function(String message) set_, + required TResult Function(String message) serialize, + }) { + return set_(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String message)? open, + TResult? Function(String message)? set_, + TResult? Function(String message)? serialize, + }) { + return set_?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String message)? open, + TResult Function(String message)? set_, + TResult Function(String message)? serialize, + required TResult orElse(), + }) { + if (set_ != null) { + return set_(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(PersistError_Open value) open, + required TResult Function(PersistError_Set value) set_, + required TResult Function(PersistError_Serialize value) serialize, + }) { + return set_(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(PersistError_Open value)? open, + TResult? Function(PersistError_Set value)? set_, + TResult? Function(PersistError_Serialize value)? serialize, + }) { + return set_?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(PersistError_Open value)? open, + TResult Function(PersistError_Set value)? set_, + TResult Function(PersistError_Serialize value)? serialize, + required TResult orElse(), + }) { + if (set_ != null) { + return set_(this); + } + return orElse(); + } +} + +abstract class PersistError_Set extends PersistError { + const factory PersistError_Set({required final String message}) = + _$PersistError_SetImpl; + const PersistError_Set._() : super._(); + + @override + String get message; + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PersistError_SetImplCopyWith<_$PersistError_SetImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$PersistError_SerializeImplCopyWith<$Res> + implements $PersistErrorCopyWith<$Res> { + factory _$$PersistError_SerializeImplCopyWith( + _$PersistError_SerializeImpl value, + $Res Function(_$PersistError_SerializeImpl) then) = + __$$PersistError_SerializeImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String message}); +} + +/// @nodoc +class __$$PersistError_SerializeImplCopyWithImpl<$Res> + extends _$PersistErrorCopyWithImpl<$Res, _$PersistError_SerializeImpl> + implements _$$PersistError_SerializeImplCopyWith<$Res> { + __$$PersistError_SerializeImplCopyWithImpl( + _$PersistError_SerializeImpl _value, + $Res Function(_$PersistError_SerializeImpl) _then) + : super(_value, _then); + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? message = null, + }) { + return _then(_$PersistError_SerializeImpl( + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$PersistError_SerializeImpl extends PersistError_Serialize { + const _$PersistError_SerializeImpl({required this.message}) : super._(); + + @override + final String message; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PersistError_SerializeImpl && + (identical(other.message, message) || other.message == message)); + } + + @override + int get hashCode => Object.hash(runtimeType, message); + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PersistError_SerializeImplCopyWith<_$PersistError_SerializeImpl> + get copyWith => __$$PersistError_SerializeImplCopyWithImpl< + _$PersistError_SerializeImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String message) open, + required TResult Function(String message) set_, + required TResult Function(String message) serialize, + }) { + return serialize(message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String message)? open, + TResult? Function(String message)? set_, + TResult? Function(String message)? serialize, + }) { + return serialize?.call(message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String message)? open, + TResult Function(String message)? set_, + TResult Function(String message)? serialize, + required TResult orElse(), + }) { + if (serialize != null) { + return serialize(message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(PersistError_Open value) open, + required TResult Function(PersistError_Set value) set_, + required TResult Function(PersistError_Serialize value) serialize, + }) { + return serialize(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(PersistError_Open value)? open, + TResult? Function(PersistError_Set value)? set_, + TResult? Function(PersistError_Serialize value)? serialize, + }) { + return serialize?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(PersistError_Open value)? open, + TResult Function(PersistError_Set value)? set_, + TResult Function(PersistError_Serialize value)? serialize, + required TResult orElse(), + }) { + if (serialize != null) { + return serialize(this); + } + return orElse(); + } +} + +abstract class PersistError_Serialize extends PersistError { + const factory PersistError_Serialize({required final String message}) = + _$PersistError_SerializeImpl; + const PersistError_Serialize._() : super._(); + + @override + String get message; + + /// Create a copy of PersistError + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PersistError_SerializeImplCopyWith<_$PersistError_SerializeImpl> + get copyWith => throw _privateConstructorUsedError; +} + /// @nodoc mixin _$RequestError { @optionalTypeArgs diff --git a/rust/bindings/dart/lib/src/generated/api/driver_client.dart b/rust/bindings/dart/lib/src/generated/api/driver_client.dart new file mode 100644 index 0000000..9e2e631 --- /dev/null +++ b/rust/bindings/dart/lib/src/generated/api/driver_client.dart @@ -0,0 +1,260 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.2.0. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import '../api.dart'; +import '../frb_generated.dart'; +import 'client.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import 'package:freezed_annotation/freezed_annotation.dart' hide protected; +part 'driver_client.freezed.dart'; + +// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `from`, `from`, `from`, `from` + +// Rust type: RustOpaqueMoi> +abstract class DriverClient implements RustOpaqueInterface { + /// Add a new monitor. + /// + /// Returns an error if a monitor with this ID already exists, or if the + /// monitor is invalid. A monitor is invalid if it has duplicate modes, or + /// if any of its modes has duplicate refresh rates. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void add({required Monitor monitor}); + + /// Add a mode to the monitor with the given ID. + /// + /// Returns an error if the monitor does not exist, or if the mode already + /// exists on that monitor, or if the mode is invalid. A mode is invalid if + /// it has duplicate refresh rates. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void addMode({required int id, required Mode mode}); + + /// Connect to driver on pipe with default name. + /// + /// You can optionally specify the name of the named pipe to connect to. The + /// default name is "virtualdisplaydriver" + static Future connect({String? pipeName}) => + RustLib.instance.api + .crateApiDriverClientDriverClientConnect(pipeName: pipeName); + + /// Find the monitor with the given ID. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + Monitor? findMonitor({required int id}); + + /// Get the closest available free ID. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + /// + /// Note: Duplicate monitors are ignored when send to the Driver using + /// [DriverClient.notify]. + int? newId({int? preferredId}); + + /// Send the current client state to the driver. + /// + /// State changes of the client are not automatically sent to the driver. + /// You must manually call this method to send changes to the driver. + Future notify(); + + /// Write client state to the registry for current user. + /// + /// Next time the driver is started, it will load this state from the + /// registry. This might be after a reboot or a driver restart. + Future persist(); + + /// Returns a stream of continuous events from the driver. + /// + /// This stream will always reflect the real state of the driver, regardless + /// of who changed its state. This means, if it is changed by another + /// process, this stream will still be updated. + Stream> receiveEvents(); + + /// Manually synchronize with the driver. + Future> refreshState(); + + /// Remove monitors by id. + /// + /// Silently skips IDs that do not exist. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void remove({required List ids}); + + /// Remove all monitors. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + void removeAll(); + + /// Remove a mode from the monitor with the given ID. + /// + /// Returns an error if the monitor does not exist. If the mode does not + /// exist, it is silently skipped. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void removeMode({required int id, required (int, int) resolution}); + + /// Replace an existing monitor. The monitor is identified by its ID. + /// + /// Throws [MonitorNotFoundError] if the monitor does not exist. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void replaceMonitor({required Monitor monitor}); + + /// Set enabled state of all monitors with the given IDs. + /// + /// Silently skips incorrect IDs. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void setEnabled({required List ids, required bool enabled}); + + /// Replace all monitors. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + void setMonitors({required List monitors}); + + /// Get the current monitor state stored inside this client. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + List get state; +} + +@freezed +sealed class AddModeError with _$AddModeError implements FrbException { + const AddModeError._(); + + const factory AddModeError.monitorNotFound({ + required int id, + }) = AddModeError_MonitorNotFound; + const factory AddModeError.modeExists({ + required int monitorId, + required int width, + required int height, + }) = AddModeError_ModeExists; + const factory AddModeError.refreshRateExists({ + required int monitorId, + required int width, + required int height, + required int refreshRate, + }) = AddModeError_RefreshRateExists; + + @override + String toString() => switch (this) { + AddModeError_MonitorNotFound(:final id) => + 'Monitor with id $id not found', + AddModeError_ModeExists( + :final monitorId, + :final width, + :final height + ) => + 'Mode ${width}x$height already exists on monitor $monitorId', + AddModeError_RefreshRateExists( + :final monitorId, + :final width, + :final height, + :final refreshRate + ) => + 'Refresh rate $refreshRate already exists on mode ${width}x$height on monitor $monitorId', + }; +} + +@freezed +sealed class DuplicateError with _$DuplicateError implements FrbException { + const DuplicateError._(); + + const factory DuplicateError.monitor({ + required int id, + }) = DuplicateError_Monitor; + const factory DuplicateError.mode({ + required int monitorId, + required int width, + required int height, + }) = DuplicateError_Mode; + const factory DuplicateError.refreshRate({ + required int monitorId, + required int width, + required int height, + required int refreshRate, + }) = DuplicateError_RefreshRate; + + @override + String toString() => switch (this) { + DuplicateError_Monitor(:final id) => + 'Monitor with id $id already exists', + DuplicateError_Mode(:final monitorId, :final width, :final height) => + 'Mode ${width}x$height already exists on monitor $monitorId', + DuplicateError_RefreshRate( + :final monitorId, + :final width, + :final height, + :final refreshRate + ) => + 'Refresh rate $refreshRate already exists on mode ${width}x$height on monitor $monitorId', + }; +} + +@freezed +sealed class InitError with _$InitError implements FrbException { + const InitError._(); + + const factory InitError.connect({ + required ConnectionError inner, + }) = InitError_Connect; + const factory InitError.requestState({ + required RequestError inner, + }) = InitError_RequestState; + + @override + String toString() => 'Failed to initialize DriverClient: $inner'; +} + +class MonitorNotFoundError implements FrbException { + final int id; + + const MonitorNotFoundError({ + required this.id, + }); + + @override + String toString() => 'Monitor with id $id not found'; + + @override + int get hashCode => id.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is MonitorNotFoundError && + runtimeType == other.runtimeType && + id == other.id; +} diff --git a/rust/bindings/dart/lib/src/generated/api/driver_client.freezed.dart b/rust/bindings/dart/lib/src/generated/api/driver_client.freezed.dart new file mode 100644 index 0000000..3cadf90 --- /dev/null +++ b/rust/bindings/dart/lib/src/generated/api/driver_client.freezed.dart @@ -0,0 +1,1562 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'driver_client.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +/// @nodoc +mixin _$AddModeError { + @optionalTypeArgs + TResult when({ + required TResult Function(int id) monitorNotFound, + required TResult Function(int monitorId, int width, int height) modeExists, + required TResult Function( + int monitorId, int width, int height, int refreshRate) + refreshRateExists, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int id)? monitorNotFound, + TResult? Function(int monitorId, int width, int height)? modeExists, + TResult? Function(int monitorId, int width, int height, int refreshRate)? + refreshRateExists, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int id)? monitorNotFound, + TResult Function(int monitorId, int width, int height)? modeExists, + TResult Function(int monitorId, int width, int height, int refreshRate)? + refreshRateExists, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(AddModeError_MonitorNotFound value) + monitorNotFound, + required TResult Function(AddModeError_ModeExists value) modeExists, + required TResult Function(AddModeError_RefreshRateExists value) + refreshRateExists, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AddModeError_MonitorNotFound value)? monitorNotFound, + TResult? Function(AddModeError_ModeExists value)? modeExists, + TResult? Function(AddModeError_RefreshRateExists value)? refreshRateExists, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AddModeError_MonitorNotFound value)? monitorNotFound, + TResult Function(AddModeError_ModeExists value)? modeExists, + TResult Function(AddModeError_RefreshRateExists value)? refreshRateExists, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $AddModeErrorCopyWith<$Res> { + factory $AddModeErrorCopyWith( + AddModeError value, $Res Function(AddModeError) then) = + _$AddModeErrorCopyWithImpl<$Res, AddModeError>; +} + +/// @nodoc +class _$AddModeErrorCopyWithImpl<$Res, $Val extends AddModeError> + implements $AddModeErrorCopyWith<$Res> { + _$AddModeErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$AddModeError_MonitorNotFoundImplCopyWith<$Res> { + factory _$$AddModeError_MonitorNotFoundImplCopyWith( + _$AddModeError_MonitorNotFoundImpl value, + $Res Function(_$AddModeError_MonitorNotFoundImpl) then) = + __$$AddModeError_MonitorNotFoundImplCopyWithImpl<$Res>; + @useResult + $Res call({int id}); +} + +/// @nodoc +class __$$AddModeError_MonitorNotFoundImplCopyWithImpl<$Res> + extends _$AddModeErrorCopyWithImpl<$Res, _$AddModeError_MonitorNotFoundImpl> + implements _$$AddModeError_MonitorNotFoundImplCopyWith<$Res> { + __$$AddModeError_MonitorNotFoundImplCopyWithImpl( + _$AddModeError_MonitorNotFoundImpl _value, + $Res Function(_$AddModeError_MonitorNotFoundImpl) _then) + : super(_value, _then); + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + }) { + return _then(_$AddModeError_MonitorNotFoundImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$AddModeError_MonitorNotFoundImpl extends AddModeError_MonitorNotFound { + const _$AddModeError_MonitorNotFoundImpl({required this.id}) : super._(); + + @override + final int id; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AddModeError_MonitorNotFoundImpl && + (identical(other.id, id) || other.id == id)); + } + + @override + int get hashCode => Object.hash(runtimeType, id); + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$AddModeError_MonitorNotFoundImplCopyWith< + _$AddModeError_MonitorNotFoundImpl> + get copyWith => __$$AddModeError_MonitorNotFoundImplCopyWithImpl< + _$AddModeError_MonitorNotFoundImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(int id) monitorNotFound, + required TResult Function(int monitorId, int width, int height) modeExists, + required TResult Function( + int monitorId, int width, int height, int refreshRate) + refreshRateExists, + }) { + return monitorNotFound(id); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int id)? monitorNotFound, + TResult? Function(int monitorId, int width, int height)? modeExists, + TResult? Function(int monitorId, int width, int height, int refreshRate)? + refreshRateExists, + }) { + return monitorNotFound?.call(id); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int id)? monitorNotFound, + TResult Function(int monitorId, int width, int height)? modeExists, + TResult Function(int monitorId, int width, int height, int refreshRate)? + refreshRateExists, + required TResult orElse(), + }) { + if (monitorNotFound != null) { + return monitorNotFound(id); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AddModeError_MonitorNotFound value) + monitorNotFound, + required TResult Function(AddModeError_ModeExists value) modeExists, + required TResult Function(AddModeError_RefreshRateExists value) + refreshRateExists, + }) { + return monitorNotFound(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AddModeError_MonitorNotFound value)? monitorNotFound, + TResult? Function(AddModeError_ModeExists value)? modeExists, + TResult? Function(AddModeError_RefreshRateExists value)? refreshRateExists, + }) { + return monitorNotFound?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AddModeError_MonitorNotFound value)? monitorNotFound, + TResult Function(AddModeError_ModeExists value)? modeExists, + TResult Function(AddModeError_RefreshRateExists value)? refreshRateExists, + required TResult orElse(), + }) { + if (monitorNotFound != null) { + return monitorNotFound(this); + } + return orElse(); + } +} + +abstract class AddModeError_MonitorNotFound extends AddModeError { + const factory AddModeError_MonitorNotFound({required final int id}) = + _$AddModeError_MonitorNotFoundImpl; + const AddModeError_MonitorNotFound._() : super._(); + + int get id; + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$AddModeError_MonitorNotFoundImplCopyWith< + _$AddModeError_MonitorNotFoundImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$AddModeError_ModeExistsImplCopyWith<$Res> { + factory _$$AddModeError_ModeExistsImplCopyWith( + _$AddModeError_ModeExistsImpl value, + $Res Function(_$AddModeError_ModeExistsImpl) then) = + __$$AddModeError_ModeExistsImplCopyWithImpl<$Res>; + @useResult + $Res call({int monitorId, int width, int height}); +} + +/// @nodoc +class __$$AddModeError_ModeExistsImplCopyWithImpl<$Res> + extends _$AddModeErrorCopyWithImpl<$Res, _$AddModeError_ModeExistsImpl> + implements _$$AddModeError_ModeExistsImplCopyWith<$Res> { + __$$AddModeError_ModeExistsImplCopyWithImpl( + _$AddModeError_ModeExistsImpl _value, + $Res Function(_$AddModeError_ModeExistsImpl) _then) + : super(_value, _then); + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? monitorId = null, + Object? width = null, + Object? height = null, + }) { + return _then(_$AddModeError_ModeExistsImpl( + monitorId: null == monitorId + ? _value.monitorId + : monitorId // ignore: cast_nullable_to_non_nullable + as int, + width: null == width + ? _value.width + : width // ignore: cast_nullable_to_non_nullable + as int, + height: null == height + ? _value.height + : height // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$AddModeError_ModeExistsImpl extends AddModeError_ModeExists { + const _$AddModeError_ModeExistsImpl( + {required this.monitorId, required this.width, required this.height}) + : super._(); + + @override + final int monitorId; + @override + final int width; + @override + final int height; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AddModeError_ModeExistsImpl && + (identical(other.monitorId, monitorId) || + other.monitorId == monitorId) && + (identical(other.width, width) || other.width == width) && + (identical(other.height, height) || other.height == height)); + } + + @override + int get hashCode => Object.hash(runtimeType, monitorId, width, height); + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$AddModeError_ModeExistsImplCopyWith<_$AddModeError_ModeExistsImpl> + get copyWith => __$$AddModeError_ModeExistsImplCopyWithImpl< + _$AddModeError_ModeExistsImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(int id) monitorNotFound, + required TResult Function(int monitorId, int width, int height) modeExists, + required TResult Function( + int monitorId, int width, int height, int refreshRate) + refreshRateExists, + }) { + return modeExists(monitorId, width, height); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int id)? monitorNotFound, + TResult? Function(int monitorId, int width, int height)? modeExists, + TResult? Function(int monitorId, int width, int height, int refreshRate)? + refreshRateExists, + }) { + return modeExists?.call(monitorId, width, height); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int id)? monitorNotFound, + TResult Function(int monitorId, int width, int height)? modeExists, + TResult Function(int monitorId, int width, int height, int refreshRate)? + refreshRateExists, + required TResult orElse(), + }) { + if (modeExists != null) { + return modeExists(monitorId, width, height); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AddModeError_MonitorNotFound value) + monitorNotFound, + required TResult Function(AddModeError_ModeExists value) modeExists, + required TResult Function(AddModeError_RefreshRateExists value) + refreshRateExists, + }) { + return modeExists(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AddModeError_MonitorNotFound value)? monitorNotFound, + TResult? Function(AddModeError_ModeExists value)? modeExists, + TResult? Function(AddModeError_RefreshRateExists value)? refreshRateExists, + }) { + return modeExists?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AddModeError_MonitorNotFound value)? monitorNotFound, + TResult Function(AddModeError_ModeExists value)? modeExists, + TResult Function(AddModeError_RefreshRateExists value)? refreshRateExists, + required TResult orElse(), + }) { + if (modeExists != null) { + return modeExists(this); + } + return orElse(); + } +} + +abstract class AddModeError_ModeExists extends AddModeError { + const factory AddModeError_ModeExists( + {required final int monitorId, + required final int width, + required final int height}) = _$AddModeError_ModeExistsImpl; + const AddModeError_ModeExists._() : super._(); + + int get monitorId; + int get width; + int get height; + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$AddModeError_ModeExistsImplCopyWith<_$AddModeError_ModeExistsImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$AddModeError_RefreshRateExistsImplCopyWith<$Res> { + factory _$$AddModeError_RefreshRateExistsImplCopyWith( + _$AddModeError_RefreshRateExistsImpl value, + $Res Function(_$AddModeError_RefreshRateExistsImpl) then) = + __$$AddModeError_RefreshRateExistsImplCopyWithImpl<$Res>; + @useResult + $Res call({int monitorId, int width, int height, int refreshRate}); +} + +/// @nodoc +class __$$AddModeError_RefreshRateExistsImplCopyWithImpl<$Res> + extends _$AddModeErrorCopyWithImpl<$Res, + _$AddModeError_RefreshRateExistsImpl> + implements _$$AddModeError_RefreshRateExistsImplCopyWith<$Res> { + __$$AddModeError_RefreshRateExistsImplCopyWithImpl( + _$AddModeError_RefreshRateExistsImpl _value, + $Res Function(_$AddModeError_RefreshRateExistsImpl) _then) + : super(_value, _then); + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? monitorId = null, + Object? width = null, + Object? height = null, + Object? refreshRate = null, + }) { + return _then(_$AddModeError_RefreshRateExistsImpl( + monitorId: null == monitorId + ? _value.monitorId + : monitorId // ignore: cast_nullable_to_non_nullable + as int, + width: null == width + ? _value.width + : width // ignore: cast_nullable_to_non_nullable + as int, + height: null == height + ? _value.height + : height // ignore: cast_nullable_to_non_nullable + as int, + refreshRate: null == refreshRate + ? _value.refreshRate + : refreshRate // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$AddModeError_RefreshRateExistsImpl + extends AddModeError_RefreshRateExists { + const _$AddModeError_RefreshRateExistsImpl( + {required this.monitorId, + required this.width, + required this.height, + required this.refreshRate}) + : super._(); + + @override + final int monitorId; + @override + final int width; + @override + final int height; + @override + final int refreshRate; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AddModeError_RefreshRateExistsImpl && + (identical(other.monitorId, monitorId) || + other.monitorId == monitorId) && + (identical(other.width, width) || other.width == width) && + (identical(other.height, height) || other.height == height) && + (identical(other.refreshRate, refreshRate) || + other.refreshRate == refreshRate)); + } + + @override + int get hashCode => + Object.hash(runtimeType, monitorId, width, height, refreshRate); + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$AddModeError_RefreshRateExistsImplCopyWith< + _$AddModeError_RefreshRateExistsImpl> + get copyWith => __$$AddModeError_RefreshRateExistsImplCopyWithImpl< + _$AddModeError_RefreshRateExistsImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(int id) monitorNotFound, + required TResult Function(int monitorId, int width, int height) modeExists, + required TResult Function( + int monitorId, int width, int height, int refreshRate) + refreshRateExists, + }) { + return refreshRateExists(monitorId, width, height, refreshRate); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int id)? monitorNotFound, + TResult? Function(int monitorId, int width, int height)? modeExists, + TResult? Function(int monitorId, int width, int height, int refreshRate)? + refreshRateExists, + }) { + return refreshRateExists?.call(monitorId, width, height, refreshRate); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int id)? monitorNotFound, + TResult Function(int monitorId, int width, int height)? modeExists, + TResult Function(int monitorId, int width, int height, int refreshRate)? + refreshRateExists, + required TResult orElse(), + }) { + if (refreshRateExists != null) { + return refreshRateExists(monitorId, width, height, refreshRate); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(AddModeError_MonitorNotFound value) + monitorNotFound, + required TResult Function(AddModeError_ModeExists value) modeExists, + required TResult Function(AddModeError_RefreshRateExists value) + refreshRateExists, + }) { + return refreshRateExists(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(AddModeError_MonitorNotFound value)? monitorNotFound, + TResult? Function(AddModeError_ModeExists value)? modeExists, + TResult? Function(AddModeError_RefreshRateExists value)? refreshRateExists, + }) { + return refreshRateExists?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(AddModeError_MonitorNotFound value)? monitorNotFound, + TResult Function(AddModeError_ModeExists value)? modeExists, + TResult Function(AddModeError_RefreshRateExists value)? refreshRateExists, + required TResult orElse(), + }) { + if (refreshRateExists != null) { + return refreshRateExists(this); + } + return orElse(); + } +} + +abstract class AddModeError_RefreshRateExists extends AddModeError { + const factory AddModeError_RefreshRateExists( + {required final int monitorId, + required final int width, + required final int height, + required final int refreshRate}) = _$AddModeError_RefreshRateExistsImpl; + const AddModeError_RefreshRateExists._() : super._(); + + int get monitorId; + int get width; + int get height; + int get refreshRate; + + /// Create a copy of AddModeError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$AddModeError_RefreshRateExistsImplCopyWith< + _$AddModeError_RefreshRateExistsImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$DuplicateError { + @optionalTypeArgs + TResult when({ + required TResult Function(int id) monitor, + required TResult Function(int monitorId, int width, int height) mode, + required TResult Function( + int monitorId, int width, int height, int refreshRate) + refreshRate, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int id)? monitor, + TResult? Function(int monitorId, int width, int height)? mode, + TResult? Function(int monitorId, int width, int height, int refreshRate)? + refreshRate, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int id)? monitor, + TResult Function(int monitorId, int width, int height)? mode, + TResult Function(int monitorId, int width, int height, int refreshRate)? + refreshRate, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(DuplicateError_Monitor value) monitor, + required TResult Function(DuplicateError_Mode value) mode, + required TResult Function(DuplicateError_RefreshRate value) refreshRate, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(DuplicateError_Monitor value)? monitor, + TResult? Function(DuplicateError_Mode value)? mode, + TResult? Function(DuplicateError_RefreshRate value)? refreshRate, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(DuplicateError_Monitor value)? monitor, + TResult Function(DuplicateError_Mode value)? mode, + TResult Function(DuplicateError_RefreshRate value)? refreshRate, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DuplicateErrorCopyWith<$Res> { + factory $DuplicateErrorCopyWith( + DuplicateError value, $Res Function(DuplicateError) then) = + _$DuplicateErrorCopyWithImpl<$Res, DuplicateError>; +} + +/// @nodoc +class _$DuplicateErrorCopyWithImpl<$Res, $Val extends DuplicateError> + implements $DuplicateErrorCopyWith<$Res> { + _$DuplicateErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$DuplicateError_MonitorImplCopyWith<$Res> { + factory _$$DuplicateError_MonitorImplCopyWith( + _$DuplicateError_MonitorImpl value, + $Res Function(_$DuplicateError_MonitorImpl) then) = + __$$DuplicateError_MonitorImplCopyWithImpl<$Res>; + @useResult + $Res call({int id}); +} + +/// @nodoc +class __$$DuplicateError_MonitorImplCopyWithImpl<$Res> + extends _$DuplicateErrorCopyWithImpl<$Res, _$DuplicateError_MonitorImpl> + implements _$$DuplicateError_MonitorImplCopyWith<$Res> { + __$$DuplicateError_MonitorImplCopyWithImpl( + _$DuplicateError_MonitorImpl _value, + $Res Function(_$DuplicateError_MonitorImpl) _then) + : super(_value, _then); + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + }) { + return _then(_$DuplicateError_MonitorImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$DuplicateError_MonitorImpl extends DuplicateError_Monitor { + const _$DuplicateError_MonitorImpl({required this.id}) : super._(); + + @override + final int id; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DuplicateError_MonitorImpl && + (identical(other.id, id) || other.id == id)); + } + + @override + int get hashCode => Object.hash(runtimeType, id); + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DuplicateError_MonitorImplCopyWith<_$DuplicateError_MonitorImpl> + get copyWith => __$$DuplicateError_MonitorImplCopyWithImpl< + _$DuplicateError_MonitorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(int id) monitor, + required TResult Function(int monitorId, int width, int height) mode, + required TResult Function( + int monitorId, int width, int height, int refreshRate) + refreshRate, + }) { + return monitor(id); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int id)? monitor, + TResult? Function(int monitorId, int width, int height)? mode, + TResult? Function(int monitorId, int width, int height, int refreshRate)? + refreshRate, + }) { + return monitor?.call(id); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int id)? monitor, + TResult Function(int monitorId, int width, int height)? mode, + TResult Function(int monitorId, int width, int height, int refreshRate)? + refreshRate, + required TResult orElse(), + }) { + if (monitor != null) { + return monitor(id); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(DuplicateError_Monitor value) monitor, + required TResult Function(DuplicateError_Mode value) mode, + required TResult Function(DuplicateError_RefreshRate value) refreshRate, + }) { + return monitor(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(DuplicateError_Monitor value)? monitor, + TResult? Function(DuplicateError_Mode value)? mode, + TResult? Function(DuplicateError_RefreshRate value)? refreshRate, + }) { + return monitor?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(DuplicateError_Monitor value)? monitor, + TResult Function(DuplicateError_Mode value)? mode, + TResult Function(DuplicateError_RefreshRate value)? refreshRate, + required TResult orElse(), + }) { + if (monitor != null) { + return monitor(this); + } + return orElse(); + } +} + +abstract class DuplicateError_Monitor extends DuplicateError { + const factory DuplicateError_Monitor({required final int id}) = + _$DuplicateError_MonitorImpl; + const DuplicateError_Monitor._() : super._(); + + int get id; + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DuplicateError_MonitorImplCopyWith<_$DuplicateError_MonitorImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$DuplicateError_ModeImplCopyWith<$Res> { + factory _$$DuplicateError_ModeImplCopyWith(_$DuplicateError_ModeImpl value, + $Res Function(_$DuplicateError_ModeImpl) then) = + __$$DuplicateError_ModeImplCopyWithImpl<$Res>; + @useResult + $Res call({int monitorId, int width, int height}); +} + +/// @nodoc +class __$$DuplicateError_ModeImplCopyWithImpl<$Res> + extends _$DuplicateErrorCopyWithImpl<$Res, _$DuplicateError_ModeImpl> + implements _$$DuplicateError_ModeImplCopyWith<$Res> { + __$$DuplicateError_ModeImplCopyWithImpl(_$DuplicateError_ModeImpl _value, + $Res Function(_$DuplicateError_ModeImpl) _then) + : super(_value, _then); + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? monitorId = null, + Object? width = null, + Object? height = null, + }) { + return _then(_$DuplicateError_ModeImpl( + monitorId: null == monitorId + ? _value.monitorId + : monitorId // ignore: cast_nullable_to_non_nullable + as int, + width: null == width + ? _value.width + : width // ignore: cast_nullable_to_non_nullable + as int, + height: null == height + ? _value.height + : height // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$DuplicateError_ModeImpl extends DuplicateError_Mode { + const _$DuplicateError_ModeImpl( + {required this.monitorId, required this.width, required this.height}) + : super._(); + + @override + final int monitorId; + @override + final int width; + @override + final int height; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DuplicateError_ModeImpl && + (identical(other.monitorId, monitorId) || + other.monitorId == monitorId) && + (identical(other.width, width) || other.width == width) && + (identical(other.height, height) || other.height == height)); + } + + @override + int get hashCode => Object.hash(runtimeType, monitorId, width, height); + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DuplicateError_ModeImplCopyWith<_$DuplicateError_ModeImpl> get copyWith => + __$$DuplicateError_ModeImplCopyWithImpl<_$DuplicateError_ModeImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(int id) monitor, + required TResult Function(int monitorId, int width, int height) mode, + required TResult Function( + int monitorId, int width, int height, int refreshRate) + refreshRate, + }) { + return mode(monitorId, width, height); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int id)? monitor, + TResult? Function(int monitorId, int width, int height)? mode, + TResult? Function(int monitorId, int width, int height, int refreshRate)? + refreshRate, + }) { + return mode?.call(monitorId, width, height); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int id)? monitor, + TResult Function(int monitorId, int width, int height)? mode, + TResult Function(int monitorId, int width, int height, int refreshRate)? + refreshRate, + required TResult orElse(), + }) { + if (mode != null) { + return mode(monitorId, width, height); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(DuplicateError_Monitor value) monitor, + required TResult Function(DuplicateError_Mode value) mode, + required TResult Function(DuplicateError_RefreshRate value) refreshRate, + }) { + return mode(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(DuplicateError_Monitor value)? monitor, + TResult? Function(DuplicateError_Mode value)? mode, + TResult? Function(DuplicateError_RefreshRate value)? refreshRate, + }) { + return mode?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(DuplicateError_Monitor value)? monitor, + TResult Function(DuplicateError_Mode value)? mode, + TResult Function(DuplicateError_RefreshRate value)? refreshRate, + required TResult orElse(), + }) { + if (mode != null) { + return mode(this); + } + return orElse(); + } +} + +abstract class DuplicateError_Mode extends DuplicateError { + const factory DuplicateError_Mode( + {required final int monitorId, + required final int width, + required final int height}) = _$DuplicateError_ModeImpl; + const DuplicateError_Mode._() : super._(); + + int get monitorId; + int get width; + int get height; + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DuplicateError_ModeImplCopyWith<_$DuplicateError_ModeImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$DuplicateError_RefreshRateImplCopyWith<$Res> { + factory _$$DuplicateError_RefreshRateImplCopyWith( + _$DuplicateError_RefreshRateImpl value, + $Res Function(_$DuplicateError_RefreshRateImpl) then) = + __$$DuplicateError_RefreshRateImplCopyWithImpl<$Res>; + @useResult + $Res call({int monitorId, int width, int height, int refreshRate}); +} + +/// @nodoc +class __$$DuplicateError_RefreshRateImplCopyWithImpl<$Res> + extends _$DuplicateErrorCopyWithImpl<$Res, _$DuplicateError_RefreshRateImpl> + implements _$$DuplicateError_RefreshRateImplCopyWith<$Res> { + __$$DuplicateError_RefreshRateImplCopyWithImpl( + _$DuplicateError_RefreshRateImpl _value, + $Res Function(_$DuplicateError_RefreshRateImpl) _then) + : super(_value, _then); + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? monitorId = null, + Object? width = null, + Object? height = null, + Object? refreshRate = null, + }) { + return _then(_$DuplicateError_RefreshRateImpl( + monitorId: null == monitorId + ? _value.monitorId + : monitorId // ignore: cast_nullable_to_non_nullable + as int, + width: null == width + ? _value.width + : width // ignore: cast_nullable_to_non_nullable + as int, + height: null == height + ? _value.height + : height // ignore: cast_nullable_to_non_nullable + as int, + refreshRate: null == refreshRate + ? _value.refreshRate + : refreshRate // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$DuplicateError_RefreshRateImpl extends DuplicateError_RefreshRate { + const _$DuplicateError_RefreshRateImpl( + {required this.monitorId, + required this.width, + required this.height, + required this.refreshRate}) + : super._(); + + @override + final int monitorId; + @override + final int width; + @override + final int height; + @override + final int refreshRate; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DuplicateError_RefreshRateImpl && + (identical(other.monitorId, monitorId) || + other.monitorId == monitorId) && + (identical(other.width, width) || other.width == width) && + (identical(other.height, height) || other.height == height) && + (identical(other.refreshRate, refreshRate) || + other.refreshRate == refreshRate)); + } + + @override + int get hashCode => + Object.hash(runtimeType, monitorId, width, height, refreshRate); + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DuplicateError_RefreshRateImplCopyWith<_$DuplicateError_RefreshRateImpl> + get copyWith => __$$DuplicateError_RefreshRateImplCopyWithImpl< + _$DuplicateError_RefreshRateImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(int id) monitor, + required TResult Function(int monitorId, int width, int height) mode, + required TResult Function( + int monitorId, int width, int height, int refreshRate) + refreshRate, + }) { + return refreshRate(monitorId, width, height, this.refreshRate); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int id)? monitor, + TResult? Function(int monitorId, int width, int height)? mode, + TResult? Function(int monitorId, int width, int height, int refreshRate)? + refreshRate, + }) { + return refreshRate?.call(monitorId, width, height, this.refreshRate); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int id)? monitor, + TResult Function(int monitorId, int width, int height)? mode, + TResult Function(int monitorId, int width, int height, int refreshRate)? + refreshRate, + required TResult orElse(), + }) { + if (refreshRate != null) { + return refreshRate(monitorId, width, height, this.refreshRate); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(DuplicateError_Monitor value) monitor, + required TResult Function(DuplicateError_Mode value) mode, + required TResult Function(DuplicateError_RefreshRate value) refreshRate, + }) { + return refreshRate(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(DuplicateError_Monitor value)? monitor, + TResult? Function(DuplicateError_Mode value)? mode, + TResult? Function(DuplicateError_RefreshRate value)? refreshRate, + }) { + return refreshRate?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(DuplicateError_Monitor value)? monitor, + TResult Function(DuplicateError_Mode value)? mode, + TResult Function(DuplicateError_RefreshRate value)? refreshRate, + required TResult orElse(), + }) { + if (refreshRate != null) { + return refreshRate(this); + } + return orElse(); + } +} + +abstract class DuplicateError_RefreshRate extends DuplicateError { + const factory DuplicateError_RefreshRate( + {required final int monitorId, + required final int width, + required final int height, + required final int refreshRate}) = _$DuplicateError_RefreshRateImpl; + const DuplicateError_RefreshRate._() : super._(); + + int get monitorId; + int get width; + int get height; + int get refreshRate; + + /// Create a copy of DuplicateError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DuplicateError_RefreshRateImplCopyWith<_$DuplicateError_RefreshRateImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$InitError { + FrbException get inner => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult when({ + required TResult Function(ConnectionError inner) connect, + required TResult Function(RequestError inner) requestState, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ConnectionError inner)? connect, + TResult? Function(RequestError inner)? requestState, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ConnectionError inner)? connect, + TResult Function(RequestError inner)? requestState, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(InitError_Connect value) connect, + required TResult Function(InitError_RequestState value) requestState, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(InitError_Connect value)? connect, + TResult? Function(InitError_RequestState value)? requestState, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(InitError_Connect value)? connect, + TResult Function(InitError_RequestState value)? requestState, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $InitErrorCopyWith<$Res> { + factory $InitErrorCopyWith(InitError value, $Res Function(InitError) then) = + _$InitErrorCopyWithImpl<$Res, InitError>; +} + +/// @nodoc +class _$InitErrorCopyWithImpl<$Res, $Val extends InitError> + implements $InitErrorCopyWith<$Res> { + _$InitErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$InitError_ConnectImplCopyWith<$Res> { + factory _$$InitError_ConnectImplCopyWith(_$InitError_ConnectImpl value, + $Res Function(_$InitError_ConnectImpl) then) = + __$$InitError_ConnectImplCopyWithImpl<$Res>; + @useResult + $Res call({ConnectionError inner}); + + $ConnectionErrorCopyWith<$Res> get inner; +} + +/// @nodoc +class __$$InitError_ConnectImplCopyWithImpl<$Res> + extends _$InitErrorCopyWithImpl<$Res, _$InitError_ConnectImpl> + implements _$$InitError_ConnectImplCopyWith<$Res> { + __$$InitError_ConnectImplCopyWithImpl(_$InitError_ConnectImpl _value, + $Res Function(_$InitError_ConnectImpl) _then) + : super(_value, _then); + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? inner = null, + }) { + return _then(_$InitError_ConnectImpl( + inner: null == inner + ? _value.inner + : inner // ignore: cast_nullable_to_non_nullable + as ConnectionError, + )); + } + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $ConnectionErrorCopyWith<$Res> get inner { + return $ConnectionErrorCopyWith<$Res>(_value.inner, (value) { + return _then(_value.copyWith(inner: value)); + }); + } +} + +/// @nodoc + +class _$InitError_ConnectImpl extends InitError_Connect { + const _$InitError_ConnectImpl({required this.inner}) : super._(); + + @override + final ConnectionError inner; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$InitError_ConnectImpl && + (identical(other.inner, inner) || other.inner == inner)); + } + + @override + int get hashCode => Object.hash(runtimeType, inner); + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$InitError_ConnectImplCopyWith<_$InitError_ConnectImpl> get copyWith => + __$$InitError_ConnectImplCopyWithImpl<_$InitError_ConnectImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(ConnectionError inner) connect, + required TResult Function(RequestError inner) requestState, + }) { + return connect(inner); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ConnectionError inner)? connect, + TResult? Function(RequestError inner)? requestState, + }) { + return connect?.call(inner); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ConnectionError inner)? connect, + TResult Function(RequestError inner)? requestState, + required TResult orElse(), + }) { + if (connect != null) { + return connect(inner); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(InitError_Connect value) connect, + required TResult Function(InitError_RequestState value) requestState, + }) { + return connect(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(InitError_Connect value)? connect, + TResult? Function(InitError_RequestState value)? requestState, + }) { + return connect?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(InitError_Connect value)? connect, + TResult Function(InitError_RequestState value)? requestState, + required TResult orElse(), + }) { + if (connect != null) { + return connect(this); + } + return orElse(); + } +} + +abstract class InitError_Connect extends InitError { + const factory InitError_Connect({required final ConnectionError inner}) = + _$InitError_ConnectImpl; + const InitError_Connect._() : super._(); + + @override + ConnectionError get inner; + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$InitError_ConnectImplCopyWith<_$InitError_ConnectImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$InitError_RequestStateImplCopyWith<$Res> { + factory _$$InitError_RequestStateImplCopyWith( + _$InitError_RequestStateImpl value, + $Res Function(_$InitError_RequestStateImpl) then) = + __$$InitError_RequestStateImplCopyWithImpl<$Res>; + @useResult + $Res call({RequestError inner}); + + $RequestErrorCopyWith<$Res> get inner; +} + +/// @nodoc +class __$$InitError_RequestStateImplCopyWithImpl<$Res> + extends _$InitErrorCopyWithImpl<$Res, _$InitError_RequestStateImpl> + implements _$$InitError_RequestStateImplCopyWith<$Res> { + __$$InitError_RequestStateImplCopyWithImpl( + _$InitError_RequestStateImpl _value, + $Res Function(_$InitError_RequestStateImpl) _then) + : super(_value, _then); + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? inner = null, + }) { + return _then(_$InitError_RequestStateImpl( + inner: null == inner + ? _value.inner + : inner // ignore: cast_nullable_to_non_nullable + as RequestError, + )); + } + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $RequestErrorCopyWith<$Res> get inner { + return $RequestErrorCopyWith<$Res>(_value.inner, (value) { + return _then(_value.copyWith(inner: value)); + }); + } +} + +/// @nodoc + +class _$InitError_RequestStateImpl extends InitError_RequestState { + const _$InitError_RequestStateImpl({required this.inner}) : super._(); + + @override + final RequestError inner; + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$InitError_RequestStateImpl && + (identical(other.inner, inner) || other.inner == inner)); + } + + @override + int get hashCode => Object.hash(runtimeType, inner); + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$InitError_RequestStateImplCopyWith<_$InitError_RequestStateImpl> + get copyWith => __$$InitError_RequestStateImplCopyWithImpl< + _$InitError_RequestStateImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(ConnectionError inner) connect, + required TResult Function(RequestError inner) requestState, + }) { + return requestState(inner); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ConnectionError inner)? connect, + TResult? Function(RequestError inner)? requestState, + }) { + return requestState?.call(inner); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ConnectionError inner)? connect, + TResult Function(RequestError inner)? requestState, + required TResult orElse(), + }) { + if (requestState != null) { + return requestState(inner); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(InitError_Connect value) connect, + required TResult Function(InitError_RequestState value) requestState, + }) { + return requestState(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(InitError_Connect value)? connect, + TResult? Function(InitError_RequestState value)? requestState, + }) { + return requestState?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(InitError_Connect value)? connect, + TResult Function(InitError_RequestState value)? requestState, + required TResult orElse(), + }) { + if (requestState != null) { + return requestState(this); + } + return orElse(); + } +} + +abstract class InitError_RequestState extends InitError { + const factory InitError_RequestState({required final RequestError inner}) = + _$InitError_RequestStateImpl; + const InitError_RequestState._() : super._(); + + @override + RequestError get inner; + + /// Create a copy of InitError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$InitError_RequestStateImplCopyWith<_$InitError_RequestStateImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/rust/bindings/dart/lib/src/generated/api/mock.dart b/rust/bindings/dart/lib/src/generated/api/mock.dart index 3d344ce..69d1a38 100644 --- a/rust/bindings/dart/lib/src/generated/api/mock.dart +++ b/rust/bindings/dart/lib/src/generated/api/mock.dart @@ -16,5 +16,7 @@ abstract class MockServer implements RustOpaqueInterface { Future pump(); + Future setState({required List state}); + List get state; } diff --git a/rust/bindings/dart/lib/src/generated/frb_generated.dart b/rust/bindings/dart/lib/src/generated/frb_generated.dart index ef3eb07..83ecbeb 100644 --- a/rust/bindings/dart/lib/src/generated/frb_generated.dart +++ b/rust/bindings/dart/lib/src/generated/frb_generated.dart @@ -5,6 +5,7 @@ import 'api.dart'; import 'api/client.dart'; +import 'api/driver_client.dart'; import 'api/mock.dart'; import 'dart:async'; import 'dart:convert'; @@ -58,7 +59,7 @@ class RustLib extends BaseEntrypoint { String get codegenVersion => '2.2.0'; @override - int get rustContentHash => -392242162; + int get rustContentHash => -527967754; static const kDefaultExternalLibraryLoaderConfig = ExternalLibraryLoaderConfig( @@ -74,6 +75,8 @@ abstract class RustLibApi extends BaseApi { Future crateApiClientClientNotify( {required Client that, required List monitors}); + Future crateApiClientClientPersist({required List monitors}); + Stream> crateApiClientClientReceiveEvents( {required Client that}); @@ -85,12 +88,66 @@ abstract class RustLibApi extends BaseApi { Future> crateApiClientClientRequestState( {required Client that}); + void crateApiDriverClientDriverClientAdd( + {required DriverClient that, required Monitor monitor}); + + void crateApiDriverClientDriverClientAddMode( + {required DriverClient that, required int id, required Mode mode}); + + Future crateApiDriverClientDriverClientConnect( + {String? pipeName}); + + Monitor? crateApiDriverClientDriverClientFindMonitor( + {required DriverClient that, required int id}); + + int? crateApiDriverClientDriverClientNewId( + {required DriverClient that, int? preferredId}); + + Future crateApiDriverClientDriverClientNotify( + {required DriverClient that}); + + Future crateApiDriverClientDriverClientPersist( + {required DriverClient that}); + + Stream> crateApiDriverClientDriverClientReceiveEvents( + {required DriverClient that}); + + Future> crateApiDriverClientDriverClientRefreshState( + {required DriverClient that}); + + void crateApiDriverClientDriverClientRemove( + {required DriverClient that, required List ids}); + + void crateApiDriverClientDriverClientRemoveAll({required DriverClient that}); + + void crateApiDriverClientDriverClientRemoveMode( + {required DriverClient that, + required int id, + required (int, int) resolution}); + + void crateApiDriverClientDriverClientReplaceMonitor( + {required DriverClient that, required Monitor monitor}); + + void crateApiDriverClientDriverClientSetEnabled( + {required DriverClient that, + required List ids, + required bool enabled}); + + void crateApiDriverClientDriverClientSetMonitors( + {required DriverClient that, required List monitors}); + + List crateApiDriverClientDriverClientState( + {required DriverClient that}); + Future crateApiMockMockServerCreate({required String pipeName}); String crateApiMockMockServerPipeName({required MockServer that}); Future crateApiMockMockServerPump({required MockServer that}); + Future crateApiMockMockServerSetState( + {required MockServer that, required List state}); + List crateApiMockMockServerState({required MockServer that}); RustArcIncrementStrongCountFnType get rust_arc_increment_strong_count_Client; @@ -99,6 +156,14 @@ abstract class RustLibApi extends BaseApi { CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_ClientPtr; + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_DriverClient; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_DriverClient; + + CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_DriverClientPtr; + RustArcIncrementStrongCountFnType get rust_arc_increment_strong_count_MockServer; @@ -169,6 +234,31 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { argNames: ["that", "monitors"], ); + @override + Future crateApiClientClientPersist({required List monitors}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_list_monitor(monitors, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 3, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_persist_error, + ), + constMeta: kCrateApiClientClientPersistConstMeta, + argValues: [monitors], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiClientClientPersistConstMeta => + const TaskConstMeta( + debugName: "Client_persist", + argNames: ["monitors"], + ); + @override Stream> crateApiClientClientReceiveEvents( {required Client that}) { @@ -180,7 +270,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { that, serializer); sse_encode_StreamSink_list_monitor_Sse(sink, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 3, port: port_); + funcId: 4, port: port_); }, codec: SseCodec( decodeSuccessData: sse_decode_unit, @@ -209,7 +299,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { that, serializer); sse_encode_list_prim_u_32_loose(ids, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 4, port: port_); + funcId: 5, port: port_); }, codec: SseCodec( decodeSuccessData: sse_decode_unit, @@ -231,51 +321,490 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return handler.executeNormal(NormalTask( callFfi: (port_) { final serializer = SseSerializer(generalizedFrbRustBinding); - sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + that, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 6, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_send_error, + ), + constMeta: kCrateApiClientClientRemoveAllConstMeta, + argValues: [that], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiClientClientRemoveAllConstMeta => + const TaskConstMeta( + debugName: "Client_remove_all", + argNames: ["that"], + ); + + @override + Future> crateApiClientClientRequestState( + {required Client that}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + that, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 7, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_list_monitor, + decodeErrorData: sse_decode_request_error, + ), + constMeta: kCrateApiClientClientRequestStateConstMeta, + argValues: [that], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiClientClientRequestStateConstMeta => + const TaskConstMeta( + debugName: "Client_request_state", + argNames: ["that"], + ); + + @override + void crateApiDriverClientDriverClientAdd( + {required DriverClient that, required Monitor monitor}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_box_autoadd_monitor(monitor, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 8)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_duplicate_error, + ), + constMeta: kCrateApiDriverClientDriverClientAddConstMeta, + argValues: [that, monitor], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientAddConstMeta => + const TaskConstMeta( + debugName: "DriverClient_add", + argNames: ["that", "monitor"], + ); + + @override + void crateApiDriverClientDriverClientAddMode( + {required DriverClient that, required int id, required Mode mode}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_u_32(id, serializer); + sse_encode_box_autoadd_mode(mode, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 9)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_add_mode_error, + ), + constMeta: kCrateApiDriverClientDriverClientAddModeConstMeta, + argValues: [that, id, mode], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientAddModeConstMeta => + const TaskConstMeta( + debugName: "DriverClient_add_mode", + argNames: ["that", "id", "mode"], + ); + + @override + Future crateApiDriverClientDriverClientConnect( + {String? pipeName}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_opt_String(pipeName, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 10, port: port_); + }, + codec: SseCodec( + decodeSuccessData: + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient, + decodeErrorData: sse_decode_init_error, + ), + constMeta: kCrateApiDriverClientDriverClientConnectConstMeta, + argValues: [pipeName], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientConnectConstMeta => + const TaskConstMeta( + debugName: "DriverClient_connect", + argNames: ["pipeName"], + ); + + @override + Monitor? crateApiDriverClientDriverClientFindMonitor( + {required DriverClient that, required int id}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_u_32(id, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 11)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_opt_box_autoadd_monitor, + decodeErrorData: null, + ), + constMeta: kCrateApiDriverClientDriverClientFindMonitorConstMeta, + argValues: [that, id], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientFindMonitorConstMeta => + const TaskConstMeta( + debugName: "DriverClient_find_monitor", + argNames: ["that", "id"], + ); + + @override + int? crateApiDriverClientDriverClientNewId( + {required DriverClient that, int? preferredId}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_opt_box_autoadd_u_32(preferredId, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 12)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_opt_box_autoadd_u_32, + decodeErrorData: null, + ), + constMeta: kCrateApiDriverClientDriverClientNewIdConstMeta, + argValues: [that, preferredId], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientNewIdConstMeta => + const TaskConstMeta( + debugName: "DriverClient_new_id", + argNames: ["that", "preferredId"], + ); + + @override + Future crateApiDriverClientDriverClientNotify( + {required DriverClient that}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 13, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_send_error, + ), + constMeta: kCrateApiDriverClientDriverClientNotifyConstMeta, + argValues: [that], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientNotifyConstMeta => + const TaskConstMeta( + debugName: "DriverClient_notify", + argNames: ["that"], + ); + + @override + Future crateApiDriverClientDriverClientPersist( + {required DriverClient that}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 14, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_persist_error, + ), + constMeta: kCrateApiDriverClientDriverClientPersistConstMeta, + argValues: [that], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientPersistConstMeta => + const TaskConstMeta( + debugName: "DriverClient_persist", + argNames: ["that"], + ); + + @override + Stream> crateApiDriverClientDriverClientReceiveEvents( + {required DriverClient that}) { + final sink = RustStreamSink>(); + unawaited(handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_StreamSink_list_monitor_Sse(sink, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 15, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_receive_error, + ), + constMeta: kCrateApiDriverClientDriverClientReceiveEventsConstMeta, + argValues: [that, sink], + apiImpl: this, + ))); + return sink.stream; + } + + TaskConstMeta get kCrateApiDriverClientDriverClientReceiveEventsConstMeta => + const TaskConstMeta( + debugName: "DriverClient_receive_events", + argNames: ["that", "sink"], + ); + + @override + Future> crateApiDriverClientDriverClientRefreshState( + {required DriverClient that}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 16, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_list_monitor, + decodeErrorData: null, + ), + constMeta: kCrateApiDriverClientDriverClientRefreshStateConstMeta, + argValues: [that], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientRefreshStateConstMeta => + const TaskConstMeta( + debugName: "DriverClient_refresh_state", + argNames: ["that"], + ); + + @override + void crateApiDriverClientDriverClientRemove( + {required DriverClient that, required List ids}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_list_prim_u_32_loose(ids, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 17)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: null, + ), + constMeta: kCrateApiDriverClientDriverClientRemoveConstMeta, + argValues: [that, ids], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientRemoveConstMeta => + const TaskConstMeta( + debugName: "DriverClient_remove", + argNames: ["that", "ids"], + ); + + @override + void crateApiDriverClientDriverClientRemoveAll({required DriverClient that}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 18)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: null, + ), + constMeta: kCrateApiDriverClientDriverClientRemoveAllConstMeta, + argValues: [that], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientRemoveAllConstMeta => + const TaskConstMeta( + debugName: "DriverClient_remove_all", + argNames: ["that"], + ); + + @override + void crateApiDriverClientDriverClientRemoveMode( + {required DriverClient that, + required int id, + required (int, int) resolution}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_u_32(id, serializer); + sse_encode_box_autoadd_record_u_32_u_32(resolution, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 19)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_monitor_not_found_error, + ), + constMeta: kCrateApiDriverClientDriverClientRemoveModeConstMeta, + argValues: [that, id, resolution], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientRemoveModeConstMeta => + const TaskConstMeta( + debugName: "DriverClient_remove_mode", + argNames: ["that", "id", "resolution"], + ); + + @override + void crateApiDriverClientDriverClientReplaceMonitor( + {required DriverClient that, required Monitor monitor}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_box_autoadd_monitor(monitor, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 20)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_monitor_not_found_error, + ), + constMeta: kCrateApiDriverClientDriverClientReplaceMonitorConstMeta, + argValues: [that, monitor], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientReplaceMonitorConstMeta => + const TaskConstMeta( + debugName: "DriverClient_replace_monitor", + argNames: ["that", "monitor"], + ); + + @override + void crateApiDriverClientDriverClientSetEnabled( + {required DriverClient that, + required List ids, + required bool enabled}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + that, serializer); + sse_encode_list_prim_u_32_loose(ids, serializer); + sse_encode_bool(enabled, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 21)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: null, + ), + constMeta: kCrateApiDriverClientDriverClientSetEnabledConstMeta, + argValues: [that, ids, enabled], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiDriverClientDriverClientSetEnabledConstMeta => + const TaskConstMeta( + debugName: "DriverClient_set_enabled", + argNames: ["that", "ids", "enabled"], + ); + + @override + void crateApiDriverClientDriverClientSetMonitors( + {required DriverClient that, required List monitors}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( that, serializer); - pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 5, port: port_); + sse_encode_list_monitor(monitors, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 22)!; }, codec: SseCodec( decodeSuccessData: sse_decode_unit, - decodeErrorData: sse_decode_send_error, + decodeErrorData: sse_decode_duplicate_error, ), - constMeta: kCrateApiClientClientRemoveAllConstMeta, - argValues: [that], + constMeta: kCrateApiDriverClientDriverClientSetMonitorsConstMeta, + argValues: [that, monitors], apiImpl: this, )); } - TaskConstMeta get kCrateApiClientClientRemoveAllConstMeta => + TaskConstMeta get kCrateApiDriverClientDriverClientSetMonitorsConstMeta => const TaskConstMeta( - debugName: "Client_remove_all", - argNames: ["that"], + debugName: "DriverClient_set_monitors", + argNames: ["that", "monitors"], ); @override - Future> crateApiClientClientRequestState( - {required Client that}) { - return handler.executeNormal(NormalTask( - callFfi: (port_) { + List crateApiDriverClientDriverClientState( + {required DriverClient that}) { + return handler.executeSync(SyncTask( + callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); - sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( that, serializer); - pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 6, port: port_); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 23)!; }, codec: SseCodec( decodeSuccessData: sse_decode_list_monitor, - decodeErrorData: sse_decode_request_error, + decodeErrorData: null, ), - constMeta: kCrateApiClientClientRequestStateConstMeta, + constMeta: kCrateApiDriverClientDriverClientStateConstMeta, argValues: [that], apiImpl: this, )); } - TaskConstMeta get kCrateApiClientClientRequestStateConstMeta => + TaskConstMeta get kCrateApiDriverClientDriverClientStateConstMeta => const TaskConstMeta( - debugName: "Client_request_state", + debugName: "DriverClient_state", argNames: ["that"], ); @@ -286,7 +815,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_String(pipeName, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 7, port: port_); + funcId: 24, port: port_); }, codec: SseCodec( decodeSuccessData: @@ -312,7 +841,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 8)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 25)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -338,7 +867,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( that, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 9, port: port_); + funcId: 26, port: port_); }, codec: SseCodec( decodeSuccessData: sse_decode_unit, @@ -355,6 +884,34 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { argNames: ["that"], ); + @override + Future crateApiMockMockServerSetState( + {required MockServer that, required List state}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( + that, serializer); + sse_encode_list_monitor(state, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 27, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: null, + ), + constMeta: kCrateApiMockMockServerSetStateConstMeta, + argValues: [that, state], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiMockMockServerSetStateConstMeta => + const TaskConstMeta( + debugName: "MockServer_set_state", + argNames: ["that", "state"], + ); + @override List crateApiMockMockServerState({required MockServer that}) { return handler.executeSync(SyncTask( @@ -362,7 +919,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 10)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 28)!; }, codec: SseCodec( decodeSuccessData: sse_decode_list_monitor, @@ -388,6 +945,14 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { get rust_arc_decrement_strong_count_Client => wire .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient; + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_DriverClient => wire + .rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_DriverClient => wire + .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient; + RustArcIncrementStrongCountFnType get rust_arc_increment_strong_count_MockServer => wire .rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer; @@ -410,6 +975,14 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return ClientImpl.frbInternalDcoDecode(raw as List); } + @protected + DriverClient + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return DriverClientImpl.frbInternalDcoDecode(raw as List); + } + @protected MockServer dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -418,6 +991,14 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return MockServerImpl.frbInternalDcoDecode(raw as List); } + @protected + DriverClient + dco_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return DriverClientImpl.frbInternalDcoDecode(raw as List); + } + @protected MockServer dco_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -434,6 +1015,14 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return ClientImpl.frbInternalDcoDecode(raw as List); } + @protected + DriverClient + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return DriverClientImpl.frbInternalDcoDecode(raw as List); + } + @protected MockServer dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -456,6 +1045,14 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return ClientImpl.frbInternalDcoDecode(raw as List); } + @protected + DriverClient + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return DriverClientImpl.frbInternalDcoDecode(raw as List); + } + @protected MockServer dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -477,12 +1074,74 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return raw as String; } + @protected + AddModeError dco_decode_add_mode_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return AddModeError_MonitorNotFound( + id: dco_decode_u_32(raw[1]), + ); + case 1: + return AddModeError_ModeExists( + monitorId: dco_decode_u_32(raw[1]), + width: dco_decode_u_32(raw[2]), + height: dco_decode_u_32(raw[3]), + ); + case 2: + return AddModeError_RefreshRateExists( + monitorId: dco_decode_u_32(raw[1]), + width: dco_decode_u_32(raw[2]), + height: dco_decode_u_32(raw[3]), + refreshRate: dco_decode_u_32(raw[4]), + ); + default: + throw Exception("unreachable"); + } + } + @protected bool dco_decode_bool(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs return raw as bool; } + @protected + ConnectionError dco_decode_box_autoadd_connection_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_connection_error(raw); + } + + @protected + Mode dco_decode_box_autoadd_mode(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_mode(raw); + } + + @protected + Monitor dco_decode_box_autoadd_monitor(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_monitor(raw); + } + + @protected + (int, int) dco_decode_box_autoadd_record_u_32_u_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as (int, int); + } + + @protected + RequestError dco_decode_box_autoadd_request_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_request_error(raw); + } + + @protected + int dco_decode_box_autoadd_u_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + @protected ConnectionError dco_decode_connection_error(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs @@ -496,12 +1155,55 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } } + @protected + DuplicateError dco_decode_duplicate_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return DuplicateError_Monitor( + id: dco_decode_u_32(raw[1]), + ); + case 1: + return DuplicateError_Mode( + monitorId: dco_decode_u_32(raw[1]), + width: dco_decode_u_32(raw[2]), + height: dco_decode_u_32(raw[3]), + ); + case 2: + return DuplicateError_RefreshRate( + monitorId: dco_decode_u_32(raw[1]), + width: dco_decode_u_32(raw[2]), + height: dco_decode_u_32(raw[3]), + refreshRate: dco_decode_u_32(raw[4]), + ); + default: + throw Exception("unreachable"); + } + } + @protected PlatformInt64 dco_decode_i_64(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs return dcoDecodeI64(raw); } + @protected + InitError dco_decode_init_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return InitError_Connect( + inner: dco_decode_box_autoadd_connection_error(raw[1]), + ); + case 1: + return InitError_RequestState( + inner: dco_decode_box_autoadd_request_error(raw[1]), + ); + default: + throw Exception("unreachable"); + } + } + @protected List dco_decode_list_mode(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs @@ -559,12 +1261,56 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { ); } + @protected + MonitorNotFoundError dco_decode_monitor_not_found_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 1) + throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); + return MonitorNotFoundError( + id: dco_decode_u_32(arr[0]), + ); + } + @protected String? dco_decode_opt_String(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs return raw == null ? null : dco_decode_String(raw); } + @protected + Monitor? dco_decode_opt_box_autoadd_monitor(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_box_autoadd_monitor(raw); + } + + @protected + int? dco_decode_opt_box_autoadd_u_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_box_autoadd_u_32(raw); + } + + @protected + PersistError dco_decode_persist_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return PersistError_Open( + message: dco_decode_String(raw[1]), + ); + case 1: + return PersistError_Set( + message: dco_decode_String(raw[1]), + ); + case 2: + return PersistError_Serialize( + message: dco_decode_String(raw[1]), + ); + default: + throw Exception("unreachable"); + } + } + @protected ReceiveError dco_decode_receive_error(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs @@ -576,6 +1322,19 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { ); } + @protected + (int, int) dco_decode_record_u_32_u_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 2) { + throw Exception('Expected 2 elements, got ${arr.length}'); + } + return ( + dco_decode_u_32(arr[0]), + dco_decode_u_32(arr[1]), + ); + } + @protected RequestError dco_decode_request_error(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs @@ -650,6 +1409,15 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); } + @protected + DriverClient + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return DriverClientImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + @protected MockServer sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -659,6 +1427,15 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); } + @protected + DriverClient + sse_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return DriverClientImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + @protected MockServer sse_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -677,6 +1454,15 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); } + @protected + DriverClient + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return DriverClientImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + @protected MockServer sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -702,6 +1488,15 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); } + @protected + DriverClient + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return DriverClientImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + @protected MockServer sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -725,6 +1520,36 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return utf8.decoder.convert(inner); } + @protected + AddModeError sse_decode_add_mode_error(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var tag_ = sse_decode_i_32(deserializer); + switch (tag_) { + case 0: + var var_id = sse_decode_u_32(deserializer); + return AddModeError_MonitorNotFound(id: var_id); + case 1: + var var_monitorId = sse_decode_u_32(deserializer); + var var_width = sse_decode_u_32(deserializer); + var var_height = sse_decode_u_32(deserializer); + return AddModeError_ModeExists( + monitorId: var_monitorId, width: var_width, height: var_height); + case 2: + var var_monitorId = sse_decode_u_32(deserializer); + var var_width = sse_decode_u_32(deserializer); + var var_height = sse_decode_u_32(deserializer); + var var_refreshRate = sse_decode_u_32(deserializer); + return AddModeError_RefreshRateExists( + monitorId: var_monitorId, + width: var_width, + height: var_height, + refreshRate: var_refreshRate); + default: + throw UnimplementedError(''); + } + } + @protected bool sse_decode_bool(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -732,14 +1557,83 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } @protected - ConnectionError sse_decode_connection_error(SseDeserializer deserializer) { + ConnectionError sse_decode_box_autoadd_connection_error( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_connection_error(deserializer)); + } + + @protected + Mode sse_decode_box_autoadd_mode(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_mode(deserializer)); + } + + @protected + Monitor sse_decode_box_autoadd_monitor(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_monitor(deserializer)); + } + + @protected + (int, int) sse_decode_box_autoadd_record_u_32_u_32( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_record_u_32_u_32(deserializer)); + } + + @protected + RequestError sse_decode_box_autoadd_request_error( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_request_error(deserializer)); + } + + @protected + int sse_decode_box_autoadd_u_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_u_32(deserializer)); + } + + @protected + ConnectionError sse_decode_connection_error(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var tag_ = sse_decode_i_32(deserializer); + switch (tag_) { + case 0: + var var_message = sse_decode_String(deserializer); + return ConnectionError_Failed(message: var_message); + default: + throw UnimplementedError(''); + } + } + + @protected + DuplicateError sse_decode_duplicate_error(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs var tag_ = sse_decode_i_32(deserializer); switch (tag_) { case 0: - var var_message = sse_decode_String(deserializer); - return ConnectionError_Failed(message: var_message); + var var_id = sse_decode_u_32(deserializer); + return DuplicateError_Monitor(id: var_id); + case 1: + var var_monitorId = sse_decode_u_32(deserializer); + var var_width = sse_decode_u_32(deserializer); + var var_height = sse_decode_u_32(deserializer); + return DuplicateError_Mode( + monitorId: var_monitorId, width: var_width, height: var_height); + case 2: + var var_monitorId = sse_decode_u_32(deserializer); + var var_width = sse_decode_u_32(deserializer); + var var_height = sse_decode_u_32(deserializer); + var var_refreshRate = sse_decode_u_32(deserializer); + return DuplicateError_RefreshRate( + monitorId: var_monitorId, + width: var_width, + height: var_height, + refreshRate: var_refreshRate); default: throw UnimplementedError(''); } @@ -751,6 +1645,23 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return deserializer.buffer.getPlatformInt64(); } + @protected + InitError sse_decode_init_error(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var tag_ = sse_decode_i_32(deserializer); + switch (tag_) { + case 0: + var var_inner = sse_decode_box_autoadd_connection_error(deserializer); + return InitError_Connect(inner: var_inner); + case 1: + var var_inner = sse_decode_box_autoadd_request_error(deserializer); + return InitError_RequestState(inner: var_inner); + default: + throw UnimplementedError(''); + } + } + @protected List sse_decode_list_mode(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -817,6 +1728,14 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { id: var_id, name: var_name, enabled: var_enabled, modes: var_modes); } + @protected + MonitorNotFoundError sse_decode_monitor_not_found_error( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_id = sse_decode_u_32(deserializer); + return MonitorNotFoundError(id: var_id); + } + @protected String? sse_decode_opt_String(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -828,6 +1747,48 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } } + @protected + Monitor? sse_decode_opt_box_autoadd_monitor(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_box_autoadd_monitor(deserializer)); + } else { + return null; + } + } + + @protected + int? sse_decode_opt_box_autoadd_u_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_box_autoadd_u_32(deserializer)); + } else { + return null; + } + } + + @protected + PersistError sse_decode_persist_error(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var tag_ = sse_decode_i_32(deserializer); + switch (tag_) { + case 0: + var var_message = sse_decode_String(deserializer); + return PersistError_Open(message: var_message); + case 1: + var var_message = sse_decode_String(deserializer); + return PersistError_Set(message: var_message); + case 2: + var var_message = sse_decode_String(deserializer); + return PersistError_Serialize(message: var_message); + default: + throw UnimplementedError(''); + } + } + @protected ReceiveError sse_decode_receive_error(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -835,6 +1796,14 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return ReceiveError(message: var_message); } + @protected + (int, int) sse_decode_record_u_32_u_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_field0 = sse_decode_u_32(deserializer); + var var_field1 = sse_decode_u_32(deserializer); + return (var_field0, var_field1); + } + @protected RequestError sse_decode_request_error(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -914,6 +1883,16 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { (self as ClientImpl).frbInternalSseEncode(move: true), serializer); } + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + DriverClient self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as DriverClientImpl).frbInternalSseEncode(move: true), + serializer); + } + @protected void sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -923,6 +1902,16 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { (self as MockServerImpl).frbInternalSseEncode(move: true), serializer); } + @protected + void + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + DriverClient self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as DriverClientImpl).frbInternalSseEncode(move: false), + serializer); + } + @protected void sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -941,6 +1930,16 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { (self as ClientImpl).frbInternalSseEncode(move: false), serializer); } + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + DriverClient self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as DriverClientImpl).frbInternalSseEncode(move: false), + serializer); + } + @protected void sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -965,6 +1964,16 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { (self as ClientImpl).frbInternalSseEncode(move: null), serializer); } + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + DriverClient self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as DriverClientImpl).frbInternalSseEncode(move: null), + serializer); + } + @protected void sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -993,12 +2002,83 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { sse_encode_list_prim_u_8_strict(utf8.encoder.convert(self), serializer); } + @protected + void sse_encode_add_mode_error(AddModeError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case AddModeError_MonitorNotFound(id: final id): + sse_encode_i_32(0, serializer); + sse_encode_u_32(id, serializer); + case AddModeError_ModeExists( + monitorId: final monitorId, + width: final width, + height: final height + ): + sse_encode_i_32(1, serializer); + sse_encode_u_32(monitorId, serializer); + sse_encode_u_32(width, serializer); + sse_encode_u_32(height, serializer); + case AddModeError_RefreshRateExists( + monitorId: final monitorId, + width: final width, + height: final height, + refreshRate: final refreshRate + ): + sse_encode_i_32(2, serializer); + sse_encode_u_32(monitorId, serializer); + sse_encode_u_32(width, serializer); + sse_encode_u_32(height, serializer); + sse_encode_u_32(refreshRate, serializer); + default: + throw UnimplementedError(''); + } + } + @protected void sse_encode_bool(bool self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs serializer.buffer.putUint8(self ? 1 : 0); } + @protected + void sse_encode_box_autoadd_connection_error( + ConnectionError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_connection_error(self, serializer); + } + + @protected + void sse_encode_box_autoadd_mode(Mode self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_mode(self, serializer); + } + + @protected + void sse_encode_box_autoadd_monitor(Monitor self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_monitor(self, serializer); + } + + @protected + void sse_encode_box_autoadd_record_u_32_u_32( + (int, int) self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_record_u_32_u_32(self, serializer); + } + + @protected + void sse_encode_box_autoadd_request_error( + RequestError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_request_error(self, serializer); + } + + @protected + void sse_encode_box_autoadd_u_32(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_u_32(self, serializer); + } + @protected void sse_encode_connection_error( ConnectionError self, SseSerializer serializer) { @@ -1012,12 +2092,60 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } } + @protected + void sse_encode_duplicate_error( + DuplicateError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case DuplicateError_Monitor(id: final id): + sse_encode_i_32(0, serializer); + sse_encode_u_32(id, serializer); + case DuplicateError_Mode( + monitorId: final monitorId, + width: final width, + height: final height + ): + sse_encode_i_32(1, serializer); + sse_encode_u_32(monitorId, serializer); + sse_encode_u_32(width, serializer); + sse_encode_u_32(height, serializer); + case DuplicateError_RefreshRate( + monitorId: final monitorId, + width: final width, + height: final height, + refreshRate: final refreshRate + ): + sse_encode_i_32(2, serializer); + sse_encode_u_32(monitorId, serializer); + sse_encode_u_32(width, serializer); + sse_encode_u_32(height, serializer); + sse_encode_u_32(refreshRate, serializer); + default: + throw UnimplementedError(''); + } + } + @protected void sse_encode_i_64(PlatformInt64 self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs serializer.buffer.putPlatformInt64(self); } + @protected + void sse_encode_init_error(InitError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case InitError_Connect(inner: final inner): + sse_encode_i_32(0, serializer); + sse_encode_box_autoadd_connection_error(inner, serializer); + case InitError_RequestState(inner: final inner): + sse_encode_i_32(1, serializer); + sse_encode_box_autoadd_request_error(inner, serializer); + default: + throw UnimplementedError(''); + } + } + @protected void sse_encode_list_mode(List self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -1078,6 +2206,13 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { sse_encode_list_mode(self.modes, serializer); } + @protected + void sse_encode_monitor_not_found_error( + MonitorNotFoundError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_u_32(self.id, serializer); + } + @protected void sse_encode_opt_String(String? self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -1088,12 +2223,58 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } } + @protected + void sse_encode_opt_box_autoadd_monitor( + Monitor? self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + sse_encode_bool(self != null, serializer); + if (self != null) { + sse_encode_box_autoadd_monitor(self, serializer); + } + } + + @protected + void sse_encode_opt_box_autoadd_u_32(int? self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + sse_encode_bool(self != null, serializer); + if (self != null) { + sse_encode_box_autoadd_u_32(self, serializer); + } + } + + @protected + void sse_encode_persist_error(PersistError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case PersistError_Open(message: final message): + sse_encode_i_32(0, serializer); + sse_encode_String(message, serializer); + case PersistError_Set(message: final message): + sse_encode_i_32(1, serializer); + sse_encode_String(message, serializer); + case PersistError_Serialize(message: final message): + sse_encode_i_32(2, serializer); + sse_encode_String(message, serializer); + default: + throw UnimplementedError(''); + } + } + @protected void sse_encode_receive_error(ReceiveError self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs sse_encode_String(self.message, serializer); } + @protected + void sse_encode_record_u_32_u_32((int, int) self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_u_32(self.$1, serializer); + sse_encode_u_32(self.$2, serializer); + } + @protected void sse_encode_request_error(RequestError self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -1207,6 +2388,184 @@ class ClientImpl extends RustOpaque implements Client { ); } +@sealed +class DriverClientImpl extends RustOpaque implements DriverClient { + // Not to be used by end users + DriverClientImpl.frbInternalDcoDecode(List wire) + : super.frbInternalDcoDecode(wire, _kStaticData); + + // Not to be used by end users + DriverClientImpl.frbInternalSseDecode(BigInt ptr, int externalSizeOnNative) + : super.frbInternalSseDecode(ptr, externalSizeOnNative, _kStaticData); + + static final _kStaticData = RustArcStaticData( + rustArcIncrementStrongCount: + RustLib.instance.api.rust_arc_increment_strong_count_DriverClient, + rustArcDecrementStrongCount: + RustLib.instance.api.rust_arc_decrement_strong_count_DriverClient, + rustArcDecrementStrongCountPtr: + RustLib.instance.api.rust_arc_decrement_strong_count_DriverClientPtr, + ); + + /// Add a new monitor. + /// + /// Returns an error if a monitor with this ID already exists, or if the + /// monitor is invalid. A monitor is invalid if it has duplicate modes, or + /// if any of its modes has duplicate refresh rates. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void add({required Monitor monitor}) => RustLib.instance.api + .crateApiDriverClientDriverClientAdd(that: this, monitor: monitor); + + /// Add a mode to the monitor with the given ID. + /// + /// Returns an error if the monitor does not exist, or if the mode already + /// exists on that monitor, or if the mode is invalid. A mode is invalid if + /// it has duplicate refresh rates. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void addMode({required int id, required Mode mode}) => RustLib.instance.api + .crateApiDriverClientDriverClientAddMode(that: this, id: id, mode: mode); + + /// Find the monitor with the given ID. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + Monitor? findMonitor({required int id}) => RustLib.instance.api + .crateApiDriverClientDriverClientFindMonitor(that: this, id: id); + + /// Get the closest available free ID. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + /// + /// Note: Duplicate monitors are ignored when send to the Driver using + /// [DriverClient.notify]. + int? newId({int? preferredId}) => + RustLib.instance.api.crateApiDriverClientDriverClientNewId( + that: this, preferredId: preferredId); + + /// Send the current client state to the driver. + /// + /// State changes of the client are not automatically sent to the driver. + /// You must manually call this method to send changes to the driver. + Future notify() => + RustLib.instance.api.crateApiDriverClientDriverClientNotify( + that: this, + ); + + /// Write client state to the registry for current user. + /// + /// Next time the driver is started, it will load this state from the + /// registry. This might be after a reboot or a driver restart. + Future persist() => + RustLib.instance.api.crateApiDriverClientDriverClientPersist( + that: this, + ); + + /// Returns a stream of continuous events from the driver. + /// + /// This stream will always reflect the real state of the driver, regardless + /// of who changed its state. This means, if it is changed by another + /// process, this stream will still be updated. + Stream> receiveEvents() => + RustLib.instance.api.crateApiDriverClientDriverClientReceiveEvents( + that: this, + ); + + /// Manually synchronize with the driver. + Future> refreshState() => + RustLib.instance.api.crateApiDriverClientDriverClientRefreshState( + that: this, + ); + + /// Remove monitors by id. + /// + /// Silently skips IDs that do not exist. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void remove({required List ids}) => RustLib.instance.api + .crateApiDriverClientDriverClientRemove(that: this, ids: ids); + + /// Remove all monitors. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + void removeAll() => + RustLib.instance.api.crateApiDriverClientDriverClientRemoveAll( + that: this, + ); + + /// Remove a mode from the monitor with the given ID. + /// + /// Returns an error if the monitor does not exist. If the mode does not + /// exist, it is silently skipped. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void removeMode({required int id, required (int, int) resolution}) => + RustLib.instance.api.crateApiDriverClientDriverClientRemoveMode( + that: this, id: id, resolution: resolution); + + /// Replace an existing monitor. The monitor is identified by its ID. + /// + /// Throws [MonitorNotFoundError] if the monitor does not exist. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void replaceMonitor({required Monitor monitor}) => + RustLib.instance.api.crateApiDriverClientDriverClientReplaceMonitor( + that: this, monitor: monitor); + + /// Set enabled state of all monitors with the given IDs. + /// + /// Silently skips incorrect IDs. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + void setEnabled({required List ids, required bool enabled}) => + RustLib.instance.api.crateApiDriverClientDriverClientSetEnabled( + that: this, ids: ids, enabled: enabled); + + /// Replace all monitors. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + void setMonitors({required List monitors}) => + RustLib.instance.api.crateApiDriverClientDriverClientSetMonitors( + that: this, monitors: monitors); + + /// Get the current monitor state stored inside this client. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + List get state => + RustLib.instance.api.crateApiDriverClientDriverClientState( + that: this, + ); +} + @sealed class MockServerImpl extends RustOpaque implements MockServer { // Not to be used by end users @@ -1234,6 +2593,9 @@ class MockServerImpl extends RustOpaque implements MockServer { that: this, ); + Future setState({required List state}) => RustLib.instance.api + .crateApiMockMockServerSetState(that: this, state: state); + List get state => RustLib.instance.api.crateApiMockMockServerState( that: this, ); diff --git a/rust/bindings/dart/lib/src/generated/frb_generated.io.dart b/rust/bindings/dart/lib/src/generated/frb_generated.io.dart index ef2ed49..caf2956 100644 --- a/rust/bindings/dart/lib/src/generated/frb_generated.io.dart +++ b/rust/bindings/dart/lib/src/generated/frb_generated.io.dart @@ -5,6 +5,7 @@ import 'api.dart'; import 'api/client.dart'; +import 'api/driver_client.dart'; import 'api/mock.dart'; import 'dart:async'; import 'dart:convert'; @@ -23,6 +24,10 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_ClientPtr => wire ._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClientPtr; + CrossPlatformFinalizerArg + get rust_arc_decrement_strong_count_DriverClientPtr => wire + ._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClientPtr; + CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_MockServerPtr => wire._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServerPtr; @@ -34,11 +39,21 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( dynamic raw); + @protected + DriverClient + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + dynamic raw); + @protected MockServer dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( dynamic raw); + @protected + DriverClient + dco_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + dynamic raw); + @protected MockServer dco_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -49,6 +64,11 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( dynamic raw); + @protected + DriverClient + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + dynamic raw); + @protected MockServer dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -62,6 +82,11 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( dynamic raw); + @protected + DriverClient + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + dynamic raw); + @protected MockServer dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -74,15 +99,42 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected String dco_decode_String(dynamic raw); + @protected + AddModeError dco_decode_add_mode_error(dynamic raw); + @protected bool dco_decode_bool(dynamic raw); + @protected + ConnectionError dco_decode_box_autoadd_connection_error(dynamic raw); + + @protected + Mode dco_decode_box_autoadd_mode(dynamic raw); + + @protected + Monitor dco_decode_box_autoadd_monitor(dynamic raw); + + @protected + (int, int) dco_decode_box_autoadd_record_u_32_u_32(dynamic raw); + + @protected + RequestError dco_decode_box_autoadd_request_error(dynamic raw); + + @protected + int dco_decode_box_autoadd_u_32(dynamic raw); + @protected ConnectionError dco_decode_connection_error(dynamic raw); + @protected + DuplicateError dco_decode_duplicate_error(dynamic raw); + @protected PlatformInt64 dco_decode_i_64(dynamic raw); + @protected + InitError dco_decode_init_error(dynamic raw); + @protected List dco_decode_list_mode(dynamic raw); @@ -104,12 +156,27 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected Monitor dco_decode_monitor(dynamic raw); + @protected + MonitorNotFoundError dco_decode_monitor_not_found_error(dynamic raw); + @protected String? dco_decode_opt_String(dynamic raw); + @protected + Monitor? dco_decode_opt_box_autoadd_monitor(dynamic raw); + + @protected + int? dco_decode_opt_box_autoadd_u_32(dynamic raw); + + @protected + PersistError dco_decode_persist_error(dynamic raw); + @protected ReceiveError dco_decode_receive_error(dynamic raw); + @protected + (int, int) dco_decode_record_u_32_u_32(dynamic raw); + @protected RequestError dco_decode_request_error(dynamic raw); @@ -136,11 +203,21 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( SseDeserializer deserializer); + @protected + DriverClient + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + SseDeserializer deserializer); + @protected MockServer sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( SseDeserializer deserializer); + @protected + DriverClient + sse_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + SseDeserializer deserializer); + @protected MockServer sse_decode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -151,6 +228,11 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( SseDeserializer deserializer); + @protected + DriverClient + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + SseDeserializer deserializer); + @protected MockServer sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -164,6 +246,11 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( SseDeserializer deserializer); + @protected + DriverClient + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + SseDeserializer deserializer); + @protected MockServer sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -176,15 +263,45 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected String sse_decode_String(SseDeserializer deserializer); + @protected + AddModeError sse_decode_add_mode_error(SseDeserializer deserializer); + @protected bool sse_decode_bool(SseDeserializer deserializer); + @protected + ConnectionError sse_decode_box_autoadd_connection_error( + SseDeserializer deserializer); + + @protected + Mode sse_decode_box_autoadd_mode(SseDeserializer deserializer); + + @protected + Monitor sse_decode_box_autoadd_monitor(SseDeserializer deserializer); + + @protected + (int, int) sse_decode_box_autoadd_record_u_32_u_32( + SseDeserializer deserializer); + + @protected + RequestError sse_decode_box_autoadd_request_error( + SseDeserializer deserializer); + + @protected + int sse_decode_box_autoadd_u_32(SseDeserializer deserializer); + @protected ConnectionError sse_decode_connection_error(SseDeserializer deserializer); + @protected + DuplicateError sse_decode_duplicate_error(SseDeserializer deserializer); + @protected PlatformInt64 sse_decode_i_64(SseDeserializer deserializer); + @protected + InitError sse_decode_init_error(SseDeserializer deserializer); + @protected List sse_decode_list_mode(SseDeserializer deserializer); @@ -206,12 +323,28 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected Monitor sse_decode_monitor(SseDeserializer deserializer); + @protected + MonitorNotFoundError sse_decode_monitor_not_found_error( + SseDeserializer deserializer); + @protected String? sse_decode_opt_String(SseDeserializer deserializer); + @protected + Monitor? sse_decode_opt_box_autoadd_monitor(SseDeserializer deserializer); + + @protected + int? sse_decode_opt_box_autoadd_u_32(SseDeserializer deserializer); + + @protected + PersistError sse_decode_persist_error(SseDeserializer deserializer); + @protected ReceiveError sse_decode_receive_error(SseDeserializer deserializer); + @protected + (int, int) sse_decode_record_u_32_u_32(SseDeserializer deserializer); + @protected RequestError sse_decode_request_error(SseDeserializer deserializer); @@ -242,11 +375,21 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( Client self, SseSerializer serializer); + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + DriverClient self, SseSerializer serializer); + @protected void sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( MockServer self, SseSerializer serializer); + @protected + void + sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + DriverClient self, SseSerializer serializer); + @protected void sse_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -257,6 +400,11 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( Client self, SseSerializer serializer); + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + DriverClient self, SseSerializer serializer); + @protected void sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -270,6 +418,11 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClient( Client self, SseSerializer serializer); + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + DriverClient self, SseSerializer serializer); + @protected void sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( @@ -282,16 +435,47 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected void sse_encode_String(String self, SseSerializer serializer); + @protected + void sse_encode_add_mode_error(AddModeError self, SseSerializer serializer); + @protected void sse_encode_bool(bool self, SseSerializer serializer); + @protected + void sse_encode_box_autoadd_connection_error( + ConnectionError self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_mode(Mode self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_monitor(Monitor self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_record_u_32_u_32( + (int, int) self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_request_error( + RequestError self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_u_32(int self, SseSerializer serializer); + @protected void sse_encode_connection_error( ConnectionError self, SseSerializer serializer); + @protected + void sse_encode_duplicate_error( + DuplicateError self, SseSerializer serializer); + @protected void sse_encode_i_64(PlatformInt64 self, SseSerializer serializer); + @protected + void sse_encode_init_error(InitError self, SseSerializer serializer); + @protected void sse_encode_list_mode(List self, SseSerializer serializer); @@ -316,12 +500,29 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { @protected void sse_encode_monitor(Monitor self, SseSerializer serializer); + @protected + void sse_encode_monitor_not_found_error( + MonitorNotFoundError self, SseSerializer serializer); + @protected void sse_encode_opt_String(String? self, SseSerializer serializer); + @protected + void sse_encode_opt_box_autoadd_monitor( + Monitor? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_u_32(int? self, SseSerializer serializer); + + @protected + void sse_encode_persist_error(PersistError self, SseSerializer serializer); + @protected void sse_encode_receive_error(ReceiveError self, SseSerializer serializer); + @protected + void sse_encode_record_u_32_u_32((int, int) self, SseSerializer serializer); + @protected void sse_encode_request_error(RequestError self, SseSerializer serializer); @@ -390,6 +591,38 @@ class RustLibWire implements BaseWire { _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerClientPtr .asFunction)>(); + void + rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + ffi.Pointer ptr, + ) { + return _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + ptr, + ); + } + + late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClientPtr = + _lookup)>>( + 'frbgen_vdd_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient'); + late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient = + _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClientPtr + .asFunction)>(); + + void + rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + ffi.Pointer ptr, + ) { + return _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + ptr, + ); + } + + late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClientPtr = + _lookup)>>( + 'frbgen_vdd_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient'); + late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient = + _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClientPtr + .asFunction)>(); + void rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( ffi.Pointer ptr, diff --git a/rust/bindings/dart/lib/vdd.dart b/rust/bindings/dart/lib/vdd.dart index 4d37d39..a4b1d17 100644 --- a/rust/bindings/dart/lib/vdd.dart +++ b/rust/bindings/dart/lib/vdd.dart @@ -4,3 +4,4 @@ export 'src/init.dart' show init; export 'src/generated/api.dart' show Mode, Monitor; export 'src/generated/api/client.dart' show Client; +export 'src/generated/api/driver_client.dart' show DriverClient; diff --git a/rust/bindings/dart/rust/src/api/client.rs b/rust/bindings/dart/rust/src/api/client.rs index c0855c0..c260a7c 100644 --- a/rust/bindings/dart/rust/src/api/client.rs +++ b/rust/bindings/dart/rust/src/api/client.rs @@ -77,6 +77,15 @@ impl Client { } Ok(()) } + + /// Write `monitors` to the registry for current user. + /// + /// Next time the driver is started, it will load this state from the + /// registry. This might be after a reboot or a driver restart. + pub fn persist(monitors: &[ipc::Monitor]) -> Result<(), PersistError> { + ipc::Client::persist(monitors)?; + Ok(()) + } } #[frb(dart_code = " @@ -166,3 +175,33 @@ impl From for ReceiveError { } } } + +#[frb(dart_code = " + @override + String toString() => switch (this) { + PersistError_Open(:final message) => 'Failed to open registry key: $message', + PersistError_Set(:final message) => 'Failed to set registry key: $message', + PersistError_Serialize(:final message) => 'Failed to serialize data: $message', + }; +")] +pub enum PersistError { + Open { message: String }, + Set { message: String }, + Serialize { message: String }, +} + +impl From for PersistError { + fn from(err: ipc::error::PersistError) -> Self { + match err { + ipc::error::PersistError::Open(err) => PersistError::Open { + message: err.to_string(), + }, + ipc::error::PersistError::Set(err) => PersistError::Set { + message: err.to_string(), + }, + ipc::error::PersistError::Serialize(err) => PersistError::Serialize { + message: err.to_string(), + }, + } + } +} diff --git a/rust/bindings/dart/rust/src/api/driver_client.rs b/rust/bindings/dart/rust/src/api/driver_client.rs new file mode 100644 index 0000000..daabba5 --- /dev/null +++ b/rust/bindings/dart/rust/src/api/driver_client.rs @@ -0,0 +1,363 @@ +#![allow(clippy::doc_markdown)] + +use driver_ipc::Monitor; +use flutter_rust_bridge::frb; +use tokio_stream::StreamExt; + +use crate::frb_generated::StreamSink; + +use super::client; + +mod ipc { + pub use driver_ipc::driver_client::*; + pub use driver_ipc::*; +} + +/// Abstraction layer over [Client]. +/// +/// It manages its own state. Changing this state does not affect the driver +/// directly. You must call [DriverClient.notify] to send changes to the +/// driver. To make your changes persistent across reboots, call +/// [DriverClient.persist]. To synchronize this object with the driver, you +/// must call [DriverClient.refreshState]. The state will not be updated +/// automatically. +#[frb(opaque)] +pub struct DriverClient(ipc::DriverClient); + +impl DriverClient { + /// Connect to driver on pipe with default name. + /// + /// You can optionally specify the name of the named pipe to connect to. The + /// default name is "virtualdisplaydriver" + pub async fn connect(pipe_name: Option) -> Result { + match pipe_name { + Some(pipe_name) => Ok(Self(ipc::DriverClient::new_with(&pipe_name).await?)), + None => Ok(Self(ipc::DriverClient::new().await?)), + } + } + + /// Manually synchronize with the driver. + pub fn refresh_state(&mut self) -> Vec { + self.0.refresh_state().to_owned() + } + + /// Returns a stream of continuous events from the driver. + /// + /// This stream will always reflect the real state of the driver, regardless + /// of who changed its state. This means, if it is changed by another + /// process, this stream will still be updated. + pub async fn receive_events( + &self, + sink: StreamSink>, + ) -> Result<(), client::ReceiveError> { + let mut stream = self.0.receive_events(); + while let Some(v) = stream.next().await { + let result = match v { + Ok(ipc::EventCommand::Changed(monitors)) => sink.add(monitors), + Err(err) => sink.add_error(client::ReceiveError::from(err)), + Ok(_) => continue, + }; + + if result.is_err() { + return Ok(()); + } + } + Ok(()) + } + + /// Get the current monitor state stored inside this client. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + #[frb(getter, sync)] + pub fn state(&self) -> Vec { + self.0.monitors().to_owned() + } + + /// Send the current client state to the driver. + /// + /// State changes of the client are not automatically sent to the driver. + /// You must manually call this method to send changes to the driver. + pub async fn notify(&mut self) -> Result<(), client::SendError> { + self.0.notify().await?; + Ok(()) + } + + /// Find the monitor with the given ID. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + #[must_use] + #[frb(sync)] + pub fn find_monitor(&self, id: u32) -> Option { + self.0.find_monitor(id).cloned() + } + + /// Replace all monitors. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + #[frb(sync)] + pub fn set_monitors(&mut self, monitors: &[Monitor]) -> Result<(), DuplicateError> { + self.0.set_monitors(monitors)?; + Ok(()) + } + + /// Replace an existing monitor. The monitor is identified by its ID. + /// + /// Throws [MonitorNotFoundError] if the monitor does not exist. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + #[frb(sync)] + pub fn replace_monitor(&mut self, monitor: Monitor) -> Result<(), MonitorNotFoundError> { + self.0.replace_monitor(monitor)?; + Ok(()) + } + + /// Remove monitors by id. + /// + /// Silently skips IDs that do not exist. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + #[frb(sync)] + pub fn remove(&mut self, ids: &[u32]) { + self.0.remove(ids); + } + + /// Remove all monitors. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + #[frb(sync)] + pub fn remove_all(&mut self) { + self.0.remove_all(); + } + + /// Add a new monitor. + /// + /// Returns an error if a monitor with this ID already exists, or if the + /// monitor is invalid. A monitor is invalid if it has duplicate modes, or + /// if any of its modes has duplicate refresh rates. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + #[frb(sync)] + pub fn add(&mut self, monitor: Monitor) -> Result<(), DuplicateError> { + self.0.add(monitor)?; + Ok(()) + } + + /// Set enabled state of all monitors with the given IDs. + /// + /// Silently skips incorrect IDs. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + #[frb(sync)] + pub fn set_enabled(&mut self, ids: &[u32], enabled: bool) { + self.0.set_enabled(ids, enabled); + } + + /// Add a mode to the monitor with the given ID. + /// + /// Returns an error if the monitor does not exist, or if the mode already + /// exists on that monitor, or if the mode is invalid. A mode is invalid if + /// it has duplicate refresh rates. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + #[frb(sync)] + pub fn add_mode(&mut self, id: u32, mode: ipc::Mode) -> Result<(), AddModeError> { + self.0.add_mode(id, mode)?; + Ok(()) + } + + /// Remove a mode from the monitor with the given ID. + /// + /// Returns an error if the monitor does not exist. If the mode does not + /// exist, it is silently skipped. + /// + /// Note: This does not affect the driver. Manually call + /// [DriverClient.notify] to send these changes to the driver. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + #[frb(sync)] + pub fn remove_mode( + &mut self, + id: u32, + resolution: (u32, u32), + ) -> Result<(), MonitorNotFoundError> { + self.0.remove_mode(id, resolution)?; + Ok(()) + } + + /// Get the closest available free ID. + /// + /// Note: Client state might be stale. To synchronize with the driver, + /// manually call [DriverClient.refreshState]. + /// + /// Note: Duplicate monitors are ignored when send to the Driver using + /// [DriverClient.notify]. + #[must_use] + #[frb(sync)] + pub fn new_id(&self, preferred_id: Option) -> Option { + self.0.new_id(preferred_id) + } + + /// Write client state to the registry for current user. + /// + /// Next time the driver is started, it will load this state from the + /// registry. This might be after a reboot or a driver restart. + pub fn persist(&self) -> Result<(), client::PersistError> { + self.0.persist()?; + Ok(()) + } +} + +#[frb(dart_code = " + @override + String toString() => 'Failed to initialize DriverClient: $inner'; +")] +pub enum InitError { + Connect { inner: client::ConnectionError }, + RequestState { inner: client::RequestError }, +} + +impl From for InitError { + fn from(value: ipc::error::InitError) -> Self { + match value { + ipc::error::InitError::Connect(inner) => InitError::Connect { + inner: inner.into(), + }, + ipc::error::InitError::RequestState(inner) => InitError::RequestState { + inner: inner.into(), + }, + } + } +} + +#[frb(dart_code = " + @override + String toString() => switch (this) { + DuplicateError_Monitor(:final id) => 'Monitor with id $id already exists', + DuplicateError_Mode(:final monitorId, :final width, :final height) => 'Mode ${width}x$height already exists on monitor $monitorId', + DuplicateError_RefreshRate(:final monitorId, :final width, :final height, :final refreshRate) => 'Refresh rate $refreshRate already exists on mode ${width}x$height on monitor $monitorId', + }; +")] +pub enum DuplicateError { + Monitor { + id: u32, + }, + Mode { + monitor_id: u32, + width: u32, + height: u32, + }, + RefreshRate { + monitor_id: u32, + width: u32, + height: u32, + refresh_rate: u32, + }, +} + +impl From for DuplicateError { + fn from(value: ipc::error::DuplicateError) -> Self { + match value { + ipc::error::DuplicateError::Monitor(id) => DuplicateError::Monitor { id }, + ipc::error::DuplicateError::Mode(width, height, monitor_id) => DuplicateError::Mode { + monitor_id, + width, + height, + }, + ipc::error::DuplicateError::RefreshRate(refresh_rate, width, height, monitor_id) => { + DuplicateError::RefreshRate { + monitor_id, + width, + height, + refresh_rate, + } + } + } + } +} + +#[frb(dart_code = " + @override + String toString() => 'Monitor with id $id not found'; +")] +pub struct MonitorNotFoundError { + pub id: u32, +} + +impl From for MonitorNotFoundError { + fn from(value: ipc::error::MonNotFound) -> Self { + MonitorNotFoundError { id: value.0 } + } +} + +#[frb(dart_code = " + @override + String toString() => switch (this) { + AddModeError_MonitorNotFound(:final id) => 'Monitor with id $id not found', + AddModeError_ModeExists(:final monitorId, :final width, :final height) => 'Mode ${width}x$height already exists on monitor $monitorId', + AddModeError_RefreshRateExists(:final monitorId, :final width, :final height, :final refreshRate) => 'Refresh rate $refreshRate already exists on mode ${width}x$height on monitor $monitorId', + }; +")] +pub enum AddModeError { + MonitorNotFound { + id: u32, + }, + ModeExists { + monitor_id: u32, + width: u32, + height: u32, + }, + RefreshRateExists { + monitor_id: u32, + width: u32, + height: u32, + refresh_rate: u32, + }, +} + +impl From for AddModeError { + fn from(value: ipc::error::AddModeError) -> Self { + match value { + ipc::error::AddModeError::MonNotFound(id) => AddModeError::MonitorNotFound { id }, + ipc::error::AddModeError::DupMode(monitor_id, width, height) => { + AddModeError::ModeExists { + monitor_id, + width, + height, + } + } + ipc::error::AddModeError::DupRefreshRate(refresh_rate, width, height, monitor_id) => { + AddModeError::RefreshRateExists { + monitor_id, + width, + height, + refresh_rate, + } + } + } + } +} diff --git a/rust/bindings/dart/rust/src/api/mock.rs b/rust/bindings/dart/rust/src/api/mock.rs index 65b527e..0570729 100644 --- a/rust/bindings/dart/rust/src/api/mock.rs +++ b/rust/bindings/dart/rust/src/api/mock.rs @@ -29,6 +29,10 @@ impl MockServer { self.server.state().to_owned() } + pub async fn set_state(&mut self, state: Vec) { + self.server.set_state(state).await; + } + pub async fn pump(&mut self) { self.server.pump().await; } diff --git a/rust/bindings/dart/rust/src/api/mod.rs b/rust/bindings/dart/rust/src/api/mod.rs index fcc47a9..121d2f9 100644 --- a/rust/bindings/dart/rust/src/api/mod.rs +++ b/rust/bindings/dart/rust/src/api/mod.rs @@ -1,7 +1,9 @@ pub mod client; +pub mod driver_client; pub mod mock; pub use client::*; +pub use driver_client::*; pub use mock::*; pub use driver_ipc::Mode; diff --git a/rust/bindings/dart/rust/src/frb_generated.rs b/rust/bindings/dart/rust/src/frb_generated.rs index 79ead1a..abb477c 100644 --- a/rust/bindings/dart/rust/src/frb_generated.rs +++ b/rust/bindings/dart/rust/src/frb_generated.rs @@ -26,6 +26,7 @@ // Section: imports use crate::api::client::*; +use crate::api::driver_client::*; use crate::api::mock::*; use flutter_rust_bridge::for_generated::byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt}; use flutter_rust_bridge::for_generated::{transform_result_dco, Lifetimeable, Lockable}; @@ -39,7 +40,7 @@ flutter_rust_bridge::frb_generated_boilerplate!( default_rust_auto_opaque = RustAutoOpaqueMoi, ); pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.2.0"; -pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -392242162; +pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -527967754; // Section: executor @@ -141,6 +142,39 @@ fn wire__crate__api__client__Client_notify_impl( }, ) } +fn wire__crate__api__client__Client_persist_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Client_persist", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_monitors = >::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, crate::api::client::PersistError>((move || { + let output_ok = crate::api::client::Client::persist(&api_monitors)?; + Ok(output_ok) + })()) + } + }, + ) +} fn wire__crate__api__client__Client_receive_events_impl( port_: flutter_rust_bridge::for_generated::MessagePort, ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, @@ -259,17 +293,847 @@ fn wire__crate__api__client__Client_remove_impl( }, ) } -fn wire__crate__api__client__Client_remove_all_impl( - port_: flutter_rust_bridge::for_generated::MessagePort, +fn wire__crate__api__client__Client_remove_all_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Client_remove_all", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, crate::api::client::SendError>( + (move || async move { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order( + vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + )], + ); + for i in decode_indices_ { + match i { + 0 => { + api_that_guard = + Some(api_that.lockable_decode_async_ref().await) + } + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = + crate::api::client::Client::remove_all(&*api_that_guard).await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__client__Client_request_state_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "Client_request_state", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, crate::api::client::RequestError>( + (move || async move { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order( + vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + )], + ); + for i in decode_indices_ { + match i { + 0 => { + api_that_guard = + Some(api_that.lockable_decode_async_ref().await) + } + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = + crate::api::client::Client::request_state(&*api_that_guard).await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_add_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_add", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_monitor = ::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, crate::api::driver_client::DuplicateError>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = crate::api::driver_client::DriverClient::add( + &mut *api_that_guard, + api_monitor, + )?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_add_mode_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_add_mode", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_id = ::sse_decode(&mut deserializer); + let api_mode = ::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, crate::api::driver_client::AddModeError>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = crate::api::driver_client::DriverClient::add_mode( + &mut *api_that_guard, + api_id, + api_mode, + )?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_connect_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_connect", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_pipe_name = >::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, crate::api::driver_client::InitError>( + (move || async move { + let output_ok = + crate::api::driver_client::DriverClient::connect(api_pipe_name).await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_find_monitor_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_find_monitor", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_id = ::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()), + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok( + crate::api::driver_client::DriverClient::find_monitor(&*api_that_guard, api_id), + )?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_new_id_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_new_id", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_preferred_id = >::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()), + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = + Result::<_, ()>::Ok(crate::api::driver_client::DriverClient::new_id( + &*api_that_guard, + api_preferred_id, + ))?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_notify_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_notify", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, crate::api::client::SendError>( + (move || async move { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order( + vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + )], + ); + for i in decode_indices_ { + match i { + 0 => { + api_that_guard = + Some(api_that.lockable_decode_async_ref_mut().await) + } + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = + crate::api::driver_client::DriverClient::notify(&mut *api_that_guard) + .await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_persist_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_persist", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, crate::api::client::PersistError>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()), + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = + crate::api::driver_client::DriverClient::persist(&*api_that_guard)?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_receive_events_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_receive_events", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_sink = , + flutter_rust_bridge::for_generated::SseCodec, + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, crate::api::client::ReceiveError>( + (move || async move { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order( + vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + )], + ); + for i in decode_indices_ { + match i { + 0 => { + api_that_guard = + Some(api_that.lockable_decode_async_ref().await) + } + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = crate::api::driver_client::DriverClient::receive_events( + &*api_that_guard, + api_sink, + ) + .await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_refresh_state_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_refresh_state", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, ()>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok( + crate::api::driver_client::DriverClient::refresh_state( + &mut *api_that_guard, + ), + )?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_remove_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_remove", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_ids = >::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok({ + crate::api::driver_client::DriverClient::remove(&mut *api_that_guard, &api_ids); + })?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_remove_all_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_remove_all", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok({ + crate::api::driver_client::DriverClient::remove_all(&mut *api_that_guard); + })?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_remove_mode_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_remove_mode", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_id = ::sse_decode(&mut deserializer); + let api_resolution = <(u32, u32)>::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, crate::api::driver_client::MonitorNotFoundError>( + (move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = crate::api::driver_client::DriverClient::remove_mode( + &mut *api_that_guard, + api_id, + api_resolution, + )?; + Ok(output_ok) + })(), + ) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_replace_monitor_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_replace_monitor", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_monitor = ::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, crate::api::driver_client::MonitorNotFoundError>( + (move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = crate::api::driver_client::DriverClient::replace_monitor( + &mut *api_that_guard, + api_monitor, + )?; + Ok(output_ok) + })(), + ) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_set_enabled_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "DriverClient_set_enabled", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_ids = >::sse_decode(&mut deserializer); + let api_enabled = ::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok({ + crate::api::driver_client::DriverClient::set_enabled( + &mut *api_that_guard, + &api_ids, + api_enabled, + ); + })?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__driver_client__DriverClient_set_monitors_impl( ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, rust_vec_len_: i32, data_len_: i32, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( flutter_rust_bridge::for_generated::TaskInfo { - debug_name: "Client_remove_all", - port: Some(port_), - mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + debug_name: "DriverClient_set_monitors", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, }, move || { let message = unsafe { @@ -282,50 +1146,44 @@ fn wire__crate__api__client__Client_remove_all_impl( let mut deserializer = flutter_rust_bridge::for_generated::SseDeserializer::new(message); let api_that = , + flutter_rust_bridge::for_generated::RustAutoOpaqueInner, >>::sse_decode(&mut deserializer); + let api_monitors = >::sse_decode(&mut deserializer); deserializer.end(); - move |context| async move { - transform_result_sse::<_, crate::api::client::SendError>( - (move || async move { - let mut api_that_guard = None; - let decode_indices_ = - flutter_rust_bridge::for_generated::lockable_compute_decode_order( - vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( - &api_that, 0, false, - )], - ); - for i in decode_indices_ { - match i { - 0 => { - api_that_guard = - Some(api_that.lockable_decode_async_ref().await) - } - _ => unreachable!(), - } - } - let api_that_guard = api_that_guard.unwrap(); - let output_ok = - crate::api::client::Client::remove_all(&*api_that_guard).await?; - Ok(output_ok) - })() - .await, - ) - } + transform_result_sse::<_, crate::api::driver_client::DuplicateError>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref_mut()), + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = crate::api::driver_client::DriverClient::set_monitors( + &mut *api_that_guard, + &api_monitors, + )?; + Ok(output_ok) + })()) }, ) } -fn wire__crate__api__client__Client_request_state_impl( - port_: flutter_rust_bridge::for_generated::MessagePort, +fn wire__crate__api__driver_client__DriverClient_state_impl( ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, rust_vec_len_: i32, data_len_: i32, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( flutter_rust_bridge::for_generated::TaskInfo { - debug_name: "Client_request_state", - port: Some(port_), - mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + debug_name: "DriverClient_state", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, }, move || { let message = unsafe { @@ -338,36 +1196,29 @@ fn wire__crate__api__client__Client_request_state_impl( let mut deserializer = flutter_rust_bridge::for_generated::SseDeserializer::new(message); let api_that = , + flutter_rust_bridge::for_generated::RustAutoOpaqueInner, >>::sse_decode(&mut deserializer); deserializer.end(); - move |context| async move { - transform_result_sse::<_, crate::api::client::RequestError>( - (move || async move { - let mut api_that_guard = None; - let decode_indices_ = - flutter_rust_bridge::for_generated::lockable_compute_decode_order( - vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( - &api_that, 0, false, - )], - ); - for i in decode_indices_ { - match i { - 0 => { - api_that_guard = - Some(api_that.lockable_decode_async_ref().await) - } - _ => unreachable!(), - } - } - let api_that_guard = api_that_guard.unwrap(); - let output_ok = - crate::api::client::Client::request_state(&*api_that_guard).await?; - Ok(output_ok) - })() - .await, - ) - } + transform_result_sse::<_, ()>((move || { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, false, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()), + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok( + crate::api::driver_client::DriverClient::state(&*api_that_guard), + )?; + Ok(output_ok) + })()) }, ) } @@ -513,6 +1364,68 @@ fn wire__crate__api__mock__MockServer_pump_impl( }, ) } +fn wire__crate__api__mock__MockServer_set_state_impl( + port_: flutter_rust_bridge::for_generated::MessagePort, + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "MockServer_set_state", + port: Some(port_), + mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_that = , + >>::sse_decode(&mut deserializer); + let api_state = >::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, ()>( + (move || async move { + let mut api_that_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order( + vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_that, 0, true, + )], + ); + for i in decode_indices_ { + match i { + 0 => { + api_that_guard = + Some(api_that.lockable_decode_async_ref_mut().await) + } + _ => unreachable!(), + } + } + let mut api_that_guard = api_that_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok({ + crate::api::mock::MockServer::set_state( + &mut *api_that_guard, + api_state, + ) + .await; + })?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} fn wire__crate__api__mock__MockServer_state_impl( ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, rust_vec_len_: i32, @@ -585,6 +1498,9 @@ const _: fn() = || { flutter_rust_bridge::frb_generated_moi_arc_impl_value!( flutter_rust_bridge::for_generated::RustAutoOpaqueInner ); +flutter_rust_bridge::frb_generated_moi_arc_impl_value!( + flutter_rust_bridge::for_generated::RustAutoOpaqueInner +); flutter_rust_bridge::frb_generated_moi_arc_impl_value!( flutter_rust_bridge::for_generated::RustAutoOpaqueInner ); @@ -609,6 +1525,16 @@ impl SseDecode for Client { } } +impl SseDecode for DriverClient { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = , + >>::sse_decode(deserializer); + return flutter_rust_bridge::for_generated::rust_auto_opaque_decode_owned(inner); + } +} + impl SseDecode for MockServer { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -635,6 +1561,16 @@ impl SseDecode for RustOpaqueMoi> +{ + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return decode_rust_opaque_moi(inner); + } +} + impl SseDecode for RustOpaqueMoi> { @@ -663,6 +1599,44 @@ impl SseDecode for String { } } +impl SseDecode for crate::api::driver_client::AddModeError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut tag_ = ::sse_decode(deserializer); + match tag_ { + 0 => { + let mut var_id = ::sse_decode(deserializer); + return crate::api::driver_client::AddModeError::MonitorNotFound { id: var_id }; + } + 1 => { + let mut var_monitorId = ::sse_decode(deserializer); + let mut var_width = ::sse_decode(deserializer); + let mut var_height = ::sse_decode(deserializer); + return crate::api::driver_client::AddModeError::ModeExists { + monitor_id: var_monitorId, + width: var_width, + height: var_height, + }; + } + 2 => { + let mut var_monitorId = ::sse_decode(deserializer); + let mut var_width = ::sse_decode(deserializer); + let mut var_height = ::sse_decode(deserializer); + let mut var_refreshRate = ::sse_decode(deserializer); + return crate::api::driver_client::AddModeError::RefreshRateExists { + monitor_id: var_monitorId, + width: var_width, + height: var_height, + refresh_rate: var_refreshRate, + }; + } + _ => { + unimplemented!(""); + } + } + } +} + impl SseDecode for bool { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -688,6 +1662,44 @@ impl SseDecode for crate::api::client::ConnectionError { } } +impl SseDecode for crate::api::driver_client::DuplicateError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut tag_ = ::sse_decode(deserializer); + match tag_ { + 0 => { + let mut var_id = ::sse_decode(deserializer); + return crate::api::driver_client::DuplicateError::Monitor { id: var_id }; + } + 1 => { + let mut var_monitorId = ::sse_decode(deserializer); + let mut var_width = ::sse_decode(deserializer); + let mut var_height = ::sse_decode(deserializer); + return crate::api::driver_client::DuplicateError::Mode { + monitor_id: var_monitorId, + width: var_width, + height: var_height, + }; + } + 2 => { + let mut var_monitorId = ::sse_decode(deserializer); + let mut var_width = ::sse_decode(deserializer); + let mut var_height = ::sse_decode(deserializer); + let mut var_refreshRate = ::sse_decode(deserializer); + return crate::api::driver_client::DuplicateError::RefreshRate { + monitor_id: var_monitorId, + width: var_width, + height: var_height, + refresh_rate: var_refreshRate, + }; + } + _ => { + unimplemented!(""); + } + } + } +} + impl SseDecode for i64 { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -695,6 +1707,26 @@ impl SseDecode for i64 { } } +impl SseDecode for crate::api::driver_client::InitError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut tag_ = ::sse_decode(deserializer); + match tag_ { + 0 => { + let mut var_inner = ::sse_decode(deserializer); + return crate::api::driver_client::InitError::Connect { inner: var_inner }; + } + 1 => { + let mut var_inner = ::sse_decode(deserializer); + return crate::api::driver_client::InitError::RequestState { inner: var_inner }; + } + _ => { + unimplemented!(""); + } + } + } +} + impl SseDecode for Vec { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -773,17 +1805,77 @@ impl SseDecode for crate::api::Monitor { } } -impl SseDecode for Option { +impl SseDecode for crate::api::driver_client::MonitorNotFoundError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_id = ::sse_decode(deserializer); + return crate::api::driver_client::MonitorNotFoundError { id: var_id }; + } +} + +impl SseDecode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + if (::sse_decode(deserializer)) { + return Some(::sse_decode(deserializer)); + } else { + return None; + } + } +} + +impl SseDecode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + if (::sse_decode(deserializer)) { + return Some(::sse_decode(deserializer)); + } else { + return None; + } + } +} + +impl SseDecode for Option { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { if (::sse_decode(deserializer)) { - return Some(::sse_decode(deserializer)); + return Some(::sse_decode(deserializer)); } else { return None; } } } +impl SseDecode for crate::api::client::PersistError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut tag_ = ::sse_decode(deserializer); + match tag_ { + 0 => { + let mut var_message = ::sse_decode(deserializer); + return crate::api::client::PersistError::Open { + message: var_message, + }; + } + 1 => { + let mut var_message = ::sse_decode(deserializer); + return crate::api::client::PersistError::Set { + message: var_message, + }; + } + 2 => { + let mut var_message = ::sse_decode(deserializer); + return crate::api::client::PersistError::Serialize { + message: var_message, + }; + } + _ => { + unimplemented!(""); + } + } + } +} + impl SseDecode for crate::api::client::ReceiveError { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -794,6 +1886,15 @@ impl SseDecode for crate::api::client::ReceiveError { } } +impl SseDecode for (u32, u32) { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut var_field0 = ::sse_decode(deserializer); + let mut var_field1 = ::sse_decode(deserializer); + return (var_field0, var_field1); + } +} + impl SseDecode for crate::api::client::RequestError { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -886,14 +1987,46 @@ fn pde_ffi_dispatcher_primary_impl( match func_id { 1 => wire__crate__api__client__Client_connect_impl(port, ptr, rust_vec_len, data_len), 2 => wire__crate__api__client__Client_notify_impl(port, ptr, rust_vec_len, data_len), - 3 => { + 3 => wire__crate__api__client__Client_persist_impl(port, ptr, rust_vec_len, data_len), + 4 => { wire__crate__api__client__Client_receive_events_impl(port, ptr, rust_vec_len, data_len) } - 4 => wire__crate__api__client__Client_remove_impl(port, ptr, rust_vec_len, data_len), - 5 => wire__crate__api__client__Client_remove_all_impl(port, ptr, rust_vec_len, data_len), - 6 => wire__crate__api__client__Client_request_state_impl(port, ptr, rust_vec_len, data_len), - 7 => wire__crate__api__mock__MockServer_create_impl(port, ptr, rust_vec_len, data_len), - 9 => wire__crate__api__mock__MockServer_pump_impl(port, ptr, rust_vec_len, data_len), + 5 => wire__crate__api__client__Client_remove_impl(port, ptr, rust_vec_len, data_len), + 6 => wire__crate__api__client__Client_remove_all_impl(port, ptr, rust_vec_len, data_len), + 7 => wire__crate__api__client__Client_request_state_impl(port, ptr, rust_vec_len, data_len), + 10 => wire__crate__api__driver_client__DriverClient_connect_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 13 => wire__crate__api__driver_client__DriverClient_notify_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 14 => wire__crate__api__driver_client__DriverClient_persist_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 15 => wire__crate__api__driver_client__DriverClient_receive_events_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 16 => wire__crate__api__driver_client__DriverClient_refresh_state_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 24 => wire__crate__api__mock__MockServer_create_impl(port, ptr, rust_vec_len, data_len), + 26 => wire__crate__api__mock__MockServer_pump_impl(port, ptr, rust_vec_len, data_len), + 27 => wire__crate__api__mock__MockServer_set_state_impl(port, ptr, rust_vec_len, data_len), _ => unreachable!(), } } @@ -906,8 +2039,49 @@ fn pde_ffi_dispatcher_sync_impl( ) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { // Codec=Pde (Serialization + dispatch), see doc to use other codecs match func_id { - 8 => wire__crate__api__mock__MockServer_pipe_name_impl(ptr, rust_vec_len, data_len), - 10 => wire__crate__api__mock__MockServer_state_impl(ptr, rust_vec_len, data_len), + 8 => wire__crate__api__driver_client__DriverClient_add_impl(ptr, rust_vec_len, data_len), + 9 => { + wire__crate__api__driver_client__DriverClient_add_mode_impl(ptr, rust_vec_len, data_len) + } + 11 => wire__crate__api__driver_client__DriverClient_find_monitor_impl( + ptr, + rust_vec_len, + data_len, + ), + 12 => { + wire__crate__api__driver_client__DriverClient_new_id_impl(ptr, rust_vec_len, data_len) + } + 17 => { + wire__crate__api__driver_client__DriverClient_remove_impl(ptr, rust_vec_len, data_len) + } + 18 => wire__crate__api__driver_client__DriverClient_remove_all_impl( + ptr, + rust_vec_len, + data_len, + ), + 19 => wire__crate__api__driver_client__DriverClient_remove_mode_impl( + ptr, + rust_vec_len, + data_len, + ), + 20 => wire__crate__api__driver_client__DriverClient_replace_monitor_impl( + ptr, + rust_vec_len, + data_len, + ), + 21 => wire__crate__api__driver_client__DriverClient_set_enabled_impl( + ptr, + rust_vec_len, + data_len, + ), + 22 => wire__crate__api__driver_client__DriverClient_set_monitors_impl( + ptr, + rust_vec_len, + data_len, + ), + 23 => wire__crate__api__driver_client__DriverClient_state_impl(ptr, rust_vec_len, data_len), + 25 => wire__crate__api__mock__MockServer_pipe_name_impl(ptr, rust_vec_len, data_len), + 28 => wire__crate__api__mock__MockServer_state_impl(ptr, rust_vec_len, data_len), _ => unreachable!(), } } @@ -929,6 +2103,21 @@ impl flutter_rust_bridge::IntoIntoDart> for Client { } } +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for FrbWrapper { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + flutter_rust_bridge::for_generated::rust_auto_opaque_encode::<_, MoiArc<_>>(self.0) + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive for FrbWrapper {} + +impl flutter_rust_bridge::IntoIntoDart> for DriverClient { + fn into_into_dart(self) -> FrbWrapper { + self.into() + } +} + // Codec=Dco (DartCObject based), see doc to use other codecs impl flutter_rust_bridge::IntoDart for FrbWrapper { fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { @@ -944,6 +2133,54 @@ impl flutter_rust_bridge::IntoIntoDart> for MockServer { } } +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::driver_client::AddModeError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::api::driver_client::AddModeError::MonitorNotFound { id } => { + [0.into_dart(), id.into_into_dart().into_dart()].into_dart() + } + crate::api::driver_client::AddModeError::ModeExists { + monitor_id, + width, + height, + } => [ + 1.into_dart(), + monitor_id.into_into_dart().into_dart(), + width.into_into_dart().into_dart(), + height.into_into_dart().into_dart(), + ] + .into_dart(), + crate::api::driver_client::AddModeError::RefreshRateExists { + monitor_id, + width, + height, + refresh_rate, + } => [ + 2.into_dart(), + monitor_id.into_into_dart().into_dart(), + width.into_into_dart().into_dart(), + height.into_into_dart().into_dart(), + refresh_rate.into_into_dart().into_dart(), + ] + .into_dart(), + _ => { + unimplemented!(""); + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::driver_client::AddModeError +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::driver_client::AddModeError +{ + fn into_into_dart(self) -> crate::api::driver_client::AddModeError { + self + } +} // Codec=Dco (DartCObject based), see doc to use other codecs impl flutter_rust_bridge::IntoDart for crate::api::client::ConnectionError { fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { @@ -969,6 +2206,81 @@ impl flutter_rust_bridge::IntoIntoDart } } // Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::driver_client::DuplicateError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::api::driver_client::DuplicateError::Monitor { id } => { + [0.into_dart(), id.into_into_dart().into_dart()].into_dart() + } + crate::api::driver_client::DuplicateError::Mode { + monitor_id, + width, + height, + } => [ + 1.into_dart(), + monitor_id.into_into_dart().into_dart(), + width.into_into_dart().into_dart(), + height.into_into_dart().into_dart(), + ] + .into_dart(), + crate::api::driver_client::DuplicateError::RefreshRate { + monitor_id, + width, + height, + refresh_rate, + } => [ + 2.into_dart(), + monitor_id.into_into_dart().into_dart(), + width.into_into_dart().into_dart(), + height.into_into_dart().into_dart(), + refresh_rate.into_into_dart().into_dart(), + ] + .into_dart(), + _ => { + unimplemented!(""); + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::driver_client::DuplicateError +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::driver_client::DuplicateError +{ + fn into_into_dart(self) -> crate::api::driver_client::DuplicateError { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::driver_client::InitError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::api::driver_client::InitError::Connect { inner } => { + [0.into_dart(), inner.into_into_dart().into_dart()].into_dart() + } + crate::api::driver_client::InitError::RequestState { inner } => { + [1.into_dart(), inner.into_into_dart().into_dart()].into_dart() + } + _ => { + unimplemented!(""); + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::driver_client::InitError +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::driver_client::InitError +{ + fn into_into_dart(self) -> crate::api::driver_client::InitError { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs impl flutter_rust_bridge::IntoDart for FrbWrapper { fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { [ @@ -1007,6 +2319,53 @@ impl flutter_rust_bridge::IntoIntoDart> for crat } } // Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::driver_client::MonitorNotFoundError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [self.id.into_into_dart().into_dart()].into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::driver_client::MonitorNotFoundError +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::driver_client::MonitorNotFoundError +{ + fn into_into_dart(self) -> crate::api::driver_client::MonitorNotFoundError { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::client::PersistError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::api::client::PersistError::Open { message } => { + [0.into_dart(), message.into_into_dart().into_dart()].into_dart() + } + crate::api::client::PersistError::Set { message } => { + [1.into_dart(), message.into_into_dart().into_dart()].into_dart() + } + crate::api::client::PersistError::Serialize { message } => { + [2.into_dart(), message.into_into_dart().into_dart()].into_dart() + } + _ => { + unimplemented!(""); + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::client::PersistError +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::client::PersistError +{ + fn into_into_dart(self) -> crate::api::client::PersistError { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs impl flutter_rust_bridge::IntoDart for crate::api::client::ReceiveError { fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { [self.message.into_into_dart().into_dart()].into_dart() @@ -1089,6 +2448,13 @@ impl SseEncode for Client { } } +impl SseEncode for DriverClient { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + >>::sse_encode(flutter_rust_bridge::for_generated::rust_auto_opaque_encode::<_, MoiArc<_>>(self), serializer); + } +} + impl SseEncode for MockServer { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -1116,6 +2482,17 @@ impl SseEncode for RustOpaqueMoi> +{ + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + let (ptr, size) = self.sse_encode_raw(); + ::sse_encode(ptr, serializer); + ::sse_encode(size, serializer); + } +} + impl SseEncode for RustOpaqueMoi> { @@ -1143,6 +2520,43 @@ impl SseEncode for String { } } +impl SseEncode for crate::api::driver_client::AddModeError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + match self { + crate::api::driver_client::AddModeError::MonitorNotFound { id } => { + ::sse_encode(0, serializer); + ::sse_encode(id, serializer); + } + crate::api::driver_client::AddModeError::ModeExists { + monitor_id, + width, + height, + } => { + ::sse_encode(1, serializer); + ::sse_encode(monitor_id, serializer); + ::sse_encode(width, serializer); + ::sse_encode(height, serializer); + } + crate::api::driver_client::AddModeError::RefreshRateExists { + monitor_id, + width, + height, + refresh_rate, + } => { + ::sse_encode(2, serializer); + ::sse_encode(monitor_id, serializer); + ::sse_encode(width, serializer); + ::sse_encode(height, serializer); + ::sse_encode(refresh_rate, serializer); + } + _ => { + unimplemented!(""); + } + } + } +} + impl SseEncode for bool { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -1165,6 +2579,43 @@ impl SseEncode for crate::api::client::ConnectionError { } } +impl SseEncode for crate::api::driver_client::DuplicateError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + match self { + crate::api::driver_client::DuplicateError::Monitor { id } => { + ::sse_encode(0, serializer); + ::sse_encode(id, serializer); + } + crate::api::driver_client::DuplicateError::Mode { + monitor_id, + width, + height, + } => { + ::sse_encode(1, serializer); + ::sse_encode(monitor_id, serializer); + ::sse_encode(width, serializer); + ::sse_encode(height, serializer); + } + crate::api::driver_client::DuplicateError::RefreshRate { + monitor_id, + width, + height, + refresh_rate, + } => { + ::sse_encode(2, serializer); + ::sse_encode(monitor_id, serializer); + ::sse_encode(width, serializer); + ::sse_encode(height, serializer); + ::sse_encode(refresh_rate, serializer); + } + _ => { + unimplemented!(""); + } + } + } +} + impl SseEncode for i64 { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -1172,6 +2623,25 @@ impl SseEncode for i64 { } } +impl SseEncode for crate::api::driver_client::InitError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + match self { + crate::api::driver_client::InitError::Connect { inner } => { + ::sse_encode(0, serializer); + ::sse_encode(inner, serializer); + } + crate::api::driver_client::InitError::RequestState { inner } => { + ::sse_encode(1, serializer); + ::sse_encode(inner, serializer); + } + _ => { + unimplemented!(""); + } + } + } +} + impl SseEncode for Vec { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -1231,6 +2701,13 @@ impl SseEncode for crate::api::Monitor { } } +impl SseEncode for crate::api::driver_client::MonitorNotFoundError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.id, serializer); + } +} + impl SseEncode for Option { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -1241,6 +2718,49 @@ impl SseEncode for Option { } } +impl SseEncode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.is_some(), serializer); + if let Some(value) = self { + ::sse_encode(value, serializer); + } + } +} + +impl SseEncode for Option { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.is_some(), serializer); + if let Some(value) = self { + ::sse_encode(value, serializer); + } + } +} + +impl SseEncode for crate::api::client::PersistError { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + match self { + crate::api::client::PersistError::Open { message } => { + ::sse_encode(0, serializer); + ::sse_encode(message, serializer); + } + crate::api::client::PersistError::Set { message } => { + ::sse_encode(1, serializer); + ::sse_encode(message, serializer); + } + crate::api::client::PersistError::Serialize { message } => { + ::sse_encode(2, serializer); + ::sse_encode(message, serializer); + } + _ => { + unimplemented!(""); + } + } + } +} + impl SseEncode for crate::api::client::ReceiveError { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -1248,6 +2768,14 @@ impl SseEncode for crate::api::client::ReceiveError { } } +impl SseEncode for (u32, u32) { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(self.0, serializer); + ::sse_encode(self.1, serializer); + } +} + impl SseEncode for crate::api::client::RequestError { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -1331,6 +2859,7 @@ mod io { use super::*; use crate::api::client::*; + use crate::api::driver_client::*; use crate::api::mock::*; use flutter_rust_bridge::for_generated::byteorder::{ NativeEndian, ReadBytesExt, WriteBytesExt, @@ -1356,6 +2885,20 @@ mod io { MoiArc::>::decrement_strong_count(ptr as _); } + #[no_mangle] + pub extern "C" fn frbgen_vdd_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + ptr: *const std::ffi::c_void, + ) { + MoiArc::>::increment_strong_count(ptr as _); + } + + #[no_mangle] + pub extern "C" fn frbgen_vdd_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDriverClient( + ptr: *const std::ffi::c_void, + ) { + MoiArc::>::decrement_strong_count(ptr as _); + } + #[no_mangle] pub extern "C" fn frbgen_vdd_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerMockServer( ptr: *const std::ffi::c_void, diff --git a/rust/bindings/dart/test/vdd_test.dart b/rust/bindings/dart/test/vdd_test.dart index fe64815..ee302b5 100644 --- a/rust/bindings/dart/test/vdd_test.dart +++ b/rust/bindings/dart/test/vdd_test.dart @@ -135,4 +135,292 @@ void main() { ]); }); }); + + group('DriverClient', () { + Future<(MockServer, DriverClient)> createDeps(String pipeName) async { + final server = await MockServer.create(pipeName: pipeName); + + final client = DriverClient.connect(pipeName: pipeName); + + await server.pump(); + + return (server, await client); + } + + test('DriverClient.connect throws correct error', () async { + try { + await DriverClient.connect(pipeName: "nonexisting"); + fail("Expected ConnectionError"); + } on InitError_Connect catch (e) { + expect(e.inner, isA()); + } catch (e) { + fail("Expected InitError_Connect, got $e"); + } + }); + + test('DiverClient can connect', () async { + final (_, client) = await createDeps("driver_client_can_connect"); + + expect(client.state, []); + }); + + test('DriverClient can notify', () async { + final (server, client) = await createDeps("driver_client_can_notify"); + + client.add(monitor: monitor); + + expect(client.state, [monitor]); + expect(server.state, []); + + await client.notify(); + + await server.pump(); + + expect(client.state, [monitor]); + expect(server.state, [monitor]); + }); + + test('DriverClient can refresh its state', () async { + final (server, client) = await createDeps("driver_client_can_refresh"); + + expect(client.state, []); + + await server.setState(state: [monitor]); + expect(server.state, [monitor]); + + expect(client.state, []); + + expect(await client.refreshState(), [monitor]); + + expect(client.state, [monitor]); + }); + + test('Adding existing monitor throws correct error', () async { + final (_, client) = await createDeps("driver_client_add_existing"); + + client.add(monitor: monitor); + + try { + client.add(monitor: monitor); + fail("Expected DuplicateError_Monitor"); + } on DuplicateError_Monitor catch (e) { + expect(e.id, monitor.id); + } catch (e) { + fail("Expected DuplicateError_Monitor, got $e"); + } + }); + + test('Setting duplicate monitors throws correct error', () async { + final (_, client) = + await createDeps("driver_client_set_duplicate_monitors"); + + try { + client.setMonitors(monitors: [monitor, monitor]); + fail("Expected DuplicateError_Monitor"); + } on DuplicateError_Monitor catch (e) { + expect(e.id, monitor.id); + } catch (e) { + fail("Expected DuplicateError_Monitor, got $e"); + } + + try { + client.setMonitors(monitors: [ + monitor.copyWith(modes: [ + Mode( + width: 1920, + height: 1080, + refreshRates: Uint32List.fromList([60]), + ), + Mode( + width: 1920, + height: 1080, + refreshRates: Uint32List.fromList([120]), + ), + ]) + ]); + fail("Expected DuplicateError_Mode"); + } on DuplicateError_Mode catch (e) { + expect(e.monitorId, monitor.id); + expect(e.width, 1920); + expect(e.height, 1080); + } catch (e) { + fail("Expected DuplicateError_Mode, got $e"); + } + + try { + client.setMonitors(monitors: [ + monitor.copyWith(modes: [ + Mode( + width: 1920, + height: 1080, + refreshRates: Uint32List.fromList([60, 60]), + ), + ]) + ]); + fail("Expected DuplicateError_RefreshRate"); + } on DuplicateError_RefreshRate catch (e) { + expect(e.monitorId, monitor.id); + expect(e.width, 1920); + expect(e.height, 1080); + expect(e.refreshRate, 60); + } catch (e) { + fail("Expected DuplicateError_RefreshRate, got $e"); + } + }); + + test('Adding duplicate mode throws correct error', () async { + final (_, client) = await createDeps("driver_client_add_duplicate_mode"); + + try { + client.addMode( + id: monitor.id, + mode: monitor.modes.first, + ); + fail("Expected AddModeError_MonitorNotFound"); + } on AddModeError_MonitorNotFound catch (e) { + expect(e.id, monitor.id); + } catch (e) { + fail("Expected AddModeError_MonitorNotFound, got $e"); + } + + client.add(monitor: monitor); + + try { + client.addMode( + id: monitor.id, + mode: monitor.modes.first, + ); + fail("Expected AddModeError_ModeExists"); + } on AddModeError_ModeExists catch (e) { + expect(e.monitorId, monitor.id); + expect(e.width, 1920); + expect(e.height, 1080); + } catch (e) { + fail("Expected AddModeError_ModeExists, got $e"); + } + + try { + client.addMode( + id: monitor.id, + mode: monitor.modes.first + .copyWith(refreshRates: Uint32List.fromList([60, 60])), + ); + fail("Expected AddModeError_RefreshRateExists"); + } on AddModeError_RefreshRateExists catch (e) { + expect(e.monitorId, monitor.id); + expect(e.width, 1920); + expect(e.height, 1080); + expect(e.refreshRate, 60); + } catch (e) { + fail("Expected AddModeError_RefreshRateExists, got $e"); + } + }); + + test('DriverClient can modify its state', () async { + final (server, client) = await createDeps("driver_client_can_modify"); + + expect(client.state, []); + + client.add(monitor: monitor); + + expect(client.state, [monitor]); + + final newId = client.newId(); + expect(newId, 1); + + client.add(monitor: monitor.copyWith(id: newId!)); + + expect(client.state, [monitor, monitor.copyWith(id: newId)]); + + client.replaceMonitor( + monitor: monitor.copyWith(id: newId, enabled: false)); + + expect( + client.state, [monitor, monitor.copyWith(id: newId, enabled: false)]); + + client.setEnabled(ids: [newId], enabled: true); + + expect( + client.state, [monitor, monitor.copyWith(id: newId, enabled: true)]); + + client.setMonitors(monitors: [ + monitor, + monitor.copyWith(id: 2), + monitor.copyWith(id: 3), + monitor.copyWith(id: 4), + monitor.copyWith(id: 5), + ]); + + expect(client.state, [ + monitor, + monitor.copyWith(id: 2), + monitor.copyWith(id: 3), + monitor.copyWith(id: 4), + monitor.copyWith(id: 5), + ]); + + client.addMode( + id: 3, + mode: Mode( + width: 2560, + height: 1440, + refreshRates: Uint32List.fromList([60, 120]), + ), + ); + + expect( + client.findMonitor(id: 3), + monitor.copyWith(id: 3, modes: [ + Mode( + width: 1920, + height: 1080, + refreshRates: Uint32List.fromList([60]), + ), + Mode( + width: 2560, + height: 1440, + refreshRates: Uint32List.fromList([60, 120]), + ), + ]), + ); + + client.removeMode(id: 3, resolution: (1920, 1080)); + + expect( + client.findMonitor(id: 3), + monitor.copyWith(id: 3, modes: [ + Mode( + width: 2560, + height: 1440, + refreshRates: Uint32List.fromList([60, 120]), + ), + ]), + ); + + expect(client.newId(preferredId: 3), null); + expect(client.newId(preferredId: 0), null); + expect(client.newId(preferredId: 1), 1); + expect(client.newId(), 1); + + expect(server.state, []); + + await client.notify(); + + await server.pump(); + + expect(server.state, client.state); + + client.remove(ids: [2, 3]); + + expect(client.state, [ + monitor, + monitor.copyWith(id: 4), + monitor.copyWith(id: 5), + ]); + + client.removeAll(); + + expect(client.state, []); + }); + }); } diff --git a/rust/driver-ipc/src/driver_client.rs b/rust/driver-ipc/src/driver_client.rs index 04bb556..09087fd 100644 --- a/rust/driver-ipc/src/driver_client.rs +++ b/rust/driver-ipc/src/driver_client.rs @@ -274,7 +274,7 @@ impl DriverClient { .collect::>(); if let Some(id) = preferred_id { - if !existing_ids.contains(&id) { + if existing_ids.contains(&id) { return None; } @@ -433,20 +433,7 @@ impl DriverClient { .iter() .any(|_mode| _mode.height == mode.height && _mode.width == mode.width) { - return Err(error::AddModeError::DupMode(mode.width, mode.height, id)); - } - - let iter = mode.refresh_rates.iter().copied(); - - for (i, &rr) in mode.refresh_rates.iter().enumerate() { - if iter.clone().skip(i).any(|_rr| _rr == rr) { - return Err(error::AddModeError::DupRefreshRate( - rr, - mode.width, - mode.height, - id, - )); - } + return Err(error::AddModeError::DupMode(id, mode.width, mode.height)); } mon.modes.push(mode); @@ -616,7 +603,7 @@ pub mod error { pub enum DuplicateError { #[error("Duplicate monitor with ID {0}")] Monitor(Id), - #[error("Duplicate mode {1}x{2} on monitor {0}")] + #[error("Duplicate mode {0}x{1} on monitor {2}")] Mode(u32, u32, Id), #[error("Duplicate refresh rate {0} on mode {1}x{2} on monitor {3}")] RefreshRate(u32, u32, u32, Id), diff --git a/rust/driver-ipc/src/mock.rs b/rust/driver-ipc/src/mock.rs index f8e7fd3..b7bdc66 100644 --- a/rust/driver-ipc/src/mock.rs +++ b/rust/driver-ipc/src/mock.rs @@ -1,4 +1,4 @@ -use std::{io, sync::Arc}; +use std::{io, mem, sync::Arc}; use tokio::{ io::{AsyncReadExt, AsyncWriteExt}, @@ -87,6 +87,13 @@ impl MockServer { &self.state } + pub async fn set_state(&mut self, state: Vec) { + let state = mem::replace(&mut self.state, state); + if state != self.state { + self.send_changed_event().await; + } + } + pub fn check_next(&mut self, cb: impl FnOnce(ServerCommand) + Send + 'static) { let mut rx = self.command_tx.subscribe(); @@ -139,16 +146,26 @@ impl MockServer { }; if changed { - let event = EventCommand::Changed(self.state.clone()); - let mut event = serde_json::to_vec(&event).unwrap(); - event.push(EOF); - - server - .write_all(&event) - .await - .expect("Failed to write event"); + self.send_changed_event().await; } } + + async fn send_changed_event(&self) { + let server = unsafe { + (self.server.as_ref() as *const _ as *mut named_pipe::NamedPipeServer) + .as_mut() + .unwrap() + }; + + let event = EventCommand::Changed(self.state.clone()); + let mut event = serde_json::to_vec(&event).unwrap(); + event.push(EOF); + + server + .write_all(&event) + .await + .expect("Failed to write event"); + } } impl Drop for MockServer {