From 33402d7d22c68911bf41accc8514acc1ce9670af Mon Sep 17 00:00:00 2001 From: Yesterday17 Date: Wed, 30 Aug 2023 00:45:19 +0800 Subject: [PATCH] Refactor native part --- .vscode/extensions.json | 6 + annix/.flutter_rust_bridge.yml | 27 +- annix/build.rs | 16 +- annix/src/api.rs | 229 ++++ annix/src/bridge_generated.io.rs | 415 +++++++ annix/src/bridge_generated.rs | 415 +++++++ annix/src/lib.rs | 8 +- annix/src/network/api.rs | 28 - annix/src/network/generated.io.rs | 32 - annix/src/network/generated.rs | 110 -- annix/src/network/mod.rs | 2 - annix/src/preferences/api.rs | 86 -- annix/src/preferences/generated.io.rs | 170 --- annix/src/preferences/generated.rs | 163 --- annix/src/preferences/mod.rs | 2 - annix/src/repo/api.rs | 52 - annix/src/repo/generated.io.rs | 175 --- annix/src/repo/generated.rs | 176 --- annix/src/repo/mod.rs | 2 - annix/src/store/api.rs | 66 - annix/src/store/generated.io.rs | 167 --- annix/src/store/generated.rs | 160 --- annix/src/store/mod.rs | 2 - annix/src/{utils/dummy.rs => utils.rs} | 0 annix/src/utils/mod.rs | 1 - ios/Runner/AppDelegate.swift | 2 +- ios/Runner/Runner-Bridging-Header.h | 2 +- ios/Runner/bridge_generated.h | 166 +++ ios/Runner/generated_network.h | 69 -- ios/Runner/generated_preferences.h | 101 -- ios/Runner/generated_repo.h | 111 -- ios/Runner/generated_store.h | 102 -- lib/bridge/bridge.dart | 30 - lib/bridge/bridge_definitions.dart | 242 ++++ lib/bridge/bridge_generated.dart | 1071 +++++++++++++++++ lib/bridge/generated_network.dart | 286 ----- lib/bridge/generated_preferences.dart | 579 --------- lib/bridge/generated_repo.dart | 568 --------- lib/bridge/generated_store.dart | 548 --------- lib/bridge/native.dart | 22 + lib/services/local/cache.dart | 5 +- lib/services/local/preferences.dart | 4 +- .../metadata/metadata_source_sqlite.dart | 6 +- lib/services/network/network.dart | 4 +- macos/Runner.xcodeproj/project.pbxproj | 6 +- macos/Runner/AppDelegate.swift | 2 +- macos/Runner/bridge_generated.h | 166 +++ macos/Runner/generated_network.h | 69 -- macos/Runner/generated_preferences.h | 111 -- macos/Runner/generated_repo.h | 121 -- macos/Runner/generated_store.h | 112 -- 51 files changed, 2763 insertions(+), 4252 deletions(-) create mode 100644 .vscode/extensions.json create mode 100644 annix/src/api.rs create mode 100644 annix/src/bridge_generated.io.rs create mode 100644 annix/src/bridge_generated.rs delete mode 100644 annix/src/network/api.rs delete mode 100644 annix/src/network/generated.io.rs delete mode 100644 annix/src/network/generated.rs delete mode 100644 annix/src/network/mod.rs delete mode 100644 annix/src/preferences/api.rs delete mode 100644 annix/src/preferences/generated.io.rs delete mode 100644 annix/src/preferences/generated.rs delete mode 100644 annix/src/preferences/mod.rs delete mode 100644 annix/src/repo/api.rs delete mode 100644 annix/src/repo/generated.io.rs delete mode 100644 annix/src/repo/generated.rs delete mode 100644 annix/src/repo/mod.rs delete mode 100644 annix/src/store/api.rs delete mode 100644 annix/src/store/generated.io.rs delete mode 100644 annix/src/store/generated.rs delete mode 100644 annix/src/store/mod.rs rename annix/src/{utils/dummy.rs => utils.rs} (100%) delete mode 100644 annix/src/utils/mod.rs create mode 100644 ios/Runner/bridge_generated.h delete mode 100644 ios/Runner/generated_network.h delete mode 100644 ios/Runner/generated_preferences.h delete mode 100644 ios/Runner/generated_repo.h delete mode 100644 ios/Runner/generated_store.h delete mode 100644 lib/bridge/bridge.dart create mode 100644 lib/bridge/bridge_definitions.dart create mode 100644 lib/bridge/bridge_generated.dart delete mode 100644 lib/bridge/generated_network.dart delete mode 100644 lib/bridge/generated_preferences.dart delete mode 100644 lib/bridge/generated_repo.dart delete mode 100644 lib/bridge/generated_store.dart create mode 100644 lib/bridge/native.dart create mode 100644 macos/Runner/bridge_generated.h delete mode 100644 macos/Runner/generated_network.h delete mode 100644 macos/Runner/generated_preferences.h delete mode 100644 macos/Runner/generated_repo.h delete mode 100644 macos/Runner/generated_store.h diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..7463701b --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "rust-lang.rust-analyzer", + "dart-code.flutter" + ] +} \ No newline at end of file diff --git a/annix/.flutter_rust_bridge.yml b/annix/.flutter_rust_bridge.yml index 500e6dd9..ea2250f0 100644 --- a/annix/.flutter_rust_bridge.yml +++ b/annix/.flutter_rust_bridge.yml @@ -1,33 +1,16 @@ rust_input: - - src/repo/api.rs - - src/preferences/api.rs - - src/store/api.rs - - src/network/api.rs + - src/api.rs rust_output: - - src/repo/generated.rs - - src/preferences/generated.rs - - src/store/generated.rs - - src/network/generated.rs + - src/bridge_generated.rs -class_name: - - ApiRepository - - ApiPreferenceStore - - ApiStore - - ApiNetwork dart_output: - - ../lib/bridge/generated_repo.dart - - ../lib/bridge/generated_preferences.dart - - ../lib/bridge/generated_store.dart - - ../lib/bridge/generated_network.dart + - ../lib/bridge/bridge_generated.dart c_output: - - ../ios/Runner/generated_repo.h - - ../ios/Runner/generated_preferences.h - - ../ios/Runner/generated_store.h - - ../ios/Runner/generated_network.h + - ../ios/Runner/bridge_generated.h extra_c_output_path: - ../macos/Runner/ -# dart_decl_output: ../lib/bridge/definitions.dart +dart_decl_output: ../lib/bridge/bridge_definitions.dart dart_format_line_length: 120 dart_enums_style: true # dump: [] diff --git a/annix/build.rs b/annix/build.rs index 7a31ac21..78159ca2 100644 --- a/annix/build.rs +++ b/annix/build.rs @@ -6,14 +6,14 @@ use lib_flutter_rust_bridge_codegen::{ const RUST_INPUT: &str = "src/api.rs"; fn main() { - // init_logger("./logs/", true).unwrap(); - // println!("cargo:rerun-if-changed={RUST_INPUT}"); + init_logger("./logs/", true).unwrap(); + println!("cargo:rerun-if-changed={RUST_INPUT}"); - // let raw_opts = RawOpts::try_parse_args_or_yaml().unwrap(); - // let configs = config_parse(raw_opts); - // let all_symbols = get_symbols_if_no_duplicates(&configs).unwrap(); + let raw_opts = RawOpts::try_parse_args_or_yaml().unwrap(); + let configs = config_parse(raw_opts); + let all_symbols = get_symbols_if_no_duplicates(&configs).unwrap(); - // for config_index in 0..configs.len() { - // frb_codegen_multi(&configs, config_index, &all_symbols).unwrap(); - // } + for config_index in 0..configs.len() { + frb_codegen_multi(&configs, config_index, &all_symbols).unwrap(); + } } diff --git a/annix/src/api.rs b/annix/src/api.rs new file mode 100644 index 00000000..bc20ff4f --- /dev/null +++ b/annix/src/api.rs @@ -0,0 +1,229 @@ +pub use anni_repo::{db::RepoDatabaseRead, prelude::JsonAlbum}; +pub use flutter_rust_bridge::{RustOpaque, SyncReturn}; +use once_cell::sync::Lazy; +pub use rusqlite::Connection; +pub use uuid::Uuid; + +use std::sync::RwLock; +pub use std::{path::PathBuf, sync::Mutex}; + +pub enum NetworkStatus { + Online, + Offline, +} + +impl NetworkStatus { + pub fn is_online(&self) -> bool { + match self { + NetworkStatus::Online => true, + NetworkStatus::Offline => false, + } + } +} + +pub static NETWORK: Lazy> = Lazy::new(|| RwLock::new(NetworkStatus::Offline)); + +pub fn update_network_status(is_online: bool) { + let mut network = NETWORK.write().unwrap(); + *network = if is_online { + NetworkStatus::Online + } else { + NetworkStatus::Offline + }; +} + +/// Preferences +use crate::dummy; + +dummy!(Dummy1); + +pub struct NativePreferenceStore { + pub conn: RustOpaque>>, +} + +impl NativePreferenceStore { + pub fn new(root: String) -> SyncReturn { + let db_path = PathBuf::from(&root).join("preference.db"); + std::fs::create_dir_all(&root).unwrap(); + let conn = Connection::open(db_path).unwrap(); + conn.execute( + r#" +CREATE TABLE IF NOT EXISTS preferences( + key TEXT PRIMARY KEY ON CONFLICT REPLACE, + value TEXT NOT NULL +); +"#, + (), + ) + .unwrap(); + + let conn = RustOpaque::new(Mutex::new(Dummy1(conn))); + SyncReturn(Self { conn }) + } + + pub fn get(&self, key: String) -> SyncReturn> { + let conn = self.conn.lock().unwrap(); + let mut stmt = conn + .prepare("SELECT value FROM preferences WHERE key = ?") + .unwrap(); + let mut rows = stmt.query(rusqlite::params![key]).unwrap(); + let result = rows + .next() + .ok() + .and_then(|r| r) + .and_then(|row| row.get(0).ok()); + + SyncReturn(result) + } + + pub fn set(&self, key: String, value: String) -> SyncReturn<()> { + self.conn + .lock() + .unwrap() + .execute( + "INSERT INTO preferences (key, value) VALUES (?, ?)", + rusqlite::params![key, value], + ) + .unwrap(); + + SyncReturn(()) + } + + pub fn remove(&self, key: String) -> SyncReturn<()> { + self.conn + .lock() + .unwrap() + .execute( + "DELETE FROM preferences WHERE key = ?", + rusqlite::params![key], + ) + .unwrap(); + + SyncReturn(()) + } + + pub fn remove_prefix(&self, prefix: String) -> SyncReturn<()> { + self.conn + .lock() + .unwrap() + .execute( + "DELETE FROM preferences WHERE key LIKE ?", + rusqlite::params![format!("{}%", prefix)], + ) + .unwrap(); + + SyncReturn(()) + } +} + +/// Repo + +pub struct LocalDb { + pub repo: RustOpaque>, +} + +pub struct TagItem { + pub name: String, + pub children: Vec, +} + +impl LocalDb { + pub fn new(path: String) -> LocalDb { + let repo = RepoDatabaseRead::new(path).unwrap(); + let repo = RustOpaque::new(Mutex::new(repo)); + Self { repo } + } + + pub fn get_album(&self, album_id: uuid::Uuid) -> Option { + let album = self.repo.lock().unwrap().read_album(album_id).unwrap(); + album.map(|album| JsonAlbum::from(album).to_string()) + } + + pub fn get_albums_by_tag(&self, tag: String, recursive: bool) -> Vec { + let albums = self + .repo + .lock() + .unwrap() + .get_albums_by_tag(&tag, recursive) + .unwrap(); + albums.into_iter().map(|album| album.album_id.0).collect() + } + + pub fn get_tags(&self) -> Vec { + let albums = self.repo.lock().unwrap().get_tags_relationship().unwrap(); + albums + .into_iter() + .map(|(_, tag)| TagItem { + name: tag.tag.to_string(), + children: tag + .children + .into_iter() + .map(|tag| tag.to_string()) + .collect(), + }) + .collect() + } +} + +/// API +pub type LocalStoreConnection = Mutex; + +pub struct LocalStore { + pub conn: RustOpaque, +} + +impl LocalStore { + pub fn new(root: String) -> SyncReturn { + let db_path = PathBuf::from(root).join("cache.db"); + let conn = Connection::open(db_path).unwrap(); + conn.execute( + r#" +CREATE TABLE IF NOT EXISTS store( + id INTEGER PRIMARY KEY, + category TEXT NOT NULL, + key TEXT NOT NULL, + value TEXT NOT NULL, + UNIQUE("category", "key", "value") ON CONFLICT REPLACE +);"#, + (), + ) + .unwrap(); + + let conn = RustOpaque::new(Mutex::new(conn)); + SyncReturn(Self { conn }) + } + + pub fn insert(&self, category: String, key: String, value: String) { + self.conn + .lock() + .unwrap() + .execute( + "INSERT INTO store (category, key, value) VALUES (?, ?, ?)", + rusqlite::params![category, key, value], + ) + .unwrap(); + } + + pub fn get(&self, category: String, key: String) -> Option { + let conn = self.conn.lock().unwrap(); + let mut stmt = conn + .prepare("SELECT value FROM store WHERE category = ? AND key = ?") + .unwrap(); + let mut rows = stmt.query(rusqlite::params![category, key]).unwrap(); + rows.next() + .ok() + .and_then(|r| r) + .and_then(|row| row.get(0).ok()) + } + + pub fn clear(&self, category: Option) { + self.conn + .lock() + .unwrap() + .execute( + "DELETE FROM store WHERE category = ?", + rusqlite::params![category], + ) + .unwrap(); + } +} diff --git a/annix/src/bridge_generated.io.rs b/annix/src/bridge_generated.io.rs new file mode 100644 index 00000000..a1fe2a07 --- /dev/null +++ b/annix/src/bridge_generated.io.rs @@ -0,0 +1,415 @@ +use super::*; +// Section: wire functions + +#[no_mangle] +pub extern "C" fn wire_update_network_status(port_: i64, is_online: bool) { + wire_update_network_status_impl(port_, is_online) +} + +#[no_mangle] +pub extern "C" fn wire_is_online__method__NetworkStatus(port_: i64, that: i32) { + wire_is_online__method__NetworkStatus_impl(port_, that) +} + +#[no_mangle] +pub extern "C" fn wire_new__static_method__NativePreferenceStore( + root: *mut wire_uint_8_list, +) -> support::WireSyncReturn { + wire_new__static_method__NativePreferenceStore_impl(root) +} + +#[no_mangle] +pub extern "C" fn wire_get__method__NativePreferenceStore( + that: *mut wire_NativePreferenceStore, + key: *mut wire_uint_8_list, +) -> support::WireSyncReturn { + wire_get__method__NativePreferenceStore_impl(that, key) +} + +#[no_mangle] +pub extern "C" fn wire_set__method__NativePreferenceStore( + that: *mut wire_NativePreferenceStore, + key: *mut wire_uint_8_list, + value: *mut wire_uint_8_list, +) -> support::WireSyncReturn { + wire_set__method__NativePreferenceStore_impl(that, key, value) +} + +#[no_mangle] +pub extern "C" fn wire_remove__method__NativePreferenceStore( + that: *mut wire_NativePreferenceStore, + key: *mut wire_uint_8_list, +) -> support::WireSyncReturn { + wire_remove__method__NativePreferenceStore_impl(that, key) +} + +#[no_mangle] +pub extern "C" fn wire_remove_prefix__method__NativePreferenceStore( + that: *mut wire_NativePreferenceStore, + prefix: *mut wire_uint_8_list, +) -> support::WireSyncReturn { + wire_remove_prefix__method__NativePreferenceStore_impl(that, prefix) +} + +#[no_mangle] +pub extern "C" fn wire_new__static_method__LocalDb(port_: i64, path: *mut wire_uint_8_list) { + wire_new__static_method__LocalDb_impl(port_, path) +} + +#[no_mangle] +pub extern "C" fn wire_get_album__method__LocalDb( + port_: i64, + that: *mut wire_LocalDb, + album_id: *mut wire_uint_8_list, +) { + wire_get_album__method__LocalDb_impl(port_, that, album_id) +} + +#[no_mangle] +pub extern "C" fn wire_get_albums_by_tag__method__LocalDb( + port_: i64, + that: *mut wire_LocalDb, + tag: *mut wire_uint_8_list, + recursive: bool, +) { + wire_get_albums_by_tag__method__LocalDb_impl(port_, that, tag, recursive) +} + +#[no_mangle] +pub extern "C" fn wire_get_tags__method__LocalDb(port_: i64, that: *mut wire_LocalDb) { + wire_get_tags__method__LocalDb_impl(port_, that) +} + +#[no_mangle] +pub extern "C" fn wire_new__static_method__LocalStore( + root: *mut wire_uint_8_list, +) -> support::WireSyncReturn { + wire_new__static_method__LocalStore_impl(root) +} + +#[no_mangle] +pub extern "C" fn wire_insert__method__LocalStore( + port_: i64, + that: *mut wire_LocalStore, + category: *mut wire_uint_8_list, + key: *mut wire_uint_8_list, + value: *mut wire_uint_8_list, +) { + wire_insert__method__LocalStore_impl(port_, that, category, key, value) +} + +#[no_mangle] +pub extern "C" fn wire_get__method__LocalStore( + port_: i64, + that: *mut wire_LocalStore, + category: *mut wire_uint_8_list, + key: *mut wire_uint_8_list, +) { + wire_get__method__LocalStore_impl(port_, that, category, key) +} + +#[no_mangle] +pub extern "C" fn wire_clear__method__LocalStore( + port_: i64, + that: *mut wire_LocalStore, + category: *mut wire_uint_8_list, +) { + wire_clear__method__LocalStore_impl(port_, that, category) +} + +// Section: allocate functions + +#[no_mangle] +pub extern "C" fn new_MutexConnection() -> wire_MutexConnection { + wire_MutexConnection::new_with_null_ptr() +} + +#[no_mangle] +pub extern "C" fn new_MutexDummy1Connection() -> wire_MutexDummy1Connection { + wire_MutexDummy1Connection::new_with_null_ptr() +} + +#[no_mangle] +pub extern "C" fn new_MutexRepoDatabaseRead() -> wire_MutexRepoDatabaseRead { + wire_MutexRepoDatabaseRead::new_with_null_ptr() +} + +#[no_mangle] +pub extern "C" fn new_box_autoadd_local_db_0() -> *mut wire_LocalDb { + support::new_leak_box_ptr(wire_LocalDb::new_with_null_ptr()) +} + +#[no_mangle] +pub extern "C" fn new_box_autoadd_local_store_0() -> *mut wire_LocalStore { + support::new_leak_box_ptr(wire_LocalStore::new_with_null_ptr()) +} + +#[no_mangle] +pub extern "C" fn new_box_autoadd_native_preference_store_0() -> *mut wire_NativePreferenceStore { + support::new_leak_box_ptr(wire_NativePreferenceStore::new_with_null_ptr()) +} + +#[no_mangle] +pub extern "C" fn new_uint_8_list_0(len: i32) -> *mut wire_uint_8_list { + let ans = wire_uint_8_list { + ptr: support::new_leak_vec_ptr(Default::default(), len), + len, + }; + support::new_leak_box_ptr(ans) +} + +// Section: related functions + +#[no_mangle] +pub extern "C" fn drop_opaque_MutexConnection(ptr: *const c_void) { + unsafe { + Arc::>::decrement_strong_count(ptr as _); + } +} + +#[no_mangle] +pub extern "C" fn share_opaque_MutexConnection(ptr: *const c_void) -> *const c_void { + unsafe { + Arc::>::increment_strong_count(ptr as _); + ptr + } +} + +#[no_mangle] +pub extern "C" fn drop_opaque_MutexDummy1Connection(ptr: *const c_void) { + unsafe { + Arc::>>::decrement_strong_count(ptr as _); + } +} + +#[no_mangle] +pub extern "C" fn share_opaque_MutexDummy1Connection(ptr: *const c_void) -> *const c_void { + unsafe { + Arc::>>::increment_strong_count(ptr as _); + ptr + } +} + +#[no_mangle] +pub extern "C" fn drop_opaque_MutexRepoDatabaseRead(ptr: *const c_void) { + unsafe { + Arc::>::decrement_strong_count(ptr as _); + } +} + +#[no_mangle] +pub extern "C" fn share_opaque_MutexRepoDatabaseRead(ptr: *const c_void) -> *const c_void { + unsafe { + Arc::>::increment_strong_count(ptr as _); + ptr + } +} + +// Section: impl Wire2Api + +impl Wire2Api>> for wire_MutexConnection { + fn wire2api(self) -> RustOpaque> { + unsafe { support::opaque_from_dart(self.ptr as _) } + } +} +impl Wire2Api>>> for wire_MutexDummy1Connection { + fn wire2api(self) -> RustOpaque>> { + unsafe { support::opaque_from_dart(self.ptr as _) } + } +} +impl Wire2Api>> for wire_MutexRepoDatabaseRead { + fn wire2api(self) -> RustOpaque> { + unsafe { support::opaque_from_dart(self.ptr as _) } + } +} +impl Wire2Api for *mut wire_uint_8_list { + fn wire2api(self) -> String { + let vec: Vec = self.wire2api(); + String::from_utf8_lossy(&vec).into_owned() + } +} +impl Wire2Api for *mut wire_uint_8_list { + fn wire2api(self) -> uuid::Uuid { + let single: Vec = self.wire2api(); + wire2api_uuid_ref(single.as_slice()) + } +} + +impl Wire2Api for *mut wire_LocalDb { + fn wire2api(self) -> LocalDb { + let wrap = unsafe { support::box_from_leak_ptr(self) }; + Wire2Api::::wire2api(*wrap).into() + } +} +impl Wire2Api for *mut wire_LocalStore { + fn wire2api(self) -> LocalStore { + let wrap = unsafe { support::box_from_leak_ptr(self) }; + Wire2Api::::wire2api(*wrap).into() + } +} +impl Wire2Api for *mut wire_NativePreferenceStore { + fn wire2api(self) -> NativePreferenceStore { + let wrap = unsafe { support::box_from_leak_ptr(self) }; + Wire2Api::::wire2api(*wrap).into() + } +} + +impl Wire2Api for wire_LocalDb { + fn wire2api(self) -> LocalDb { + LocalDb { + repo: self.repo.wire2api(), + } + } +} +impl Wire2Api for wire_LocalStore { + fn wire2api(self) -> LocalStore { + LocalStore { + conn: self.conn.wire2api(), + } + } +} +impl Wire2Api for wire_NativePreferenceStore { + fn wire2api(self) -> NativePreferenceStore { + NativePreferenceStore { + conn: self.conn.wire2api(), + } + } +} + +impl Wire2Api> for *mut wire_uint_8_list { + fn wire2api(self) -> Vec { + unsafe { + let wrap = support::box_from_leak_ptr(self); + support::vec_from_leak_ptr(wrap.ptr, wrap.len) + } + } +} +// Section: wire structs + +#[repr(C)] +#[derive(Clone)] +pub struct wire_MutexConnection { + ptr: *const core::ffi::c_void, +} + +#[repr(C)] +#[derive(Clone)] +pub struct wire_MutexDummy1Connection { + ptr: *const core::ffi::c_void, +} + +#[repr(C)] +#[derive(Clone)] +pub struct wire_MutexRepoDatabaseRead { + ptr: *const core::ffi::c_void, +} + +#[repr(C)] +#[derive(Clone)] +pub struct wire_LocalDb { + repo: wire_MutexRepoDatabaseRead, +} + +#[repr(C)] +#[derive(Clone)] +pub struct wire_LocalStore { + conn: wire_MutexConnection, +} + +#[repr(C)] +#[derive(Clone)] +pub struct wire_NativePreferenceStore { + conn: wire_MutexDummy1Connection, +} + +#[repr(C)] +#[derive(Clone)] +pub struct wire_uint_8_list { + ptr: *mut u8, + len: i32, +} + +// Section: impl NewWithNullPtr + +pub trait NewWithNullPtr { + fn new_with_null_ptr() -> Self; +} + +impl NewWithNullPtr for *mut T { + fn new_with_null_ptr() -> Self { + std::ptr::null_mut() + } +} + +impl NewWithNullPtr for wire_MutexConnection { + fn new_with_null_ptr() -> Self { + Self { + ptr: core::ptr::null(), + } + } +} +impl NewWithNullPtr for wire_MutexDummy1Connection { + fn new_with_null_ptr() -> Self { + Self { + ptr: core::ptr::null(), + } + } +} +impl NewWithNullPtr for wire_MutexRepoDatabaseRead { + fn new_with_null_ptr() -> Self { + Self { + ptr: core::ptr::null(), + } + } +} + +impl NewWithNullPtr for wire_LocalDb { + fn new_with_null_ptr() -> Self { + Self { + repo: wire_MutexRepoDatabaseRead::new_with_null_ptr(), + } + } +} + +impl Default for wire_LocalDb { + fn default() -> Self { + Self::new_with_null_ptr() + } +} + +impl NewWithNullPtr for wire_LocalStore { + fn new_with_null_ptr() -> Self { + Self { + conn: wire_MutexConnection::new_with_null_ptr(), + } + } +} + +impl Default for wire_LocalStore { + fn default() -> Self { + Self::new_with_null_ptr() + } +} + +impl NewWithNullPtr for wire_NativePreferenceStore { + fn new_with_null_ptr() -> Self { + Self { + conn: wire_MutexDummy1Connection::new_with_null_ptr(), + } + } +} + +impl Default for wire_NativePreferenceStore { + fn default() -> Self { + Self::new_with_null_ptr() + } +} + +// Section: sync execution mode utility + +#[no_mangle] +pub extern "C" fn free_WireSyncReturn(ptr: support::WireSyncReturn) { + unsafe { + let _ = support::box_from_leak_ptr(ptr); + }; +} diff --git a/annix/src/bridge_generated.rs b/annix/src/bridge_generated.rs new file mode 100644 index 00000000..57955b29 --- /dev/null +++ b/annix/src/bridge_generated.rs @@ -0,0 +1,415 @@ +#![allow( + non_camel_case_types, + unused, + clippy::redundant_closure, + clippy::useless_conversion, + clippy::unit_arg, + clippy::double_parens, + non_snake_case, + clippy::too_many_arguments +)] +// AUTO GENERATED FILE, DO NOT EDIT. +// Generated by `flutter_rust_bridge`@ 1.81.0. + +use crate::api::*; +use core::panic::UnwindSafe; +use flutter_rust_bridge::rust2dart::IntoIntoDart; +use flutter_rust_bridge::*; +use std::ffi::c_void; +use std::sync::Arc; + +// Section: imports + +// Section: wire functions + +fn wire_update_network_status_impl( + port_: MessagePort, + is_online: impl Wire2Api + UnwindSafe, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, ()>( + WrapInfo { + debug_name: "update_network_status", + port: Some(port_), + mode: FfiCallMode::Normal, + }, + move || { + let api_is_online = is_online.wire2api(); + move |task_callback| Ok(update_network_status(api_is_online)) + }, + ) +} +fn wire_is_online__method__NetworkStatus_impl( + port_: MessagePort, + that: impl Wire2Api + UnwindSafe, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, bool>( + WrapInfo { + debug_name: "is_online__method__NetworkStatus", + port: Some(port_), + mode: FfiCallMode::Normal, + }, + move || { + let api_that = that.wire2api(); + move |task_callback| Ok(NetworkStatus::is_online(&api_that)) + }, + ) +} +fn wire_new__static_method__NativePreferenceStore_impl( + root: impl Wire2Api + UnwindSafe, +) -> support::WireSyncReturn { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync( + WrapInfo { + debug_name: "new__static_method__NativePreferenceStore", + port: None, + mode: FfiCallMode::Sync, + }, + move || { + let api_root = root.wire2api(); + Ok(NativePreferenceStore::new(api_root)) + }, + ) +} +fn wire_get__method__NativePreferenceStore_impl( + that: impl Wire2Api + UnwindSafe, + key: impl Wire2Api + UnwindSafe, +) -> support::WireSyncReturn { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync( + WrapInfo { + debug_name: "get__method__NativePreferenceStore", + port: None, + mode: FfiCallMode::Sync, + }, + move || { + let api_that = that.wire2api(); + let api_key = key.wire2api(); + Ok(NativePreferenceStore::get(&api_that, api_key)) + }, + ) +} +fn wire_set__method__NativePreferenceStore_impl( + that: impl Wire2Api + UnwindSafe, + key: impl Wire2Api + UnwindSafe, + value: impl Wire2Api + UnwindSafe, +) -> support::WireSyncReturn { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync( + WrapInfo { + debug_name: "set__method__NativePreferenceStore", + port: None, + mode: FfiCallMode::Sync, + }, + move || { + let api_that = that.wire2api(); + let api_key = key.wire2api(); + let api_value = value.wire2api(); + Ok(NativePreferenceStore::set(&api_that, api_key, api_value)) + }, + ) +} +fn wire_remove__method__NativePreferenceStore_impl( + that: impl Wire2Api + UnwindSafe, + key: impl Wire2Api + UnwindSafe, +) -> support::WireSyncReturn { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync( + WrapInfo { + debug_name: "remove__method__NativePreferenceStore", + port: None, + mode: FfiCallMode::Sync, + }, + move || { + let api_that = that.wire2api(); + let api_key = key.wire2api(); + Ok(NativePreferenceStore::remove(&api_that, api_key)) + }, + ) +} +fn wire_remove_prefix__method__NativePreferenceStore_impl( + that: impl Wire2Api + UnwindSafe, + prefix: impl Wire2Api + UnwindSafe, +) -> support::WireSyncReturn { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync( + WrapInfo { + debug_name: "remove_prefix__method__NativePreferenceStore", + port: None, + mode: FfiCallMode::Sync, + }, + move || { + let api_that = that.wire2api(); + let api_prefix = prefix.wire2api(); + Ok(NativePreferenceStore::remove_prefix(&api_that, api_prefix)) + }, + ) +} +fn wire_new__static_method__LocalDb_impl( + port_: MessagePort, + path: impl Wire2Api + UnwindSafe, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, LocalDb>( + WrapInfo { + debug_name: "new__static_method__LocalDb", + port: Some(port_), + mode: FfiCallMode::Normal, + }, + move || { + let api_path = path.wire2api(); + move |task_callback| Ok(LocalDb::new(api_path)) + }, + ) +} +fn wire_get_album__method__LocalDb_impl( + port_: MessagePort, + that: impl Wire2Api + UnwindSafe, + album_id: impl Wire2Api + UnwindSafe, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, Option>( + WrapInfo { + debug_name: "get_album__method__LocalDb", + port: Some(port_), + mode: FfiCallMode::Normal, + }, + move || { + let api_that = that.wire2api(); + let api_album_id = album_id.wire2api(); + move |task_callback| Ok(LocalDb::get_album(&api_that, api_album_id)) + }, + ) +} +fn wire_get_albums_by_tag__method__LocalDb_impl( + port_: MessagePort, + that: impl Wire2Api + UnwindSafe, + tag: impl Wire2Api + UnwindSafe, + recursive: impl Wire2Api + UnwindSafe, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, Vec>( + WrapInfo { + debug_name: "get_albums_by_tag__method__LocalDb", + port: Some(port_), + mode: FfiCallMode::Normal, + }, + move || { + let api_that = that.wire2api(); + let api_tag = tag.wire2api(); + let api_recursive = recursive.wire2api(); + move |task_callback| { + Ok(LocalDb::get_albums_by_tag( + &api_that, + api_tag, + api_recursive, + )) + } + }, + ) +} +fn wire_get_tags__method__LocalDb_impl( + port_: MessagePort, + that: impl Wire2Api + UnwindSafe, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, Vec>( + WrapInfo { + debug_name: "get_tags__method__LocalDb", + port: Some(port_), + mode: FfiCallMode::Normal, + }, + move || { + let api_that = that.wire2api(); + move |task_callback| Ok(LocalDb::get_tags(&api_that)) + }, + ) +} +fn wire_new__static_method__LocalStore_impl( + root: impl Wire2Api + UnwindSafe, +) -> support::WireSyncReturn { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync( + WrapInfo { + debug_name: "new__static_method__LocalStore", + port: None, + mode: FfiCallMode::Sync, + }, + move || { + let api_root = root.wire2api(); + Ok(LocalStore::new(api_root)) + }, + ) +} +fn wire_insert__method__LocalStore_impl( + port_: MessagePort, + that: impl Wire2Api + UnwindSafe, + category: impl Wire2Api + UnwindSafe, + key: impl Wire2Api + UnwindSafe, + value: impl Wire2Api + UnwindSafe, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, ()>( + WrapInfo { + debug_name: "insert__method__LocalStore", + port: Some(port_), + mode: FfiCallMode::Normal, + }, + move || { + let api_that = that.wire2api(); + let api_category = category.wire2api(); + let api_key = key.wire2api(); + let api_value = value.wire2api(); + move |task_callback| { + Ok(LocalStore::insert( + &api_that, + api_category, + api_key, + api_value, + )) + } + }, + ) +} +fn wire_get__method__LocalStore_impl( + port_: MessagePort, + that: impl Wire2Api + UnwindSafe, + category: impl Wire2Api + UnwindSafe, + key: impl Wire2Api + UnwindSafe, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, Option>( + WrapInfo { + debug_name: "get__method__LocalStore", + port: Some(port_), + mode: FfiCallMode::Normal, + }, + move || { + let api_that = that.wire2api(); + let api_category = category.wire2api(); + let api_key = key.wire2api(); + move |task_callback| Ok(LocalStore::get(&api_that, api_category, api_key)) + }, + ) +} +fn wire_clear__method__LocalStore_impl( + port_: MessagePort, + that: impl Wire2Api + UnwindSafe, + category: impl Wire2Api> + UnwindSafe, +) { + FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, ()>( + WrapInfo { + debug_name: "clear__method__LocalStore", + port: Some(port_), + mode: FfiCallMode::Normal, + }, + move || { + let api_that = that.wire2api(); + let api_category = category.wire2api(); + move |task_callback| Ok(LocalStore::clear(&api_that, api_category)) + }, + ) +} +// Section: wrapper structs + +// Section: static checks + +// Section: allocate functions + +// Section: related functions + +// Section: impl Wire2Api + +pub trait Wire2Api { + fn wire2api(self) -> T; +} + +impl Wire2Api> for *mut S +where + *mut S: Wire2Api, +{ + fn wire2api(self) -> Option { + (!self.is_null()).then(|| self.wire2api()) + } +} + +impl Wire2Api for bool { + fn wire2api(self) -> bool { + self + } +} + +impl Wire2Api for i32 { + fn wire2api(self) -> i32 { + self + } +} + +impl Wire2Api for i32 { + fn wire2api(self) -> NetworkStatus { + match self { + 0 => NetworkStatus::Online, + 1 => NetworkStatus::Offline, + _ => unreachable!("Invalid variant for NetworkStatus: {}", self), + } + } +} + +impl Wire2Api for u8 { + fn wire2api(self) -> u8 { + self + } +} + +// Section: impl IntoDart + +impl support::IntoDart for LocalDb { + fn into_dart(self) -> support::DartAbi { + vec![self.repo.into_dart()].into_dart() + } +} +impl support::IntoDartExceptPrimitive for LocalDb {} +impl rust2dart::IntoIntoDart for LocalDb { + fn into_into_dart(self) -> Self { + self + } +} + +impl support::IntoDart for LocalStore { + fn into_dart(self) -> support::DartAbi { + vec![self.conn.into_dart()].into_dart() + } +} +impl support::IntoDartExceptPrimitive for LocalStore {} +impl rust2dart::IntoIntoDart for LocalStore { + fn into_into_dart(self) -> Self { + self + } +} + +impl support::IntoDart for NativePreferenceStore { + fn into_dart(self) -> support::DartAbi { + vec![self.conn.into_dart()].into_dart() + } +} +impl support::IntoDartExceptPrimitive for NativePreferenceStore {} +impl rust2dart::IntoIntoDart for NativePreferenceStore { + fn into_into_dart(self) -> Self { + self + } +} + +impl support::IntoDart for TagItem { + fn into_dart(self) -> support::DartAbi { + vec![ + self.name.into_into_dart().into_dart(), + self.children.into_into_dart().into_dart(), + ] + .into_dart() + } +} +impl support::IntoDartExceptPrimitive for TagItem {} +impl rust2dart::IntoIntoDart for TagItem { + fn into_into_dart(self) -> Self { + self + } +} + +// Section: executor + +support::lazy_static! { + pub static ref FLUTTER_RUST_BRIDGE_HANDLER: support::DefaultHandler = Default::default(); +} + +#[cfg(not(target_family = "wasm"))] +#[path = "bridge_generated.io.rs"] +mod io; +#[cfg(not(target_family = "wasm"))] +pub use io::*; diff --git a/annix/src/lib.rs b/annix/src/lib.rs index f321abca..56a37cd5 100644 --- a/annix/src/lib.rs +++ b/annix/src/lib.rs @@ -1,5 +1,3 @@ -pub mod network; -pub mod preferences; -pub mod repo; -pub mod store; -pub mod utils; +mod api; +mod bridge_generated; +mod utils; diff --git a/annix/src/network/api.rs b/annix/src/network/api.rs deleted file mode 100644 index 12ae3f63..00000000 --- a/annix/src/network/api.rs +++ /dev/null @@ -1,28 +0,0 @@ -use std::sync::RwLock; - -use once_cell::sync::Lazy; - -pub enum NetworkStatus { - Online, - Offline, -} - -impl NetworkStatus { - pub fn is_online(&self) -> bool { - match self { - NetworkStatus::Online => true, - NetworkStatus::Offline => false, - } - } -} - -pub static NETWORK: Lazy> = Lazy::new(|| RwLock::new(NetworkStatus::Offline)); - -pub fn update_network_status(is_online: bool) { - let mut network = NETWORK.write().unwrap(); - *network = if is_online { - NetworkStatus::Online - } else { - NetworkStatus::Offline - }; -} diff --git a/annix/src/network/generated.io.rs b/annix/src/network/generated.io.rs deleted file mode 100644 index fbbab03b..00000000 --- a/annix/src/network/generated.io.rs +++ /dev/null @@ -1,32 +0,0 @@ -use super::*; -// Section: wire functions - -#[no_mangle] -pub extern "C" fn wire_update_network_status(port_: i64, is_online: bool) { - wire_update_network_status_impl(port_, is_online) -} - -#[no_mangle] -pub extern "C" fn wire_is_online__method__NetworkStatus(port_: i64, that: i32) { - wire_is_online__method__NetworkStatus_impl(port_, that) -} - -// Section: allocate functions - -// Section: related functions - -// Section: impl Wire2Api - -// Section: wire structs - -// Section: impl NewWithNullPtr - -pub trait NewWithNullPtr { - fn new_with_null_ptr() -> Self; -} - -impl NewWithNullPtr for *mut T { - fn new_with_null_ptr() -> Self { - std::ptr::null_mut() - } -} diff --git a/annix/src/network/generated.rs b/annix/src/network/generated.rs deleted file mode 100644 index 168ccb39..00000000 --- a/annix/src/network/generated.rs +++ /dev/null @@ -1,110 +0,0 @@ -#![allow( - non_camel_case_types, - unused, - clippy::redundant_closure, - clippy::useless_conversion, - clippy::unit_arg, - clippy::double_parens, - non_snake_case, - clippy::too_many_arguments -)] -// AUTO GENERATED FILE, DO NOT EDIT. -// Generated by `flutter_rust_bridge`@ 1.81.0. - -use crate::network::api::*; -use core::panic::UnwindSafe; -use flutter_rust_bridge::rust2dart::IntoIntoDart; -use flutter_rust_bridge::*; -use std::ffi::c_void; -use std::sync::Arc; - -// Section: imports - -// Section: wire functions - -fn wire_update_network_status_impl( - port_: MessagePort, - is_online: impl Wire2Api + UnwindSafe, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, ()>( - WrapInfo { - debug_name: "update_network_status", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || { - let api_is_online = is_online.wire2api(); - move |task_callback| Ok(update_network_status(api_is_online)) - }, - ) -} -fn wire_is_online__method__NetworkStatus_impl( - port_: MessagePort, - that: impl Wire2Api + UnwindSafe, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, bool>( - WrapInfo { - debug_name: "is_online__method__NetworkStatus", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || { - let api_that = that.wire2api(); - move |task_callback| Ok(NetworkStatus::is_online(&api_that)) - }, - ) -} -// Section: wrapper structs - -// Section: static checks - -// Section: allocate functions - -// Section: related functions - -// Section: impl Wire2Api - -pub trait Wire2Api { - fn wire2api(self) -> T; -} - -impl Wire2Api> for *mut S -where - *mut S: Wire2Api, -{ - fn wire2api(self) -> Option { - (!self.is_null()).then(|| self.wire2api()) - } -} -impl Wire2Api for bool { - fn wire2api(self) -> bool { - self - } -} -impl Wire2Api for i32 { - fn wire2api(self) -> i32 { - self - } -} -impl Wire2Api for i32 { - fn wire2api(self) -> NetworkStatus { - match self { - 0 => NetworkStatus::Online, - 1 => NetworkStatus::Offline, - _ => unreachable!("Invalid variant for NetworkStatus: {}", self), - } - } -} -// Section: impl IntoDart - -// Section: executor - -support::lazy_static! { - pub static ref FLUTTER_RUST_BRIDGE_HANDLER: support::DefaultHandler = Default::default(); -} - -#[cfg(not(target_family = "wasm"))] -#[path = "generated.io.rs"] -mod io; -#[cfg(not(target_family = "wasm"))] -pub use io::*; diff --git a/annix/src/network/mod.rs b/annix/src/network/mod.rs deleted file mode 100644 index 97bc528b..00000000 --- a/annix/src/network/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod api; -mod generated; diff --git a/annix/src/preferences/api.rs b/annix/src/preferences/api.rs deleted file mode 100644 index 238317d2..00000000 --- a/annix/src/preferences/api.rs +++ /dev/null @@ -1,86 +0,0 @@ -pub use flutter_rust_bridge::{RustOpaque, SyncReturn}; -pub use rusqlite::Connection; -pub use std::{path::PathBuf, sync::Mutex}; - -use crate::dummy; - -dummy!(Dummy1); - -pub struct NativePreferenceStore { - pub conn: RustOpaque>>, -} - -impl NativePreferenceStore { - pub fn new(root: String) -> SyncReturn { - let db_path = PathBuf::from(&root).join("preference.db"); - std::fs::create_dir_all(&root).unwrap(); - let conn = Connection::open(db_path).unwrap(); - conn.execute( - r#" -CREATE TABLE IF NOT EXISTS preferences( - key TEXT PRIMARY KEY ON CONFLICT REPLACE, - value TEXT NOT NULL -); -"#, - (), - ) - .unwrap(); - - let conn = RustOpaque::new(Mutex::new(Dummy1(conn))); - SyncReturn(Self { conn }) - } - - pub fn get(&self, key: String) -> SyncReturn> { - let conn = self.conn.lock().unwrap(); - let mut stmt = conn - .prepare("SELECT value FROM preferences WHERE key = ?") - .unwrap(); - let mut rows = stmt.query(rusqlite::params![key]).unwrap(); - let result = rows - .next() - .ok() - .and_then(|r| r) - .and_then(|row| row.get(0).ok()); - - SyncReturn(result) - } - - pub fn set(&self, key: String, value: String) -> SyncReturn<()> { - self.conn - .lock() - .unwrap() - .execute( - "INSERT INTO preferences (key, value) VALUES (?, ?)", - rusqlite::params![key, value], - ) - .unwrap(); - - SyncReturn(()) - } - - pub fn remove(&self, key: String) -> SyncReturn<()> { - self.conn - .lock() - .unwrap() - .execute( - "DELETE FROM preferences WHERE key = ?", - rusqlite::params![key], - ) - .unwrap(); - - SyncReturn(()) - } - - pub fn remove_prefix(&self, prefix: String) -> SyncReturn<()> { - self.conn - .lock() - .unwrap() - .execute( - "DELETE FROM preferences WHERE key LIKE ?", - rusqlite::params![format!("{}%", prefix)], - ) - .unwrap(); - - SyncReturn(()) - } -} diff --git a/annix/src/preferences/generated.io.rs b/annix/src/preferences/generated.io.rs deleted file mode 100644 index 56fe2154..00000000 --- a/annix/src/preferences/generated.io.rs +++ /dev/null @@ -1,170 +0,0 @@ -use super::*; -// Section: wire functions - -#[no_mangle] -pub extern "C" fn wire_new__static_method__NativePreferenceStore( - root: *mut wire_uint_8_list, -) -> support::WireSyncReturn { - wire_new__static_method__NativePreferenceStore_impl(root) -} - -#[no_mangle] -pub extern "C" fn wire_get__method__NativePreferenceStore( - that: *mut wire_NativePreferenceStore, - key: *mut wire_uint_8_list, -) -> support::WireSyncReturn { - wire_get__method__NativePreferenceStore_impl(that, key) -} - -#[no_mangle] -pub extern "C" fn wire_set__method__NativePreferenceStore( - that: *mut wire_NativePreferenceStore, - key: *mut wire_uint_8_list, - value: *mut wire_uint_8_list, -) -> support::WireSyncReturn { - wire_set__method__NativePreferenceStore_impl(that, key, value) -} - -#[no_mangle] -pub extern "C" fn wire_remove__method__NativePreferenceStore( - that: *mut wire_NativePreferenceStore, - key: *mut wire_uint_8_list, -) -> support::WireSyncReturn { - wire_remove__method__NativePreferenceStore_impl(that, key) -} - -#[no_mangle] -pub extern "C" fn wire_remove_prefix__method__NativePreferenceStore( - that: *mut wire_NativePreferenceStore, - prefix: *mut wire_uint_8_list, -) -> support::WireSyncReturn { - wire_remove_prefix__method__NativePreferenceStore_impl(that, prefix) -} - -// Section: allocate functions - -#[no_mangle] -pub extern "C" fn new_MutexDummy1Connection() -> wire_MutexDummy1Connection { - wire_MutexDummy1Connection::new_with_null_ptr() -} - -#[no_mangle] -pub extern "C" fn new_box_autoadd_native_preference_store_1() -> *mut wire_NativePreferenceStore { - support::new_leak_box_ptr(wire_NativePreferenceStore::new_with_null_ptr()) -} - -#[no_mangle] -pub extern "C" fn new_uint_8_list_1(len: i32) -> *mut wire_uint_8_list { - let ans = wire_uint_8_list { - ptr: support::new_leak_vec_ptr(Default::default(), len), - len, - }; - support::new_leak_box_ptr(ans) -} - -// Section: related functions - -#[no_mangle] -pub extern "C" fn drop_opaque_MutexDummy1Connection(ptr: *const c_void) { - unsafe { - Arc::>>::decrement_strong_count(ptr as _); - } -} - -#[no_mangle] -pub extern "C" fn share_opaque_MutexDummy1Connection(ptr: *const c_void) -> *const c_void { - unsafe { - Arc::>>::increment_strong_count(ptr as _); - ptr - } -} - -// Section: impl Wire2Api - -impl Wire2Api>>> for wire_MutexDummy1Connection { - fn wire2api(self) -> RustOpaque>> { - unsafe { support::opaque_from_dart(self.ptr as _) } - } -} -impl Wire2Api for *mut wire_uint_8_list { - fn wire2api(self) -> String { - let vec: Vec = self.wire2api(); - String::from_utf8_lossy(&vec).into_owned() - } -} -impl Wire2Api for *mut wire_NativePreferenceStore { - fn wire2api(self) -> NativePreferenceStore { - let wrap = unsafe { support::box_from_leak_ptr(self) }; - Wire2Api::::wire2api(*wrap).into() - } -} -impl Wire2Api for wire_NativePreferenceStore { - fn wire2api(self) -> NativePreferenceStore { - NativePreferenceStore { - conn: self.conn.wire2api(), - } - } -} - -impl Wire2Api> for *mut wire_uint_8_list { - fn wire2api(self) -> Vec { - unsafe { - let wrap = support::box_from_leak_ptr(self); - support::vec_from_leak_ptr(wrap.ptr, wrap.len) - } - } -} -// Section: wire structs - -#[repr(C)] -#[derive(Clone)] -pub struct wire_MutexDummy1Connection { - ptr: *const core::ffi::c_void, -} - -#[repr(C)] -#[derive(Clone)] -pub struct wire_NativePreferenceStore { - conn: wire_MutexDummy1Connection, -} - -#[repr(C)] -#[derive(Clone)] -pub struct wire_uint_8_list { - ptr: *mut u8, - len: i32, -} - -// Section: impl NewWithNullPtr - -pub trait NewWithNullPtr { - fn new_with_null_ptr() -> Self; -} - -impl NewWithNullPtr for *mut T { - fn new_with_null_ptr() -> Self { - std::ptr::null_mut() - } -} - -impl NewWithNullPtr for wire_MutexDummy1Connection { - fn new_with_null_ptr() -> Self { - Self { - ptr: core::ptr::null(), - } - } -} - -impl NewWithNullPtr for wire_NativePreferenceStore { - fn new_with_null_ptr() -> Self { - Self { - conn: wire_MutexDummy1Connection::new_with_null_ptr(), - } - } -} - -impl Default for wire_NativePreferenceStore { - fn default() -> Self { - Self::new_with_null_ptr() - } -} diff --git a/annix/src/preferences/generated.rs b/annix/src/preferences/generated.rs deleted file mode 100644 index 081587af..00000000 --- a/annix/src/preferences/generated.rs +++ /dev/null @@ -1,163 +0,0 @@ -#![allow( - non_camel_case_types, - unused, - clippy::redundant_closure, - clippy::useless_conversion, - clippy::unit_arg, - clippy::double_parens, - non_snake_case, - clippy::too_many_arguments -)] -// AUTO GENERATED FILE, DO NOT EDIT. -// Generated by `flutter_rust_bridge`@ 1.81.0. - -use crate::preferences::api::*; -use core::panic::UnwindSafe; -use flutter_rust_bridge::rust2dart::IntoIntoDart; -use flutter_rust_bridge::*; -use std::ffi::c_void; -use std::sync::Arc; - -// Section: imports - -// Section: wire functions - -fn wire_new__static_method__NativePreferenceStore_impl( - root: impl Wire2Api + UnwindSafe, -) -> support::WireSyncReturn { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync( - WrapInfo { - debug_name: "new__static_method__NativePreferenceStore", - port: None, - mode: FfiCallMode::Sync, - }, - move || { - let api_root = root.wire2api(); - Ok(NativePreferenceStore::new(api_root)) - }, - ) -} -fn wire_get__method__NativePreferenceStore_impl( - that: impl Wire2Api + UnwindSafe, - key: impl Wire2Api + UnwindSafe, -) -> support::WireSyncReturn { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync( - WrapInfo { - debug_name: "get__method__NativePreferenceStore", - port: None, - mode: FfiCallMode::Sync, - }, - move || { - let api_that = that.wire2api(); - let api_key = key.wire2api(); - Ok(NativePreferenceStore::get(&api_that, api_key)) - }, - ) -} -fn wire_set__method__NativePreferenceStore_impl( - that: impl Wire2Api + UnwindSafe, - key: impl Wire2Api + UnwindSafe, - value: impl Wire2Api + UnwindSafe, -) -> support::WireSyncReturn { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync( - WrapInfo { - debug_name: "set__method__NativePreferenceStore", - port: None, - mode: FfiCallMode::Sync, - }, - move || { - let api_that = that.wire2api(); - let api_key = key.wire2api(); - let api_value = value.wire2api(); - Ok(NativePreferenceStore::set(&api_that, api_key, api_value)) - }, - ) -} -fn wire_remove__method__NativePreferenceStore_impl( - that: impl Wire2Api + UnwindSafe, - key: impl Wire2Api + UnwindSafe, -) -> support::WireSyncReturn { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync( - WrapInfo { - debug_name: "remove__method__NativePreferenceStore", - port: None, - mode: FfiCallMode::Sync, - }, - move || { - let api_that = that.wire2api(); - let api_key = key.wire2api(); - Ok(NativePreferenceStore::remove(&api_that, api_key)) - }, - ) -} -fn wire_remove_prefix__method__NativePreferenceStore_impl( - that: impl Wire2Api + UnwindSafe, - prefix: impl Wire2Api + UnwindSafe, -) -> support::WireSyncReturn { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync( - WrapInfo { - debug_name: "remove_prefix__method__NativePreferenceStore", - port: None, - mode: FfiCallMode::Sync, - }, - move || { - let api_that = that.wire2api(); - let api_prefix = prefix.wire2api(); - Ok(NativePreferenceStore::remove_prefix(&api_that, api_prefix)) - }, - ) -} -// Section: wrapper structs - -// Section: static checks - -// Section: allocate functions - -// Section: related functions - -// Section: impl Wire2Api - -pub trait Wire2Api { - fn wire2api(self) -> T; -} - -impl Wire2Api> for *mut S -where - *mut S: Wire2Api, -{ - fn wire2api(self) -> Option { - (!self.is_null()).then(|| self.wire2api()) - } -} - -impl Wire2Api for u8 { - fn wire2api(self) -> u8 { - self - } -} - -// Section: impl IntoDart - -impl support::IntoDart for NativePreferenceStore { - fn into_dart(self) -> support::DartAbi { - vec![self.conn.into_dart()].into_dart() - } -} -impl support::IntoDartExceptPrimitive for NativePreferenceStore {} -impl rust2dart::IntoIntoDart for NativePreferenceStore { - fn into_into_dart(self) -> Self { - self - } -} - -// Section: executor - -support::lazy_static! { - pub static ref FLUTTER_RUST_BRIDGE_HANDLER: support::DefaultHandler = Default::default(); -} - -#[cfg(not(target_family = "wasm"))] -#[path = "generated.io.rs"] -mod io; -#[cfg(not(target_family = "wasm"))] -pub use io::*; diff --git a/annix/src/preferences/mod.rs b/annix/src/preferences/mod.rs deleted file mode 100644 index 97bc528b..00000000 --- a/annix/src/preferences/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod api; -mod generated; diff --git a/annix/src/repo/api.rs b/annix/src/repo/api.rs deleted file mode 100644 index faabe36b..00000000 --- a/annix/src/repo/api.rs +++ /dev/null @@ -1,52 +0,0 @@ -pub use anni_repo::{db::RepoDatabaseRead, prelude::JsonAlbum}; -pub use flutter_rust_bridge::RustOpaque; -pub use rusqlite::Connection; -pub use std::sync::Mutex; -pub use uuid::Uuid; - -pub struct LocalDb { - pub repo: RustOpaque>, -} - -pub struct TagItem { - pub name: String, - pub children: Vec, -} - -impl LocalDb { - pub fn new(path: String) -> LocalDb { - let repo = RepoDatabaseRead::new(path).unwrap(); - let repo = RustOpaque::new(Mutex::new(repo)); - Self { repo } - } - - pub fn get_album(&self, album_id: uuid::Uuid) -> Option { - let album = self.repo.lock().unwrap().read_album(album_id).unwrap(); - album.map(|album| JsonAlbum::from(album).to_string()) - } - - pub fn get_albums_by_tag(&self, tag: String, recursive: bool) -> Vec { - let albums = self - .repo - .lock() - .unwrap() - .get_albums_by_tag(&tag, recursive) - .unwrap(); - albums.into_iter().map(|album| album.album_id.0).collect() - } - - pub fn get_tags(&self) -> Vec { - let albums = self.repo.lock().unwrap().get_tags_relationship().unwrap(); - albums - .into_iter() - .map(|(_, tag)| TagItem { - name: tag.tag.to_string(), - children: tag - .children - .into_iter() - .map(|tag| tag.to_string()) - .collect(), - }) - .collect() - } -} diff --git a/annix/src/repo/generated.io.rs b/annix/src/repo/generated.io.rs deleted file mode 100644 index 510a1460..00000000 --- a/annix/src/repo/generated.io.rs +++ /dev/null @@ -1,175 +0,0 @@ -use super::*; -// Section: wire functions - -#[no_mangle] -pub extern "C" fn wire_new__static_method__LocalDb(port_: i64, path: *mut wire_uint_8_list) { - wire_new__static_method__LocalDb_impl(port_, path) -} - -#[no_mangle] -pub extern "C" fn wire_get_album__method__LocalDb( - port_: i64, - that: *mut wire_LocalDb, - album_id: *mut wire_uint_8_list, -) { - wire_get_album__method__LocalDb_impl(port_, that, album_id) -} - -#[no_mangle] -pub extern "C" fn wire_get_albums_by_tag__method__LocalDb( - port_: i64, - that: *mut wire_LocalDb, - tag: *mut wire_uint_8_list, - recursive: bool, -) { - wire_get_albums_by_tag__method__LocalDb_impl(port_, that, tag, recursive) -} - -#[no_mangle] -pub extern "C" fn wire_get_tags__method__LocalDb(port_: i64, that: *mut wire_LocalDb) { - wire_get_tags__method__LocalDb_impl(port_, that) -} - -// Section: allocate functions - -#[no_mangle] -pub extern "C" fn new_MutexRepoDatabaseRead() -> wire_MutexRepoDatabaseRead { - wire_MutexRepoDatabaseRead::new_with_null_ptr() -} - -#[no_mangle] -pub extern "C" fn new_box_autoadd_local_db_0() -> *mut wire_LocalDb { - support::new_leak_box_ptr(wire_LocalDb::new_with_null_ptr()) -} - -#[no_mangle] -pub extern "C" fn new_uint_8_list_0(len: i32) -> *mut wire_uint_8_list { - let ans = wire_uint_8_list { - ptr: support::new_leak_vec_ptr(Default::default(), len), - len, - }; - support::new_leak_box_ptr(ans) -} - -// Section: related functions - -#[no_mangle] -pub extern "C" fn drop_opaque_MutexRepoDatabaseRead(ptr: *const c_void) { - unsafe { - Arc::>::decrement_strong_count(ptr as _); - } -} - -#[no_mangle] -pub extern "C" fn share_opaque_MutexRepoDatabaseRead(ptr: *const c_void) -> *const c_void { - unsafe { - Arc::>::increment_strong_count(ptr as _); - ptr - } -} - -// Section: impl Wire2Api - -impl Wire2Api>> for wire_MutexRepoDatabaseRead { - fn wire2api(self) -> RustOpaque> { - unsafe { support::opaque_from_dart(self.ptr as _) } - } -} -impl Wire2Api for *mut wire_uint_8_list { - fn wire2api(self) -> String { - let vec: Vec = self.wire2api(); - String::from_utf8_lossy(&vec).into_owned() - } -} -impl Wire2Api for *mut wire_uint_8_list { - fn wire2api(self) -> uuid::Uuid { - let single: Vec = self.wire2api(); - wire2api_uuid_ref(single.as_slice()) - } -} - -impl Wire2Api for *mut wire_LocalDb { - fn wire2api(self) -> LocalDb { - let wrap = unsafe { support::box_from_leak_ptr(self) }; - Wire2Api::::wire2api(*wrap).into() - } -} -impl Wire2Api for wire_LocalDb { - fn wire2api(self) -> LocalDb { - LocalDb { - repo: self.repo.wire2api(), - } - } -} - -impl Wire2Api> for *mut wire_uint_8_list { - fn wire2api(self) -> Vec { - unsafe { - let wrap = support::box_from_leak_ptr(self); - support::vec_from_leak_ptr(wrap.ptr, wrap.len) - } - } -} -// Section: wire structs - -#[repr(C)] -#[derive(Clone)] -pub struct wire_MutexRepoDatabaseRead { - ptr: *const core::ffi::c_void, -} - -#[repr(C)] -#[derive(Clone)] -pub struct wire_LocalDb { - repo: wire_MutexRepoDatabaseRead, -} - -#[repr(C)] -#[derive(Clone)] -pub struct wire_uint_8_list { - ptr: *mut u8, - len: i32, -} - -// Section: impl NewWithNullPtr - -pub trait NewWithNullPtr { - fn new_with_null_ptr() -> Self; -} - -impl NewWithNullPtr for *mut T { - fn new_with_null_ptr() -> Self { - std::ptr::null_mut() - } -} - -impl NewWithNullPtr for wire_MutexRepoDatabaseRead { - fn new_with_null_ptr() -> Self { - Self { - ptr: core::ptr::null(), - } - } -} - -impl NewWithNullPtr for wire_LocalDb { - fn new_with_null_ptr() -> Self { - Self { - repo: wire_MutexRepoDatabaseRead::new_with_null_ptr(), - } - } -} - -impl Default for wire_LocalDb { - fn default() -> Self { - Self::new_with_null_ptr() - } -} - -// Section: sync execution mode utility - -#[no_mangle] -pub extern "C" fn free_WireSyncReturn(ptr: support::WireSyncReturn) { - unsafe { - let _ = support::box_from_leak_ptr(ptr); - }; -} diff --git a/annix/src/repo/generated.rs b/annix/src/repo/generated.rs deleted file mode 100644 index 5679511d..00000000 --- a/annix/src/repo/generated.rs +++ /dev/null @@ -1,176 +0,0 @@ -#![allow( - non_camel_case_types, - unused, - clippy::redundant_closure, - clippy::useless_conversion, - clippy::unit_arg, - clippy::double_parens, - non_snake_case, - clippy::too_many_arguments -)] -// AUTO GENERATED FILE, DO NOT EDIT. -// Generated by `flutter_rust_bridge`@ 1.81.0. - -use crate::repo::api::*; -use core::panic::UnwindSafe; -use flutter_rust_bridge::rust2dart::IntoIntoDart; -use flutter_rust_bridge::*; -use std::ffi::c_void; -use std::sync::Arc; - -// Section: imports - -// Section: wire functions - -fn wire_new__static_method__LocalDb_impl( - port_: MessagePort, - path: impl Wire2Api + UnwindSafe, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, LocalDb>( - WrapInfo { - debug_name: "new__static_method__LocalDb", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || { - let api_path = path.wire2api(); - move |task_callback| Ok(LocalDb::new(api_path)) - }, - ) -} -fn wire_get_album__method__LocalDb_impl( - port_: MessagePort, - that: impl Wire2Api + UnwindSafe, - album_id: impl Wire2Api + UnwindSafe, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, Option>( - WrapInfo { - debug_name: "get_album__method__LocalDb", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || { - let api_that = that.wire2api(); - let api_album_id = album_id.wire2api(); - move |task_callback| Ok(LocalDb::get_album(&api_that, api_album_id)) - }, - ) -} -fn wire_get_albums_by_tag__method__LocalDb_impl( - port_: MessagePort, - that: impl Wire2Api + UnwindSafe, - tag: impl Wire2Api + UnwindSafe, - recursive: impl Wire2Api + UnwindSafe, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, Vec>( - WrapInfo { - debug_name: "get_albums_by_tag__method__LocalDb", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || { - let api_that = that.wire2api(); - let api_tag = tag.wire2api(); - let api_recursive = recursive.wire2api(); - move |task_callback| { - Ok(LocalDb::get_albums_by_tag( - &api_that, - api_tag, - api_recursive, - )) - } - }, - ) -} -fn wire_get_tags__method__LocalDb_impl( - port_: MessagePort, - that: impl Wire2Api + UnwindSafe, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, Vec>( - WrapInfo { - debug_name: "get_tags__method__LocalDb", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || { - let api_that = that.wire2api(); - move |task_callback| Ok(LocalDb::get_tags(&api_that)) - }, - ) -} -// Section: wrapper structs - -// Section: static checks - -// Section: allocate functions - -// Section: related functions - -// Section: impl Wire2Api - -pub trait Wire2Api { - fn wire2api(self) -> T; -} - -impl Wire2Api> for *mut S -where - *mut S: Wire2Api, -{ - fn wire2api(self) -> Option { - (!self.is_null()).then(|| self.wire2api()) - } -} - -impl Wire2Api for bool { - fn wire2api(self) -> bool { - self - } -} - -impl Wire2Api for u8 { - fn wire2api(self) -> u8 { - self - } -} - -// Section: impl IntoDart - -impl support::IntoDart for LocalDb { - fn into_dart(self) -> support::DartAbi { - vec![self.repo.into_dart()].into_dart() - } -} -impl support::IntoDartExceptPrimitive for LocalDb {} -impl rust2dart::IntoIntoDart for LocalDb { - fn into_into_dart(self) -> Self { - self - } -} - -impl support::IntoDart for TagItem { - fn into_dart(self) -> support::DartAbi { - vec![ - self.name.into_into_dart().into_dart(), - self.children.into_into_dart().into_dart(), - ] - .into_dart() - } -} -impl support::IntoDartExceptPrimitive for TagItem {} -impl rust2dart::IntoIntoDart for TagItem { - fn into_into_dart(self) -> Self { - self - } -} - -// Section: executor - -support::lazy_static! { - pub static ref FLUTTER_RUST_BRIDGE_HANDLER: support::DefaultHandler = Default::default(); -} - -#[cfg(not(target_family = "wasm"))] -#[path = "generated.io.rs"] -mod io; -#[cfg(not(target_family = "wasm"))] -pub use io::*; diff --git a/annix/src/repo/mod.rs b/annix/src/repo/mod.rs deleted file mode 100644 index 97bc528b..00000000 --- a/annix/src/repo/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod api; -mod generated; diff --git a/annix/src/store/api.rs b/annix/src/store/api.rs deleted file mode 100644 index a8a5658d..00000000 --- a/annix/src/store/api.rs +++ /dev/null @@ -1,66 +0,0 @@ -pub use std::{path::PathBuf, sync::Mutex}; - -pub use flutter_rust_bridge::{RustOpaque, SyncReturn}; -pub use rusqlite::Connection; - -pub type LocalStoreConnection = Mutex; - -pub struct LocalStore { - pub conn: RustOpaque, -} - -impl LocalStore { - pub fn new(root: String) -> SyncReturn { - let db_path = PathBuf::from(root).join("cache.db"); - let conn = Connection::open(db_path).unwrap(); - conn.execute( - r#" -CREATE TABLE IF NOT EXISTS store( - id INTEGER PRIMARY KEY, - category TEXT NOT NULL, - key TEXT NOT NULL, - value TEXT NOT NULL, - UNIQUE("category", "key", "value") ON CONFLICT REPLACE -);"#, - (), - ) - .unwrap(); - - let conn = RustOpaque::new(Mutex::new(conn)); - SyncReturn(Self { conn }) - } - - pub fn insert(&self, category: String, key: String, value: String) { - self.conn - .lock() - .unwrap() - .execute( - "INSERT INTO store (category, key, value) VALUES (?, ?, ?)", - rusqlite::params![category, key, value], - ) - .unwrap(); - } - - pub fn get(&self, category: String, key: String) -> Option { - let conn = self.conn.lock().unwrap(); - let mut stmt = conn - .prepare("SELECT value FROM store WHERE category = ? AND key = ?") - .unwrap(); - let mut rows = stmt.query(rusqlite::params![category, key]).unwrap(); - rows.next() - .ok() - .and_then(|r| r) - .and_then(|row| row.get(0).ok()) - } - - pub fn clear(&self, category: Option) { - self.conn - .lock() - .unwrap() - .execute( - "DELETE FROM store WHERE category = ?", - rusqlite::params![category], - ) - .unwrap(); - } -} diff --git a/annix/src/store/generated.io.rs b/annix/src/store/generated.io.rs deleted file mode 100644 index 881d2745..00000000 --- a/annix/src/store/generated.io.rs +++ /dev/null @@ -1,167 +0,0 @@ -use super::*; -// Section: wire functions - -#[no_mangle] -pub extern "C" fn wire_new__static_method__LocalStore( - root: *mut wire_uint_8_list, -) -> support::WireSyncReturn { - wire_new__static_method__LocalStore_impl(root) -} - -#[no_mangle] -pub extern "C" fn wire_insert__method__LocalStore( - port_: i64, - that: *mut wire_LocalStore, - category: *mut wire_uint_8_list, - key: *mut wire_uint_8_list, - value: *mut wire_uint_8_list, -) { - wire_insert__method__LocalStore_impl(port_, that, category, key, value) -} - -#[no_mangle] -pub extern "C" fn wire_get__method__LocalStore( - port_: i64, - that: *mut wire_LocalStore, - category: *mut wire_uint_8_list, - key: *mut wire_uint_8_list, -) { - wire_get__method__LocalStore_impl(port_, that, category, key) -} - -#[no_mangle] -pub extern "C" fn wire_clear__method__LocalStore( - port_: i64, - that: *mut wire_LocalStore, - category: *mut wire_uint_8_list, -) { - wire_clear__method__LocalStore_impl(port_, that, category) -} - -// Section: allocate functions - -#[no_mangle] -pub extern "C" fn new_MutexConnection() -> wire_MutexConnection { - wire_MutexConnection::new_with_null_ptr() -} - -#[no_mangle] -pub extern "C" fn new_box_autoadd_local_store_2() -> *mut wire_LocalStore { - support::new_leak_box_ptr(wire_LocalStore::new_with_null_ptr()) -} - -#[no_mangle] -pub extern "C" fn new_uint_8_list_2(len: i32) -> *mut wire_uint_8_list { - let ans = wire_uint_8_list { - ptr: support::new_leak_vec_ptr(Default::default(), len), - len, - }; - support::new_leak_box_ptr(ans) -} - -// Section: related functions - -#[no_mangle] -pub extern "C" fn drop_opaque_MutexConnection(ptr: *const c_void) { - unsafe { - Arc::>::decrement_strong_count(ptr as _); - } -} - -#[no_mangle] -pub extern "C" fn share_opaque_MutexConnection(ptr: *const c_void) -> *const c_void { - unsafe { - Arc::>::increment_strong_count(ptr as _); - ptr - } -} - -// Section: impl Wire2Api - -impl Wire2Api>> for wire_MutexConnection { - fn wire2api(self) -> RustOpaque> { - unsafe { support::opaque_from_dart(self.ptr as _) } - } -} -impl Wire2Api for *mut wire_uint_8_list { - fn wire2api(self) -> String { - let vec: Vec = self.wire2api(); - String::from_utf8_lossy(&vec).into_owned() - } -} -impl Wire2Api for *mut wire_LocalStore { - fn wire2api(self) -> LocalStore { - let wrap = unsafe { support::box_from_leak_ptr(self) }; - Wire2Api::::wire2api(*wrap).into() - } -} -impl Wire2Api for wire_LocalStore { - fn wire2api(self) -> LocalStore { - LocalStore { - conn: self.conn.wire2api(), - } - } -} - -impl Wire2Api> for *mut wire_uint_8_list { - fn wire2api(self) -> Vec { - unsafe { - let wrap = support::box_from_leak_ptr(self); - support::vec_from_leak_ptr(wrap.ptr, wrap.len) - } - } -} -// Section: wire structs - -#[repr(C)] -#[derive(Clone)] -pub struct wire_MutexConnection { - ptr: *const core::ffi::c_void, -} - -#[repr(C)] -#[derive(Clone)] -pub struct wire_LocalStore { - conn: wire_MutexConnection, -} - -#[repr(C)] -#[derive(Clone)] -pub struct wire_uint_8_list { - ptr: *mut u8, - len: i32, -} - -// Section: impl NewWithNullPtr - -pub trait NewWithNullPtr { - fn new_with_null_ptr() -> Self; -} - -impl NewWithNullPtr for *mut T { - fn new_with_null_ptr() -> Self { - std::ptr::null_mut() - } -} - -impl NewWithNullPtr for wire_MutexConnection { - fn new_with_null_ptr() -> Self { - Self { - ptr: core::ptr::null(), - } - } -} - -impl NewWithNullPtr for wire_LocalStore { - fn new_with_null_ptr() -> Self { - Self { - conn: wire_MutexConnection::new_with_null_ptr(), - } - } -} - -impl Default for wire_LocalStore { - fn default() -> Self { - Self::new_with_null_ptr() - } -} diff --git a/annix/src/store/generated.rs b/annix/src/store/generated.rs deleted file mode 100644 index 06425cd9..00000000 --- a/annix/src/store/generated.rs +++ /dev/null @@ -1,160 +0,0 @@ -#![allow( - non_camel_case_types, - unused, - clippy::redundant_closure, - clippy::useless_conversion, - clippy::unit_arg, - clippy::double_parens, - non_snake_case, - clippy::too_many_arguments -)] -// AUTO GENERATED FILE, DO NOT EDIT. -// Generated by `flutter_rust_bridge`@ 1.81.0. - -use crate::store::api::*; -use core::panic::UnwindSafe; -use flutter_rust_bridge::rust2dart::IntoIntoDart; -use flutter_rust_bridge::*; -use std::ffi::c_void; -use std::sync::Arc; - -// Section: imports - -// Section: wire functions - -fn wire_new__static_method__LocalStore_impl( - root: impl Wire2Api + UnwindSafe, -) -> support::WireSyncReturn { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync( - WrapInfo { - debug_name: "new__static_method__LocalStore", - port: None, - mode: FfiCallMode::Sync, - }, - move || { - let api_root = root.wire2api(); - Ok(LocalStore::new(api_root)) - }, - ) -} -fn wire_insert__method__LocalStore_impl( - port_: MessagePort, - that: impl Wire2Api + UnwindSafe, - category: impl Wire2Api + UnwindSafe, - key: impl Wire2Api + UnwindSafe, - value: impl Wire2Api + UnwindSafe, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, ()>( - WrapInfo { - debug_name: "insert__method__LocalStore", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || { - let api_that = that.wire2api(); - let api_category = category.wire2api(); - let api_key = key.wire2api(); - let api_value = value.wire2api(); - move |task_callback| { - Ok(LocalStore::insert( - &api_that, - api_category, - api_key, - api_value, - )) - } - }, - ) -} -fn wire_get__method__LocalStore_impl( - port_: MessagePort, - that: impl Wire2Api + UnwindSafe, - category: impl Wire2Api + UnwindSafe, - key: impl Wire2Api + UnwindSafe, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, Option>( - WrapInfo { - debug_name: "get__method__LocalStore", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || { - let api_that = that.wire2api(); - let api_category = category.wire2api(); - let api_key = key.wire2api(); - move |task_callback| Ok(LocalStore::get(&api_that, api_category, api_key)) - }, - ) -} -fn wire_clear__method__LocalStore_impl( - port_: MessagePort, - that: impl Wire2Api + UnwindSafe, - category: impl Wire2Api> + UnwindSafe, -) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap::<_, _, _, ()>( - WrapInfo { - debug_name: "clear__method__LocalStore", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || { - let api_that = that.wire2api(); - let api_category = category.wire2api(); - move |task_callback| Ok(LocalStore::clear(&api_that, api_category)) - }, - ) -} -// Section: wrapper structs - -// Section: static checks - -// Section: allocate functions - -// Section: related functions - -// Section: impl Wire2Api - -pub trait Wire2Api { - fn wire2api(self) -> T; -} - -impl Wire2Api> for *mut S -where - *mut S: Wire2Api, -{ - fn wire2api(self) -> Option { - (!self.is_null()).then(|| self.wire2api()) - } -} - -impl Wire2Api for u8 { - fn wire2api(self) -> u8 { - self - } -} - -// Section: impl IntoDart - -impl support::IntoDart for LocalStore { - fn into_dart(self) -> support::DartAbi { - vec![self.conn.into_dart()].into_dart() - } -} -impl support::IntoDartExceptPrimitive for LocalStore {} -impl rust2dart::IntoIntoDart for LocalStore { - fn into_into_dart(self) -> Self { - self - } -} - -// Section: executor - -support::lazy_static! { - pub static ref FLUTTER_RUST_BRIDGE_HANDLER: support::DefaultHandler = Default::default(); -} - -#[cfg(not(target_family = "wasm"))] -#[path = "generated.io.rs"] -mod io; -#[cfg(not(target_family = "wasm"))] -pub use io::*; diff --git a/annix/src/store/mod.rs b/annix/src/store/mod.rs deleted file mode 100644 index 97bc528b..00000000 --- a/annix/src/store/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod api; -mod generated; diff --git a/annix/src/utils/dummy.rs b/annix/src/utils.rs similarity index 100% rename from annix/src/utils/dummy.rs rename to annix/src/utils.rs diff --git a/annix/src/utils/mod.rs b/annix/src/utils/mod.rs deleted file mode 100644 index 61147493..00000000 --- a/annix/src/utils/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod dummy; diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 9057ceb4..38fb0ca1 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -7,7 +7,7 @@ import Flutter _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { - let dummy = dummy_method_to_enforce_bundling_ApiPreferenceStore() + let dummy = dummy_method_to_enforce_bundling() print(dummy) GeneratedPluginRegistrant.register(with: self) diff --git a/ios/Runner/Runner-Bridging-Header.h b/ios/Runner/Runner-Bridging-Header.h index b3808766..ffb33c60 100644 --- a/ios/Runner/Runner-Bridging-Header.h +++ b/ios/Runner/Runner-Bridging-Header.h @@ -1,2 +1,2 @@ #import "GeneratedPluginRegistrant.h" -#import "generated_preferences.h" +#import "bridge_generated.h" diff --git a/ios/Runner/bridge_generated.h b/ios/Runner/bridge_generated.h new file mode 100644 index 00000000..d23541b5 --- /dev/null +++ b/ios/Runner/bridge_generated.h @@ -0,0 +1,166 @@ +#include +#include +#include +typedef struct _Dart_Handle* Dart_Handle; + +typedef struct DartCObject DartCObject; + +typedef int64_t DartPort; + +typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); + +typedef struct DartCObject *WireSyncReturn; + +typedef struct wire_uint_8_list { + uint8_t *ptr; + int32_t len; +} wire_uint_8_list; + +typedef struct wire_MutexDummy1Connection { + const void *ptr; +} wire_MutexDummy1Connection; + +typedef struct wire_NativePreferenceStore { + struct wire_MutexDummy1Connection conn; +} wire_NativePreferenceStore; + +typedef struct wire_MutexRepoDatabaseRead { + const void *ptr; +} wire_MutexRepoDatabaseRead; + +typedef struct wire_LocalDb { + struct wire_MutexRepoDatabaseRead repo; +} wire_LocalDb; + +typedef struct wire_MutexConnection { + const void *ptr; +} wire_MutexConnection; + +typedef struct wire_LocalStore { + struct wire_MutexConnection conn; +} wire_LocalStore; + +void store_dart_post_cobject(DartPostCObjectFnType ptr); + +Dart_Handle get_dart_object(uintptr_t ptr); + +void drop_dart_object(uintptr_t ptr); + +uintptr_t new_dart_opaque(Dart_Handle handle); + +intptr_t init_frb_dart_api_dl(void *obj); + +void wire_update_network_status(int64_t port_, bool is_online); + +void wire_is_online__method__NetworkStatus(int64_t port_, int32_t that); + +WireSyncReturn wire_new__static_method__NativePreferenceStore(struct wire_uint_8_list *root); + +WireSyncReturn wire_get__method__NativePreferenceStore(struct wire_NativePreferenceStore *that, + struct wire_uint_8_list *key); + +WireSyncReturn wire_set__method__NativePreferenceStore(struct wire_NativePreferenceStore *that, + struct wire_uint_8_list *key, + struct wire_uint_8_list *value); + +WireSyncReturn wire_remove__method__NativePreferenceStore(struct wire_NativePreferenceStore *that, + struct wire_uint_8_list *key); + +WireSyncReturn wire_remove_prefix__method__NativePreferenceStore(struct wire_NativePreferenceStore *that, + struct wire_uint_8_list *prefix); + +void wire_new__static_method__LocalDb(int64_t port_, struct wire_uint_8_list *path); + +void wire_get_album__method__LocalDb(int64_t port_, + struct wire_LocalDb *that, + struct wire_uint_8_list *album_id); + +void wire_get_albums_by_tag__method__LocalDb(int64_t port_, + struct wire_LocalDb *that, + struct wire_uint_8_list *tag, + bool recursive); + +void wire_get_tags__method__LocalDb(int64_t port_, struct wire_LocalDb *that); + +WireSyncReturn wire_new__static_method__LocalStore(struct wire_uint_8_list *root); + +void wire_insert__method__LocalStore(int64_t port_, + struct wire_LocalStore *that, + struct wire_uint_8_list *category, + struct wire_uint_8_list *key, + struct wire_uint_8_list *value); + +void wire_get__method__LocalStore(int64_t port_, + struct wire_LocalStore *that, + struct wire_uint_8_list *category, + struct wire_uint_8_list *key); + +void wire_clear__method__LocalStore(int64_t port_, + struct wire_LocalStore *that, + struct wire_uint_8_list *category); + +struct wire_MutexConnection new_MutexConnection(void); + +struct wire_MutexDummy1Connection new_MutexDummy1Connection(void); + +struct wire_MutexRepoDatabaseRead new_MutexRepoDatabaseRead(void); + +struct wire_LocalDb *new_box_autoadd_local_db_0(void); + +struct wire_LocalStore *new_box_autoadd_local_store_0(void); + +struct wire_NativePreferenceStore *new_box_autoadd_native_preference_store_0(void); + +struct wire_uint_8_list *new_uint_8_list_0(int32_t len); + +void drop_opaque_MutexConnection(const void *ptr); + +const void *share_opaque_MutexConnection(const void *ptr); + +void drop_opaque_MutexDummy1Connection(const void *ptr); + +const void *share_opaque_MutexDummy1Connection(const void *ptr); + +void drop_opaque_MutexRepoDatabaseRead(const void *ptr); + +const void *share_opaque_MutexRepoDatabaseRead(const void *ptr); + +void free_WireSyncReturn(WireSyncReturn ptr); + +static int64_t dummy_method_to_enforce_bundling(void) { + int64_t dummy_var = 0; + dummy_var ^= ((int64_t) (void*) wire_update_network_status); + dummy_var ^= ((int64_t) (void*) wire_is_online__method__NetworkStatus); + dummy_var ^= ((int64_t) (void*) wire_new__static_method__NativePreferenceStore); + dummy_var ^= ((int64_t) (void*) wire_get__method__NativePreferenceStore); + dummy_var ^= ((int64_t) (void*) wire_set__method__NativePreferenceStore); + dummy_var ^= ((int64_t) (void*) wire_remove__method__NativePreferenceStore); + dummy_var ^= ((int64_t) (void*) wire_remove_prefix__method__NativePreferenceStore); + dummy_var ^= ((int64_t) (void*) wire_new__static_method__LocalDb); + dummy_var ^= ((int64_t) (void*) wire_get_album__method__LocalDb); + dummy_var ^= ((int64_t) (void*) wire_get_albums_by_tag__method__LocalDb); + dummy_var ^= ((int64_t) (void*) wire_get_tags__method__LocalDb); + dummy_var ^= ((int64_t) (void*) wire_new__static_method__LocalStore); + dummy_var ^= ((int64_t) (void*) wire_insert__method__LocalStore); + dummy_var ^= ((int64_t) (void*) wire_get__method__LocalStore); + dummy_var ^= ((int64_t) (void*) wire_clear__method__LocalStore); + dummy_var ^= ((int64_t) (void*) new_MutexConnection); + dummy_var ^= ((int64_t) (void*) new_MutexDummy1Connection); + dummy_var ^= ((int64_t) (void*) new_MutexRepoDatabaseRead); + dummy_var ^= ((int64_t) (void*) new_box_autoadd_local_db_0); + dummy_var ^= ((int64_t) (void*) new_box_autoadd_local_store_0); + dummy_var ^= ((int64_t) (void*) new_box_autoadd_native_preference_store_0); + dummy_var ^= ((int64_t) (void*) new_uint_8_list_0); + dummy_var ^= ((int64_t) (void*) drop_opaque_MutexConnection); + dummy_var ^= ((int64_t) (void*) share_opaque_MutexConnection); + dummy_var ^= ((int64_t) (void*) drop_opaque_MutexDummy1Connection); + dummy_var ^= ((int64_t) (void*) share_opaque_MutexDummy1Connection); + dummy_var ^= ((int64_t) (void*) drop_opaque_MutexRepoDatabaseRead); + dummy_var ^= ((int64_t) (void*) share_opaque_MutexRepoDatabaseRead); + dummy_var ^= ((int64_t) (void*) free_WireSyncReturn); + dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); + dummy_var ^= ((int64_t) (void*) get_dart_object); + dummy_var ^= ((int64_t) (void*) drop_dart_object); + dummy_var ^= ((int64_t) (void*) new_dart_opaque); + return dummy_var; +} diff --git a/ios/Runner/generated_network.h b/ios/Runner/generated_network.h deleted file mode 100644 index 684d4d7f..00000000 --- a/ios/Runner/generated_network.h +++ /dev/null @@ -1,69 +0,0 @@ -#include -#include -#include -typedef struct _Dart_Handle* Dart_Handle; - -typedef struct DartCObject DartCObject; - -typedef int64_t DartPort; - -typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); - -typedef struct wire_MutexDummy1Connection { - const void *ptr; -} wire_MutexDummy1Connection; - -typedef struct wire_NativePreferenceStore { - struct wire_MutexDummy1Connection conn; -} wire_NativePreferenceStore; - -typedef struct wire_MutexRepoDatabaseRead { - const void *ptr; -} wire_MutexRepoDatabaseRead; - -typedef struct wire_LocalDb { - struct wire_MutexRepoDatabaseRead repo; -} wire_LocalDb; - -typedef struct DartCObject *WireSyncReturn; - -typedef struct wire_MutexConnection { - const void *ptr; -} wire_MutexConnection; - -typedef struct wire_LocalStore { - struct wire_MutexConnection conn; -} wire_LocalStore; - -void store_dart_post_cobject(DartPostCObjectFnType ptr); - -Dart_Handle get_dart_object(uintptr_t ptr); - -void drop_dart_object(uintptr_t ptr); - -uintptr_t new_dart_opaque(Dart_Handle handle); - -intptr_t init_frb_dart_api_dl(void *obj); - -void wire_update_network_status(int64_t port_, bool is_online); - -void wire_is_online__method__NetworkStatus(int64_t port_, int32_t that); - -struct wire_NativePreferenceStore *new_box_autoadd_native_preference_store_1(void); - -struct wire_LocalDb *new_box_autoadd_local_db_0(void); - -void free_WireSyncReturn(WireSyncReturn ptr); - -struct wire_LocalStore *new_box_autoadd_local_store_2(void); - -static int64_t dummy_method_to_enforce_bundling_ApiNetwork(void) { - int64_t dummy_var = 0; - dummy_var ^= ((int64_t) (void*) wire_update_network_status); - dummy_var ^= ((int64_t) (void*) wire_is_online__method__NetworkStatus); - dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); - dummy_var ^= ((int64_t) (void*) get_dart_object); - dummy_var ^= ((int64_t) (void*) drop_dart_object); - dummy_var ^= ((int64_t) (void*) new_dart_opaque); - return dummy_var; -} diff --git a/ios/Runner/generated_preferences.h b/ios/Runner/generated_preferences.h deleted file mode 100644 index f1b44307..00000000 --- a/ios/Runner/generated_preferences.h +++ /dev/null @@ -1,101 +0,0 @@ -#include -#include -#include -typedef struct _Dart_Handle* Dart_Handle; - -typedef struct DartCObject DartCObject; - -typedef int64_t DartPort; - -typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); - -typedef struct DartCObject *WireSyncReturn; - -typedef struct wire_uint_8_list { - uint8_t *ptr; - int32_t len; -} wire_uint_8_list; - -typedef struct wire_MutexDummy1Connection { - const void *ptr; -} wire_MutexDummy1Connection; - -typedef struct wire_NativePreferenceStore { - struct wire_MutexDummy1Connection conn; -} wire_NativePreferenceStore; - -typedef struct wire_MutexRepoDatabaseRead { - const void *ptr; -} wire_MutexRepoDatabaseRead; - -typedef struct wire_LocalDb { - struct wire_MutexRepoDatabaseRead repo; -} wire_LocalDb; - -typedef struct wire_MutexConnection { - const void *ptr; -} wire_MutexConnection; - -typedef struct wire_LocalStore { - struct wire_MutexConnection conn; -} wire_LocalStore; - -void store_dart_post_cobject(DartPostCObjectFnType ptr); - -Dart_Handle get_dart_object(uintptr_t ptr); - -void drop_dart_object(uintptr_t ptr); - -uintptr_t new_dart_opaque(Dart_Handle handle); - -intptr_t init_frb_dart_api_dl(void *obj); - -WireSyncReturn wire_new__static_method__NativePreferenceStore(struct wire_uint_8_list *root); - -WireSyncReturn wire_get__method__NativePreferenceStore(struct wire_NativePreferenceStore *that, - struct wire_uint_8_list *key); - -WireSyncReturn wire_set__method__NativePreferenceStore(struct wire_NativePreferenceStore *that, - struct wire_uint_8_list *key, - struct wire_uint_8_list *value); - -WireSyncReturn wire_remove__method__NativePreferenceStore(struct wire_NativePreferenceStore *that, - struct wire_uint_8_list *key); - -WireSyncReturn wire_remove_prefix__method__NativePreferenceStore(struct wire_NativePreferenceStore *that, - struct wire_uint_8_list *prefix); - -struct wire_MutexDummy1Connection new_MutexDummy1Connection(void); - -struct wire_NativePreferenceStore *new_box_autoadd_native_preference_store_1(void); - -struct wire_uint_8_list *new_uint_8_list_1(int32_t len); - -void drop_opaque_MutexDummy1Connection(const void *ptr); - -const void *share_opaque_MutexDummy1Connection(const void *ptr); - -struct wire_LocalDb *new_box_autoadd_local_db_0(void); - -void free_WireSyncReturn(WireSyncReturn ptr); - -struct wire_LocalStore *new_box_autoadd_local_store_2(void); - -static int64_t dummy_method_to_enforce_bundling_ApiPreferenceStore(void) { - int64_t dummy_var = 0; - dummy_var ^= ((int64_t) (void*) wire_new__static_method__NativePreferenceStore); - dummy_var ^= ((int64_t) (void*) wire_get__method__NativePreferenceStore); - dummy_var ^= ((int64_t) (void*) wire_set__method__NativePreferenceStore); - dummy_var ^= ((int64_t) (void*) wire_remove__method__NativePreferenceStore); - dummy_var ^= ((int64_t) (void*) wire_remove_prefix__method__NativePreferenceStore); - dummy_var ^= ((int64_t) (void*) new_MutexDummy1Connection); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_native_preference_store_1); - dummy_var ^= ((int64_t) (void*) new_uint_8_list_1); - dummy_var ^= ((int64_t) (void*) drop_opaque_MutexDummy1Connection); - dummy_var ^= ((int64_t) (void*) share_opaque_MutexDummy1Connection); - dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); - dummy_var ^= ((int64_t) (void*) get_dart_object); - dummy_var ^= ((int64_t) (void*) drop_dart_object); - dummy_var ^= ((int64_t) (void*) new_dart_opaque); - return dummy_var; -} diff --git a/ios/Runner/generated_repo.h b/ios/Runner/generated_repo.h deleted file mode 100644 index a21464e5..00000000 --- a/ios/Runner/generated_repo.h +++ /dev/null @@ -1,111 +0,0 @@ -#include -#include -#include -typedef struct _Dart_Handle* Dart_Handle; - -typedef struct DartCObject DartCObject; - -typedef struct wire_MutexDummy1Connection { - const void *ptr; -} wire_MutexDummy1Connection; - -typedef struct wire_NativePreferenceStore { - struct wire_MutexDummy1Connection conn; -} wire_NativePreferenceStore; - -typedef int64_t DartPort; - -typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); - -typedef struct wire_uint_8_list { - uint8_t *ptr; - int32_t len; -} wire_uint_8_list; - -typedef struct wire_MutexRepoDatabaseRead { - const void *ptr; -} wire_MutexRepoDatabaseRead; - -typedef struct wire_LocalDb { - struct wire_MutexRepoDatabaseRead repo; -} wire_LocalDb; - -typedef struct DartCObject *WireSyncReturn; - -typedef struct wire_MutexConnection { - const void *ptr; -} wire_MutexConnection; - -typedef struct wire_LocalStore { - struct wire_MutexConnection conn; -} wire_LocalStore; - -struct wire_NativePreferenceStore *new_box_autoadd_native_preference_store_1(void); - -void store_dart_post_cobject(DartPostCObjectFnType ptr); - -Dart_Handle get_dart_object(uintptr_t ptr); - -void drop_dart_object(uintptr_t ptr); - -uintptr_t new_dart_opaque(Dart_Handle handle); - -intptr_t init_frb_dart_api_dl(void *obj); - -void wire_new__static_method__LocalDb(int64_t port_, struct wire_uint_8_list *path); - -void wire_get_album__method__LocalDb(int64_t port_, - struct wire_LocalDb *that, - struct wire_uint_8_list *album_id); - -void wire_get_albums_by_tag__method__LocalDb(int64_t port_, - struct wire_LocalDb *that, - struct wire_uint_8_list *tag, - bool recursive); - -void wire_get_tags__method__LocalDb(int64_t port_, struct wire_LocalDb *that); - -struct wire_MutexRepoDatabaseRead new_MutexRepoDatabaseRead(void); - -struct wire_LocalDb *new_box_autoadd_local_db_0(void); - -struct wire_uint_8_list *new_uint_8_list_0(int32_t len); - -void drop_opaque_MutexRepoDatabaseRead(const void *ptr); - -const void *share_opaque_MutexRepoDatabaseRead(const void *ptr); - -void free_WireSyncReturn(WireSyncReturn ptr); - -struct wire_LocalStore *new_box_autoadd_local_store_2(void); - -static int64_t dummy_method_to_enforce_bundling_ApiRepository(void) { - int64_t dummy_var = 0; - dummy_var ^= ((int64_t) (void*) wire_new__static_method__LocalDb); - dummy_var ^= ((int64_t) (void*) wire_get_album__method__LocalDb); - dummy_var ^= ((int64_t) (void*) wire_get_albums_by_tag__method__LocalDb); - dummy_var ^= ((int64_t) (void*) wire_get_tags__method__LocalDb); - dummy_var ^= ((int64_t) (void*) new_MutexRepoDatabaseRead); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_local_db_0); - dummy_var ^= ((int64_t) (void*) new_uint_8_list_0); - dummy_var ^= ((int64_t) (void*) drop_opaque_MutexRepoDatabaseRead); - dummy_var ^= ((int64_t) (void*) share_opaque_MutexRepoDatabaseRead); - dummy_var ^= ((int64_t) (void*) free_WireSyncReturn); - dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); - dummy_var ^= ((int64_t) (void*) get_dart_object); - dummy_var ^= ((int64_t) (void*) drop_dart_object); - dummy_var ^= ((int64_t) (void*) new_dart_opaque); - return dummy_var; -} - -#include "generated_preferences.h" -#include "generated_store.h" -#include "generated_network.h" -static int64_t dummy_method_to_enforce_bundling(void) { - int64_t dummy_var = 0; - dummy_var ^= ((int64_t) (void*) dummy_method_to_enforce_bundling_ApiRepository); - dummy_var ^= ((int64_t) (void*) dummy_method_to_enforce_bundling_ApiPreferenceStore); - dummy_var ^= ((int64_t) (void*) dummy_method_to_enforce_bundling_ApiStore); - dummy_var ^= ((int64_t) (void*) dummy_method_to_enforce_bundling_ApiNetwork); - return dummy_var; -} diff --git a/ios/Runner/generated_store.h b/ios/Runner/generated_store.h deleted file mode 100644 index 78f5c017..00000000 --- a/ios/Runner/generated_store.h +++ /dev/null @@ -1,102 +0,0 @@ -#include -#include -#include -typedef struct _Dart_Handle* Dart_Handle; - -typedef struct DartCObject DartCObject; - -typedef struct wire_MutexDummy1Connection { - const void *ptr; -} wire_MutexDummy1Connection; - -typedef struct wire_NativePreferenceStore { - struct wire_MutexDummy1Connection conn; -} wire_NativePreferenceStore; - -typedef struct wire_MutexRepoDatabaseRead { - const void *ptr; -} wire_MutexRepoDatabaseRead; - -typedef struct wire_LocalDb { - struct wire_MutexRepoDatabaseRead repo; -} wire_LocalDb; - -typedef struct DartCObject *WireSyncReturn; - -typedef int64_t DartPort; - -typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); - -typedef struct wire_uint_8_list { - uint8_t *ptr; - int32_t len; -} wire_uint_8_list; - -typedef struct wire_MutexConnection { - const void *ptr; -} wire_MutexConnection; - -typedef struct wire_LocalStore { - struct wire_MutexConnection conn; -} wire_LocalStore; - -struct wire_NativePreferenceStore *new_box_autoadd_native_preference_store_1(void); - -struct wire_LocalDb *new_box_autoadd_local_db_0(void); - -void free_WireSyncReturn(WireSyncReturn ptr); - -void store_dart_post_cobject(DartPostCObjectFnType ptr); - -Dart_Handle get_dart_object(uintptr_t ptr); - -void drop_dart_object(uintptr_t ptr); - -uintptr_t new_dart_opaque(Dart_Handle handle); - -intptr_t init_frb_dart_api_dl(void *obj); - -WireSyncReturn wire_new__static_method__LocalStore(struct wire_uint_8_list *root); - -void wire_insert__method__LocalStore(int64_t port_, - struct wire_LocalStore *that, - struct wire_uint_8_list *category, - struct wire_uint_8_list *key, - struct wire_uint_8_list *value); - -void wire_get__method__LocalStore(int64_t port_, - struct wire_LocalStore *that, - struct wire_uint_8_list *category, - struct wire_uint_8_list *key); - -void wire_clear__method__LocalStore(int64_t port_, - struct wire_LocalStore *that, - struct wire_uint_8_list *category); - -struct wire_MutexConnection new_MutexConnection(void); - -struct wire_LocalStore *new_box_autoadd_local_store_2(void); - -struct wire_uint_8_list *new_uint_8_list_2(int32_t len); - -void drop_opaque_MutexConnection(const void *ptr); - -const void *share_opaque_MutexConnection(const void *ptr); - -static int64_t dummy_method_to_enforce_bundling_ApiStore(void) { - int64_t dummy_var = 0; - dummy_var ^= ((int64_t) (void*) wire_new__static_method__LocalStore); - dummy_var ^= ((int64_t) (void*) wire_insert__method__LocalStore); - dummy_var ^= ((int64_t) (void*) wire_get__method__LocalStore); - dummy_var ^= ((int64_t) (void*) wire_clear__method__LocalStore); - dummy_var ^= ((int64_t) (void*) new_MutexConnection); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_local_store_2); - dummy_var ^= ((int64_t) (void*) new_uint_8_list_2); - dummy_var ^= ((int64_t) (void*) drop_opaque_MutexConnection); - dummy_var ^= ((int64_t) (void*) share_opaque_MutexConnection); - dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); - dummy_var ^= ((int64_t) (void*) get_dart_object); - dummy_var ^= ((int64_t) (void*) drop_dart_object); - dummy_var ^= ((int64_t) (void*) new_dart_opaque); - return dummy_var; -} diff --git a/lib/bridge/bridge.dart b/lib/bridge/bridge.dart deleted file mode 100644 index 8567e5c1..00000000 --- a/lib/bridge/bridge.dart +++ /dev/null @@ -1,30 +0,0 @@ -// This file initializes the dynamic library and connects it with the stub -// generated by flutter_rust_bridge_codegen. - -import 'dart:ffi'; - -import 'package:annix/bridge/generated_network.dart'; -import 'package:annix/bridge/generated_repo.dart'; -import 'package:annix/bridge/generated_store.dart'; -import 'package:annix/bridge/generated_preferences.dart'; - -// Re-export the bridge so it is only necessary to import this file. -import 'dart:io' as io; -export 'generated_network.dart' show NetworkStatus; -export 'generated_repo.dart' show LocalDb; -export 'generated_store.dart' show LocalStore; -export 'generated_preferences.dart' show NativePreferenceStore; - -const _base = 'annix_native'; - -// On MacOS, the dynamic library is not bundled with the binary, -// but rather directly **linked** against the binary. -final _dylibPath = io.Platform.isWindows ? '$_base.dll' : 'lib$_base.so'; -final _dylib = io.Platform.isIOS || io.Platform.isMacOS - ? DynamicLibrary.executable() - : DynamicLibrary.open(_dylibPath); - -final ApiRepository nativeRepository = ApiRepositoryImpl(_dylib); -final ApiStore nativeStore = ApiStoreImpl(_dylib); -final ApiNetwork nativeNetwork = ApiNetworkImpl(_dylib); -final ApiPreferenceStore nativePreferenceStore = ApiPreferenceStoreImpl(_dylib); diff --git a/lib/bridge/bridge_definitions.dart b/lib/bridge/bridge_definitions.dart new file mode 100644 index 00000000..80713e14 --- /dev/null +++ b/lib/bridge/bridge_definitions.dart @@ -0,0 +1,242 @@ +// AUTO GENERATED FILE, DO NOT EDIT. +// Generated by `flutter_rust_bridge`@ 1.81.0. +// ignore_for_file: non_constant_identifier_names, unused_element, duplicate_ignore, directives_ordering, curly_braces_in_flow_control_structures, unnecessary_lambdas, slash_for_doc_comments, prefer_const_literals_to_create_immutables, implicit_dynamic_list_literal, duplicate_import, unused_import, unnecessary_import, prefer_single_quotes, prefer_const_constructors, use_super_parameters, always_use_package_imports, annotate_overrides, invalid_use_of_protected_member, constant_identifier_names, invalid_use_of_internal_member, prefer_is_empty, unnecessary_const + +import 'dart:convert'; +import 'dart:async'; +import 'package:meta/meta.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; +import 'package:uuid/uuid.dart'; + +abstract class AnnixNative { + Future updateNetworkStatus({required bool isOnline, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kUpdateNetworkStatusConstMeta; + + Future isOnlineMethodNetworkStatus({required NetworkStatus that, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kIsOnlineMethodNetworkStatusConstMeta; + + NativePreferenceStore newStaticMethodNativePreferenceStore({required String root, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kNewStaticMethodNativePreferenceStoreConstMeta; + + String? getMethodNativePreferenceStore({required NativePreferenceStore that, required String key, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGetMethodNativePreferenceStoreConstMeta; + + void setMethodNativePreferenceStore( + {required NativePreferenceStore that, required String key, required String value, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kSetMethodNativePreferenceStoreConstMeta; + + void removeMethodNativePreferenceStore({required NativePreferenceStore that, required String key, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kRemoveMethodNativePreferenceStoreConstMeta; + + void removePrefixMethodNativePreferenceStore( + {required NativePreferenceStore that, required String prefix, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kRemovePrefixMethodNativePreferenceStoreConstMeta; + + Future newStaticMethodLocalDb({required String path, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kNewStaticMethodLocalDbConstMeta; + + Future getAlbumMethodLocalDb({required LocalDb that, required UuidValue albumId, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGetAlbumMethodLocalDbConstMeta; + + Future> getAlbumsByTagMethodLocalDb( + {required LocalDb that, required String tag, required bool recursive, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGetAlbumsByTagMethodLocalDbConstMeta; + + Future> getTagsMethodLocalDb({required LocalDb that, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGetTagsMethodLocalDbConstMeta; + + LocalStore newStaticMethodLocalStore({required String root, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kNewStaticMethodLocalStoreConstMeta; + + Future insertMethodLocalStore( + {required LocalStore that, required String category, required String key, required String value, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kInsertMethodLocalStoreConstMeta; + + Future getMethodLocalStore( + {required LocalStore that, required String category, required String key, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGetMethodLocalStoreConstMeta; + + Future clearMethodLocalStore({required LocalStore that, String? category, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kClearMethodLocalStoreConstMeta; + + DropFnType get dropOpaqueMutexConnection; + ShareFnType get shareOpaqueMutexConnection; + OpaqueTypeFinalizer get MutexConnectionFinalizer; + + DropFnType get dropOpaqueMutexDummy1Connection; + ShareFnType get shareOpaqueMutexDummy1Connection; + OpaqueTypeFinalizer get MutexDummy1ConnectionFinalizer; + + DropFnType get dropOpaqueMutexRepoDatabaseRead; + ShareFnType get shareOpaqueMutexRepoDatabaseRead; + OpaqueTypeFinalizer get MutexRepoDatabaseReadFinalizer; +} + +@sealed +class MutexConnection extends FrbOpaque { + final AnnixNative bridge; + MutexConnection.fromRaw(int ptr, int size, this.bridge) : super.unsafe(ptr, size); + @override + DropFnType get dropFn => bridge.dropOpaqueMutexConnection; + + @override + ShareFnType get shareFn => bridge.shareOpaqueMutexConnection; + + @override + OpaqueTypeFinalizer get staticFinalizer => bridge.MutexConnectionFinalizer; +} + +@sealed +class MutexDummy1Connection extends FrbOpaque { + final AnnixNative bridge; + MutexDummy1Connection.fromRaw(int ptr, int size, this.bridge) : super.unsafe(ptr, size); + @override + DropFnType get dropFn => bridge.dropOpaqueMutexDummy1Connection; + + @override + ShareFnType get shareFn => bridge.shareOpaqueMutexDummy1Connection; + + @override + OpaqueTypeFinalizer get staticFinalizer => bridge.MutexDummy1ConnectionFinalizer; +} + +@sealed +class MutexRepoDatabaseRead extends FrbOpaque { + final AnnixNative bridge; + MutexRepoDatabaseRead.fromRaw(int ptr, int size, this.bridge) : super.unsafe(ptr, size); + @override + DropFnType get dropFn => bridge.dropOpaqueMutexRepoDatabaseRead; + + @override + ShareFnType get shareFn => bridge.shareOpaqueMutexRepoDatabaseRead; + + @override + OpaqueTypeFinalizer get staticFinalizer => bridge.MutexRepoDatabaseReadFinalizer; +} + +/// Repo +class LocalDb { + final AnnixNative bridge; + final MutexRepoDatabaseRead repo; + + const LocalDb({ + required this.bridge, + required this.repo, + }); + + static Future newLocalDb({required AnnixNative bridge, required String path, dynamic hint}) => + bridge.newStaticMethodLocalDb(path: path, hint: hint); + + Future getAlbum({required UuidValue albumId, dynamic hint}) => bridge.getAlbumMethodLocalDb( + that: this, + albumId: albumId, + ); + + Future> getAlbumsByTag({required String tag, required bool recursive, dynamic hint}) => + bridge.getAlbumsByTagMethodLocalDb( + that: this, + tag: tag, + recursive: recursive, + ); + + Future> getTags({dynamic hint}) => bridge.getTagsMethodLocalDb( + that: this, + ); +} + +class LocalStore { + final AnnixNative bridge; + final MutexConnection conn; + + const LocalStore({ + required this.bridge, + required this.conn, + }); + + static LocalStore newLocalStore({required AnnixNative bridge, required String root, dynamic hint}) => + bridge.newStaticMethodLocalStore(root: root, hint: hint); + + Future insert({required String category, required String key, required String value, dynamic hint}) => + bridge.insertMethodLocalStore( + that: this, + category: category, + key: key, + value: value, + ); + + Future get({required String category, required String key, dynamic hint}) => bridge.getMethodLocalStore( + that: this, + category: category, + key: key, + ); + + Future clear({String? category, dynamic hint}) => bridge.clearMethodLocalStore( + that: this, + category: category, + ); +} + +class NativePreferenceStore { + final AnnixNative bridge; + final MutexDummy1Connection conn; + + const NativePreferenceStore({ + required this.bridge, + required this.conn, + }); + + static NativePreferenceStore newNativePreferenceStore( + {required AnnixNative bridge, required String root, dynamic hint}) => + bridge.newStaticMethodNativePreferenceStore(root: root, hint: hint); + + String? get({required String key, dynamic hint}) => bridge.getMethodNativePreferenceStore( + that: this, + key: key, + ); + + void set({required String key, required String value, dynamic hint}) => bridge.setMethodNativePreferenceStore( + that: this, + key: key, + value: value, + ); + + void remove({required String key, dynamic hint}) => bridge.removeMethodNativePreferenceStore( + that: this, + key: key, + ); + + void removePrefix({required String prefix, dynamic hint}) => bridge.removePrefixMethodNativePreferenceStore( + that: this, + prefix: prefix, + ); +} + +enum NetworkStatus { + online, + offline, +} + +class TagItem { + final String name; + final List children; + + const TagItem({ + required this.name, + required this.children, + }); +} diff --git a/lib/bridge/bridge_generated.dart b/lib/bridge/bridge_generated.dart new file mode 100644 index 00000000..54ea89db --- /dev/null +++ b/lib/bridge/bridge_generated.dart @@ -0,0 +1,1071 @@ +// AUTO GENERATED FILE, DO NOT EDIT. +// Generated by `flutter_rust_bridge`@ 1.81.0. +// ignore_for_file: non_constant_identifier_names, unused_element, duplicate_ignore, directives_ordering, curly_braces_in_flow_control_structures, unnecessary_lambdas, slash_for_doc_comments, prefer_const_literals_to_create_immutables, implicit_dynamic_list_literal, duplicate_import, unused_import, unnecessary_import, prefer_single_quotes, prefer_const_constructors, use_super_parameters, always_use_package_imports, annotate_overrides, invalid_use_of_protected_member, constant_identifier_names, invalid_use_of_internal_member, prefer_is_empty, unnecessary_const + +import "bridge_definitions.dart"; +import 'dart:convert'; +import 'dart:async'; +import 'package:meta/meta.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; +import 'package:uuid/uuid.dart'; + +import 'dart:convert'; +import 'dart:async'; +import 'package:meta/meta.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; +import 'package:uuid/uuid.dart'; + +import 'dart:ffi' as ffi; + +class AnnixNativeImpl implements AnnixNative { + final AnnixNativePlatform _platform; + factory AnnixNativeImpl(ExternalLibrary dylib) => AnnixNativeImpl.raw(AnnixNativePlatform(dylib)); + + /// Only valid on web/WASM platforms. + factory AnnixNativeImpl.wasm(FutureOr module) => AnnixNativeImpl(module as ExternalLibrary); + AnnixNativeImpl.raw(this._platform); + Future updateNetworkStatus({required bool isOnline, dynamic hint}) { + var arg0 = isOnline; + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_update_network_status(port_, arg0), + parseSuccessData: _wire2api_unit, + constMeta: kUpdateNetworkStatusConstMeta, + argValues: [isOnline], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kUpdateNetworkStatusConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "update_network_status", + argNames: ["isOnline"], + ); + + Future isOnlineMethodNetworkStatus({required NetworkStatus that, dynamic hint}) { + var arg0 = api2wire_network_status(that); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_is_online__method__NetworkStatus(port_, arg0), + parseSuccessData: _wire2api_bool, + constMeta: kIsOnlineMethodNetworkStatusConstMeta, + argValues: [that], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kIsOnlineMethodNetworkStatusConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "is_online__method__NetworkStatus", + argNames: ["that"], + ); + + NativePreferenceStore newStaticMethodNativePreferenceStore({required String root, dynamic hint}) { + var arg0 = _platform.api2wire_String(root); + return _platform.executeSync(FlutterRustBridgeSyncTask( + callFfi: () => _platform.inner.wire_new__static_method__NativePreferenceStore(arg0), + parseSuccessData: _wire2api_native_preference_store, + constMeta: kNewStaticMethodNativePreferenceStoreConstMeta, + argValues: [root], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kNewStaticMethodNativePreferenceStoreConstMeta => + const FlutterRustBridgeTaskConstMeta( + debugName: "new__static_method__NativePreferenceStore", + argNames: ["root"], + ); + + String? getMethodNativePreferenceStore({required NativePreferenceStore that, required String key, dynamic hint}) { + var arg0 = _platform.api2wire_box_autoadd_native_preference_store(that); + var arg1 = _platform.api2wire_String(key); + return _platform.executeSync(FlutterRustBridgeSyncTask( + callFfi: () => _platform.inner.wire_get__method__NativePreferenceStore(arg0, arg1), + parseSuccessData: _wire2api_opt_String, + constMeta: kGetMethodNativePreferenceStoreConstMeta, + argValues: [that, key], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kGetMethodNativePreferenceStoreConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "get__method__NativePreferenceStore", + argNames: ["that", "key"], + ); + + void setMethodNativePreferenceStore( + {required NativePreferenceStore that, required String key, required String value, dynamic hint}) { + var arg0 = _platform.api2wire_box_autoadd_native_preference_store(that); + var arg1 = _platform.api2wire_String(key); + var arg2 = _platform.api2wire_String(value); + return _platform.executeSync(FlutterRustBridgeSyncTask( + callFfi: () => _platform.inner.wire_set__method__NativePreferenceStore(arg0, arg1, arg2), + parseSuccessData: _wire2api_unit, + constMeta: kSetMethodNativePreferenceStoreConstMeta, + argValues: [that, key, value], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kSetMethodNativePreferenceStoreConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "set__method__NativePreferenceStore", + argNames: ["that", "key", "value"], + ); + + void removeMethodNativePreferenceStore({required NativePreferenceStore that, required String key, dynamic hint}) { + var arg0 = _platform.api2wire_box_autoadd_native_preference_store(that); + var arg1 = _platform.api2wire_String(key); + return _platform.executeSync(FlutterRustBridgeSyncTask( + callFfi: () => _platform.inner.wire_remove__method__NativePreferenceStore(arg0, arg1), + parseSuccessData: _wire2api_unit, + constMeta: kRemoveMethodNativePreferenceStoreConstMeta, + argValues: [that, key], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kRemoveMethodNativePreferenceStoreConstMeta => + const FlutterRustBridgeTaskConstMeta( + debugName: "remove__method__NativePreferenceStore", + argNames: ["that", "key"], + ); + + void removePrefixMethodNativePreferenceStore( + {required NativePreferenceStore that, required String prefix, dynamic hint}) { + var arg0 = _platform.api2wire_box_autoadd_native_preference_store(that); + var arg1 = _platform.api2wire_String(prefix); + return _platform.executeSync(FlutterRustBridgeSyncTask( + callFfi: () => _platform.inner.wire_remove_prefix__method__NativePreferenceStore(arg0, arg1), + parseSuccessData: _wire2api_unit, + constMeta: kRemovePrefixMethodNativePreferenceStoreConstMeta, + argValues: [that, prefix], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kRemovePrefixMethodNativePreferenceStoreConstMeta => + const FlutterRustBridgeTaskConstMeta( + debugName: "remove_prefix__method__NativePreferenceStore", + argNames: ["that", "prefix"], + ); + + Future newStaticMethodLocalDb({required String path, dynamic hint}) { + var arg0 = _platform.api2wire_String(path); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_new__static_method__LocalDb(port_, arg0), + parseSuccessData: (d) => _wire2api_local_db(d), + constMeta: kNewStaticMethodLocalDbConstMeta, + argValues: [path], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kNewStaticMethodLocalDbConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "new__static_method__LocalDb", + argNames: ["path"], + ); + + Future getAlbumMethodLocalDb({required LocalDb that, required UuidValue albumId, dynamic hint}) { + var arg0 = _platform.api2wire_box_autoadd_local_db(that); + var arg1 = _platform.api2wire_Uuid(albumId); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_get_album__method__LocalDb(port_, arg0, arg1), + parseSuccessData: _wire2api_opt_String, + constMeta: kGetAlbumMethodLocalDbConstMeta, + argValues: [that, albumId], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kGetAlbumMethodLocalDbConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "get_album__method__LocalDb", + argNames: ["that", "albumId"], + ); + + Future> getAlbumsByTagMethodLocalDb( + {required LocalDb that, required String tag, required bool recursive, dynamic hint}) { + var arg0 = _platform.api2wire_box_autoadd_local_db(that); + var arg1 = _platform.api2wire_String(tag); + var arg2 = recursive; + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_get_albums_by_tag__method__LocalDb(port_, arg0, arg1, arg2), + parseSuccessData: _wire2api_Uuids, + constMeta: kGetAlbumsByTagMethodLocalDbConstMeta, + argValues: [that, tag, recursive], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kGetAlbumsByTagMethodLocalDbConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "get_albums_by_tag__method__LocalDb", + argNames: ["that", "tag", "recursive"], + ); + + Future> getTagsMethodLocalDb({required LocalDb that, dynamic hint}) { + var arg0 = _platform.api2wire_box_autoadd_local_db(that); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_get_tags__method__LocalDb(port_, arg0), + parseSuccessData: _wire2api_list_tag_item, + constMeta: kGetTagsMethodLocalDbConstMeta, + argValues: [that], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kGetTagsMethodLocalDbConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "get_tags__method__LocalDb", + argNames: ["that"], + ); + + LocalStore newStaticMethodLocalStore({required String root, dynamic hint}) { + var arg0 = _platform.api2wire_String(root); + return _platform.executeSync(FlutterRustBridgeSyncTask( + callFfi: () => _platform.inner.wire_new__static_method__LocalStore(arg0), + parseSuccessData: _wire2api_local_store, + constMeta: kNewStaticMethodLocalStoreConstMeta, + argValues: [root], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kNewStaticMethodLocalStoreConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "new__static_method__LocalStore", + argNames: ["root"], + ); + + Future insertMethodLocalStore( + {required LocalStore that, required String category, required String key, required String value, dynamic hint}) { + var arg0 = _platform.api2wire_box_autoadd_local_store(that); + var arg1 = _platform.api2wire_String(category); + var arg2 = _platform.api2wire_String(key); + var arg3 = _platform.api2wire_String(value); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_insert__method__LocalStore(port_, arg0, arg1, arg2, arg3), + parseSuccessData: _wire2api_unit, + constMeta: kInsertMethodLocalStoreConstMeta, + argValues: [that, category, key, value], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kInsertMethodLocalStoreConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "insert__method__LocalStore", + argNames: ["that", "category", "key", "value"], + ); + + Future getMethodLocalStore( + {required LocalStore that, required String category, required String key, dynamic hint}) { + var arg0 = _platform.api2wire_box_autoadd_local_store(that); + var arg1 = _platform.api2wire_String(category); + var arg2 = _platform.api2wire_String(key); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_get__method__LocalStore(port_, arg0, arg1, arg2), + parseSuccessData: _wire2api_opt_String, + constMeta: kGetMethodLocalStoreConstMeta, + argValues: [that, category, key], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kGetMethodLocalStoreConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "get__method__LocalStore", + argNames: ["that", "category", "key"], + ); + + Future clearMethodLocalStore({required LocalStore that, String? category, dynamic hint}) { + var arg0 = _platform.api2wire_box_autoadd_local_store(that); + var arg1 = _platform.api2wire_opt_String(category); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_clear__method__LocalStore(port_, arg0, arg1), + parseSuccessData: _wire2api_unit, + constMeta: kClearMethodLocalStoreConstMeta, + argValues: [that, category], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kClearMethodLocalStoreConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "clear__method__LocalStore", + argNames: ["that", "category"], + ); + + DropFnType get dropOpaqueMutexConnection => _platform.inner.drop_opaque_MutexConnection; + ShareFnType get shareOpaqueMutexConnection => _platform.inner.share_opaque_MutexConnection; + OpaqueTypeFinalizer get MutexConnectionFinalizer => _platform.MutexConnectionFinalizer; + + DropFnType get dropOpaqueMutexDummy1Connection => _platform.inner.drop_opaque_MutexDummy1Connection; + ShareFnType get shareOpaqueMutexDummy1Connection => _platform.inner.share_opaque_MutexDummy1Connection; + OpaqueTypeFinalizer get MutexDummy1ConnectionFinalizer => _platform.MutexDummy1ConnectionFinalizer; + + DropFnType get dropOpaqueMutexRepoDatabaseRead => _platform.inner.drop_opaque_MutexRepoDatabaseRead; + ShareFnType get shareOpaqueMutexRepoDatabaseRead => _platform.inner.share_opaque_MutexRepoDatabaseRead; + OpaqueTypeFinalizer get MutexRepoDatabaseReadFinalizer => _platform.MutexRepoDatabaseReadFinalizer; + + void dispose() { + _platform.dispose(); + } +// Section: wire2api + + MutexConnection _wire2api_MutexConnection(dynamic raw) { + return MutexConnection.fromRaw(raw[0], raw[1], this); + } + + MutexDummy1Connection _wire2api_MutexDummy1Connection(dynamic raw) { + return MutexDummy1Connection.fromRaw(raw[0], raw[1], this); + } + + MutexRepoDatabaseRead _wire2api_MutexRepoDatabaseRead(dynamic raw) { + return MutexRepoDatabaseRead.fromRaw(raw[0], raw[1], this); + } + + String _wire2api_String(dynamic raw) { + return raw as String; + } + + List _wire2api_StringList(dynamic raw) { + return (raw as List).cast(); + } + + List _wire2api_Uuids(dynamic raw) { + final bytes = _wire2api_uint_8_list(raw); + return wire2apiUuids(bytes); + } + + bool _wire2api_bool(dynamic raw) { + return raw as bool; + } + + List _wire2api_list_tag_item(dynamic raw) { + return (raw as List).map(_wire2api_tag_item).toList(); + } + + LocalDb _wire2api_local_db(dynamic raw) { + final arr = raw as List; + if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); + return LocalDb( + bridge: this, + repo: _wire2api_MutexRepoDatabaseRead(arr[0]), + ); + } + + LocalStore _wire2api_local_store(dynamic raw) { + final arr = raw as List; + if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); + return LocalStore( + bridge: this, + conn: _wire2api_MutexConnection(arr[0]), + ); + } + + NativePreferenceStore _wire2api_native_preference_store(dynamic raw) { + final arr = raw as List; + if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); + return NativePreferenceStore( + bridge: this, + conn: _wire2api_MutexDummy1Connection(arr[0]), + ); + } + + String? _wire2api_opt_String(dynamic raw) { + return raw == null ? null : _wire2api_String(raw); + } + + TagItem _wire2api_tag_item(dynamic raw) { + final arr = raw as List; + if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); + return TagItem( + name: _wire2api_String(arr[0]), + children: _wire2api_StringList(arr[1]), + ); + } + + int _wire2api_u8(dynamic raw) { + return raw as int; + } + + Uint8List _wire2api_uint_8_list(dynamic raw) { + return raw as Uint8List; + } + + void _wire2api_unit(dynamic raw) { + return; + } +} + +// Section: api2wire + +@protected +bool api2wire_bool(bool raw) { + return raw; +} + +@protected +int api2wire_i32(int raw) { + return raw; +} + +@protected +int api2wire_network_status(NetworkStatus raw) { + return api2wire_i32(raw.index); +} + +@protected +int api2wire_u8(int raw) { + return raw; +} + +// Section: finalizer + +class AnnixNativePlatform extends FlutterRustBridgeBase { + AnnixNativePlatform(ffi.DynamicLibrary dylib) : super(AnnixNativeWire(dylib)); + +// Section: api2wire + + @protected + wire_MutexConnection api2wire_MutexConnection(MutexConnection raw) { + final ptr = inner.new_MutexConnection(); + _api_fill_to_wire_MutexConnection(raw, ptr); + return ptr; + } + + @protected + wire_MutexDummy1Connection api2wire_MutexDummy1Connection(MutexDummy1Connection raw) { + final ptr = inner.new_MutexDummy1Connection(); + _api_fill_to_wire_MutexDummy1Connection(raw, ptr); + return ptr; + } + + @protected + wire_MutexRepoDatabaseRead api2wire_MutexRepoDatabaseRead(MutexRepoDatabaseRead raw) { + final ptr = inner.new_MutexRepoDatabaseRead(); + _api_fill_to_wire_MutexRepoDatabaseRead(raw, ptr); + return ptr; + } + + @protected + ffi.Pointer api2wire_String(String raw) { + return api2wire_uint_8_list(utf8.encoder.convert(raw)); + } + + @protected + ffi.Pointer api2wire_Uuid(UuidValue raw) { + return api2wire_uint_8_list(raw.toBytes()); + } + + @protected + ffi.Pointer api2wire_box_autoadd_local_db(LocalDb raw) { + final ptr = inner.new_box_autoadd_local_db_0(); + _api_fill_to_wire_local_db(raw, ptr.ref); + return ptr; + } + + @protected + ffi.Pointer api2wire_box_autoadd_local_store(LocalStore raw) { + final ptr = inner.new_box_autoadd_local_store_0(); + _api_fill_to_wire_local_store(raw, ptr.ref); + return ptr; + } + + @protected + ffi.Pointer api2wire_box_autoadd_native_preference_store(NativePreferenceStore raw) { + final ptr = inner.new_box_autoadd_native_preference_store_0(); + _api_fill_to_wire_native_preference_store(raw, ptr.ref); + return ptr; + } + + @protected + ffi.Pointer api2wire_opt_String(String? raw) { + return raw == null ? ffi.nullptr : api2wire_String(raw); + } + + @protected + ffi.Pointer api2wire_uint_8_list(Uint8List raw) { + final ans = inner.new_uint_8_list_0(raw.length); + ans.ref.ptr.asTypedList(raw.length).setAll(0, raw); + return ans; + } +// Section: finalizer + + late final OpaqueTypeFinalizer _MutexConnectionFinalizer = OpaqueTypeFinalizer(inner._drop_opaque_MutexConnectionPtr); + OpaqueTypeFinalizer get MutexConnectionFinalizer => _MutexConnectionFinalizer; + late final OpaqueTypeFinalizer _MutexDummy1ConnectionFinalizer = + OpaqueTypeFinalizer(inner._drop_opaque_MutexDummy1ConnectionPtr); + OpaqueTypeFinalizer get MutexDummy1ConnectionFinalizer => _MutexDummy1ConnectionFinalizer; + late final OpaqueTypeFinalizer _MutexRepoDatabaseReadFinalizer = + OpaqueTypeFinalizer(inner._drop_opaque_MutexRepoDatabaseReadPtr); + OpaqueTypeFinalizer get MutexRepoDatabaseReadFinalizer => _MutexRepoDatabaseReadFinalizer; +// Section: api_fill_to_wire + + void _api_fill_to_wire_MutexConnection(MutexConnection apiObj, wire_MutexConnection wireObj) { + wireObj.ptr = apiObj.shareOrMove(); + } + + void _api_fill_to_wire_MutexDummy1Connection(MutexDummy1Connection apiObj, wire_MutexDummy1Connection wireObj) { + wireObj.ptr = apiObj.shareOrMove(); + } + + void _api_fill_to_wire_MutexRepoDatabaseRead(MutexRepoDatabaseRead apiObj, wire_MutexRepoDatabaseRead wireObj) { + wireObj.ptr = apiObj.shareOrMove(); + } + + void _api_fill_to_wire_box_autoadd_local_db(LocalDb apiObj, ffi.Pointer wireObj) { + _api_fill_to_wire_local_db(apiObj, wireObj.ref); + } + + void _api_fill_to_wire_box_autoadd_local_store(LocalStore apiObj, ffi.Pointer wireObj) { + _api_fill_to_wire_local_store(apiObj, wireObj.ref); + } + + void _api_fill_to_wire_box_autoadd_native_preference_store( + NativePreferenceStore apiObj, ffi.Pointer wireObj) { + _api_fill_to_wire_native_preference_store(apiObj, wireObj.ref); + } + + void _api_fill_to_wire_local_db(LocalDb apiObj, wire_LocalDb wireObj) { + wireObj.repo = api2wire_MutexRepoDatabaseRead(apiObj.repo); + } + + void _api_fill_to_wire_local_store(LocalStore apiObj, wire_LocalStore wireObj) { + wireObj.conn = api2wire_MutexConnection(apiObj.conn); + } + + void _api_fill_to_wire_native_preference_store(NativePreferenceStore apiObj, wire_NativePreferenceStore wireObj) { + wireObj.conn = api2wire_MutexDummy1Connection(apiObj.conn); + } +} + +// ignore_for_file: camel_case_types, non_constant_identifier_names, avoid_positional_boolean_parameters, annotate_overrides, constant_identifier_names + +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +// ignore_for_file: type=lint + +/// generated by flutter_rust_bridge +class AnnixNativeWire implements FlutterRustBridgeWireBase { + @internal + late final dartApi = DartApiDl(init_frb_dart_api_dl); + + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + AnnixNativeWire(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; + + /// The symbols are looked up with [lookup]. + AnnixNativeWire.fromLookup(ffi.Pointer Function(String symbolName) lookup) + : _lookup = lookup; + + void store_dart_post_cobject( + DartPostCObjectFnType ptr, + ) { + return _store_dart_post_cobject( + ptr, + ); + } + + late final _store_dart_post_cobjectPtr = + _lookup>('store_dart_post_cobject'); + late final _store_dart_post_cobject = _store_dart_post_cobjectPtr.asFunction(); + + Object get_dart_object( + int ptr, + ) { + return _get_dart_object( + ptr, + ); + } + + late final _get_dart_objectPtr = _lookup>('get_dart_object'); + late final _get_dart_object = _get_dart_objectPtr.asFunction(); + + void drop_dart_object( + int ptr, + ) { + return _drop_dart_object( + ptr, + ); + } + + late final _drop_dart_objectPtr = _lookup>('drop_dart_object'); + late final _drop_dart_object = _drop_dart_objectPtr.asFunction(); + + int new_dart_opaque( + Object handle, + ) { + return _new_dart_opaque( + handle, + ); + } + + late final _new_dart_opaquePtr = _lookup>('new_dart_opaque'); + late final _new_dart_opaque = _new_dart_opaquePtr.asFunction(); + + int init_frb_dart_api_dl( + ffi.Pointer obj, + ) { + return _init_frb_dart_api_dl( + obj, + ); + } + + late final _init_frb_dart_api_dlPtr = + _lookup)>>('init_frb_dart_api_dl'); + late final _init_frb_dart_api_dl = _init_frb_dart_api_dlPtr.asFunction)>(); + + void wire_update_network_status( + int port_, + bool is_online, + ) { + return _wire_update_network_status( + port_, + is_online, + ); + } + + late final _wire_update_network_statusPtr = + _lookup>('wire_update_network_status'); + late final _wire_update_network_status = _wire_update_network_statusPtr.asFunction(); + + void wire_is_online__method__NetworkStatus( + int port_, + int that, + ) { + return _wire_is_online__method__NetworkStatus( + port_, + that, + ); + } + + late final _wire_is_online__method__NetworkStatusPtr = + _lookup>('wire_is_online__method__NetworkStatus'); + late final _wire_is_online__method__NetworkStatus = + _wire_is_online__method__NetworkStatusPtr.asFunction(); + + WireSyncReturn wire_new__static_method__NativePreferenceStore( + ffi.Pointer root, + ) { + return _wire_new__static_method__NativePreferenceStore( + root, + ); + } + + late final _wire_new__static_method__NativePreferenceStorePtr = + _lookup)>>( + 'wire_new__static_method__NativePreferenceStore'); + late final _wire_new__static_method__NativePreferenceStore = _wire_new__static_method__NativePreferenceStorePtr + .asFunction)>(); + + WireSyncReturn wire_get__method__NativePreferenceStore( + ffi.Pointer that, + ffi.Pointer key, + ) { + return _wire_get__method__NativePreferenceStore( + that, + key, + ); + } + + late final _wire_get__method__NativePreferenceStorePtr = _lookup< + ffi.NativeFunction< + WireSyncReturn Function(ffi.Pointer, + ffi.Pointer)>>('wire_get__method__NativePreferenceStore'); + late final _wire_get__method__NativePreferenceStore = _wire_get__method__NativePreferenceStorePtr + .asFunction, ffi.Pointer)>(); + + WireSyncReturn wire_set__method__NativePreferenceStore( + ffi.Pointer that, + ffi.Pointer key, + ffi.Pointer value, + ) { + return _wire_set__method__NativePreferenceStore( + that, + key, + value, + ); + } + + late final _wire_set__method__NativePreferenceStorePtr = _lookup< + ffi.NativeFunction< + WireSyncReturn Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('wire_set__method__NativePreferenceStore'); + late final _wire_set__method__NativePreferenceStore = _wire_set__method__NativePreferenceStorePtr.asFunction< + WireSyncReturn Function( + ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); + + WireSyncReturn wire_remove__method__NativePreferenceStore( + ffi.Pointer that, + ffi.Pointer key, + ) { + return _wire_remove__method__NativePreferenceStore( + that, + key, + ); + } + + late final _wire_remove__method__NativePreferenceStorePtr = _lookup< + ffi.NativeFunction< + WireSyncReturn Function(ffi.Pointer, + ffi.Pointer)>>('wire_remove__method__NativePreferenceStore'); + late final _wire_remove__method__NativePreferenceStore = _wire_remove__method__NativePreferenceStorePtr + .asFunction, ffi.Pointer)>(); + + WireSyncReturn wire_remove_prefix__method__NativePreferenceStore( + ffi.Pointer that, + ffi.Pointer prefix, + ) { + return _wire_remove_prefix__method__NativePreferenceStore( + that, + prefix, + ); + } + + late final _wire_remove_prefix__method__NativePreferenceStorePtr = _lookup< + ffi.NativeFunction< + WireSyncReturn Function(ffi.Pointer, + ffi.Pointer)>>('wire_remove_prefix__method__NativePreferenceStore'); + late final _wire_remove_prefix__method__NativePreferenceStore = _wire_remove_prefix__method__NativePreferenceStorePtr + .asFunction, ffi.Pointer)>(); + + void wire_new__static_method__LocalDb( + int port_, + ffi.Pointer path, + ) { + return _wire_new__static_method__LocalDb( + port_, + path, + ); + } + + late final _wire_new__static_method__LocalDbPtr = + _lookup)>>( + 'wire_new__static_method__LocalDb'); + late final _wire_new__static_method__LocalDb = + _wire_new__static_method__LocalDbPtr.asFunction)>(); + + void wire_get_album__method__LocalDb( + int port_, + ffi.Pointer that, + ffi.Pointer album_id, + ) { + return _wire_get_album__method__LocalDb( + port_, + that, + album_id, + ); + } + + late final _wire_get_album__method__LocalDbPtr = _lookup< + ffi.NativeFunction, ffi.Pointer)>>( + 'wire_get_album__method__LocalDb'); + late final _wire_get_album__method__LocalDb = _wire_get_album__method__LocalDbPtr + .asFunction, ffi.Pointer)>(); + + void wire_get_albums_by_tag__method__LocalDb( + int port_, + ffi.Pointer that, + ffi.Pointer tag, + bool recursive, + ) { + return _wire_get_albums_by_tag__method__LocalDb( + port_, + that, + tag, + recursive, + ); + } + + late final _wire_get_albums_by_tag__method__LocalDbPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, ffi.Pointer, ffi.Pointer, + ffi.Bool)>>('wire_get_albums_by_tag__method__LocalDb'); + late final _wire_get_albums_by_tag__method__LocalDb = _wire_get_albums_by_tag__method__LocalDbPtr + .asFunction, ffi.Pointer, bool)>(); + + void wire_get_tags__method__LocalDb( + int port_, + ffi.Pointer that, + ) { + return _wire_get_tags__method__LocalDb( + port_, + that, + ); + } + + late final _wire_get_tags__method__LocalDbPtr = + _lookup)>>( + 'wire_get_tags__method__LocalDb'); + late final _wire_get_tags__method__LocalDb = + _wire_get_tags__method__LocalDbPtr.asFunction)>(); + + WireSyncReturn wire_new__static_method__LocalStore( + ffi.Pointer root, + ) { + return _wire_new__static_method__LocalStore( + root, + ); + } + + late final _wire_new__static_method__LocalStorePtr = + _lookup)>>( + 'wire_new__static_method__LocalStore'); + late final _wire_new__static_method__LocalStore = + _wire_new__static_method__LocalStorePtr.asFunction)>(); + + void wire_insert__method__LocalStore( + int port_, + ffi.Pointer that, + ffi.Pointer category, + ffi.Pointer key, + ffi.Pointer value, + ) { + return _wire_insert__method__LocalStore( + port_, + that, + category, + key, + value, + ); + } + + late final _wire_insert__method__LocalStorePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, ffi.Pointer, ffi.Pointer, + ffi.Pointer, ffi.Pointer)>>('wire_insert__method__LocalStore'); + late final _wire_insert__method__LocalStore = _wire_insert__method__LocalStorePtr.asFunction< + void Function(int, ffi.Pointer, ffi.Pointer, ffi.Pointer, + ffi.Pointer)>(); + + void wire_get__method__LocalStore( + int port_, + ffi.Pointer that, + ffi.Pointer category, + ffi.Pointer key, + ) { + return _wire_get__method__LocalStore( + port_, + that, + category, + key, + ); + } + + late final _wire_get__method__LocalStorePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, ffi.Pointer, ffi.Pointer, + ffi.Pointer)>>('wire_get__method__LocalStore'); + late final _wire_get__method__LocalStore = _wire_get__method__LocalStorePtr.asFunction< + void Function(int, ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); + + void wire_clear__method__LocalStore( + int port_, + ffi.Pointer that, + ffi.Pointer category, + ) { + return _wire_clear__method__LocalStore( + port_, + that, + category, + ); + } + + late final _wire_clear__method__LocalStorePtr = _lookup< + ffi + .NativeFunction, ffi.Pointer)>>( + 'wire_clear__method__LocalStore'); + late final _wire_clear__method__LocalStore = _wire_clear__method__LocalStorePtr + .asFunction, ffi.Pointer)>(); + + wire_MutexConnection new_MutexConnection() { + return _new_MutexConnection(); + } + + late final _new_MutexConnectionPtr = + _lookup>('new_MutexConnection'); + late final _new_MutexConnection = _new_MutexConnectionPtr.asFunction(); + + wire_MutexDummy1Connection new_MutexDummy1Connection() { + return _new_MutexDummy1Connection(); + } + + late final _new_MutexDummy1ConnectionPtr = + _lookup>('new_MutexDummy1Connection'); + late final _new_MutexDummy1Connection = + _new_MutexDummy1ConnectionPtr.asFunction(); + + wire_MutexRepoDatabaseRead new_MutexRepoDatabaseRead() { + return _new_MutexRepoDatabaseRead(); + } + + late final _new_MutexRepoDatabaseReadPtr = + _lookup>('new_MutexRepoDatabaseRead'); + late final _new_MutexRepoDatabaseRead = + _new_MutexRepoDatabaseReadPtr.asFunction(); + + ffi.Pointer new_box_autoadd_local_db_0() { + return _new_box_autoadd_local_db_0(); + } + + late final _new_box_autoadd_local_db_0Ptr = + _lookup Function()>>('new_box_autoadd_local_db_0'); + late final _new_box_autoadd_local_db_0 = + _new_box_autoadd_local_db_0Ptr.asFunction Function()>(); + + ffi.Pointer new_box_autoadd_local_store_0() { + return _new_box_autoadd_local_store_0(); + } + + late final _new_box_autoadd_local_store_0Ptr = + _lookup Function()>>('new_box_autoadd_local_store_0'); + late final _new_box_autoadd_local_store_0 = + _new_box_autoadd_local_store_0Ptr.asFunction Function()>(); + + ffi.Pointer new_box_autoadd_native_preference_store_0() { + return _new_box_autoadd_native_preference_store_0(); + } + + late final _new_box_autoadd_native_preference_store_0Ptr = + _lookup Function()>>( + 'new_box_autoadd_native_preference_store_0'); + late final _new_box_autoadd_native_preference_store_0 = + _new_box_autoadd_native_preference_store_0Ptr.asFunction Function()>(); + + ffi.Pointer new_uint_8_list_0( + int len, + ) { + return _new_uint_8_list_0( + len, + ); + } + + late final _new_uint_8_list_0Ptr = + _lookup Function(ffi.Int32)>>('new_uint_8_list_0'); + late final _new_uint_8_list_0 = _new_uint_8_list_0Ptr.asFunction Function(int)>(); + + void drop_opaque_MutexConnection( + ffi.Pointer ptr, + ) { + return _drop_opaque_MutexConnection( + ptr, + ); + } + + late final _drop_opaque_MutexConnectionPtr = + _lookup)>>('drop_opaque_MutexConnection'); + late final _drop_opaque_MutexConnection = + _drop_opaque_MutexConnectionPtr.asFunction)>(); + + ffi.Pointer share_opaque_MutexConnection( + ffi.Pointer ptr, + ) { + return _share_opaque_MutexConnection( + ptr, + ); + } + + late final _share_opaque_MutexConnectionPtr = + _lookup Function(ffi.Pointer)>>( + 'share_opaque_MutexConnection'); + late final _share_opaque_MutexConnection = + _share_opaque_MutexConnectionPtr.asFunction Function(ffi.Pointer)>(); + + void drop_opaque_MutexDummy1Connection( + ffi.Pointer ptr, + ) { + return _drop_opaque_MutexDummy1Connection( + ptr, + ); + } + + late final _drop_opaque_MutexDummy1ConnectionPtr = + _lookup)>>('drop_opaque_MutexDummy1Connection'); + late final _drop_opaque_MutexDummy1Connection = + _drop_opaque_MutexDummy1ConnectionPtr.asFunction)>(); + + ffi.Pointer share_opaque_MutexDummy1Connection( + ffi.Pointer ptr, + ) { + return _share_opaque_MutexDummy1Connection( + ptr, + ); + } + + late final _share_opaque_MutexDummy1ConnectionPtr = + _lookup Function(ffi.Pointer)>>( + 'share_opaque_MutexDummy1Connection'); + late final _share_opaque_MutexDummy1Connection = + _share_opaque_MutexDummy1ConnectionPtr.asFunction Function(ffi.Pointer)>(); + + void drop_opaque_MutexRepoDatabaseRead( + ffi.Pointer ptr, + ) { + return _drop_opaque_MutexRepoDatabaseRead( + ptr, + ); + } + + late final _drop_opaque_MutexRepoDatabaseReadPtr = + _lookup)>>('drop_opaque_MutexRepoDatabaseRead'); + late final _drop_opaque_MutexRepoDatabaseRead = + _drop_opaque_MutexRepoDatabaseReadPtr.asFunction)>(); + + ffi.Pointer share_opaque_MutexRepoDatabaseRead( + ffi.Pointer ptr, + ) { + return _share_opaque_MutexRepoDatabaseRead( + ptr, + ); + } + + late final _share_opaque_MutexRepoDatabaseReadPtr = + _lookup Function(ffi.Pointer)>>( + 'share_opaque_MutexRepoDatabaseRead'); + late final _share_opaque_MutexRepoDatabaseRead = + _share_opaque_MutexRepoDatabaseReadPtr.asFunction Function(ffi.Pointer)>(); + + void free_WireSyncReturn( + WireSyncReturn ptr, + ) { + return _free_WireSyncReturn( + ptr, + ); + } + + late final _free_WireSyncReturnPtr = + _lookup>('free_WireSyncReturn'); + late final _free_WireSyncReturn = _free_WireSyncReturnPtr.asFunction(); +} + +final class _Dart_Handle extends ffi.Opaque {} + +final class wire_uint_8_list extends ffi.Struct { + external ffi.Pointer ptr; + + @ffi.Int32() + external int len; +} + +final class wire_MutexDummy1Connection extends ffi.Struct { + external ffi.Pointer ptr; +} + +final class wire_NativePreferenceStore extends ffi.Struct { + external wire_MutexDummy1Connection conn; +} + +final class wire_MutexRepoDatabaseRead extends ffi.Struct { + external ffi.Pointer ptr; +} + +final class wire_LocalDb extends ffi.Struct { + external wire_MutexRepoDatabaseRead repo; +} + +final class wire_MutexConnection extends ffi.Struct { + external ffi.Pointer ptr; +} + +final class wire_LocalStore extends ffi.Struct { + external wire_MutexConnection conn; +} + +typedef DartPostCObjectFnType + = ffi.Pointer message)>>; +typedef DartPort = ffi.Int64; diff --git a/lib/bridge/generated_network.dart b/lib/bridge/generated_network.dart deleted file mode 100644 index 3c79714e..00000000 --- a/lib/bridge/generated_network.dart +++ /dev/null @@ -1,286 +0,0 @@ -// AUTO GENERATED FILE, DO NOT EDIT. -// Generated by `flutter_rust_bridge`@ 1.81.0. -// ignore_for_file: non_constant_identifier_names, unused_element, duplicate_ignore, directives_ordering, curly_braces_in_flow_control_structures, unnecessary_lambdas, slash_for_doc_comments, prefer_const_literals_to_create_immutables, implicit_dynamic_list_literal, duplicate_import, unused_import, unnecessary_import, prefer_single_quotes, prefer_const_constructors, use_super_parameters, always_use_package_imports, annotate_overrides, invalid_use_of_protected_member, constant_identifier_names, invalid_use_of_internal_member, prefer_is_empty, unnecessary_const - -import 'dart:convert'; -import 'dart:async'; -import 'package:meta/meta.dart'; -import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; -import 'package:uuid/uuid.dart'; - -import 'dart:ffi' as ffi; - -abstract class ApiNetwork { - Future updateNetworkStatus({required bool isOnline, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kUpdateNetworkStatusConstMeta; - - Future isOnlineMethodNetworkStatus({required NetworkStatus that, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kIsOnlineMethodNetworkStatusConstMeta; -} - -enum NetworkStatus { - online, - offline, -} - -class ApiNetworkImpl implements ApiNetwork { - final ApiNetworkPlatform _platform; - factory ApiNetworkImpl(ExternalLibrary dylib) => ApiNetworkImpl.raw(ApiNetworkPlatform(dylib)); - - /// Only valid on web/WASM platforms. - factory ApiNetworkImpl.wasm(FutureOr module) => ApiNetworkImpl(module as ExternalLibrary); - ApiNetworkImpl.raw(this._platform); - Future updateNetworkStatus({required bool isOnline, dynamic hint}) { - var arg0 = isOnline; - return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_update_network_status(port_, arg0), - parseSuccessData: _wire2api_unit, - constMeta: kUpdateNetworkStatusConstMeta, - argValues: [isOnline], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kUpdateNetworkStatusConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "update_network_status", - argNames: ["isOnline"], - ); - - Future isOnlineMethodNetworkStatus({required NetworkStatus that, dynamic hint}) { - var arg0 = api2wire_network_status(that); - return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_is_online__method__NetworkStatus(port_, arg0), - parseSuccessData: _wire2api_bool, - constMeta: kIsOnlineMethodNetworkStatusConstMeta, - argValues: [that], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kIsOnlineMethodNetworkStatusConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "is_online__method__NetworkStatus", - argNames: ["that"], - ); - - void dispose() { - _platform.dispose(); - } -// Section: wire2api - - bool _wire2api_bool(dynamic raw) { - return raw as bool; - } - - void _wire2api_unit(dynamic raw) { - return; - } -} - -// Section: api2wire - -@protected -bool api2wire_bool(bool raw) { - return raw; -} - -@protected -int api2wire_i32(int raw) { - return raw; -} - -@protected -int api2wire_network_status(NetworkStatus raw) { - return api2wire_i32(raw.index); -} -// Section: finalizer - -class ApiNetworkPlatform extends FlutterRustBridgeBase { - ApiNetworkPlatform(ffi.DynamicLibrary dylib) : super(ApiNetworkWire(dylib)); - -// Section: api2wire - -// Section: finalizer - -// Section: api_fill_to_wire -} - -// ignore_for_file: camel_case_types, non_constant_identifier_names, avoid_positional_boolean_parameters, annotate_overrides, constant_identifier_names - -// AUTO GENERATED FILE, DO NOT EDIT. -// -// Generated by `package:ffigen`. -// ignore_for_file: type=lint - -/// generated by flutter_rust_bridge -class ApiNetworkWire implements FlutterRustBridgeWireBase { - @internal - late final dartApi = DartApiDl(init_frb_dart_api_dl); - - /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) _lookup; - - /// The symbols are looked up in [dynamicLibrary]. - ApiNetworkWire(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; - - /// The symbols are looked up with [lookup]. - ApiNetworkWire.fromLookup(ffi.Pointer Function(String symbolName) lookup) - : _lookup = lookup; - - void store_dart_post_cobject( - DartPostCObjectFnType ptr, - ) { - return _store_dart_post_cobject( - ptr, - ); - } - - late final _store_dart_post_cobjectPtr = - _lookup>('store_dart_post_cobject'); - late final _store_dart_post_cobject = _store_dart_post_cobjectPtr.asFunction(); - - Object get_dart_object( - int ptr, - ) { - return _get_dart_object( - ptr, - ); - } - - late final _get_dart_objectPtr = _lookup>('get_dart_object'); - late final _get_dart_object = _get_dart_objectPtr.asFunction(); - - void drop_dart_object( - int ptr, - ) { - return _drop_dart_object( - ptr, - ); - } - - late final _drop_dart_objectPtr = _lookup>('drop_dart_object'); - late final _drop_dart_object = _drop_dart_objectPtr.asFunction(); - - int new_dart_opaque( - Object handle, - ) { - return _new_dart_opaque( - handle, - ); - } - - late final _new_dart_opaquePtr = _lookup>('new_dart_opaque'); - late final _new_dart_opaque = _new_dart_opaquePtr.asFunction(); - - int init_frb_dart_api_dl( - ffi.Pointer obj, - ) { - return _init_frb_dart_api_dl( - obj, - ); - } - - late final _init_frb_dart_api_dlPtr = - _lookup)>>('init_frb_dart_api_dl'); - late final _init_frb_dart_api_dl = _init_frb_dart_api_dlPtr.asFunction)>(); - - void wire_update_network_status( - int port_, - bool is_online, - ) { - return _wire_update_network_status( - port_, - is_online, - ); - } - - late final _wire_update_network_statusPtr = - _lookup>('wire_update_network_status'); - late final _wire_update_network_status = _wire_update_network_statusPtr.asFunction(); - - void wire_is_online__method__NetworkStatus( - int port_, - int that, - ) { - return _wire_is_online__method__NetworkStatus( - port_, - that, - ); - } - - late final _wire_is_online__method__NetworkStatusPtr = - _lookup>('wire_is_online__method__NetworkStatus'); - late final _wire_is_online__method__NetworkStatus = - _wire_is_online__method__NetworkStatusPtr.asFunction(); - - ffi.Pointer new_box_autoadd_native_preference_store_1() { - return _new_box_autoadd_native_preference_store_1(); - } - - late final _new_box_autoadd_native_preference_store_1Ptr = - _lookup Function()>>( - 'new_box_autoadd_native_preference_store_1'); - late final _new_box_autoadd_native_preference_store_1 = - _new_box_autoadd_native_preference_store_1Ptr.asFunction Function()>(); - - ffi.Pointer new_box_autoadd_local_db_0() { - return _new_box_autoadd_local_db_0(); - } - - late final _new_box_autoadd_local_db_0Ptr = - _lookup Function()>>('new_box_autoadd_local_db_0'); - late final _new_box_autoadd_local_db_0 = - _new_box_autoadd_local_db_0Ptr.asFunction Function()>(); - - void free_WireSyncReturn( - WireSyncReturn ptr, - ) { - return _free_WireSyncReturn( - ptr, - ); - } - - late final _free_WireSyncReturnPtr = - _lookup>('free_WireSyncReturn'); - late final _free_WireSyncReturn = _free_WireSyncReturnPtr.asFunction(); - - ffi.Pointer new_box_autoadd_local_store_2() { - return _new_box_autoadd_local_store_2(); - } - - late final _new_box_autoadd_local_store_2Ptr = - _lookup Function()>>('new_box_autoadd_local_store_2'); - late final _new_box_autoadd_local_store_2 = - _new_box_autoadd_local_store_2Ptr.asFunction Function()>(); -} - -final class _Dart_Handle extends ffi.Opaque {} - -final class wire_MutexDummy1Connection extends ffi.Struct { - external ffi.Pointer ptr; -} - -final class wire_NativePreferenceStore extends ffi.Struct { - external wire_MutexDummy1Connection conn; -} - -final class wire_MutexRepoDatabaseRead extends ffi.Struct { - external ffi.Pointer ptr; -} - -final class wire_LocalDb extends ffi.Struct { - external wire_MutexRepoDatabaseRead repo; -} - -final class wire_MutexConnection extends ffi.Struct { - external ffi.Pointer ptr; -} - -final class wire_LocalStore extends ffi.Struct { - external wire_MutexConnection conn; -} - -typedef DartPostCObjectFnType - = ffi.Pointer message)>>; -typedef DartPort = ffi.Int64; diff --git a/lib/bridge/generated_preferences.dart b/lib/bridge/generated_preferences.dart deleted file mode 100644 index 6e2c81ca..00000000 --- a/lib/bridge/generated_preferences.dart +++ /dev/null @@ -1,579 +0,0 @@ -// AUTO GENERATED FILE, DO NOT EDIT. -// Generated by `flutter_rust_bridge`@ 1.81.0. -// ignore_for_file: non_constant_identifier_names, unused_element, duplicate_ignore, directives_ordering, curly_braces_in_flow_control_structures, unnecessary_lambdas, slash_for_doc_comments, prefer_const_literals_to_create_immutables, implicit_dynamic_list_literal, duplicate_import, unused_import, unnecessary_import, prefer_single_quotes, prefer_const_constructors, use_super_parameters, always_use_package_imports, annotate_overrides, invalid_use_of_protected_member, constant_identifier_names, invalid_use_of_internal_member, prefer_is_empty, unnecessary_const - -import 'dart:convert'; -import 'dart:async'; -import 'package:meta/meta.dart'; -import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; -import 'package:uuid/uuid.dart'; - -import 'dart:ffi' as ffi; - -abstract class ApiPreferenceStore { - NativePreferenceStore newStaticMethodNativePreferenceStore({required String root, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kNewStaticMethodNativePreferenceStoreConstMeta; - - String? getMethodNativePreferenceStore({required NativePreferenceStore that, required String key, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kGetMethodNativePreferenceStoreConstMeta; - - void setMethodNativePreferenceStore( - {required NativePreferenceStore that, required String key, required String value, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kSetMethodNativePreferenceStoreConstMeta; - - void removeMethodNativePreferenceStore({required NativePreferenceStore that, required String key, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kRemoveMethodNativePreferenceStoreConstMeta; - - void removePrefixMethodNativePreferenceStore( - {required NativePreferenceStore that, required String prefix, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kRemovePrefixMethodNativePreferenceStoreConstMeta; - - DropFnType get dropOpaqueMutexDummy1Connection; - ShareFnType get shareOpaqueMutexDummy1Connection; - OpaqueTypeFinalizer get MutexDummy1ConnectionFinalizer; -} - -@sealed -class MutexDummy1Connection extends FrbOpaque { - final ApiPreferenceStore bridge; - MutexDummy1Connection.fromRaw(int ptr, int size, this.bridge) : super.unsafe(ptr, size); - @override - DropFnType get dropFn => bridge.dropOpaqueMutexDummy1Connection; - - @override - ShareFnType get shareFn => bridge.shareOpaqueMutexDummy1Connection; - - @override - OpaqueTypeFinalizer get staticFinalizer => bridge.MutexDummy1ConnectionFinalizer; -} - -class NativePreferenceStore { - final ApiPreferenceStore bridge; - final MutexDummy1Connection conn; - - const NativePreferenceStore({ - required this.bridge, - required this.conn, - }); - - static NativePreferenceStore newNativePreferenceStore( - {required ApiPreferenceStore bridge, required String root, dynamic hint}) => - bridge.newStaticMethodNativePreferenceStore(root: root, hint: hint); - - String? get({required String key, dynamic hint}) => bridge.getMethodNativePreferenceStore( - that: this, - key: key, - ); - - void set({required String key, required String value, dynamic hint}) => bridge.setMethodNativePreferenceStore( - that: this, - key: key, - value: value, - ); - - void remove({required String key, dynamic hint}) => bridge.removeMethodNativePreferenceStore( - that: this, - key: key, - ); - - void removePrefix({required String prefix, dynamic hint}) => bridge.removePrefixMethodNativePreferenceStore( - that: this, - prefix: prefix, - ); -} - -class ApiPreferenceStoreImpl implements ApiPreferenceStore { - final ApiPreferenceStorePlatform _platform; - factory ApiPreferenceStoreImpl(ExternalLibrary dylib) => - ApiPreferenceStoreImpl.raw(ApiPreferenceStorePlatform(dylib)); - - /// Only valid on web/WASM platforms. - factory ApiPreferenceStoreImpl.wasm(FutureOr module) => ApiPreferenceStoreImpl(module as ExternalLibrary); - ApiPreferenceStoreImpl.raw(this._platform); - NativePreferenceStore newStaticMethodNativePreferenceStore({required String root, dynamic hint}) { - var arg0 = _platform.api2wire_String(root); - return _platform.executeSync(FlutterRustBridgeSyncTask( - callFfi: () => _platform.inner.wire_new__static_method__NativePreferenceStore(arg0), - parseSuccessData: _wire2api_native_preference_store, - constMeta: kNewStaticMethodNativePreferenceStoreConstMeta, - argValues: [root], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kNewStaticMethodNativePreferenceStoreConstMeta => - const FlutterRustBridgeTaskConstMeta( - debugName: "new__static_method__NativePreferenceStore", - argNames: ["root"], - ); - - String? getMethodNativePreferenceStore({required NativePreferenceStore that, required String key, dynamic hint}) { - var arg0 = _platform.api2wire_box_autoadd_native_preference_store(that); - var arg1 = _platform.api2wire_String(key); - return _platform.executeSync(FlutterRustBridgeSyncTask( - callFfi: () => _platform.inner.wire_get__method__NativePreferenceStore(arg0, arg1), - parseSuccessData: _wire2api_opt_String, - constMeta: kGetMethodNativePreferenceStoreConstMeta, - argValues: [that, key], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kGetMethodNativePreferenceStoreConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "get__method__NativePreferenceStore", - argNames: ["that", "key"], - ); - - void setMethodNativePreferenceStore( - {required NativePreferenceStore that, required String key, required String value, dynamic hint}) { - var arg0 = _platform.api2wire_box_autoadd_native_preference_store(that); - var arg1 = _platform.api2wire_String(key); - var arg2 = _platform.api2wire_String(value); - return _platform.executeSync(FlutterRustBridgeSyncTask( - callFfi: () => _platform.inner.wire_set__method__NativePreferenceStore(arg0, arg1, arg2), - parseSuccessData: _wire2api_unit, - constMeta: kSetMethodNativePreferenceStoreConstMeta, - argValues: [that, key, value], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kSetMethodNativePreferenceStoreConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "set__method__NativePreferenceStore", - argNames: ["that", "key", "value"], - ); - - void removeMethodNativePreferenceStore({required NativePreferenceStore that, required String key, dynamic hint}) { - var arg0 = _platform.api2wire_box_autoadd_native_preference_store(that); - var arg1 = _platform.api2wire_String(key); - return _platform.executeSync(FlutterRustBridgeSyncTask( - callFfi: () => _platform.inner.wire_remove__method__NativePreferenceStore(arg0, arg1), - parseSuccessData: _wire2api_unit, - constMeta: kRemoveMethodNativePreferenceStoreConstMeta, - argValues: [that, key], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kRemoveMethodNativePreferenceStoreConstMeta => - const FlutterRustBridgeTaskConstMeta( - debugName: "remove__method__NativePreferenceStore", - argNames: ["that", "key"], - ); - - void removePrefixMethodNativePreferenceStore( - {required NativePreferenceStore that, required String prefix, dynamic hint}) { - var arg0 = _platform.api2wire_box_autoadd_native_preference_store(that); - var arg1 = _platform.api2wire_String(prefix); - return _platform.executeSync(FlutterRustBridgeSyncTask( - callFfi: () => _platform.inner.wire_remove_prefix__method__NativePreferenceStore(arg0, arg1), - parseSuccessData: _wire2api_unit, - constMeta: kRemovePrefixMethodNativePreferenceStoreConstMeta, - argValues: [that, prefix], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kRemovePrefixMethodNativePreferenceStoreConstMeta => - const FlutterRustBridgeTaskConstMeta( - debugName: "remove_prefix__method__NativePreferenceStore", - argNames: ["that", "prefix"], - ); - - DropFnType get dropOpaqueMutexDummy1Connection => _platform.inner.drop_opaque_MutexDummy1Connection; - ShareFnType get shareOpaqueMutexDummy1Connection => _platform.inner.share_opaque_MutexDummy1Connection; - OpaqueTypeFinalizer get MutexDummy1ConnectionFinalizer => _platform.MutexDummy1ConnectionFinalizer; - - void dispose() { - _platform.dispose(); - } -// Section: wire2api - - MutexDummy1Connection _wire2api_MutexDummy1Connection(dynamic raw) { - return MutexDummy1Connection.fromRaw(raw[0], raw[1], this); - } - - String _wire2api_String(dynamic raw) { - return raw as String; - } - - NativePreferenceStore _wire2api_native_preference_store(dynamic raw) { - final arr = raw as List; - if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); - return NativePreferenceStore( - bridge: this, - conn: _wire2api_MutexDummy1Connection(arr[0]), - ); - } - - String? _wire2api_opt_String(dynamic raw) { - return raw == null ? null : _wire2api_String(raw); - } - - int _wire2api_u8(dynamic raw) { - return raw as int; - } - - Uint8List _wire2api_uint_8_list(dynamic raw) { - return raw as Uint8List; - } - - void _wire2api_unit(dynamic raw) { - return; - } -} - -// Section: api2wire - -@protected -int api2wire_u8(int raw) { - return raw; -} - -// Section: finalizer - -class ApiPreferenceStorePlatform extends FlutterRustBridgeBase { - ApiPreferenceStorePlatform(ffi.DynamicLibrary dylib) : super(ApiPreferenceStoreWire(dylib)); - -// Section: api2wire - - @protected - wire_MutexDummy1Connection api2wire_MutexDummy1Connection(MutexDummy1Connection raw) { - final ptr = inner.new_MutexDummy1Connection(); - _api_fill_to_wire_MutexDummy1Connection(raw, ptr); - return ptr; - } - - @protected - ffi.Pointer api2wire_String(String raw) { - return api2wire_uint_8_list(utf8.encoder.convert(raw)); - } - - @protected - ffi.Pointer api2wire_box_autoadd_native_preference_store(NativePreferenceStore raw) { - final ptr = inner.new_box_autoadd_native_preference_store_1(); - _api_fill_to_wire_native_preference_store(raw, ptr.ref); - return ptr; - } - - @protected - ffi.Pointer api2wire_uint_8_list(Uint8List raw) { - final ans = inner.new_uint_8_list_1(raw.length); - ans.ref.ptr.asTypedList(raw.length).setAll(0, raw); - return ans; - } -// Section: finalizer - - late final OpaqueTypeFinalizer _MutexDummy1ConnectionFinalizer = - OpaqueTypeFinalizer(inner._drop_opaque_MutexDummy1ConnectionPtr); - OpaqueTypeFinalizer get MutexDummy1ConnectionFinalizer => _MutexDummy1ConnectionFinalizer; -// Section: api_fill_to_wire - - void _api_fill_to_wire_MutexDummy1Connection(MutexDummy1Connection apiObj, wire_MutexDummy1Connection wireObj) { - wireObj.ptr = apiObj.shareOrMove(); - } - - void _api_fill_to_wire_box_autoadd_native_preference_store( - NativePreferenceStore apiObj, ffi.Pointer wireObj) { - _api_fill_to_wire_native_preference_store(apiObj, wireObj.ref); - } - - void _api_fill_to_wire_native_preference_store(NativePreferenceStore apiObj, wire_NativePreferenceStore wireObj) { - wireObj.conn = api2wire_MutexDummy1Connection(apiObj.conn); - } -} - -// ignore_for_file: camel_case_types, non_constant_identifier_names, avoid_positional_boolean_parameters, annotate_overrides, constant_identifier_names - -// AUTO GENERATED FILE, DO NOT EDIT. -// -// Generated by `package:ffigen`. -// ignore_for_file: type=lint - -/// generated by flutter_rust_bridge -class ApiPreferenceStoreWire implements FlutterRustBridgeWireBase { - @internal - late final dartApi = DartApiDl(init_frb_dart_api_dl); - - /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) _lookup; - - /// The symbols are looked up in [dynamicLibrary]. - ApiPreferenceStoreWire(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; - - /// The symbols are looked up with [lookup]. - ApiPreferenceStoreWire.fromLookup(ffi.Pointer Function(String symbolName) lookup) - : _lookup = lookup; - - void store_dart_post_cobject( - DartPostCObjectFnType ptr, - ) { - return _store_dart_post_cobject( - ptr, - ); - } - - late final _store_dart_post_cobjectPtr = - _lookup>('store_dart_post_cobject'); - late final _store_dart_post_cobject = _store_dart_post_cobjectPtr.asFunction(); - - Object get_dart_object( - int ptr, - ) { - return _get_dart_object( - ptr, - ); - } - - late final _get_dart_objectPtr = _lookup>('get_dart_object'); - late final _get_dart_object = _get_dart_objectPtr.asFunction(); - - void drop_dart_object( - int ptr, - ) { - return _drop_dart_object( - ptr, - ); - } - - late final _drop_dart_objectPtr = _lookup>('drop_dart_object'); - late final _drop_dart_object = _drop_dart_objectPtr.asFunction(); - - int new_dart_opaque( - Object handle, - ) { - return _new_dart_opaque( - handle, - ); - } - - late final _new_dart_opaquePtr = _lookup>('new_dart_opaque'); - late final _new_dart_opaque = _new_dart_opaquePtr.asFunction(); - - int init_frb_dart_api_dl( - ffi.Pointer obj, - ) { - return _init_frb_dart_api_dl( - obj, - ); - } - - late final _init_frb_dart_api_dlPtr = - _lookup)>>('init_frb_dart_api_dl'); - late final _init_frb_dart_api_dl = _init_frb_dart_api_dlPtr.asFunction)>(); - - WireSyncReturn wire_new__static_method__NativePreferenceStore( - ffi.Pointer root, - ) { - return _wire_new__static_method__NativePreferenceStore( - root, - ); - } - - late final _wire_new__static_method__NativePreferenceStorePtr = - _lookup)>>( - 'wire_new__static_method__NativePreferenceStore'); - late final _wire_new__static_method__NativePreferenceStore = _wire_new__static_method__NativePreferenceStorePtr - .asFunction)>(); - - WireSyncReturn wire_get__method__NativePreferenceStore( - ffi.Pointer that, - ffi.Pointer key, - ) { - return _wire_get__method__NativePreferenceStore( - that, - key, - ); - } - - late final _wire_get__method__NativePreferenceStorePtr = _lookup< - ffi.NativeFunction< - WireSyncReturn Function(ffi.Pointer, - ffi.Pointer)>>('wire_get__method__NativePreferenceStore'); - late final _wire_get__method__NativePreferenceStore = _wire_get__method__NativePreferenceStorePtr - .asFunction, ffi.Pointer)>(); - - WireSyncReturn wire_set__method__NativePreferenceStore( - ffi.Pointer that, - ffi.Pointer key, - ffi.Pointer value, - ) { - return _wire_set__method__NativePreferenceStore( - that, - key, - value, - ); - } - - late final _wire_set__method__NativePreferenceStorePtr = _lookup< - ffi.NativeFunction< - WireSyncReturn Function(ffi.Pointer, ffi.Pointer, - ffi.Pointer)>>('wire_set__method__NativePreferenceStore'); - late final _wire_set__method__NativePreferenceStore = _wire_set__method__NativePreferenceStorePtr.asFunction< - WireSyncReturn Function( - ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); - - WireSyncReturn wire_remove__method__NativePreferenceStore( - ffi.Pointer that, - ffi.Pointer key, - ) { - return _wire_remove__method__NativePreferenceStore( - that, - key, - ); - } - - late final _wire_remove__method__NativePreferenceStorePtr = _lookup< - ffi.NativeFunction< - WireSyncReturn Function(ffi.Pointer, - ffi.Pointer)>>('wire_remove__method__NativePreferenceStore'); - late final _wire_remove__method__NativePreferenceStore = _wire_remove__method__NativePreferenceStorePtr - .asFunction, ffi.Pointer)>(); - - WireSyncReturn wire_remove_prefix__method__NativePreferenceStore( - ffi.Pointer that, - ffi.Pointer prefix, - ) { - return _wire_remove_prefix__method__NativePreferenceStore( - that, - prefix, - ); - } - - late final _wire_remove_prefix__method__NativePreferenceStorePtr = _lookup< - ffi.NativeFunction< - WireSyncReturn Function(ffi.Pointer, - ffi.Pointer)>>('wire_remove_prefix__method__NativePreferenceStore'); - late final _wire_remove_prefix__method__NativePreferenceStore = _wire_remove_prefix__method__NativePreferenceStorePtr - .asFunction, ffi.Pointer)>(); - - wire_MutexDummy1Connection new_MutexDummy1Connection() { - return _new_MutexDummy1Connection(); - } - - late final _new_MutexDummy1ConnectionPtr = - _lookup>('new_MutexDummy1Connection'); - late final _new_MutexDummy1Connection = - _new_MutexDummy1ConnectionPtr.asFunction(); - - ffi.Pointer new_box_autoadd_native_preference_store_1() { - return _new_box_autoadd_native_preference_store_1(); - } - - late final _new_box_autoadd_native_preference_store_1Ptr = - _lookup Function()>>( - 'new_box_autoadd_native_preference_store_1'); - late final _new_box_autoadd_native_preference_store_1 = - _new_box_autoadd_native_preference_store_1Ptr.asFunction Function()>(); - - ffi.Pointer new_uint_8_list_1( - int len, - ) { - return _new_uint_8_list_1( - len, - ); - } - - late final _new_uint_8_list_1Ptr = - _lookup Function(ffi.Int32)>>('new_uint_8_list_1'); - late final _new_uint_8_list_1 = _new_uint_8_list_1Ptr.asFunction Function(int)>(); - - void drop_opaque_MutexDummy1Connection( - ffi.Pointer ptr, - ) { - return _drop_opaque_MutexDummy1Connection( - ptr, - ); - } - - late final _drop_opaque_MutexDummy1ConnectionPtr = - _lookup)>>('drop_opaque_MutexDummy1Connection'); - late final _drop_opaque_MutexDummy1Connection = - _drop_opaque_MutexDummy1ConnectionPtr.asFunction)>(); - - ffi.Pointer share_opaque_MutexDummy1Connection( - ffi.Pointer ptr, - ) { - return _share_opaque_MutexDummy1Connection( - ptr, - ); - } - - late final _share_opaque_MutexDummy1ConnectionPtr = - _lookup Function(ffi.Pointer)>>( - 'share_opaque_MutexDummy1Connection'); - late final _share_opaque_MutexDummy1Connection = - _share_opaque_MutexDummy1ConnectionPtr.asFunction Function(ffi.Pointer)>(); - - ffi.Pointer new_box_autoadd_local_db_0() { - return _new_box_autoadd_local_db_0(); - } - - late final _new_box_autoadd_local_db_0Ptr = - _lookup Function()>>('new_box_autoadd_local_db_0'); - late final _new_box_autoadd_local_db_0 = - _new_box_autoadd_local_db_0Ptr.asFunction Function()>(); - - void free_WireSyncReturn( - WireSyncReturn ptr, - ) { - return _free_WireSyncReturn( - ptr, - ); - } - - late final _free_WireSyncReturnPtr = - _lookup>('free_WireSyncReturn'); - late final _free_WireSyncReturn = _free_WireSyncReturnPtr.asFunction(); - - ffi.Pointer new_box_autoadd_local_store_2() { - return _new_box_autoadd_local_store_2(); - } - - late final _new_box_autoadd_local_store_2Ptr = - _lookup Function()>>('new_box_autoadd_local_store_2'); - late final _new_box_autoadd_local_store_2 = - _new_box_autoadd_local_store_2Ptr.asFunction Function()>(); -} - -final class _Dart_Handle extends ffi.Opaque {} - -final class wire_uint_8_list extends ffi.Struct { - external ffi.Pointer ptr; - - @ffi.Int32() - external int len; -} - -final class wire_MutexDummy1Connection extends ffi.Struct { - external ffi.Pointer ptr; -} - -final class wire_NativePreferenceStore extends ffi.Struct { - external wire_MutexDummy1Connection conn; -} - -final class wire_MutexRepoDatabaseRead extends ffi.Struct { - external ffi.Pointer ptr; -} - -final class wire_LocalDb extends ffi.Struct { - external wire_MutexRepoDatabaseRead repo; -} - -final class wire_MutexConnection extends ffi.Struct { - external ffi.Pointer ptr; -} - -final class wire_LocalStore extends ffi.Struct { - external wire_MutexConnection conn; -} - -typedef DartPostCObjectFnType - = ffi.Pointer message)>>; -typedef DartPort = ffi.Int64; diff --git a/lib/bridge/generated_repo.dart b/lib/bridge/generated_repo.dart deleted file mode 100644 index f45cb426..00000000 --- a/lib/bridge/generated_repo.dart +++ /dev/null @@ -1,568 +0,0 @@ -// AUTO GENERATED FILE, DO NOT EDIT. -// Generated by `flutter_rust_bridge`@ 1.81.0. -// ignore_for_file: non_constant_identifier_names, unused_element, duplicate_ignore, directives_ordering, curly_braces_in_flow_control_structures, unnecessary_lambdas, slash_for_doc_comments, prefer_const_literals_to_create_immutables, implicit_dynamic_list_literal, duplicate_import, unused_import, unnecessary_import, prefer_single_quotes, prefer_const_constructors, use_super_parameters, always_use_package_imports, annotate_overrides, invalid_use_of_protected_member, constant_identifier_names, invalid_use_of_internal_member, prefer_is_empty, unnecessary_const - -import 'dart:convert'; -import 'dart:async'; -import 'package:meta/meta.dart'; -import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; -import 'package:uuid/uuid.dart'; - -import 'dart:ffi' as ffi; - -abstract class ApiRepository { - Future newStaticMethodLocalDb({required String path, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kNewStaticMethodLocalDbConstMeta; - - Future getAlbumMethodLocalDb({required LocalDb that, required UuidValue albumId, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kGetAlbumMethodLocalDbConstMeta; - - Future> getAlbumsByTagMethodLocalDb( - {required LocalDb that, required String tag, required bool recursive, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kGetAlbumsByTagMethodLocalDbConstMeta; - - Future> getTagsMethodLocalDb({required LocalDb that, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kGetTagsMethodLocalDbConstMeta; - - DropFnType get dropOpaqueMutexRepoDatabaseRead; - ShareFnType get shareOpaqueMutexRepoDatabaseRead; - OpaqueTypeFinalizer get MutexRepoDatabaseReadFinalizer; -} - -@sealed -class MutexRepoDatabaseRead extends FrbOpaque { - final ApiRepository bridge; - MutexRepoDatabaseRead.fromRaw(int ptr, int size, this.bridge) : super.unsafe(ptr, size); - @override - DropFnType get dropFn => bridge.dropOpaqueMutexRepoDatabaseRead; - - @override - ShareFnType get shareFn => bridge.shareOpaqueMutexRepoDatabaseRead; - - @override - OpaqueTypeFinalizer get staticFinalizer => bridge.MutexRepoDatabaseReadFinalizer; -} - -class LocalDb { - final ApiRepository bridge; - final MutexRepoDatabaseRead repo; - - const LocalDb({ - required this.bridge, - required this.repo, - }); - - static Future newLocalDb({required ApiRepository bridge, required String path, dynamic hint}) => - bridge.newStaticMethodLocalDb(path: path, hint: hint); - - Future getAlbum({required UuidValue albumId, dynamic hint}) => bridge.getAlbumMethodLocalDb( - that: this, - albumId: albumId, - ); - - Future> getAlbumsByTag({required String tag, required bool recursive, dynamic hint}) => - bridge.getAlbumsByTagMethodLocalDb( - that: this, - tag: tag, - recursive: recursive, - ); - - Future> getTags({dynamic hint}) => bridge.getTagsMethodLocalDb( - that: this, - ); -} - -class TagItem { - final String name; - final List children; - - const TagItem({ - required this.name, - required this.children, - }); -} - -class ApiRepositoryImpl implements ApiRepository { - final ApiRepositoryPlatform _platform; - factory ApiRepositoryImpl(ExternalLibrary dylib) => ApiRepositoryImpl.raw(ApiRepositoryPlatform(dylib)); - - /// Only valid on web/WASM platforms. - factory ApiRepositoryImpl.wasm(FutureOr module) => ApiRepositoryImpl(module as ExternalLibrary); - ApiRepositoryImpl.raw(this._platform); - Future newStaticMethodLocalDb({required String path, dynamic hint}) { - var arg0 = _platform.api2wire_String(path); - return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_new__static_method__LocalDb(port_, arg0), - parseSuccessData: (d) => _wire2api_local_db(d), - constMeta: kNewStaticMethodLocalDbConstMeta, - argValues: [path], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kNewStaticMethodLocalDbConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "new__static_method__LocalDb", - argNames: ["path"], - ); - - Future getAlbumMethodLocalDb({required LocalDb that, required UuidValue albumId, dynamic hint}) { - var arg0 = _platform.api2wire_box_autoadd_local_db(that); - var arg1 = _platform.api2wire_Uuid(albumId); - return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_get_album__method__LocalDb(port_, arg0, arg1), - parseSuccessData: _wire2api_opt_String, - constMeta: kGetAlbumMethodLocalDbConstMeta, - argValues: [that, albumId], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kGetAlbumMethodLocalDbConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "get_album__method__LocalDb", - argNames: ["that", "albumId"], - ); - - Future> getAlbumsByTagMethodLocalDb( - {required LocalDb that, required String tag, required bool recursive, dynamic hint}) { - var arg0 = _platform.api2wire_box_autoadd_local_db(that); - var arg1 = _platform.api2wire_String(tag); - var arg2 = recursive; - return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_get_albums_by_tag__method__LocalDb(port_, arg0, arg1, arg2), - parseSuccessData: _wire2api_Uuids, - constMeta: kGetAlbumsByTagMethodLocalDbConstMeta, - argValues: [that, tag, recursive], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kGetAlbumsByTagMethodLocalDbConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "get_albums_by_tag__method__LocalDb", - argNames: ["that", "tag", "recursive"], - ); - - Future> getTagsMethodLocalDb({required LocalDb that, dynamic hint}) { - var arg0 = _platform.api2wire_box_autoadd_local_db(that); - return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_get_tags__method__LocalDb(port_, arg0), - parseSuccessData: _wire2api_list_tag_item, - constMeta: kGetTagsMethodLocalDbConstMeta, - argValues: [that], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kGetTagsMethodLocalDbConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "get_tags__method__LocalDb", - argNames: ["that"], - ); - - DropFnType get dropOpaqueMutexRepoDatabaseRead => _platform.inner.drop_opaque_MutexRepoDatabaseRead; - ShareFnType get shareOpaqueMutexRepoDatabaseRead => _platform.inner.share_opaque_MutexRepoDatabaseRead; - OpaqueTypeFinalizer get MutexRepoDatabaseReadFinalizer => _platform.MutexRepoDatabaseReadFinalizer; - - void dispose() { - _platform.dispose(); - } -// Section: wire2api - - MutexRepoDatabaseRead _wire2api_MutexRepoDatabaseRead(dynamic raw) { - return MutexRepoDatabaseRead.fromRaw(raw[0], raw[1], this); - } - - String _wire2api_String(dynamic raw) { - return raw as String; - } - - List _wire2api_StringList(dynamic raw) { - return (raw as List).cast(); - } - - List _wire2api_Uuids(dynamic raw) { - final bytes = _wire2api_uint_8_list(raw); - return wire2apiUuids(bytes); - } - - List _wire2api_list_tag_item(dynamic raw) { - return (raw as List).map(_wire2api_tag_item).toList(); - } - - LocalDb _wire2api_local_db(dynamic raw) { - final arr = raw as List; - if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); - return LocalDb( - bridge: this, - repo: _wire2api_MutexRepoDatabaseRead(arr[0]), - ); - } - - String? _wire2api_opt_String(dynamic raw) { - return raw == null ? null : _wire2api_String(raw); - } - - TagItem _wire2api_tag_item(dynamic raw) { - final arr = raw as List; - if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); - return TagItem( - name: _wire2api_String(arr[0]), - children: _wire2api_StringList(arr[1]), - ); - } - - int _wire2api_u8(dynamic raw) { - return raw as int; - } - - Uint8List _wire2api_uint_8_list(dynamic raw) { - return raw as Uint8List; - } -} - -// Section: api2wire - -@protected -bool api2wire_bool(bool raw) { - return raw; -} - -@protected -int api2wire_u8(int raw) { - return raw; -} - -// Section: finalizer - -class ApiRepositoryPlatform extends FlutterRustBridgeBase { - ApiRepositoryPlatform(ffi.DynamicLibrary dylib) : super(ApiRepositoryWire(dylib)); - -// Section: api2wire - - @protected - wire_MutexRepoDatabaseRead api2wire_MutexRepoDatabaseRead(MutexRepoDatabaseRead raw) { - final ptr = inner.new_MutexRepoDatabaseRead(); - _api_fill_to_wire_MutexRepoDatabaseRead(raw, ptr); - return ptr; - } - - @protected - ffi.Pointer api2wire_String(String raw) { - return api2wire_uint_8_list(utf8.encoder.convert(raw)); - } - - @protected - ffi.Pointer api2wire_Uuid(UuidValue raw) { - return api2wire_uint_8_list(raw.toBytes()); - } - - @protected - ffi.Pointer api2wire_box_autoadd_local_db(LocalDb raw) { - final ptr = inner.new_box_autoadd_local_db_0(); - _api_fill_to_wire_local_db(raw, ptr.ref); - return ptr; - } - - @protected - ffi.Pointer api2wire_uint_8_list(Uint8List raw) { - final ans = inner.new_uint_8_list_0(raw.length); - ans.ref.ptr.asTypedList(raw.length).setAll(0, raw); - return ans; - } -// Section: finalizer - - late final OpaqueTypeFinalizer _MutexRepoDatabaseReadFinalizer = - OpaqueTypeFinalizer(inner._drop_opaque_MutexRepoDatabaseReadPtr); - OpaqueTypeFinalizer get MutexRepoDatabaseReadFinalizer => _MutexRepoDatabaseReadFinalizer; -// Section: api_fill_to_wire - - void _api_fill_to_wire_MutexRepoDatabaseRead(MutexRepoDatabaseRead apiObj, wire_MutexRepoDatabaseRead wireObj) { - wireObj.ptr = apiObj.shareOrMove(); - } - - void _api_fill_to_wire_box_autoadd_local_db(LocalDb apiObj, ffi.Pointer wireObj) { - _api_fill_to_wire_local_db(apiObj, wireObj.ref); - } - - void _api_fill_to_wire_local_db(LocalDb apiObj, wire_LocalDb wireObj) { - wireObj.repo = api2wire_MutexRepoDatabaseRead(apiObj.repo); - } -} - -// ignore_for_file: camel_case_types, non_constant_identifier_names, avoid_positional_boolean_parameters, annotate_overrides, constant_identifier_names - -// AUTO GENERATED FILE, DO NOT EDIT. -// -// Generated by `package:ffigen`. -// ignore_for_file: type=lint - -/// generated by flutter_rust_bridge -class ApiRepositoryWire implements FlutterRustBridgeWireBase { - @internal - late final dartApi = DartApiDl(init_frb_dart_api_dl); - - /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) _lookup; - - /// The symbols are looked up in [dynamicLibrary]. - ApiRepositoryWire(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; - - /// The symbols are looked up with [lookup]. - ApiRepositoryWire.fromLookup(ffi.Pointer Function(String symbolName) lookup) - : _lookup = lookup; - - ffi.Pointer new_box_autoadd_native_preference_store_1() { - return _new_box_autoadd_native_preference_store_1(); - } - - late final _new_box_autoadd_native_preference_store_1Ptr = - _lookup Function()>>( - 'new_box_autoadd_native_preference_store_1'); - late final _new_box_autoadd_native_preference_store_1 = - _new_box_autoadd_native_preference_store_1Ptr.asFunction Function()>(); - - void store_dart_post_cobject( - DartPostCObjectFnType ptr, - ) { - return _store_dart_post_cobject( - ptr, - ); - } - - late final _store_dart_post_cobjectPtr = - _lookup>('store_dart_post_cobject'); - late final _store_dart_post_cobject = _store_dart_post_cobjectPtr.asFunction(); - - Object get_dart_object( - int ptr, - ) { - return _get_dart_object( - ptr, - ); - } - - late final _get_dart_objectPtr = _lookup>('get_dart_object'); - late final _get_dart_object = _get_dart_objectPtr.asFunction(); - - void drop_dart_object( - int ptr, - ) { - return _drop_dart_object( - ptr, - ); - } - - late final _drop_dart_objectPtr = _lookup>('drop_dart_object'); - late final _drop_dart_object = _drop_dart_objectPtr.asFunction(); - - int new_dart_opaque( - Object handle, - ) { - return _new_dart_opaque( - handle, - ); - } - - late final _new_dart_opaquePtr = _lookup>('new_dart_opaque'); - late final _new_dart_opaque = _new_dart_opaquePtr.asFunction(); - - int init_frb_dart_api_dl( - ffi.Pointer obj, - ) { - return _init_frb_dart_api_dl( - obj, - ); - } - - late final _init_frb_dart_api_dlPtr = - _lookup)>>('init_frb_dart_api_dl'); - late final _init_frb_dart_api_dl = _init_frb_dart_api_dlPtr.asFunction)>(); - - void wire_new__static_method__LocalDb( - int port_, - ffi.Pointer path, - ) { - return _wire_new__static_method__LocalDb( - port_, - path, - ); - } - - late final _wire_new__static_method__LocalDbPtr = - _lookup)>>( - 'wire_new__static_method__LocalDb'); - late final _wire_new__static_method__LocalDb = - _wire_new__static_method__LocalDbPtr.asFunction)>(); - - void wire_get_album__method__LocalDb( - int port_, - ffi.Pointer that, - ffi.Pointer album_id, - ) { - return _wire_get_album__method__LocalDb( - port_, - that, - album_id, - ); - } - - late final _wire_get_album__method__LocalDbPtr = _lookup< - ffi.NativeFunction, ffi.Pointer)>>( - 'wire_get_album__method__LocalDb'); - late final _wire_get_album__method__LocalDb = _wire_get_album__method__LocalDbPtr - .asFunction, ffi.Pointer)>(); - - void wire_get_albums_by_tag__method__LocalDb( - int port_, - ffi.Pointer that, - ffi.Pointer tag, - bool recursive, - ) { - return _wire_get_albums_by_tag__method__LocalDb( - port_, - that, - tag, - recursive, - ); - } - - late final _wire_get_albums_by_tag__method__LocalDbPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Int64, ffi.Pointer, ffi.Pointer, - ffi.Bool)>>('wire_get_albums_by_tag__method__LocalDb'); - late final _wire_get_albums_by_tag__method__LocalDb = _wire_get_albums_by_tag__method__LocalDbPtr - .asFunction, ffi.Pointer, bool)>(); - - void wire_get_tags__method__LocalDb( - int port_, - ffi.Pointer that, - ) { - return _wire_get_tags__method__LocalDb( - port_, - that, - ); - } - - late final _wire_get_tags__method__LocalDbPtr = - _lookup)>>( - 'wire_get_tags__method__LocalDb'); - late final _wire_get_tags__method__LocalDb = - _wire_get_tags__method__LocalDbPtr.asFunction)>(); - - wire_MutexRepoDatabaseRead new_MutexRepoDatabaseRead() { - return _new_MutexRepoDatabaseRead(); - } - - late final _new_MutexRepoDatabaseReadPtr = - _lookup>('new_MutexRepoDatabaseRead'); - late final _new_MutexRepoDatabaseRead = - _new_MutexRepoDatabaseReadPtr.asFunction(); - - ffi.Pointer new_box_autoadd_local_db_0() { - return _new_box_autoadd_local_db_0(); - } - - late final _new_box_autoadd_local_db_0Ptr = - _lookup Function()>>('new_box_autoadd_local_db_0'); - late final _new_box_autoadd_local_db_0 = - _new_box_autoadd_local_db_0Ptr.asFunction Function()>(); - - ffi.Pointer new_uint_8_list_0( - int len, - ) { - return _new_uint_8_list_0( - len, - ); - } - - late final _new_uint_8_list_0Ptr = - _lookup Function(ffi.Int32)>>('new_uint_8_list_0'); - late final _new_uint_8_list_0 = _new_uint_8_list_0Ptr.asFunction Function(int)>(); - - void drop_opaque_MutexRepoDatabaseRead( - ffi.Pointer ptr, - ) { - return _drop_opaque_MutexRepoDatabaseRead( - ptr, - ); - } - - late final _drop_opaque_MutexRepoDatabaseReadPtr = - _lookup)>>('drop_opaque_MutexRepoDatabaseRead'); - late final _drop_opaque_MutexRepoDatabaseRead = - _drop_opaque_MutexRepoDatabaseReadPtr.asFunction)>(); - - ffi.Pointer share_opaque_MutexRepoDatabaseRead( - ffi.Pointer ptr, - ) { - return _share_opaque_MutexRepoDatabaseRead( - ptr, - ); - } - - late final _share_opaque_MutexRepoDatabaseReadPtr = - _lookup Function(ffi.Pointer)>>( - 'share_opaque_MutexRepoDatabaseRead'); - late final _share_opaque_MutexRepoDatabaseRead = - _share_opaque_MutexRepoDatabaseReadPtr.asFunction Function(ffi.Pointer)>(); - - void free_WireSyncReturn( - WireSyncReturn ptr, - ) { - return _free_WireSyncReturn( - ptr, - ); - } - - late final _free_WireSyncReturnPtr = - _lookup>('free_WireSyncReturn'); - late final _free_WireSyncReturn = _free_WireSyncReturnPtr.asFunction(); - - ffi.Pointer new_box_autoadd_local_store_2() { - return _new_box_autoadd_local_store_2(); - } - - late final _new_box_autoadd_local_store_2Ptr = - _lookup Function()>>('new_box_autoadd_local_store_2'); - late final _new_box_autoadd_local_store_2 = - _new_box_autoadd_local_store_2Ptr.asFunction Function()>(); -} - -final class _Dart_Handle extends ffi.Opaque {} - -final class wire_MutexDummy1Connection extends ffi.Struct { - external ffi.Pointer ptr; -} - -final class wire_NativePreferenceStore extends ffi.Struct { - external wire_MutexDummy1Connection conn; -} - -final class wire_uint_8_list extends ffi.Struct { - external ffi.Pointer ptr; - - @ffi.Int32() - external int len; -} - -final class wire_MutexRepoDatabaseRead extends ffi.Struct { - external ffi.Pointer ptr; -} - -final class wire_LocalDb extends ffi.Struct { - external wire_MutexRepoDatabaseRead repo; -} - -final class wire_MutexConnection extends ffi.Struct { - external ffi.Pointer ptr; -} - -final class wire_LocalStore extends ffi.Struct { - external wire_MutexConnection conn; -} - -typedef DartPostCObjectFnType - = ffi.Pointer message)>>; -typedef DartPort = ffi.Int64; diff --git a/lib/bridge/generated_store.dart b/lib/bridge/generated_store.dart deleted file mode 100644 index c9762d26..00000000 --- a/lib/bridge/generated_store.dart +++ /dev/null @@ -1,548 +0,0 @@ -// AUTO GENERATED FILE, DO NOT EDIT. -// Generated by `flutter_rust_bridge`@ 1.81.0. -// ignore_for_file: non_constant_identifier_names, unused_element, duplicate_ignore, directives_ordering, curly_braces_in_flow_control_structures, unnecessary_lambdas, slash_for_doc_comments, prefer_const_literals_to_create_immutables, implicit_dynamic_list_literal, duplicate_import, unused_import, unnecessary_import, prefer_single_quotes, prefer_const_constructors, use_super_parameters, always_use_package_imports, annotate_overrides, invalid_use_of_protected_member, constant_identifier_names, invalid_use_of_internal_member, prefer_is_empty, unnecessary_const - -import 'dart:convert'; -import 'dart:async'; -import 'package:meta/meta.dart'; -import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; -import 'package:uuid/uuid.dart'; - -import 'dart:ffi' as ffi; - -abstract class ApiStore { - LocalStore newStaticMethodLocalStore({required String root, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kNewStaticMethodLocalStoreConstMeta; - - Future insertMethodLocalStore( - {required LocalStore that, required String category, required String key, required String value, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kInsertMethodLocalStoreConstMeta; - - Future getMethodLocalStore( - {required LocalStore that, required String category, required String key, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kGetMethodLocalStoreConstMeta; - - Future clearMethodLocalStore({required LocalStore that, String? category, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kClearMethodLocalStoreConstMeta; - - DropFnType get dropOpaqueMutexConnection; - ShareFnType get shareOpaqueMutexConnection; - OpaqueTypeFinalizer get MutexConnectionFinalizer; -} - -@sealed -class MutexConnection extends FrbOpaque { - final ApiStore bridge; - MutexConnection.fromRaw(int ptr, int size, this.bridge) : super.unsafe(ptr, size); - @override - DropFnType get dropFn => bridge.dropOpaqueMutexConnection; - - @override - ShareFnType get shareFn => bridge.shareOpaqueMutexConnection; - - @override - OpaqueTypeFinalizer get staticFinalizer => bridge.MutexConnectionFinalizer; -} - -class LocalStore { - final ApiStore bridge; - final MutexConnection conn; - - const LocalStore({ - required this.bridge, - required this.conn, - }); - - static LocalStore newLocalStore({required ApiStore bridge, required String root, dynamic hint}) => - bridge.newStaticMethodLocalStore(root: root, hint: hint); - - Future insert({required String category, required String key, required String value, dynamic hint}) => - bridge.insertMethodLocalStore( - that: this, - category: category, - key: key, - value: value, - ); - - Future get({required String category, required String key, dynamic hint}) => bridge.getMethodLocalStore( - that: this, - category: category, - key: key, - ); - - Future clear({String? category, dynamic hint}) => bridge.clearMethodLocalStore( - that: this, - category: category, - ); -} - -class ApiStoreImpl implements ApiStore { - final ApiStorePlatform _platform; - factory ApiStoreImpl(ExternalLibrary dylib) => ApiStoreImpl.raw(ApiStorePlatform(dylib)); - - /// Only valid on web/WASM platforms. - factory ApiStoreImpl.wasm(FutureOr module) => ApiStoreImpl(module as ExternalLibrary); - ApiStoreImpl.raw(this._platform); - LocalStore newStaticMethodLocalStore({required String root, dynamic hint}) { - var arg0 = _platform.api2wire_String(root); - return _platform.executeSync(FlutterRustBridgeSyncTask( - callFfi: () => _platform.inner.wire_new__static_method__LocalStore(arg0), - parseSuccessData: _wire2api_local_store, - constMeta: kNewStaticMethodLocalStoreConstMeta, - argValues: [root], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kNewStaticMethodLocalStoreConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "new__static_method__LocalStore", - argNames: ["root"], - ); - - Future insertMethodLocalStore( - {required LocalStore that, required String category, required String key, required String value, dynamic hint}) { - var arg0 = _platform.api2wire_box_autoadd_local_store(that); - var arg1 = _platform.api2wire_String(category); - var arg2 = _platform.api2wire_String(key); - var arg3 = _platform.api2wire_String(value); - return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_insert__method__LocalStore(port_, arg0, arg1, arg2, arg3), - parseSuccessData: _wire2api_unit, - constMeta: kInsertMethodLocalStoreConstMeta, - argValues: [that, category, key, value], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kInsertMethodLocalStoreConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "insert__method__LocalStore", - argNames: ["that", "category", "key", "value"], - ); - - Future getMethodLocalStore( - {required LocalStore that, required String category, required String key, dynamic hint}) { - var arg0 = _platform.api2wire_box_autoadd_local_store(that); - var arg1 = _platform.api2wire_String(category); - var arg2 = _platform.api2wire_String(key); - return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_get__method__LocalStore(port_, arg0, arg1, arg2), - parseSuccessData: _wire2api_opt_String, - constMeta: kGetMethodLocalStoreConstMeta, - argValues: [that, category, key], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kGetMethodLocalStoreConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "get__method__LocalStore", - argNames: ["that", "category", "key"], - ); - - Future clearMethodLocalStore({required LocalStore that, String? category, dynamic hint}) { - var arg0 = _platform.api2wire_box_autoadd_local_store(that); - var arg1 = _platform.api2wire_opt_String(category); - return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_clear__method__LocalStore(port_, arg0, arg1), - parseSuccessData: _wire2api_unit, - constMeta: kClearMethodLocalStoreConstMeta, - argValues: [that, category], - hint: hint, - )); - } - - FlutterRustBridgeTaskConstMeta get kClearMethodLocalStoreConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "clear__method__LocalStore", - argNames: ["that", "category"], - ); - - DropFnType get dropOpaqueMutexConnection => _platform.inner.drop_opaque_MutexConnection; - ShareFnType get shareOpaqueMutexConnection => _platform.inner.share_opaque_MutexConnection; - OpaqueTypeFinalizer get MutexConnectionFinalizer => _platform.MutexConnectionFinalizer; - - void dispose() { - _platform.dispose(); - } -// Section: wire2api - - MutexConnection _wire2api_MutexConnection(dynamic raw) { - return MutexConnection.fromRaw(raw[0], raw[1], this); - } - - String _wire2api_String(dynamic raw) { - return raw as String; - } - - LocalStore _wire2api_local_store(dynamic raw) { - final arr = raw as List; - if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); - return LocalStore( - bridge: this, - conn: _wire2api_MutexConnection(arr[0]), - ); - } - - String? _wire2api_opt_String(dynamic raw) { - return raw == null ? null : _wire2api_String(raw); - } - - int _wire2api_u8(dynamic raw) { - return raw as int; - } - - Uint8List _wire2api_uint_8_list(dynamic raw) { - return raw as Uint8List; - } - - void _wire2api_unit(dynamic raw) { - return; - } -} - -// Section: api2wire - -@protected -int api2wire_u8(int raw) { - return raw; -} - -// Section: finalizer - -class ApiStorePlatform extends FlutterRustBridgeBase { - ApiStorePlatform(ffi.DynamicLibrary dylib) : super(ApiStoreWire(dylib)); - -// Section: api2wire - - @protected - wire_MutexConnection api2wire_MutexConnection(MutexConnection raw) { - final ptr = inner.new_MutexConnection(); - _api_fill_to_wire_MutexConnection(raw, ptr); - return ptr; - } - - @protected - ffi.Pointer api2wire_String(String raw) { - return api2wire_uint_8_list(utf8.encoder.convert(raw)); - } - - @protected - ffi.Pointer api2wire_box_autoadd_local_store(LocalStore raw) { - final ptr = inner.new_box_autoadd_local_store_2(); - _api_fill_to_wire_local_store(raw, ptr.ref); - return ptr; - } - - @protected - ffi.Pointer api2wire_opt_String(String? raw) { - return raw == null ? ffi.nullptr : api2wire_String(raw); - } - - @protected - ffi.Pointer api2wire_uint_8_list(Uint8List raw) { - final ans = inner.new_uint_8_list_2(raw.length); - ans.ref.ptr.asTypedList(raw.length).setAll(0, raw); - return ans; - } -// Section: finalizer - - late final OpaqueTypeFinalizer _MutexConnectionFinalizer = OpaqueTypeFinalizer(inner._drop_opaque_MutexConnectionPtr); - OpaqueTypeFinalizer get MutexConnectionFinalizer => _MutexConnectionFinalizer; -// Section: api_fill_to_wire - - void _api_fill_to_wire_MutexConnection(MutexConnection apiObj, wire_MutexConnection wireObj) { - wireObj.ptr = apiObj.shareOrMove(); - } - - void _api_fill_to_wire_box_autoadd_local_store(LocalStore apiObj, ffi.Pointer wireObj) { - _api_fill_to_wire_local_store(apiObj, wireObj.ref); - } - - void _api_fill_to_wire_local_store(LocalStore apiObj, wire_LocalStore wireObj) { - wireObj.conn = api2wire_MutexConnection(apiObj.conn); - } -} - -// ignore_for_file: camel_case_types, non_constant_identifier_names, avoid_positional_boolean_parameters, annotate_overrides, constant_identifier_names - -// AUTO GENERATED FILE, DO NOT EDIT. -// -// Generated by `package:ffigen`. -// ignore_for_file: type=lint - -/// generated by flutter_rust_bridge -class ApiStoreWire implements FlutterRustBridgeWireBase { - @internal - late final dartApi = DartApiDl(init_frb_dart_api_dl); - - /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) _lookup; - - /// The symbols are looked up in [dynamicLibrary]. - ApiStoreWire(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; - - /// The symbols are looked up with [lookup]. - ApiStoreWire.fromLookup(ffi.Pointer Function(String symbolName) lookup) - : _lookup = lookup; - - ffi.Pointer new_box_autoadd_native_preference_store_1() { - return _new_box_autoadd_native_preference_store_1(); - } - - late final _new_box_autoadd_native_preference_store_1Ptr = - _lookup Function()>>( - 'new_box_autoadd_native_preference_store_1'); - late final _new_box_autoadd_native_preference_store_1 = - _new_box_autoadd_native_preference_store_1Ptr.asFunction Function()>(); - - ffi.Pointer new_box_autoadd_local_db_0() { - return _new_box_autoadd_local_db_0(); - } - - late final _new_box_autoadd_local_db_0Ptr = - _lookup Function()>>('new_box_autoadd_local_db_0'); - late final _new_box_autoadd_local_db_0 = - _new_box_autoadd_local_db_0Ptr.asFunction Function()>(); - - void free_WireSyncReturn( - WireSyncReturn ptr, - ) { - return _free_WireSyncReturn( - ptr, - ); - } - - late final _free_WireSyncReturnPtr = - _lookup>('free_WireSyncReturn'); - late final _free_WireSyncReturn = _free_WireSyncReturnPtr.asFunction(); - - void store_dart_post_cobject( - DartPostCObjectFnType ptr, - ) { - return _store_dart_post_cobject( - ptr, - ); - } - - late final _store_dart_post_cobjectPtr = - _lookup>('store_dart_post_cobject'); - late final _store_dart_post_cobject = _store_dart_post_cobjectPtr.asFunction(); - - Object get_dart_object( - int ptr, - ) { - return _get_dart_object( - ptr, - ); - } - - late final _get_dart_objectPtr = _lookup>('get_dart_object'); - late final _get_dart_object = _get_dart_objectPtr.asFunction(); - - void drop_dart_object( - int ptr, - ) { - return _drop_dart_object( - ptr, - ); - } - - late final _drop_dart_objectPtr = _lookup>('drop_dart_object'); - late final _drop_dart_object = _drop_dart_objectPtr.asFunction(); - - int new_dart_opaque( - Object handle, - ) { - return _new_dart_opaque( - handle, - ); - } - - late final _new_dart_opaquePtr = _lookup>('new_dart_opaque'); - late final _new_dart_opaque = _new_dart_opaquePtr.asFunction(); - - int init_frb_dart_api_dl( - ffi.Pointer obj, - ) { - return _init_frb_dart_api_dl( - obj, - ); - } - - late final _init_frb_dart_api_dlPtr = - _lookup)>>('init_frb_dart_api_dl'); - late final _init_frb_dart_api_dl = _init_frb_dart_api_dlPtr.asFunction)>(); - - WireSyncReturn wire_new__static_method__LocalStore( - ffi.Pointer root, - ) { - return _wire_new__static_method__LocalStore( - root, - ); - } - - late final _wire_new__static_method__LocalStorePtr = - _lookup)>>( - 'wire_new__static_method__LocalStore'); - late final _wire_new__static_method__LocalStore = - _wire_new__static_method__LocalStorePtr.asFunction)>(); - - void wire_insert__method__LocalStore( - int port_, - ffi.Pointer that, - ffi.Pointer category, - ffi.Pointer key, - ffi.Pointer value, - ) { - return _wire_insert__method__LocalStore( - port_, - that, - category, - key, - value, - ); - } - - late final _wire_insert__method__LocalStorePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Int64, ffi.Pointer, ffi.Pointer, - ffi.Pointer, ffi.Pointer)>>('wire_insert__method__LocalStore'); - late final _wire_insert__method__LocalStore = _wire_insert__method__LocalStorePtr.asFunction< - void Function(int, ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Pointer)>(); - - void wire_get__method__LocalStore( - int port_, - ffi.Pointer that, - ffi.Pointer category, - ffi.Pointer key, - ) { - return _wire_get__method__LocalStore( - port_, - that, - category, - key, - ); - } - - late final _wire_get__method__LocalStorePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Int64, ffi.Pointer, ffi.Pointer, - ffi.Pointer)>>('wire_get__method__LocalStore'); - late final _wire_get__method__LocalStore = _wire_get__method__LocalStorePtr.asFunction< - void Function(int, ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); - - void wire_clear__method__LocalStore( - int port_, - ffi.Pointer that, - ffi.Pointer category, - ) { - return _wire_clear__method__LocalStore( - port_, - that, - category, - ); - } - - late final _wire_clear__method__LocalStorePtr = _lookup< - ffi - .NativeFunction, ffi.Pointer)>>( - 'wire_clear__method__LocalStore'); - late final _wire_clear__method__LocalStore = _wire_clear__method__LocalStorePtr - .asFunction, ffi.Pointer)>(); - - wire_MutexConnection new_MutexConnection() { - return _new_MutexConnection(); - } - - late final _new_MutexConnectionPtr = - _lookup>('new_MutexConnection'); - late final _new_MutexConnection = _new_MutexConnectionPtr.asFunction(); - - ffi.Pointer new_box_autoadd_local_store_2() { - return _new_box_autoadd_local_store_2(); - } - - late final _new_box_autoadd_local_store_2Ptr = - _lookup Function()>>('new_box_autoadd_local_store_2'); - late final _new_box_autoadd_local_store_2 = - _new_box_autoadd_local_store_2Ptr.asFunction Function()>(); - - ffi.Pointer new_uint_8_list_2( - int len, - ) { - return _new_uint_8_list_2( - len, - ); - } - - late final _new_uint_8_list_2Ptr = - _lookup Function(ffi.Int32)>>('new_uint_8_list_2'); - late final _new_uint_8_list_2 = _new_uint_8_list_2Ptr.asFunction Function(int)>(); - - void drop_opaque_MutexConnection( - ffi.Pointer ptr, - ) { - return _drop_opaque_MutexConnection( - ptr, - ); - } - - late final _drop_opaque_MutexConnectionPtr = - _lookup)>>('drop_opaque_MutexConnection'); - late final _drop_opaque_MutexConnection = - _drop_opaque_MutexConnectionPtr.asFunction)>(); - - ffi.Pointer share_opaque_MutexConnection( - ffi.Pointer ptr, - ) { - return _share_opaque_MutexConnection( - ptr, - ); - } - - late final _share_opaque_MutexConnectionPtr = - _lookup Function(ffi.Pointer)>>( - 'share_opaque_MutexConnection'); - late final _share_opaque_MutexConnection = - _share_opaque_MutexConnectionPtr.asFunction Function(ffi.Pointer)>(); -} - -final class _Dart_Handle extends ffi.Opaque {} - -final class wire_MutexDummy1Connection extends ffi.Struct { - external ffi.Pointer ptr; -} - -final class wire_NativePreferenceStore extends ffi.Struct { - external wire_MutexDummy1Connection conn; -} - -final class wire_MutexRepoDatabaseRead extends ffi.Struct { - external ffi.Pointer ptr; -} - -final class wire_LocalDb extends ffi.Struct { - external wire_MutexRepoDatabaseRead repo; -} - -final class wire_uint_8_list extends ffi.Struct { - external ffi.Pointer ptr; - - @ffi.Int32() - external int len; -} - -final class wire_MutexConnection extends ffi.Struct { - external ffi.Pointer ptr; -} - -final class wire_LocalStore extends ffi.Struct { - external wire_MutexConnection conn; -} - -typedef DartPostCObjectFnType - = ffi.Pointer message)>>; -typedef DartPort = ffi.Int64; diff --git a/lib/bridge/native.dart b/lib/bridge/native.dart new file mode 100644 index 00000000..1653aa92 --- /dev/null +++ b/lib/bridge/native.dart @@ -0,0 +1,22 @@ +// This file initializes the dynamic library and connects it with the stub +// generated by flutter_rust_bridge_codegen. + +import 'dart:ffi'; + +import 'package:annix/bridge/bridge_generated.dart'; +export 'package:annix/bridge/bridge_generated.dart'; +export 'package:annix/bridge/bridge_definitions.dart'; + +// Re-export the bridge so it is only necessary to import this file. +import 'dart:io' as io; + +const _base = 'annix_native'; + +// On MacOS, the dynamic library is not bundled with the binary, +// but rather directly **linked** against the binary. +final _dylibPath = io.Platform.isWindows ? '$_base.dll' : 'lib$_base.so'; +final _dylib = io.Platform.isIOS || io.Platform.isMacOS + ? DynamicLibrary.executable() + : DynamicLibrary.open(_dylibPath); + +final api = AnnixNativeImpl(_dylib); diff --git a/lib/services/local/cache.dart b/lib/services/local/cache.dart index 4d9ee2e7..68acd35a 100644 --- a/lib/services/local/cache.dart +++ b/lib/services/local/cache.dart @@ -1,6 +1,6 @@ import 'dart:convert'; -import 'package:annix/bridge/bridge.dart'; +import 'package:annix/bridge/native.dart'; import 'package:annix/services/path.dart'; class AnnixStore { @@ -13,8 +13,7 @@ class AnnixStore { final LocalStore _database; AnnixStore._() - : _database = - nativeStore.newStaticMethodLocalStore(root: PathService.dataRoot); + : _database = api.newStaticMethodLocalStore(root: PathService.dataRoot); AnnixStoreCategory category(final String category) { return AnnixStoreCategory(this, category); diff --git a/lib/services/local/preferences.dart b/lib/services/local/preferences.dart index 087f818a..e135e1fa 100644 --- a/lib/services/local/preferences.dart +++ b/lib/services/local/preferences.dart @@ -1,6 +1,6 @@ import 'dart:convert'; -import 'package:annix/bridge/bridge.dart'; +import 'package:annix/bridge/native.dart'; import 'package:annix/services/path.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; @@ -8,7 +8,7 @@ class PreferencesStore { late final NativePreferenceStore _store; PreferencesStore(final Ref ref) - : _store = nativePreferenceStore.newStaticMethodNativePreferenceStore( + : _store = api.newStaticMethodNativePreferenceStore( root: PathService.dataRoot); T? get(final String key) { diff --git a/lib/services/metadata/metadata_source_sqlite.dart b/lib/services/metadata/metadata_source_sqlite.dart index d35a71e3..3aa82016 100644 --- a/lib/services/metadata/metadata_source_sqlite.dart +++ b/lib/services/metadata/metadata_source_sqlite.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'dart:io'; -import 'package:annix/bridge/bridge.dart'; +import 'package:annix/bridge/native.dart'; import 'package:annix/services/metadata/metadata_model.dart'; import 'package:annix/services/anniv/anniv_model.dart'; import 'package:annix/services/metadata/metadata_source.dart'; @@ -16,8 +16,8 @@ class SqliteMetadataSource extends MetadataSource { @override Future prepare() async { - database = await nativeRepository.newStaticMethodLocalDb( - path: p.join(dbFolderPath, 'repo.db')); + database = + await api.newStaticMethodLocalDb(path: p.join(dbFolderPath, 'repo.db')); } @override diff --git a/lib/services/network/network.dart b/lib/services/network/network.dart index 0c9a37f8..b9c130e8 100644 --- a/lib/services/network/network.dart +++ b/lib/services/network/network.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:annix/bridge/bridge.dart'; +import 'package:annix/bridge/native.dart'; import 'package:annix/providers.dart'; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:dio/dio.dart'; @@ -63,7 +63,7 @@ class NetworkService extends ChangeNotifier { /// Update network status both in NetworkService and void updateAndNotify() { - nativeNetwork.updateNetworkStatus(isOnline: isOnline); + api.updateNetworkStatus(isOnline: isOnline); notifyListeners(); } diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index b25ee181..5698b394 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -473,7 +473,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OBJC_BRIDGING_HEADER = Runner/generated_network.h; + SWIFT_OBJC_BRIDGING_HEADER = Runner/bridge_generated.h; SWIFT_OPTIMIZATION_LEVEL = "-O"; }; name = Profile; @@ -555,7 +555,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OBJC_BRIDGING_HEADER = Runner/generated_network.h; + SWIFT_OBJC_BRIDGING_HEADER = Runner/bridge_generated.h; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; name = Debug; @@ -603,7 +603,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OBJC_BRIDGING_HEADER = Runner/generated_network.h; + SWIFT_OBJC_BRIDGING_HEADER = Runner/bridge_generated.h; SWIFT_OPTIMIZATION_LEVEL = "-O"; }; name = Release; diff --git a/macos/Runner/AppDelegate.swift b/macos/Runner/AppDelegate.swift index f99e43db..35578ddc 100644 --- a/macos/Runner/AppDelegate.swift +++ b/macos/Runner/AppDelegate.swift @@ -4,7 +4,7 @@ import FlutterMacOS @NSApplicationMain class AppDelegate: FlutterAppDelegate { override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { - dummy_method_to_enforce_bundling_ApiNetwork() + dummy_method_to_enforce_bundling() return true } } diff --git a/macos/Runner/bridge_generated.h b/macos/Runner/bridge_generated.h new file mode 100644 index 00000000..d23541b5 --- /dev/null +++ b/macos/Runner/bridge_generated.h @@ -0,0 +1,166 @@ +#include +#include +#include +typedef struct _Dart_Handle* Dart_Handle; + +typedef struct DartCObject DartCObject; + +typedef int64_t DartPort; + +typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); + +typedef struct DartCObject *WireSyncReturn; + +typedef struct wire_uint_8_list { + uint8_t *ptr; + int32_t len; +} wire_uint_8_list; + +typedef struct wire_MutexDummy1Connection { + const void *ptr; +} wire_MutexDummy1Connection; + +typedef struct wire_NativePreferenceStore { + struct wire_MutexDummy1Connection conn; +} wire_NativePreferenceStore; + +typedef struct wire_MutexRepoDatabaseRead { + const void *ptr; +} wire_MutexRepoDatabaseRead; + +typedef struct wire_LocalDb { + struct wire_MutexRepoDatabaseRead repo; +} wire_LocalDb; + +typedef struct wire_MutexConnection { + const void *ptr; +} wire_MutexConnection; + +typedef struct wire_LocalStore { + struct wire_MutexConnection conn; +} wire_LocalStore; + +void store_dart_post_cobject(DartPostCObjectFnType ptr); + +Dart_Handle get_dart_object(uintptr_t ptr); + +void drop_dart_object(uintptr_t ptr); + +uintptr_t new_dart_opaque(Dart_Handle handle); + +intptr_t init_frb_dart_api_dl(void *obj); + +void wire_update_network_status(int64_t port_, bool is_online); + +void wire_is_online__method__NetworkStatus(int64_t port_, int32_t that); + +WireSyncReturn wire_new__static_method__NativePreferenceStore(struct wire_uint_8_list *root); + +WireSyncReturn wire_get__method__NativePreferenceStore(struct wire_NativePreferenceStore *that, + struct wire_uint_8_list *key); + +WireSyncReturn wire_set__method__NativePreferenceStore(struct wire_NativePreferenceStore *that, + struct wire_uint_8_list *key, + struct wire_uint_8_list *value); + +WireSyncReturn wire_remove__method__NativePreferenceStore(struct wire_NativePreferenceStore *that, + struct wire_uint_8_list *key); + +WireSyncReturn wire_remove_prefix__method__NativePreferenceStore(struct wire_NativePreferenceStore *that, + struct wire_uint_8_list *prefix); + +void wire_new__static_method__LocalDb(int64_t port_, struct wire_uint_8_list *path); + +void wire_get_album__method__LocalDb(int64_t port_, + struct wire_LocalDb *that, + struct wire_uint_8_list *album_id); + +void wire_get_albums_by_tag__method__LocalDb(int64_t port_, + struct wire_LocalDb *that, + struct wire_uint_8_list *tag, + bool recursive); + +void wire_get_tags__method__LocalDb(int64_t port_, struct wire_LocalDb *that); + +WireSyncReturn wire_new__static_method__LocalStore(struct wire_uint_8_list *root); + +void wire_insert__method__LocalStore(int64_t port_, + struct wire_LocalStore *that, + struct wire_uint_8_list *category, + struct wire_uint_8_list *key, + struct wire_uint_8_list *value); + +void wire_get__method__LocalStore(int64_t port_, + struct wire_LocalStore *that, + struct wire_uint_8_list *category, + struct wire_uint_8_list *key); + +void wire_clear__method__LocalStore(int64_t port_, + struct wire_LocalStore *that, + struct wire_uint_8_list *category); + +struct wire_MutexConnection new_MutexConnection(void); + +struct wire_MutexDummy1Connection new_MutexDummy1Connection(void); + +struct wire_MutexRepoDatabaseRead new_MutexRepoDatabaseRead(void); + +struct wire_LocalDb *new_box_autoadd_local_db_0(void); + +struct wire_LocalStore *new_box_autoadd_local_store_0(void); + +struct wire_NativePreferenceStore *new_box_autoadd_native_preference_store_0(void); + +struct wire_uint_8_list *new_uint_8_list_0(int32_t len); + +void drop_opaque_MutexConnection(const void *ptr); + +const void *share_opaque_MutexConnection(const void *ptr); + +void drop_opaque_MutexDummy1Connection(const void *ptr); + +const void *share_opaque_MutexDummy1Connection(const void *ptr); + +void drop_opaque_MutexRepoDatabaseRead(const void *ptr); + +const void *share_opaque_MutexRepoDatabaseRead(const void *ptr); + +void free_WireSyncReturn(WireSyncReturn ptr); + +static int64_t dummy_method_to_enforce_bundling(void) { + int64_t dummy_var = 0; + dummy_var ^= ((int64_t) (void*) wire_update_network_status); + dummy_var ^= ((int64_t) (void*) wire_is_online__method__NetworkStatus); + dummy_var ^= ((int64_t) (void*) wire_new__static_method__NativePreferenceStore); + dummy_var ^= ((int64_t) (void*) wire_get__method__NativePreferenceStore); + dummy_var ^= ((int64_t) (void*) wire_set__method__NativePreferenceStore); + dummy_var ^= ((int64_t) (void*) wire_remove__method__NativePreferenceStore); + dummy_var ^= ((int64_t) (void*) wire_remove_prefix__method__NativePreferenceStore); + dummy_var ^= ((int64_t) (void*) wire_new__static_method__LocalDb); + dummy_var ^= ((int64_t) (void*) wire_get_album__method__LocalDb); + dummy_var ^= ((int64_t) (void*) wire_get_albums_by_tag__method__LocalDb); + dummy_var ^= ((int64_t) (void*) wire_get_tags__method__LocalDb); + dummy_var ^= ((int64_t) (void*) wire_new__static_method__LocalStore); + dummy_var ^= ((int64_t) (void*) wire_insert__method__LocalStore); + dummy_var ^= ((int64_t) (void*) wire_get__method__LocalStore); + dummy_var ^= ((int64_t) (void*) wire_clear__method__LocalStore); + dummy_var ^= ((int64_t) (void*) new_MutexConnection); + dummy_var ^= ((int64_t) (void*) new_MutexDummy1Connection); + dummy_var ^= ((int64_t) (void*) new_MutexRepoDatabaseRead); + dummy_var ^= ((int64_t) (void*) new_box_autoadd_local_db_0); + dummy_var ^= ((int64_t) (void*) new_box_autoadd_local_store_0); + dummy_var ^= ((int64_t) (void*) new_box_autoadd_native_preference_store_0); + dummy_var ^= ((int64_t) (void*) new_uint_8_list_0); + dummy_var ^= ((int64_t) (void*) drop_opaque_MutexConnection); + dummy_var ^= ((int64_t) (void*) share_opaque_MutexConnection); + dummy_var ^= ((int64_t) (void*) drop_opaque_MutexDummy1Connection); + dummy_var ^= ((int64_t) (void*) share_opaque_MutexDummy1Connection); + dummy_var ^= ((int64_t) (void*) drop_opaque_MutexRepoDatabaseRead); + dummy_var ^= ((int64_t) (void*) share_opaque_MutexRepoDatabaseRead); + dummy_var ^= ((int64_t) (void*) free_WireSyncReturn); + dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); + dummy_var ^= ((int64_t) (void*) get_dart_object); + dummy_var ^= ((int64_t) (void*) drop_dart_object); + dummy_var ^= ((int64_t) (void*) new_dart_opaque); + return dummy_var; +} diff --git a/macos/Runner/generated_network.h b/macos/Runner/generated_network.h deleted file mode 100644 index 684d4d7f..00000000 --- a/macos/Runner/generated_network.h +++ /dev/null @@ -1,69 +0,0 @@ -#include -#include -#include -typedef struct _Dart_Handle* Dart_Handle; - -typedef struct DartCObject DartCObject; - -typedef int64_t DartPort; - -typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); - -typedef struct wire_MutexDummy1Connection { - const void *ptr; -} wire_MutexDummy1Connection; - -typedef struct wire_NativePreferenceStore { - struct wire_MutexDummy1Connection conn; -} wire_NativePreferenceStore; - -typedef struct wire_MutexRepoDatabaseRead { - const void *ptr; -} wire_MutexRepoDatabaseRead; - -typedef struct wire_LocalDb { - struct wire_MutexRepoDatabaseRead repo; -} wire_LocalDb; - -typedef struct DartCObject *WireSyncReturn; - -typedef struct wire_MutexConnection { - const void *ptr; -} wire_MutexConnection; - -typedef struct wire_LocalStore { - struct wire_MutexConnection conn; -} wire_LocalStore; - -void store_dart_post_cobject(DartPostCObjectFnType ptr); - -Dart_Handle get_dart_object(uintptr_t ptr); - -void drop_dart_object(uintptr_t ptr); - -uintptr_t new_dart_opaque(Dart_Handle handle); - -intptr_t init_frb_dart_api_dl(void *obj); - -void wire_update_network_status(int64_t port_, bool is_online); - -void wire_is_online__method__NetworkStatus(int64_t port_, int32_t that); - -struct wire_NativePreferenceStore *new_box_autoadd_native_preference_store_1(void); - -struct wire_LocalDb *new_box_autoadd_local_db_0(void); - -void free_WireSyncReturn(WireSyncReturn ptr); - -struct wire_LocalStore *new_box_autoadd_local_store_2(void); - -static int64_t dummy_method_to_enforce_bundling_ApiNetwork(void) { - int64_t dummy_var = 0; - dummy_var ^= ((int64_t) (void*) wire_update_network_status); - dummy_var ^= ((int64_t) (void*) wire_is_online__method__NetworkStatus); - dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); - dummy_var ^= ((int64_t) (void*) get_dart_object); - dummy_var ^= ((int64_t) (void*) drop_dart_object); - dummy_var ^= ((int64_t) (void*) new_dart_opaque); - return dummy_var; -} diff --git a/macos/Runner/generated_preferences.h b/macos/Runner/generated_preferences.h deleted file mode 100644 index 20a88cb0..00000000 --- a/macos/Runner/generated_preferences.h +++ /dev/null @@ -1,111 +0,0 @@ -#include -#include -#include -typedef struct _Dart_Handle* Dart_Handle; - -typedef struct DartCObject DartCObject; - -typedef int64_t DartPort; - -typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); - -typedef struct DartCObject *WireSyncReturn; - -typedef struct wire_uint_8_list { - uint8_t *ptr; - int32_t len; -} wire_uint_8_list; - -typedef struct wire_uint_8_list { - uint8_t *ptr; - int32_t len; -} wire_uint_8_list; - -typedef struct wire_uint_8_list { - uint8_t *ptr; - int32_t len; -} wire_uint_8_list; - -typedef struct wire_MutexDummy1Connection { - const void *ptr; -} wire_MutexDummy1Connection; - -typedef struct wire_NativePreferenceStore { - struct wire_MutexDummy1Connection conn; -} wire_NativePreferenceStore; - -typedef struct wire_MutexRepoDatabaseRead { - const void *ptr; -} wire_MutexRepoDatabaseRead; - -typedef struct wire_LocalDb { - struct wire_MutexRepoDatabaseRead repo; -} wire_LocalDb; - -typedef struct wire_MutexConnection { - const void *ptr; -} wire_MutexConnection; - -typedef struct wire_LocalStore { - struct wire_MutexConnection conn; -} wire_LocalStore; - -void store_dart_post_cobject(DartPostCObjectFnType ptr); - -Dart_Handle get_dart_object(uintptr_t ptr); - -void drop_dart_object(uintptr_t ptr); - -uintptr_t new_dart_opaque(Dart_Handle handle); - -intptr_t init_frb_dart_api_dl(void *obj); - -WireSyncReturn wire_new__static_method__NativePreferenceStore(struct wire_uint_8_list *root); - -WireSyncReturn wire_get__method__NativePreferenceStore(struct wire_NativePreferenceStore *that, - struct wire_uint_8_list *key); - -WireSyncReturn wire_set__method__NativePreferenceStore(struct wire_NativePreferenceStore *that, - struct wire_uint_8_list *key, - struct wire_uint_8_list *value); - -WireSyncReturn wire_remove__method__NativePreferenceStore(struct wire_NativePreferenceStore *that, - struct wire_uint_8_list *key); - -WireSyncReturn wire_remove_prefix__method__NativePreferenceStore(struct wire_NativePreferenceStore *that, - struct wire_uint_8_list *prefix); - -struct wire_MutexDummy1Connection new_MutexDummy1Connection(void); - -struct wire_NativePreferenceStore *new_box_autoadd_native_preference_store_1(void); - -struct wire_uint_8_list *new_uint_8_list_1(int32_t len); - -void drop_opaque_MutexDummy1Connection(const void *ptr); - -const void *share_opaque_MutexDummy1Connection(const void *ptr); - -struct wire_LocalDb *new_box_autoadd_local_db_0(void); - -void free_WireSyncReturn(WireSyncReturn ptr); - -struct wire_LocalStore *new_box_autoadd_local_store_2(void); - -static int64_t dummy_method_to_enforce_bundling_ApiPreferenceStore(void) { - int64_t dummy_var = 0; - dummy_var ^= ((int64_t) (void*) wire_new__static_method__NativePreferenceStore); - dummy_var ^= ((int64_t) (void*) wire_get__method__NativePreferenceStore); - dummy_var ^= ((int64_t) (void*) wire_set__method__NativePreferenceStore); - dummy_var ^= ((int64_t) (void*) wire_remove__method__NativePreferenceStore); - dummy_var ^= ((int64_t) (void*) wire_remove_prefix__method__NativePreferenceStore); - dummy_var ^= ((int64_t) (void*) new_MutexDummy1Connection); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_native_preference_store_1); - dummy_var ^= ((int64_t) (void*) new_uint_8_list_1); - dummy_var ^= ((int64_t) (void*) drop_opaque_MutexDummy1Connection); - dummy_var ^= ((int64_t) (void*) share_opaque_MutexDummy1Connection); - dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); - dummy_var ^= ((int64_t) (void*) get_dart_object); - dummy_var ^= ((int64_t) (void*) drop_dart_object); - dummy_var ^= ((int64_t) (void*) new_dart_opaque); - return dummy_var; -} diff --git a/macos/Runner/generated_repo.h b/macos/Runner/generated_repo.h deleted file mode 100644 index 4ed42858..00000000 --- a/macos/Runner/generated_repo.h +++ /dev/null @@ -1,121 +0,0 @@ -#include -#include -#include -typedef struct _Dart_Handle* Dart_Handle; - -typedef struct DartCObject DartCObject; - -typedef struct wire_MutexDummy1Connection { - const void *ptr; -} wire_MutexDummy1Connection; - -typedef struct wire_NativePreferenceStore { - struct wire_MutexDummy1Connection conn; -} wire_NativePreferenceStore; - -typedef int64_t DartPort; - -typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); - -typedef struct wire_uint_8_list { - uint8_t *ptr; - int32_t len; -} wire_uint_8_list; - -typedef struct wire_uint_8_list { - uint8_t *ptr; - int32_t len; -} wire_uint_8_list; - -typedef struct wire_uint_8_list { - uint8_t *ptr; - int32_t len; -} wire_uint_8_list; - -typedef struct wire_MutexRepoDatabaseRead { - const void *ptr; -} wire_MutexRepoDatabaseRead; - -typedef struct wire_LocalDb { - struct wire_MutexRepoDatabaseRead repo; -} wire_LocalDb; - -typedef struct DartCObject *WireSyncReturn; - -typedef struct wire_MutexConnection { - const void *ptr; -} wire_MutexConnection; - -typedef struct wire_LocalStore { - struct wire_MutexConnection conn; -} wire_LocalStore; - -struct wire_NativePreferenceStore *new_box_autoadd_native_preference_store_1(void); - -void store_dart_post_cobject(DartPostCObjectFnType ptr); - -Dart_Handle get_dart_object(uintptr_t ptr); - -void drop_dart_object(uintptr_t ptr); - -uintptr_t new_dart_opaque(Dart_Handle handle); - -intptr_t init_frb_dart_api_dl(void *obj); - -void wire_new__static_method__LocalDb(int64_t port_, struct wire_uint_8_list *path); - -void wire_get_album__method__LocalDb(int64_t port_, - struct wire_LocalDb *that, - struct wire_uint_8_list *album_id); - -void wire_get_albums_by_tag__method__LocalDb(int64_t port_, - struct wire_LocalDb *that, - struct wire_uint_8_list *tag, - bool recursive); - -void wire_get_tags__method__LocalDb(int64_t port_, struct wire_LocalDb *that); - -struct wire_MutexRepoDatabaseRead new_MutexRepoDatabaseRead(void); - -struct wire_LocalDb *new_box_autoadd_local_db_0(void); - -struct wire_uint_8_list *new_uint_8_list_0(int32_t len); - -void drop_opaque_MutexRepoDatabaseRead(const void *ptr); - -const void *share_opaque_MutexRepoDatabaseRead(const void *ptr); - -void free_WireSyncReturn(WireSyncReturn ptr); - -struct wire_LocalStore *new_box_autoadd_local_store_2(void); - -static int64_t dummy_method_to_enforce_bundling_ApiRepository(void) { - int64_t dummy_var = 0; - dummy_var ^= ((int64_t) (void*) wire_new__static_method__LocalDb); - dummy_var ^= ((int64_t) (void*) wire_get_album__method__LocalDb); - dummy_var ^= ((int64_t) (void*) wire_get_albums_by_tag__method__LocalDb); - dummy_var ^= ((int64_t) (void*) wire_get_tags__method__LocalDb); - dummy_var ^= ((int64_t) (void*) new_MutexRepoDatabaseRead); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_local_db_0); - dummy_var ^= ((int64_t) (void*) new_uint_8_list_0); - dummy_var ^= ((int64_t) (void*) drop_opaque_MutexRepoDatabaseRead); - dummy_var ^= ((int64_t) (void*) share_opaque_MutexRepoDatabaseRead); - dummy_var ^= ((int64_t) (void*) free_WireSyncReturn); - dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); - dummy_var ^= ((int64_t) (void*) get_dart_object); - dummy_var ^= ((int64_t) (void*) drop_dart_object); - dummy_var ^= ((int64_t) (void*) new_dart_opaque); - return dummy_var; -} - -#include "generated_preferences.h" -#include "generated_store.h" -#include "generated_network.h" -static int64_t dummy_method_to_enforce_bundling(void) { - int64_t dummy_var = 0; - dummy_var ^= ((int64_t) (void*) dummy_method_to_enforce_bundling_ApiRepository); - dummy_var ^= ((int64_t) (void*) dummy_method_to_enforce_bundling_ApiPreferenceStore); - dummy_var ^= ((int64_t) (void*) dummy_method_to_enforce_bundling_ApiStore); - dummy_var ^= ((int64_t) (void*) dummy_method_to_enforce_bundling_ApiNetwork); - return dummy_var; -} diff --git a/macos/Runner/generated_store.h b/macos/Runner/generated_store.h deleted file mode 100644 index d777b21c..00000000 --- a/macos/Runner/generated_store.h +++ /dev/null @@ -1,112 +0,0 @@ -#include -#include -#include -typedef struct _Dart_Handle* Dart_Handle; - -typedef struct DartCObject DartCObject; - -typedef struct wire_MutexDummy1Connection { - const void *ptr; -} wire_MutexDummy1Connection; - -typedef struct wire_NativePreferenceStore { - struct wire_MutexDummy1Connection conn; -} wire_NativePreferenceStore; - -typedef struct wire_MutexRepoDatabaseRead { - const void *ptr; -} wire_MutexRepoDatabaseRead; - -typedef struct wire_LocalDb { - struct wire_MutexRepoDatabaseRead repo; -} wire_LocalDb; - -typedef struct DartCObject *WireSyncReturn; - -typedef int64_t DartPort; - -typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); - -typedef struct wire_uint_8_list { - uint8_t *ptr; - int32_t len; -} wire_uint_8_list; - -typedef struct wire_uint_8_list { - uint8_t *ptr; - int32_t len; -} wire_uint_8_list; - -typedef struct wire_uint_8_list { - uint8_t *ptr; - int32_t len; -} wire_uint_8_list; - -typedef struct wire_MutexConnection { - const void *ptr; -} wire_MutexConnection; - -typedef struct wire_LocalStore { - struct wire_MutexConnection conn; -} wire_LocalStore; - -struct wire_NativePreferenceStore *new_box_autoadd_native_preference_store_1(void); - -struct wire_LocalDb *new_box_autoadd_local_db_0(void); - -void free_WireSyncReturn(WireSyncReturn ptr); - -void store_dart_post_cobject(DartPostCObjectFnType ptr); - -Dart_Handle get_dart_object(uintptr_t ptr); - -void drop_dart_object(uintptr_t ptr); - -uintptr_t new_dart_opaque(Dart_Handle handle); - -intptr_t init_frb_dart_api_dl(void *obj); - -WireSyncReturn wire_new__static_method__LocalStore(struct wire_uint_8_list *root); - -void wire_insert__method__LocalStore(int64_t port_, - struct wire_LocalStore *that, - struct wire_uint_8_list *category, - struct wire_uint_8_list *key, - struct wire_uint_8_list *value); - -void wire_get__method__LocalStore(int64_t port_, - struct wire_LocalStore *that, - struct wire_uint_8_list *category, - struct wire_uint_8_list *key); - -void wire_clear__method__LocalStore(int64_t port_, - struct wire_LocalStore *that, - struct wire_uint_8_list *category); - -struct wire_MutexConnection new_MutexConnection(void); - -struct wire_LocalStore *new_box_autoadd_local_store_2(void); - -struct wire_uint_8_list *new_uint_8_list_2(int32_t len); - -void drop_opaque_MutexConnection(const void *ptr); - -const void *share_opaque_MutexConnection(const void *ptr); - -static int64_t dummy_method_to_enforce_bundling_ApiStore(void) { - int64_t dummy_var = 0; - dummy_var ^= ((int64_t) (void*) wire_new__static_method__LocalStore); - dummy_var ^= ((int64_t) (void*) wire_insert__method__LocalStore); - dummy_var ^= ((int64_t) (void*) wire_get__method__LocalStore); - dummy_var ^= ((int64_t) (void*) wire_clear__method__LocalStore); - dummy_var ^= ((int64_t) (void*) new_MutexConnection); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_local_store_2); - dummy_var ^= ((int64_t) (void*) new_uint_8_list_2); - dummy_var ^= ((int64_t) (void*) drop_opaque_MutexConnection); - dummy_var ^= ((int64_t) (void*) share_opaque_MutexConnection); - dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); - dummy_var ^= ((int64_t) (void*) get_dart_object); - dummy_var ^= ((int64_t) (void*) drop_dart_object); - dummy_var ^= ((int64_t) (void*) new_dart_opaque); - return dummy_var; -}