Skip to main content

csv_rs/
lib.rs

1// Copyright (C) Hygon Info Technologies Ltd.
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6/// CSV certificates interface.
7pub mod certs;
8
9/// CSV API interface.
10pub mod api;
11
12/// Crypto module for key and signature.
13pub mod crypto;
14
15/// Error module.
16pub mod error;
17
18pub mod session;
19
20mod util;
21
22pub use util::cached_chain;
23
24use std::io::Write;
25
26use serde::{Deserialize, Serialize};
27
28/// Information about the CSV platform version.
29#[repr(C)]
30#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
31pub struct Version {
32    /// The major version number.
33    pub major: u8,
34
35    /// The minor version number.
36    pub minor: u8,
37}
38
39impl std::fmt::Display for Version {
40    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
41        write!(f, "{}.{}", self.major, self.minor)
42    }
43}
44
45impl From<u16> for Version {
46    fn from(v: u16) -> Self {
47        Self {
48            major: ((v & 0xF0) >> 4) as u8,
49            minor: (v & 0x0F) as u8,
50        }
51    }
52}
53
54/// A description of the CSV platform's build information.
55#[repr(C)]
56#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
57pub struct Build {
58    /// The version information.
59    pub version: Version,
60
61    /// The build number.
62    pub build: u8,
63}
64
65pub struct Body;