straw/rust/strawcore/src/lib.rs
Kayos 7327de2843 v0.1.0-V (vc=9): U-3 — streamInfo via rustypipe drives VideoDetail+Player
stream_info(url) UniFFI suspend fn replaces NewPipeExtractor's
StreamInfo.getInfo() for both VideoDetailViewModel and PlayerViewModel.
One Rust round-trip drives the detail screen render AND the player's
resolve(). The VideoDetailUiState.info field cached on detail load is
reused by the Download dialog so we don't refetch.

Deferred to U-3.5:
- like_count (rustypipe's player() doesn't surface engagement data;
  a separate query is needed)
- related (player() doesn't include 'up next'; comes from a separate
  endpoint). Kotlin gets empty list for now — RelatedRow handles it.

Type quirks vs my initial guesses (caught by cargo check):
- details.duration is u32, not Option<u32>
- channel is split into channel_id + channel_name, not a struct
- like_count doesn't exist at this query depth
- VideoFormat::Webm (lowercase mb), VideoCodec::Avc1 (not H264)
- video_only is a separate vec (video_only_streams), not a bool flag
2026-05-24 08:52:43 -07:00

48 lines
1.5 KiB
Rust

// strawcore — Rust core for the Straw Android app.
//
// Phase U-1: hello-world smoke test. One exported function, returns a
// String so we know JNI + UniFFI marshalling works end-to-end before we
// pull in rustypipe.
//
// Phase U-2+ adds real APIs (search, stream_info, channel_info).
use std::sync::Once;
mod error;
mod runtime;
mod search;
mod stream;
#[allow(unused_imports)]
use runtime::block_on;
// Re-exports so UniFFI sees the types at the crate root for macro discovery.
pub use error::StrawcoreError;
pub use search::SearchItem;
pub use stream::{AudioStreamItem, StreamInfo, VideoStreamItem};
/// Initialize Android logging once. The Kotlin side calls this from
/// StrawApp.onCreate() so anything emitted via `log::info!()` shows up in
/// `adb logcat -s strawcore`.
#[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");
});
}
/// Smoke-test entry point — round-trip a string through JNI so we know
/// the bridge is working before pulling in rustypipe.
#[uniffi::export]
pub fn hello_from_rust(name: String) -> String {
log::info!("hello_from_rust called with name={}", name);
format!("hello {} from rust 🦀 (strawcore v{})", name, env!("CARGO_PKG_VERSION"))
}
uniffi::setup_scaffolding!();