libyaml/
version_directive.rs

1use std::mem;
2
3use crate::sys;
4
5/// Document version directive.
6#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
7pub struct VersionDirective(pub u8, pub u8);
8
9impl VersionDirective {
10    /// Convert from `yaml_version_directive_t`.
11    pub fn from_raw(raw: sys::yaml_version_directive_t) -> Self {
12        Self(raw.major as _, raw.minor as _)
13    }
14
15    /// Convert to `yaml_version_directive_t`.
16    pub fn into_raw(self) -> sys::yaml_version_directive_t {
17        let mut ret: sys::yaml_version_directive_t = unsafe { mem::MaybeUninit::zeroed().assume_init() };
18        ret.major = self.0 as _;
19        ret.minor = self.1 as _;
20        ret
21    }
22}