Function open_asset

Source
pub fn open_asset(
    _sk_info: &Option<Rc<RefCell<SkInfo>>>,
    asset_path: impl AsRef<Path>,
) -> Option<File>
Expand description

Open an asset like a file

  • sk_info - The SkInfo smart pointer
  • asset_path - The path to the asset.

Returns a File if the asset was opened successfully, None otherwise.

ยงExamples

use stereokit_rust::tools::os_api::open_asset;
use std::io::Read;

let sk_info  = Some(sk.get_sk_info_clone());

let asset_path = "textures/readme.md";

let mut file = open_asset(&sk_info, asset_path).expect("File readme should be opened");

let mut buffer = String::new();
file.read_to_string(&mut buffer).expect("File readme should be read");
assert!(buffer.starts_with("# Images"));