twonly-app/lib/core/bridge/wrapper/app_database.dart

102 lines
3.2 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 '../../database/app.dart';
import '../../frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
class LegacyMigrationReport {
final PlatformInt64 legacyVersion;
final List<LegacyTableMigrationCount> tables;
const LegacyMigrationReport({
required this.legacyVersion,
required this.tables,
});
@override
int get hashCode => legacyVersion.hashCode ^ tables.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LegacyMigrationReport &&
runtimeType == other.runtimeType &&
legacyVersion == other.legacyVersion &&
tables == other.tables;
}
class LegacyTableMigrationCount {
final String table;
final PlatformInt64 rows;
const LegacyTableMigrationCount({
required this.table,
required this.rows,
});
@override
int get hashCode => table.hashCode ^ rows.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LegacyTableMigrationCount &&
runtimeType == other.runtimeType &&
table == other.table &&
rows == other.rows;
}
class RustAppDatabase {
const RustAppDatabase();
/// Streams the tables Rust has committed to.
///
/// Rust owns the connection, so writes it makes on its own never pass
/// through the Drift compatibility executor and cannot invalidate Drift's
/// query streams. Dart forwards each batch into `notifyUpdates` so
/// `watch()` keeps reflecting Rust-side writes.
///
/// An empty list means "assume every table changed". It is sent right
/// after (re)subscribing, and whenever the broadcast channel drops
/// notifications, so Dart never silently keeps stale rows on screen.
static Stream<List<String>> changes() => RustLib.instance.api
.crateBridgeWrapperAppDatabaseRustAppDatabaseChanges();
static Future<SqlExecutionResult> execute({
required String statement,
required List<SqlValue> arguments,
}) =>
RustLib.instance.api.crateBridgeWrapperAppDatabaseRustAppDatabaseExecute(
statement: statement,
arguments: arguments,
);
static Future<bool> legacyImportComplete() => RustLib.instance.api
.crateBridgeWrapperAppDatabaseRustAppDatabaseLegacyImportComplete();
/// Imports the non-Signal tables from a Drift v25 database. The import is
/// transactional and idempotent. Drift must be closed while this runs.
static Future<LegacyMigrationReport> migrateLegacyDatabase() => RustLib
.instance
.api
.crateBridgeWrapperAppDatabaseRustAppDatabaseMigrateLegacyDatabase();
static Future<SqlRows> select({
required String statement,
required List<SqlValue> arguments,
}) => RustLib.instance.api.crateBridgeWrapperAppDatabaseRustAppDatabaseSelect(
statement: statement,
arguments: arguments,
);
@override
int get hashCode => 0;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is RustAppDatabase && runtimeType == other.runtimeType;
}