Struct vcd::Header

source ·
#[non_exhaustive]
pub struct Header { pub date: Option<String>, pub version: Option<String>, pub timescale: Option<(u32, TimescaleUnit)>, pub items: Vec<ScopeItem>, }
Expand description

Structure containing the data from the header of a VCD file.

A Header can be parsed from VCD with Parser::parse_header, or create an empty Header with Header::default.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§date: Option<String>

$date text

§version: Option<String>

$version text

§timescale: Option<(u32, TimescaleUnit)>

Parsed $timescale indicating the time unit used in the file

§items: Vec<ScopeItem>

Top-level variables, scopes, and comments

Implementations§

source§

impl Header

source

pub fn find_scope<S>(&self, path: &[S]) -> Option<&Scope>where S: Borrow<str>,

Find the scope object at a specified path.

Example
let mut parser = vcd::Parser::new(&b"
$scope module a $end
$scope module b $end
$var integer 16 n0 counter $end
$upscope $end
$upscope $end
$enddefinitions $end
"[..]);
let header = parser.parse_header().unwrap();
let scope = header.find_scope(&["a", "b"]).unwrap();
assert_eq!(scope.identifier, "b");
source

pub fn find_var<S>(&self, path: &[S]) -> Option<&Var>where S: Borrow<str>,

Find the variable object at a specified path.

Example
let mut parser = vcd::Parser::new(&b"
$scope module a $end
$scope module b $end
$var integer 16 n0 counter $end
$upscope $end
$upscope $end
$enddefinitions $end
"[..]);
let header = parser.parse_header().unwrap();
let var = header.find_var(&["a", "b", "counter"]).unwrap();
assert_eq!(var.reference, "counter");

Trait Implementations§

source§

impl Debug for Header

source§

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

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

impl Default for Header

source§

fn default() -> Header

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

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.