Baseline Compose Multiplatform Iroh migration

This commit is contained in:
2026-07-02 23:53:47 +02:00
commit 90463d7210
64 changed files with 8439 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
[package]
name = "vnidrop-core"
version = "0.1.0"
edition = "2021"
[lib]
name = "vnidrop_core"
crate-type = ["cdylib", "staticlib", "rlib"]
[dependencies]
anyhow = "1.0.102"
async-channel = "2.5.0"
bytes = "1.11.1"
data-encoding = "2.11.0"
futures = "0.3"
futures-lite = "2.6.1"
iroh = "1.0.0"
iroh-blobs = "0.103.0"
irpc = "0.17.0"
n0-future = "0.3.1"
num_cpus = "1.17.0"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "2.0.18"
tokio = { version = "1.52.3", features = ["full"] }
uniffi = { version = "=0.29.4", features = ["tokio"] }
uuid = { version = "1.23.3", features = ["v4", "serde"] }
walkdir = "2.5.0"
[dev-dependencies]
tempfile = "3.27.0"

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,68 @@
use std::sync::{Arc, Mutex};
use vnidrop_core::{
CoreEvent, CoreEventSink, ShareMetadataInput, ShareSource, SourceKind, VnidropCore,
};
#[derive(Default)]
struct RecordingSink {
events: Mutex<Vec<CoreEvent>>,
}
impl CoreEventSink for RecordingSink {
fn on_event(&self, event: CoreEvent) {
self.events.lock().unwrap().push(event);
}
}
#[test]
fn two_local_cores_transfer_file() {
let sender_dir = tempfile::tempdir().unwrap();
let receiver_dir = tempfile::tempdir().unwrap();
let output_dir = tempfile::tempdir().unwrap();
let source_path = sender_dir.path().join("hello.txt");
std::fs::write(&source_path, b"hello from vnidrop").unwrap();
let sender = VnidropCore::initialize(
sender_dir.path().join("core").to_string_lossy().to_string(),
Arc::new(RecordingSink::default()),
)
.unwrap();
let receiver = VnidropCore::initialize(
receiver_dir.path().join("core").to_string_lossy().to_string(),
Arc::new(RecordingSink::default()),
)
.unwrap();
let share = sender
.share_files(
vec![ShareSource {
kind: SourceKind::Path,
value: source_path.to_string_lossy().to_string(),
display_name: Some("hello.txt".to_string()),
is_directory: false,
}],
ShareMetadataInput {
transfer_id: 7,
transfer_name: Some("hello".to_string()),
sender_name: Some("sender".to_string()),
},
)
.unwrap();
receiver
.receive(
share.ticket,
output_dir.path().to_string_lossy().to_string(),
Some("receiver".to_string()),
)
.unwrap();
assert_eq!(
std::fs::read(output_dir.path().join("hello.txt")).unwrap(),
b"hello from vnidrop"
);
sender.shutdown();
receiver.shutdown();
}

View File

@@ -0,0 +1,2 @@
[bindings.kotlin]
package_name = "com.vnidrop.core"