Struct Schema

Source
pub struct Schema {
    pub version: String,
    pub metadata: Metadata,
    pub bit_order: BitOrder,
    pub conditional_offsets: Vec<ConditionalOffset>,
    pub analysis: AnalysisConfig,
    pub root: Group,
}
Expand description

Represents the complete schema configuration for a bit-packed structure to analyze.

The schema defines the layout and structure of the bit-packed data format. It includes versioning, metadata, bit order configuration, and the root group definition.

§Examples

use struct_compression_analyzer::schema::Schema;
use std::path::Path;

let schema = Schema::load_from_file(Path::new("schema.yaml")).unwrap();

Fields§

§version: String

Schema version. Currently only 1.0 is supported

§metadata: Metadata

Contains user-provided metadata about the schema

§bit_order: BitOrder

Determines whether the bytes are read from the most significant bit (MSB) or least significant bit (LSB) first.

  • Msb: First bit is the high bit (7)
  • Lsb: First bit is the low bit (0)
§conditional_offsets: Vec<ConditionalOffset>

Conditional offsets for the schema

§analysis: AnalysisConfig

Configuration for analysis operations and output grouping

§root: Group

The root group of the schema

Implementations§

Source§

impl Schema

Source

pub fn from_yaml(content: &str) -> Result<Self, SchemaError>

Creates a new Schema from a YAML string.

§Arguments
  • content - YAML string containing the schema definition
§Returns
  • Result<Self, SchemaError> - Resulting schema or error
Source

pub fn load_from_file(path: &Path) -> Result<Self, SchemaError>

Loads and parses a schema from a YAML file.

§Arguments
  • path - Path to the schema YAML file
§Returns
  • Result<Self, SchemaError> - Resulting schema or error
Source

pub fn ordered_field_and_group_paths(&self) -> Vec<String>

Collects a list of field (and group) paths in schema order.

§Examples

Given the following schema:

root:
  type: group
  fields:
    header:
      type: group
      fields:
        mode: 2
        partition: 4
    colors:
      type: group
      fields:
        r:
          type: array
          field: R
        g:
          type: array
          field: G
        b:
          type: array
          field: B

The resulting field paths would be:

  • “header”
  • “colors”
  • “colors.r”
  • “colors.g”
  • “colors.b”
§Returns
  • Vec<String> - List of field paths in schema order

Trait Implementations§

Source§

impl Debug for Schema

Source§

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

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

impl Default for Schema

Source§

fn default() -> Schema

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

impl<'de> Deserialize<'de> for Schema

Source§

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

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

§

impl Freeze for Schema

§

impl RefUnwindSafe for Schema

§

impl Send for Schema

§

impl Sync for Schema

§

impl Unpin for Schema

§

impl UnwindSafe for Schema

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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, 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,