// strawcore (wrapper) — UniFFI surface for the Straw Android app. // // Thin layer over the new Sulkta-Coop/strawcore-core crate. All extractor // logic (InnerTube, JS deobf, stream parsing, search, channel, playlist) // lives in core. This file: // * re-exports the DTOs Kotlin expects under their familiar names // * exposes #[uniffi::export] async fns that bridge Kotlin suspend funs // to the core's blocking calls via tokio::task::spawn_blocking // * owns init_logging() — also initializes the core Downloader use std::sync::Once; mod channel; mod error; mod runtime; mod search; mod stream; // Re-exports so UniFFI sees the types at the crate root for macro discovery. pub use channel::ChannelInfo; pub use error::StrawcoreError; pub use search::SearchItem; pub use stream::{AudioStreamItem, StreamInfo, VideoStreamItem}; /// Initialize Android logging + the strawcore-core HTTP downloader. /// Kotlin calls this from StrawApp.onCreate(). Idempotent. #[uniffi::export] pub fn init_logging() { static ONCE: Once = Once::new(); ONCE.call_once(|| { android_logger::init_once( android_logger::Config::default() .with_max_level(log::LevelFilter::Info) .with_tag("strawcore"), ); log::info!("strawcore initialized"); }); runtime::ensure_initialized(); } /// Smoke-test entry point — round-trip a string through JNI. /// Used during the initial UniFFI bring-up; kept for future smoke /// debugging. Logs shape only — the `name` value never hits logcat /// because a future caller might pass a real user-supplied string. #[uniffi::export] pub fn hello_from_rust(name: String) -> String { log::info!("hello_from_rust called name_len={}", name.len()); format!( "hello {} from rust 🦀 (strawcore v{})", name, env!("CARGO_PKG_VERSION") ) } uniffi::setup_scaffolding!();