read_asset

Function read_asset 

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

Open and read 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::read_asset;
use std::io::Read;

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

let asset_path = "textures/readme.md";

let buffer = read_asset(&sk_info, asset_path).expect("File readme should be readable");
assert!(buffer.starts_with(b"# Images"));