pub struct AssetBundle {
pub header: BundleHeader,
pub blocks: Vec<CompressionBlock>,
pub nodes: Vec<DirectoryNode>,
pub files: Vec<BundleFileInfo>,
pub assets: Vec<SerializedFile>,
pub asset_names: Vec<String>,
/* private fields */
}Expand description
A Unity AssetBundle
This structure represents a complete Unity AssetBundle with all its metadata, compression information, and contained assets.
Fields§
§header: BundleHeaderBundle header
blocks: Vec<CompressionBlock>Compression blocks
nodes: Vec<DirectoryNode>Directory nodes
files: Vec<BundleFileInfo>File information
assets: Vec<SerializedFile>Contained assets
asset_names: Vec<String>Asset file names within the bundle (aligned with assets indices).
Implementations§
Source§impl AssetBundle
impl AssetBundle
Sourcepub fn new(header: BundleHeader, data: Vec<u8>) -> AssetBundle
pub fn new(header: BundleHeader, data: Vec<u8>) -> AssetBundle
Create a new AssetBundle
Sourcepub fn data_checked(&self) -> Result<&[u8], BinaryError>
pub fn data_checked(&self) -> Result<&[u8], BinaryError>
Get the decompressed bundle data, decompressing UnityFS blocks on demand.
Sourcepub fn data(&self) -> &[u8] ⓘ
pub fn data(&self) -> &[u8] ⓘ
Get the raw bundle data if already decompressed, otherwise returns an empty slice.
Sourcepub fn data_arc(&self) -> Result<Arc<[u8]>, BinaryError>
pub fn data_arc(&self) -> Result<Arc<[u8]>, BinaryError>
Get a shared reference to the decompressed bundle data, decompressing on demand.
Sourcepub fn is_compressed(&self) -> bool
pub fn is_compressed(&self) -> bool
Check if the bundle is compressed
Sourcepub fn file_count(&self) -> usize
pub fn file_count(&self) -> usize
Get the number of files in the bundle
Sourcepub fn asset_count(&self) -> usize
pub fn asset_count(&self) -> usize
Get the number of assets in the bundle
Sourcepub fn find_file(&self, name: &str) -> Option<&BundleFileInfo>
pub fn find_file(&self, name: &str) -> Option<&BundleFileInfo>
Find a file by name
Sourcepub fn find_node(&self, name: &str) -> Option<&DirectoryNode>
pub fn find_node(&self, name: &str) -> Option<&DirectoryNode>
Find a node by name
Sourcepub fn file_names(&self) -> Vec<&str>
pub fn file_names(&self) -> Vec<&str>
Get all file names
Sourcepub fn node_names(&self) -> Vec<&str>
pub fn node_names(&self) -> Vec<&str>
Get all node names
Sourcepub fn extract_file_data(
&self,
file: &BundleFileInfo,
) -> Result<Vec<u8>, BinaryError>
pub fn extract_file_data( &self, file: &BundleFileInfo, ) -> Result<Vec<u8>, BinaryError>
Extract data for a specific file
pub fn extract_file_slice( &self, file: &BundleFileInfo, ) -> Result<&[u8], BinaryError>
Sourcepub fn extract_node_data(
&self,
node: &DirectoryNode,
) -> Result<Vec<u8>, BinaryError>
pub fn extract_node_data( &self, node: &DirectoryNode, ) -> Result<Vec<u8>, BinaryError>
Extract data for a specific node
pub fn extract_node_slice( &self, node: &DirectoryNode, ) -> Result<&[u8], BinaryError>
Sourcepub fn statistics(&self) -> BundleStatistics
pub fn statistics(&self) -> BundleStatistics
Get bundle statistics
Sourcepub fn validate(&self) -> Result<(), BinaryError>
pub fn validate(&self) -> Result<(), BinaryError>
Validate bundle consistency
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AssetBundle
impl !RefUnwindSafe for AssetBundle
impl Send for AssetBundle
impl Sync for AssetBundle
impl Unpin for AssetBundle
impl !UnwindSafe for AssetBundle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more