vanilladocs
vanillapunch.com
API / resource/bunchasset

resource/bunchasset

묶음 애셋. (원본 resource/bunchasset.js 의 BunchAsset)

  • 원본은 BlobAsset 을 상속하고 애셋 타입만 bunch 로 바꾼 뼈대다. 읽기는 BlobAsset 과 같다. (묶음을 푸는 일은 아직 없다)
  • 러스트 판은 상속 대신 같은 함수를 가진 구조체이고, 애셋 타입이 AssetType::Bunch 다.

Bunch asset. (BunchAsset of the original resource/bunchasset.js)

  • In the original it is a skeleton that inherits BlobAsset and only changes the asset type to bunch. Reading is the same as BlobAsset. (unpacking the bunch is not done yet)
  • In the Rust version it is a struct with the same functions instead of inheritance, and the asset type is AssetType::Bunch.

BunchAssetstruct traits Default, Asset

짝Counterpart: vanilla.js BunchAsset소스source

묶음 애셋.

  • 읽기와 꺼내기는 BlobAsset 과 같고 애셋 타입만 bunch 다.

Bunch asset.

  • Reading and taking out are the same as BlobAsset, and only the asset type is bunch.
예제Example가진 바이트로 읽고 애셋 타입 보기Read with bytes in hand and check the asset type
use vanilla::{Asset, AssetType, BunchAsset};

let mut bunch_asset = BunchAsset::new();
assert_eq!(bunch_asset.get_asset_base().get_asset_type(), AssetType::Bunch);
bunch_asset.load_from_bytes("pack.bunch", vec![1, 2, 3]);
assert!(bunch_asset.is_loaded());
assert_eq!(bunch_asset.get_blob().expect("bytes").as_slice(), &[1, 2, 3]);
생성자constructorpub fn new() -> BunchAsset#0.3.2 부터since 0.3.2소스source

생성. (애셋 타입 bunch)

Creates one. (asset type bunch)

반환ReturnsBunchAsset 요청 전의 빈 묶음 애셋.Empty bunch asset before a request.

짝Counterpart: vanilla.js BunchAsset.constructor

메서드methodpub fn load(&mut self, engine: &Engine, asset_path: &str) -> AssetLoadHandle#0.3.2 부터since 0.3.2소스source

읽기 요청. (원본 load = BlobAsset.load, await 할 수 있는 읽기 손잡이를 돌려준다)

  • 이미 요청했으면 다시 하지 않고 처음 손잡이를 돌려준다.

Requests a read. (the original load = BlobAsset.load, returns a load handle that can be awaited)

  • If already requested, does not request again and returns the first handle.
engine&Engine
바이트를 부탁할 엔진.Engine to ask for the bytes.
asset_path&str
애셋 경로. (데스크탑은 애셋 폴더 기준, 웹은 asset_base_url 기준, data: 주소도 된다)Asset path. (relative to the asset folder on desktop, to asset_base_url on the web; data: URLs also work)

반환ReturnsAssetLoadHandle 읽기 손잡이. (데스크탑은 그 자리에서 읽혀 끝나 있다. 못 읽으면 실패로 끝난다)Load handle. (on desktop it is read on the spot and already finished. Finishes in failure if it cannot be read)

짝Counterpart: vanilla.js BunchAsset.load

메서드methodpub fn load_from_bytes(&mut self, asset_path: &str, bytes: Vec<u8>)#0.3.2 부터since 0.3.2소스source

이미 가진 바이트로 읽기.

  • 이미 요청한 손잡이가 있어도 새 손잡이로 바꾼다.

Reads from bytes already in hand.

  • Replaces it with a new handle even if a requested handle exists.
asset_path&str
적어 둘 경로.Path to record.
bytesVec<u8>
애셋 바이트.Asset bytes.

짝Counterpart: vanilla.js BlobAsset.loadFromBytes

메서드methodpub fn unload(&mut self)#0.3.2 부터since 0.3.2소스source

내리기.

Unloads.

짝Counterpart: vanilla.js Asset.unload

메서드methodpub fn get_blob(&self) -> Option<Rc<Vec<u8>>>#0.3.2 부터since 0.3.2소스source

바이트. (원본 getBlob. 다 읽히기 전이면 None)

Bytes. (the original getBlob. None before it is fully read)

반환ReturnsOption<Rc<Vec<u8>>> 읽은 바이트. 요청 전이거나 읽는 중이거나 실패했으면 None.Loaded bytes. None before a request, while loading, or on failure.

짝Counterpart: vanilla.js BlobAsset.getBlob