Struct SpecificationFile

Source
pub struct SpecificationFile {
    pub datecode: i32,
    pub texts: Vec<String>,
    pub localized_texts: Vec<LocalizedText>,
    pub units: Vec<Unit>,
    pub device_templates: Vec<DeviceTemplate>,
    pub packet_templates: Vec<PacketTemplate>,
}
Expand description

Contains the information from a VSF1 file.

Fields§

§datecode: i32

Date of VSF creation in format ‘YYYMMDD’

§texts: Vec<String>

List of texts.

§localized_texts: Vec<LocalizedText>

List of localized texts.

§units: Vec<Unit>

List of units.

§device_templates: Vec<DeviceTemplate>

List of device templates.

§packet_templates: Vec<PacketTemplate>

List of packet templates.

Implementations§

Source§

impl SpecificationFile

Source

pub fn from_bytes(bytes: &[u8]) -> Result<SpecificationFile, Error>

Construct a new SpecificationFile from a byte slice of VSF1 data.

Source

pub fn new_default() -> SpecificationFile

Construct a new SpecificationFile from the embedded default VSF data.

Source

pub fn text_by_index(&self, idx: &TextIndex) -> &str

Get text by its index.

Source

pub fn localized_text_by_index( &self, idx: &LocalizedTextIndex, language: Language, ) -> &str

Get localized text by its index and language.

Source

pub fn unit_family_by_id(&self, id: &UnitFamilyId) -> UnitFamily

Get UnitFamily by its ID.

Source

pub fn unit_by_id(&self, id: &UnitId) -> &Unit

Get Unit by its index.

Source

pub fn type_by_id(&self, id: &TypeId) -> Type

Get Type by its ID.

Source

pub fn find_device_template( &self, self_address: u16, peer_address: u16, ) -> Option<&DeviceTemplate>

Find a DeviceTemplate matching the self and peer addresses.

Source

pub fn find_packet_template( &self, destination_address: u16, source_address: u16, command: u16, ) -> Option<&PacketTemplate>

Find a PacketTemplate matching the destination and source addresses as well as the command.

Trait Implementations§

Source§

impl Debug for SpecificationFile

Source§

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

Formats the value using the given formatter. 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> 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, 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.