Metadata

Struct Metadata 

Source
pub struct Metadata {
    pub keywords: KeywordMap,
    pub delimiter: char,
}
Expand description

Contains keyword-value pairs and delimiter from the TEXT segment of an FCS file

The TEXT segment contains all metadata about the FCS file, including:

  • File information (GUID, filename, cytometer type)
  • Data structure information (number of events, parameters, data type, byte order)
  • Parameter metadata (names, labels, ranges, transforms)
  • Optional information (compensation matrices, timestamps, etc.)

Keywords are stored in a hashmap for fast lookup, with type-safe accessors for different keyword types (integer, float, string, byte, mixed).

Fields§

§keywords: KeywordMap§delimiter: char

Implementations§

Source§

impl Metadata

Source

pub fn new() -> Self

Source

pub fn print_sorted_by_keyword(&self)

Prints all keywords sorted alphabetically by key name

This is a debugging utility that displays all keyword-value pairs in the metadata, sorted for easy reading.

Source

pub fn from_mmap(mmap: &Mmap, header: &Header) -> Self

Reads the text segment of the fcs file and returns an Metadata struct

Uses memchr for fast delimiter finding (5-10x faster than byte-by-byte iteration)

Source

pub fn validate_text_segment_keywords(&self, header: &Header) -> Result<()>

Check that required keys are present in the TEXT segment of the metadata

§Errors

Will return Err if:

  • any of the required keywords are missing from the keywords hashmap
  • the number of parameters can’t be obtained from the $PAR keyword in the TEXT section
  • any keyword has a Pn[X] value where n is greater than the number of parameters indicated by the $PAR keyword
Source

pub fn validate_guid(&mut self)

Validates if a GUID is present in the file’s metadata, and if not, generates a new one.

Source

pub fn get_number_of_parameters(&self) -> Result<&usize>

Return the number of parameters in the file from the $PAR keyword in the metadata TEXT section

§Errors

Will return Err if the $PAR keyword is not present in the metadata keywords hashmap

Source

pub fn get_number_of_events(&self) -> Result<&usize>

Return the number of events in the file from the $TOT keyword in the metadata TEXT section

§Errors

Will return Err if the $TOT keyword is not present in the metadata keywords hashmap

Source

pub fn get_data_type(&self) -> Result<&FcsDataType>

Return the data type from the $DATATYPE keyword in the metadata TEXT section, unwraps and returns it if it exists.

§Errors

Will return Err if the $DATATYPE keyword is not present in the metadata keywords hashmap

Source

pub fn get_data_type_for_channel( &self, parameter_number: usize, ) -> Result<FcsDataType>

Get the data type for a specific channel/parameter (FCS 3.2+)

First checks for $PnDATATYPE keyword to see if this parameter has a specific data type override. If not found, falls back to the default $DATATYPE keyword.

§Arguments
  • parameter_number - 1-based parameter index
§Errors

Will return Err if neither $PnDATATYPE nor $DATATYPE is present

Source

pub fn calculate_bytes_per_event(&self) -> Result<usize>

Calculate the total bytes per event by summing bytes per parameter

Uses $PnB (bits per parameter) divided by 8 to get bytes per parameter, then sums across all parameters. This is more accurate than using $DATATYPE which only provides a default value.

§Errors

Will return Err if the number of parameters cannot be determined or if any required $PnB keyword is missing

Source

pub fn get_bytes_per_parameter(&self, parameter_number: usize) -> Result<usize>

Get bytes per parameter for a specific channel

Uses $PnB (bits per parameter) divided by 8 to get bytes per parameter.

§Arguments
  • parameter_number - 1-based parameter index
§Errors

Will return Err if the $PnB keyword is missing for this parameter

Source

pub fn get_byte_order(&self) -> Result<&ByteOrder>

Return the byte order from the $BYTEORD keyword in the metadata TEXT section, unwraps and returns it if it exists.

§Errors

Will return Err if the $BYTEORD keyword is not present in the keywords hashmap

Source

pub fn get_integer_keyword(&self, keyword: &str) -> Result<&IntegerKeyword>

Returns a keyword that holds numeric data from the keywords hashmap, if it exists

§Errors

Will return Err if the keyword is not present in the keywords hashmap

Source

pub fn get_float_keyword(&self, keyword: &str) -> Result<&FloatKeyword>

Returns a keyword that holds numeric data from the keywords hashmap, if it exists

§Errors

Will return Err if the keyword is not present in the keywords hashmap

Source

pub fn get_string_keyword(&self, keyword: &str) -> Result<&StringKeyword>

Returns a keyword that holds string data from the keywords hashmap, if it exists

§Errors

Will return Err if the keyword is not present in the keywords hashmap

Source

pub fn get_byte_keyword(&self, keyword: &str) -> Result<&ByteKeyword>

Returns a keyword that holds byte-orientation data from the keywords hashmap, if it exists

§Errors

Will return Err if the keyword is not present in the keywords hashmap

Source

pub fn get_mixed_keyword(&self, keyword: &str) -> Result<&MixedKeyword>

Returns a keyword that holds mixed data from the keywords hashmap, if it exists

§Errors

Will return Err if the keyword is not present in the keywords hashmap

Source

pub fn get_parameter_string_metadata( &self, parameter_number: usize, suffix: &str, ) -> Result<&StringKeyword>

General function to get a given parameter’s string keyword from the file’s metadata (e.g. $PnN or $PnS)

§Errors

Will return Err if the keyword is not present in the keywords hashmap

Source

pub fn get_parameter_numeric_metadata( &self, parameter_number: usize, suffix: &str, ) -> Result<&IntegerKeyword>

Generic function to get a given parameter’s integer keyword from the file’s metadata (e.g. $PnN, $PnS, $PnDATATYPE)

§Errors

Will return Err if the keyword is not present in the keywords hashmap

Source

pub fn get_parameter_excitation_wavelength( &self, parameter_number: usize, ) -> Result<Option<usize>>

Get excitation wavelength(s) for a parameter from $PnL keyword Returns the first wavelength if multiple are present (for co-axial lasers)

§Errors

Will return Err if the keyword is not present in the keywords hashmap

Source

pub fn get_parameter_channel_name( &self, parameter_number: usize, ) -> Result<&str>

Return the name of the parameter’s channel from the $PnN keyword in the metadata TEXT section, where n is the provided parameter index (1-based)

§Errors

Will return Err if the keyword is not present in the keywords hashmap

Source

pub fn get_parameter_label(&self, parameter_number: usize) -> Result<&str>

Return the label name of the parameter from the $PnS keyword in the metadata TEXT section, where n is the provided parameter number

§Errors

Will return Err if the keyword is not present in the keywords hashmap

Source

pub fn get_metadata_as_json_string(&self) -> Result<String>

Transform the metadata keywords hashmap into a JSON object via serde

§Errors

Will return Err if the metadata keywords hashmap is empty

Source

pub fn insert_string_keyword(&mut self, key: String, value: String)

Insert or update a string keyword in the metadata

Trait Implementations§

Source§

impl Clone for Metadata

Source§

fn clone(&self) -> Metadata

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Metadata

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Metadata

Source§

fn default() -> Metadata

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Metadata

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Metadata

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Key for T
where T: Clone,

Source§

fn align() -> usize

The alignment necessary for the key. Must return a power of two.
Source§

fn size(&self) -> usize

The size of the key in bytes.
Source§

unsafe fn init(&self, ptr: *mut u8)

Initialize the key in the given memory location. Read more
Source§

unsafe fn get<'a>(ptr: *const u8) -> &'a T

Get a reference to the key from the given memory location. Read more
Source§

unsafe fn drop_in_place(ptr: *mut u8)

Drop the key in place. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> PlanCallbackArgs for T

Source§

impl<T> PlanCallbackOut for T