pub struct SsbhArray<T> {
pub elements: Vec<T>,
}
Expand description
A fixed-size collection of contiguous elements consisting of a relative offset to the array elements and an element count.
use binrw::BinRead;
use ssbh_lib::{SsbhArray, Matrix4x4};
use ssbh_write::SsbhWrite;
#[derive(BinRead, SsbhWrite)]
struct Transforms {
array_relative_offset: u64,
array_item_count: u64
}
This can instead be expressed as the following struct with an explicit array item type. The generated parsing and exporting code will correctly read and write the array data from the appropriate offset.
use binrw::BinRead;
use ssbh_lib::{SsbhArray, Matrix4x4};
use ssbh_write::SsbhWrite;
#[derive(BinRead, SsbhWrite)]
struct Transforms {
data: SsbhArray<Matrix4x4>,
}
Fields§
§elements: Vec<T>
Implementations§
Trait Implementations§
source§impl<T> BinRead for SsbhArray<T>
impl<T> BinRead for SsbhArray<T>
source§fn read_options<R: Read + Seek>(
reader: &mut R,
endian: Endian,
_args: Self::Args<'_>,
) -> BinResult<Self>
fn read_options<R: Read + Seek>( reader: &mut R, endian: Endian, _args: Self::Args<'_>, ) -> BinResult<Self>
source§fn read_be<R>(reader: &mut R) -> Result<Self, Error>
fn read_be<R>(reader: &mut R) -> Result<Self, Error>
Read
Self
from the reader using default arguments and assuming
big-endian byte order. Read moresource§fn read_le<R>(reader: &mut R) -> Result<Self, Error>
fn read_le<R>(reader: &mut R) -> Result<Self, Error>
Read
Self
from the reader using default arguments and assuming
little-endian byte order. Read moresource§fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
Read
T
from the reader assuming native-endian byte order. Read moresource§fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
Read
Self
from the reader, assuming big-endian byte order, using the
given arguments. Read moresource§impl<T> FromIterator<T> for SsbhArray<T>
impl<T> FromIterator<T> for SsbhArray<T>
source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
source§impl<T: PartialEq> PartialEq for SsbhArray<T>
impl<T: PartialEq> PartialEq for SsbhArray<T>
source§impl<T: SsbhWrite> SsbhWrite for SsbhArray<T>
impl<T: SsbhWrite> SsbhWrite for SsbhArray<T>
source§fn ssbh_write<W: Write + Seek>(
&self,
writer: &mut W,
data_ptr: &mut u64,
) -> Result<()>
fn ssbh_write<W: Write + Seek>( &self, writer: &mut W, data_ptr: &mut u64, ) -> Result<()>
Writes the byte representation of
self
to writer
.
data_ptr
is assumed to be the absolute offset where the next data stored behind an offset will be written.
Struct that contains no offsets as fields can skip updating data_ptr
. Read moresource§fn size_in_bytes(&self) -> u64
fn size_in_bytes(&self) -> u64
The offset in bytes between successive elements in an array of this type.
This should include any alignment or padding.
source§fn alignment_in_bytes() -> u64
fn alignment_in_bytes() -> u64
The alignment for pointers of this type, which is useful for offset calculations.
impl<T: Eq> Eq for SsbhArray<T>
Auto Trait Implementations§
impl<T> Freeze for SsbhArray<T>
impl<T> RefUnwindSafe for SsbhArray<T>where
T: RefUnwindSafe,
impl<T> Send for SsbhArray<T>where
T: Send,
impl<T> Sync for SsbhArray<T>where
T: Sync,
impl<T> Unpin for SsbhArray<T>where
T: Unpin,
impl<T> UnwindSafe for SsbhArray<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)