Skip to main content

statime_wire/
lib.rs

1//! General datastructures as defined by the ptp spec
2#![no_std]
3
4#[cfg(feature = "std")]
5extern crate std;
6
7use core::fmt::Debug;
8
9mod common;
10mod messages;
11
12pub use common::*;
13pub use messages::*;
14
15/// An error that occured during processing in this crate.
16#[derive(Clone, Debug)]
17pub enum Error {
18    /// The provided buffer was too short for the requested operation.
19    BufferTooShort,
20    /// The data provided is invalid for the requested operation.
21    Invalid,
22}
23
24impl core::fmt::Display for Error {
25    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
26        match self {
27            Error::BufferTooShort => f.write_str("a buffer is too short"),
28            Error::Invalid => f.write_str("an invariant was violated"),
29        }
30    }
31}
32
33#[cfg(feature = "std")]
34impl std::error::Error for Error {}