MCPcopy Create free account
hub / github.com/GCWing/BitFun / file_url_for_export_html

Function file_url_for_export_html

src/apps/desktop/src/api/miniapp_export_api.rs:45–62  ·  view source on GitHub ↗

Write slide HTML to app cache and return a `file://` URL for the export webview.

(
    app: &AppHandle<R>,
    html: &str,
)

Source from the content-addressed store, hash-verified

43
44/// Write slide HTML to app cache and return a `file://` URL for the export webview.
45fn file_url_for_export_html<R: tauri::Runtime>(
46 app: &AppHandle<R>,
47 html: &str,
48) -> Result<(tauri::Url, PathBuf), String> {
49 let cache_dir = app
50 .path()
51 .app_cache_dir()
52 .map_err(|error| format!("Failed to resolve app cache dir: {error}"))?;
53 let export_dir = cache_dir.join("miniapp-slide-export");
54 std::fs::create_dir_all(&export_dir)
55 .map_err(|error| format!("Failed to create export cache dir: {error}"))?;
56 let file_path = export_dir.join(format!("slide-{}.html", Uuid::new_v4()));
57 std::fs::write(&file_path, html)
58 .map_err(|error| format!("Failed to write export HTML: {error}"))?;
59 let url = tauri::Url::from_file_path(&file_path)
60 .map_err(|_| "Failed to build file URL for export webview".to_string())?;
61 Ok((url, file_path))
62}
63
64fn ensure_export_host_window<R: tauri::Runtime>(
65 app: &AppHandle<R>,

Callers 1

with_export_webviewFunction · 0.85

Calls 3

create_dir_allFunction · 0.85
pathMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected