1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
//! Types used to represent values at compile-time, eg: True/False.
/// Type-level booleans.
///
/// This is a re-export from `core_extensions::type_level_bool`,
/// so as to allow glob imports (`abi_stable::type_level::bools::*`)
/// without worrying about importing too many items.
pub mod bools {
#[doc(no_inline)]
pub use core_extensions::type_level_bool::{Boolean, False, True};
}
// Uncomment if I have a use for type-level `Option`s
// pub mod option;
/// Type-level enum representing whether a
/// `DynTrait`/`RObject`/`#[sabi_trait]`-generated trait object
/// can be converted back into the concrete type they were constructed with.
pub mod downcasting;
/// Marker types representing traits.
pub mod trait_marker {
///
pub struct Send;
///
pub struct Sync;
///
pub struct Clone;
///
pub struct Default;
///
pub struct Display;
///
pub struct Debug;
///
pub struct Eq;
///
pub struct PartialEq;
///
pub struct Ord;
///
pub struct PartialOrd;
///
pub struct Hash;
/// Represents the [`serde::Deserialize`] trait.
pub struct Deserialize;
/// Represents the [`serde::Serialize`] trait.
pub struct Serialize;
///
pub struct Iterator;
///
pub struct DoubleEndedIterator;
/// Represents the [`std::fmt::Write`] trait.
pub struct FmtWrite;
/// Represents the [`std::io::Write`] trait.
pub struct IoWrite;
/// Represents the [`std::io::Seek`] trait.
pub struct IoSeek;
/// Represents the [`std::io::Read`] trait.
pub struct IoRead;
/// Represents the [`std::io::BufRead`] trait.
pub struct IoBufRead;
/// Represents the [`std::error::Error`] trait.
pub struct Error;
/// Represents the [`std::marker::Unpin`] trait.
pub struct Unpin;
#[doc(hidden)]
#[allow(non_camel_case_types)]
pub struct define_this_in_the_impl_InterfaceType_macro;
}
/// Type-level-enum representing whether a trait is implemented or not implemented.
pub mod impl_enum {
use crate::marker_type::NonOwningPhantom;
use core_extensions::type_level_bool::{False, True};
mod sealed {
pub trait Sealed {}
}
use self::sealed::Sealed;
/// Trait for [`Implemented`] and [`Unimplemented`]
pub trait Implementability: Sealed {
/// Whether the trait represented by the type parameter must be implemented.
const IS_IMPLD: bool;
}
/// Converts a type to either `Unimplemented` or `Implemented`.
///
/// The `T` type parameter represents the (un)required trait.
///
pub trait ImplFrom_<T: ?Sized> {
/// Either `Unimplemented` or `Implemented`.
type Impl: ?Sized + Implementability;
}
impl<T: ?Sized> ImplFrom_<T> for False {
type Impl = Unimplemented<T>;
}
impl<T: ?Sized> ImplFrom_<T> for True {
type Impl = Implemented<T>;
}
impl<T: ?Sized> ImplFrom_<T> for Unimplemented<T> {
type Impl = Unimplemented<T>;
}
impl<T: ?Sized> ImplFrom_<T> for Implemented<T> {
type Impl = Implemented<T>;
}
/// Converts `B` to either `Unimplemented<T>` or `Implemented<T>`.
///
/// The `T` type parameter represents the (un)required trait.
pub type ImplFrom<B, T> = <B as ImplFrom_<T>>::Impl;
/// Describes that a trait must be implemented.
///
/// The `T` type parameter represents the required trait.
pub struct Implemented<T: ?Sized>(NonOwningPhantom<T>);
impl<T: ?Sized> Sealed for Implemented<T> {}
impl<T: ?Sized> Implementability for Implemented<T> {
const IS_IMPLD: bool = true;
}
/// Describes that a trait does not need to be implemented.
///
/// The `T` type parameter represents the trait.
pub struct Unimplemented<T: ?Sized>(NonOwningPhantom<T>);
impl<T: ?Sized> Sealed for Unimplemented<T> {}
impl<T: ?Sized> Implementability for Unimplemented<T> {
const IS_IMPLD: bool = false;
}
}