AsyncHttp(ApiAsyncHttpHandlerFn),
}
+#[cfg(feature = "test-harness")]
+impl Eq for ApiHandler {}
+
+#[cfg(feature = "test-harness")]
+impl PartialEq for ApiHandler {
+ fn eq(&self, rhs: &Self) -> bool {
+ unsafe {
+ match (self, rhs) {
+ (ApiHandler::Sync(l), ApiHandler::Sync(r)) => {
+ core::mem::transmute::<_, usize>(l) == core::mem::transmute::<_, usize>(r)
+ }
+ (ApiHandler::Async(l), ApiHandler::Async(r)) => {
+ core::mem::transmute::<_, usize>(l) == core::mem::transmute::<_, usize>(r)
+ }
+ (ApiHandler::AsyncHttp(l), ApiHandler::AsyncHttp(r)) => {
+ core::mem::transmute::<_, usize>(l) == core::mem::transmute::<_, usize>(r)
+ }
+ _ => false,
+ }
+ }
+ }
+}
+
/// Lookup table to child `Router`s
///
/// Stores a sorted list of `(name, router)` tuples:
const DUMMY_HANDLER: ApiHandler = ApiHandler::Sync(&dummy_handler_fn);
/// This struct defines synchronous API call which returns the restulkt as json `Value`
+#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
pub struct ApiMethod {
/// The protected flag indicates that the provides function should be forwarded
/// to the deaemon running in priviledged mode.
/// Data type to describe boolean values
#[derive(Debug)]
+#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
pub struct BooleanSchema {
pub description: &'static str,
/// Optional default value.
/// Data type to describe integer values.
#[derive(Debug)]
+#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
pub struct IntegerSchema {
pub description: &'static str,
/// Optional minimum.
}
}
+#[cfg(feature = "test-harness")]
+impl Eq for NumberSchema {}
+
+#[cfg(feature = "test-harness")]
+impl PartialEq for NumberSchema {
+ fn eq(&self, rhs: &Self) -> bool {
+ fn f64_eq(l: Option<f64>, r: Option<f64>) -> bool {
+ match (l, r) {
+ (None, None) => true,
+ (Some(l), Some(r)) => (l - r).abs() < 0.0001,
+ _ => false,
+ }
+ }
+
+ self.description == rhs.description
+ && f64_eq(self.minimum, rhs.minimum)
+ && f64_eq(self.maximum, rhs.maximum)
+ && f64_eq(self.default, rhs.default)
+ }
+}
+
/// Data type to describe string values.
#[derive(Debug)]
+#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
pub struct StringSchema {
pub description: &'static str,
/// Optional default value.
/// All array elements are of the same type, as defined in the `items`
/// schema.
#[derive(Debug)]
+#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
pub struct ArraySchema {
pub description: &'static str,
/// Element type schema.
/// Data type to describe objects (maps).
#[derive(Debug)]
+#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
pub struct ObjectSchema {
pub description: &'static str,
/// If set, allow additional properties which are not defined in
/// ).schema();
/// ```
#[derive(Debug)]
+#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
pub enum Schema {
Null,
Boolean(BooleanSchema),
}
}
+#[cfg(feature = "test-harness")]
+impl Eq for ApiStringFormat {}
+
+#[cfg(feature = "test-harness")]
+impl PartialEq for ApiStringFormat {
+ fn eq(&self, rhs: &Self) -> bool {
+ match (self, rhs) {
+ (ApiStringFormat::Enum(l), ApiStringFormat::Enum(r)) => l == r,
+ (ApiStringFormat::Pattern(l), ApiStringFormat::Pattern(r)) => l == r,
+ (ApiStringFormat::PropertyString(l), ApiStringFormat::PropertyString(r)) => l == r,
+ (ApiStringFormat::VerifyFn(l), ApiStringFormat::VerifyFn(r)) => {
+ (l as *const fn(&str) -> _ as usize) == (r as *const fn(&str) -> _ as usize)
+ }
+ (_, _) => false,
+ }
+ }
+}
+
/// Helper function to parse boolean values
///
/// - true: `1 | on | yes | true`