#![doc(html_root_url = "https://docs.rs/amadeus-types/0.4.3")]
#![warn(
// missing_copy_implementations,
// missing_debug_implementations,
// missing_docs,
trivial_numeric_casts,
unused_import_braces,
unused_qualifications,
unused_results,
// unreachable_pub,
clippy::pedantic,
)]
#![allow(
clippy::module_name_repetitions,
clippy::similar_names,
clippy::if_not_else,
clippy::must_use_candidate,
clippy::missing_errors_doc,
clippy::doc_markdown,
clippy::wildcard_imports,
clippy::default_trait_access,
clippy::inline_always,
clippy::too_many_lines,
clippy::missing_panics_doc
)]
#![deny(unsafe_code)]
#[macro_export]
macro_rules! array {
($array_macro:ident) => (
$array_macro!(0 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); )
}
#[macro_export]
macro_rules! tuple {
($tuple_macro:ident) => (
$tuple_macro!(0);
$tuple_macro!(1 A 0);
$tuple_macro!(2 A 0 B 1);
$tuple_macro!(3 A 0 B 1 C 2);
$tuple_macro!(4 A 0 B 1 C 2 D 3);
$tuple_macro!(5 A 0 B 1 C 2 D 3 E 4);
$tuple_macro!(6 A 0 B 1 C 2 D 3 E 4 F 5);
$tuple_macro!(7 A 0 B 1 C 2 D 3 E 4 F 5 G 6);
$tuple_macro!(8 A 0 B 1 C 2 D 3 E 4 F 5 G 6 H 7);
$tuple_macro!(9 A 0 B 1 C 2 D 3 E 4 F 5 G 6 H 7 I 8);
$tuple_macro!(10 A 0 B 1 C 2 D 3 E 4 F 5 G 6 H 7 I 8 J 9);
$tuple_macro!(11 A 0 B 1 C 2 D 3 E 4 F 5 G 6 H 7 I 8 J 9 K 10);
$tuple_macro!(12 A 0 B 1 C 2 D 3 E 4 F 5 G 6 H 7 I 8 J 9 K 10 L 11);
)
}
mod array;
mod data;
mod decimal;
mod group;
mod http;
mod list;
mod ord;
mod time;
mod util;
mod value;
mod value_required;
use std::{
error::Error, fmt::{self, Debug, Display}
};
pub use self::{
array::{Bson, Enum, Json}, data::Data, decimal::Decimal, group::Group, http::{IpAddr, ParseAddrError, ParseUrlError, ParseWebpageError, Url, Webpage}, list::{List, ListVec}, ord::AmadeusOrd, time::{
Date, DateTime, DateTimeWithoutTimezone, DateWithoutTimezone, ParseDateError, Time, TimeWithoutTimezone, Timezone
}, value::{Schema, SchemaIncomplete, Value}, value_required::ValueRequired
};
pub mod __internal {
pub use serde::{
de::{Deserializer, Error, SeqAccess, Visitor}, ser::{SerializeTuple, Serializer}, Deserialize, Serialize
};
}
pub trait DowncastFrom<T>
where
T: Downcast<Self>,
Self: Sized,
{
fn downcast_from(t: T) -> Result<Self, DowncastError>
where
Self: Sized;
}
pub trait Downcast<T> {
fn downcast(self) -> Result<T, DowncastError>;
}
impl<A, B> Downcast<A> for B
where
A: DowncastFrom<B>,
{
fn downcast(self) -> Result<A, DowncastError> {
A::downcast_from(self)
}
}
impl<A, B> DowncastFrom<A> for Box<B>
where
B: DowncastFrom<A>,
{
fn downcast_from(t: A) -> Result<Self, DowncastError>
where
Self: Sized,
{
t.downcast().map(Box::new)
}
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct DowncastError {
pub from: &'static str,
pub to: &'static str,
}
impl Error for DowncastError {
fn description(&self) -> &str {
"invalid downcast"
}
}
impl Display for DowncastError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "could not downcast \"{}\" to \"{}\"", self.from, self.to)
}
}