From aa2b40814484ce798c8ebeb03162390c7799fb05 Mon Sep 17 00:00:00 2001 From: kodjomoustapha <107993382+kodjodevf@users.noreply.github.com> Date: Wed, 11 Sep 2024 12:04:01 +0100 Subject: [PATCH] + - adding modify codes from the rhttp package --- flutter_rust_bridge.yaml | 3 +- lib/main.dart | 2 - .../download/providers/download_provider.dart | 13 +- .../providers/download_provider.g.dart | 2 +- .../downloader/downloader_http_client.dart | 7 +- lib/services/http/m_client.dart | 14 +- lib/services/http/rhttp/LICENSE | 21 + lib/services/http/rhttp/rhttp.dart | 29 + .../rhttp/src/client/compatible_client.dart | 118 + .../http/rhttp/src/client/rhttp_client.dart | 102 + .../http/rhttp/src/model/cancel_token.dart | 48 + .../http/rhttp/src/model/exception.dart | 151 ++ lib/services/http/rhttp/src/model/header.dart | 88 + .../http/rhttp/src/model/request.dart | 62 + .../http/rhttp/src/model/response.dart | 90 + .../http/rhttp/src/model/settings.dart | 214 ++ lib/services/http/rhttp/src/request.dart | 64 + lib/services/m3u8/m3u8_downloader.dart | 45 +- lib/src/rust/api/rhttp/client.dart | 138 ++ lib/src/rust/api/rhttp/client.freezed.dart | 344 +++ lib/src/rust/api/rhttp/error.dart | 35 + lib/src/rust/api/rhttp/error.freezed.dart | 1439 ++++++++++++ lib/src/rust/api/rhttp/http.dart | 128 ++ lib/src/rust/api/rhttp/http.freezed.dart | 869 ++++++++ lib/src/rust/frb_generated.dart | 1975 ++++++++++++++++- lib/src/rust/frb_generated.io.dart | 679 +++++- lib/src/rust/frb_generated.web.dart | 657 +++++- lib/src/rust/lib.dart | 10 + linux/flutter/generated_plugins.cmake | 1 - pubspec.lock | 55 +- pubspec.yaml | 8 +- rust/Cargo.lock | 973 +++++++- rust/Cargo.toml | 7 +- rust/src/api/mod.rs | 1 + rust/src/api/rhttp/LICENSE | 21 + rust/src/api/rhttp/client.rs | 165 ++ rust/src/api/rhttp/error.rs | 33 + rust/src/api/rhttp/http.rs | 335 +++ rust/src/api/rhttp/mod.rs | 3 + rust/src/frb_generated.rs | 1802 ++++++++++++++- windows/flutter/generated_plugins.cmake | 1 - 41 files changed, 10618 insertions(+), 134 deletions(-) create mode 100644 lib/services/http/rhttp/LICENSE create mode 100644 lib/services/http/rhttp/rhttp.dart create mode 100644 lib/services/http/rhttp/src/client/compatible_client.dart create mode 100644 lib/services/http/rhttp/src/client/rhttp_client.dart create mode 100644 lib/services/http/rhttp/src/model/cancel_token.dart create mode 100644 lib/services/http/rhttp/src/model/exception.dart create mode 100644 lib/services/http/rhttp/src/model/header.dart create mode 100644 lib/services/http/rhttp/src/model/request.dart create mode 100644 lib/services/http/rhttp/src/model/response.dart create mode 100644 lib/services/http/rhttp/src/model/settings.dart create mode 100644 lib/services/http/rhttp/src/request.dart create mode 100644 lib/src/rust/api/rhttp/client.dart create mode 100644 lib/src/rust/api/rhttp/client.freezed.dart create mode 100644 lib/src/rust/api/rhttp/error.dart create mode 100644 lib/src/rust/api/rhttp/error.freezed.dart create mode 100644 lib/src/rust/api/rhttp/http.dart create mode 100644 lib/src/rust/api/rhttp/http.freezed.dart create mode 100644 lib/src/rust/lib.dart create mode 100644 rust/src/api/rhttp/LICENSE create mode 100644 rust/src/api/rhttp/client.rs create mode 100644 rust/src/api/rhttp/error.rs create mode 100644 rust/src/api/rhttp/http.rs create mode 100644 rust/src/api/rhttp/mod.rs diff --git a/flutter_rust_bridge.yaml b/flutter_rust_bridge.yaml index c888c944..3fafcf5c 100644 --- a/flutter_rust_bridge.yaml +++ b/flutter_rust_bridge.yaml @@ -1,3 +1,4 @@ rust_root: rust/ rust_input: crate::api -dart_output: lib/src/rust \ No newline at end of file +dart_output: lib/src/rust +enable_lifetime: true \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 49effa0b..baad466e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -20,7 +20,6 @@ import 'package:mangayomi/modules/more/settings/appearance/providers/theme_mode_ import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:mangayomi/src/rust/frb_generated.dart'; import 'package:media_kit/media_kit.dart'; -import 'package:rhttp/rhttp.dart'; import 'package:window_manager/window_manager.dart'; late Isar isar; @@ -34,7 +33,6 @@ void main(List args) async { } MediaKit.ensureInitialized(); await RustLib.init(); - await Rhttp.init(); if (!(Platform.isAndroid || Platform.isIOS)) { await windowManager.ensureInitialized(); } diff --git a/lib/modules/manga/download/providers/download_provider.dart b/lib/modules/manga/download/providers/download_provider.dart index b8f42e5e..d38022c6 100644 --- a/lib/modules/manga/download/providers/download_provider.dart +++ b/lib/modules/manga/download/providers/download_provider.dart @@ -51,6 +51,7 @@ Future> downloadChapter( bool hasM3U8File = false; bool nonM3U8File = false; M3u8Downloader? m3u8Downloader; + String? tsKey; void savePageUrls() { final settings = isar.settings.getSync(227)!; List? chapterPageUrls = []; @@ -96,13 +97,9 @@ Future> downloadChapter( final nonM3u8Urls = value.$1 .where((element) => element.originalUrl.isMediaVideo()) .toList(); - nonM3U8File = nonM3u8Urls.isNotEmpty && !Platform.isIOS; + nonM3U8File = nonM3u8Urls.isNotEmpty; hasM3U8File = nonM3U8File ? false : m3u8Urls.isNotEmpty; - final videosUrls = nonM3U8File - ? nonM3u8Urls - : (hasM3U8File || Platform.isIOS) - ? m3u8Urls - : nonM3u8Urls; + final videosUrls = nonM3U8File ? nonM3u8Urls : m3u8Urls; if (videosUrls.isNotEmpty) { List tsList = []; if (hasM3U8File) { @@ -110,7 +107,7 @@ Future> downloadChapter( m3u8Url: videosUrls.first.url, downloadDir: "${path!.path}$chapterName", headers: videosUrls.first.headers ?? {}); - tsList = await m3u8Downloader!.getTsList(); + (tsList, tsKey) = await m3u8Downloader!.getTsList(); } pageUrls = hasM3U8File ? [...tsList.map((e) => PageUrl(e.url))] @@ -302,6 +299,7 @@ Future> downloadChapter( isar.downloads.putSync(download..chapter.value = chapter); }); } else { + savePageUrls(); await FileDownloader().downloadBatch( tasks, batchProgressCallback: (succeeded, failed) async { @@ -309,7 +307,6 @@ Future> downloadChapter( if (succeeded == tasks.length) { if (hasM3U8File) { } else { - savePageUrls(); if (ref.watch(saveAsCBZArchiveStateProvider)) { await ref.watch(convertToCBZProvider( path!.path, diff --git a/lib/modules/manga/download/providers/download_provider.g.dart b/lib/modules/manga/download/providers/download_provider.g.dart index 17848c5c..fc40f8cb 100644 --- a/lib/modules/manga/download/providers/download_provider.g.dart +++ b/lib/modules/manga/download/providers/download_provider.g.dart @@ -6,7 +6,7 @@ part of 'download_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$downloadChapterHash() => r'ceb6f5d311f5da585b0272a0af598532ab511adc'; +String _$downloadChapterHash() => r'c5e5cf07f28a558d6dc827a1e08933125ef52261'; /// Copied from Dart SDK class _SystemHash { diff --git a/lib/services/background_downloader/src/downloader/downloader_http_client.dart b/lib/services/background_downloader/src/downloader/downloader_http_client.dart index f40ec246..bf64470a 100644 --- a/lib/services/background_downloader/src/downloader/downloader_http_client.dart +++ b/lib/services/background_downloader/src/downloader/downloader_http_client.dart @@ -9,9 +9,10 @@ import 'package:collection/collection.dart'; import 'package:flutter/services.dart'; import 'package:logging/logging.dart'; import 'package:mangayomi/services/http/m_client.dart'; +import 'package:mangayomi/src/rust/frb_generated.dart'; import 'package:path/path.dart' as path; import 'package:path_provider/path_provider.dart'; -import 'package:rhttp/rhttp.dart'; +import 'package:mangayomi/services/http/rhttp/rhttp.dart'; import '../base_downloader.dart'; import '../chunk.dart'; import '../exceptions.dart'; @@ -571,9 +572,7 @@ final class DownloaderHttpClient extends BaseDownloader { /// Recreates the [httpClient] used for Requests and isolate downloads/uploads static _recreateClient() async { - if (!Platform.isIOS) { - await Rhttp.init(); - } + await RustLib.init(); httpClient = MClient.httpClient( settings: const ClientSettings( throwOnStatusCode: false, diff --git a/lib/services/http/m_client.dart b/lib/services/http/m_client.dart index d676bec3..126ed67a 100644 --- a/lib/services/http/m_client.dart +++ b/lib/services/http/m_client.dart @@ -1,4 +1,3 @@ -import 'package:cupertino_http/cupertino_http.dart'; import 'package:http_interceptor/http_interceptor.dart'; import 'package:mangayomi/eval/dart/model/m_bridge.dart'; import 'dart:async'; @@ -10,18 +9,13 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart' import 'package:mangayomi/models/settings.dart'; import 'package:http/io_client.dart'; import 'package:mangayomi/utils/log/log.dart'; -import 'package:rhttp/rhttp.dart' as rhttp; +import 'package:mangayomi/services/http/rhttp/rhttp.dart' as rhttp; class MClient { MClient(); static Client httpClient( {Map? reqcopyWith, rhttp.ClientSettings? settings}) { if (!(reqcopyWith?["useDartHttpClient"] ?? false)) { - if (Platform.isIOS) { - final config = URLSessionConfiguration.ephemeralSessionConfiguration() - ..cache = URLCache.withCapacity(memoryCapacity: 5 * 1024 * 1024); - return CupertinoClient.fromSessionConfiguration(config); - } try { settings ??= rhttp.ClientSettings( throwOnStatusCode: false, @@ -44,9 +38,11 @@ class MClient { } static InterceptedClient init( - {MSource? source, Map? reqcopyWith}) { + {MSource? source, + Map? reqcopyWith, + rhttp.ClientSettings? settings}) { return InterceptedClient.build( - client: httpClient(reqcopyWith: reqcopyWith), + client: httpClient(settings: settings), interceptors: [MCookieManager(reqcopyWith), LoggerInterceptor()]); } diff --git a/lib/services/http/rhttp/LICENSE b/lib/services/http/rhttp/LICENSE new file mode 100644 index 00000000..aed1c37a --- /dev/null +++ b/lib/services/http/rhttp/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Tien Do Nam + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/lib/services/http/rhttp/rhttp.dart b/lib/services/http/rhttp/rhttp.dart new file mode 100644 index 00000000..8a95efee --- /dev/null +++ b/lib/services/http/rhttp/rhttp.dart @@ -0,0 +1,29 @@ +library rhttp; + +export 'src/client/compatible_client.dart' + show RhttpCompatibleClient, RhttpWrappedClientException; +export 'src/client/rhttp_client.dart' show RhttpClient; +export 'src/model/cancel_token.dart' show CancelToken; +export 'src/model/exception.dart' + show + RhttpException, + RhttpCancelException, + RhttpTimeoutException, + RhttpRedirectException, + RhttpStatusCodeException, + RhttpInvalidCertificateException, + RhttpConnectionException, + RhttpClientDisposedException, + RhttpInterceptorException, + RhttpUnknownException; +export 'src/model/header.dart'; +export 'src/model/request.dart' show BaseHttpRequest, HttpRequest; +export 'src/model/settings.dart' + show + ClientSettings, + ProxySettings, + RedirectSettings, + TlsSettings, + ClientCertificate; +export 'src/model/response.dart' + show HttpResponse, HttpBytesResponse, HttpStreamResponse, HttpVersion; diff --git a/lib/services/http/rhttp/src/client/compatible_client.dart b/lib/services/http/rhttp/src/client/compatible_client.dart new file mode 100644 index 00000000..da24841e --- /dev/null +++ b/lib/services/http/rhttp/src/client/compatible_client.dart @@ -0,0 +1,118 @@ +import 'package:http/http.dart'; +import 'package:mangayomi/services/http/rhttp/src/client/rhttp_client.dart'; +import 'package:mangayomi/services/http/rhttp/src/model/exception.dart'; +import 'package:mangayomi/services/http/rhttp/src/model/settings.dart'; +import 'package:mangayomi/src/rust/api/rhttp/http.dart' as rust; + +/// An HTTP client that is compatible with the `http` package. +/// This minimizes the changes needed to switch from `http` to `rhttp` +/// and also avoids vendor lock-in. +/// +/// This comes with some downsides, such as: +/// - inferior type safety due to the flaw that `body` is of type `Object?` +/// instead of a sane supertype. +/// - body of type [Map] is implicitly interpreted as `x-www-form-urlencoded` +/// that is only documented in StackOverflow (as of writing this). +/// - no support for cancellation +/// - no out-of-the-box support for multipart requests +class RhttpCompatibleClient with BaseClient { + /// The actual client that is used to make requests. + final RhttpClient client; + + RhttpCompatibleClient._(this.client); + + /// Use this method if your app is starting up to simplify the code + /// that might arise by using async/await. + /// + /// Note: + /// This method crashes when configured to use HTTP/3. + /// See: https://github.com/Tienisto/rhttp/issues/10 + factory RhttpCompatibleClient.createSync({ + ClientSettings? settings, + }) { + final client = RhttpClient.createSync( + settings: (settings ?? const ClientSettings()).digest(), + ); + return RhttpCompatibleClient._(client); + } + + @override + Future send(BaseRequest request) async { + try { + final response = await client.requestStream( + method: switch (request.method) { + 'GET' => rust.HttpMethod.get_, + 'POST' => rust.HttpMethod.post, + 'PUT' => rust.HttpMethod.put, + 'PATCH' => rust.HttpMethod.patch, + 'DELETE' => rust.HttpMethod.delete, + 'HEAD' => rust.HttpMethod.head, + 'OPTIONS' => rust.HttpMethod.options, + 'TRACE' => rust.HttpMethod.trace, + 'CONNECT' => rust.HttpMethod.connect, + _ => throw ArgumentError('Unsupported method: ${request.method}'), + }, + url: request.url.toString(), + headers: rust.HttpHeaders.map(request.headers), + body: await request.finalize().toBytes(), + ); + + final responseHeaderMap = response.headerMap; + + return StreamedResponse( + response.body, + response.statusCode, + contentLength: switch (responseHeaderMap['content-length']) { + String s => int.parse(s), + null => null, + }, + request: request, + headers: responseHeaderMap, + isRedirect: false, + persistentConnection: true, + reasonPhrase: null, + ); + } on RhttpException catch (e, st) { + Error.throwWithStackTrace( + RhttpWrappedClientException(e.toString(), request.url, e), + st, + ); + } catch (e, st) { + Error.throwWithStackTrace( + ClientException(e.toString(), request.url), + st, + ); + } + } + + @override + void close() { + client.dispose(cancelRunningRequests: true); + } +} + +/// Every exception must be a subclass of [ClientException] +/// as per contract of [BaseClient]. +class RhttpWrappedClientException extends ClientException { + /// The original exception that was thrown by rhttp. + final RhttpException rhttpException; + + RhttpWrappedClientException(super.message, super.uri, this.rhttpException); + + @override + String toString() => rhttpException.toString(); +} + +extension on ClientSettings { + /// Makes sure that the settings conform to the requirements of [BaseClient]. + ClientSettings digest() { + ClientSettings settings = this; + if (throwOnStatusCode) { + settings = settings.copyWith( + throwOnStatusCode: false, + ); + } + + return settings; + } +} diff --git a/lib/services/http/rhttp/src/client/rhttp_client.dart b/lib/services/http/rhttp/src/client/rhttp_client.dart new file mode 100644 index 00000000..4292bcfd --- /dev/null +++ b/lib/services/http/rhttp/src/client/rhttp_client.dart @@ -0,0 +1,102 @@ +import 'dart:async'; +import 'dart:typed_data'; + +import 'package:mangayomi/services/http/rhttp/src/model/cancel_token.dart'; +import 'package:mangayomi/services/http/rhttp/src/model/request.dart'; +import 'package:mangayomi/services/http/rhttp/src/model/response.dart'; +import 'package:mangayomi/services/http/rhttp/src/model/settings.dart'; +import 'package:mangayomi/services/http/rhttp/src/request.dart'; +import 'package:mangayomi/src/rust/api/rhttp/client.dart' as rust_client; +import 'package:mangayomi/src/rust/api/rhttp/http.dart' as rust; + +/// An HTTP client that is used to make requests. +/// Creating this is an expensive operation, so it is recommended to reuse it. +/// Internally, it holds a connection pool and other resources on the Rust side. +class RhttpClient { + /// Settings for the client. + final ClientSettings settings; + + /// Internal reference to the Rust client. + + final rust_client.RequestClient ref; + + const RhttpClient._({ + required this.settings, + required this.ref, + }); + + /// Creates a new HTTP client synchronously. + /// Use this method if your app is starting up to simplify the code + /// that might arise by using async/await. + /// + /// Note: + /// This method crashes when configured to use HTTP/3. + /// See: https://github.com/Tienisto/rhttp/issues/10 + factory RhttpClient.createSync({ + ClientSettings? settings, + }) { + settings ??= const ClientSettings(); + final ref = rust.registerClientSync( + settings: settings.toRustType(), + ); + return RhttpClient._( + settings: settings, + ref: ref, + ); + } + + /// Disposes the client. + /// This frees the resources associated with the client. + /// After calling this method, the client should not be used anymore. + /// + /// Note: + /// This might improve performance but it is not necessary because the client + /// is automatically disposed when the Dart object is garbage collected. + void dispose({bool cancelRunningRequests = false}) async { + if (ref.isDisposed) { + return; + } + + if (cancelRunningRequests) { + await rust.cancelRunningRequests(client: ref); + } + ref.dispose(); + } + + /// Makes an HTTP request. + /// Use [send] if you already have a [BaseHttpRequest] object. + Future request( + {required rust.HttpMethod method, + required String url, + Map? query, + required rust.HttpHeaders headers, + Uint8List? body, + CancelToken? cancelToken}) => + requestInternalGeneric(HttpRequest( + client: this, + settings: settings, + method: method, + url: url, + query: query, + headers: headers, + body: body, + cancelToken: cancelToken)); + + /// Makes an HTTP request and returns the response as a stream. + Future requestStream( + {required rust.HttpMethod method, + required String url, + Map? query, + required rust.HttpHeaders headers, + Uint8List? body, + CancelToken? cancelToken}) async { + final response = await request( + method: method, + url: url, + query: query, + headers: headers, + body: body, + cancelToken: cancelToken); + return response as HttpStreamResponse; + } +} diff --git a/lib/services/http/rhttp/src/model/cancel_token.dart b/lib/services/http/rhttp/src/model/cancel_token.dart new file mode 100644 index 00000000..d7991665 --- /dev/null +++ b/lib/services/http/rhttp/src/model/cancel_token.dart @@ -0,0 +1,48 @@ +import 'dart:async'; +import 'package:mangayomi/src/rust/api/rhttp/http.dart' as rust; +import 'package:mangayomi/src/rust/lib.dart' as rust_lib; + +/// A token that can be used to cancel an HTTP request. +/// This token must be passed to the request method. +class CancelToken { + final _ref = Completer(); + + bool _isCancelled = false; + + /// Whether the request has been cancelled. + bool get isCancelled => _isCancelled; + + CancelToken? _delegated; + + CancelToken(); + + + void setRef(rust_lib.CancellationToken ref) { + _ref.complete(ref); + } + + /// Cancels the HTTP request. + /// If the [CancelToken] is not passed to the request method, + /// this method never finishes. + Future cancel() async { + if (_delegated != null) { + await _delegated!.cancel(); + } else { + // We need to wait for the ref to be set. + final ref = await _ref.future; + + await rust.cancelRequest(token: ref); + _isCancelled = true; + } + } + + /// When a request is retried, a new [CancelToken] is created. + /// To ensure that [cancel] is still working on the old token, + /// a new token is created that gets cancelled + /// when the old token is cancelled. + CancelToken createDelegatedToken() { + final delegated = CancelToken(); + _delegated = delegated; + return delegated; + } +} diff --git a/lib/services/http/rhttp/src/model/exception.dart b/lib/services/http/rhttp/src/model/exception.dart new file mode 100644 index 00000000..2ab4928e --- /dev/null +++ b/lib/services/http/rhttp/src/model/exception.dart @@ -0,0 +1,151 @@ +import 'dart:typed_data'; +import 'package:mangayomi/services/http/rhttp/src/model/request.dart'; +import 'package:mangayomi/src/rust/api/rhttp/error.dart' as rust; +import 'package:mangayomi/src/rust/api/rhttp/http.dart' as rust_http; + +/// The base class for all exceptions thrown by the `rhttp` library +/// or by interceptors. +/// +/// This class is not sealed to allow for custom exceptions. +class RhttpException { + /// The associated request when the exception was thrown. + final HttpRequest request; + + const RhttpException(this.request); +} + +/// An exception thrown when a request is canceled. +class RhttpCancelException extends RhttpException { + const RhttpCancelException(super.request); + + @override + String toString() => + '[$runtimeType] Request was canceled. URL: ${request.url}'; +} + +/// An exception thrown when a request times out. +class RhttpTimeoutException extends RhttpException { + const RhttpTimeoutException(super.request); + + @override + String toString() => '[$runtimeType] Request timed out. URL: ${request.url}'; +} + +/// An exception thrown when there are issues related to redirects. +class RhttpRedirectException extends RhttpException { + const RhttpRedirectException(super.request); + + @override + String toString() => '[$runtimeType] Redirect error. URL: ${request.url}'; +} + +/// An exception thrown on a 4xx or 5xx status code. +class RhttpStatusCodeException extends RhttpException { + /// The status code of the response. + final int statusCode; + + /// Response headers. + final List<(String, String)> headers; + + Map get headerMap => { + for (final entry in headers) entry.$1: entry.$2, + }; + + /// The response body. For simplicity, we don't differentiate between + /// text or bytes. Streams are always null. + /// Can be [String], [Uint8List], or null. + final Object? body; + + const RhttpStatusCodeException({ + required HttpRequest request, + required this.statusCode, + required this.headers, + required this.body, + }) : super(request); + + @override + String toString() => + '[$runtimeType] Status code: $statusCode. URL: ${request.url}'; +} + +/// An exception thrown when the server's certificate is invalid. +class RhttpInvalidCertificateException extends RhttpException { + /// The more detailed error message. + final String message; + + const RhttpInvalidCertificateException({ + required HttpRequest request, + required this.message, + }) : super(request); + + @override + String toString() => + '[$runtimeType] Invalid certificate. $message URL: ${request.url}'; +} + +/// An exception thrown when a connection error occurs. +/// For example, when the server is unreachable or internet is not available. +class RhttpConnectionException extends RhttpException { + final String message; + + const RhttpConnectionException(super.request, this.message); + + @override + String toString() => + '[$runtimeType] Connection error. URL: ${request.url} ($message)'; +} + +/// An exception thrown a request is made with an invalid client. +class RhttpClientDisposedException extends RhttpException { + const RhttpClientDisposedException(super.request); + + @override + String toString() => + '[$runtimeType] Client is already disposed. URL: ${request.url}'; +} + +/// An exception thrown by an interceptor. +/// Interceptors should only throw exceptions of type [RhttpException]. +class RhttpInterceptorException extends RhttpException { + final Object error; + + RhttpInterceptorException(super.request, this.error); + + @override + String toString() => '[$runtimeType] $error. URL: ${request.url}'; +} + +/// An exception thrown when an unknown error occurs. +class RhttpUnknownException extends RhttpException { + /// The error message + final String message; + + const RhttpUnknownException(super.request, this.message); + + @override + String toString() => '[$runtimeType] $message'; +} + + +RhttpException parseError(HttpRequest request, rust.RhttpError error) { + return error.when( + rhttpCancelError: () => RhttpCancelException(request), + rhttpTimeoutError: () => RhttpTimeoutException(request), + rhttpRedirectError: () => RhttpRedirectException(request), + rhttpStatusCodeError: (code, headers, body) => RhttpStatusCodeException( + request: request, + statusCode: code, + headers: headers, + body: switch (body) { + rust_http.HttpResponseBody_Text() => body.field0, + rust_http.HttpResponseBody_Bytes() => body.field0, + rust_http.HttpResponseBody_Stream() => null, + }, + ), + rhttpInvalidCertificateError: (message) => + RhttpInvalidCertificateException(request: request, message: message), + rhttpConnectionError: (message) => + RhttpConnectionException(request, message), + rhttpUnknownError: (message) => RhttpUnknownException(request, message), + ); +} diff --git a/lib/services/http/rhttp/src/model/header.dart b/lib/services/http/rhttp/src/model/header.dart new file mode 100644 index 00000000..f65d22a4 --- /dev/null +++ b/lib/services/http/rhttp/src/model/header.dart @@ -0,0 +1,88 @@ +/// Type safe representation of HTTP headers. +enum HttpHeaderName { + accept('accept'), + acceptCharset('accept-charset'), + acceptEncoding('accept-encoding'), + acceptLanguage('accept-language'), + acceptRanges('accept-ranges'), + accessControlAllowCredentials('access-control-allow-credentials'), + accessControlAllowHeaders('access-control-allow-headers'), + accessControlAllowMethods('access-control-allow-methods'), + accessControlAllowOrigin('access-control-allow-origin'), + accessControlExposeHeaders('access-control-expose-headers'), + accessControlMaxAge('access-control-max-age'), + accessControlRequestHeaders('access-control-request-headers'), + accessControlRequestMethod('access-control-request-method'), + age('age'), + allow('allow'), + altSvc('alt-svc'), + authorization('authorization'), + cacheControl('cache-control'), + cacheStatus('cache-status'), + cdnCacheControl('cdn-cache-control'), + connection('connection'), + contentDisposition('content-disposition'), + contentEncoding('content-encoding'), + contentLanguage('content-language'), + contentLength('content-length'), + contentLocation('content-location'), + contentRange('content-range'), + contentSecurityPolicy('content-security-policy'), + contentSecurityPolicyReportOnly('content-security-policy-report-only'), + contentType('content-type'), + cookie('cookie'), + dnt('dnt'), + date('date'), + etag('etag'), + expect('expect'), + expires('expires'), + forwarded('forwarded'), + from('from'), + host('host'), + ifMatch('if-match'), + ifModifiedSince('if-modified-since'), + ifNoneMatch('if-none-match'), + ifRange('if-range'), + ifUnmodifiedSince('if-unmodified-since'), + lastModified('last-modified'), + link('link'), + location('location'), + maxForwards('max-forwards'), + origin('origin'), + pragma('pragma'), + proxyAuthenticate('proxy-authenticate'), + proxyAuthorization('proxy-authorization'), + publicKeyPins('public-key-pins'), + publicKeyPinsReportOnly('public-key-pins-report-only'), + range('range'), + referer('referer'), + referrerPolicy('referrer-policy'), + refresh('refresh'), + retryAfter('retry-after'), + secWebSocketAccept('sec-websocket-accept'), + secWebSocketExtensions('sec-websocket-extensions'), + secWebSocketKey('sec-websocket-key'), + secWebSocketProtocol('sec-websocket-protocol'), + secWebSocketVersion('sec-websocket-version'), + server('server'), + setCookie('set-cookie'), + strictTransportSecurity('strict-transport-security'), + te('te'), + trailer('trailer'), + transferEncoding('transfer-encoding'), + userAgent('user-agent'), + upgrade('upgrade'), + upgradeInsecureRequests('upgrade-insecure-requests'), + vary('vary'), + via('via'), + warning('warning'), + wwwAuthenticate('www-authenticate'), + xContentTypeOptions('x-content-type-options'), + xDnsPrefetchControl('x-dns-prefetch-control'), + xFrameOptions('x-frame-options'), + xXssProtection('x-xss-protection'); + + final String httpName; + + const HttpHeaderName(this.httpName); +} diff --git a/lib/services/http/rhttp/src/model/request.dart b/lib/services/http/rhttp/src/model/request.dart new file mode 100644 index 00000000..cb90d6b7 --- /dev/null +++ b/lib/services/http/rhttp/src/model/request.dart @@ -0,0 +1,62 @@ +import 'dart:typed_data'; +import 'package:mangayomi/services/http/rhttp/src/client/rhttp_client.dart'; +import 'package:mangayomi/services/http/rhttp/src/model/cancel_token.dart'; +import 'package:mangayomi/services/http/rhttp/src/model/settings.dart'; +import 'package:mangayomi/src/rust/api/rhttp/http.dart' as rust; + +/// An HTTP request that can be used +/// on a client or statically. +class BaseHttpRequest { + /// The HTTP method to use. + final rust.HttpMethod method; + + /// The URL to request. + final String url; + + /// Query parameters. + /// This can be null, if there are no query parameters + /// or if they are already part of the URL. + final Map? query; + + /// Headers to send with the request. + final rust.HttpHeaders? headers; + + /// The body of the request. + final Uint8List? body; + + /// The cancel token to use for the request. + final CancelToken? cancelToken; + + /// Map that can be used to store additional information. + /// Primarily used by interceptors. + /// This is not const to allow for modifications. + final Map additionalData = {}; + + BaseHttpRequest( + {required this.method, + required this.url, + required this.query, + required this.headers, + required this.body, + required this.cancelToken}); +} + +/// An HTTP request with the information which client to use. +class HttpRequest extends BaseHttpRequest { + /// The client to use for the request. + final RhttpClient? client; + + /// The settings to use for the request. + /// This is **only** used if [client] is `null`. + final ClientSettings? settings; + + HttpRequest( + {required this.client, + required this.settings, + required super.method, + required super.url, + required super.query, + required super.headers, + required super.body, + required super.cancelToken}); +} diff --git a/lib/services/http/rhttp/src/model/response.dart b/lib/services/http/rhttp/src/model/response.dart new file mode 100644 index 00000000..893a24d9 --- /dev/null +++ b/lib/services/http/rhttp/src/model/response.dart @@ -0,0 +1,90 @@ +import 'dart:typed_data'; +import 'package:mangayomi/services/http/rhttp/src/model/request.dart'; +import 'package:mangayomi/src/rust/api/rhttp/http.dart' as rust; + +sealed class HttpResponse { + final HttpRequest request; + final HttpVersion version; + final int statusCode; + final List<(String, String)> headers; + + Map get headerMap => { + for (final entry in headers) entry.$1: entry.$2, + }; + + const HttpResponse({ + required this.request, + required this.version, + required this.statusCode, + required this.headers, + }); +} + +class HttpBytesResponse extends HttpResponse { + final Uint8List body; + + const HttpBytesResponse({ + required super.request, + required super.version, + required super.statusCode, + required super.headers, + required this.body, + }); + + @override + String toString() { + return 'HttpBytesResponse(${version.name}, status: $statusCode)'; + } +} + +class HttpStreamResponse extends HttpResponse { + final Stream body; + + const HttpStreamResponse({ + required super.request, + required super.version, + required super.statusCode, + required super.headers, + required this.body, + }); + + @override + String toString() { + return 'HttpStreamResponse(${version.name}, status: $statusCode)'; + } +} + +enum HttpVersion { + http09, + http1_0, + http1_1, + other, + ; +} + +HttpResponse parseHttpResponse( + HttpRequest request, + rust.HttpResponse response, { + Stream? bodyStream, +}) { + assert((response.body is rust.HttpResponseBody_Stream && + bodyStream != null) || + (response.body is! rust.HttpResponseBody_Stream && bodyStream == null)); + + return HttpStreamResponse( + request: request, + version: parseHttpVersion(response.version), + statusCode: response.statusCode, + headers: response.headers, + body: bodyStream!, + ); +} + +HttpVersion parseHttpVersion(rust.HttpVersion version) { + return switch (version) { + rust.HttpVersion.http09 => HttpVersion.http09, + rust.HttpVersion.http10 => HttpVersion.http1_0, + rust.HttpVersion.http11 => HttpVersion.http1_1, + rust.HttpVersion.other => HttpVersion.other, + }; +} diff --git a/lib/services/http/rhttp/src/model/settings.dart b/lib/services/http/rhttp/src/model/settings.dart new file mode 100644 index 00000000..85a504c6 --- /dev/null +++ b/lib/services/http/rhttp/src/model/settings.dart @@ -0,0 +1,214 @@ +import 'dart:typed_data'; +import 'package:mangayomi/src/rust/api/rhttp/client.dart' as rust_client; + +export 'package:mangayomi/src/rust/api/rhttp/client.dart' show TlsVersion; + +const _keepBaseUrl = '__rhttp_keep__'; +const _keepDuration = Duration(microseconds: -9999); +const _keepProxySettings = ProxySettings.noProxy(); +const _keepRedirectSettings = RedirectSettings.limited(-9999); +const _keepTlsSettings = TlsSettings(); + +class ClientSettings { + /// Base URL to be prefixed to all requests. + final String? baseUrl; + + /// The timeout for the request including time to establish a connection. + final Duration? timeout; + + /// The timeout for establishing a connection. + /// See [timeout] for the total timeout. + final Duration? connectTimeout; + + /// Throws an exception if the status code is 4xx or 5xx. + final bool throwOnStatusCode; + + /// Proxy settings. + final ProxySettings? proxySettings; + + /// Redirect settings. + /// By default, the client will follow maximum 10 redirects. + /// See: https://docs.rs/reqwest/latest/reqwest/redirect/struct.Policy.html + final RedirectSettings? redirectSettings; + + /// TLS settings. + final TlsSettings? tlsSettings; + + const ClientSettings({ + this.baseUrl, + this.timeout, + this.connectTimeout, + this.throwOnStatusCode = true, + this.proxySettings, + this.redirectSettings, + this.tlsSettings, + }); + + ClientSettings copyWith({ + String? baseUrl = _keepBaseUrl, + Duration? timeout = _keepDuration, + Duration? connectTimeout = _keepDuration, + bool? throwOnStatusCode, + ProxySettings? proxySettings = _keepProxySettings, + RedirectSettings? redirectSettings = _keepRedirectSettings, + TlsSettings? tlsSettings = _keepTlsSettings, + }) { + return ClientSettings( + baseUrl: identical(baseUrl, _keepBaseUrl) ? this.baseUrl : baseUrl, + timeout: identical(timeout, _keepDuration) ? this.timeout : timeout, + connectTimeout: identical(connectTimeout, _keepDuration) + ? this.connectTimeout + : connectTimeout, + throwOnStatusCode: throwOnStatusCode ?? this.throwOnStatusCode, + proxySettings: identical(proxySettings, _keepProxySettings) + ? this.proxySettings + : proxySettings, + redirectSettings: identical(redirectSettings, _keepRedirectSettings) + ? this.redirectSettings + : redirectSettings, + tlsSettings: identical(tlsSettings, _keepTlsSettings) + ? this.tlsSettings + : tlsSettings, + ); + } +} + +sealed class ProxySettings { + const ProxySettings(); + + /// Disables any proxy settings including system settings. + const factory ProxySettings.noProxy() = NoProxy._; +} + +class NoProxy extends ProxySettings { + const NoProxy._(); +} + +sealed class RedirectSettings { + const RedirectSettings(); + + /// Disables any redirects and exceptions related to redirects. + const factory RedirectSettings.none() = NoRedirectSetting._; + + /// Limits the number of redirects. + const factory RedirectSettings.limited(int maxRedirects) = LimitedRedirects._; +} + +/// Disables any redirects. +class NoRedirectSetting extends RedirectSettings { + const NoRedirectSetting._(); +} + +/// Limits the number of redirects. +class LimitedRedirects extends RedirectSettings { + final int maxRedirects; + + const LimitedRedirects._(this.maxRedirects); +} + +/// TLS settings for the client. +/// Used to configure HTTPS connections. +class TlsSettings { + /// Trust the root certificates that are pre-installed on the system. + final bool trustRootCertificates; + + /// The trusted root certificates in PEM format. + /// Either specify the root certificate or the full + /// certificate chain. + /// The Rust API currently doesn't support trusting a single leaf certificate. + /// Hint: PEM format starts with `-----BEGIN CERTIFICATE-----`. + final List trustedRootCertificates; + + /// Verify the server's certificate. + /// If set to `false`, the client will accept any certificate. + /// This is insecure and should only be used for testing. + final bool verifyCertificates; + + /// The client certificate to use. + /// This is used for client authentication / mutual TLS. + final ClientCertificate? clientCertificate; + + /// The minimum TLS version to use. + final rust_client.TlsVersion? minTlsVersion; + + /// The maximum TLS version to use. + final rust_client.TlsVersion? maxTlsVersion; + + const TlsSettings({ + this.trustRootCertificates = true, + this.trustedRootCertificates = const [], + this.verifyCertificates = true, + this.clientCertificate, + this.minTlsVersion, + this.maxTlsVersion, + }); +} + +/// A client certificate for client authentication / mutual TLS. +class ClientCertificate { + /// The certificate in PEM format. + final String certificate; + + /// The private key in PEM format. + final String privateKey; + + const ClientCertificate({ + required this.certificate, + required this.privateKey, + }); +} + +extension ClientSettingsExt on ClientSettings { + rust_client.ClientSettings toRustType() { + return rust_client.ClientSettings( + timeout: timeout, + connectTimeout: connectTimeout, + throwOnStatusCode: throwOnStatusCode, + proxySettings: proxySettings?._toRustType(), + redirectSettings: redirectSettings?._toRustType(), + tlsSettings: tlsSettings?._toRustType(), + ); + } +} + +extension on ProxySettings { + rust_client.ProxySettings _toRustType() { + return switch (this) { + NoProxy() => rust_client.ProxySettings.noProxy, + }; + } +} + +extension on RedirectSettings { + rust_client.RedirectSettings _toRustType() { + return switch (this) { + NoRedirectSetting() => const rust_client.RedirectSettings.noRedirect(), + LimitedRedirects r => + rust_client.RedirectSettings.limitedRedirects(r.maxRedirects), + }; + } +} + +extension on TlsSettings { + rust_client.TlsSettings _toRustType() { + return rust_client.TlsSettings( + trustRootCertificates: trustRootCertificates, + trustedRootCertificates: trustedRootCertificates + .map((e) => Uint8List.fromList(e.codeUnits)) + .toList(), + verifyCertificates: verifyCertificates, + clientCertificate: clientCertificate?._toRustType(), + minTlsVersion: minTlsVersion, + maxTlsVersion: maxTlsVersion, + ); + } +} + +extension on ClientCertificate { + rust_client.ClientCertificate _toRustType() { + return rust_client.ClientCertificate( + certificate: Uint8List.fromList(certificate.codeUnits), + privateKey: Uint8List.fromList(privateKey.codeUnits), + ); + } +} diff --git a/lib/services/http/rhttp/src/request.dart b/lib/services/http/rhttp/src/request.dart new file mode 100644 index 00000000..40896a04 --- /dev/null +++ b/lib/services/http/rhttp/src/request.dart @@ -0,0 +1,64 @@ +import 'dart:async'; +import 'package:flutter/foundation.dart'; +import 'package:mangayomi/services/http/rhttp/src/model/exception.dart'; +import 'package:mangayomi/services/http/rhttp/src/model/request.dart'; +import 'package:mangayomi/services/http/rhttp/src/model/response.dart'; +import 'package:mangayomi/services/http/rhttp/src/model/settings.dart'; +import 'package:mangayomi/src/rust/api/rhttp/error.dart' as rust_error; +import 'package:mangayomi/src/rust/api/rhttp/http.dart' as rust; +import 'package:mangayomi/src/rust/lib.dart' as rust_lib; + +/// Non-Generated helper function that is used by +/// the client and also by the static class. + +Future requestInternalGeneric(HttpRequest request) async { + if (request.client?.ref.isDisposed ?? false) { + throw RhttpClientDisposedException(request); + } + + final url = switch (request.settings?.baseUrl) { + String baseUrl => baseUrl + request.url, + null => request.url, + }; + + try { + final cancelRefCompleter = Completer(); + final responseCompleter = Completer(); + Stream stream = rust.makeHttpRequestReceiveStream( + client: request.client?.ref, + settings: request.settings?.toRustType(), + method: request.method, + url: url, + query: request.query?.entries.map((e) => (e.key, e.value)).toList(), + headers: request.headers, + body: request.body, + onResponse: (r) => responseCompleter.complete(r), + onError: (e) => responseCompleter.completeError(e), + onCancelToken: (cancelRef) => cancelRefCompleter.complete(cancelRef), + cancelable: request.cancelToken != null, + ); + + final cancelToken = request.cancelToken; + if (cancelToken != null) { + final cancelRef = await cancelRefCompleter.future; + cancelToken.setRef(cancelRef); + } + + final rustResponse = await responseCompleter.future; + + HttpResponse response = parseHttpResponse( + request, + rustResponse, + bodyStream: stream, + ); + + return response; + } catch (e, st) { + if (e is rust_error.RhttpError) { + RhttpException exception = parseError(request, e); + Error.throwWithStackTrace(exception, st); + } else { + rethrow; + } + } +} diff --git a/lib/services/m3u8/m3u8_downloader.dart b/lib/services/m3u8/m3u8_downloader.dart index 697157a0..24b0758d 100644 --- a/lib/services/m3u8/m3u8_downloader.dart +++ b/lib/services/m3u8/m3u8_downloader.dart @@ -19,18 +19,28 @@ class M3u8Downloader { required this.downloadDir, required this.headers}); - Future> getTsList() async { + Future<(List, String?)> getTsList() async { + String? key; final uri = Uri.parse(m3u8Url); final m3u8Host = "${uri.scheme}://${uri.host}${path.dirname(uri.path)}"; - final m3u8Body = await _getM3u8Body(m3u8Url, headers); + final m3u8Body = await _getM3u8Body(m3u8Url); final tsList = _parseTsList(m3u8Host, m3u8Body); if (kDebugMode) { print("Total TS files to download: ${tsList.length}"); } - return tsList; + String? tsKey = await getM3u8Key(m3u8Body); + if (tsKey?.isNotEmpty ?? false) { + if (kDebugMode) { + print("TS Key: $tsKey"); + } + key = tsKey; + } + return (tsList, key); } - Future _getM3u8Body(String url, Map? headers) async { + Future _getM3u8Body( + String url, + ) async { final response = await MClient.httpClient().get(Uri.parse(url), headers: headers); if (response.statusCode == 200) { @@ -61,4 +71,31 @@ class M3u8Downloader { File("$downloadDir/index.m3u8").writeAsStringSync(allText); return tsList; } + + Future getM3u8Key(String m3u8Body) async { + final uri = Uri.parse(m3u8Url); + final m3u8Host = "${uri.scheme}://${uri.host}${path.dirname(uri.path)}"; + final lines = m3u8Body.split("\n"); + for (final line in lines) { + if (line.contains("#EXT-X-KEY")) { + final keyUrl = _extractKeyUrl(m3u8Host, line); + final response = + await MClient.httpClient().get(Uri.parse(keyUrl), headers: headers); + if (response.statusCode == 200) { + return response.body; + } + } + } + return null; + } + + String _extractKeyUrl(String host, String line) { + final uriPos = line.indexOf("URI"); + final quotationMarkPos = line.lastIndexOf("\""); + var keyUrl = line.substring(uriPos, quotationMarkPos).split("\"")[1]; + if (!line.contains("http")) { + keyUrl = "$host/$keyUrl"; + } + return keyUrl; + } } diff --git a/lib/src/rust/api/rhttp/client.dart b/lib/src/rust/api/rhttp/client.dart new file mode 100644 index 00000000..9d3e94ca --- /dev/null +++ b/lib/src/rust/api/rhttp/client.dart @@ -0,0 +1,138 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.3.0. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import '../../frb_generated.dart'; +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 functions are ignored because they are not marked as `pub`: `create_client`, `new_default`, `new` +// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone` + +// Rust type: RustOpaqueMoi> +abstract class RequestClient implements RustOpaqueInterface {} + +class ClientCertificate { + final Uint8List certificate; + final Uint8List privateKey; + + const ClientCertificate({ + required this.certificate, + required this.privateKey, + }); + + @override + int get hashCode => certificate.hashCode ^ privateKey.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is ClientCertificate && + runtimeType == other.runtimeType && + certificate == other.certificate && + privateKey == other.privateKey; +} + +class ClientSettings { + final Duration? timeout; + final Duration? connectTimeout; + final bool throwOnStatusCode; + final ProxySettings? proxySettings; + final RedirectSettings? redirectSettings; + final TlsSettings? tlsSettings; + + const ClientSettings({ + this.timeout, + this.connectTimeout, + required this.throwOnStatusCode, + this.proxySettings, + this.redirectSettings, + this.tlsSettings, + }); + + static Future default_() => + RustLib.instance.api.crateApiRhttpClientClientSettingsDefault(); + + @override + int get hashCode => + timeout.hashCode ^ + connectTimeout.hashCode ^ + throwOnStatusCode.hashCode ^ + proxySettings.hashCode ^ + redirectSettings.hashCode ^ + tlsSettings.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is ClientSettings && + runtimeType == other.runtimeType && + timeout == other.timeout && + connectTimeout == other.connectTimeout && + throwOnStatusCode == other.throwOnStatusCode && + proxySettings == other.proxySettings && + redirectSettings == other.redirectSettings && + tlsSettings == other.tlsSettings; +} + +enum ProxySettings { + noProxy, + ; +} + +@freezed +sealed class RedirectSettings with _$RedirectSettings { + const RedirectSettings._(); + + const factory RedirectSettings.noRedirect() = RedirectSettings_NoRedirect; + const factory RedirectSettings.limitedRedirects( + int field0, + ) = RedirectSettings_LimitedRedirects; +} + +class TlsSettings { + final bool trustRootCertificates; + final List trustedRootCertificates; + final bool verifyCertificates; + final ClientCertificate? clientCertificate; + final TlsVersion? minTlsVersion; + final TlsVersion? maxTlsVersion; + + const TlsSettings({ + required this.trustRootCertificates, + required this.trustedRootCertificates, + required this.verifyCertificates, + this.clientCertificate, + this.minTlsVersion, + this.maxTlsVersion, + }); + + @override + int get hashCode => + trustRootCertificates.hashCode ^ + trustedRootCertificates.hashCode ^ + verifyCertificates.hashCode ^ + clientCertificate.hashCode ^ + minTlsVersion.hashCode ^ + maxTlsVersion.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is TlsSettings && + runtimeType == other.runtimeType && + trustRootCertificates == other.trustRootCertificates && + trustedRootCertificates == other.trustedRootCertificates && + verifyCertificates == other.verifyCertificates && + clientCertificate == other.clientCertificate && + minTlsVersion == other.minTlsVersion && + maxTlsVersion == other.maxTlsVersion; +} + +enum TlsVersion { + tls12, + tls13, + ; +} diff --git a/lib/src/rust/api/rhttp/client.freezed.dart b/lib/src/rust/api/rhttp/client.freezed.dart new file mode 100644 index 00000000..836134a4 --- /dev/null +++ b/lib/src/rust/api/rhttp/client.freezed.dart @@ -0,0 +1,344 @@ +// 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 '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 _$RedirectSettings { + @optionalTypeArgs + TResult when({ + required TResult Function() noRedirect, + required TResult Function(int field0) limitedRedirects, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? noRedirect, + TResult? Function(int field0)? limitedRedirects, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? noRedirect, + TResult Function(int field0)? limitedRedirects, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(RedirectSettings_NoRedirect value) noRedirect, + required TResult Function(RedirectSettings_LimitedRedirects value) + limitedRedirects, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(RedirectSettings_NoRedirect value)? noRedirect, + TResult? Function(RedirectSettings_LimitedRedirects value)? + limitedRedirects, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(RedirectSettings_NoRedirect value)? noRedirect, + TResult Function(RedirectSettings_LimitedRedirects value)? limitedRedirects, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $RedirectSettingsCopyWith<$Res> { + factory $RedirectSettingsCopyWith( + RedirectSettings value, $Res Function(RedirectSettings) then) = + _$RedirectSettingsCopyWithImpl<$Res, RedirectSettings>; +} + +/// @nodoc +class _$RedirectSettingsCopyWithImpl<$Res, $Val extends RedirectSettings> + implements $RedirectSettingsCopyWith<$Res> { + _$RedirectSettingsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of RedirectSettings + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$RedirectSettings_NoRedirectImplCopyWith<$Res> { + factory _$$RedirectSettings_NoRedirectImplCopyWith( + _$RedirectSettings_NoRedirectImpl value, + $Res Function(_$RedirectSettings_NoRedirectImpl) then) = + __$$RedirectSettings_NoRedirectImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$RedirectSettings_NoRedirectImplCopyWithImpl<$Res> + extends _$RedirectSettingsCopyWithImpl<$Res, + _$RedirectSettings_NoRedirectImpl> + implements _$$RedirectSettings_NoRedirectImplCopyWith<$Res> { + __$$RedirectSettings_NoRedirectImplCopyWithImpl( + _$RedirectSettings_NoRedirectImpl _value, + $Res Function(_$RedirectSettings_NoRedirectImpl) _then) + : super(_value, _then); + + /// Create a copy of RedirectSettings + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$RedirectSettings_NoRedirectImpl extends RedirectSettings_NoRedirect { + const _$RedirectSettings_NoRedirectImpl() : super._(); + + @override + String toString() { + return 'RedirectSettings.noRedirect()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RedirectSettings_NoRedirectImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() noRedirect, + required TResult Function(int field0) limitedRedirects, + }) { + return noRedirect(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? noRedirect, + TResult? Function(int field0)? limitedRedirects, + }) { + return noRedirect?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? noRedirect, + TResult Function(int field0)? limitedRedirects, + required TResult orElse(), + }) { + if (noRedirect != null) { + return noRedirect(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(RedirectSettings_NoRedirect value) noRedirect, + required TResult Function(RedirectSettings_LimitedRedirects value) + limitedRedirects, + }) { + return noRedirect(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(RedirectSettings_NoRedirect value)? noRedirect, + TResult? Function(RedirectSettings_LimitedRedirects value)? + limitedRedirects, + }) { + return noRedirect?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(RedirectSettings_NoRedirect value)? noRedirect, + TResult Function(RedirectSettings_LimitedRedirects value)? limitedRedirects, + required TResult orElse(), + }) { + if (noRedirect != null) { + return noRedirect(this); + } + return orElse(); + } +} + +abstract class RedirectSettings_NoRedirect extends RedirectSettings { + const factory RedirectSettings_NoRedirect() = + _$RedirectSettings_NoRedirectImpl; + const RedirectSettings_NoRedirect._() : super._(); +} + +/// @nodoc +abstract class _$$RedirectSettings_LimitedRedirectsImplCopyWith<$Res> { + factory _$$RedirectSettings_LimitedRedirectsImplCopyWith( + _$RedirectSettings_LimitedRedirectsImpl value, + $Res Function(_$RedirectSettings_LimitedRedirectsImpl) then) = + __$$RedirectSettings_LimitedRedirectsImplCopyWithImpl<$Res>; + @useResult + $Res call({int field0}); +} + +/// @nodoc +class __$$RedirectSettings_LimitedRedirectsImplCopyWithImpl<$Res> + extends _$RedirectSettingsCopyWithImpl<$Res, + _$RedirectSettings_LimitedRedirectsImpl> + implements _$$RedirectSettings_LimitedRedirectsImplCopyWith<$Res> { + __$$RedirectSettings_LimitedRedirectsImplCopyWithImpl( + _$RedirectSettings_LimitedRedirectsImpl _value, + $Res Function(_$RedirectSettings_LimitedRedirectsImpl) _then) + : super(_value, _then); + + /// Create a copy of RedirectSettings + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? field0 = null, + }) { + return _then(_$RedirectSettings_LimitedRedirectsImpl( + null == field0 + ? _value.field0 + : field0 // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$RedirectSettings_LimitedRedirectsImpl + extends RedirectSettings_LimitedRedirects { + const _$RedirectSettings_LimitedRedirectsImpl(this.field0) : super._(); + + @override + final int field0; + + @override + String toString() { + return 'RedirectSettings.limitedRedirects(field0: $field0)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RedirectSettings_LimitedRedirectsImpl && + (identical(other.field0, field0) || other.field0 == field0)); + } + + @override + int get hashCode => Object.hash(runtimeType, field0); + + /// Create a copy of RedirectSettings + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$RedirectSettings_LimitedRedirectsImplCopyWith< + _$RedirectSettings_LimitedRedirectsImpl> + get copyWith => __$$RedirectSettings_LimitedRedirectsImplCopyWithImpl< + _$RedirectSettings_LimitedRedirectsImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() noRedirect, + required TResult Function(int field0) limitedRedirects, + }) { + return limitedRedirects(field0); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? noRedirect, + TResult? Function(int field0)? limitedRedirects, + }) { + return limitedRedirects?.call(field0); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? noRedirect, + TResult Function(int field0)? limitedRedirects, + required TResult orElse(), + }) { + if (limitedRedirects != null) { + return limitedRedirects(field0); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(RedirectSettings_NoRedirect value) noRedirect, + required TResult Function(RedirectSettings_LimitedRedirects value) + limitedRedirects, + }) { + return limitedRedirects(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(RedirectSettings_NoRedirect value)? noRedirect, + TResult? Function(RedirectSettings_LimitedRedirects value)? + limitedRedirects, + }) { + return limitedRedirects?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(RedirectSettings_NoRedirect value)? noRedirect, + TResult Function(RedirectSettings_LimitedRedirects value)? limitedRedirects, + required TResult orElse(), + }) { + if (limitedRedirects != null) { + return limitedRedirects(this); + } + return orElse(); + } +} + +abstract class RedirectSettings_LimitedRedirects extends RedirectSettings { + const factory RedirectSettings_LimitedRedirects(final int field0) = + _$RedirectSettings_LimitedRedirectsImpl; + const RedirectSettings_LimitedRedirects._() : super._(); + + int get field0; + + /// Create a copy of RedirectSettings + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$RedirectSettings_LimitedRedirectsImplCopyWith< + _$RedirectSettings_LimitedRedirectsImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/src/rust/api/rhttp/error.dart b/lib/src/rust/api/rhttp/error.dart new file mode 100644 index 00000000..b5e71849 --- /dev/null +++ b/lib/src/rust/api/rhttp/error.dart @@ -0,0 +1,35 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.3.0. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import '../../frb_generated.dart'; +import 'http.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import 'package:freezed_annotation/freezed_annotation.dart' hide protected; +part 'error.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): `clone`, `fmt`, `fmt` + +@freezed +sealed class RhttpError with _$RhttpError { + const RhttpError._(); + + const factory RhttpError.rhttpCancelError() = RhttpError_RhttpCancelError; + const factory RhttpError.rhttpTimeoutError() = RhttpError_RhttpTimeoutError; + const factory RhttpError.rhttpRedirectError() = RhttpError_RhttpRedirectError; + const factory RhttpError.rhttpStatusCodeError( + int field0, + List<(String, String)> field1, + HttpResponseBody field2, + ) = RhttpError_RhttpStatusCodeError; + const factory RhttpError.rhttpInvalidCertificateError( + String field0, + ) = RhttpError_RhttpInvalidCertificateError; + const factory RhttpError.rhttpConnectionError( + String field0, + ) = RhttpError_RhttpConnectionError; + const factory RhttpError.rhttpUnknownError( + String field0, + ) = RhttpError_RhttpUnknownError; +} diff --git a/lib/src/rust/api/rhttp/error.freezed.dart b/lib/src/rust/api/rhttp/error.freezed.dart new file mode 100644 index 00000000..07e5f871 --- /dev/null +++ b/lib/src/rust/api/rhttp/error.freezed.dart @@ -0,0 +1,1439 @@ +// 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 'error.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 _$RhttpError { + @optionalTypeArgs + TResult when({ + required TResult Function() rhttpCancelError, + required TResult Function() rhttpTimeoutError, + required TResult Function() rhttpRedirectError, + required TResult Function( + int field0, List<(String, String)> field1, HttpResponseBody field2) + rhttpStatusCodeError, + required TResult Function(String field0) rhttpInvalidCertificateError, + required TResult Function(String field0) rhttpConnectionError, + required TResult Function(String field0) rhttpUnknownError, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? rhttpCancelError, + TResult? Function()? rhttpTimeoutError, + TResult? Function()? rhttpRedirectError, + TResult? Function( + int field0, List<(String, String)> field1, HttpResponseBody field2)? + rhttpStatusCodeError, + TResult? Function(String field0)? rhttpInvalidCertificateError, + TResult? Function(String field0)? rhttpConnectionError, + TResult? Function(String field0)? rhttpUnknownError, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? rhttpCancelError, + TResult Function()? rhttpTimeoutError, + TResult Function()? rhttpRedirectError, + TResult Function( + int field0, List<(String, String)> field1, HttpResponseBody field2)? + rhttpStatusCodeError, + TResult Function(String field0)? rhttpInvalidCertificateError, + TResult Function(String field0)? rhttpConnectionError, + TResult Function(String field0)? rhttpUnknownError, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(RhttpError_RhttpCancelError value) + rhttpCancelError, + required TResult Function(RhttpError_RhttpTimeoutError value) + rhttpTimeoutError, + required TResult Function(RhttpError_RhttpRedirectError value) + rhttpRedirectError, + required TResult Function(RhttpError_RhttpStatusCodeError value) + rhttpStatusCodeError, + required TResult Function(RhttpError_RhttpInvalidCertificateError value) + rhttpInvalidCertificateError, + required TResult Function(RhttpError_RhttpConnectionError value) + rhttpConnectionError, + required TResult Function(RhttpError_RhttpUnknownError value) + rhttpUnknownError, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(RhttpError_RhttpCancelError value)? rhttpCancelError, + TResult? Function(RhttpError_RhttpTimeoutError value)? rhttpTimeoutError, + TResult? Function(RhttpError_RhttpRedirectError value)? rhttpRedirectError, + TResult? Function(RhttpError_RhttpStatusCodeError value)? + rhttpStatusCodeError, + TResult? Function(RhttpError_RhttpInvalidCertificateError value)? + rhttpInvalidCertificateError, + TResult? Function(RhttpError_RhttpConnectionError value)? + rhttpConnectionError, + TResult? Function(RhttpError_RhttpUnknownError value)? rhttpUnknownError, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(RhttpError_RhttpCancelError value)? rhttpCancelError, + TResult Function(RhttpError_RhttpTimeoutError value)? rhttpTimeoutError, + TResult Function(RhttpError_RhttpRedirectError value)? rhttpRedirectError, + TResult Function(RhttpError_RhttpStatusCodeError value)? + rhttpStatusCodeError, + TResult Function(RhttpError_RhttpInvalidCertificateError value)? + rhttpInvalidCertificateError, + TResult Function(RhttpError_RhttpConnectionError value)? + rhttpConnectionError, + TResult Function(RhttpError_RhttpUnknownError value)? rhttpUnknownError, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $RhttpErrorCopyWith<$Res> { + factory $RhttpErrorCopyWith( + RhttpError value, $Res Function(RhttpError) then) = + _$RhttpErrorCopyWithImpl<$Res, RhttpError>; +} + +/// @nodoc +class _$RhttpErrorCopyWithImpl<$Res, $Val extends RhttpError> + implements $RhttpErrorCopyWith<$Res> { + _$RhttpErrorCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$RhttpError_RhttpCancelErrorImplCopyWith<$Res> { + factory _$$RhttpError_RhttpCancelErrorImplCopyWith( + _$RhttpError_RhttpCancelErrorImpl value, + $Res Function(_$RhttpError_RhttpCancelErrorImpl) then) = + __$$RhttpError_RhttpCancelErrorImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$RhttpError_RhttpCancelErrorImplCopyWithImpl<$Res> + extends _$RhttpErrorCopyWithImpl<$Res, _$RhttpError_RhttpCancelErrorImpl> + implements _$$RhttpError_RhttpCancelErrorImplCopyWith<$Res> { + __$$RhttpError_RhttpCancelErrorImplCopyWithImpl( + _$RhttpError_RhttpCancelErrorImpl _value, + $Res Function(_$RhttpError_RhttpCancelErrorImpl) _then) + : super(_value, _then); + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$RhttpError_RhttpCancelErrorImpl extends RhttpError_RhttpCancelError { + const _$RhttpError_RhttpCancelErrorImpl() : super._(); + + @override + String toString() { + return 'RhttpError.rhttpCancelError()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RhttpError_RhttpCancelErrorImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() rhttpCancelError, + required TResult Function() rhttpTimeoutError, + required TResult Function() rhttpRedirectError, + required TResult Function( + int field0, List<(String, String)> field1, HttpResponseBody field2) + rhttpStatusCodeError, + required TResult Function(String field0) rhttpInvalidCertificateError, + required TResult Function(String field0) rhttpConnectionError, + required TResult Function(String field0) rhttpUnknownError, + }) { + return rhttpCancelError(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? rhttpCancelError, + TResult? Function()? rhttpTimeoutError, + TResult? Function()? rhttpRedirectError, + TResult? Function( + int field0, List<(String, String)> field1, HttpResponseBody field2)? + rhttpStatusCodeError, + TResult? Function(String field0)? rhttpInvalidCertificateError, + TResult? Function(String field0)? rhttpConnectionError, + TResult? Function(String field0)? rhttpUnknownError, + }) { + return rhttpCancelError?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? rhttpCancelError, + TResult Function()? rhttpTimeoutError, + TResult Function()? rhttpRedirectError, + TResult Function( + int field0, List<(String, String)> field1, HttpResponseBody field2)? + rhttpStatusCodeError, + TResult Function(String field0)? rhttpInvalidCertificateError, + TResult Function(String field0)? rhttpConnectionError, + TResult Function(String field0)? rhttpUnknownError, + required TResult orElse(), + }) { + if (rhttpCancelError != null) { + return rhttpCancelError(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(RhttpError_RhttpCancelError value) + rhttpCancelError, + required TResult Function(RhttpError_RhttpTimeoutError value) + rhttpTimeoutError, + required TResult Function(RhttpError_RhttpRedirectError value) + rhttpRedirectError, + required TResult Function(RhttpError_RhttpStatusCodeError value) + rhttpStatusCodeError, + required TResult Function(RhttpError_RhttpInvalidCertificateError value) + rhttpInvalidCertificateError, + required TResult Function(RhttpError_RhttpConnectionError value) + rhttpConnectionError, + required TResult Function(RhttpError_RhttpUnknownError value) + rhttpUnknownError, + }) { + return rhttpCancelError(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(RhttpError_RhttpCancelError value)? rhttpCancelError, + TResult? Function(RhttpError_RhttpTimeoutError value)? rhttpTimeoutError, + TResult? Function(RhttpError_RhttpRedirectError value)? rhttpRedirectError, + TResult? Function(RhttpError_RhttpStatusCodeError value)? + rhttpStatusCodeError, + TResult? Function(RhttpError_RhttpInvalidCertificateError value)? + rhttpInvalidCertificateError, + TResult? Function(RhttpError_RhttpConnectionError value)? + rhttpConnectionError, + TResult? Function(RhttpError_RhttpUnknownError value)? rhttpUnknownError, + }) { + return rhttpCancelError?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(RhttpError_RhttpCancelError value)? rhttpCancelError, + TResult Function(RhttpError_RhttpTimeoutError value)? rhttpTimeoutError, + TResult Function(RhttpError_RhttpRedirectError value)? rhttpRedirectError, + TResult Function(RhttpError_RhttpStatusCodeError value)? + rhttpStatusCodeError, + TResult Function(RhttpError_RhttpInvalidCertificateError value)? + rhttpInvalidCertificateError, + TResult Function(RhttpError_RhttpConnectionError value)? + rhttpConnectionError, + TResult Function(RhttpError_RhttpUnknownError value)? rhttpUnknownError, + required TResult orElse(), + }) { + if (rhttpCancelError != null) { + return rhttpCancelError(this); + } + return orElse(); + } +} + +abstract class RhttpError_RhttpCancelError extends RhttpError { + const factory RhttpError_RhttpCancelError() = + _$RhttpError_RhttpCancelErrorImpl; + const RhttpError_RhttpCancelError._() : super._(); +} + +/// @nodoc +abstract class _$$RhttpError_RhttpTimeoutErrorImplCopyWith<$Res> { + factory _$$RhttpError_RhttpTimeoutErrorImplCopyWith( + _$RhttpError_RhttpTimeoutErrorImpl value, + $Res Function(_$RhttpError_RhttpTimeoutErrorImpl) then) = + __$$RhttpError_RhttpTimeoutErrorImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$RhttpError_RhttpTimeoutErrorImplCopyWithImpl<$Res> + extends _$RhttpErrorCopyWithImpl<$Res, _$RhttpError_RhttpTimeoutErrorImpl> + implements _$$RhttpError_RhttpTimeoutErrorImplCopyWith<$Res> { + __$$RhttpError_RhttpTimeoutErrorImplCopyWithImpl( + _$RhttpError_RhttpTimeoutErrorImpl _value, + $Res Function(_$RhttpError_RhttpTimeoutErrorImpl) _then) + : super(_value, _then); + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$RhttpError_RhttpTimeoutErrorImpl extends RhttpError_RhttpTimeoutError { + const _$RhttpError_RhttpTimeoutErrorImpl() : super._(); + + @override + String toString() { + return 'RhttpError.rhttpTimeoutError()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RhttpError_RhttpTimeoutErrorImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() rhttpCancelError, + required TResult Function() rhttpTimeoutError, + required TResult Function() rhttpRedirectError, + required TResult Function( + int field0, List<(String, String)> field1, HttpResponseBody field2) + rhttpStatusCodeError, + required TResult Function(String field0) rhttpInvalidCertificateError, + required TResult Function(String field0) rhttpConnectionError, + required TResult Function(String field0) rhttpUnknownError, + }) { + return rhttpTimeoutError(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? rhttpCancelError, + TResult? Function()? rhttpTimeoutError, + TResult? Function()? rhttpRedirectError, + TResult? Function( + int field0, List<(String, String)> field1, HttpResponseBody field2)? + rhttpStatusCodeError, + TResult? Function(String field0)? rhttpInvalidCertificateError, + TResult? Function(String field0)? rhttpConnectionError, + TResult? Function(String field0)? rhttpUnknownError, + }) { + return rhttpTimeoutError?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? rhttpCancelError, + TResult Function()? rhttpTimeoutError, + TResult Function()? rhttpRedirectError, + TResult Function( + int field0, List<(String, String)> field1, HttpResponseBody field2)? + rhttpStatusCodeError, + TResult Function(String field0)? rhttpInvalidCertificateError, + TResult Function(String field0)? rhttpConnectionError, + TResult Function(String field0)? rhttpUnknownError, + required TResult orElse(), + }) { + if (rhttpTimeoutError != null) { + return rhttpTimeoutError(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(RhttpError_RhttpCancelError value) + rhttpCancelError, + required TResult Function(RhttpError_RhttpTimeoutError value) + rhttpTimeoutError, + required TResult Function(RhttpError_RhttpRedirectError value) + rhttpRedirectError, + required TResult Function(RhttpError_RhttpStatusCodeError value) + rhttpStatusCodeError, + required TResult Function(RhttpError_RhttpInvalidCertificateError value) + rhttpInvalidCertificateError, + required TResult Function(RhttpError_RhttpConnectionError value) + rhttpConnectionError, + required TResult Function(RhttpError_RhttpUnknownError value) + rhttpUnknownError, + }) { + return rhttpTimeoutError(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(RhttpError_RhttpCancelError value)? rhttpCancelError, + TResult? Function(RhttpError_RhttpTimeoutError value)? rhttpTimeoutError, + TResult? Function(RhttpError_RhttpRedirectError value)? rhttpRedirectError, + TResult? Function(RhttpError_RhttpStatusCodeError value)? + rhttpStatusCodeError, + TResult? Function(RhttpError_RhttpInvalidCertificateError value)? + rhttpInvalidCertificateError, + TResult? Function(RhttpError_RhttpConnectionError value)? + rhttpConnectionError, + TResult? Function(RhttpError_RhttpUnknownError value)? rhttpUnknownError, + }) { + return rhttpTimeoutError?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(RhttpError_RhttpCancelError value)? rhttpCancelError, + TResult Function(RhttpError_RhttpTimeoutError value)? rhttpTimeoutError, + TResult Function(RhttpError_RhttpRedirectError value)? rhttpRedirectError, + TResult Function(RhttpError_RhttpStatusCodeError value)? + rhttpStatusCodeError, + TResult Function(RhttpError_RhttpInvalidCertificateError value)? + rhttpInvalidCertificateError, + TResult Function(RhttpError_RhttpConnectionError value)? + rhttpConnectionError, + TResult Function(RhttpError_RhttpUnknownError value)? rhttpUnknownError, + required TResult orElse(), + }) { + if (rhttpTimeoutError != null) { + return rhttpTimeoutError(this); + } + return orElse(); + } +} + +abstract class RhttpError_RhttpTimeoutError extends RhttpError { + const factory RhttpError_RhttpTimeoutError() = + _$RhttpError_RhttpTimeoutErrorImpl; + const RhttpError_RhttpTimeoutError._() : super._(); +} + +/// @nodoc +abstract class _$$RhttpError_RhttpRedirectErrorImplCopyWith<$Res> { + factory _$$RhttpError_RhttpRedirectErrorImplCopyWith( + _$RhttpError_RhttpRedirectErrorImpl value, + $Res Function(_$RhttpError_RhttpRedirectErrorImpl) then) = + __$$RhttpError_RhttpRedirectErrorImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$RhttpError_RhttpRedirectErrorImplCopyWithImpl<$Res> + extends _$RhttpErrorCopyWithImpl<$Res, _$RhttpError_RhttpRedirectErrorImpl> + implements _$$RhttpError_RhttpRedirectErrorImplCopyWith<$Res> { + __$$RhttpError_RhttpRedirectErrorImplCopyWithImpl( + _$RhttpError_RhttpRedirectErrorImpl _value, + $Res Function(_$RhttpError_RhttpRedirectErrorImpl) _then) + : super(_value, _then); + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$RhttpError_RhttpRedirectErrorImpl + extends RhttpError_RhttpRedirectError { + const _$RhttpError_RhttpRedirectErrorImpl() : super._(); + + @override + String toString() { + return 'RhttpError.rhttpRedirectError()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RhttpError_RhttpRedirectErrorImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() rhttpCancelError, + required TResult Function() rhttpTimeoutError, + required TResult Function() rhttpRedirectError, + required TResult Function( + int field0, List<(String, String)> field1, HttpResponseBody field2) + rhttpStatusCodeError, + required TResult Function(String field0) rhttpInvalidCertificateError, + required TResult Function(String field0) rhttpConnectionError, + required TResult Function(String field0) rhttpUnknownError, + }) { + return rhttpRedirectError(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? rhttpCancelError, + TResult? Function()? rhttpTimeoutError, + TResult? Function()? rhttpRedirectError, + TResult? Function( + int field0, List<(String, String)> field1, HttpResponseBody field2)? + rhttpStatusCodeError, + TResult? Function(String field0)? rhttpInvalidCertificateError, + TResult? Function(String field0)? rhttpConnectionError, + TResult? Function(String field0)? rhttpUnknownError, + }) { + return rhttpRedirectError?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? rhttpCancelError, + TResult Function()? rhttpTimeoutError, + TResult Function()? rhttpRedirectError, + TResult Function( + int field0, List<(String, String)> field1, HttpResponseBody field2)? + rhttpStatusCodeError, + TResult Function(String field0)? rhttpInvalidCertificateError, + TResult Function(String field0)? rhttpConnectionError, + TResult Function(String field0)? rhttpUnknownError, + required TResult orElse(), + }) { + if (rhttpRedirectError != null) { + return rhttpRedirectError(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(RhttpError_RhttpCancelError value) + rhttpCancelError, + required TResult Function(RhttpError_RhttpTimeoutError value) + rhttpTimeoutError, + required TResult Function(RhttpError_RhttpRedirectError value) + rhttpRedirectError, + required TResult Function(RhttpError_RhttpStatusCodeError value) + rhttpStatusCodeError, + required TResult Function(RhttpError_RhttpInvalidCertificateError value) + rhttpInvalidCertificateError, + required TResult Function(RhttpError_RhttpConnectionError value) + rhttpConnectionError, + required TResult Function(RhttpError_RhttpUnknownError value) + rhttpUnknownError, + }) { + return rhttpRedirectError(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(RhttpError_RhttpCancelError value)? rhttpCancelError, + TResult? Function(RhttpError_RhttpTimeoutError value)? rhttpTimeoutError, + TResult? Function(RhttpError_RhttpRedirectError value)? rhttpRedirectError, + TResult? Function(RhttpError_RhttpStatusCodeError value)? + rhttpStatusCodeError, + TResult? Function(RhttpError_RhttpInvalidCertificateError value)? + rhttpInvalidCertificateError, + TResult? Function(RhttpError_RhttpConnectionError value)? + rhttpConnectionError, + TResult? Function(RhttpError_RhttpUnknownError value)? rhttpUnknownError, + }) { + return rhttpRedirectError?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(RhttpError_RhttpCancelError value)? rhttpCancelError, + TResult Function(RhttpError_RhttpTimeoutError value)? rhttpTimeoutError, + TResult Function(RhttpError_RhttpRedirectError value)? rhttpRedirectError, + TResult Function(RhttpError_RhttpStatusCodeError value)? + rhttpStatusCodeError, + TResult Function(RhttpError_RhttpInvalidCertificateError value)? + rhttpInvalidCertificateError, + TResult Function(RhttpError_RhttpConnectionError value)? + rhttpConnectionError, + TResult Function(RhttpError_RhttpUnknownError value)? rhttpUnknownError, + required TResult orElse(), + }) { + if (rhttpRedirectError != null) { + return rhttpRedirectError(this); + } + return orElse(); + } +} + +abstract class RhttpError_RhttpRedirectError extends RhttpError { + const factory RhttpError_RhttpRedirectError() = + _$RhttpError_RhttpRedirectErrorImpl; + const RhttpError_RhttpRedirectError._() : super._(); +} + +/// @nodoc +abstract class _$$RhttpError_RhttpStatusCodeErrorImplCopyWith<$Res> { + factory _$$RhttpError_RhttpStatusCodeErrorImplCopyWith( + _$RhttpError_RhttpStatusCodeErrorImpl value, + $Res Function(_$RhttpError_RhttpStatusCodeErrorImpl) then) = + __$$RhttpError_RhttpStatusCodeErrorImplCopyWithImpl<$Res>; + @useResult + $Res call( + {int field0, List<(String, String)> field1, HttpResponseBody field2}); + + $HttpResponseBodyCopyWith<$Res> get field2; +} + +/// @nodoc +class __$$RhttpError_RhttpStatusCodeErrorImplCopyWithImpl<$Res> + extends _$RhttpErrorCopyWithImpl<$Res, + _$RhttpError_RhttpStatusCodeErrorImpl> + implements _$$RhttpError_RhttpStatusCodeErrorImplCopyWith<$Res> { + __$$RhttpError_RhttpStatusCodeErrorImplCopyWithImpl( + _$RhttpError_RhttpStatusCodeErrorImpl _value, + $Res Function(_$RhttpError_RhttpStatusCodeErrorImpl) _then) + : super(_value, _then); + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? field0 = null, + Object? field1 = null, + Object? field2 = null, + }) { + return _then(_$RhttpError_RhttpStatusCodeErrorImpl( + null == field0 + ? _value.field0 + : field0 // ignore: cast_nullable_to_non_nullable + as int, + null == field1 + ? _value._field1 + : field1 // ignore: cast_nullable_to_non_nullable + as List<(String, String)>, + null == field2 + ? _value.field2 + : field2 // ignore: cast_nullable_to_non_nullable + as HttpResponseBody, + )); + } + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $HttpResponseBodyCopyWith<$Res> get field2 { + return $HttpResponseBodyCopyWith<$Res>(_value.field2, (value) { + return _then(_value.copyWith(field2: value)); + }); + } +} + +/// @nodoc + +class _$RhttpError_RhttpStatusCodeErrorImpl + extends RhttpError_RhttpStatusCodeError { + const _$RhttpError_RhttpStatusCodeErrorImpl( + this.field0, final List<(String, String)> field1, this.field2) + : _field1 = field1, + super._(); + + @override + final int field0; + final List<(String, String)> _field1; + @override + List<(String, String)> get field1 { + if (_field1 is EqualUnmodifiableListView) return _field1; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_field1); + } + + @override + final HttpResponseBody field2; + + @override + String toString() { + return 'RhttpError.rhttpStatusCodeError(field0: $field0, field1: $field1, field2: $field2)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RhttpError_RhttpStatusCodeErrorImpl && + (identical(other.field0, field0) || other.field0 == field0) && + const DeepCollectionEquality().equals(other._field1, _field1) && + (identical(other.field2, field2) || other.field2 == field2)); + } + + @override + int get hashCode => Object.hash(runtimeType, field0, + const DeepCollectionEquality().hash(_field1), field2); + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$RhttpError_RhttpStatusCodeErrorImplCopyWith< + _$RhttpError_RhttpStatusCodeErrorImpl> + get copyWith => __$$RhttpError_RhttpStatusCodeErrorImplCopyWithImpl< + _$RhttpError_RhttpStatusCodeErrorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() rhttpCancelError, + required TResult Function() rhttpTimeoutError, + required TResult Function() rhttpRedirectError, + required TResult Function( + int field0, List<(String, String)> field1, HttpResponseBody field2) + rhttpStatusCodeError, + required TResult Function(String field0) rhttpInvalidCertificateError, + required TResult Function(String field0) rhttpConnectionError, + required TResult Function(String field0) rhttpUnknownError, + }) { + return rhttpStatusCodeError(field0, field1, field2); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? rhttpCancelError, + TResult? Function()? rhttpTimeoutError, + TResult? Function()? rhttpRedirectError, + TResult? Function( + int field0, List<(String, String)> field1, HttpResponseBody field2)? + rhttpStatusCodeError, + TResult? Function(String field0)? rhttpInvalidCertificateError, + TResult? Function(String field0)? rhttpConnectionError, + TResult? Function(String field0)? rhttpUnknownError, + }) { + return rhttpStatusCodeError?.call(field0, field1, field2); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? rhttpCancelError, + TResult Function()? rhttpTimeoutError, + TResult Function()? rhttpRedirectError, + TResult Function( + int field0, List<(String, String)> field1, HttpResponseBody field2)? + rhttpStatusCodeError, + TResult Function(String field0)? rhttpInvalidCertificateError, + TResult Function(String field0)? rhttpConnectionError, + TResult Function(String field0)? rhttpUnknownError, + required TResult orElse(), + }) { + if (rhttpStatusCodeError != null) { + return rhttpStatusCodeError(field0, field1, field2); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(RhttpError_RhttpCancelError value) + rhttpCancelError, + required TResult Function(RhttpError_RhttpTimeoutError value) + rhttpTimeoutError, + required TResult Function(RhttpError_RhttpRedirectError value) + rhttpRedirectError, + required TResult Function(RhttpError_RhttpStatusCodeError value) + rhttpStatusCodeError, + required TResult Function(RhttpError_RhttpInvalidCertificateError value) + rhttpInvalidCertificateError, + required TResult Function(RhttpError_RhttpConnectionError value) + rhttpConnectionError, + required TResult Function(RhttpError_RhttpUnknownError value) + rhttpUnknownError, + }) { + return rhttpStatusCodeError(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(RhttpError_RhttpCancelError value)? rhttpCancelError, + TResult? Function(RhttpError_RhttpTimeoutError value)? rhttpTimeoutError, + TResult? Function(RhttpError_RhttpRedirectError value)? rhttpRedirectError, + TResult? Function(RhttpError_RhttpStatusCodeError value)? + rhttpStatusCodeError, + TResult? Function(RhttpError_RhttpInvalidCertificateError value)? + rhttpInvalidCertificateError, + TResult? Function(RhttpError_RhttpConnectionError value)? + rhttpConnectionError, + TResult? Function(RhttpError_RhttpUnknownError value)? rhttpUnknownError, + }) { + return rhttpStatusCodeError?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(RhttpError_RhttpCancelError value)? rhttpCancelError, + TResult Function(RhttpError_RhttpTimeoutError value)? rhttpTimeoutError, + TResult Function(RhttpError_RhttpRedirectError value)? rhttpRedirectError, + TResult Function(RhttpError_RhttpStatusCodeError value)? + rhttpStatusCodeError, + TResult Function(RhttpError_RhttpInvalidCertificateError value)? + rhttpInvalidCertificateError, + TResult Function(RhttpError_RhttpConnectionError value)? + rhttpConnectionError, + TResult Function(RhttpError_RhttpUnknownError value)? rhttpUnknownError, + required TResult orElse(), + }) { + if (rhttpStatusCodeError != null) { + return rhttpStatusCodeError(this); + } + return orElse(); + } +} + +abstract class RhttpError_RhttpStatusCodeError extends RhttpError { + const factory RhttpError_RhttpStatusCodeError( + final int field0, + final List<(String, String)> field1, + final HttpResponseBody field2) = _$RhttpError_RhttpStatusCodeErrorImpl; + const RhttpError_RhttpStatusCodeError._() : super._(); + + int get field0; + List<(String, String)> get field1; + HttpResponseBody get field2; + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$RhttpError_RhttpStatusCodeErrorImplCopyWith< + _$RhttpError_RhttpStatusCodeErrorImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$RhttpError_RhttpInvalidCertificateErrorImplCopyWith<$Res> { + factory _$$RhttpError_RhttpInvalidCertificateErrorImplCopyWith( + _$RhttpError_RhttpInvalidCertificateErrorImpl value, + $Res Function(_$RhttpError_RhttpInvalidCertificateErrorImpl) then) = + __$$RhttpError_RhttpInvalidCertificateErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String field0}); +} + +/// @nodoc +class __$$RhttpError_RhttpInvalidCertificateErrorImplCopyWithImpl<$Res> + extends _$RhttpErrorCopyWithImpl<$Res, + _$RhttpError_RhttpInvalidCertificateErrorImpl> + implements _$$RhttpError_RhttpInvalidCertificateErrorImplCopyWith<$Res> { + __$$RhttpError_RhttpInvalidCertificateErrorImplCopyWithImpl( + _$RhttpError_RhttpInvalidCertificateErrorImpl _value, + $Res Function(_$RhttpError_RhttpInvalidCertificateErrorImpl) _then) + : super(_value, _then); + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? field0 = null, + }) { + return _then(_$RhttpError_RhttpInvalidCertificateErrorImpl( + null == field0 + ? _value.field0 + : field0 // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$RhttpError_RhttpInvalidCertificateErrorImpl + extends RhttpError_RhttpInvalidCertificateError { + const _$RhttpError_RhttpInvalidCertificateErrorImpl(this.field0) : super._(); + + @override + final String field0; + + @override + String toString() { + return 'RhttpError.rhttpInvalidCertificateError(field0: $field0)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RhttpError_RhttpInvalidCertificateErrorImpl && + (identical(other.field0, field0) || other.field0 == field0)); + } + + @override + int get hashCode => Object.hash(runtimeType, field0); + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$RhttpError_RhttpInvalidCertificateErrorImplCopyWith< + _$RhttpError_RhttpInvalidCertificateErrorImpl> + get copyWith => + __$$RhttpError_RhttpInvalidCertificateErrorImplCopyWithImpl< + _$RhttpError_RhttpInvalidCertificateErrorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() rhttpCancelError, + required TResult Function() rhttpTimeoutError, + required TResult Function() rhttpRedirectError, + required TResult Function( + int field0, List<(String, String)> field1, HttpResponseBody field2) + rhttpStatusCodeError, + required TResult Function(String field0) rhttpInvalidCertificateError, + required TResult Function(String field0) rhttpConnectionError, + required TResult Function(String field0) rhttpUnknownError, + }) { + return rhttpInvalidCertificateError(field0); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? rhttpCancelError, + TResult? Function()? rhttpTimeoutError, + TResult? Function()? rhttpRedirectError, + TResult? Function( + int field0, List<(String, String)> field1, HttpResponseBody field2)? + rhttpStatusCodeError, + TResult? Function(String field0)? rhttpInvalidCertificateError, + TResult? Function(String field0)? rhttpConnectionError, + TResult? Function(String field0)? rhttpUnknownError, + }) { + return rhttpInvalidCertificateError?.call(field0); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? rhttpCancelError, + TResult Function()? rhttpTimeoutError, + TResult Function()? rhttpRedirectError, + TResult Function( + int field0, List<(String, String)> field1, HttpResponseBody field2)? + rhttpStatusCodeError, + TResult Function(String field0)? rhttpInvalidCertificateError, + TResult Function(String field0)? rhttpConnectionError, + TResult Function(String field0)? rhttpUnknownError, + required TResult orElse(), + }) { + if (rhttpInvalidCertificateError != null) { + return rhttpInvalidCertificateError(field0); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(RhttpError_RhttpCancelError value) + rhttpCancelError, + required TResult Function(RhttpError_RhttpTimeoutError value) + rhttpTimeoutError, + required TResult Function(RhttpError_RhttpRedirectError value) + rhttpRedirectError, + required TResult Function(RhttpError_RhttpStatusCodeError value) + rhttpStatusCodeError, + required TResult Function(RhttpError_RhttpInvalidCertificateError value) + rhttpInvalidCertificateError, + required TResult Function(RhttpError_RhttpConnectionError value) + rhttpConnectionError, + required TResult Function(RhttpError_RhttpUnknownError value) + rhttpUnknownError, + }) { + return rhttpInvalidCertificateError(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(RhttpError_RhttpCancelError value)? rhttpCancelError, + TResult? Function(RhttpError_RhttpTimeoutError value)? rhttpTimeoutError, + TResult? Function(RhttpError_RhttpRedirectError value)? rhttpRedirectError, + TResult? Function(RhttpError_RhttpStatusCodeError value)? + rhttpStatusCodeError, + TResult? Function(RhttpError_RhttpInvalidCertificateError value)? + rhttpInvalidCertificateError, + TResult? Function(RhttpError_RhttpConnectionError value)? + rhttpConnectionError, + TResult? Function(RhttpError_RhttpUnknownError value)? rhttpUnknownError, + }) { + return rhttpInvalidCertificateError?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(RhttpError_RhttpCancelError value)? rhttpCancelError, + TResult Function(RhttpError_RhttpTimeoutError value)? rhttpTimeoutError, + TResult Function(RhttpError_RhttpRedirectError value)? rhttpRedirectError, + TResult Function(RhttpError_RhttpStatusCodeError value)? + rhttpStatusCodeError, + TResult Function(RhttpError_RhttpInvalidCertificateError value)? + rhttpInvalidCertificateError, + TResult Function(RhttpError_RhttpConnectionError value)? + rhttpConnectionError, + TResult Function(RhttpError_RhttpUnknownError value)? rhttpUnknownError, + required TResult orElse(), + }) { + if (rhttpInvalidCertificateError != null) { + return rhttpInvalidCertificateError(this); + } + return orElse(); + } +} + +abstract class RhttpError_RhttpInvalidCertificateError extends RhttpError { + const factory RhttpError_RhttpInvalidCertificateError(final String field0) = + _$RhttpError_RhttpInvalidCertificateErrorImpl; + const RhttpError_RhttpInvalidCertificateError._() : super._(); + + String get field0; + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$RhttpError_RhttpInvalidCertificateErrorImplCopyWith< + _$RhttpError_RhttpInvalidCertificateErrorImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$RhttpError_RhttpConnectionErrorImplCopyWith<$Res> { + factory _$$RhttpError_RhttpConnectionErrorImplCopyWith( + _$RhttpError_RhttpConnectionErrorImpl value, + $Res Function(_$RhttpError_RhttpConnectionErrorImpl) then) = + __$$RhttpError_RhttpConnectionErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String field0}); +} + +/// @nodoc +class __$$RhttpError_RhttpConnectionErrorImplCopyWithImpl<$Res> + extends _$RhttpErrorCopyWithImpl<$Res, + _$RhttpError_RhttpConnectionErrorImpl> + implements _$$RhttpError_RhttpConnectionErrorImplCopyWith<$Res> { + __$$RhttpError_RhttpConnectionErrorImplCopyWithImpl( + _$RhttpError_RhttpConnectionErrorImpl _value, + $Res Function(_$RhttpError_RhttpConnectionErrorImpl) _then) + : super(_value, _then); + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? field0 = null, + }) { + return _then(_$RhttpError_RhttpConnectionErrorImpl( + null == field0 + ? _value.field0 + : field0 // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$RhttpError_RhttpConnectionErrorImpl + extends RhttpError_RhttpConnectionError { + const _$RhttpError_RhttpConnectionErrorImpl(this.field0) : super._(); + + @override + final String field0; + + @override + String toString() { + return 'RhttpError.rhttpConnectionError(field0: $field0)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RhttpError_RhttpConnectionErrorImpl && + (identical(other.field0, field0) || other.field0 == field0)); + } + + @override + int get hashCode => Object.hash(runtimeType, field0); + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$RhttpError_RhttpConnectionErrorImplCopyWith< + _$RhttpError_RhttpConnectionErrorImpl> + get copyWith => __$$RhttpError_RhttpConnectionErrorImplCopyWithImpl< + _$RhttpError_RhttpConnectionErrorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() rhttpCancelError, + required TResult Function() rhttpTimeoutError, + required TResult Function() rhttpRedirectError, + required TResult Function( + int field0, List<(String, String)> field1, HttpResponseBody field2) + rhttpStatusCodeError, + required TResult Function(String field0) rhttpInvalidCertificateError, + required TResult Function(String field0) rhttpConnectionError, + required TResult Function(String field0) rhttpUnknownError, + }) { + return rhttpConnectionError(field0); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? rhttpCancelError, + TResult? Function()? rhttpTimeoutError, + TResult? Function()? rhttpRedirectError, + TResult? Function( + int field0, List<(String, String)> field1, HttpResponseBody field2)? + rhttpStatusCodeError, + TResult? Function(String field0)? rhttpInvalidCertificateError, + TResult? Function(String field0)? rhttpConnectionError, + TResult? Function(String field0)? rhttpUnknownError, + }) { + return rhttpConnectionError?.call(field0); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? rhttpCancelError, + TResult Function()? rhttpTimeoutError, + TResult Function()? rhttpRedirectError, + TResult Function( + int field0, List<(String, String)> field1, HttpResponseBody field2)? + rhttpStatusCodeError, + TResult Function(String field0)? rhttpInvalidCertificateError, + TResult Function(String field0)? rhttpConnectionError, + TResult Function(String field0)? rhttpUnknownError, + required TResult orElse(), + }) { + if (rhttpConnectionError != null) { + return rhttpConnectionError(field0); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(RhttpError_RhttpCancelError value) + rhttpCancelError, + required TResult Function(RhttpError_RhttpTimeoutError value) + rhttpTimeoutError, + required TResult Function(RhttpError_RhttpRedirectError value) + rhttpRedirectError, + required TResult Function(RhttpError_RhttpStatusCodeError value) + rhttpStatusCodeError, + required TResult Function(RhttpError_RhttpInvalidCertificateError value) + rhttpInvalidCertificateError, + required TResult Function(RhttpError_RhttpConnectionError value) + rhttpConnectionError, + required TResult Function(RhttpError_RhttpUnknownError value) + rhttpUnknownError, + }) { + return rhttpConnectionError(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(RhttpError_RhttpCancelError value)? rhttpCancelError, + TResult? Function(RhttpError_RhttpTimeoutError value)? rhttpTimeoutError, + TResult? Function(RhttpError_RhttpRedirectError value)? rhttpRedirectError, + TResult? Function(RhttpError_RhttpStatusCodeError value)? + rhttpStatusCodeError, + TResult? Function(RhttpError_RhttpInvalidCertificateError value)? + rhttpInvalidCertificateError, + TResult? Function(RhttpError_RhttpConnectionError value)? + rhttpConnectionError, + TResult? Function(RhttpError_RhttpUnknownError value)? rhttpUnknownError, + }) { + return rhttpConnectionError?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(RhttpError_RhttpCancelError value)? rhttpCancelError, + TResult Function(RhttpError_RhttpTimeoutError value)? rhttpTimeoutError, + TResult Function(RhttpError_RhttpRedirectError value)? rhttpRedirectError, + TResult Function(RhttpError_RhttpStatusCodeError value)? + rhttpStatusCodeError, + TResult Function(RhttpError_RhttpInvalidCertificateError value)? + rhttpInvalidCertificateError, + TResult Function(RhttpError_RhttpConnectionError value)? + rhttpConnectionError, + TResult Function(RhttpError_RhttpUnknownError value)? rhttpUnknownError, + required TResult orElse(), + }) { + if (rhttpConnectionError != null) { + return rhttpConnectionError(this); + } + return orElse(); + } +} + +abstract class RhttpError_RhttpConnectionError extends RhttpError { + const factory RhttpError_RhttpConnectionError(final String field0) = + _$RhttpError_RhttpConnectionErrorImpl; + const RhttpError_RhttpConnectionError._() : super._(); + + String get field0; + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$RhttpError_RhttpConnectionErrorImplCopyWith< + _$RhttpError_RhttpConnectionErrorImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$RhttpError_RhttpUnknownErrorImplCopyWith<$Res> { + factory _$$RhttpError_RhttpUnknownErrorImplCopyWith( + _$RhttpError_RhttpUnknownErrorImpl value, + $Res Function(_$RhttpError_RhttpUnknownErrorImpl) then) = + __$$RhttpError_RhttpUnknownErrorImplCopyWithImpl<$Res>; + @useResult + $Res call({String field0}); +} + +/// @nodoc +class __$$RhttpError_RhttpUnknownErrorImplCopyWithImpl<$Res> + extends _$RhttpErrorCopyWithImpl<$Res, _$RhttpError_RhttpUnknownErrorImpl> + implements _$$RhttpError_RhttpUnknownErrorImplCopyWith<$Res> { + __$$RhttpError_RhttpUnknownErrorImplCopyWithImpl( + _$RhttpError_RhttpUnknownErrorImpl _value, + $Res Function(_$RhttpError_RhttpUnknownErrorImpl) _then) + : super(_value, _then); + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? field0 = null, + }) { + return _then(_$RhttpError_RhttpUnknownErrorImpl( + null == field0 + ? _value.field0 + : field0 // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$RhttpError_RhttpUnknownErrorImpl extends RhttpError_RhttpUnknownError { + const _$RhttpError_RhttpUnknownErrorImpl(this.field0) : super._(); + + @override + final String field0; + + @override + String toString() { + return 'RhttpError.rhttpUnknownError(field0: $field0)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$RhttpError_RhttpUnknownErrorImpl && + (identical(other.field0, field0) || other.field0 == field0)); + } + + @override + int get hashCode => Object.hash(runtimeType, field0); + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$RhttpError_RhttpUnknownErrorImplCopyWith< + _$RhttpError_RhttpUnknownErrorImpl> + get copyWith => __$$RhttpError_RhttpUnknownErrorImplCopyWithImpl< + _$RhttpError_RhttpUnknownErrorImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() rhttpCancelError, + required TResult Function() rhttpTimeoutError, + required TResult Function() rhttpRedirectError, + required TResult Function( + int field0, List<(String, String)> field1, HttpResponseBody field2) + rhttpStatusCodeError, + required TResult Function(String field0) rhttpInvalidCertificateError, + required TResult Function(String field0) rhttpConnectionError, + required TResult Function(String field0) rhttpUnknownError, + }) { + return rhttpUnknownError(field0); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? rhttpCancelError, + TResult? Function()? rhttpTimeoutError, + TResult? Function()? rhttpRedirectError, + TResult? Function( + int field0, List<(String, String)> field1, HttpResponseBody field2)? + rhttpStatusCodeError, + TResult? Function(String field0)? rhttpInvalidCertificateError, + TResult? Function(String field0)? rhttpConnectionError, + TResult? Function(String field0)? rhttpUnknownError, + }) { + return rhttpUnknownError?.call(field0); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? rhttpCancelError, + TResult Function()? rhttpTimeoutError, + TResult Function()? rhttpRedirectError, + TResult Function( + int field0, List<(String, String)> field1, HttpResponseBody field2)? + rhttpStatusCodeError, + TResult Function(String field0)? rhttpInvalidCertificateError, + TResult Function(String field0)? rhttpConnectionError, + TResult Function(String field0)? rhttpUnknownError, + required TResult orElse(), + }) { + if (rhttpUnknownError != null) { + return rhttpUnknownError(field0); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(RhttpError_RhttpCancelError value) + rhttpCancelError, + required TResult Function(RhttpError_RhttpTimeoutError value) + rhttpTimeoutError, + required TResult Function(RhttpError_RhttpRedirectError value) + rhttpRedirectError, + required TResult Function(RhttpError_RhttpStatusCodeError value) + rhttpStatusCodeError, + required TResult Function(RhttpError_RhttpInvalidCertificateError value) + rhttpInvalidCertificateError, + required TResult Function(RhttpError_RhttpConnectionError value) + rhttpConnectionError, + required TResult Function(RhttpError_RhttpUnknownError value) + rhttpUnknownError, + }) { + return rhttpUnknownError(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(RhttpError_RhttpCancelError value)? rhttpCancelError, + TResult? Function(RhttpError_RhttpTimeoutError value)? rhttpTimeoutError, + TResult? Function(RhttpError_RhttpRedirectError value)? rhttpRedirectError, + TResult? Function(RhttpError_RhttpStatusCodeError value)? + rhttpStatusCodeError, + TResult? Function(RhttpError_RhttpInvalidCertificateError value)? + rhttpInvalidCertificateError, + TResult? Function(RhttpError_RhttpConnectionError value)? + rhttpConnectionError, + TResult? Function(RhttpError_RhttpUnknownError value)? rhttpUnknownError, + }) { + return rhttpUnknownError?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(RhttpError_RhttpCancelError value)? rhttpCancelError, + TResult Function(RhttpError_RhttpTimeoutError value)? rhttpTimeoutError, + TResult Function(RhttpError_RhttpRedirectError value)? rhttpRedirectError, + TResult Function(RhttpError_RhttpStatusCodeError value)? + rhttpStatusCodeError, + TResult Function(RhttpError_RhttpInvalidCertificateError value)? + rhttpInvalidCertificateError, + TResult Function(RhttpError_RhttpConnectionError value)? + rhttpConnectionError, + TResult Function(RhttpError_RhttpUnknownError value)? rhttpUnknownError, + required TResult orElse(), + }) { + if (rhttpUnknownError != null) { + return rhttpUnknownError(this); + } + return orElse(); + } +} + +abstract class RhttpError_RhttpUnknownError extends RhttpError { + const factory RhttpError_RhttpUnknownError(final String field0) = + _$RhttpError_RhttpUnknownErrorImpl; + const RhttpError_RhttpUnknownError._() : super._(); + + String get field0; + + /// Create a copy of RhttpError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$RhttpError_RhttpUnknownErrorImplCopyWith< + _$RhttpError_RhttpUnknownErrorImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/src/rust/api/rhttp/http.dart b/lib/src/rust/api/rhttp/http.dart new file mode 100644 index 00000000..0ed5faf7 --- /dev/null +++ b/lib/src/rust/api/rhttp/http.dart @@ -0,0 +1,128 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.3.0. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import '../../frb_generated.dart'; +import '../../lib.dart'; +import 'client.dart'; +import 'error.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import 'package:freezed_annotation/freezed_annotation.dart' hide protected; +part 'http.freezed.dart'; + +// These functions are ignored because they are not marked as `pub`: `build_cancel_tokens`, `from_version`, `header_to_vec`, `make_http_request_helper`, `make_http_request_receive_stream_inner`, `register_client_internal`, `to_method` +// These types are ignored because they are not used by any `pub` functions: `HttpExpectBody`, `RequestCancelTokens` +// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `clone`, `fmt` + +Future registerClient({required ClientSettings settings}) => + RustLib.instance.api.crateApiRhttpHttpRegisterClient(settings: settings); + +RequestClient registerClientSync({required ClientSettings settings}) => + RustLib.instance.api + .crateApiRhttpHttpRegisterClientSync(settings: settings); + +Future cancelRunningRequests({required RequestClient client}) => + RustLib.instance.api.crateApiRhttpHttpCancelRunningRequests(client: client); + +Stream makeHttpRequestReceiveStream( + {RequestClient? client, + ClientSettings? settings, + required HttpMethod method, + required String url, + List<(String, String)>? query, + HttpHeaders? headers, + Uint8List? body, + required FutureOr Function(HttpResponse) onResponse, + required FutureOr Function(RhttpError) onError, + required FutureOr Function(CancellationToken) onCancelToken, + required bool cancelable}) => + RustLib.instance.api.crateApiRhttpHttpMakeHttpRequestReceiveStream( + client: client, + settings: settings, + method: method, + url: url, + query: query, + headers: headers, + body: body, + onResponse: onResponse, + onError: onError, + onCancelToken: onCancelToken, + cancelable: cancelable); + +Future cancelRequest({required CancellationToken token}) => + RustLib.instance.api.crateApiRhttpHttpCancelRequest(token: token); + +@freezed +sealed class HttpHeaders with _$HttpHeaders { + const HttpHeaders._(); + + const factory HttpHeaders.map( + Map field0, + ) = HttpHeaders_Map; + const factory HttpHeaders.list( + List<(String, String)> field0, + ) = HttpHeaders_List; +} + +enum HttpMethod { + options, + get_, + post, + put, + delete, + head, + trace, + connect, + patch, + ; +} + +class HttpResponse { + final List<(String, String)> headers; + final HttpVersion version; + final int statusCode; + final HttpResponseBody body; + + const HttpResponse({ + required this.headers, + required this.version, + required this.statusCode, + required this.body, + }); + + @override + int get hashCode => + headers.hashCode ^ version.hashCode ^ statusCode.hashCode ^ body.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is HttpResponse && + runtimeType == other.runtimeType && + headers == other.headers && + version == other.version && + statusCode == other.statusCode && + body == other.body; +} + +@freezed +sealed class HttpResponseBody with _$HttpResponseBody { + const HttpResponseBody._(); + + const factory HttpResponseBody.text( + String field0, + ) = HttpResponseBody_Text; + const factory HttpResponseBody.bytes( + Uint8List field0, + ) = HttpResponseBody_Bytes; + const factory HttpResponseBody.stream() = HttpResponseBody_Stream; +} + +enum HttpVersion { + http09, + http10, + http11, + other, + ; +} diff --git a/lib/src/rust/api/rhttp/http.freezed.dart b/lib/src/rust/api/rhttp/http.freezed.dart new file mode 100644 index 00000000..d6941458 --- /dev/null +++ b/lib/src/rust/api/rhttp/http.freezed.dart @@ -0,0 +1,869 @@ +// 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 'http.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 _$HttpHeaders { + Object get field0 => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult when({ + required TResult Function(Map field0) map, + required TResult Function(List<(String, String)> field0) list, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(Map field0)? map, + TResult? Function(List<(String, String)> field0)? list, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(Map field0)? map, + TResult Function(List<(String, String)> field0)? list, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(HttpHeaders_Map value) map, + required TResult Function(HttpHeaders_List value) list, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(HttpHeaders_Map value)? map, + TResult? Function(HttpHeaders_List value)? list, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(HttpHeaders_Map value)? map, + TResult Function(HttpHeaders_List value)? list, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $HttpHeadersCopyWith<$Res> { + factory $HttpHeadersCopyWith( + HttpHeaders value, $Res Function(HttpHeaders) then) = + _$HttpHeadersCopyWithImpl<$Res, HttpHeaders>; +} + +/// @nodoc +class _$HttpHeadersCopyWithImpl<$Res, $Val extends HttpHeaders> + implements $HttpHeadersCopyWith<$Res> { + _$HttpHeadersCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of HttpHeaders + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$HttpHeaders_MapImplCopyWith<$Res> { + factory _$$HttpHeaders_MapImplCopyWith(_$HttpHeaders_MapImpl value, + $Res Function(_$HttpHeaders_MapImpl) then) = + __$$HttpHeaders_MapImplCopyWithImpl<$Res>; + @useResult + $Res call({Map field0}); +} + +/// @nodoc +class __$$HttpHeaders_MapImplCopyWithImpl<$Res> + extends _$HttpHeadersCopyWithImpl<$Res, _$HttpHeaders_MapImpl> + implements _$$HttpHeaders_MapImplCopyWith<$Res> { + __$$HttpHeaders_MapImplCopyWithImpl( + _$HttpHeaders_MapImpl _value, $Res Function(_$HttpHeaders_MapImpl) _then) + : super(_value, _then); + + /// Create a copy of HttpHeaders + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? field0 = null, + }) { + return _then(_$HttpHeaders_MapImpl( + null == field0 + ? _value._field0 + : field0 // ignore: cast_nullable_to_non_nullable + as Map, + )); + } +} + +/// @nodoc + +class _$HttpHeaders_MapImpl extends HttpHeaders_Map { + const _$HttpHeaders_MapImpl(final Map field0) + : _field0 = field0, + super._(); + + final Map _field0; + @override + Map get field0 { + if (_field0 is EqualUnmodifiableMapView) return _field0; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_field0); + } + + @override + String toString() { + return 'HttpHeaders.map(field0: $field0)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$HttpHeaders_MapImpl && + const DeepCollectionEquality().equals(other._field0, _field0)); + } + + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(_field0)); + + /// Create a copy of HttpHeaders + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$HttpHeaders_MapImplCopyWith<_$HttpHeaders_MapImpl> get copyWith => + __$$HttpHeaders_MapImplCopyWithImpl<_$HttpHeaders_MapImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(Map field0) map, + required TResult Function(List<(String, String)> field0) list, + }) { + return map(field0); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(Map field0)? map, + TResult? Function(List<(String, String)> field0)? list, + }) { + return map?.call(field0); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(Map field0)? map, + TResult Function(List<(String, String)> field0)? list, + required TResult orElse(), + }) { + if (map != null) { + return map(field0); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(HttpHeaders_Map value) map, + required TResult Function(HttpHeaders_List value) list, + }) { + return map(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(HttpHeaders_Map value)? map, + TResult? Function(HttpHeaders_List value)? list, + }) { + return map?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(HttpHeaders_Map value)? map, + TResult Function(HttpHeaders_List value)? list, + required TResult orElse(), + }) { + if (map != null) { + return map(this); + } + return orElse(); + } +} + +abstract class HttpHeaders_Map extends HttpHeaders { + const factory HttpHeaders_Map(final Map field0) = + _$HttpHeaders_MapImpl; + const HttpHeaders_Map._() : super._(); + + @override + Map get field0; + + /// Create a copy of HttpHeaders + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$HttpHeaders_MapImplCopyWith<_$HttpHeaders_MapImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$HttpHeaders_ListImplCopyWith<$Res> { + factory _$$HttpHeaders_ListImplCopyWith(_$HttpHeaders_ListImpl value, + $Res Function(_$HttpHeaders_ListImpl) then) = + __$$HttpHeaders_ListImplCopyWithImpl<$Res>; + @useResult + $Res call({List<(String, String)> field0}); +} + +/// @nodoc +class __$$HttpHeaders_ListImplCopyWithImpl<$Res> + extends _$HttpHeadersCopyWithImpl<$Res, _$HttpHeaders_ListImpl> + implements _$$HttpHeaders_ListImplCopyWith<$Res> { + __$$HttpHeaders_ListImplCopyWithImpl(_$HttpHeaders_ListImpl _value, + $Res Function(_$HttpHeaders_ListImpl) _then) + : super(_value, _then); + + /// Create a copy of HttpHeaders + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? field0 = null, + }) { + return _then(_$HttpHeaders_ListImpl( + null == field0 + ? _value._field0 + : field0 // ignore: cast_nullable_to_non_nullable + as List<(String, String)>, + )); + } +} + +/// @nodoc + +class _$HttpHeaders_ListImpl extends HttpHeaders_List { + const _$HttpHeaders_ListImpl(final List<(String, String)> field0) + : _field0 = field0, + super._(); + + final List<(String, String)> _field0; + @override + List<(String, String)> get field0 { + if (_field0 is EqualUnmodifiableListView) return _field0; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_field0); + } + + @override + String toString() { + return 'HttpHeaders.list(field0: $field0)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$HttpHeaders_ListImpl && + const DeepCollectionEquality().equals(other._field0, _field0)); + } + + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(_field0)); + + /// Create a copy of HttpHeaders + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$HttpHeaders_ListImplCopyWith<_$HttpHeaders_ListImpl> get copyWith => + __$$HttpHeaders_ListImplCopyWithImpl<_$HttpHeaders_ListImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(Map field0) map, + required TResult Function(List<(String, String)> field0) list, + }) { + return list(field0); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(Map field0)? map, + TResult? Function(List<(String, String)> field0)? list, + }) { + return list?.call(field0); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(Map field0)? map, + TResult Function(List<(String, String)> field0)? list, + required TResult orElse(), + }) { + if (list != null) { + return list(field0); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(HttpHeaders_Map value) map, + required TResult Function(HttpHeaders_List value) list, + }) { + return list(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(HttpHeaders_Map value)? map, + TResult? Function(HttpHeaders_List value)? list, + }) { + return list?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(HttpHeaders_Map value)? map, + TResult Function(HttpHeaders_List value)? list, + required TResult orElse(), + }) { + if (list != null) { + return list(this); + } + return orElse(); + } +} + +abstract class HttpHeaders_List extends HttpHeaders { + const factory HttpHeaders_List(final List<(String, String)> field0) = + _$HttpHeaders_ListImpl; + const HttpHeaders_List._() : super._(); + + @override + List<(String, String)> get field0; + + /// Create a copy of HttpHeaders + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$HttpHeaders_ListImplCopyWith<_$HttpHeaders_ListImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +mixin _$HttpResponseBody { + @optionalTypeArgs + TResult when({ + required TResult Function(String field0) text, + required TResult Function(Uint8List field0) bytes, + required TResult Function() stream, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String field0)? text, + TResult? Function(Uint8List field0)? bytes, + TResult? Function()? stream, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String field0)? text, + TResult Function(Uint8List field0)? bytes, + TResult Function()? stream, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(HttpResponseBody_Text value) text, + required TResult Function(HttpResponseBody_Bytes value) bytes, + required TResult Function(HttpResponseBody_Stream value) stream, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(HttpResponseBody_Text value)? text, + TResult? Function(HttpResponseBody_Bytes value)? bytes, + TResult? Function(HttpResponseBody_Stream value)? stream, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(HttpResponseBody_Text value)? text, + TResult Function(HttpResponseBody_Bytes value)? bytes, + TResult Function(HttpResponseBody_Stream value)? stream, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $HttpResponseBodyCopyWith<$Res> { + factory $HttpResponseBodyCopyWith( + HttpResponseBody value, $Res Function(HttpResponseBody) then) = + _$HttpResponseBodyCopyWithImpl<$Res, HttpResponseBody>; +} + +/// @nodoc +class _$HttpResponseBodyCopyWithImpl<$Res, $Val extends HttpResponseBody> + implements $HttpResponseBodyCopyWith<$Res> { + _$HttpResponseBodyCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of HttpResponseBody + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$HttpResponseBody_TextImplCopyWith<$Res> { + factory _$$HttpResponseBody_TextImplCopyWith( + _$HttpResponseBody_TextImpl value, + $Res Function(_$HttpResponseBody_TextImpl) then) = + __$$HttpResponseBody_TextImplCopyWithImpl<$Res>; + @useResult + $Res call({String field0}); +} + +/// @nodoc +class __$$HttpResponseBody_TextImplCopyWithImpl<$Res> + extends _$HttpResponseBodyCopyWithImpl<$Res, _$HttpResponseBody_TextImpl> + implements _$$HttpResponseBody_TextImplCopyWith<$Res> { + __$$HttpResponseBody_TextImplCopyWithImpl(_$HttpResponseBody_TextImpl _value, + $Res Function(_$HttpResponseBody_TextImpl) _then) + : super(_value, _then); + + /// Create a copy of HttpResponseBody + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? field0 = null, + }) { + return _then(_$HttpResponseBody_TextImpl( + null == field0 + ? _value.field0 + : field0 // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc + +class _$HttpResponseBody_TextImpl extends HttpResponseBody_Text { + const _$HttpResponseBody_TextImpl(this.field0) : super._(); + + @override + final String field0; + + @override + String toString() { + return 'HttpResponseBody.text(field0: $field0)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$HttpResponseBody_TextImpl && + (identical(other.field0, field0) || other.field0 == field0)); + } + + @override + int get hashCode => Object.hash(runtimeType, field0); + + /// Create a copy of HttpResponseBody + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$HttpResponseBody_TextImplCopyWith<_$HttpResponseBody_TextImpl> + get copyWith => __$$HttpResponseBody_TextImplCopyWithImpl< + _$HttpResponseBody_TextImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String field0) text, + required TResult Function(Uint8List field0) bytes, + required TResult Function() stream, + }) { + return text(field0); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String field0)? text, + TResult? Function(Uint8List field0)? bytes, + TResult? Function()? stream, + }) { + return text?.call(field0); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String field0)? text, + TResult Function(Uint8List field0)? bytes, + TResult Function()? stream, + required TResult orElse(), + }) { + if (text != null) { + return text(field0); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(HttpResponseBody_Text value) text, + required TResult Function(HttpResponseBody_Bytes value) bytes, + required TResult Function(HttpResponseBody_Stream value) stream, + }) { + return text(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(HttpResponseBody_Text value)? text, + TResult? Function(HttpResponseBody_Bytes value)? bytes, + TResult? Function(HttpResponseBody_Stream value)? stream, + }) { + return text?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(HttpResponseBody_Text value)? text, + TResult Function(HttpResponseBody_Bytes value)? bytes, + TResult Function(HttpResponseBody_Stream value)? stream, + required TResult orElse(), + }) { + if (text != null) { + return text(this); + } + return orElse(); + } +} + +abstract class HttpResponseBody_Text extends HttpResponseBody { + const factory HttpResponseBody_Text(final String field0) = + _$HttpResponseBody_TextImpl; + const HttpResponseBody_Text._() : super._(); + + String get field0; + + /// Create a copy of HttpResponseBody + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$HttpResponseBody_TextImplCopyWith<_$HttpResponseBody_TextImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$HttpResponseBody_BytesImplCopyWith<$Res> { + factory _$$HttpResponseBody_BytesImplCopyWith( + _$HttpResponseBody_BytesImpl value, + $Res Function(_$HttpResponseBody_BytesImpl) then) = + __$$HttpResponseBody_BytesImplCopyWithImpl<$Res>; + @useResult + $Res call({Uint8List field0}); +} + +/// @nodoc +class __$$HttpResponseBody_BytesImplCopyWithImpl<$Res> + extends _$HttpResponseBodyCopyWithImpl<$Res, _$HttpResponseBody_BytesImpl> + implements _$$HttpResponseBody_BytesImplCopyWith<$Res> { + __$$HttpResponseBody_BytesImplCopyWithImpl( + _$HttpResponseBody_BytesImpl _value, + $Res Function(_$HttpResponseBody_BytesImpl) _then) + : super(_value, _then); + + /// Create a copy of HttpResponseBody + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? field0 = null, + }) { + return _then(_$HttpResponseBody_BytesImpl( + null == field0 + ? _value.field0 + : field0 // ignore: cast_nullable_to_non_nullable + as Uint8List, + )); + } +} + +/// @nodoc + +class _$HttpResponseBody_BytesImpl extends HttpResponseBody_Bytes { + const _$HttpResponseBody_BytesImpl(this.field0) : super._(); + + @override + final Uint8List field0; + + @override + String toString() { + return 'HttpResponseBody.bytes(field0: $field0)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$HttpResponseBody_BytesImpl && + const DeepCollectionEquality().equals(other.field0, field0)); + } + + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(field0)); + + /// Create a copy of HttpResponseBody + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$HttpResponseBody_BytesImplCopyWith<_$HttpResponseBody_BytesImpl> + get copyWith => __$$HttpResponseBody_BytesImplCopyWithImpl< + _$HttpResponseBody_BytesImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String field0) text, + required TResult Function(Uint8List field0) bytes, + required TResult Function() stream, + }) { + return bytes(field0); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String field0)? text, + TResult? Function(Uint8List field0)? bytes, + TResult? Function()? stream, + }) { + return bytes?.call(field0); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String field0)? text, + TResult Function(Uint8List field0)? bytes, + TResult Function()? stream, + required TResult orElse(), + }) { + if (bytes != null) { + return bytes(field0); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(HttpResponseBody_Text value) text, + required TResult Function(HttpResponseBody_Bytes value) bytes, + required TResult Function(HttpResponseBody_Stream value) stream, + }) { + return bytes(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(HttpResponseBody_Text value)? text, + TResult? Function(HttpResponseBody_Bytes value)? bytes, + TResult? Function(HttpResponseBody_Stream value)? stream, + }) { + return bytes?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(HttpResponseBody_Text value)? text, + TResult Function(HttpResponseBody_Bytes value)? bytes, + TResult Function(HttpResponseBody_Stream value)? stream, + required TResult orElse(), + }) { + if (bytes != null) { + return bytes(this); + } + return orElse(); + } +} + +abstract class HttpResponseBody_Bytes extends HttpResponseBody { + const factory HttpResponseBody_Bytes(final Uint8List field0) = + _$HttpResponseBody_BytesImpl; + const HttpResponseBody_Bytes._() : super._(); + + Uint8List get field0; + + /// Create a copy of HttpResponseBody + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$HttpResponseBody_BytesImplCopyWith<_$HttpResponseBody_BytesImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$HttpResponseBody_StreamImplCopyWith<$Res> { + factory _$$HttpResponseBody_StreamImplCopyWith( + _$HttpResponseBody_StreamImpl value, + $Res Function(_$HttpResponseBody_StreamImpl) then) = + __$$HttpResponseBody_StreamImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$HttpResponseBody_StreamImplCopyWithImpl<$Res> + extends _$HttpResponseBodyCopyWithImpl<$Res, _$HttpResponseBody_StreamImpl> + implements _$$HttpResponseBody_StreamImplCopyWith<$Res> { + __$$HttpResponseBody_StreamImplCopyWithImpl( + _$HttpResponseBody_StreamImpl _value, + $Res Function(_$HttpResponseBody_StreamImpl) _then) + : super(_value, _then); + + /// Create a copy of HttpResponseBody + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$HttpResponseBody_StreamImpl extends HttpResponseBody_Stream { + const _$HttpResponseBody_StreamImpl() : super._(); + + @override + String toString() { + return 'HttpResponseBody.stream()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$HttpResponseBody_StreamImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(String field0) text, + required TResult Function(Uint8List field0) bytes, + required TResult Function() stream, + }) { + return stream(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String field0)? text, + TResult? Function(Uint8List field0)? bytes, + TResult? Function()? stream, + }) { + return stream?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String field0)? text, + TResult Function(Uint8List field0)? bytes, + TResult Function()? stream, + required TResult orElse(), + }) { + if (stream != null) { + return stream(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(HttpResponseBody_Text value) text, + required TResult Function(HttpResponseBody_Bytes value) bytes, + required TResult Function(HttpResponseBody_Stream value) stream, + }) { + return stream(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(HttpResponseBody_Text value)? text, + TResult? Function(HttpResponseBody_Bytes value)? bytes, + TResult? Function(HttpResponseBody_Stream value)? stream, + }) { + return stream?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(HttpResponseBody_Text value)? text, + TResult Function(HttpResponseBody_Bytes value)? bytes, + TResult Function(HttpResponseBody_Stream value)? stream, + required TResult orElse(), + }) { + if (stream != null) { + return stream(this); + } + return orElse(); + } +} + +abstract class HttpResponseBody_Stream extends HttpResponseBody { + const factory HttpResponseBody_Stream() = _$HttpResponseBody_StreamImpl; + const HttpResponseBody_Stream._() : super._(); +} diff --git a/lib/src/rust/frb_generated.dart b/lib/src/rust/frb_generated.dart index 9dc22ccf..c35bf91c 100644 --- a/lib/src/rust/frb_generated.dart +++ b/lib/src/rust/frb_generated.dart @@ -4,11 +4,15 @@ // ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field import 'api/image.dart'; +import 'api/rhttp/client.dart'; +import 'api/rhttp/error.dart'; +import 'api/rhttp/http.dart'; import 'dart:async'; import 'dart:convert'; import 'frb_generated.dart'; import 'frb_generated.io.dart' if (dart.library.js_interop) 'frb_generated.web.dart'; +import 'lib.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; /// Main entrypoint of the Rust API @@ -66,7 +70,7 @@ class RustLib extends BaseEntrypoint { String get codegenVersion => '2.3.0'; @override - int get rustContentHash => -287789500; + int get rustContentHash => 107666026; static const kDefaultExternalLibraryLoaderConfig = ExternalLibraryLoaderConfig( @@ -78,6 +82,51 @@ class RustLib extends BaseEntrypoint { abstract class RustLibApi extends BaseApi { Uint8List crateApiImageProcessCropImage({required List image}); + + Future crateApiRhttpClientClientSettingsDefault(); + + Future crateApiRhttpHttpCancelRequest( + {required CancellationToken token}); + + Future crateApiRhttpHttpCancelRunningRequests( + {required RequestClient client}); + + Stream crateApiRhttpHttpMakeHttpRequestReceiveStream( + {RequestClient? client, + ClientSettings? settings, + required HttpMethod method, + required String url, + List<(String, String)>? query, + HttpHeaders? headers, + Uint8List? body, + required FutureOr Function(HttpResponse) onResponse, + required FutureOr Function(RhttpError) onError, + required FutureOr Function(CancellationToken) onCancelToken, + required bool cancelable}); + + Future crateApiRhttpHttpRegisterClient( + {required ClientSettings settings}); + + RequestClient crateApiRhttpHttpRegisterClientSync( + {required ClientSettings settings}); + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_CancellationToken; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_CancellationToken; + + CrossPlatformFinalizerArg + get rust_arc_decrement_strong_count_CancellationTokenPtr; + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_RequestClient; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_RequestClient; + + CrossPlatformFinalizerArg + get rust_arc_decrement_strong_count_RequestClientPtr; } class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { @@ -112,6 +161,620 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { argNames: ["image"], ); + @override + Future crateApiRhttpClientClientSettingsDefault() { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 2, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_client_settings, + decodeErrorData: null, + ), + constMeta: kCrateApiRhttpClientClientSettingsDefaultConstMeta, + argValues: [], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiRhttpClientClientSettingsDefaultConstMeta => + const TaskConstMeta( + debugName: "client_settings_default", + argNames: [], + ); + + @override + Future crateApiRhttpHttpCancelRequest( + {required CancellationToken token}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + token, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 3, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: null, + ), + constMeta: kCrateApiRhttpHttpCancelRequestConstMeta, + argValues: [token], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiRhttpHttpCancelRequestConstMeta => + const TaskConstMeta( + debugName: "cancel_request", + argNames: ["token"], + ); + + @override + Future crateApiRhttpHttpCancelRunningRequests( + {required RequestClient client}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + client, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 4, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: null, + ), + constMeta: kCrateApiRhttpHttpCancelRunningRequestsConstMeta, + argValues: [client], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiRhttpHttpCancelRunningRequestsConstMeta => + const TaskConstMeta( + debugName: "cancel_running_requests", + argNames: ["client"], + ); + + @override + Stream crateApiRhttpHttpMakeHttpRequestReceiveStream( + {RequestClient? client, + ClientSettings? settings, + required HttpMethod method, + required String url, + List<(String, String)>? query, + HttpHeaders? headers, + Uint8List? body, + required FutureOr Function(HttpResponse) onResponse, + required FutureOr Function(RhttpError) onError, + required FutureOr Function(CancellationToken) onCancelToken, + required bool cancelable}) { + final streamSink = RustStreamSink(); + unawaited(handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_opt_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + client, serializer); + sse_encode_opt_box_autoadd_client_settings(settings, serializer); + sse_encode_http_method(method, serializer); + sse_encode_String(url, serializer); + sse_encode_opt_list_record_string_string(query, serializer); + sse_encode_opt_box_autoadd_http_headers(headers, serializer); + sse_encode_opt_list_prim_u_8_strict(body, serializer); + sse_encode_StreamSink_list_prim_u_8_strict_Sse(streamSink, serializer); + sse_encode_DartFn_Inputs_http_response_Output_unit_AnyhowException( + onResponse, serializer); + sse_encode_DartFn_Inputs_rhttp_error_Output_unit_AnyhowException( + onError, serializer); + sse_encode_DartFn_Inputs_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken_Output_unit_AnyhowException( + onCancelToken, serializer); + sse_encode_bool(cancelable, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 5, port: port_); + }, + codec: SseCodec( + decodeSuccessData: sse_decode_unit, + decodeErrorData: sse_decode_rhttp_error, + ), + constMeta: kCrateApiRhttpHttpMakeHttpRequestReceiveStreamConstMeta, + argValues: [ + client, + settings, + method, + url, + query, + headers, + body, + streamSink, + onResponse, + onError, + onCancelToken, + cancelable + ], + apiImpl: this, + ))); + return streamSink.stream; + } + + TaskConstMeta get kCrateApiRhttpHttpMakeHttpRequestReceiveStreamConstMeta => + const TaskConstMeta( + debugName: "make_http_request_receive_stream", + argNames: [ + "client", + "settings", + "method", + "url", + "query", + "headers", + "body", + "streamSink", + "onResponse", + "onError", + "onCancelToken", + "cancelable" + ], + ); + + @override + Future crateApiRhttpHttpRegisterClient( + {required ClientSettings settings}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_box_autoadd_client_settings(settings, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 6, port: port_); + }, + codec: SseCodec( + decodeSuccessData: + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient, + decodeErrorData: sse_decode_rhttp_error, + ), + constMeta: kCrateApiRhttpHttpRegisterClientConstMeta, + argValues: [settings], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiRhttpHttpRegisterClientConstMeta => + const TaskConstMeta( + debugName: "register_client", + argNames: ["settings"], + ); + + @override + RequestClient crateApiRhttpHttpRegisterClientSync( + {required ClientSettings settings}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_box_autoadd_client_settings(settings, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 7)!; + }, + codec: SseCodec( + decodeSuccessData: + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient, + decodeErrorData: sse_decode_rhttp_error, + ), + constMeta: kCrateApiRhttpHttpRegisterClientSyncConstMeta, + argValues: [settings], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiRhttpHttpRegisterClientSyncConstMeta => + const TaskConstMeta( + debugName: "register_client_sync", + argNames: ["settings"], + ); + + Future Function(int, dynamic) + encode_DartFn_Inputs_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken_Output_unit_AnyhowException( + FutureOr Function(CancellationToken) raw) { + return (callId, rawArg0) async { + final arg0 = + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + rawArg0); + + Box? rawOutput; + Box? rawError; + try { + rawOutput = Box(await raw(arg0)); + } catch (e, s) { + rawError = Box(AnyhowException("$e\n\n$s")); + } + + final serializer = SseSerializer(generalizedFrbRustBinding); + assert((rawOutput != null) ^ (rawError != null)); + if (rawOutput != null) { + serializer.buffer.putUint8(0); + sse_encode_unit(rawOutput.value, serializer); + } else { + serializer.buffer.putUint8(1); + sse_encode_AnyhowException(rawError!.value, serializer); + } + final output = serializer.intoRaw(); + + generalizedFrbRustBinding.dartFnDeliverOutput( + callId: callId, + ptr: output.ptr, + rustVecLen: output.rustVecLen, + dataLen: output.dataLen); + }; + } + + Future Function(int, dynamic) + encode_DartFn_Inputs_http_response_Output_unit_AnyhowException( + FutureOr Function(HttpResponse) raw) { + return (callId, rawArg0) async { + final arg0 = dco_decode_http_response(rawArg0); + + Box? rawOutput; + Box? rawError; + try { + rawOutput = Box(await raw(arg0)); + } catch (e, s) { + rawError = Box(AnyhowException("$e\n\n$s")); + } + + final serializer = SseSerializer(generalizedFrbRustBinding); + assert((rawOutput != null) ^ (rawError != null)); + if (rawOutput != null) { + serializer.buffer.putUint8(0); + sse_encode_unit(rawOutput.value, serializer); + } else { + serializer.buffer.putUint8(1); + sse_encode_AnyhowException(rawError!.value, serializer); + } + final output = serializer.intoRaw(); + + generalizedFrbRustBinding.dartFnDeliverOutput( + callId: callId, + ptr: output.ptr, + rustVecLen: output.rustVecLen, + dataLen: output.dataLen); + }; + } + + Future Function(int, dynamic) + encode_DartFn_Inputs_rhttp_error_Output_unit_AnyhowException( + FutureOr Function(RhttpError) raw) { + return (callId, rawArg0) async { + final arg0 = dco_decode_rhttp_error(rawArg0); + + Box? rawOutput; + Box? rawError; + try { + rawOutput = Box(await raw(arg0)); + } catch (e, s) { + rawError = Box(AnyhowException("$e\n\n$s")); + } + + final serializer = SseSerializer(generalizedFrbRustBinding); + assert((rawOutput != null) ^ (rawError != null)); + if (rawOutput != null) { + serializer.buffer.putUint8(0); + sse_encode_unit(rawOutput.value, serializer); + } else { + serializer.buffer.putUint8(1); + sse_encode_AnyhowException(rawError!.value, serializer); + } + final output = serializer.intoRaw(); + + generalizedFrbRustBinding.dartFnDeliverOutput( + callId: callId, + ptr: output.ptr, + rustVecLen: output.rustVecLen, + dataLen: output.dataLen); + }; + } + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_CancellationToken => wire + .rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_CancellationToken => wire + .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken; + + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_RequestClient => wire + .rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_RequestClient => wire + .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient; + + @protected + AnyhowException dco_decode_AnyhowException(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return AnyhowException(raw as String); + } + + @protected + RequestClient + dco_decode_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + raw); + } + + @protected + CancellationToken + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return CancellationTokenImpl.frbInternalDcoDecode(raw as List); + } + + @protected + RequestClient + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return RequestClientImpl.frbInternalDcoDecode(raw as List); + } + + @protected + CancellationToken + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return CancellationTokenImpl.frbInternalDcoDecode(raw as List); + } + + @protected + RequestClient + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return RequestClientImpl.frbInternalDcoDecode(raw as List); + } + + @protected + Duration dco_decode_Chrono_Duration(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dcoDecodeDuration(dco_decode_i_64(raw).toInt()); + } + + @protected + FutureOr Function(CancellationToken) + dco_decode_DartFn_Inputs_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken_Output_unit_AnyhowException( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + throw UnimplementedError(''); + } + + @protected + FutureOr Function(HttpResponse) + dco_decode_DartFn_Inputs_http_response_Output_unit_AnyhowException( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + throw UnimplementedError(''); + } + + @protected + FutureOr Function(RhttpError) + dco_decode_DartFn_Inputs_rhttp_error_Output_unit_AnyhowException( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + throw UnimplementedError(''); + } + + @protected + Object dco_decode_DartOpaque(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return decodeDartOpaque(raw, generalizedFrbRustBinding); + } + + @protected + Map dco_decode_Map_String_String(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return Map.fromEntries(dco_decode_list_record_string_string(raw) + .map((e) => MapEntry(e.$1, e.$2))); + } + + @protected + CancellationToken + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return CancellationTokenImpl.frbInternalDcoDecode(raw as List); + } + + @protected + RequestClient + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return RequestClientImpl.frbInternalDcoDecode(raw as List); + } + + @protected + RustStreamSink dco_decode_StreamSink_list_prim_u_8_strict_Sse( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + throw UnimplementedError(); + } + + @protected + String dco_decode_String(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as String; + } + + @protected + bool dco_decode_bool(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as bool; + } + + @protected + Duration dco_decode_box_autoadd_Chrono_Duration(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_Chrono_Duration(raw); + } + + @protected + ClientCertificate dco_decode_box_autoadd_client_certificate(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_client_certificate(raw); + } + + @protected + ClientSettings dco_decode_box_autoadd_client_settings(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_client_settings(raw); + } + + @protected + HttpHeaders dco_decode_box_autoadd_http_headers(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_http_headers(raw); + } + + @protected + HttpResponseBody dco_decode_box_autoadd_http_response_body(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_http_response_body(raw); + } + + @protected + ProxySettings dco_decode_box_autoadd_proxy_settings(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_proxy_settings(raw); + } + + @protected + RedirectSettings dco_decode_box_autoadd_redirect_settings(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_redirect_settings(raw); + } + + @protected + TlsSettings dco_decode_box_autoadd_tls_settings(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_tls_settings(raw); + } + + @protected + TlsVersion dco_decode_box_autoadd_tls_version(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dco_decode_tls_version(raw); + } + + @protected + ClientCertificate dco_decode_client_certificate(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 2) + throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); + return ClientCertificate( + certificate: dco_decode_list_prim_u_8_strict(arr[0]), + privateKey: dco_decode_list_prim_u_8_strict(arr[1]), + ); + } + + @protected + ClientSettings dco_decode_client_settings(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 6) + throw Exception('unexpected arr length: expect 6 but see ${arr.length}'); + return ClientSettings( + timeout: dco_decode_opt_box_autoadd_Chrono_Duration(arr[0]), + connectTimeout: dco_decode_opt_box_autoadd_Chrono_Duration(arr[1]), + throwOnStatusCode: dco_decode_bool(arr[2]), + proxySettings: dco_decode_opt_box_autoadd_proxy_settings(arr[3]), + redirectSettings: dco_decode_opt_box_autoadd_redirect_settings(arr[4]), + tlsSettings: dco_decode_opt_box_autoadd_tls_settings(arr[5]), + ); + } + + @protected + HttpHeaders dco_decode_http_headers(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return HttpHeaders_Map( + dco_decode_Map_String_String(raw[1]), + ); + case 1: + return HttpHeaders_List( + dco_decode_list_record_string_string(raw[1]), + ); + default: + throw Exception("unreachable"); + } + } + + @protected + HttpMethod dco_decode_http_method(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return HttpMethod.values[raw as int]; + } + + @protected + HttpResponse dco_decode_http_response(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 4) + throw Exception('unexpected arr length: expect 4 but see ${arr.length}'); + return HttpResponse( + headers: dco_decode_list_record_string_string(arr[0]), + version: dco_decode_http_version(arr[1]), + statusCode: dco_decode_u_16(arr[2]), + body: dco_decode_http_response_body(arr[3]), + ); + } + + @protected + HttpResponseBody dco_decode_http_response_body(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return HttpResponseBody_Text( + dco_decode_String(raw[1]), + ); + case 1: + return HttpResponseBody_Bytes( + dco_decode_list_prim_u_8_strict(raw[1]), + ); + case 2: + return HttpResponseBody_Stream(); + default: + throw Exception("unreachable"); + } + } + + @protected + HttpVersion dco_decode_http_version(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return HttpVersion.values[raw as int]; + } + + @protected + int dco_decode_i_32(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + + @protected + PlatformInt64 dco_decode_i_64(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dcoDecodeI64(raw); + } + + @protected + List dco_decode_list_list_prim_u_8_strict(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return (raw as List).map(dco_decode_list_prim_u_8_strict).toList(); + } + @protected List dco_decode_list_prim_u_8_loose(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs @@ -124,6 +787,180 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return raw as Uint8List; } + @protected + List<(String, String)> dco_decode_list_record_string_string(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return (raw as List).map(dco_decode_record_string_string).toList(); + } + + @protected + RequestClient? + dco_decode_opt_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null + ? null + : dco_decode_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + raw); + } + + @protected + Duration? dco_decode_opt_box_autoadd_Chrono_Duration(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_box_autoadd_Chrono_Duration(raw); + } + + @protected + ClientCertificate? dco_decode_opt_box_autoadd_client_certificate( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_box_autoadd_client_certificate(raw); + } + + @protected + ClientSettings? dco_decode_opt_box_autoadd_client_settings(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_box_autoadd_client_settings(raw); + } + + @protected + HttpHeaders? dco_decode_opt_box_autoadd_http_headers(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_box_autoadd_http_headers(raw); + } + + @protected + ProxySettings? dco_decode_opt_box_autoadd_proxy_settings(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_box_autoadd_proxy_settings(raw); + } + + @protected + RedirectSettings? dco_decode_opt_box_autoadd_redirect_settings(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_box_autoadd_redirect_settings(raw); + } + + @protected + TlsSettings? dco_decode_opt_box_autoadd_tls_settings(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_box_autoadd_tls_settings(raw); + } + + @protected + TlsVersion? dco_decode_opt_box_autoadd_tls_version(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_box_autoadd_tls_version(raw); + } + + @protected + Uint8List? dco_decode_opt_list_prim_u_8_strict(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_list_prim_u_8_strict(raw); + } + + @protected + List<(String, String)>? dco_decode_opt_list_record_string_string( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw == null ? null : dco_decode_list_record_string_string(raw); + } + + @protected + ProxySettings dco_decode_proxy_settings(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return ProxySettings.values[raw as int]; + } + + @protected + (String, String) dco_decode_record_string_string(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_String(arr[0]), + dco_decode_String(arr[1]), + ); + } + + @protected + RedirectSettings dco_decode_redirect_settings(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return RedirectSettings_NoRedirect(); + case 1: + return RedirectSettings_LimitedRedirects( + dco_decode_i_32(raw[1]), + ); + default: + throw Exception("unreachable"); + } + } + + @protected + RhttpError dco_decode_rhttp_error(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + switch (raw[0]) { + case 0: + return RhttpError_RhttpCancelError(); + case 1: + return RhttpError_RhttpTimeoutError(); + case 2: + return RhttpError_RhttpRedirectError(); + case 3: + return RhttpError_RhttpStatusCodeError( + dco_decode_u_16(raw[1]), + dco_decode_list_record_string_string(raw[2]), + dco_decode_box_autoadd_http_response_body(raw[3]), + ); + case 4: + return RhttpError_RhttpInvalidCertificateError( + dco_decode_String(raw[1]), + ); + case 5: + return RhttpError_RhttpConnectionError( + dco_decode_String(raw[1]), + ); + case 6: + return RhttpError_RhttpUnknownError( + dco_decode_String(raw[1]), + ); + default: + throw Exception("unreachable"); + } + } + + @protected + TlsSettings dco_decode_tls_settings(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + final arr = raw as List; + if (arr.length != 6) + throw Exception('unexpected arr length: expect 6 but see ${arr.length}'); + return TlsSettings( + trustRootCertificates: dco_decode_bool(arr[0]), + trustedRootCertificates: dco_decode_list_list_prim_u_8_strict(arr[1]), + verifyCertificates: dco_decode_bool(arr[2]), + clientCertificate: dco_decode_opt_box_autoadd_client_certificate(arr[3]), + minTlsVersion: dco_decode_opt_box_autoadd_tls_version(arr[4]), + maxTlsVersion: dco_decode_opt_box_autoadd_tls_version(arr[5]), + ); + } + + @protected + TlsVersion dco_decode_tls_version(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return TlsVersion.values[raw as int]; + } + + @protected + int dco_decode_u_16(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return raw as int; + } + @protected int dco_decode_u_8(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs @@ -136,6 +973,308 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return; } + @protected + BigInt dco_decode_usize(dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return dcoDecodeU64(raw); + } + + @protected + AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_String(deserializer); + return AnyhowException(inner); + } + + @protected + RequestClient + sse_decode_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + deserializer); + return inner; + } + + @protected + CancellationToken + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return CancellationTokenImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + RequestClient + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return RequestClientImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + CancellationToken + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return CancellationTokenImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + RequestClient + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return RequestClientImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + Duration sse_decode_Chrono_Duration(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_i_64(deserializer); + return Duration(microseconds: inner.toInt()); + } + + @protected + Object sse_decode_DartOpaque(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_usize(deserializer); + return decodeDartOpaque(inner, generalizedFrbRustBinding); + } + + @protected + Map sse_decode_Map_String_String( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_list_record_string_string(deserializer); + return Map.fromEntries(inner.map((e) => MapEntry(e.$1, e.$2))); + } + + @protected + CancellationToken + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return CancellationTokenImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + RequestClient + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return RequestClientImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + + @protected + RustStreamSink sse_decode_StreamSink_list_prim_u_8_strict_Sse( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + throw UnimplementedError('Unreachable ()'); + } + + @protected + String sse_decode_String(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_list_prim_u_8_strict(deserializer); + return utf8.decoder.convert(inner); + } + + @protected + bool sse_decode_bool(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint8() != 0; + } + + @protected + Duration sse_decode_box_autoadd_Chrono_Duration( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_Chrono_Duration(deserializer)); + } + + @protected + ClientCertificate sse_decode_box_autoadd_client_certificate( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_client_certificate(deserializer)); + } + + @protected + ClientSettings sse_decode_box_autoadd_client_settings( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_client_settings(deserializer)); + } + + @protected + HttpHeaders sse_decode_box_autoadd_http_headers( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_http_headers(deserializer)); + } + + @protected + HttpResponseBody sse_decode_box_autoadd_http_response_body( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_http_response_body(deserializer)); + } + + @protected + ProxySettings sse_decode_box_autoadd_proxy_settings( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_proxy_settings(deserializer)); + } + + @protected + RedirectSettings sse_decode_box_autoadd_redirect_settings( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_redirect_settings(deserializer)); + } + + @protected + TlsSettings sse_decode_box_autoadd_tls_settings( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_tls_settings(deserializer)); + } + + @protected + TlsVersion sse_decode_box_autoadd_tls_version(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return (sse_decode_tls_version(deserializer)); + } + + @protected + ClientCertificate sse_decode_client_certificate( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_certificate = sse_decode_list_prim_u_8_strict(deserializer); + var var_privateKey = sse_decode_list_prim_u_8_strict(deserializer); + return ClientCertificate( + certificate: var_certificate, privateKey: var_privateKey); + } + + @protected + ClientSettings sse_decode_client_settings(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_timeout = sse_decode_opt_box_autoadd_Chrono_Duration(deserializer); + var var_connectTimeout = + sse_decode_opt_box_autoadd_Chrono_Duration(deserializer); + var var_throwOnStatusCode = sse_decode_bool(deserializer); + var var_proxySettings = + sse_decode_opt_box_autoadd_proxy_settings(deserializer); + var var_redirectSettings = + sse_decode_opt_box_autoadd_redirect_settings(deserializer); + var var_tlsSettings = sse_decode_opt_box_autoadd_tls_settings(deserializer); + return ClientSettings( + timeout: var_timeout, + connectTimeout: var_connectTimeout, + throwOnStatusCode: var_throwOnStatusCode, + proxySettings: var_proxySettings, + redirectSettings: var_redirectSettings, + tlsSettings: var_tlsSettings); + } + + @protected + HttpHeaders sse_decode_http_headers(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_field0 = sse_decode_Map_String_String(deserializer); + return HttpHeaders_Map(var_field0); + case 1: + var var_field0 = sse_decode_list_record_string_string(deserializer); + return HttpHeaders_List(var_field0); + default: + throw UnimplementedError(''); + } + } + + @protected + HttpMethod sse_decode_http_method(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_i_32(deserializer); + return HttpMethod.values[inner]; + } + + @protected + HttpResponse sse_decode_http_response(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_headers = sse_decode_list_record_string_string(deserializer); + var var_version = sse_decode_http_version(deserializer); + var var_statusCode = sse_decode_u_16(deserializer); + var var_body = sse_decode_http_response_body(deserializer); + return HttpResponse( + headers: var_headers, + version: var_version, + statusCode: var_statusCode, + body: var_body); + } + + @protected + HttpResponseBody sse_decode_http_response_body(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_field0 = sse_decode_String(deserializer); + return HttpResponseBody_Text(var_field0); + case 1: + var var_field0 = sse_decode_list_prim_u_8_strict(deserializer); + return HttpResponseBody_Bytes(var_field0); + case 2: + return HttpResponseBody_Stream(); + default: + throw UnimplementedError(''); + } + } + + @protected + HttpVersion sse_decode_http_version(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_i_32(deserializer); + return HttpVersion.values[inner]; + } + + @protected + int sse_decode_i_32(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getInt32(); + } + + @protected + PlatformInt64 sse_decode_i_64(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getPlatformInt64(); + } + + @protected + List sse_decode_list_list_prim_u_8_strict( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var len_ = sse_decode_i_32(deserializer); + var ans_ = []; + for (var idx_ = 0; idx_ < len_; ++idx_) { + ans_.add(sse_decode_list_prim_u_8_strict(deserializer)); + } + return ans_; + } + @protected List sse_decode_list_prim_u_8_loose(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -150,6 +1289,252 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return deserializer.buffer.getUint8List(len_); } + @protected + List<(String, String)> sse_decode_list_record_string_string( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var len_ = sse_decode_i_32(deserializer); + var ans_ = <(String, String)>[]; + for (var idx_ = 0; idx_ < len_; ++idx_) { + ans_.add(sse_decode_record_string_string(deserializer)); + } + return ans_; + } + + @protected + RequestClient? + sse_decode_opt_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + deserializer)); + } else { + return null; + } + } + + @protected + Duration? sse_decode_opt_box_autoadd_Chrono_Duration( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_box_autoadd_Chrono_Duration(deserializer)); + } else { + return null; + } + } + + @protected + ClientCertificate? sse_decode_opt_box_autoadd_client_certificate( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_box_autoadd_client_certificate(deserializer)); + } else { + return null; + } + } + + @protected + ClientSettings? sse_decode_opt_box_autoadd_client_settings( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_box_autoadd_client_settings(deserializer)); + } else { + return null; + } + } + + @protected + HttpHeaders? sse_decode_opt_box_autoadd_http_headers( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_box_autoadd_http_headers(deserializer)); + } else { + return null; + } + } + + @protected + ProxySettings? sse_decode_opt_box_autoadd_proxy_settings( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_box_autoadd_proxy_settings(deserializer)); + } else { + return null; + } + } + + @protected + RedirectSettings? sse_decode_opt_box_autoadd_redirect_settings( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_box_autoadd_redirect_settings(deserializer)); + } else { + return null; + } + } + + @protected + TlsSettings? sse_decode_opt_box_autoadd_tls_settings( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_box_autoadd_tls_settings(deserializer)); + } else { + return null; + } + } + + @protected + TlsVersion? sse_decode_opt_box_autoadd_tls_version( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_box_autoadd_tls_version(deserializer)); + } else { + return null; + } + } + + @protected + Uint8List? sse_decode_opt_list_prim_u_8_strict(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_list_prim_u_8_strict(deserializer)); + } else { + return null; + } + } + + @protected + List<(String, String)>? sse_decode_opt_list_record_string_string( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + if (sse_decode_bool(deserializer)) { + return (sse_decode_list_record_string_string(deserializer)); + } else { + return null; + } + } + + @protected + ProxySettings sse_decode_proxy_settings(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_i_32(deserializer); + return ProxySettings.values[inner]; + } + + @protected + (String, String) sse_decode_record_string_string( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_field0 = sse_decode_String(deserializer); + var var_field1 = sse_decode_String(deserializer); + return (var_field0, var_field1); + } + + @protected + RedirectSettings sse_decode_redirect_settings(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var tag_ = sse_decode_i_32(deserializer); + switch (tag_) { + case 0: + return RedirectSettings_NoRedirect(); + case 1: + var var_field0 = sse_decode_i_32(deserializer); + return RedirectSettings_LimitedRedirects(var_field0); + default: + throw UnimplementedError(''); + } + } + + @protected + RhttpError sse_decode_rhttp_error(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + var tag_ = sse_decode_i_32(deserializer); + switch (tag_) { + case 0: + return RhttpError_RhttpCancelError(); + case 1: + return RhttpError_RhttpTimeoutError(); + case 2: + return RhttpError_RhttpRedirectError(); + case 3: + var var_field0 = sse_decode_u_16(deserializer); + var var_field1 = sse_decode_list_record_string_string(deserializer); + var var_field2 = + sse_decode_box_autoadd_http_response_body(deserializer); + return RhttpError_RhttpStatusCodeError( + var_field0, var_field1, var_field2); + case 4: + var var_field0 = sse_decode_String(deserializer); + return RhttpError_RhttpInvalidCertificateError(var_field0); + case 5: + var var_field0 = sse_decode_String(deserializer); + return RhttpError_RhttpConnectionError(var_field0); + case 6: + var var_field0 = sse_decode_String(deserializer); + return RhttpError_RhttpUnknownError(var_field0); + default: + throw UnimplementedError(''); + } + } + + @protected + TlsSettings sse_decode_tls_settings(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var var_trustRootCertificates = sse_decode_bool(deserializer); + var var_trustedRootCertificates = + sse_decode_list_list_prim_u_8_strict(deserializer); + var var_verifyCertificates = sse_decode_bool(deserializer); + var var_clientCertificate = + sse_decode_opt_box_autoadd_client_certificate(deserializer); + var var_minTlsVersion = + sse_decode_opt_box_autoadd_tls_version(deserializer); + var var_maxTlsVersion = + sse_decode_opt_box_autoadd_tls_version(deserializer); + return TlsSettings( + trustRootCertificates: var_trustRootCertificates, + trustedRootCertificates: var_trustedRootCertificates, + verifyCertificates: var_verifyCertificates, + clientCertificate: var_clientCertificate, + minTlsVersion: var_minTlsVersion, + maxTlsVersion: var_maxTlsVersion); + } + + @protected + TlsVersion sse_decode_tls_version(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + var inner = sse_decode_i_32(deserializer); + return TlsVersion.values[inner]; + } + + @protected + int sse_decode_u_16(SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return deserializer.buffer.getUint16(); + } + @protected int sse_decode_u_8(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -162,15 +1547,324 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } @protected - int sse_decode_i_32(SseDeserializer deserializer) { + BigInt sse_decode_usize(SseDeserializer deserializer) { // Codec=Sse (Serialization based), see doc to use other codecs - return deserializer.buffer.getInt32(); + return deserializer.buffer.getBigUint64(); } @protected - bool sse_decode_bool(SseDeserializer deserializer) { + void sse_encode_AnyhowException( + AnyhowException self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs - return deserializer.buffer.getUint8() != 0; + sse_encode_String(self.message, serializer); + } + + @protected + void + sse_encode_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + RequestClient self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + self, serializer); + } + + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + CancellationToken self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as CancellationTokenImpl).frbInternalSseEncode(move: true), + serializer); + } + + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + RequestClient self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as RequestClientImpl).frbInternalSseEncode(move: true), + serializer); + } + + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + CancellationToken self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as CancellationTokenImpl).frbInternalSseEncode(move: false), + serializer); + } + + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + RequestClient self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as RequestClientImpl).frbInternalSseEncode(move: false), + serializer); + } + + @protected + void sse_encode_Chrono_Duration(Duration self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_64(PlatformInt64Util.from(self.inMicroseconds), serializer); + } + + @protected + void + sse_encode_DartFn_Inputs_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken_Output_unit_AnyhowException( + FutureOr Function(CancellationToken) self, + SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_DartOpaque( + encode_DartFn_Inputs_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken_Output_unit_AnyhowException( + self), + serializer); + } + + @protected + void sse_encode_DartFn_Inputs_http_response_Output_unit_AnyhowException( + FutureOr Function(HttpResponse) self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_DartOpaque( + encode_DartFn_Inputs_http_response_Output_unit_AnyhowException(self), + serializer); + } + + @protected + void sse_encode_DartFn_Inputs_rhttp_error_Output_unit_AnyhowException( + FutureOr Function(RhttpError) self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_DartOpaque( + encode_DartFn_Inputs_rhttp_error_Output_unit_AnyhowException(self), + serializer); + } + + @protected + void sse_encode_DartOpaque(Object self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + BigInt.from(PlatformPointerUtil.ptrToInt(encodeDartOpaque( + self, portManager.dartHandlerPort, generalizedFrbRustBinding))) + .toUnsigned(64), + serializer); + } + + @protected + void sse_encode_Map_String_String( + Map self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_list_record_string_string( + self.entries.map((e) => (e.key, e.value)).toList(), serializer); + } + + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + CancellationToken self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as CancellationTokenImpl).frbInternalSseEncode(move: null), + serializer); + } + + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + RequestClient self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as RequestClientImpl).frbInternalSseEncode(move: null), + serializer); + } + + @protected + void sse_encode_StreamSink_list_prim_u_8_strict_Sse( + RustStreamSink self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_String( + self.setupAndSerialize( + codec: SseCodec( + decodeSuccessData: sse_decode_list_prim_u_8_strict, + decodeErrorData: sse_decode_AnyhowException, + )), + serializer); + } + + @protected + void sse_encode_String(String self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_list_prim_u_8_strict(utf8.encoder.convert(self), serializer); + } + + @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_Chrono_Duration( + Duration self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_Chrono_Duration(self, serializer); + } + + @protected + void sse_encode_box_autoadd_client_certificate( + ClientCertificate self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_client_certificate(self, serializer); + } + + @protected + void sse_encode_box_autoadd_client_settings( + ClientSettings self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_client_settings(self, serializer); + } + + @protected + void sse_encode_box_autoadd_http_headers( + HttpHeaders self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_http_headers(self, serializer); + } + + @protected + void sse_encode_box_autoadd_http_response_body( + HttpResponseBody self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_http_response_body(self, serializer); + } + + @protected + void sse_encode_box_autoadd_proxy_settings( + ProxySettings self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_proxy_settings(self, serializer); + } + + @protected + void sse_encode_box_autoadd_redirect_settings( + RedirectSettings self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_redirect_settings(self, serializer); + } + + @protected + void sse_encode_box_autoadd_tls_settings( + TlsSettings self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_tls_settings(self, serializer); + } + + @protected + void sse_encode_box_autoadd_tls_version( + TlsVersion self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_tls_version(self, serializer); + } + + @protected + void sse_encode_client_certificate( + ClientCertificate self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_list_prim_u_8_strict(self.certificate, serializer); + sse_encode_list_prim_u_8_strict(self.privateKey, serializer); + } + + @protected + void sse_encode_client_settings( + ClientSettings self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_opt_box_autoadd_Chrono_Duration(self.timeout, serializer); + sse_encode_opt_box_autoadd_Chrono_Duration(self.connectTimeout, serializer); + sse_encode_bool(self.throwOnStatusCode, serializer); + sse_encode_opt_box_autoadd_proxy_settings(self.proxySettings, serializer); + sse_encode_opt_box_autoadd_redirect_settings( + self.redirectSettings, serializer); + sse_encode_opt_box_autoadd_tls_settings(self.tlsSettings, serializer); + } + + @protected + void sse_encode_http_headers(HttpHeaders self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case HttpHeaders_Map(field0: final field0): + sse_encode_i_32(0, serializer); + sse_encode_Map_String_String(field0, serializer); + case HttpHeaders_List(field0: final field0): + sse_encode_i_32(1, serializer); + sse_encode_list_record_string_string(field0, serializer); + default: + throw UnimplementedError(''); + } + } + + @protected + void sse_encode_http_method(HttpMethod self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.index, serializer); + } + + @protected + void sse_encode_http_response(HttpResponse self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_list_record_string_string(self.headers, serializer); + sse_encode_http_version(self.version, serializer); + sse_encode_u_16(self.statusCode, serializer); + sse_encode_http_response_body(self.body, serializer); + } + + @protected + void sse_encode_http_response_body( + HttpResponseBody self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case HttpResponseBody_Text(field0: final field0): + sse_encode_i_32(0, serializer); + sse_encode_String(field0, serializer); + case HttpResponseBody_Bytes(field0: final field0): + sse_encode_i_32(1, serializer); + sse_encode_list_prim_u_8_strict(field0, serializer); + case HttpResponseBody_Stream(): + sse_encode_i_32(2, serializer); + default: + throw UnimplementedError(''); + } + } + + @protected + void sse_encode_http_version(HttpVersion self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.index, serializer); + } + + @protected + void sse_encode_i_32(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putInt32(self); + } + + @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_list_list_prim_u_8_strict( + List self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.length, serializer); + for (final item in self) { + sse_encode_list_prim_u_8_strict(item, serializer); + } } @protected @@ -190,6 +1884,226 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { serializer.buffer.putUint8List(self); } + @protected + void sse_encode_list_record_string_string( + List<(String, String)> self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.length, serializer); + for (final item in self) { + sse_encode_record_string_string(item, serializer); + } + } + + @protected + void + sse_encode_opt_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + RequestClient? self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + sse_encode_bool(self != null, serializer); + if (self != null) { + sse_encode_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + self, serializer); + } + } + + @protected + void sse_encode_opt_box_autoadd_Chrono_Duration( + Duration? 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_Chrono_Duration(self, serializer); + } + } + + @protected + void sse_encode_opt_box_autoadd_client_certificate( + ClientCertificate? 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_client_certificate(self, serializer); + } + } + + @protected + void sse_encode_opt_box_autoadd_client_settings( + ClientSettings? 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_client_settings(self, serializer); + } + } + + @protected + void sse_encode_opt_box_autoadd_http_headers( + HttpHeaders? 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_http_headers(self, serializer); + } + } + + @protected + void sse_encode_opt_box_autoadd_proxy_settings( + ProxySettings? 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_proxy_settings(self, serializer); + } + } + + @protected + void sse_encode_opt_box_autoadd_redirect_settings( + RedirectSettings? 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_redirect_settings(self, serializer); + } + } + + @protected + void sse_encode_opt_box_autoadd_tls_settings( + TlsSettings? 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_tls_settings(self, serializer); + } + } + + @protected + void sse_encode_opt_box_autoadd_tls_version( + TlsVersion? 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_tls_version(self, serializer); + } + } + + @protected + void sse_encode_opt_list_prim_u_8_strict( + Uint8List? self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + sse_encode_bool(self != null, serializer); + if (self != null) { + sse_encode_list_prim_u_8_strict(self, serializer); + } + } + + @protected + void sse_encode_opt_list_record_string_string( + List<(String, String)>? self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + + sse_encode_bool(self != null, serializer); + if (self != null) { + sse_encode_list_record_string_string(self, serializer); + } + } + + @protected + void sse_encode_proxy_settings(ProxySettings self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.index, serializer); + } + + @protected + void sse_encode_record_string_string( + (String, String) self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_String(self.$1, serializer); + sse_encode_String(self.$2, serializer); + } + + @protected + void sse_encode_redirect_settings( + RedirectSettings self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case RedirectSettings_NoRedirect(): + sse_encode_i_32(0, serializer); + case RedirectSettings_LimitedRedirects(field0: final field0): + sse_encode_i_32(1, serializer); + sse_encode_i_32(field0, serializer); + default: + throw UnimplementedError(''); + } + } + + @protected + void sse_encode_rhttp_error(RhttpError self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + switch (self) { + case RhttpError_RhttpCancelError(): + sse_encode_i_32(0, serializer); + case RhttpError_RhttpTimeoutError(): + sse_encode_i_32(1, serializer); + case RhttpError_RhttpRedirectError(): + sse_encode_i_32(2, serializer); + case RhttpError_RhttpStatusCodeError( + field0: final field0, + field1: final field1, + field2: final field2 + ): + sse_encode_i_32(3, serializer); + sse_encode_u_16(field0, serializer); + sse_encode_list_record_string_string(field1, serializer); + sse_encode_box_autoadd_http_response_body(field2, serializer); + case RhttpError_RhttpInvalidCertificateError(field0: final field0): + sse_encode_i_32(4, serializer); + sse_encode_String(field0, serializer); + case RhttpError_RhttpConnectionError(field0: final field0): + sse_encode_i_32(5, serializer); + sse_encode_String(field0, serializer); + case RhttpError_RhttpUnknownError(field0: final field0): + sse_encode_i_32(6, serializer); + sse_encode_String(field0, serializer); + default: + throw UnimplementedError(''); + } + } + + @protected + void sse_encode_tls_settings(TlsSettings self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_bool(self.trustRootCertificates, serializer); + sse_encode_list_list_prim_u_8_strict( + self.trustedRootCertificates, serializer); + sse_encode_bool(self.verifyCertificates, serializer); + sse_encode_opt_box_autoadd_client_certificate( + self.clientCertificate, serializer); + sse_encode_opt_box_autoadd_tls_version(self.minTlsVersion, serializer); + sse_encode_opt_box_autoadd_tls_version(self.maxTlsVersion, serializer); + } + + @protected + void sse_encode_tls_version(TlsVersion self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_i_32(self.index, serializer); + } + + @protected + void sse_encode_u_16(int self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + serializer.buffer.putUint16(self); + } + @protected void sse_encode_u_8(int self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs @@ -202,14 +2116,49 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { } @protected - void sse_encode_i_32(int self, SseSerializer serializer) { + void sse_encode_usize(BigInt self, SseSerializer serializer) { // Codec=Sse (Serialization based), see doc to use other codecs - serializer.buffer.putInt32(self); - } - - @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); + serializer.buffer.putBigUint64(self); } } + +@sealed +class CancellationTokenImpl extends RustOpaque implements CancellationToken { + // Not to be used by end users + CancellationTokenImpl.frbInternalDcoDecode(List wire) + : super.frbInternalDcoDecode(wire, _kStaticData); + + // Not to be used by end users + CancellationTokenImpl.frbInternalSseDecode( + BigInt ptr, int externalSizeOnNative) + : super.frbInternalSseDecode(ptr, externalSizeOnNative, _kStaticData); + + static final _kStaticData = RustArcStaticData( + rustArcIncrementStrongCount: + RustLib.instance.api.rust_arc_increment_strong_count_CancellationToken, + rustArcDecrementStrongCount: + RustLib.instance.api.rust_arc_decrement_strong_count_CancellationToken, + rustArcDecrementStrongCountPtr: RustLib + .instance.api.rust_arc_decrement_strong_count_CancellationTokenPtr, + ); +} + +@sealed +class RequestClientImpl extends RustOpaque implements RequestClient { + // Not to be used by end users + RequestClientImpl.frbInternalDcoDecode(List wire) + : super.frbInternalDcoDecode(wire, _kStaticData); + + // Not to be used by end users + RequestClientImpl.frbInternalSseDecode(BigInt ptr, int externalSizeOnNative) + : super.frbInternalSseDecode(ptr, externalSizeOnNative, _kStaticData); + + static final _kStaticData = RustArcStaticData( + rustArcIncrementStrongCount: + RustLib.instance.api.rust_arc_increment_strong_count_RequestClient, + rustArcDecrementStrongCount: + RustLib.instance.api.rust_arc_decrement_strong_count_RequestClient, + rustArcDecrementStrongCountPtr: + RustLib.instance.api.rust_arc_decrement_strong_count_RequestClientPtr, + ); +} diff --git a/lib/src/rust/frb_generated.io.dart b/lib/src/rust/frb_generated.io.dart index 32da1754..c02bd167 100644 --- a/lib/src/rust/frb_generated.io.dart +++ b/lib/src/rust/frb_generated.io.dart @@ -4,10 +4,14 @@ // ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field import 'api/image.dart'; +import 'api/rhttp/client.dart'; +import 'api/rhttp/error.dart'; +import 'api/rhttp/http.dart'; import 'dart:async'; import 'dart:convert'; import 'dart:ffi' as ffi; import 'frb_generated.dart'; +import 'lib.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated_io.dart'; abstract class RustLibApiImplPlatform extends BaseApiImpl { @@ -18,24 +22,414 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { required super.portManager, }); + CrossPlatformFinalizerArg + get rust_arc_decrement_strong_count_CancellationTokenPtr => wire + ._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationTokenPtr; + + CrossPlatformFinalizerArg + get rust_arc_decrement_strong_count_RequestClientPtr => wire + ._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClientPtr; + + @protected + AnyhowException dco_decode_AnyhowException(dynamic raw); + + @protected + RequestClient + dco_decode_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + dynamic raw); + + @protected + CancellationToken + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + dynamic raw); + + @protected + RequestClient + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + dynamic raw); + + @protected + CancellationToken + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + dynamic raw); + + @protected + RequestClient + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + dynamic raw); + + @protected + Duration dco_decode_Chrono_Duration(dynamic raw); + + @protected + FutureOr Function(CancellationToken) + dco_decode_DartFn_Inputs_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken_Output_unit_AnyhowException( + dynamic raw); + + @protected + FutureOr Function(HttpResponse) + dco_decode_DartFn_Inputs_http_response_Output_unit_AnyhowException( + dynamic raw); + + @protected + FutureOr Function(RhttpError) + dco_decode_DartFn_Inputs_rhttp_error_Output_unit_AnyhowException( + dynamic raw); + + @protected + Object dco_decode_DartOpaque(dynamic raw); + + @protected + Map dco_decode_Map_String_String(dynamic raw); + + @protected + CancellationToken + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + dynamic raw); + + @protected + RequestClient + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + dynamic raw); + + @protected + RustStreamSink dco_decode_StreamSink_list_prim_u_8_strict_Sse( + dynamic raw); + + @protected + String dco_decode_String(dynamic raw); + + @protected + bool dco_decode_bool(dynamic raw); + + @protected + Duration dco_decode_box_autoadd_Chrono_Duration(dynamic raw); + + @protected + ClientCertificate dco_decode_box_autoadd_client_certificate(dynamic raw); + + @protected + ClientSettings dco_decode_box_autoadd_client_settings(dynamic raw); + + @protected + HttpHeaders dco_decode_box_autoadd_http_headers(dynamic raw); + + @protected + HttpResponseBody dco_decode_box_autoadd_http_response_body(dynamic raw); + + @protected + ProxySettings dco_decode_box_autoadd_proxy_settings(dynamic raw); + + @protected + RedirectSettings dco_decode_box_autoadd_redirect_settings(dynamic raw); + + @protected + TlsSettings dco_decode_box_autoadd_tls_settings(dynamic raw); + + @protected + TlsVersion dco_decode_box_autoadd_tls_version(dynamic raw); + + @protected + ClientCertificate dco_decode_client_certificate(dynamic raw); + + @protected + ClientSettings dco_decode_client_settings(dynamic raw); + + @protected + HttpHeaders dco_decode_http_headers(dynamic raw); + + @protected + HttpMethod dco_decode_http_method(dynamic raw); + + @protected + HttpResponse dco_decode_http_response(dynamic raw); + + @protected + HttpResponseBody dco_decode_http_response_body(dynamic raw); + + @protected + HttpVersion dco_decode_http_version(dynamic raw); + + @protected + int dco_decode_i_32(dynamic raw); + + @protected + PlatformInt64 dco_decode_i_64(dynamic raw); + + @protected + List dco_decode_list_list_prim_u_8_strict(dynamic raw); + @protected List dco_decode_list_prim_u_8_loose(dynamic raw); @protected Uint8List dco_decode_list_prim_u_8_strict(dynamic raw); + @protected + List<(String, String)> dco_decode_list_record_string_string(dynamic raw); + + @protected + RequestClient? + dco_decode_opt_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + dynamic raw); + + @protected + Duration? dco_decode_opt_box_autoadd_Chrono_Duration(dynamic raw); + + @protected + ClientCertificate? dco_decode_opt_box_autoadd_client_certificate(dynamic raw); + + @protected + ClientSettings? dco_decode_opt_box_autoadd_client_settings(dynamic raw); + + @protected + HttpHeaders? dco_decode_opt_box_autoadd_http_headers(dynamic raw); + + @protected + ProxySettings? dco_decode_opt_box_autoadd_proxy_settings(dynamic raw); + + @protected + RedirectSettings? dco_decode_opt_box_autoadd_redirect_settings(dynamic raw); + + @protected + TlsSettings? dco_decode_opt_box_autoadd_tls_settings(dynamic raw); + + @protected + TlsVersion? dco_decode_opt_box_autoadd_tls_version(dynamic raw); + + @protected + Uint8List? dco_decode_opt_list_prim_u_8_strict(dynamic raw); + + @protected + List<(String, String)>? dco_decode_opt_list_record_string_string(dynamic raw); + + @protected + ProxySettings dco_decode_proxy_settings(dynamic raw); + + @protected + (String, String) dco_decode_record_string_string(dynamic raw); + + @protected + RedirectSettings dco_decode_redirect_settings(dynamic raw); + + @protected + RhttpError dco_decode_rhttp_error(dynamic raw); + + @protected + TlsSettings dco_decode_tls_settings(dynamic raw); + + @protected + TlsVersion dco_decode_tls_version(dynamic raw); + + @protected + int dco_decode_u_16(dynamic raw); + @protected int dco_decode_u_8(dynamic raw); @protected void dco_decode_unit(dynamic raw); + @protected + BigInt dco_decode_usize(dynamic raw); + + @protected + AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer); + + @protected + RequestClient + sse_decode_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + SseDeserializer deserializer); + + @protected + CancellationToken + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + SseDeserializer deserializer); + + @protected + RequestClient + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + SseDeserializer deserializer); + + @protected + CancellationToken + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + SseDeserializer deserializer); + + @protected + RequestClient + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + SseDeserializer deserializer); + + @protected + Duration sse_decode_Chrono_Duration(SseDeserializer deserializer); + + @protected + Object sse_decode_DartOpaque(SseDeserializer deserializer); + + @protected + Map sse_decode_Map_String_String( + SseDeserializer deserializer); + + @protected + CancellationToken + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + SseDeserializer deserializer); + + @protected + RequestClient + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + SseDeserializer deserializer); + + @protected + RustStreamSink sse_decode_StreamSink_list_prim_u_8_strict_Sse( + SseDeserializer deserializer); + + @protected + String sse_decode_String(SseDeserializer deserializer); + + @protected + bool sse_decode_bool(SseDeserializer deserializer); + + @protected + Duration sse_decode_box_autoadd_Chrono_Duration(SseDeserializer deserializer); + + @protected + ClientCertificate sse_decode_box_autoadd_client_certificate( + SseDeserializer deserializer); + + @protected + ClientSettings sse_decode_box_autoadd_client_settings( + SseDeserializer deserializer); + + @protected + HttpHeaders sse_decode_box_autoadd_http_headers(SseDeserializer deserializer); + + @protected + HttpResponseBody sse_decode_box_autoadd_http_response_body( + SseDeserializer deserializer); + + @protected + ProxySettings sse_decode_box_autoadd_proxy_settings( + SseDeserializer deserializer); + + @protected + RedirectSettings sse_decode_box_autoadd_redirect_settings( + SseDeserializer deserializer); + + @protected + TlsSettings sse_decode_box_autoadd_tls_settings(SseDeserializer deserializer); + + @protected + TlsVersion sse_decode_box_autoadd_tls_version(SseDeserializer deserializer); + + @protected + ClientCertificate sse_decode_client_certificate(SseDeserializer deserializer); + + @protected + ClientSettings sse_decode_client_settings(SseDeserializer deserializer); + + @protected + HttpHeaders sse_decode_http_headers(SseDeserializer deserializer); + + @protected + HttpMethod sse_decode_http_method(SseDeserializer deserializer); + + @protected + HttpResponse sse_decode_http_response(SseDeserializer deserializer); + + @protected + HttpResponseBody sse_decode_http_response_body(SseDeserializer deserializer); + + @protected + HttpVersion sse_decode_http_version(SseDeserializer deserializer); + + @protected + int sse_decode_i_32(SseDeserializer deserializer); + + @protected + PlatformInt64 sse_decode_i_64(SseDeserializer deserializer); + + @protected + List sse_decode_list_list_prim_u_8_strict( + SseDeserializer deserializer); + @protected List sse_decode_list_prim_u_8_loose(SseDeserializer deserializer); @protected Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer); + @protected + List<(String, String)> sse_decode_list_record_string_string( + SseDeserializer deserializer); + + @protected + RequestClient? + sse_decode_opt_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + SseDeserializer deserializer); + + @protected + Duration? sse_decode_opt_box_autoadd_Chrono_Duration( + SseDeserializer deserializer); + + @protected + ClientCertificate? sse_decode_opt_box_autoadd_client_certificate( + SseDeserializer deserializer); + + @protected + ClientSettings? sse_decode_opt_box_autoadd_client_settings( + SseDeserializer deserializer); + + @protected + HttpHeaders? sse_decode_opt_box_autoadd_http_headers( + SseDeserializer deserializer); + + @protected + ProxySettings? sse_decode_opt_box_autoadd_proxy_settings( + SseDeserializer deserializer); + + @protected + RedirectSettings? sse_decode_opt_box_autoadd_redirect_settings( + SseDeserializer deserializer); + + @protected + TlsSettings? sse_decode_opt_box_autoadd_tls_settings( + SseDeserializer deserializer); + + @protected + TlsVersion? sse_decode_opt_box_autoadd_tls_version( + SseDeserializer deserializer); + + @protected + Uint8List? sse_decode_opt_list_prim_u_8_strict(SseDeserializer deserializer); + + @protected + List<(String, String)>? sse_decode_opt_list_record_string_string( + SseDeserializer deserializer); + + @protected + ProxySettings sse_decode_proxy_settings(SseDeserializer deserializer); + + @protected + (String, String) sse_decode_record_string_string( + SseDeserializer deserializer); + + @protected + RedirectSettings sse_decode_redirect_settings(SseDeserializer deserializer); + + @protected + RhttpError sse_decode_rhttp_error(SseDeserializer deserializer); + + @protected + TlsSettings sse_decode_tls_settings(SseDeserializer deserializer); + + @protected + TlsVersion sse_decode_tls_version(SseDeserializer deserializer); + + @protected + int sse_decode_u_16(SseDeserializer deserializer); + @protected int sse_decode_u_8(SseDeserializer deserializer); @@ -43,10 +437,150 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { void sse_decode_unit(SseDeserializer deserializer); @protected - int sse_decode_i_32(SseDeserializer deserializer); + BigInt sse_decode_usize(SseDeserializer deserializer); @protected - bool sse_decode_bool(SseDeserializer deserializer); + void sse_encode_AnyhowException( + AnyhowException self, SseSerializer serializer); + + @protected + void + sse_encode_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + RequestClient self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + CancellationToken self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + RequestClient self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + CancellationToken self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + RequestClient self, SseSerializer serializer); + + @protected + void sse_encode_Chrono_Duration(Duration self, SseSerializer serializer); + + @protected + void + sse_encode_DartFn_Inputs_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken_Output_unit_AnyhowException( + FutureOr Function(CancellationToken) self, + SseSerializer serializer); + + @protected + void sse_encode_DartFn_Inputs_http_response_Output_unit_AnyhowException( + FutureOr Function(HttpResponse) self, SseSerializer serializer); + + @protected + void sse_encode_DartFn_Inputs_rhttp_error_Output_unit_AnyhowException( + FutureOr Function(RhttpError) self, SseSerializer serializer); + + @protected + void sse_encode_DartOpaque(Object self, SseSerializer serializer); + + @protected + void sse_encode_Map_String_String( + Map self, SseSerializer serializer); + + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + CancellationToken self, SseSerializer serializer); + + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + RequestClient self, SseSerializer serializer); + + @protected + void sse_encode_StreamSink_list_prim_u_8_strict_Sse( + RustStreamSink self, SseSerializer serializer); + + @protected + void sse_encode_String(String self, SseSerializer serializer); + + @protected + void sse_encode_bool(bool self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_Chrono_Duration( + Duration self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_client_certificate( + ClientCertificate self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_client_settings( + ClientSettings self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_http_headers( + HttpHeaders self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_http_response_body( + HttpResponseBody self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_proxy_settings( + ProxySettings self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_redirect_settings( + RedirectSettings self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_tls_settings( + TlsSettings self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_tls_version( + TlsVersion self, SseSerializer serializer); + + @protected + void sse_encode_client_certificate( + ClientCertificate self, SseSerializer serializer); + + @protected + void sse_encode_client_settings( + ClientSettings self, SseSerializer serializer); + + @protected + void sse_encode_http_headers(HttpHeaders self, SseSerializer serializer); + + @protected + void sse_encode_http_method(HttpMethod self, SseSerializer serializer); + + @protected + void sse_encode_http_response(HttpResponse self, SseSerializer serializer); + + @protected + void sse_encode_http_response_body( + HttpResponseBody self, SseSerializer serializer); + + @protected + void sse_encode_http_version(HttpVersion self, SseSerializer serializer); + + @protected + void sse_encode_i_32(int self, SseSerializer serializer); + + @protected + void sse_encode_i_64(PlatformInt64 self, SseSerializer serializer); + + @protected + void sse_encode_list_list_prim_u_8_strict( + List self, SseSerializer serializer); @protected void sse_encode_list_prim_u_8_loose(List self, SseSerializer serializer); @@ -55,6 +589,78 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { void sse_encode_list_prim_u_8_strict( Uint8List self, SseSerializer serializer); + @protected + void sse_encode_list_record_string_string( + List<(String, String)> self, SseSerializer serializer); + + @protected + void + sse_encode_opt_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + RequestClient? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_Chrono_Duration( + Duration? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_client_certificate( + ClientCertificate? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_client_settings( + ClientSettings? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_http_headers( + HttpHeaders? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_proxy_settings( + ProxySettings? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_redirect_settings( + RedirectSettings? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_tls_settings( + TlsSettings? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_tls_version( + TlsVersion? self, SseSerializer serializer); + + @protected + void sse_encode_opt_list_prim_u_8_strict( + Uint8List? self, SseSerializer serializer); + + @protected + void sse_encode_opt_list_record_string_string( + List<(String, String)>? self, SseSerializer serializer); + + @protected + void sse_encode_proxy_settings(ProxySettings self, SseSerializer serializer); + + @protected + void sse_encode_record_string_string( + (String, String) self, SseSerializer serializer); + + @protected + void sse_encode_redirect_settings( + RedirectSettings self, SseSerializer serializer); + + @protected + void sse_encode_rhttp_error(RhttpError self, SseSerializer serializer); + + @protected + void sse_encode_tls_settings(TlsSettings self, SseSerializer serializer); + + @protected + void sse_encode_tls_version(TlsVersion self, SseSerializer serializer); + + @protected + void sse_encode_u_16(int self, SseSerializer serializer); + @protected void sse_encode_u_8(int self, SseSerializer serializer); @@ -62,10 +668,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { void sse_encode_unit(void self, SseSerializer serializer); @protected - void sse_encode_i_32(int self, SseSerializer serializer); - - @protected - void sse_encode_bool(bool self, SseSerializer serializer); + void sse_encode_usize(BigInt self, SseSerializer serializer); } // Section: wire_class @@ -81,4 +684,68 @@ class RustLibWire implements BaseWire { /// The symbols are looked up in [dynamicLibrary]. RustLibWire(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; + + void + rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + ffi.Pointer ptr, + ) { + return _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + ptr, + ); + } + + late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationTokenPtr = + _lookup)>>( + 'frbgen_mangayomi_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken'); + late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken = + _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationTokenPtr + .asFunction)>(); + + void + rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + ffi.Pointer ptr, + ) { + return _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + ptr, + ); + } + + late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationTokenPtr = + _lookup)>>( + 'frbgen_mangayomi_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken'); + late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken = + _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationTokenPtr + .asFunction)>(); + + void + rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + ffi.Pointer ptr, + ) { + return _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + ptr, + ); + } + + late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClientPtr = + _lookup)>>( + 'frbgen_mangayomi_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient'); + late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient = + _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClientPtr + .asFunction)>(); + + void + rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + ffi.Pointer ptr, + ) { + return _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + ptr, + ); + } + + late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClientPtr = + _lookup)>>( + 'frbgen_mangayomi_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient'); + late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient = + _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClientPtr + .asFunction)>(); } diff --git a/lib/src/rust/frb_generated.web.dart b/lib/src/rust/frb_generated.web.dart index 6e79bde2..e115ca21 100644 --- a/lib/src/rust/frb_generated.web.dart +++ b/lib/src/rust/frb_generated.web.dart @@ -7,9 +7,13 @@ // ignore_for_file: argument_type_not_assignable import 'api/image.dart'; +import 'api/rhttp/client.dart'; +import 'api/rhttp/error.dart'; +import 'api/rhttp/http.dart'; import 'dart:async'; import 'dart:convert'; import 'frb_generated.dart'; +import 'lib.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated_web.dart'; abstract class RustLibApiImplPlatform extends BaseApiImpl { @@ -20,24 +24,414 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { required super.portManager, }); + CrossPlatformFinalizerArg + get rust_arc_decrement_strong_count_CancellationTokenPtr => wire + .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken; + + CrossPlatformFinalizerArg + get rust_arc_decrement_strong_count_RequestClientPtr => wire + .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient; + + @protected + AnyhowException dco_decode_AnyhowException(dynamic raw); + + @protected + RequestClient + dco_decode_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + dynamic raw); + + @protected + CancellationToken + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + dynamic raw); + + @protected + RequestClient + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + dynamic raw); + + @protected + CancellationToken + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + dynamic raw); + + @protected + RequestClient + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + dynamic raw); + + @protected + Duration dco_decode_Chrono_Duration(dynamic raw); + + @protected + FutureOr Function(CancellationToken) + dco_decode_DartFn_Inputs_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken_Output_unit_AnyhowException( + dynamic raw); + + @protected + FutureOr Function(HttpResponse) + dco_decode_DartFn_Inputs_http_response_Output_unit_AnyhowException( + dynamic raw); + + @protected + FutureOr Function(RhttpError) + dco_decode_DartFn_Inputs_rhttp_error_Output_unit_AnyhowException( + dynamic raw); + + @protected + Object dco_decode_DartOpaque(dynamic raw); + + @protected + Map dco_decode_Map_String_String(dynamic raw); + + @protected + CancellationToken + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + dynamic raw); + + @protected + RequestClient + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + dynamic raw); + + @protected + RustStreamSink dco_decode_StreamSink_list_prim_u_8_strict_Sse( + dynamic raw); + + @protected + String dco_decode_String(dynamic raw); + + @protected + bool dco_decode_bool(dynamic raw); + + @protected + Duration dco_decode_box_autoadd_Chrono_Duration(dynamic raw); + + @protected + ClientCertificate dco_decode_box_autoadd_client_certificate(dynamic raw); + + @protected + ClientSettings dco_decode_box_autoadd_client_settings(dynamic raw); + + @protected + HttpHeaders dco_decode_box_autoadd_http_headers(dynamic raw); + + @protected + HttpResponseBody dco_decode_box_autoadd_http_response_body(dynamic raw); + + @protected + ProxySettings dco_decode_box_autoadd_proxy_settings(dynamic raw); + + @protected + RedirectSettings dco_decode_box_autoadd_redirect_settings(dynamic raw); + + @protected + TlsSettings dco_decode_box_autoadd_tls_settings(dynamic raw); + + @protected + TlsVersion dco_decode_box_autoadd_tls_version(dynamic raw); + + @protected + ClientCertificate dco_decode_client_certificate(dynamic raw); + + @protected + ClientSettings dco_decode_client_settings(dynamic raw); + + @protected + HttpHeaders dco_decode_http_headers(dynamic raw); + + @protected + HttpMethod dco_decode_http_method(dynamic raw); + + @protected + HttpResponse dco_decode_http_response(dynamic raw); + + @protected + HttpResponseBody dco_decode_http_response_body(dynamic raw); + + @protected + HttpVersion dco_decode_http_version(dynamic raw); + + @protected + int dco_decode_i_32(dynamic raw); + + @protected + PlatformInt64 dco_decode_i_64(dynamic raw); + + @protected + List dco_decode_list_list_prim_u_8_strict(dynamic raw); + @protected List dco_decode_list_prim_u_8_loose(dynamic raw); @protected Uint8List dco_decode_list_prim_u_8_strict(dynamic raw); + @protected + List<(String, String)> dco_decode_list_record_string_string(dynamic raw); + + @protected + RequestClient? + dco_decode_opt_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + dynamic raw); + + @protected + Duration? dco_decode_opt_box_autoadd_Chrono_Duration(dynamic raw); + + @protected + ClientCertificate? dco_decode_opt_box_autoadd_client_certificate(dynamic raw); + + @protected + ClientSettings? dco_decode_opt_box_autoadd_client_settings(dynamic raw); + + @protected + HttpHeaders? dco_decode_opt_box_autoadd_http_headers(dynamic raw); + + @protected + ProxySettings? dco_decode_opt_box_autoadd_proxy_settings(dynamic raw); + + @protected + RedirectSettings? dco_decode_opt_box_autoadd_redirect_settings(dynamic raw); + + @protected + TlsSettings? dco_decode_opt_box_autoadd_tls_settings(dynamic raw); + + @protected + TlsVersion? dco_decode_opt_box_autoadd_tls_version(dynamic raw); + + @protected + Uint8List? dco_decode_opt_list_prim_u_8_strict(dynamic raw); + + @protected + List<(String, String)>? dco_decode_opt_list_record_string_string(dynamic raw); + + @protected + ProxySettings dco_decode_proxy_settings(dynamic raw); + + @protected + (String, String) dco_decode_record_string_string(dynamic raw); + + @protected + RedirectSettings dco_decode_redirect_settings(dynamic raw); + + @protected + RhttpError dco_decode_rhttp_error(dynamic raw); + + @protected + TlsSettings dco_decode_tls_settings(dynamic raw); + + @protected + TlsVersion dco_decode_tls_version(dynamic raw); + + @protected + int dco_decode_u_16(dynamic raw); + @protected int dco_decode_u_8(dynamic raw); @protected void dco_decode_unit(dynamic raw); + @protected + BigInt dco_decode_usize(dynamic raw); + + @protected + AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer); + + @protected + RequestClient + sse_decode_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + SseDeserializer deserializer); + + @protected + CancellationToken + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + SseDeserializer deserializer); + + @protected + RequestClient + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + SseDeserializer deserializer); + + @protected + CancellationToken + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + SseDeserializer deserializer); + + @protected + RequestClient + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + SseDeserializer deserializer); + + @protected + Duration sse_decode_Chrono_Duration(SseDeserializer deserializer); + + @protected + Object sse_decode_DartOpaque(SseDeserializer deserializer); + + @protected + Map sse_decode_Map_String_String( + SseDeserializer deserializer); + + @protected + CancellationToken + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + SseDeserializer deserializer); + + @protected + RequestClient + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + SseDeserializer deserializer); + + @protected + RustStreamSink sse_decode_StreamSink_list_prim_u_8_strict_Sse( + SseDeserializer deserializer); + + @protected + String sse_decode_String(SseDeserializer deserializer); + + @protected + bool sse_decode_bool(SseDeserializer deserializer); + + @protected + Duration sse_decode_box_autoadd_Chrono_Duration(SseDeserializer deserializer); + + @protected + ClientCertificate sse_decode_box_autoadd_client_certificate( + SseDeserializer deserializer); + + @protected + ClientSettings sse_decode_box_autoadd_client_settings( + SseDeserializer deserializer); + + @protected + HttpHeaders sse_decode_box_autoadd_http_headers(SseDeserializer deserializer); + + @protected + HttpResponseBody sse_decode_box_autoadd_http_response_body( + SseDeserializer deserializer); + + @protected + ProxySettings sse_decode_box_autoadd_proxy_settings( + SseDeserializer deserializer); + + @protected + RedirectSettings sse_decode_box_autoadd_redirect_settings( + SseDeserializer deserializer); + + @protected + TlsSettings sse_decode_box_autoadd_tls_settings(SseDeserializer deserializer); + + @protected + TlsVersion sse_decode_box_autoadd_tls_version(SseDeserializer deserializer); + + @protected + ClientCertificate sse_decode_client_certificate(SseDeserializer deserializer); + + @protected + ClientSettings sse_decode_client_settings(SseDeserializer deserializer); + + @protected + HttpHeaders sse_decode_http_headers(SseDeserializer deserializer); + + @protected + HttpMethod sse_decode_http_method(SseDeserializer deserializer); + + @protected + HttpResponse sse_decode_http_response(SseDeserializer deserializer); + + @protected + HttpResponseBody sse_decode_http_response_body(SseDeserializer deserializer); + + @protected + HttpVersion sse_decode_http_version(SseDeserializer deserializer); + + @protected + int sse_decode_i_32(SseDeserializer deserializer); + + @protected + PlatformInt64 sse_decode_i_64(SseDeserializer deserializer); + + @protected + List sse_decode_list_list_prim_u_8_strict( + SseDeserializer deserializer); + @protected List sse_decode_list_prim_u_8_loose(SseDeserializer deserializer); @protected Uint8List sse_decode_list_prim_u_8_strict(SseDeserializer deserializer); + @protected + List<(String, String)> sse_decode_list_record_string_string( + SseDeserializer deserializer); + + @protected + RequestClient? + sse_decode_opt_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + SseDeserializer deserializer); + + @protected + Duration? sse_decode_opt_box_autoadd_Chrono_Duration( + SseDeserializer deserializer); + + @protected + ClientCertificate? sse_decode_opt_box_autoadd_client_certificate( + SseDeserializer deserializer); + + @protected + ClientSettings? sse_decode_opt_box_autoadd_client_settings( + SseDeserializer deserializer); + + @protected + HttpHeaders? sse_decode_opt_box_autoadd_http_headers( + SseDeserializer deserializer); + + @protected + ProxySettings? sse_decode_opt_box_autoadd_proxy_settings( + SseDeserializer deserializer); + + @protected + RedirectSettings? sse_decode_opt_box_autoadd_redirect_settings( + SseDeserializer deserializer); + + @protected + TlsSettings? sse_decode_opt_box_autoadd_tls_settings( + SseDeserializer deserializer); + + @protected + TlsVersion? sse_decode_opt_box_autoadd_tls_version( + SseDeserializer deserializer); + + @protected + Uint8List? sse_decode_opt_list_prim_u_8_strict(SseDeserializer deserializer); + + @protected + List<(String, String)>? sse_decode_opt_list_record_string_string( + SseDeserializer deserializer); + + @protected + ProxySettings sse_decode_proxy_settings(SseDeserializer deserializer); + + @protected + (String, String) sse_decode_record_string_string( + SseDeserializer deserializer); + + @protected + RedirectSettings sse_decode_redirect_settings(SseDeserializer deserializer); + + @protected + RhttpError sse_decode_rhttp_error(SseDeserializer deserializer); + + @protected + TlsSettings sse_decode_tls_settings(SseDeserializer deserializer); + + @protected + TlsVersion sse_decode_tls_version(SseDeserializer deserializer); + + @protected + int sse_decode_u_16(SseDeserializer deserializer); + @protected int sse_decode_u_8(SseDeserializer deserializer); @@ -45,10 +439,150 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { void sse_decode_unit(SseDeserializer deserializer); @protected - int sse_decode_i_32(SseDeserializer deserializer); + BigInt sse_decode_usize(SseDeserializer deserializer); @protected - bool sse_decode_bool(SseDeserializer deserializer); + void sse_encode_AnyhowException( + AnyhowException self, SseSerializer serializer); + + @protected + void + sse_encode_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + RequestClient self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + CancellationToken self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + RequestClient self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + CancellationToken self, SseSerializer serializer); + + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + RequestClient self, SseSerializer serializer); + + @protected + void sse_encode_Chrono_Duration(Duration self, SseSerializer serializer); + + @protected + void + sse_encode_DartFn_Inputs_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken_Output_unit_AnyhowException( + FutureOr Function(CancellationToken) self, + SseSerializer serializer); + + @protected + void sse_encode_DartFn_Inputs_http_response_Output_unit_AnyhowException( + FutureOr Function(HttpResponse) self, SseSerializer serializer); + + @protected + void sse_encode_DartFn_Inputs_rhttp_error_Output_unit_AnyhowException( + FutureOr Function(RhttpError) self, SseSerializer serializer); + + @protected + void sse_encode_DartOpaque(Object self, SseSerializer serializer); + + @protected + void sse_encode_Map_String_String( + Map self, SseSerializer serializer); + + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + CancellationToken self, SseSerializer serializer); + + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + RequestClient self, SseSerializer serializer); + + @protected + void sse_encode_StreamSink_list_prim_u_8_strict_Sse( + RustStreamSink self, SseSerializer serializer); + + @protected + void sse_encode_String(String self, SseSerializer serializer); + + @protected + void sse_encode_bool(bool self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_Chrono_Duration( + Duration self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_client_certificate( + ClientCertificate self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_client_settings( + ClientSettings self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_http_headers( + HttpHeaders self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_http_response_body( + HttpResponseBody self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_proxy_settings( + ProxySettings self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_redirect_settings( + RedirectSettings self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_tls_settings( + TlsSettings self, SseSerializer serializer); + + @protected + void sse_encode_box_autoadd_tls_version( + TlsVersion self, SseSerializer serializer); + + @protected + void sse_encode_client_certificate( + ClientCertificate self, SseSerializer serializer); + + @protected + void sse_encode_client_settings( + ClientSettings self, SseSerializer serializer); + + @protected + void sse_encode_http_headers(HttpHeaders self, SseSerializer serializer); + + @protected + void sse_encode_http_method(HttpMethod self, SseSerializer serializer); + + @protected + void sse_encode_http_response(HttpResponse self, SseSerializer serializer); + + @protected + void sse_encode_http_response_body( + HttpResponseBody self, SseSerializer serializer); + + @protected + void sse_encode_http_version(HttpVersion self, SseSerializer serializer); + + @protected + void sse_encode_i_32(int self, SseSerializer serializer); + + @protected + void sse_encode_i_64(PlatformInt64 self, SseSerializer serializer); + + @protected + void sse_encode_list_list_prim_u_8_strict( + List self, SseSerializer serializer); @protected void sse_encode_list_prim_u_8_loose(List self, SseSerializer serializer); @@ -57,6 +591,78 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { void sse_encode_list_prim_u_8_strict( Uint8List self, SseSerializer serializer); + @protected + void sse_encode_list_record_string_string( + List<(String, String)> self, SseSerializer serializer); + + @protected + void + sse_encode_opt_AutoExplicit_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + RequestClient? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_Chrono_Duration( + Duration? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_client_certificate( + ClientCertificate? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_client_settings( + ClientSettings? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_http_headers( + HttpHeaders? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_proxy_settings( + ProxySettings? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_redirect_settings( + RedirectSettings? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_tls_settings( + TlsSettings? self, SseSerializer serializer); + + @protected + void sse_encode_opt_box_autoadd_tls_version( + TlsVersion? self, SseSerializer serializer); + + @protected + void sse_encode_opt_list_prim_u_8_strict( + Uint8List? self, SseSerializer serializer); + + @protected + void sse_encode_opt_list_record_string_string( + List<(String, String)>? self, SseSerializer serializer); + + @protected + void sse_encode_proxy_settings(ProxySettings self, SseSerializer serializer); + + @protected + void sse_encode_record_string_string( + (String, String) self, SseSerializer serializer); + + @protected + void sse_encode_redirect_settings( + RedirectSettings self, SseSerializer serializer); + + @protected + void sse_encode_rhttp_error(RhttpError self, SseSerializer serializer); + + @protected + void sse_encode_tls_settings(TlsSettings self, SseSerializer serializer); + + @protected + void sse_encode_tls_version(TlsVersion self, SseSerializer serializer); + + @protected + void sse_encode_u_16(int self, SseSerializer serializer); + @protected void sse_encode_u_8(int self, SseSerializer serializer); @@ -64,16 +670,37 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { void sse_encode_unit(void self, SseSerializer serializer); @protected - void sse_encode_i_32(int self, SseSerializer serializer); - - @protected - void sse_encode_bool(bool self, SseSerializer serializer); + void sse_encode_usize(BigInt self, SseSerializer serializer); } // Section: wire_class class RustLibWire implements BaseWire { RustLibWire.fromExternalLibrary(ExternalLibrary lib); + + void rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + int ptr) => + wasmModule + .rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + ptr); + + void rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + int ptr) => + wasmModule + .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + ptr); + + void rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + int ptr) => + wasmModule + .rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + ptr); + + void rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + int ptr) => + wasmModule + .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + ptr); } @JS('wasm_bindgen') @@ -81,4 +708,20 @@ external RustLibWasmModule get wasmModule; @JS() @anonymous -extension type RustLibWasmModule._(JSObject _) implements JSObject {} +extension type RustLibWasmModule._(JSObject _) implements JSObject { + external void + rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + int ptr); + + external void + rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + int ptr); + + external void + rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + int ptr); + + external void + rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + int ptr); +} diff --git a/lib/src/rust/lib.dart b/lib/src/rust/lib.dart new file mode 100644 index 00000000..ecb1f003 --- /dev/null +++ b/lib/src/rust/lib.dart @@ -0,0 +1,10 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.3.0. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import 'frb_generated.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; + +// Rust type: RustOpaqueMoi> +abstract class CancellationToken implements RustOpaqueInterface {} diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index f67aa4b3..2e6da95e 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -15,7 +15,6 @@ list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_FFI_PLUGIN_LIST media_kit_native_event_loop - rhttp rust_lib_mangayomi ) diff --git a/pubspec.lock b/pubspec.lock index 12ac377a..040adf87 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -254,14 +254,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" - cupertino_http: - dependency: "direct main" - description: - name: cupertino_http - sha256: "7e75c45a27cc13a886ab0a1e4d8570078397057bd612de9d24fe5df0d9387717" - url: "https://pub.dev" - source: hosted - version: "1.5.1" cupertino_icons: dependency: "direct main" description: @@ -290,10 +282,10 @@ packages: dependency: transitive description: name: dart_style - sha256: "99e066ce75c89d6b29903d788a7bb9369cf754f7b24bf70bf4b6d6d6b26853b9" + sha256: "7856d364b589d1f08986e140938578ed36ed948581fbc3bc9aef1805039ac5ab" url: "https://pub.dev" source: hosted - version: "2.3.6" + version: "2.3.7" dartx: dependency: transitive description: @@ -371,18 +363,18 @@ packages: dependency: transitive description: name: expressions - sha256: "0a3a207dc4697bbb0e17c731c7f10f2df6f88d9dbb99ac83c4168a10b57e7a20" + sha256: "308a621b602923dd8a0cf3072793b24850d06453eb49c6b698cbda41a282e904" url: "https://pub.dev" source: hosted - version: "0.2.5+1" + version: "0.2.5+2" extended_image: dependency: "direct main" description: name: extended_image - sha256: "9786aab821aac117763d6e4419cd49f5031fbaacfe3fd212c5b313d0334c37a9" + sha256: "1733803146df102c66e71af8099afd0e5dafc96ff6aa4802825e82108e8fb897" url: "https://pub.dev" source: hosted - version: "8.2.1" + version: "8.2.2" extended_image_library: dependency: transitive description: @@ -581,8 +573,16 @@ packages: url: "https://pub.dev" source: hosted version: "10.7.0" + freezed: + dependency: "direct dev" + description: + name: freezed + sha256: "44c19278dd9d89292cf46e97dc0c1e52ce03275f40a97c5a348e802a924bf40e" + url: "https://pub.dev" + source: hosted + version: "2.5.7" freezed_annotation: - dependency: transitive + dependency: "direct main" description: name: freezed_annotation sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2 @@ -701,14 +701,6 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.0" - http_profile: - dependency: transitive - description: - name: http_profile - sha256: "7e679e355b09aaee2ab5010915c932cce3f2d1c11c3b2dc177891687014ffa78" - url: "https://pub.dev" - source: hosted - version: "0.1.0" image: dependency: transitive description: @@ -1124,10 +1116,10 @@ packages: dependency: transitive description: name: permission_handler_platform_interface - sha256: fe0ffe274d665be8e34f9c59705441a7d248edebbe5d9e3ec2665f88b79358ea + sha256: e9c8eadee926c4532d0305dff94b85bf961f16759c3af791486613152af4b4f9 url: "https://pub.dev" source: hosted - version: "4.2.2" + version: "4.2.3" permission_handler_windows: dependency: transitive description: @@ -1232,15 +1224,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.2.0" - rhttp: - dependency: "direct main" - description: - path: rhttp - ref: main - resolved-ref: e2c8dd04320936213c1f6ae66a3768b2b4f3a49a - url: "https://github.com/kodjodevf/rhttp.git" - source: git - version: "0.7.0" riverpod: dependency: transitive description: @@ -1284,10 +1267,10 @@ packages: dependency: transitive description: name: rxdart - sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb" + sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962" url: "https://pub.dev" source: hosted - version: "0.27.7" + version: "0.28.0" safe_local_storage: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 679b5eaf..6e03ef9f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -75,14 +75,9 @@ dependencies: rust_lib_mangayomi: path: rust_builder pseudom: ^1.0.1 - rhttp: - git: - url: https://github.com/kodjodevf/rhttp.git - path: rhttp - ref: main - cupertino_http: ^1.5.1 shelf: ^1.4.2 path: ^1.9.0 + freezed_annotation: ^2.0.0 dependency_overrides: http: ^1.2.1 @@ -116,6 +111,7 @@ dev_dependencies: flutter_launcher_icons: ^0.13.1 isar_generator: ^3.1.0+1 flutter_lints: ^4.0.0 + freezed: ^2.0.0 flutter: uses-material-design: true diff --git a/rust/Cargo.lock b/rust/Cargo.lock index e621c3e1..16220bc5 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -41,8 +41,15 @@ dependencies = [ "anyhow", "atomic", "backtrace", + "chrono", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_log-sys" version = "0.3.1" @@ -61,6 +68,15 @@ dependencies = [ "once_cell", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.75" @@ -96,6 +112,12 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.1.0" @@ -140,6 +162,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "bit_field" version = "0.10.2" @@ -152,6 +180,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + [[package]] name = "bitstream-io" version = "2.3.0" @@ -203,6 +237,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" +[[package]] +name = "bytes" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" + [[package]] name = "cc" version = "1.0.83" @@ -229,6 +269,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets", +] + [[package]] name = "color_quant" version = "1.1.0" @@ -245,6 +299,22 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "crc32fast" version = "1.4.2" @@ -341,6 +411,15 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + [[package]] name = "env_logger" version = "0.10.1" @@ -413,6 +492,7 @@ dependencies = [ "build-target", "bytemuck", "byteorder", + "chrono", "console_error_panic_hook", "dart-sys-fork", "delegate-attr", @@ -442,6 +522,21 @@ dependencies = [ "syn", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + [[package]] name = "futures" version = "0.3.29" @@ -486,15 +581,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-macro" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", @@ -509,15 +604,15 @@ checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -568,6 +663,25 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +[[package]] +name = "h2" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "half" version = "2.4.1" @@ -592,9 +706,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hex" @@ -602,6 +716,138 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" + +[[package]] +name = "hyper" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" +dependencies = [ + "futures-util", + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-native-certs 0.8.0", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", + "webpki-roots", +] + +[[package]] +name = "hyper-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "image" version = "0.25.1" @@ -662,6 +908,12 @@ dependencies = [ "syn", ] +[[package]] +name = "ipnet" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" + [[package]] name = "itertools" version = "0.12.1" @@ -671,6 +923,12 @@ dependencies = [ "either", ] +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + [[package]] name = "jobserver" version = "0.1.31" @@ -775,6 +1033,22 @@ version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -791,6 +1065,18 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "mio" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi", + "libc", + "wasi", + "windows-sys 0.52.0", +] + [[package]] name = "new_debug_unreachable" version = "1.0.6" @@ -888,6 +1174,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + [[package]] name = "oslog" version = "0.1.0" @@ -899,12 +1191,61 @@ dependencies = [ "log", ] +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + [[package]] name = "paste" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "pin-project-lite" version = "0.2.13" @@ -929,7 +1270,7 @@ version = "0.17.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" dependencies = [ - "bitflags", + "bitflags 1.3.2", "crc32fast", "fdeflate", "flate2", @@ -985,6 +1326,54 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" +[[package]] +name = "quinn" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" +dependencies = [ + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "quinn-proto" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" +dependencies = [ + "bytes", + "rand", + "ring", + "rustc-hash", + "rustls", + "slab", + "thiserror", + "tinyvec", + "tracing", +] + +[[package]] +name = "quinn-udp" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" +dependencies = [ + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.59.0", +] + [[package]] name = "quote" version = "1.0.36" @@ -1094,6 +1483,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "redox_syscall" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +dependencies = [ + "bitflags 2.6.0", +] + [[package]] name = "regex" version = "1.10.6" @@ -1123,6 +1521,54 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "reqwest" +version = "0.12.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "mime_guess", + "once_cell", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-native-certs 0.7.3", + "rustls-pemfile", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tokio-util", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "webpki-roots", + "windows-registry", +] + [[package]] name = "rgb" version = "0.8.37" @@ -1132,12 +1578,32 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rust_lib_mangayomi" version = "0.1.0" dependencies = [ + "chrono", "flutter_rust_bridge", + "futures-util", "image", + "reqwest", + "tokio", + "tokio-util", ] [[package]] @@ -1146,12 +1612,123 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + +[[package]] +name = "rustls" +version = "0.23.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" +dependencies = [ + "base64", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" + +[[package]] +name = "rustls-webpki" +version = "0.102.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "schannel" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "serde" version = "1.0.209" @@ -1172,6 +1749,18 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_json" +version = "1.0.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + [[package]] name = "serde_spanned" version = "0.6.6" @@ -1181,6 +1770,27 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + [[package]] name = "simd-adler32" version = "0.3.7" @@ -1211,6 +1821,16 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "spin" version = "0.9.8" @@ -1220,6 +1840,12 @@ dependencies = [ "lock_api", ] +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" version = "2.0.77" @@ -1231,6 +1857,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] + [[package]] name = "system-deps" version = "6.2.2" @@ -1291,14 +1926,71 @@ dependencies = [ ] [[package]] -name = "tokio" -version = "1.34.0" +name = "tinyvec" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", - "num_cpus", + "bytes", + "libc", + "mio", + "parking_lot", "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-macros" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls", + "rustls-pki-types", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", ] [[package]] @@ -1335,18 +2027,111 @@ dependencies = [ "winnow", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "typenum" version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "v_frame" version = "0.3.8" @@ -1370,6 +2155,15 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1442,6 +2236,19 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +[[package]] +name = "wasm-streams" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "web-sys" version = "0.3.69" @@ -1452,12 +2259,142 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.26.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "weezl" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "winnow" version = "0.6.9" @@ -1467,6 +2404,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + [[package]] name = "zune-core" version = "0.4.12" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 24881be2..31a9df76 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -7,5 +7,10 @@ edition = "2021" crate-type = ["cdylib", "staticlib"] [dependencies] -flutter_rust_bridge = "=2.3.0" +flutter_rust_bridge = { version = "=2.3.0", features = ["chrono"] } image = "0.25.0" +chrono = "0.4.38" +futures-util = "0.3.30" +reqwest = { version = "0.12.7", default-features = false, features = ["charset", "http2", "rustls-tls", "rustls-tls-native-roots", "stream", "multipart"] } +tokio = { version = "1.39.3", features = ["full"] } +tokio-util = "0.7.11" \ No newline at end of file diff --git a/rust/src/api/mod.rs b/rust/src/api/mod.rs index 26d28b46..1703651a 100644 --- a/rust/src/api/mod.rs +++ b/rust/src/api/mod.rs @@ -3,3 +3,4 @@ // pub mod image; +pub mod rhttp; \ No newline at end of file diff --git a/rust/src/api/rhttp/LICENSE b/rust/src/api/rhttp/LICENSE new file mode 100644 index 00000000..aed1c37a --- /dev/null +++ b/rust/src/api/rhttp/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Tien Do Nam + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/rust/src/api/rhttp/client.rs b/rust/src/api/rhttp/client.rs new file mode 100644 index 00000000..62057fa1 --- /dev/null +++ b/rust/src/api/rhttp/client.rs @@ -0,0 +1,165 @@ +use crate::api::rhttp::error::RhttpError; +use chrono::Duration; +use reqwest::{tls, Certificate}; +pub use tokio_util::sync::CancellationToken; + +pub struct ClientSettings { + pub timeout: Option, + pub connect_timeout: Option, + pub throw_on_status_code: bool, + pub proxy_settings: Option, + pub redirect_settings: Option, + pub tls_settings: Option, +} + +pub enum ProxySettings { + NoProxy, +} + +pub enum RedirectSettings { + NoRedirect, + LimitedRedirects(i32), +} + +pub struct TlsSettings { + pub trust_root_certificates: bool, + pub trusted_root_certificates: Vec>, + pub verify_certificates: bool, + pub client_certificate: Option, + pub min_tls_version: Option, + pub max_tls_version: Option, +} + +pub struct ClientCertificate { + pub certificate: Vec, + pub private_key: Vec, +} + +pub enum TlsVersion { + Tls1_2, + Tls1_3, +} + +impl Default for ClientSettings { + fn default() -> Self { + ClientSettings { + timeout: None, + connect_timeout: None, + throw_on_status_code: true, + proxy_settings: None, + redirect_settings: None, + tls_settings: None, + } + } +} + +#[derive(Clone)] +pub struct RequestClient { + pub(crate) client: reqwest::Client, + pub(crate) throw_on_status_code: bool, + + /// A token that can be used to cancel all requests made by this client. + pub(crate) cancel_token: CancellationToken, +} + +impl RequestClient { + pub(crate) fn new_default() -> Self { + create_client(ClientSettings::default()).unwrap() + } + + pub(crate) fn new(settings: ClientSettings) -> Result { + create_client(settings) + } +} + +fn create_client(settings: ClientSettings) -> Result { + let client: reqwest::Client = { + let mut client = reqwest::Client::builder(); + if let Some(proxy_settings) = settings.proxy_settings { + match proxy_settings { + ProxySettings::NoProxy => client = client.no_proxy(), + } + } + + if let Some(redirect_settings) = settings.redirect_settings { + client = match redirect_settings { + RedirectSettings::NoRedirect => client.redirect(reqwest::redirect::Policy::none()), + RedirectSettings::LimitedRedirects(max_redirects) => { + client.redirect(reqwest::redirect::Policy::limited(max_redirects as usize)) + } + }; + } + + if let Some(timeout) = settings.timeout { + client = client.timeout( + timeout + .to_std() + .map_err(|e| RhttpError::RhttpUnknownError(e.to_string()))?, + ); + } + if let Some(timeout) = settings.connect_timeout { + client = client.connect_timeout( + timeout + .to_std() + .map_err(|e| RhttpError::RhttpUnknownError(e.to_string()))?, + ); + } + + if let Some(tls_settings) = settings.tls_settings { + if !tls_settings.trust_root_certificates { + client = client.tls_built_in_root_certs(false); + } + + for cert in tls_settings.trusted_root_certificates { + client = + client.add_root_certificate(Certificate::from_pem(&cert).map_err(|e| { + RhttpError::RhttpUnknownError(format!( + "Error adding trusted certificate: {e:?}" + )) + })?); + } + + if !tls_settings.verify_certificates { + client = client.danger_accept_invalid_certs(true); + } + + if let Some(client_certificate) = tls_settings.client_certificate { + let identity = &[ + client_certificate.certificate.as_slice(), + "\n".as_bytes(), + client_certificate.private_key.as_slice(), + ] + .concat(); + + client = client.identity( + reqwest::Identity::from_pem(identity) + .map_err(|e| RhttpError::RhttpUnknownError(format!("{e:?}")))?, + ); + } + + if let Some(min_tls_version) = tls_settings.min_tls_version { + client = client.min_tls_version(match min_tls_version { + TlsVersion::Tls1_2 => tls::Version::TLS_1_2, + TlsVersion::Tls1_3 => tls::Version::TLS_1_3, + }); + } + + if let Some(max_tls_version) = tls_settings.max_tls_version { + client = client.max_tls_version(match max_tls_version { + TlsVersion::Tls1_2 => tls::Version::TLS_1_2, + TlsVersion::Tls1_3 => tls::Version::TLS_1_3, + }); + } + } + + client + .build() + .map_err(|e| RhttpError::RhttpUnknownError(format!("{e:?}")))? + }; + + Ok(RequestClient { + client, + throw_on_status_code: settings.throw_on_status_code, + cancel_token: CancellationToken::new(), + }) +} diff --git a/rust/src/api/rhttp/error.rs b/rust/src/api/rhttp/error.rs new file mode 100644 index 00000000..a92eee8f --- /dev/null +++ b/rust/src/api/rhttp/error.rs @@ -0,0 +1,33 @@ +use crate::api::rhttp::http::HttpResponseBody; +use std::fmt::Display; + +#[derive(Clone, Debug)] +pub enum RhttpError { + RhttpCancelError, + RhttpTimeoutError, + RhttpRedirectError, + RhttpStatusCodeError(u16, Vec<(String, String)>, HttpResponseBody), + RhttpInvalidCertificateError(String), + RhttpConnectionError(String), + RhttpUnknownError(String), +} + +impl Display for RhttpError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + RhttpError::RhttpCancelError => write!(f, "RhttpCancelError"), + RhttpError::RhttpTimeoutError => write!(f, "RhttpTimeoutError"), + RhttpError::RhttpRedirectError => write!(f, "RhttpRedirectError"), + RhttpError::RhttpStatusCodeError(i, _, _) => { + write!(f, "RhttpStatusCodeError: {i}") + } + RhttpError::RhttpInvalidCertificateError(d) => { + write!(f, "RhttpInvalidCertificateError: {d}") + } + RhttpError::RhttpConnectionError(e) => write!(f, "RhttpConnectionError: {e}"), + RhttpError::RhttpUnknownError(e) => write!(f, "{}", e), + } + } +} + +impl std::error::Error for RhttpError {} diff --git a/rust/src/api/rhttp/http.rs b/rust/src/api/rhttp/http.rs new file mode 100644 index 00000000..51eb90d9 --- /dev/null +++ b/rust/src/api/rhttp/http.rs @@ -0,0 +1,335 @@ +use flutter_rust_bridge::{frb, DartFnFuture}; +use futures_util::StreamExt; +use reqwest::header::{HeaderName, HeaderValue}; +use reqwest::{Method, Response, Url, Version}; +use std::collections::HashMap; +use std::error::Error; +use std::str::FromStr; +use tokio_util::sync::CancellationToken; + +use crate::api::rhttp::client::{ClientSettings, RequestClient}; +use crate::api::rhttp::error::RhttpError; +use crate::frb_generated::{RustAutoOpaque, StreamSink}; + +pub enum HttpMethod { + Options, + Get, + Post, + Put, + Delete, + Head, + Trace, + Connect, + Patch, +} + +impl HttpMethod { + fn to_method(&self) -> Method { + match self { + HttpMethod::Options => Method::OPTIONS, + HttpMethod::Get => Method::GET, + HttpMethod::Post => Method::POST, + HttpMethod::Put => Method::PUT, + HttpMethod::Delete => Method::DELETE, + HttpMethod::Head => Method::HEAD, + HttpMethod::Trace => Method::TRACE, + HttpMethod::Connect => Method::CONNECT, + HttpMethod::Patch => Method::PATCH, + } + } +} + +pub enum HttpHeaders { + Map(HashMap), + List(Vec<(String, String)>), +} + +#[derive(Clone, Copy)] +pub enum HttpExpectBody { + Text, + Bytes, +} + +pub enum HttpVersion { + Http09, + Http10, + Http11, + Other, +} + +impl HttpVersion { + fn from_version(version: Version) -> HttpVersion { + match version { + Version::HTTP_09 => HttpVersion::Http09, + Version::HTTP_10 => HttpVersion::Http10, + Version::HTTP_11 => HttpVersion::Http11, + _ => HttpVersion::Other, + } + } +} + +pub struct HttpResponse { + pub headers: Vec<(String, String)>, + pub version: HttpVersion, + pub status_code: u16, + pub body: HttpResponseBody, +} + +#[derive(Clone, Debug)] +pub enum HttpResponseBody { + Text(String), + Bytes(Vec), + Stream, +} + +// It must be async so that frb provides an async context. +pub async fn register_client(settings: ClientSettings) -> Result { + register_client_internal(settings) +} + +#[frb(sync)] +pub fn register_client_sync(settings: ClientSettings) -> Result { + register_client_internal(settings) +} + +fn register_client_internal(settings: ClientSettings) -> Result { + let client = RequestClient::new(settings)?; + Ok(client) +} + +pub fn cancel_running_requests(client: &RequestClient) { + client.cancel_token.cancel(); +} + +struct RequestCancelTokens { + request_cancel_token: CancellationToken, + client_cancel_token: CancellationToken, +} + +fn build_cancel_tokens(client: Option>) -> RequestCancelTokens { + let client_cancel_token = match client { + Some(client) => Some(client.try_read().unwrap().cancel_token.clone()), + None => None, + } + .unwrap_or_else(|| CancellationToken::new()); + + RequestCancelTokens { + request_cancel_token: CancellationToken::new(), + client_cancel_token, + } +} + +pub async fn make_http_request_receive_stream( + client: Option>, + settings: Option, + method: HttpMethod, + url: String, + query: Option>, + headers: Option, + body: Option>, + stream_sink: StreamSink>, + on_response: impl Fn(HttpResponse) -> DartFnFuture<()>, + on_error: impl Fn(RhttpError) -> DartFnFuture<()>, + on_cancel_token: impl Fn(CancellationToken) -> DartFnFuture<()>, + cancelable: bool, +) -> Result<(), RhttpError> { + let cancel_tokens = build_cancel_tokens(client.clone()); + + if cancelable { + on_cancel_token(cancel_tokens.request_cancel_token.clone()).await; + } + + tokio::select! { + _ = cancel_tokens.request_cancel_token.cancelled() => Err(RhttpError::RhttpCancelError), + _ = cancel_tokens.client_cancel_token.cancelled() => Err(RhttpError::RhttpCancelError), + _ = make_http_request_receive_stream_inner( + client, + settings, + method, + url.to_owned(), + query, + headers, + body, + stream_sink, + on_response, + on_error, + ) => Ok(()), + } +} + +async fn make_http_request_receive_stream_inner( + client: Option>, + settings: Option, + method: HttpMethod, + url: String, + query: Option>, + headers: Option, + body: Option>, + stream_sink: StreamSink>, + on_response: impl Fn(HttpResponse) -> DartFnFuture<()>, + on_error: impl Fn(RhttpError) -> DartFnFuture<()>, +) -> Result<(), RhttpError> { + let response = + make_http_request_helper(client, settings, method, url, query, headers, body, None).await; + + let response = match response { + Ok(_) => response, + Err(e) => { + on_error(e.clone()).await; + Err(e) + } + }?; + + let http_response = HttpResponse { + headers: header_to_vec(response.headers()), + version: HttpVersion::from_version(response.version()), + status_code: response.status().as_u16(), + body: HttpResponseBody::Stream, + }; + + on_response(http_response).await; + + let mut stream = response.bytes_stream(); + + while let Some(chunk) = stream.next().await { + let chunk = chunk.map_err(|e| { + let _ = stream_sink.add_error(RhttpError::RhttpUnknownError(e.to_string())); + RhttpError::RhttpUnknownError(e.to_string()) + })?; + + stream_sink.add(chunk.to_vec()).map_err(|e| { + let _ = stream_sink.add_error(RhttpError::RhttpUnknownError(e.to_string())); + RhttpError::RhttpUnknownError(e.to_string()) + })?; + } + + Ok(()) +} + +/// This function is used to make an HTTP request without any response handling. +async fn make_http_request_helper( + client: Option>, + settings: Option, + method: HttpMethod, + url: String, + query: Option>, + headers: Option, + body: Option>, + expect_body: Option, +) -> Result { + let client: RequestClient = match client { + Some(client) => client.try_read().unwrap().clone(), + None => match settings { + Some(settings) => RequestClient::new(settings) + .map_err(|e| RhttpError::RhttpUnknownError(e.to_string()))?, + None => RequestClient::new_default(), + }, + }; + + let request = { + let mut request = client.client.request( + method.to_method(), + Url::parse(&url).map_err(|e| RhttpError::RhttpUnknownError(e.to_string()))?, + ); + + if let Some(query) = query { + request = request.query(&query); + } + + match headers { + Some(HttpHeaders::Map(map)) => { + for (k, v) in map { + let header_name = HeaderName::from_str(&k) + .map_err(|e| RhttpError::RhttpUnknownError(e.to_string()))?; + let header_value = HeaderValue::from_str(&v) + .map_err(|e| RhttpError::RhttpUnknownError(e.to_string()))?; + request = request.header(header_name, header_value); + } + } + Some(HttpHeaders::List(list)) => { + for (k, v) in list { + let header_name = HeaderName::from_str(&k) + .map_err(|e| RhttpError::RhttpUnknownError(e.to_string()))?; + let header_value = HeaderValue::from_str(&v) + .map_err(|e| RhttpError::RhttpUnknownError(e.to_string()))?; + request = request.header(header_name, header_value); + } + } + None => (), + }; + request = match body { + Some(body) => request.body(body), + None => request, + }; + + request + .build() + .map_err(|e| RhttpError::RhttpUnknownError(e.to_string()))? + }; + + let response = client.client.execute(request).await.map_err(|e| { + if e.is_redirect() { + RhttpError::RhttpRedirectError + } else if e.is_timeout() { + RhttpError::RhttpTimeoutError + } else { + // We use the debug string because it contains more information + let inner = e.source(); + let is_cert_error = match inner { + // TODO: This is a hacky way to check if the error is a certificate error + Some(inner) => format!("{:?}", inner).contains("InvalidCertificate"), + None => false, + }; + + if is_cert_error { + RhttpError::RhttpInvalidCertificateError(format!("{:?}", inner.unwrap())) + } else if e.is_connect() { + RhttpError::RhttpConnectionError(format!("{:?}", inner.unwrap())) + } else { + RhttpError::RhttpUnknownError(match inner { + Some(inner) => format!("{inner:?}"), + None => format!("{e:?}"), + }) + } + } + })?; + + if client.throw_on_status_code { + let status = response.status(); + if status.is_client_error() || status.is_server_error() { + return Err(RhttpError::RhttpStatusCodeError( + response.status().as_u16(), + header_to_vec(response.headers()), + match expect_body { + Some(HttpExpectBody::Text) => HttpResponseBody::Text( + response + .text() + .await + .map_err(|e| RhttpError::RhttpUnknownError(e.to_string()))?, + ), + Some(HttpExpectBody::Bytes) => HttpResponseBody::Bytes( + response + .bytes() + .await + .map_err(|e| RhttpError::RhttpUnknownError(e.to_string()))? + .to_vec(), + ), + _ => HttpResponseBody::Stream, + }, + )); + } + } + + Ok(response) +} + +fn header_to_vec(headers: &reqwest::header::HeaderMap) -> Vec<(String, String)> { + headers + .iter() + .map(|(k, v)| (k.as_str().to_string(), v.to_str().unwrap().to_string())) + .collect() +} + +pub fn cancel_request(token: &CancellationToken) { + token.cancel(); +} diff --git a/rust/src/api/rhttp/mod.rs b/rust/src/api/rhttp/mod.rs new file mode 100644 index 00000000..3c42d443 --- /dev/null +++ b/rust/src/api/rhttp/mod.rs @@ -0,0 +1,3 @@ +pub mod client; +pub mod error; +pub mod http; diff --git a/rust/src/frb_generated.rs b/rust/src/frb_generated.rs index ce48ffa6..85b65971 100644 --- a/rust/src/frb_generated.rs +++ b/rust/src/frb_generated.rs @@ -25,6 +25,8 @@ // Section: imports +use crate::api::rhttp::client::*; +use crate::*; use flutter_rust_bridge::for_generated::byteorder::{NativeEndian, ReadBytesExt, WriteBytesExt}; use flutter_rust_bridge::for_generated::{transform_result_dco, Lifetimeable, Lockable}; use flutter_rust_bridge::{Handler, IntoIntoDart}; @@ -37,7 +39,7 @@ flutter_rust_bridge::frb_generated_boilerplate!( default_rust_auto_opaque = RustAutoOpaqueMoi, ); pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.3.0"; -pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -287789500; +pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = 107666026; // Section: executor @@ -76,9 +78,611 @@ fn wire__crate__api__image__process_crop_image_impl( }, ) } +fn wire__crate__api__rhttp__client__client_settings_default_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_settings_default", + 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); + deserializer.end(); + move |context| { + transform_result_sse::<_, ()>((move || { + let output_ok = + Result::<_, ()>::Ok(crate::api::rhttp::client::ClientSettings::default())?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__rhttp__http__cancel_request_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: "cancel_request", + 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_token = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, ()>((move || { + let mut api_token_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_token, 0, false, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_token_guard = Some(api_token.lockable_decode_sync_ref()), + _ => unreachable!(), + } + } + let api_token_guard = api_token_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok({ + crate::api::rhttp::http::cancel_request(&*api_token_guard); + })?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__rhttp__http__cancel_running_requests_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: "cancel_running_requests", + 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_client = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| { + transform_result_sse::<_, ()>((move || { + let mut api_client_guard = None; + let decode_indices_ = + flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![ + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_client, + 0, + false, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_client_guard = Some(api_client.lockable_decode_sync_ref()), + _ => unreachable!(), + } + } + let api_client_guard = api_client_guard.unwrap(); + let output_ok = Result::<_, ()>::Ok({ + crate::api::rhttp::http::cancel_running_requests(&*api_client_guard); + })?; + Ok(output_ok) + })()) + } + }, + ) +} +fn wire__crate__api__rhttp__http__make_http_request_receive_stream_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: "make_http_request_receive_stream", 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_client = >>::sse_decode(&mut deserializer); +let api_settings = >::sse_decode(&mut deserializer); +let api_method = ::sse_decode(&mut deserializer); +let api_url = ::sse_decode(&mut deserializer); +let api_query = >>::sse_decode(&mut deserializer); +let api_headers = >::sse_decode(&mut deserializer); +let api_body = >>::sse_decode(&mut deserializer); +let api_stream_sink = ,flutter_rust_bridge::for_generated::SseCodec>>::sse_decode(&mut deserializer); +let api_on_response = decode_DartFn_Inputs_http_response_Output_unit_AnyhowException(::sse_decode(&mut deserializer)); +let api_on_error = decode_DartFn_Inputs_rhttp_error_Output_unit_AnyhowException(::sse_decode(&mut deserializer)); +let api_on_cancel_token = decode_DartFn_Inputs_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken_Output_unit_AnyhowException(::sse_decode(&mut deserializer)); +let api_cancelable = ::sse_decode(&mut deserializer);deserializer.end(); move |context| async move { + transform_result_sse::<_, crate::api::rhttp::error::RhttpError>((move || async move { + let output_ok = crate::api::rhttp::http::make_http_request_receive_stream(api_client, api_settings, api_method, api_url, api_query, api_headers, api_body, api_stream_sink, api_on_response, api_on_error, api_on_cancel_token, api_cancelable).await?; Ok(output_ok) + })().await) + } }) +} +fn wire__crate__api__rhttp__http__register_client_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: "register_client", + 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_settings = + ::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, crate::api::rhttp::error::RhttpError>( + (move || async move { + let output_ok = + crate::api::rhttp::http::register_client(api_settings).await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__rhttp__http__register_client_sync_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: "register_client_sync", + 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_settings = + ::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, crate::api::rhttp::error::RhttpError>((move || { + let output_ok = crate::api::rhttp::http::register_client_sync(api_settings)?; + Ok(output_ok) + })()) + }, + ) +} + +// Section: related_funcs + +fn decode_DartFn_Inputs_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken_Output_unit_AnyhowException( + dart_opaque: flutter_rust_bridge::DartOpaque, +) -> impl Fn(CancellationToken) -> flutter_rust_bridge::DartFnFuture<()> { + use flutter_rust_bridge::IntoDart; + + async fn body(dart_opaque: flutter_rust_bridge::DartOpaque, arg0: CancellationToken) -> () { + let args = vec![arg0.into_into_dart().into_dart()]; + let message = FLUTTER_RUST_BRIDGE_HANDLER + .dart_fn_invoke(dart_opaque, args) + .await; + + let mut deserializer = flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let action = deserializer.cursor.read_u8().unwrap(); + let ans = match action { + 0 => std::result::Result::Ok(<()>::sse_decode(&mut deserializer)), + 1 => std::result::Result::Err( + ::sse_decode(&mut deserializer), + ), + _ => unreachable!(), + }; + deserializer.end(); + let ans = ans.expect("Dart throws exception but Rust side assume it is not failable"); + ans + } + + move |arg0: CancellationToken| { + flutter_rust_bridge::for_generated::convert_into_dart_fn_future(body( + dart_opaque.clone(), + arg0, + )) + } +} +fn decode_DartFn_Inputs_http_response_Output_unit_AnyhowException( + dart_opaque: flutter_rust_bridge::DartOpaque, +) -> impl Fn(crate::api::rhttp::http::HttpResponse) -> flutter_rust_bridge::DartFnFuture<()> { + use flutter_rust_bridge::IntoDart; + + async fn body( + dart_opaque: flutter_rust_bridge::DartOpaque, + arg0: crate::api::rhttp::http::HttpResponse, + ) -> () { + let args = vec![arg0.into_into_dart().into_dart()]; + let message = FLUTTER_RUST_BRIDGE_HANDLER + .dart_fn_invoke(dart_opaque, args) + .await; + + let mut deserializer = flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let action = deserializer.cursor.read_u8().unwrap(); + let ans = match action { + 0 => std::result::Result::Ok(<()>::sse_decode(&mut deserializer)), + 1 => std::result::Result::Err( + ::sse_decode(&mut deserializer), + ), + _ => unreachable!(), + }; + deserializer.end(); + let ans = ans.expect("Dart throws exception but Rust side assume it is not failable"); + ans + } + + move |arg0: crate::api::rhttp::http::HttpResponse| { + flutter_rust_bridge::for_generated::convert_into_dart_fn_future(body( + dart_opaque.clone(), + arg0, + )) + } +} +fn decode_DartFn_Inputs_rhttp_error_Output_unit_AnyhowException( + dart_opaque: flutter_rust_bridge::DartOpaque, +) -> impl Fn(crate::api::rhttp::error::RhttpError) -> flutter_rust_bridge::DartFnFuture<()> { + use flutter_rust_bridge::IntoDart; + + async fn body( + dart_opaque: flutter_rust_bridge::DartOpaque, + arg0: crate::api::rhttp::error::RhttpError, + ) -> () { + let args = vec![arg0.into_into_dart().into_dart()]; + let message = FLUTTER_RUST_BRIDGE_HANDLER + .dart_fn_invoke(dart_opaque, args) + .await; + + let mut deserializer = flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let action = deserializer.cursor.read_u8().unwrap(); + let ans = match action { + 0 => std::result::Result::Ok(<()>::sse_decode(&mut deserializer)), + 1 => std::result::Result::Err( + ::sse_decode(&mut deserializer), + ), + _ => unreachable!(), + }; + deserializer.end(); + let ans = ans.expect("Dart throws exception but Rust side assume it is not failable"); + ans + } + + move |arg0: crate::api::rhttp::error::RhttpError| { + flutter_rust_bridge::for_generated::convert_into_dart_fn_future(body( + dart_opaque.clone(), + arg0, + )) + } +} +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 +); // Section: dart2rust +impl SseDecode for flutter_rust_bridge::for_generated::anyhow::Error { + // 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::anyhow::anyhow!("{}", inner); + } +} + +impl SseDecode for RustAutoOpaqueMoi { + // 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_explicit_decode(inner); + } +} + +impl SseDecode for CancellationToken { + // 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 RequestClient { + // 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 chrono::Duration { + // 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 chrono::Duration::microseconds(inner); + } +} + +impl SseDecode for flutter_rust_bridge::DartOpaque { + // 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 unsafe { flutter_rust_bridge::for_generated::sse_decode_dart_opaque(inner) }; + } +} + +impl SseDecode for std::collections::HashMap { + // 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 inner.into_iter().collect(); + } +} + +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> +{ + // 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 StreamSink, flutter_rust_bridge::for_generated::SseCodec> { + // 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 StreamSink::deserialize(inner); + } +} + +impl SseDecode for String { + // 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 String::from_utf8(inner).unwrap(); + } +} + +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 { + deserializer.cursor.read_u8().unwrap() != 0 + } +} + +impl SseDecode for crate::api::rhttp::client::ClientCertificate { + // 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_certificate = >::sse_decode(deserializer); + let mut var_privateKey = >::sse_decode(deserializer); + return crate::api::rhttp::client::ClientCertificate { + certificate: var_certificate, + private_key: var_privateKey, + }; + } +} + +impl SseDecode for crate::api::rhttp::client::ClientSettings { + // 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_timeout = >::sse_decode(deserializer); + let mut var_connectTimeout = >::sse_decode(deserializer); + let mut var_throwOnStatusCode = ::sse_decode(deserializer); + let mut var_proxySettings = + >::sse_decode(deserializer); + let mut var_redirectSettings = + >::sse_decode(deserializer); + let mut var_tlsSettings = + >::sse_decode(deserializer); + return crate::api::rhttp::client::ClientSettings { + timeout: var_timeout, + connect_timeout: var_connectTimeout, + throw_on_status_code: var_throwOnStatusCode, + proxy_settings: var_proxySettings, + redirect_settings: var_redirectSettings, + tls_settings: var_tlsSettings, + }; + } +} + +impl SseDecode for crate::api::rhttp::http::HttpHeaders { + // 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_field0 = + >::sse_decode(deserializer); + return crate::api::rhttp::http::HttpHeaders::Map(var_field0); + } + 1 => { + let mut var_field0 = >::sse_decode(deserializer); + return crate::api::rhttp::http::HttpHeaders::List(var_field0); + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseDecode for crate::api::rhttp::http::HttpMethod { + // 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 match inner { + 0 => crate::api::rhttp::http::HttpMethod::Options, + 1 => crate::api::rhttp::http::HttpMethod::Get, + 2 => crate::api::rhttp::http::HttpMethod::Post, + 3 => crate::api::rhttp::http::HttpMethod::Put, + 4 => crate::api::rhttp::http::HttpMethod::Delete, + 5 => crate::api::rhttp::http::HttpMethod::Head, + 6 => crate::api::rhttp::http::HttpMethod::Trace, + 7 => crate::api::rhttp::http::HttpMethod::Connect, + 8 => crate::api::rhttp::http::HttpMethod::Patch, + _ => unreachable!("Invalid variant for HttpMethod: {}", inner), + }; + } +} + +impl SseDecode for crate::api::rhttp::http::HttpResponse { + // 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_headers = >::sse_decode(deserializer); + let mut var_version = ::sse_decode(deserializer); + let mut var_statusCode = ::sse_decode(deserializer); + let mut var_body = ::sse_decode(deserializer); + return crate::api::rhttp::http::HttpResponse { + headers: var_headers, + version: var_version, + status_code: var_statusCode, + body: var_body, + }; + } +} + +impl SseDecode for crate::api::rhttp::http::HttpResponseBody { + // 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_field0 = ::sse_decode(deserializer); + return crate::api::rhttp::http::HttpResponseBody::Text(var_field0); + } + 1 => { + let mut var_field0 = >::sse_decode(deserializer); + return crate::api::rhttp::http::HttpResponseBody::Bytes(var_field0); + } + 2 => { + return crate::api::rhttp::http::HttpResponseBody::Stream; + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseDecode for crate::api::rhttp::http::HttpVersion { + // 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 match inner { + 0 => crate::api::rhttp::http::HttpVersion::Http09, + 1 => crate::api::rhttp::http::HttpVersion::Http10, + 2 => crate::api::rhttp::http::HttpVersion::Http11, + 3 => crate::api::rhttp::http::HttpVersion::Other, + _ => unreachable!("Invalid variant for HttpVersion: {}", inner), + }; + } +} + +impl SseDecode for i32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_i32::().unwrap() + } +} + +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 { + deserializer.cursor.read_i64::().unwrap() + } +} + +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 { + let mut len_ = ::sse_decode(deserializer); + let mut ans_ = vec![]; + for idx_ in 0..len_ { + ans_.push(>::sse_decode(deserializer)); + } + return ans_; + } +} + 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 { @@ -91,6 +695,278 @@ impl SseDecode for Vec { } } +impl SseDecode for Vec<(String, String)> { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut len_ = ::sse_decode(deserializer); + let mut ans_ = vec![]; + for idx_ in 0..len_ { + ans_.push(<(String, String)>::sse_decode(deserializer)); + } + return ans_; + } +} + +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, + )); + } 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, + )); + } 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, + )); + } 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, + )); + } 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)); + } else { + return None; + } + } +} + +impl SseDecode for crate::api::rhttp::client::ProxySettings { + // 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 match inner { + 0 => crate::api::rhttp::client::ProxySettings::NoProxy, + _ => unreachable!("Invalid variant for ProxySettings: {}", inner), + }; + } +} + +impl SseDecode for (String, String) { + // 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::rhttp::client::RedirectSettings { + // 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 => { + return crate::api::rhttp::client::RedirectSettings::NoRedirect; + } + 1 => { + let mut var_field0 = ::sse_decode(deserializer); + return crate::api::rhttp::client::RedirectSettings::LimitedRedirects(var_field0); + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseDecode for crate::api::rhttp::error::RhttpError { + // 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 => { + return crate::api::rhttp::error::RhttpError::RhttpCancelError; + } + 1 => { + return crate::api::rhttp::error::RhttpError::RhttpTimeoutError; + } + 2 => { + return crate::api::rhttp::error::RhttpError::RhttpRedirectError; + } + 3 => { + let mut var_field0 = ::sse_decode(deserializer); + let mut var_field1 = >::sse_decode(deserializer); + let mut var_field2 = + ::sse_decode(deserializer); + return crate::api::rhttp::error::RhttpError::RhttpStatusCodeError( + var_field0, var_field1, var_field2, + ); + } + 4 => { + let mut var_field0 = ::sse_decode(deserializer); + return crate::api::rhttp::error::RhttpError::RhttpInvalidCertificateError( + var_field0, + ); + } + 5 => { + let mut var_field0 = ::sse_decode(deserializer); + return crate::api::rhttp::error::RhttpError::RhttpConnectionError(var_field0); + } + 6 => { + let mut var_field0 = ::sse_decode(deserializer); + return crate::api::rhttp::error::RhttpError::RhttpUnknownError(var_field0); + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseDecode for crate::api::rhttp::client::TlsSettings { + // 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_trustRootCertificates = ::sse_decode(deserializer); + let mut var_trustedRootCertificates = >>::sse_decode(deserializer); + let mut var_verifyCertificates = ::sse_decode(deserializer); + let mut var_clientCertificate = + >::sse_decode(deserializer); + let mut var_minTlsVersion = + >::sse_decode(deserializer); + let mut var_maxTlsVersion = + >::sse_decode(deserializer); + return crate::api::rhttp::client::TlsSettings { + trust_root_certificates: var_trustRootCertificates, + trusted_root_certificates: var_trustedRootCertificates, + verify_certificates: var_verifyCertificates, + client_certificate: var_clientCertificate, + min_tls_version: var_minTlsVersion, + max_tls_version: var_maxTlsVersion, + }; + } +} + +impl SseDecode for crate::api::rhttp::client::TlsVersion { + // 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 match inner { + 0 => crate::api::rhttp::client::TlsVersion::Tls1_2, + 1 => crate::api::rhttp::client::TlsVersion::Tls1_3, + _ => unreachable!("Invalid variant for TlsVersion: {}", inner), + }; + } +} + +impl SseDecode for u16 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + deserializer.cursor.read_u16::().unwrap() + } +} + impl SseDecode for u8 { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -103,17 +979,10 @@ impl SseDecode for () { fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {} } -impl SseDecode for i32 { +impl SseDecode for usize { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { - deserializer.cursor.read_i32::().unwrap() - } -} - -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 { - deserializer.cursor.read_u8().unwrap() != 0 + deserializer.cursor.read_u64::().unwrap() as _ } } @@ -126,6 +995,26 @@ fn pde_ffi_dispatcher_primary_impl( ) { // Codec=Pde (Serialization + dispatch), see doc to use other codecs match func_id { + 2 => wire__crate__api__rhttp__client__client_settings_default_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 3 => wire__crate__api__rhttp__http__cancel_request_impl(port, ptr, rust_vec_len, data_len), + 4 => wire__crate__api__rhttp__http__cancel_running_requests_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 5 => wire__crate__api__rhttp__http__make_http_request_receive_stream_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 6 => wire__crate__api__rhttp__http__register_client_impl(port, ptr, rust_vec_len, data_len), _ => unreachable!(), } } @@ -139,12 +1028,588 @@ fn pde_ffi_dispatcher_sync_impl( // Codec=Pde (Serialization + dispatch), see doc to use other codecs match func_id { 1 => wire__crate__api__image__process_crop_image_impl(ptr, rust_vec_len, data_len), + 7 => wire__crate__api__rhttp__http__register_client_sync_impl(ptr, rust_vec_len, data_len), _ => unreachable!(), } } // Section: rust2dart +// 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 CancellationToken { + 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 { + 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 RequestClient { + fn into_into_dart(self) -> FrbWrapper { + self.into() + } +} + +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::rhttp::client::ClientCertificate { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.certificate.into_into_dart().into_dart(), + self.private_key.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::rhttp::client::ClientCertificate +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::rhttp::client::ClientCertificate +{ + fn into_into_dart(self) -> crate::api::rhttp::client::ClientCertificate { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::rhttp::client::ClientSettings { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.timeout.into_into_dart().into_dart(), + self.connect_timeout.into_into_dart().into_dart(), + self.throw_on_status_code.into_into_dart().into_dart(), + self.proxy_settings.into_into_dart().into_dart(), + self.redirect_settings.into_into_dart().into_dart(), + self.tls_settings.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::rhttp::client::ClientSettings +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::rhttp::client::ClientSettings +{ + fn into_into_dart(self) -> crate::api::rhttp::client::ClientSettings { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::rhttp::http::HttpHeaders { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::api::rhttp::http::HttpHeaders::Map(field0) => { + [0.into_dart(), field0.into_into_dart().into_dart()].into_dart() + } + crate::api::rhttp::http::HttpHeaders::List(field0) => { + [1.into_dart(), field0.into_into_dart().into_dart()].into_dart() + } + _ => { + unimplemented!(""); + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::rhttp::http::HttpHeaders +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::rhttp::http::HttpHeaders +{ + fn into_into_dart(self) -> crate::api::rhttp::http::HttpHeaders { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::rhttp::http::HttpMethod { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + Self::Options => 0.into_dart(), + Self::Get => 1.into_dart(), + Self::Post => 2.into_dart(), + Self::Put => 3.into_dart(), + Self::Delete => 4.into_dart(), + Self::Head => 5.into_dart(), + Self::Trace => 6.into_dart(), + Self::Connect => 7.into_dart(), + Self::Patch => 8.into_dart(), + _ => unreachable!(), + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::rhttp::http::HttpMethod +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::rhttp::http::HttpMethod +{ + fn into_into_dart(self) -> crate::api::rhttp::http::HttpMethod { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::rhttp::http::HttpResponse { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.headers.into_into_dart().into_dart(), + self.version.into_into_dart().into_dart(), + self.status_code.into_into_dart().into_dart(), + self.body.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::rhttp::http::HttpResponse +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::rhttp::http::HttpResponse +{ + fn into_into_dart(self) -> crate::api::rhttp::http::HttpResponse { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::rhttp::http::HttpResponseBody { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::api::rhttp::http::HttpResponseBody::Text(field0) => { + [0.into_dart(), field0.into_into_dart().into_dart()].into_dart() + } + crate::api::rhttp::http::HttpResponseBody::Bytes(field0) => { + [1.into_dart(), field0.into_into_dart().into_dart()].into_dart() + } + crate::api::rhttp::http::HttpResponseBody::Stream => [2.into_dart()].into_dart(), + _ => { + unimplemented!(""); + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::rhttp::http::HttpResponseBody +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::rhttp::http::HttpResponseBody +{ + fn into_into_dart(self) -> crate::api::rhttp::http::HttpResponseBody { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::rhttp::http::HttpVersion { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + Self::Http09 => 0.into_dart(), + Self::Http10 => 1.into_dart(), + Self::Http11 => 2.into_dart(), + Self::Other => 3.into_dart(), + _ => unreachable!(), + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::rhttp::http::HttpVersion +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::rhttp::http::HttpVersion +{ + fn into_into_dart(self) -> crate::api::rhttp::http::HttpVersion { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::rhttp::client::ProxySettings { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + Self::NoProxy => 0.into_dart(), + _ => unreachable!(), + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::rhttp::client::ProxySettings +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::rhttp::client::ProxySettings +{ + fn into_into_dart(self) -> crate::api::rhttp::client::ProxySettings { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::rhttp::client::RedirectSettings { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::api::rhttp::client::RedirectSettings::NoRedirect => [0.into_dart()].into_dart(), + crate::api::rhttp::client::RedirectSettings::LimitedRedirects(field0) => { + [1.into_dart(), field0.into_into_dart().into_dart()].into_dart() + } + _ => { + unimplemented!(""); + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::rhttp::client::RedirectSettings +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::rhttp::client::RedirectSettings +{ + fn into_into_dart(self) -> crate::api::rhttp::client::RedirectSettings { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::rhttp::error::RhttpError { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + crate::api::rhttp::error::RhttpError::RhttpCancelError => [0.into_dart()].into_dart(), + crate::api::rhttp::error::RhttpError::RhttpTimeoutError => [1.into_dart()].into_dart(), + crate::api::rhttp::error::RhttpError::RhttpRedirectError => [2.into_dart()].into_dart(), + crate::api::rhttp::error::RhttpError::RhttpStatusCodeError(field0, field1, field2) => [ + 3.into_dart(), + field0.into_into_dart().into_dart(), + field1.into_into_dart().into_dart(), + field2.into_into_dart().into_dart(), + ] + .into_dart(), + crate::api::rhttp::error::RhttpError::RhttpInvalidCertificateError(field0) => { + [4.into_dart(), field0.into_into_dart().into_dart()].into_dart() + } + crate::api::rhttp::error::RhttpError::RhttpConnectionError(field0) => { + [5.into_dart(), field0.into_into_dart().into_dart()].into_dart() + } + crate::api::rhttp::error::RhttpError::RhttpUnknownError(field0) => { + [6.into_dart(), field0.into_into_dart().into_dart()].into_dart() + } + _ => { + unimplemented!(""); + } + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::rhttp::error::RhttpError +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::rhttp::error::RhttpError +{ + fn into_into_dart(self) -> crate::api::rhttp::error::RhttpError { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::rhttp::client::TlsSettings { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + [ + self.trust_root_certificates.into_into_dart().into_dart(), + self.trusted_root_certificates.into_into_dart().into_dart(), + self.verify_certificates.into_into_dart().into_dart(), + self.client_certificate.into_into_dart().into_dart(), + self.min_tls_version.into_into_dart().into_dart(), + self.max_tls_version.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::rhttp::client::TlsSettings +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::rhttp::client::TlsSettings +{ + fn into_into_dart(self) -> crate::api::rhttp::client::TlsSettings { + self + } +} +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for crate::api::rhttp::client::TlsVersion { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + match self { + Self::Tls1_2 => 0.into_dart(), + Self::Tls1_3 => 1.into_dart(), + _ => unreachable!(), + } + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive + for crate::api::rhttp::client::TlsVersion +{ +} +impl flutter_rust_bridge::IntoIntoDart + for crate::api::rhttp::client::TlsVersion +{ + fn into_into_dart(self) -> crate::api::rhttp::client::TlsVersion { + self + } +} + +impl SseEncode for flutter_rust_bridge::for_generated::anyhow::Error { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode(format!("{:?}", self), serializer); + } +} + +impl SseEncode for RustAutoOpaqueMoi { + // 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_explicit_encode(self), serializer); + } +} + +impl SseEncode for CancellationToken { + // 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 RequestClient { + // 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 chrono::Duration { + // 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.num_microseconds() + .expect("cannot get microseconds from time"), + serializer, + ); + } +} + +impl SseEncode for flutter_rust_bridge::DartOpaque { + // 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.encode(), serializer); + } +} + +impl SseEncode for std::collections::HashMap { + // 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.into_iter().collect(), serializer); + } +} + +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> +{ + // 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 StreamSink, flutter_rust_bridge::for_generated::SseCodec> { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + unimplemented!("") + } +} + +impl SseEncode for String { + // 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.into_bytes(), serializer); + } +} + +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) { + serializer.cursor.write_u8(self as _).unwrap(); + } +} + +impl SseEncode for crate::api::rhttp::client::ClientCertificate { + // 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.certificate, serializer); + >::sse_encode(self.private_key, serializer); + } +} + +impl SseEncode for crate::api::rhttp::client::ClientSettings { + // 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.timeout, serializer); + >::sse_encode(self.connect_timeout, serializer); + ::sse_encode(self.throw_on_status_code, serializer); + >::sse_encode( + self.proxy_settings, + serializer, + ); + >::sse_encode( + self.redirect_settings, + serializer, + ); + >::sse_encode(self.tls_settings, serializer); + } +} + +impl SseEncode for crate::api::rhttp::http::HttpHeaders { + // 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::rhttp::http::HttpHeaders::Map(field0) => { + ::sse_encode(0, serializer); + >::sse_encode(field0, serializer); + } + crate::api::rhttp::http::HttpHeaders::List(field0) => { + ::sse_encode(1, serializer); + >::sse_encode(field0, serializer); + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseEncode for crate::api::rhttp::http::HttpMethod { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode( + match self { + crate::api::rhttp::http::HttpMethod::Options => 0, + crate::api::rhttp::http::HttpMethod::Get => 1, + crate::api::rhttp::http::HttpMethod::Post => 2, + crate::api::rhttp::http::HttpMethod::Put => 3, + crate::api::rhttp::http::HttpMethod::Delete => 4, + crate::api::rhttp::http::HttpMethod::Head => 5, + crate::api::rhttp::http::HttpMethod::Trace => 6, + crate::api::rhttp::http::HttpMethod::Connect => 7, + crate::api::rhttp::http::HttpMethod::Patch => 8, + _ => { + unimplemented!(""); + } + }, + serializer, + ); + } +} + +impl SseEncode for crate::api::rhttp::http::HttpResponse { + // 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.headers, serializer); + ::sse_encode(self.version, serializer); + ::sse_encode(self.status_code, serializer); + ::sse_encode(self.body, serializer); + } +} + +impl SseEncode for crate::api::rhttp::http::HttpResponseBody { + // 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::rhttp::http::HttpResponseBody::Text(field0) => { + ::sse_encode(0, serializer); + ::sse_encode(field0, serializer); + } + crate::api::rhttp::http::HttpResponseBody::Bytes(field0) => { + ::sse_encode(1, serializer); + >::sse_encode(field0, serializer); + } + crate::api::rhttp::http::HttpResponseBody::Stream => { + ::sse_encode(2, serializer); + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseEncode for crate::api::rhttp::http::HttpVersion { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode( + match self { + crate::api::rhttp::http::HttpVersion::Http09 => 0, + crate::api::rhttp::http::HttpVersion::Http10 => 1, + crate::api::rhttp::http::HttpVersion::Http11 => 2, + crate::api::rhttp::http::HttpVersion::Other => 3, + _ => { + unimplemented!(""); + } + }, + serializer, + ); + } +} + +impl SseEncode for i32 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_i32::(self).unwrap(); + } +} + +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) { + serializer.cursor.write_i64::(self).unwrap(); + } +} + +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) { + ::sse_encode(self.len() as _, serializer); + for item in self { + >::sse_encode(item, serializer); + } + } +} + 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) { @@ -155,6 +1620,249 @@ impl SseEncode for Vec { } } +impl SseEncode for Vec<(String, String)> { + // 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.len() as _, serializer); + for item in self { + <(String, String)>::sse_encode(item, 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 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 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 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 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 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::rhttp::client::ProxySettings { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode( + match self { + crate::api::rhttp::client::ProxySettings::NoProxy => 0, + _ => { + unimplemented!(""); + } + }, + serializer, + ); + } +} + +impl SseEncode for (String, String) { + // 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::rhttp::client::RedirectSettings { + // 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::rhttp::client::RedirectSettings::NoRedirect => { + ::sse_encode(0, serializer); + } + crate::api::rhttp::client::RedirectSettings::LimitedRedirects(field0) => { + ::sse_encode(1, serializer); + ::sse_encode(field0, serializer); + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseEncode for crate::api::rhttp::error::RhttpError { + // 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::rhttp::error::RhttpError::RhttpCancelError => { + ::sse_encode(0, serializer); + } + crate::api::rhttp::error::RhttpError::RhttpTimeoutError => { + ::sse_encode(1, serializer); + } + crate::api::rhttp::error::RhttpError::RhttpRedirectError => { + ::sse_encode(2, serializer); + } + crate::api::rhttp::error::RhttpError::RhttpStatusCodeError(field0, field1, field2) => { + ::sse_encode(3, serializer); + ::sse_encode(field0, serializer); + >::sse_encode(field1, serializer); + ::sse_encode(field2, serializer); + } + crate::api::rhttp::error::RhttpError::RhttpInvalidCertificateError(field0) => { + ::sse_encode(4, serializer); + ::sse_encode(field0, serializer); + } + crate::api::rhttp::error::RhttpError::RhttpConnectionError(field0) => { + ::sse_encode(5, serializer); + ::sse_encode(field0, serializer); + } + crate::api::rhttp::error::RhttpError::RhttpUnknownError(field0) => { + ::sse_encode(6, serializer); + ::sse_encode(field0, serializer); + } + _ => { + unimplemented!(""); + } + } + } +} + +impl SseEncode for crate::api::rhttp::client::TlsSettings { + // 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.trust_root_certificates, serializer); + >>::sse_encode(self.trusted_root_certificates, serializer); + ::sse_encode(self.verify_certificates, serializer); + >::sse_encode( + self.client_certificate, + serializer, + ); + >::sse_encode( + self.min_tls_version, + serializer, + ); + >::sse_encode( + self.max_tls_version, + serializer, + ); + } +} + +impl SseEncode for crate::api::rhttp::client::TlsVersion { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + ::sse_encode( + match self { + crate::api::rhttp::client::TlsVersion::Tls1_2 => 0, + crate::api::rhttp::client::TlsVersion::Tls1_3 => 1, + _ => { + unimplemented!(""); + } + }, + serializer, + ); + } +} + +impl SseEncode for u16 { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + serializer.cursor.write_u16::(self).unwrap(); + } +} + impl SseEncode for u8 { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -167,17 +1875,13 @@ impl SseEncode for () { fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {} } -impl SseEncode for i32 { +impl SseEncode for usize { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { - serializer.cursor.write_i32::(self).unwrap(); - } -} - -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) { - serializer.cursor.write_u8(self as _).unwrap(); + serializer + .cursor + .write_u64::(self as _) + .unwrap(); } } @@ -189,6 +1893,8 @@ mod io { // Section: imports use super::*; + use crate::api::rhttp::client::*; + use crate::*; use flutter_rust_bridge::for_generated::byteorder::{ NativeEndian, ReadBytesExt, WriteBytesExt, }; @@ -198,6 +1904,34 @@ mod io { // Section: boilerplate flutter_rust_bridge::frb_generated_boilerplate_io!(); + + #[no_mangle] + pub extern "C" fn frbgen_mangayomi_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + ptr: *const std::ffi::c_void, + ) { + MoiArc::>::increment_strong_count(ptr as _); + } + + #[no_mangle] + pub extern "C" fn frbgen_mangayomi_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + ptr: *const std::ffi::c_void, + ) { + MoiArc::>::decrement_strong_count(ptr as _); + } + + #[no_mangle] + pub extern "C" fn frbgen_mangayomi_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + ptr: *const std::ffi::c_void, + ) { + MoiArc::>::increment_strong_count(ptr as _); + } + + #[no_mangle] + pub extern "C" fn frbgen_mangayomi_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + ptr: *const std::ffi::c_void, + ) { + MoiArc::>::decrement_strong_count(ptr as _); + } } #[cfg(not(target_family = "wasm"))] pub use io::*; @@ -211,6 +1945,8 @@ mod web { // Section: imports use super::*; + use crate::api::rhttp::client::*; + use crate::*; use flutter_rust_bridge::for_generated::byteorder::{ NativeEndian, ReadBytesExt, WriteBytesExt, }; @@ -222,6 +1958,34 @@ mod web { // Section: boilerplate flutter_rust_bridge::frb_generated_boilerplate_web!(); + + #[wasm_bindgen] + pub fn rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + ptr: *const std::ffi::c_void, + ) { + MoiArc::>::increment_strong_count(ptr as _); + } + + #[wasm_bindgen] + pub fn rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerCancellationToken( + ptr: *const std::ffi::c_void, + ) { + MoiArc::>::decrement_strong_count(ptr as _); + } + + #[wasm_bindgen] + pub fn rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + ptr: *const std::ffi::c_void, + ) { + MoiArc::>::increment_strong_count(ptr as _); + } + + #[wasm_bindgen] + pub fn rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRequestClient( + ptr: *const std::ffi::c_void, + ) { + MoiArc::>::decrement_strong_count(ptr as _); + } } #[cfg(target_family = "wasm")] pub use web::*; diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 480ec039..30030d90 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -19,7 +19,6 @@ list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_FFI_PLUGIN_LIST media_kit_native_event_loop - rhttp rust_lib_mangayomi )