pub struct TrxFile<P: TrxScalar> { /* private fields */ }Expand description
Core TRX container, generic over the position scalar type P.
Owns all memory-mapped (or heap-allocated) backings. Typed views borrow
from self — no explicit lifetime annotations needed.
§Field ordering
_tempdir must be declared AFTER mmap fields so it is dropped last,
keeping the temp directory alive while mmaps reference files within it.
Implementations§
Source§impl<P: TrxScalar> TrxFile<P>
impl<P: TrxScalar> TrxFile<P>
pub fn header(&self) -> &Header
Sourcepub fn with_updated_header(self, header: Header) -> Self
pub fn with_updated_header(self, header: Header) -> Self
Return a new TrxFile with the header replaced. All data arrays and
positions are shared by reference-counted backing (owned copies).
Sourcepub fn positions_2d(&self) -> TypedView2D<'_, P>
pub fn positions_2d(&self) -> TypedView2D<'_, P>
Positions as a TypedView2D with 3 columns.
Sourcepub fn positions_bytes(&self) -> &[u8] ⓘ
pub fn positions_bytes(&self) -> &[u8] ⓘ
Raw position bytes for direct GPU buffer upload.
Sourcepub fn nb_vertices(&self) -> usize
pub fn nb_vertices(&self) -> usize
Number of vertices (points) across all streamlines.
Sourcepub fn offsets(&self) -> &[u32]
pub fn offsets(&self) -> &[u32]
Offsets as a slice of u32. Length is nb_streamlines + 1.
The i-th streamline spans positions[offsets[i]..offsets[i+1]].
pub fn offsets_vec(&self) -> Vec<u32>
Sourcepub fn nb_streamlines(&self) -> usize
pub fn nb_streamlines(&self) -> usize
Number of streamlines.
Sourcepub fn streamline(&self, i: usize) -> &[[P; 3]]
pub fn streamline(&self, i: usize) -> &[[P; 3]]
Get the i-th streamline as a slice of [P; 3] points.
Sourcepub fn streamlines(&self) -> StreamlineIter<'_, P> ⓘ
pub fn streamlines(&self) -> StreamlineIter<'_, P> ⓘ
Iterate over all streamlines.
Sourcepub fn streamline_lengths(&self) -> Vec<usize>
pub fn streamline_lengths(&self) -> Vec<usize>
Length (number of points) of each streamline.
Sourcepub fn dps<T: Pod>(&self, name: &str) -> Result<TypedView2D<'_, T>>
pub fn dps<T: Pod>(&self, name: &str) -> Result<TypedView2D<'_, T>>
Get a DPS (data-per-streamline) array cast to type T.
Sourcepub fn dpv<T: Pod>(&self, name: &str) -> Result<TypedView2D<'_, T>>
pub fn dpv<T: Pod>(&self, name: &str) -> Result<TypedView2D<'_, T>>
Get a DPV (data-per-vertex) array cast to type T.
Sourcepub fn dpg<T: Pod>(&self, group: &str, name: &str) -> Result<TypedView2D<'_, T>>
pub fn dpg<T: Pod>(&self, group: &str, name: &str) -> Result<TypedView2D<'_, T>>
Get a DPG (data-per-group) array cast to type T.
Sourcepub fn group_names(&self) -> Vec<&str>
pub fn group_names(&self) -> Vec<&str>
List group names.
Sourcepub fn dpg_group_names(&self) -> Vec<&str>
pub fn dpg_group_names(&self) -> Vec<&str>
List DPG group names.
pub fn iter_dps(&self) -> impl Iterator<Item = (&str, DataArrayInfo)> + '_
pub fn iter_dpv(&self) -> impl Iterator<Item = (&str, DataArrayInfo)> + '_
Sourcepub fn iter_groups(&self) -> impl Iterator<Item = (&str, &[u32])> + '_
pub fn iter_groups(&self) -> impl Iterator<Item = (&str, &[u32])> + '_
Iterate over groups, yielding (name, &[u32]) pairs.
§Safety note
This performs a raw byte reinterpretation via cast_slice::<u32>().
If the on-disk group dtype is not uint32 (e.g. int64), the
returned slice will contain mangled values. Prefer
[group_entries_owned] which handles dtype conversion correctly.
pub fn dpg_entries(&self, group: &str) -> Result<Vec<(String, DataArrayInfo)>>
pub fn dps_info(&self, name: &str) -> Result<DataArrayInfo>
pub fn dps_array(&self, name: &str) -> Result<&DataArray>
pub fn dpv_info(&self, name: &str) -> Result<DataArrayInfo>
pub fn dpv_array(&self, name: &str) -> Result<&DataArray>
pub fn group_info(&self, name: &str) -> Result<DataArrayInfo>
pub fn group_array(&self, name: &str) -> Result<&DataArray>
pub fn dpg_info(&self, group: &str, name: &str) -> Result<DataArrayInfo>
pub fn dpg_array(&self, group: &str, name: &str) -> Result<&DataArray>
pub fn scalar_dps_f32(&self, name: &str) -> Result<Vec<f32>>
pub fn scalar_dpv_f32(&self, name: &str) -> Result<Vec<f32>>
pub fn group_entries_owned(&self) -> Vec<(String, Vec<u32>)>
Sourcepub fn save_to_directory(&self, path: &Path) -> Result<()>
pub fn save_to_directory(&self, path: &Path) -> Result<()>
Save to a directory. The offsets.* array is written as uint32 if
every offset fits in u32, otherwise as uint64.
Sourcepub fn save_to_zip(&self, path: &Path) -> Result<()>
pub fn save_to_zip(&self, path: &Path) -> Result<()>
Save to a .trx zip archive. All entries are Stored (no compression):
DEFLATE rarely pays off on float-heavy tractography data. The
offsets.* array width is auto-picked (uint32 if it fits, else uint64).
Sourcepub fn save_to_zip_deflate_groups(&self, path: &Path) -> Result<()>
pub fn save_to_zip_deflate_groups(&self, path: &Path) -> Result<()>
Save to a .trx zip archive, applying DEFLATE only to groups/ entries.
Everything else is Stored.
Sourcepub fn save_to_zip_stored(&self, path: &Path) -> Result<()>
pub fn save_to_zip_stored(&self, path: &Path) -> Result<()>
Deprecated alias for [save_to_zip] — kept for backward compatibility.
Sourcepub fn save(&self, path: &Path) -> Result<()>
pub fn save(&self, path: &Path) -> Result<()>
Save — auto-detects format from extension (.trx = zip, otherwise directory).
pub fn is_file_backed(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl<P> Freeze for TrxFile<P>
impl<P> RefUnwindSafe for TrxFile<P>where
P: RefUnwindSafe,
impl<P> Send for TrxFile<P>where
P: Send,
impl<P> Sync for TrxFile<P>where
P: Sync,
impl<P> Unpin for TrxFile<P>where
P: Unpin,
impl<P> UnsafeUnpin for TrxFile<P>
impl<P> UnwindSafe for TrxFile<P>where
P: 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
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.