pub fn is_virtual_path(path: &str) -> boolExpand description
Check if a path is a virtual path.
Examples found in repository?
examples/collections.rs (line 40)
14fn main() -> Result<()> {
15 let db_path = std::env::temp_dir().join("qmd_collections.db");
16 let _ = std::fs::remove_file(&db_path);
17 let store = Store::open(&db_path)?;
18
19 let now = chrono::Utc::now().to_rfc3339();
20 for (name, content) in SAMPLE_DOCS {
21 let hash = Store::hash_content(content);
22 let title = Store::extract_title(content);
23 store.insert_content(&hash, content, &now)?;
24 store.insert_document("samples", name, &title, &hash, &now, &now)?;
25 }
26
27 // List files
28 println!("Files in 'samples':");
29 for (path, title, _, size) in store.list_files("samples", None)? {
30 println!(" {} - {} ({} bytes)", path, title, size);
31 }
32
33 // Virtual path parsing
34 println!("\nVirtual path parsing:");
35 for path in [
36 "qmd://samples/rust-basics.md",
37 "/local/file.md",
38 "relative.md",
39 ] {
40 if is_virtual_path(path) {
41 if let Some((coll, file)) = parse_virtual_path(path) {
42 println!(" {} -> [{}] {}", path, coll, file);
43 }
44 } else {
45 println!(" {} -> local", path);
46 }
47 }
48
49 let _ = std::fs::remove_file(&db_path);
50 Ok(())
51}