mirror of
https://github.com/localsend/localsend.git
synced 2026-08-07 07:14:52 +00:00
158 lines
5.0 KiB
Dart
158 lines
5.0 KiB
Dart
// This file is automatically generated, so please do not edit it.
|
|
// @generated by `flutter_rust_bridge`@ 2.12.0.
|
|
|
|
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
|
|
|
|
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
|
|
import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
|
|
import 'package:localsend_isolates/rust/api/cancel.dart';
|
|
import 'package:localsend_isolates/rust/api/model.dart';
|
|
import 'package:localsend_isolates/rust/api/stream.dart';
|
|
import 'package:localsend_isolates/rust/frb_generated.dart';
|
|
|
|
part 'http.freezed.dart';
|
|
|
|
// These functions are ignored because they are not marked as `pub`: `error_chain`, `resolve_file_content`
|
|
// 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`, `from`
|
|
|
|
/// Creates an HTTP client.
|
|
///
|
|
/// `expected_fingerprint` pins the peer to the certificate with that SHA-256
|
|
/// fingerprint (uppercase hex). It is enforced during the TLS handshake, so a
|
|
/// peer that does not present the expected certificate never receives the
|
|
/// request. Pass `None` only for discovery, where the peer is not known yet.
|
|
RsHttpClient createClient({
|
|
required String privateKey,
|
|
required String cert,
|
|
required LsHttpClientVersion version,
|
|
String? expectedFingerprint,
|
|
int? timeoutMs,
|
|
}) => RustLib.instance.api.crateApiHttpCreateClient(
|
|
privateKey: privateKey,
|
|
cert: cert,
|
|
version: version,
|
|
expectedFingerprint: expectedFingerprint,
|
|
timeoutMs: timeoutMs,
|
|
);
|
|
|
|
// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<RsHttpClient>>
|
|
abstract class RsHttpClient implements RustOpaqueInterface {
|
|
Future<void> cancel({required ProtocolType protocol, required String ip, required int port, required String sessionId});
|
|
|
|
Future<PrepareUploadResult> prepareUpload({
|
|
required ProtocolType protocol,
|
|
required String ip,
|
|
required int port,
|
|
required PrepareUploadRequestDto payload,
|
|
String? publicKey,
|
|
String? pin,
|
|
required RsCancellationToken cancelToken,
|
|
});
|
|
|
|
Future<ResultWithPublicKeyRegisterResponseDto> register({
|
|
required ProtocolType protocol,
|
|
required String ip,
|
|
required int port,
|
|
required RegisterDto payload,
|
|
});
|
|
|
|
/// Uploads a single file, emitting [RsUploadEvent]s on [sink].
|
|
///
|
|
/// Failures are emitted as [RsUploadEvent::Failed] instead of being
|
|
/// returned: flutter_rust_bridge discards the returned `Result` of
|
|
/// functions taking a [StreamSink], so a returned error would become an
|
|
/// uncaught async error killing the calling isolate.
|
|
Stream<RsUploadEvent> upload({
|
|
required ProtocolType protocol,
|
|
required String ip,
|
|
required int port,
|
|
String? publicKey,
|
|
required String sessionId,
|
|
required String fileId,
|
|
required String token,
|
|
Dart2RustStreamReceiver? binary,
|
|
String? path,
|
|
int? fileDescriptor,
|
|
required BigInt contentLength,
|
|
required RsCancellationToken cancelToken,
|
|
});
|
|
}
|
|
|
|
enum LsHttpClientVersion {
|
|
v2,
|
|
v3,
|
|
}
|
|
|
|
class PrepareUploadResult {
|
|
final int statusCode;
|
|
final PrepareUploadResponseDto? response;
|
|
|
|
const PrepareUploadResult({
|
|
required this.statusCode,
|
|
this.response,
|
|
});
|
|
|
|
@override
|
|
int get hashCode => statusCode.hashCode ^ response.hashCode;
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
other is PrepareUploadResult && runtimeType == other.runtimeType && statusCode == other.statusCode && response == other.response;
|
|
}
|
|
|
|
class ResultWithPublicKeyRegisterResponseDto {
|
|
final String? publicKey;
|
|
final RegisterResponseDto body;
|
|
|
|
const ResultWithPublicKeyRegisterResponseDto({
|
|
this.publicKey,
|
|
required this.body,
|
|
});
|
|
|
|
@override
|
|
int get hashCode => publicKey.hashCode ^ body.hashCode;
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
other is ResultWithPublicKeyRegisterResponseDto && runtimeType == other.runtimeType && publicKey == other.publicKey && body == other.body;
|
|
}
|
|
|
|
@freezed
|
|
sealed class RsHttpClientError with _$RsHttpClientError implements FrbException {
|
|
const RsHttpClientError._();
|
|
|
|
const factory RsHttpClientError.statusCode({
|
|
required int status,
|
|
String? message,
|
|
}) = RsHttpClientError_StatusCode;
|
|
const factory RsHttpClientError.reqwest(
|
|
String field0,
|
|
) = RsHttpClientError_Reqwest;
|
|
const factory RsHttpClientError.json(
|
|
String field0,
|
|
) = RsHttpClientError_Json;
|
|
const factory RsHttpClientError.io(
|
|
String field0,
|
|
) = RsHttpClientError_Io;
|
|
const factory RsHttpClientError.other(
|
|
String field0,
|
|
) = RsHttpClientError_Other;
|
|
}
|
|
|
|
@freezed
|
|
sealed class RsUploadEvent with _$RsUploadEvent {
|
|
const RsUploadEvent._();
|
|
|
|
/// The upload progress as a fraction (0.0 to 1.0). Throttled.
|
|
const factory RsUploadEvent.progress({
|
|
required double progress,
|
|
}) = RsUploadEvent_Progress;
|
|
|
|
/// The upload failed. Always the last event of the stream.
|
|
const factory RsUploadEvent.failed({
|
|
required RsHttpClientError error,
|
|
}) = RsUploadEvent_Failed;
|
|
}
|