From a7a6bb36ede53d41dd0d87de57e434c27f0bd5c5 Mon Sep 17 00:00:00 2001 From: xqtc Date: Sat, 26 Oct 2024 16:31:10 +0200 Subject: [PATCH] major refactor --- client/src/{ingestions.rs => .ingestions.rs} | 0 ...ingestions_util.rs => .ingestions_util.rs} | 0 .../{substance_util.rs => .substance_util.rs} | 0 client/src/{substances.rs => .substances.rs} | 0 client/src/drugs/drug_schema.rs | 3887 +++++++++++++++++ client/src/drugs/mod.rs | 1 + client/src/main.rs | 107 +- client/src/substances_new/mod.rs | 356 -- server/src/main.rs | 2 +- 9 files changed, 3943 insertions(+), 410 deletions(-) rename client/src/{ingestions.rs => .ingestions.rs} (100%) rename client/src/{ingestions_util.rs => .ingestions_util.rs} (100%) rename client/src/{substance_util.rs => .substance_util.rs} (100%) rename client/src/{substances.rs => .substances.rs} (100%) create mode 100644 client/src/drugs/drug_schema.rs create mode 100644 client/src/drugs/mod.rs delete mode 100644 client/src/substances_new/mod.rs diff --git a/client/src/ingestions.rs b/client/src/.ingestions.rs similarity index 100% rename from client/src/ingestions.rs rename to client/src/.ingestions.rs diff --git a/client/src/ingestions_util.rs b/client/src/.ingestions_util.rs similarity index 100% rename from client/src/ingestions_util.rs rename to client/src/.ingestions_util.rs diff --git a/client/src/substance_util.rs b/client/src/.substance_util.rs similarity index 100% rename from client/src/substance_util.rs rename to client/src/.substance_util.rs diff --git a/client/src/substances.rs b/client/src/.substances.rs similarity index 100% rename from client/src/substances.rs rename to client/src/.substances.rs diff --git a/client/src/drugs/drug_schema.rs b/client/src/drugs/drug_schema.rs new file mode 100644 index 0000000..67e88c0 --- /dev/null +++ b/client/src/drugs/drug_schema.rs @@ -0,0 +1,3887 @@ +#![allow(clippy::redundant_closure_call)] +#![allow(clippy::needless_lifetimes)] +#![allow(clippy::match_single_binding)] +#![allow(clippy::clone_on_copy)] + +use serde::{Deserialize, Serialize}; + +#[doc = r" Error types."] +pub mod error { + #[doc = r" Error from a TryFrom or FromStr implementation."] + pub struct ConversionError(std::borrow::Cow<'static, str>); + impl std::error::Error for ConversionError {} + impl std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + std::fmt::Display::fmt(&self.0, f) + } + } + impl std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + std::fmt::Debug::fmt(&self.0, f) + } + } + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } +} +#[doc = "Category"] +#[doc = r""] +#[doc = r"
JSON schema"] +#[doc = r""] +#[doc = r" ```json"] +#[doc = "{"] +#[doc = " \"title\": \"Category\","] +#[doc = " \"type\": \"string\","] +#[doc = " \"enum\": ["] +#[doc = " \"depressant\","] +#[doc = " \"habit-forming\","] +#[doc = " \"tentative\","] +#[doc = " \"research-chemical\","] +#[doc = " \"psychedelic\","] +#[doc = " \"stimulant\","] +#[doc = " \"dissociative\","] +#[doc = " \"inactive\","] +#[doc = " \"empathogen\","] +#[doc = " \"common\","] +#[doc = " \"benzodiazepine\","] +#[doc = " \"opioid\","] +#[doc = " \"supplement\","] +#[doc = " \"nootropic\","] +#[doc = " \"barbiturate\","] +#[doc = " \"deliriant\","] +#[doc = " \"ssri\""] +#[doc = " ]"] +#[doc = "}"] +#[doc = r" ```"] +#[doc = r"
"] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] +pub enum Category { + #[serde(rename = "depressant")] + Depressant, + #[serde(rename = "habit-forming")] + HabitForming, + #[serde(rename = "tentative")] + Tentative, + #[serde(rename = "research-chemical")] + ResearchChemical, + #[serde(rename = "psychedelic")] + Psychedelic, + #[serde(rename = "stimulant")] + Stimulant, + #[serde(rename = "dissociative")] + Dissociative, + #[serde(rename = "inactive")] + Inactive, + #[serde(rename = "empathogen")] + Empathogen, + #[serde(rename = "common")] + Common, + #[serde(rename = "benzodiazepine")] + Benzodiazepine, + #[serde(rename = "opioid")] + Opioid, + #[serde(rename = "supplement")] + Supplement, + #[serde(rename = "nootropic")] + Nootropic, + #[serde(rename = "barbiturate")] + Barbiturate, + #[serde(rename = "deliriant")] + Deliriant, + #[serde(rename = "ssri")] + Ssri, +} +impl From<&Category> for Category { + fn from(value: &Category) -> Self { + value.clone() + } +} +impl ToString for Category { + fn to_string(&self) -> String { + match *self { + Self::Depressant => "depressant".to_string(), + Self::HabitForming => "habit-forming".to_string(), + Self::Tentative => "tentative".to_string(), + Self::ResearchChemical => "research-chemical".to_string(), + Self::Psychedelic => "psychedelic".to_string(), + Self::Stimulant => "stimulant".to_string(), + Self::Dissociative => "dissociative".to_string(), + Self::Inactive => "inactive".to_string(), + Self::Empathogen => "empathogen".to_string(), + Self::Common => "common".to_string(), + Self::Benzodiazepine => "benzodiazepine".to_string(), + Self::Opioid => "opioid".to_string(), + Self::Supplement => "supplement".to_string(), + Self::Nootropic => "nootropic".to_string(), + Self::Barbiturate => "barbiturate".to_string(), + Self::Deliriant => "deliriant".to_string(), + Self::Ssri => "ssri".to_string(), + } + } +} +impl std::str::FromStr for Category { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { + match value { + "depressant" => Ok(Self::Depressant), + "habit-forming" => Ok(Self::HabitForming), + "tentative" => Ok(Self::Tentative), + "research-chemical" => Ok(Self::ResearchChemical), + "psychedelic" => Ok(Self::Psychedelic), + "stimulant" => Ok(Self::Stimulant), + "dissociative" => Ok(Self::Dissociative), + "inactive" => Ok(Self::Inactive), + "empathogen" => Ok(Self::Empathogen), + "common" => Ok(Self::Common), + "benzodiazepine" => Ok(Self::Benzodiazepine), + "opioid" => Ok(Self::Opioid), + "supplement" => Ok(Self::Supplement), + "nootropic" => Ok(Self::Nootropic), + "barbiturate" => Ok(Self::Barbiturate), + "deliriant" => Ok(Self::Deliriant), + "ssri" => Ok(Self::Ssri), + _ => Err("invalid value".into()), + } + } +} +impl std::convert::TryFrom<&str> for Category { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { + value.parse() + } +} +impl std::convert::TryFrom<&String> for Category { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { + value.parse() + } +} +impl std::convert::TryFrom for Category { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { + value.parse() + } +} +#[doc = "Combo"] +#[doc = r""] +#[doc = r"
JSON schema"] +#[doc = r""] +#[doc = r" ```json"] +#[doc = "{"] +#[doc = " \"title\": \"Combo\","] +#[doc = " \"type\": \"object\","] +#[doc = " \"required\": ["] +#[doc = " \"status\""] +#[doc = " ],"] +#[doc = " \"properties\": {"] +#[doc = " \"note\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"sources\": {"] +#[doc = " \"type\": \"array\","] +#[doc = " \"items\": {"] +#[doc = " \"$ref\": \"#/definitions/SourceData\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"status\": {"] +#[doc = " \"$ref\": \"#/definitions/Status\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"additionalProperties\": false"] +#[doc = "}"] +#[doc = r" ```"] +#[doc = r"
"] +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct Combo { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub note: Option, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub sources: Vec, + pub status: Status, +} +impl From<&Combo> for Combo { + fn from(value: &Combo) -> Self { + value.clone() + } +} +impl Combo { + pub fn builder() -> builder::Combo { + Default::default() + } +} +#[doc = "Dosage"] +#[doc = r""] +#[doc = r"
JSON schema"] +#[doc = r""] +#[doc = r" ```json"] +#[doc = "{"] +#[doc = " \"title\": \"Buccal\","] +#[doc = " \"type\": \"object\","] +#[doc = " \"properties\": {"] +#[doc = " \"Common\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Dangerous\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Fatal\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Heavy\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Light\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Note\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Strong\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Threshold\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"additionalProperties\": false"] +#[doc = "}"] +#[doc = r" ```"] +#[doc = r"
"] +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct Dosage { + #[serde(rename = "Common", default, skip_serializing_if = "Option::is_none")] + pub common: Option, + #[serde(rename = "Dangerous", default, skip_serializing_if = "Option::is_none")] + pub dangerous: Option, + #[serde(rename = "Fatal", default, skip_serializing_if = "Option::is_none")] + pub fatal: Option, + #[serde(rename = "Heavy", default, skip_serializing_if = "Option::is_none")] + pub heavy: Option, + #[serde(rename = "Light", default, skip_serializing_if = "Option::is_none")] + pub light: Option, + #[serde(rename = "Note", default, skip_serializing_if = "Option::is_none")] + pub note: Option, + #[serde(rename = "Strong", default, skip_serializing_if = "Option::is_none")] + pub strong: Option, + #[serde(rename = "Threshold", default, skip_serializing_if = "Option::is_none")] + pub threshold: Option, +} +impl From<&Dosage> for Dosage { + fn from(value: &Dosage) -> Self { + value.clone() + } +} +impl Dosage { + pub fn builder() -> builder::Dosage { + Default::default() + } +} +#[doc = "Dose"] +#[doc = r""] +#[doc = r"
JSON schema"] +#[doc = r""] +#[doc = r" ```json"] +#[doc = "{"] +#[doc = " \"title\": \"FormattedDose\","] +#[doc = " \"type\": \"object\","] +#[doc = " \"properties\": {"] +#[doc = " \"Buccal\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Dried\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Dry\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Fresh\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"HBWR\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Insufflated\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Insufflated(Pure)\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Intramuscular\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Intravenous\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Morning_Glory\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Oral\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Oral(Benzedrex)\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Oral(Pure)\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Rectal\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Smoked\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Sublingual\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Transdermal\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Vapourized\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " },"] +#[doc = " \"Wet\": {"] +#[doc = " \"$ref\": \"#/definitions/Dosage\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"additionalProperties\": false"] +#[doc = "}"] +#[doc = r" ```"] +#[doc = r"
"] +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct Dose { + #[serde(rename = "Buccal", default, skip_serializing_if = "Option::is_none")] + pub buccal: Option, + #[serde(rename = "Dried", default, skip_serializing_if = "Option::is_none")] + pub dried: Option, + #[serde(rename = "Dry", default, skip_serializing_if = "Option::is_none")] + pub dry: Option, + #[serde(rename = "Fresh", default, skip_serializing_if = "Option::is_none")] + pub fresh: Option, + #[serde(rename = "HBWR", default, skip_serializing_if = "Option::is_none")] + pub hbwr: Option, + #[serde( + rename = "Insufflated", + default, + skip_serializing_if = "Option::is_none" + )] + pub insufflated: Option, + #[serde( + rename = "Insufflated(Pure)", + default, + skip_serializing_if = "Option::is_none" + )] + pub insufflated_pure: Option, + #[serde( + rename = "Intramuscular", + default, + skip_serializing_if = "Option::is_none" + )] + pub intramuscular: Option, + #[serde( + rename = "Intravenous", + default, + skip_serializing_if = "Option::is_none" + )] + pub intravenous: Option, + #[serde( + rename = "Morning_Glory", + default, + skip_serializing_if = "Option::is_none" + )] + pub morning_glory: Option, + #[serde(rename = "Oral", default, skip_serializing_if = "Option::is_none")] + pub oral: Option, + #[serde( + rename = "Oral(Benzedrex)", + default, + skip_serializing_if = "Option::is_none" + )] + pub oral_benzedrex: Option, + #[serde( + rename = "Oral(Pure)", + default, + skip_serializing_if = "Option::is_none" + )] + pub oral_pure: Option, + #[serde(rename = "Rectal", default, skip_serializing_if = "Option::is_none")] + pub rectal: Option, + #[serde(rename = "Smoked", default, skip_serializing_if = "Option::is_none")] + pub smoked: Option, + #[serde( + rename = "Sublingual", + default, + skip_serializing_if = "Option::is_none" + )] + pub sublingual: Option, + #[serde( + rename = "Transdermal", + default, + skip_serializing_if = "Option::is_none" + )] + pub transdermal: Option, + #[serde( + rename = "Vapourized", + default, + skip_serializing_if = "Option::is_none" + )] + pub vapourized: Option, + #[serde(rename = "Wet", default, skip_serializing_if = "Option::is_none")] + pub wet: Option, +} +impl From<&Dose> for Dose { + fn from(value: &Dose) -> Self { + value.clone() + } +} +impl Dose { + pub fn builder() -> builder::Dose { + Default::default() + } +} +#[doc = "Drug"] +#[doc = r""] +#[doc = r"
JSON schema"] +#[doc = r""] +#[doc = r" ```json"] +#[doc = "{"] +#[doc = " \"title\": \"Drug\","] +#[doc = " \"type\": \"object\","] +#[doc = " \"required\": ["] +#[doc = " \"name\","] +#[doc = " \"pretty_name\","] +#[doc = " \"properties\""] +#[doc = " ],"] +#[doc = " \"properties\": {"] +#[doc = " \"aliases\": {"] +#[doc = " \"type\": \"array\","] +#[doc = " \"items\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"categories\": {"] +#[doc = " \"type\": \"array\","] +#[doc = " \"items\": {"] +#[doc = " \"$ref\": \"#/definitions/Category\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"combos\": {"] +#[doc = " \"type\": \"object\","] +#[doc = " \"properties\": {"] +#[doc = " \"2c-t-x\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"2c-x\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"5-meo-xxt\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"alcohol\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"amphetamines\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"amt\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"benzodiazepines\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"caffeine\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"cannabis\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"cocaine\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"dextromethorphan\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"diphenhydramine\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"dmt\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"dox\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"ghb/gbl\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"ketamine\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"lithium\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"lsd\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"maois\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"mdma\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"mephedrone\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"mescaline\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"mushrooms\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"mxe\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"nbomes\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"nitrous\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"opioids\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"pcp\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"ssris\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"tramadol\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"additionalProperties\": false"] +#[doc = " },"] +#[doc = " \"dose_note\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"formatted_aftereffects\": {"] +#[doc = " \"$ref\": \"#/definitions/Duration\""] +#[doc = " },"] +#[doc = " \"formatted_dose\": {"] +#[doc = " \"$ref\": \"#/definitions/Dose\""] +#[doc = " },"] +#[doc = " \"formatted_duration\": {"] +#[doc = " \"$ref\": \"#/definitions/Duration\""] +#[doc = " },"] +#[doc = " \"formatted_effects\": {"] +#[doc = " \"type\": \"array\","] +#[doc = " \"items\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"formatted_onset\": {"] +#[doc = " \"$ref\": \"#/definitions/Duration\""] +#[doc = " },"] +#[doc = " \"links\": {"] +#[doc = " \"$ref\": \"#/definitions/Links\""] +#[doc = " },"] +#[doc = " \"name\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"pretty_name\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"properties\": {"] +#[doc = " \"$ref\": \"#/definitions/Properties\""] +#[doc = " },"] +#[doc = " \"pweffects\": {"] +#[doc = " \"type\": \"object\","] +#[doc = " \"additionalProperties\": {"] +#[doc = " \"type\": \"string\","] +#[doc = " \"format\": \"uri\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"sources\": {"] +#[doc = " \"$ref\": \"#/definitions/Sources\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"additionalProperties\": false"] +#[doc = "}"] +#[doc = r" ```"] +#[doc = r"
"] +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct Drug { + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub aliases: Vec, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub categories: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub combos: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub dose_note: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub formatted_aftereffects: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub formatted_dose: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub formatted_duration: Option, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub formatted_effects: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub formatted_onset: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub links: Option, + pub name: String, + pub pretty_name: String, + pub properties: Properties, + #[serde(default, skip_serializing_if = "std::collections::HashMap::is_empty")] + pub pweffects: std::collections::HashMap, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub sources: Option, +} +impl From<&Drug> for Drug { + fn from(value: &Drug) -> Self { + value.clone() + } +} +impl Drug { + pub fn builder() -> builder::Drug { + Default::default() + } +} +#[doc = "DrugCombos"] +#[doc = r""] +#[doc = r"
JSON schema"] +#[doc = r""] +#[doc = r" ```json"] +#[doc = "{"] +#[doc = " \"type\": \"object\","] +#[doc = " \"properties\": {"] +#[doc = " \"2c-t-x\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"2c-x\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"5-meo-xxt\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"alcohol\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"amphetamines\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"amt\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"benzodiazepines\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"caffeine\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"cannabis\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"cocaine\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"dextromethorphan\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"diphenhydramine\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"dmt\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"dox\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"ghb/gbl\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"ketamine\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"lithium\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"lsd\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"maois\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"mdma\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"mephedrone\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"mescaline\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"mushrooms\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"mxe\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"nbomes\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"nitrous\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"opioids\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"pcp\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"ssris\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " },"] +#[doc = " \"tramadol\": {"] +#[doc = " \"$ref\": \"#/definitions/Combo\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"additionalProperties\": false"] +#[doc = "}"] +#[doc = r" ```"] +#[doc = r"
"] +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct DrugCombos { + #[serde(rename = "2c-t-x", default, skip_serializing_if = "Option::is_none")] + pub _2c_t_x: Option, + #[serde(rename = "2c-x", default, skip_serializing_if = "Option::is_none")] + pub _2c_x: Option, + #[serde(rename = "5-meo-xxt", default, skip_serializing_if = "Option::is_none")] + pub _5_meo_xxt: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub alcohol: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub amphetamines: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub amt: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub benzodiazepines: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub caffeine: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cannabis: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cocaine: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub dextromethorphan: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub diphenhydramine: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub dmt: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub dox: Option, + #[serde(rename = "ghb/gbl", default, skip_serializing_if = "Option::is_none")] + pub ghb_gbl: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub ketamine: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub lithium: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub lsd: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub maois: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mdma: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mephedrone: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mescaline: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mushrooms: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mxe: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub nbomes: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub nitrous: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub opioids: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub pcp: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub ssris: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub tramadol: Option, +} +impl From<&DrugCombos> for DrugCombos { + fn from(value: &DrugCombos) -> Self { + value.clone() + } +} +impl DrugCombos { + pub fn builder() -> builder::DrugCombos { + Default::default() + } +} +#[doc = "Duration"] +#[doc = r""] +#[doc = r"
JSON schema"] +#[doc = r""] +#[doc = r" ```json"] +#[doc = "{"] +#[doc = " \"title\": \"Formatted\","] +#[doc = " \"type\": \"object\","] +#[doc = " \"properties\": {"] +#[doc = " \"Buccal\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Insufflated\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Insufflated_IR\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Insufflated_XR\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Intramuscular\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Intravenous\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Metabolites\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Oral\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Oral_ER\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Oral_IR\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Oral_MAOI\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Parent\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Rectal\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Smoked\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Sublingual\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Transdermal\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"Vapourized\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"_unit\": {"] +#[doc = " \"$ref\": \"#/definitions/Unit\""] +#[doc = " },"] +#[doc = " \"value\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"additionalProperties\": false"] +#[doc = "}"] +#[doc = r" ```"] +#[doc = r"
"] +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct Duration { + #[serde(rename = "Buccal", default, skip_serializing_if = "Option::is_none")] + pub buccal: Option, + #[serde( + rename = "Insufflated", + default, + skip_serializing_if = "Option::is_none" + )] + pub insufflated: Option, + #[serde( + rename = "Insufflated_IR", + default, + skip_serializing_if = "Option::is_none" + )] + pub insufflated_ir: Option, + #[serde( + rename = "Insufflated_XR", + default, + skip_serializing_if = "Option::is_none" + )] + pub insufflated_xr: Option, + #[serde( + rename = "Intramuscular", + default, + skip_serializing_if = "Option::is_none" + )] + pub intramuscular: Option, + #[serde( + rename = "Intravenous", + default, + skip_serializing_if = "Option::is_none" + )] + pub intravenous: Option, + #[serde( + rename = "Metabolites", + default, + skip_serializing_if = "Option::is_none" + )] + pub metabolites: Option, + #[serde(rename = "Oral", default, skip_serializing_if = "Option::is_none")] + pub oral: Option, + #[serde(rename = "Oral_ER", default, skip_serializing_if = "Option::is_none")] + pub oral_er: Option, + #[serde(rename = "Oral_IR", default, skip_serializing_if = "Option::is_none")] + pub oral_ir: Option, + #[serde(rename = "Oral_MAOI", default, skip_serializing_if = "Option::is_none")] + pub oral_maoi: Option, + #[serde(rename = "Parent", default, skip_serializing_if = "Option::is_none")] + pub parent: Option, + #[serde(rename = "Rectal", default, skip_serializing_if = "Option::is_none")] + pub rectal: Option, + #[serde(rename = "Smoked", default, skip_serializing_if = "Option::is_none")] + pub smoked: Option, + #[serde( + rename = "Sublingual", + default, + skip_serializing_if = "Option::is_none" + )] + pub sublingual: Option, + #[serde( + rename = "Transdermal", + default, + skip_serializing_if = "Option::is_none" + )] + pub transdermal: Option, + #[serde(rename = "_unit", default, skip_serializing_if = "Option::is_none")] + pub unit: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub value: Option, + #[serde( + rename = "Vapourized", + default, + skip_serializing_if = "Option::is_none" + )] + pub vapourized: Option, +} +impl From<&Duration> for Duration { + fn from(value: &Duration) -> Self { + value.clone() + } +} +impl Duration { + pub fn builder() -> builder::Duration { + Default::default() + } +} +#[doc = "Links"] +#[doc = r""] +#[doc = r"
JSON schema"] +#[doc = r""] +#[doc = r" ```json"] +#[doc = "{"] +#[doc = " \"title\": \"Links\","] +#[doc = " \"type\": \"object\","] +#[doc = " \"required\": ["] +#[doc = " \"experiences\""] +#[doc = " ],"] +#[doc = " \"properties\": {"] +#[doc = " \"experiences\": {"] +#[doc = " \"type\": \"string\","] +#[doc = " \"format\": \"uri\""] +#[doc = " },"] +#[doc = " \"pihkal\": {"] +#[doc = " \"type\": \"string\","] +#[doc = " \"format\": \"uri\""] +#[doc = " },"] +#[doc = " \"tihkal\": {"] +#[doc = " \"type\": \"string\","] +#[doc = " \"format\": \"uri\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"additionalProperties\": false"] +#[doc = "}"] +#[doc = r" ```"] +#[doc = r"
"] +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct Links { + pub experiences: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub pihkal: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub tihkal: Option, +} +impl From<&Links> for Links { + fn from(value: &Links) -> Self { + value.clone() + } +} +impl Links { + pub fn builder() -> builder::Links { + Default::default() + } +} +#[doc = "Properties"] +#[doc = r""] +#[doc = r"
JSON schema"] +#[doc = r""] +#[doc = r" ```json"] +#[doc = "{"] +#[doc = " \"title\": \"Properties\","] +#[doc = " \"type\": \"object\","] +#[doc = " \"properties\": {"] +#[doc = " \"Oral\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"adverse-effects\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"after-effects\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"aliases\": {"] +#[doc = " \"type\": \"array\","] +#[doc = " \"items\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"avoid\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"bioavailability\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"calculator\": {"] +#[doc = " \"type\": \"string\","] +#[doc = " \"format\": \"uri\""] +#[doc = " },"] +#[doc = " \"categories\": {"] +#[doc = " \"type\": \"array\","] +#[doc = " \"items\": {"] +#[doc = " \"$ref\": \"#/definitions/Category\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"chart\": {"] +#[doc = " \"type\": \"string\","] +#[doc = " \"format\": \"uri\""] +#[doc = " },"] +#[doc = " \"chemistry\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"comeup\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"contraindications\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"detection\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"dose\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"dose_to_diazepam\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"duration\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"effects\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"experiences\": {"] +#[doc = " \"type\": \"string\","] +#[doc = " \"format\": \"uri\""] +#[doc = " },"] +#[doc = " \"general-advice\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"half-life\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"legal\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"marquis\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"mdma\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"molecule\": {"] +#[doc = " \"type\": \"string\","] +#[doc = " \"format\": \"uri\""] +#[doc = " },"] +#[doc = " \"note\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"obtain\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"onset\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"overdose-symptoms\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"pharmacodynamics\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"pharmacokinetics\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"pharmacology\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"potentiators\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"risks\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"side-effects\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"summary\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"test-kits\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"tolerance\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"vaporization\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"warning\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"wiki\": {"] +#[doc = " \"type\": \"string\","] +#[doc = " \"format\": \"uri\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"additionalProperties\": false"] +#[doc = "}"] +#[doc = r" ```"] +#[doc = r"
"] +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct Properties { + #[serde( + rename = "adverse-effects", + default, + skip_serializing_if = "Option::is_none" + )] + pub adverse_effects: Option, + #[serde( + rename = "after-effects", + default, + skip_serializing_if = "Option::is_none" + )] + pub after_effects: Option, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub aliases: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub avoid: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub bioavailability: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub calculator: Option, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub categories: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub chart: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub chemistry: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub comeup: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub contraindications: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub detection: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub dose: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub dose_to_diazepam: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub duration: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub effects: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub experiences: Option, + #[serde( + rename = "general-advice", + default, + skip_serializing_if = "Option::is_none" + )] + pub general_advice: Option, + #[serde(rename = "half-life", default, skip_serializing_if = "Option::is_none")] + pub half_life: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub legal: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub marquis: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub mdma: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub molecule: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub note: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub obtain: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub onset: Option, + #[serde(rename = "Oral", default, skip_serializing_if = "Option::is_none")] + pub oral: Option, + #[serde( + rename = "overdose-symptoms", + default, + skip_serializing_if = "Option::is_none" + )] + pub overdose_symptoms: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub pharmacodynamics: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub pharmacokinetics: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub pharmacology: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub potentiators: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub risks: Option, + #[serde( + rename = "side-effects", + default, + skip_serializing_if = "Option::is_none" + )] + pub side_effects: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub summary: Option, + #[serde(rename = "test-kits", default, skip_serializing_if = "Option::is_none")] + pub test_kits: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub tolerance: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub vaporization: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub warning: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub wiki: Option, +} +impl From<&Properties> for Properties { + fn from(value: &Properties) -> Self { + value.clone() + } +} +impl Properties { + pub fn builder() -> builder::Properties { + Default::default() + } +} +#[doc = "SourceData"] +#[doc = r""] +#[doc = r"
JSON schema"] +#[doc = r""] +#[doc = r" ```json"] +#[doc = "{"] +#[doc = " \"title\": \"SourceData\","] +#[doc = " \"type\": \"object\","] +#[doc = " \"properties\": {"] +#[doc = " \"author\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"title\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"url\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"additionalProperties\": false"] +#[doc = "}"] +#[doc = r" ```"] +#[doc = r"
"] +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct SourceData { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub author: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub title: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub url: Option, +} +impl From<&SourceData> for SourceData { + fn from(value: &SourceData) -> Self { + value.clone() + } +} +impl SourceData { + pub fn builder() -> builder::SourceData { + Default::default() + } +} +#[doc = "Sources"] +#[doc = r""] +#[doc = r"
JSON schema"] +#[doc = r""] +#[doc = r" ```json"] +#[doc = "{"] +#[doc = " \"title\": \"Sources\","] +#[doc = " \"type\": \"object\","] +#[doc = " \"properties\": {"] +#[doc = " \"_general\": {"] +#[doc = " \"type\": \"array\","] +#[doc = " \"items\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"bioavailability\": {"] +#[doc = " \"type\": \"array\","] +#[doc = " \"items\": {"] +#[doc = " \"type\": \"string\","] +#[doc = " \"format\": \"uri\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"dose\": {"] +#[doc = " \"type\": \"array\","] +#[doc = " \"items\": {"] +#[doc = " \"type\": \"string\","] +#[doc = " \"format\": \"uri\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"duration\": {"] +#[doc = " \"type\": \"array\","] +#[doc = " \"items\": {"] +#[doc = " \"type\": \"string\","] +#[doc = " \"format\": \"uri\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"legality\": {"] +#[doc = " \"type\": \"array\","] +#[doc = " \"items\": {"] +#[doc = " \"type\": \"string\","] +#[doc = " \"format\": \"uri\""] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"onset\": {"] +#[doc = " \"type\": \"array\","] +#[doc = " \"items\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " }"] +#[doc = " }"] +#[doc = " },"] +#[doc = " \"additionalProperties\": false"] +#[doc = "}"] +#[doc = r" ```"] +#[doc = r"
"] +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub struct Sources { + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub bioavailability: Vec, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub dose: Vec, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub duration: Vec, + #[serde(rename = "_general", default, skip_serializing_if = "Vec::is_empty")] + pub general: Vec, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub legality: Vec, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub onset: Vec, +} +impl From<&Sources> for Sources { + fn from(value: &Sources) -> Self { + value.clone() + } +} +impl Sources { + pub fn builder() -> builder::Sources { + Default::default() + } +} +#[doc = "Status"] +#[doc = r""] +#[doc = r"
JSON schema"] +#[doc = r""] +#[doc = r" ```json"] +#[doc = "{"] +#[doc = " \"title\": \"Status\","] +#[doc = " \"type\": \"string\","] +#[doc = " \"enum\": ["] +#[doc = " \"Low Risk & Decrease\","] +#[doc = " \"Dangerous\","] +#[doc = " \"Low Risk & No Synergy\","] +#[doc = " \"Caution\","] +#[doc = " \"Unsafe\","] +#[doc = " \"Low Risk & Synergy\""] +#[doc = " ]"] +#[doc = "}"] +#[doc = r" ```"] +#[doc = r"
"] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] +pub enum Status { + #[serde(rename = "Low Risk & Decrease")] + LowRiskDecrease, + Dangerous, + #[serde(rename = "Low Risk & No Synergy")] + LowRiskNoSynergy, + Caution, + Unsafe, + #[serde(rename = "Low Risk & Synergy")] + LowRiskSynergy, +} +impl From<&Status> for Status { + fn from(value: &Status) -> Self { + value.clone() + } +} +impl ToString for Status { + fn to_string(&self) -> String { + match *self { + Self::LowRiskDecrease => "Low Risk & Decrease".to_string(), + Self::Dangerous => "Dangerous".to_string(), + Self::LowRiskNoSynergy => "Low Risk & No Synergy".to_string(), + Self::Caution => "Caution".to_string(), + Self::Unsafe => "Unsafe".to_string(), + Self::LowRiskSynergy => "Low Risk & Synergy".to_string(), + } + } +} +impl std::str::FromStr for Status { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { + match value { + "Low Risk & Decrease" => Ok(Self::LowRiskDecrease), + "Dangerous" => Ok(Self::Dangerous), + "Low Risk & No Synergy" => Ok(Self::LowRiskNoSynergy), + "Caution" => Ok(Self::Caution), + "Unsafe" => Ok(Self::Unsafe), + "Low Risk & Synergy" => Ok(Self::LowRiskSynergy), + _ => Err("invalid value".into()), + } + } +} +impl std::convert::TryFrom<&str> for Status { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { + value.parse() + } +} +impl std::convert::TryFrom<&String> for Status { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { + value.parse() + } +} +impl std::convert::TryFrom for Status { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { + value.parse() + } +} +#[doc = "Unit"] +#[doc = r""] +#[doc = r"
JSON schema"] +#[doc = r""] +#[doc = r" ```json"] +#[doc = "{"] +#[doc = " \"title\": \"Unit\","] +#[doc = " \"type\": \"string\","] +#[doc = " \"enum\": ["] +#[doc = " \"hours\","] +#[doc = " \"minutes\""] +#[doc = " ]"] +#[doc = "}"] +#[doc = r" ```"] +#[doc = r"
"] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] +pub enum Unit { + #[serde(rename = "hours")] + Hours, + #[serde(rename = "minutes")] + Minutes, +} +impl From<&Unit> for Unit { + fn from(value: &Unit) -> Self { + value.clone() + } +} +impl ToString for Unit { + fn to_string(&self) -> String { + match *self { + Self::Hours => "hours".to_string(), + Self::Minutes => "minutes".to_string(), + } + } +} +impl std::str::FromStr for Unit { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { + match value { + "hours" => Ok(Self::Hours), + "minutes" => Ok(Self::Minutes), + _ => Err("invalid value".into()), + } + } +} +impl std::convert::TryFrom<&str> for Unit { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { + value.parse() + } +} +impl std::convert::TryFrom<&String> for Unit { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { + value.parse() + } +} +impl std::convert::TryFrom for Unit { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { + value.parse() + } +} +#[doc = r" Types for composing complex structures."] +pub mod builder { + #[derive(Clone, Debug)] + pub struct Combo { + note: Result, String>, + sources: Result, String>, + status: Result, + } + impl Default for Combo { + fn default() -> Self { + Self { + note: Ok(Default::default()), + sources: Ok(Default::default()), + status: Err("no value supplied for status".to_string()), + } + } + } + impl Combo { + pub fn note(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.note = value + .try_into() + .map_err(|e| format!("error converting supplied value for note: {}", e)); + self + } + pub fn sources(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.sources = value + .try_into() + .map_err(|e| format!("error converting supplied value for sources: {}", e)); + self + } + pub fn status(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + } + impl std::convert::TryFrom for super::Combo { + type Error = super::error::ConversionError; + fn try_from(value: Combo) -> Result { + Ok(Self { + note: value.note?, + sources: value.sources?, + status: value.status?, + }) + } + } + impl From for Combo { + fn from(value: super::Combo) -> Self { + Self { + note: Ok(value.note), + sources: Ok(value.sources), + status: Ok(value.status), + } + } + } + #[derive(Clone, Debug)] + pub struct Dosage { + common: Result, String>, + dangerous: Result, String>, + fatal: Result, String>, + heavy: Result, String>, + light: Result, String>, + note: Result, String>, + strong: Result, String>, + threshold: Result, String>, + } + impl Default for Dosage { + fn default() -> Self { + Self { + common: Ok(Default::default()), + dangerous: Ok(Default::default()), + fatal: Ok(Default::default()), + heavy: Ok(Default::default()), + light: Ok(Default::default()), + note: Ok(Default::default()), + strong: Ok(Default::default()), + threshold: Ok(Default::default()), + } + } + } + impl Dosage { + pub fn common(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.common = value + .try_into() + .map_err(|e| format!("error converting supplied value for common: {}", e)); + self + } + pub fn dangerous(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.dangerous = value + .try_into() + .map_err(|e| format!("error converting supplied value for dangerous: {}", e)); + self + } + pub fn fatal(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.fatal = value + .try_into() + .map_err(|e| format!("error converting supplied value for fatal: {}", e)); + self + } + pub fn heavy(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.heavy = value + .try_into() + .map_err(|e| format!("error converting supplied value for heavy: {}", e)); + self + } + pub fn light(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.light = value + .try_into() + .map_err(|e| format!("error converting supplied value for light: {}", e)); + self + } + pub fn note(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.note = value + .try_into() + .map_err(|e| format!("error converting supplied value for note: {}", e)); + self + } + pub fn strong(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.strong = value + .try_into() + .map_err(|e| format!("error converting supplied value for strong: {}", e)); + self + } + pub fn threshold(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.threshold = value + .try_into() + .map_err(|e| format!("error converting supplied value for threshold: {}", e)); + self + } + } + impl std::convert::TryFrom for super::Dosage { + type Error = super::error::ConversionError; + fn try_from(value: Dosage) -> Result { + Ok(Self { + common: value.common?, + dangerous: value.dangerous?, + fatal: value.fatal?, + heavy: value.heavy?, + light: value.light?, + note: value.note?, + strong: value.strong?, + threshold: value.threshold?, + }) + } + } + impl From for Dosage { + fn from(value: super::Dosage) -> Self { + Self { + common: Ok(value.common), + dangerous: Ok(value.dangerous), + fatal: Ok(value.fatal), + heavy: Ok(value.heavy), + light: Ok(value.light), + note: Ok(value.note), + strong: Ok(value.strong), + threshold: Ok(value.threshold), + } + } + } + #[derive(Clone, Debug)] + pub struct Dose { + buccal: Result, String>, + dried: Result, String>, + dry: Result, String>, + fresh: Result, String>, + hbwr: Result, String>, + insufflated: Result, String>, + insufflated_pure: Result, String>, + intramuscular: Result, String>, + intravenous: Result, String>, + morning_glory: Result, String>, + oral: Result, String>, + oral_benzedrex: Result, String>, + oral_pure: Result, String>, + rectal: Result, String>, + smoked: Result, String>, + sublingual: Result, String>, + transdermal: Result, String>, + vapourized: Result, String>, + wet: Result, String>, + } + impl Default for Dose { + fn default() -> Self { + Self { + buccal: Ok(Default::default()), + dried: Ok(Default::default()), + dry: Ok(Default::default()), + fresh: Ok(Default::default()), + hbwr: Ok(Default::default()), + insufflated: Ok(Default::default()), + insufflated_pure: Ok(Default::default()), + intramuscular: Ok(Default::default()), + intravenous: Ok(Default::default()), + morning_glory: Ok(Default::default()), + oral: Ok(Default::default()), + oral_benzedrex: Ok(Default::default()), + oral_pure: Ok(Default::default()), + rectal: Ok(Default::default()), + smoked: Ok(Default::default()), + sublingual: Ok(Default::default()), + transdermal: Ok(Default::default()), + vapourized: Ok(Default::default()), + wet: Ok(Default::default()), + } + } + } + impl Dose { + pub fn buccal(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.buccal = value + .try_into() + .map_err(|e| format!("error converting supplied value for buccal: {}", e)); + self + } + pub fn dried(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.dried = value + .try_into() + .map_err(|e| format!("error converting supplied value for dried: {}", e)); + self + } + pub fn dry(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.dry = value + .try_into() + .map_err(|e| format!("error converting supplied value for dry: {}", e)); + self + } + pub fn fresh(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.fresh = value + .try_into() + .map_err(|e| format!("error converting supplied value for fresh: {}", e)); + self + } + pub fn hbwr(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.hbwr = value + .try_into() + .map_err(|e| format!("error converting supplied value for hbwr: {}", e)); + self + } + pub fn insufflated(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.insufflated = value + .try_into() + .map_err(|e| format!("error converting supplied value for insufflated: {}", e)); + self + } + pub fn insufflated_pure(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.insufflated_pure = value.try_into().map_err(|e| { + format!( + "error converting supplied value for insufflated_pure: {}", + e + ) + }); + self + } + pub fn intramuscular(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.intramuscular = value + .try_into() + .map_err(|e| format!("error converting supplied value for intramuscular: {}", e)); + self + } + pub fn intravenous(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.intravenous = value + .try_into() + .map_err(|e| format!("error converting supplied value for intravenous: {}", e)); + self + } + pub fn morning_glory(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.morning_glory = value + .try_into() + .map_err(|e| format!("error converting supplied value for morning_glory: {}", e)); + self + } + pub fn oral(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.oral = value + .try_into() + .map_err(|e| format!("error converting supplied value for oral: {}", e)); + self + } + pub fn oral_benzedrex(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.oral_benzedrex = value + .try_into() + .map_err(|e| format!("error converting supplied value for oral_benzedrex: {}", e)); + self + } + pub fn oral_pure(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.oral_pure = value + .try_into() + .map_err(|e| format!("error converting supplied value for oral_pure: {}", e)); + self + } + pub fn rectal(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.rectal = value + .try_into() + .map_err(|e| format!("error converting supplied value for rectal: {}", e)); + self + } + pub fn smoked(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.smoked = value + .try_into() + .map_err(|e| format!("error converting supplied value for smoked: {}", e)); + self + } + pub fn sublingual(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.sublingual = value + .try_into() + .map_err(|e| format!("error converting supplied value for sublingual: {}", e)); + self + } + pub fn transdermal(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.transdermal = value + .try_into() + .map_err(|e| format!("error converting supplied value for transdermal: {}", e)); + self + } + pub fn vapourized(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.vapourized = value + .try_into() + .map_err(|e| format!("error converting supplied value for vapourized: {}", e)); + self + } + pub fn wet(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.wet = value + .try_into() + .map_err(|e| format!("error converting supplied value for wet: {}", e)); + self + } + } + impl std::convert::TryFrom for super::Dose { + type Error = super::error::ConversionError; + fn try_from(value: Dose) -> Result { + Ok(Self { + buccal: value.buccal?, + dried: value.dried?, + dry: value.dry?, + fresh: value.fresh?, + hbwr: value.hbwr?, + insufflated: value.insufflated?, + insufflated_pure: value.insufflated_pure?, + intramuscular: value.intramuscular?, + intravenous: value.intravenous?, + morning_glory: value.morning_glory?, + oral: value.oral?, + oral_benzedrex: value.oral_benzedrex?, + oral_pure: value.oral_pure?, + rectal: value.rectal?, + smoked: value.smoked?, + sublingual: value.sublingual?, + transdermal: value.transdermal?, + vapourized: value.vapourized?, + wet: value.wet?, + }) + } + } + impl From for Dose { + fn from(value: super::Dose) -> Self { + Self { + buccal: Ok(value.buccal), + dried: Ok(value.dried), + dry: Ok(value.dry), + fresh: Ok(value.fresh), + hbwr: Ok(value.hbwr), + insufflated: Ok(value.insufflated), + insufflated_pure: Ok(value.insufflated_pure), + intramuscular: Ok(value.intramuscular), + intravenous: Ok(value.intravenous), + morning_glory: Ok(value.morning_glory), + oral: Ok(value.oral), + oral_benzedrex: Ok(value.oral_benzedrex), + oral_pure: Ok(value.oral_pure), + rectal: Ok(value.rectal), + smoked: Ok(value.smoked), + sublingual: Ok(value.sublingual), + transdermal: Ok(value.transdermal), + vapourized: Ok(value.vapourized), + wet: Ok(value.wet), + } + } + } + #[derive(Clone, Debug)] + pub struct Drug { + aliases: Result, String>, + categories: Result, String>, + combos: Result, String>, + dose_note: Result, String>, + formatted_aftereffects: Result, String>, + formatted_dose: Result, String>, + formatted_duration: Result, String>, + formatted_effects: Result, String>, + formatted_onset: Result, String>, + links: Result, String>, + name: Result, + pretty_name: Result, + properties: Result, + pweffects: Result, String>, + sources: Result, String>, + } + impl Default for Drug { + fn default() -> Self { + Self { + aliases: Ok(Default::default()), + categories: Ok(Default::default()), + combos: Ok(Default::default()), + dose_note: Ok(Default::default()), + formatted_aftereffects: Ok(Default::default()), + formatted_dose: Ok(Default::default()), + formatted_duration: Ok(Default::default()), + formatted_effects: Ok(Default::default()), + formatted_onset: Ok(Default::default()), + links: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + pretty_name: Err("no value supplied for pretty_name".to_string()), + properties: Err("no value supplied for properties".to_string()), + pweffects: Ok(Default::default()), + sources: Ok(Default::default()), + } + } + } + impl Drug { + pub fn aliases(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.aliases = value + .try_into() + .map_err(|e| format!("error converting supplied value for aliases: {}", e)); + self + } + pub fn categories(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.categories = value + .try_into() + .map_err(|e| format!("error converting supplied value for categories: {}", e)); + self + } + pub fn combos(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.combos = value + .try_into() + .map_err(|e| format!("error converting supplied value for combos: {}", e)); + self + } + pub fn dose_note(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.dose_note = value + .try_into() + .map_err(|e| format!("error converting supplied value for dose_note: {}", e)); + self + } + pub fn formatted_aftereffects(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.formatted_aftereffects = value.try_into().map_err(|e| { + format!( + "error converting supplied value for formatted_aftereffects: {}", + e + ) + }); + self + } + pub fn formatted_dose(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.formatted_dose = value + .try_into() + .map_err(|e| format!("error converting supplied value for formatted_dose: {}", e)); + self + } + pub fn formatted_duration(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.formatted_duration = value.try_into().map_err(|e| { + format!( + "error converting supplied value for formatted_duration: {}", + e + ) + }); + self + } + pub fn formatted_effects(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.formatted_effects = value.try_into().map_err(|e| { + format!( + "error converting supplied value for formatted_effects: {}", + e + ) + }); + self + } + pub fn formatted_onset(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.formatted_onset = value + .try_into() + .map_err(|e| format!("error converting supplied value for formatted_onset: {}", e)); + self + } + pub fn links(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.links = value + .try_into() + .map_err(|e| format!("error converting supplied value for links: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn pretty_name(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.pretty_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for pretty_name: {}", e)); + self + } + pub fn properties(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.properties = value + .try_into() + .map_err(|e| format!("error converting supplied value for properties: {}", e)); + self + } + pub fn pweffects(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.pweffects = value + .try_into() + .map_err(|e| format!("error converting supplied value for pweffects: {}", e)); + self + } + pub fn sources(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.sources = value + .try_into() + .map_err(|e| format!("error converting supplied value for sources: {}", e)); + self + } + } + impl std::convert::TryFrom for super::Drug { + type Error = super::error::ConversionError; + fn try_from(value: Drug) -> Result { + Ok(Self { + aliases: value.aliases?, + categories: value.categories?, + combos: value.combos?, + dose_note: value.dose_note?, + formatted_aftereffects: value.formatted_aftereffects?, + formatted_dose: value.formatted_dose?, + formatted_duration: value.formatted_duration?, + formatted_effects: value.formatted_effects?, + formatted_onset: value.formatted_onset?, + links: value.links?, + name: value.name?, + pretty_name: value.pretty_name?, + properties: value.properties?, + pweffects: value.pweffects?, + sources: value.sources?, + }) + } + } + impl From for Drug { + fn from(value: super::Drug) -> Self { + Self { + aliases: Ok(value.aliases), + categories: Ok(value.categories), + combos: Ok(value.combos), + dose_note: Ok(value.dose_note), + formatted_aftereffects: Ok(value.formatted_aftereffects), + formatted_dose: Ok(value.formatted_dose), + formatted_duration: Ok(value.formatted_duration), + formatted_effects: Ok(value.formatted_effects), + formatted_onset: Ok(value.formatted_onset), + links: Ok(value.links), + name: Ok(value.name), + pretty_name: Ok(value.pretty_name), + properties: Ok(value.properties), + pweffects: Ok(value.pweffects), + sources: Ok(value.sources), + } + } + } + #[derive(Clone, Debug)] + pub struct DrugCombos { + _2c_t_x: Result, String>, + _2c_x: Result, String>, + _5_meo_xxt: Result, String>, + alcohol: Result, String>, + amphetamines: Result, String>, + amt: Result, String>, + benzodiazepines: Result, String>, + caffeine: Result, String>, + cannabis: Result, String>, + cocaine: Result, String>, + dextromethorphan: Result, String>, + diphenhydramine: Result, String>, + dmt: Result, String>, + dox: Result, String>, + ghb_gbl: Result, String>, + ketamine: Result, String>, + lithium: Result, String>, + lsd: Result, String>, + maois: Result, String>, + mdma: Result, String>, + mephedrone: Result, String>, + mescaline: Result, String>, + mushrooms: Result, String>, + mxe: Result, String>, + nbomes: Result, String>, + nitrous: Result, String>, + opioids: Result, String>, + pcp: Result, String>, + ssris: Result, String>, + tramadol: Result, String>, + } + impl Default for DrugCombos { + fn default() -> Self { + Self { + _2c_t_x: Ok(Default::default()), + _2c_x: Ok(Default::default()), + _5_meo_xxt: Ok(Default::default()), + alcohol: Ok(Default::default()), + amphetamines: Ok(Default::default()), + amt: Ok(Default::default()), + benzodiazepines: Ok(Default::default()), + caffeine: Ok(Default::default()), + cannabis: Ok(Default::default()), + cocaine: Ok(Default::default()), + dextromethorphan: Ok(Default::default()), + diphenhydramine: Ok(Default::default()), + dmt: Ok(Default::default()), + dox: Ok(Default::default()), + ghb_gbl: Ok(Default::default()), + ketamine: Ok(Default::default()), + lithium: Ok(Default::default()), + lsd: Ok(Default::default()), + maois: Ok(Default::default()), + mdma: Ok(Default::default()), + mephedrone: Ok(Default::default()), + mescaline: Ok(Default::default()), + mushrooms: Ok(Default::default()), + mxe: Ok(Default::default()), + nbomes: Ok(Default::default()), + nitrous: Ok(Default::default()), + opioids: Ok(Default::default()), + pcp: Ok(Default::default()), + ssris: Ok(Default::default()), + tramadol: Ok(Default::default()), + } + } + } + impl DrugCombos { + pub fn _2c_t_x(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self._2c_t_x = value + .try_into() + .map_err(|e| format!("error converting supplied value for _2c_t_x: {}", e)); + self + } + pub fn _2c_x(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self._2c_x = value + .try_into() + .map_err(|e| format!("error converting supplied value for _2c_x: {}", e)); + self + } + pub fn _5_meo_xxt(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self._5_meo_xxt = value + .try_into() + .map_err(|e| format!("error converting supplied value for _5_meo_xxt: {}", e)); + self + } + pub fn alcohol(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.alcohol = value + .try_into() + .map_err(|e| format!("error converting supplied value for alcohol: {}", e)); + self + } + pub fn amphetamines(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.amphetamines = value + .try_into() + .map_err(|e| format!("error converting supplied value for amphetamines: {}", e)); + self + } + pub fn amt(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.amt = value + .try_into() + .map_err(|e| format!("error converting supplied value for amt: {}", e)); + self + } + pub fn benzodiazepines(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.benzodiazepines = value + .try_into() + .map_err(|e| format!("error converting supplied value for benzodiazepines: {}", e)); + self + } + pub fn caffeine(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.caffeine = value + .try_into() + .map_err(|e| format!("error converting supplied value for caffeine: {}", e)); + self + } + pub fn cannabis(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.cannabis = value + .try_into() + .map_err(|e| format!("error converting supplied value for cannabis: {}", e)); + self + } + pub fn cocaine(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.cocaine = value + .try_into() + .map_err(|e| format!("error converting supplied value for cocaine: {}", e)); + self + } + pub fn dextromethorphan(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.dextromethorphan = value.try_into().map_err(|e| { + format!( + "error converting supplied value for dextromethorphan: {}", + e + ) + }); + self + } + pub fn diphenhydramine(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.diphenhydramine = value + .try_into() + .map_err(|e| format!("error converting supplied value for diphenhydramine: {}", e)); + self + } + pub fn dmt(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.dmt = value + .try_into() + .map_err(|e| format!("error converting supplied value for dmt: {}", e)); + self + } + pub fn dox(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.dox = value + .try_into() + .map_err(|e| format!("error converting supplied value for dox: {}", e)); + self + } + pub fn ghb_gbl(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.ghb_gbl = value + .try_into() + .map_err(|e| format!("error converting supplied value for ghb_gbl: {}", e)); + self + } + pub fn ketamine(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.ketamine = value + .try_into() + .map_err(|e| format!("error converting supplied value for ketamine: {}", e)); + self + } + pub fn lithium(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.lithium = value + .try_into() + .map_err(|e| format!("error converting supplied value for lithium: {}", e)); + self + } + pub fn lsd(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.lsd = value + .try_into() + .map_err(|e| format!("error converting supplied value for lsd: {}", e)); + self + } + pub fn maois(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.maois = value + .try_into() + .map_err(|e| format!("error converting supplied value for maois: {}", e)); + self + } + pub fn mdma(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.mdma = value + .try_into() + .map_err(|e| format!("error converting supplied value for mdma: {}", e)); + self + } + pub fn mephedrone(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.mephedrone = value + .try_into() + .map_err(|e| format!("error converting supplied value for mephedrone: {}", e)); + self + } + pub fn mescaline(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.mescaline = value + .try_into() + .map_err(|e| format!("error converting supplied value for mescaline: {}", e)); + self + } + pub fn mushrooms(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.mushrooms = value + .try_into() + .map_err(|e| format!("error converting supplied value for mushrooms: {}", e)); + self + } + pub fn mxe(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.mxe = value + .try_into() + .map_err(|e| format!("error converting supplied value for mxe: {}", e)); + self + } + pub fn nbomes(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.nbomes = value + .try_into() + .map_err(|e| format!("error converting supplied value for nbomes: {}", e)); + self + } + pub fn nitrous(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.nitrous = value + .try_into() + .map_err(|e| format!("error converting supplied value for nitrous: {}", e)); + self + } + pub fn opioids(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.opioids = value + .try_into() + .map_err(|e| format!("error converting supplied value for opioids: {}", e)); + self + } + pub fn pcp(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.pcp = value + .try_into() + .map_err(|e| format!("error converting supplied value for pcp: {}", e)); + self + } + pub fn ssris(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.ssris = value + .try_into() + .map_err(|e| format!("error converting supplied value for ssris: {}", e)); + self + } + pub fn tramadol(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.tramadol = value + .try_into() + .map_err(|e| format!("error converting supplied value for tramadol: {}", e)); + self + } + } + impl std::convert::TryFrom for super::DrugCombos { + type Error = super::error::ConversionError; + fn try_from(value: DrugCombos) -> Result { + Ok(Self { + _2c_t_x: value._2c_t_x?, + _2c_x: value._2c_x?, + _5_meo_xxt: value._5_meo_xxt?, + alcohol: value.alcohol?, + amphetamines: value.amphetamines?, + amt: value.amt?, + benzodiazepines: value.benzodiazepines?, + caffeine: value.caffeine?, + cannabis: value.cannabis?, + cocaine: value.cocaine?, + dextromethorphan: value.dextromethorphan?, + diphenhydramine: value.diphenhydramine?, + dmt: value.dmt?, + dox: value.dox?, + ghb_gbl: value.ghb_gbl?, + ketamine: value.ketamine?, + lithium: value.lithium?, + lsd: value.lsd?, + maois: value.maois?, + mdma: value.mdma?, + mephedrone: value.mephedrone?, + mescaline: value.mescaline?, + mushrooms: value.mushrooms?, + mxe: value.mxe?, + nbomes: value.nbomes?, + nitrous: value.nitrous?, + opioids: value.opioids?, + pcp: value.pcp?, + ssris: value.ssris?, + tramadol: value.tramadol?, + }) + } + } + impl From for DrugCombos { + fn from(value: super::DrugCombos) -> Self { + Self { + _2c_t_x: Ok(value._2c_t_x), + _2c_x: Ok(value._2c_x), + _5_meo_xxt: Ok(value._5_meo_xxt), + alcohol: Ok(value.alcohol), + amphetamines: Ok(value.amphetamines), + amt: Ok(value.amt), + benzodiazepines: Ok(value.benzodiazepines), + caffeine: Ok(value.caffeine), + cannabis: Ok(value.cannabis), + cocaine: Ok(value.cocaine), + dextromethorphan: Ok(value.dextromethorphan), + diphenhydramine: Ok(value.diphenhydramine), + dmt: Ok(value.dmt), + dox: Ok(value.dox), + ghb_gbl: Ok(value.ghb_gbl), + ketamine: Ok(value.ketamine), + lithium: Ok(value.lithium), + lsd: Ok(value.lsd), + maois: Ok(value.maois), + mdma: Ok(value.mdma), + mephedrone: Ok(value.mephedrone), + mescaline: Ok(value.mescaline), + mushrooms: Ok(value.mushrooms), + mxe: Ok(value.mxe), + nbomes: Ok(value.nbomes), + nitrous: Ok(value.nitrous), + opioids: Ok(value.opioids), + pcp: Ok(value.pcp), + ssris: Ok(value.ssris), + tramadol: Ok(value.tramadol), + } + } + } + #[derive(Clone, Debug)] + pub struct Duration { + buccal: Result, String>, + insufflated: Result, String>, + insufflated_ir: Result, String>, + insufflated_xr: Result, String>, + intramuscular: Result, String>, + intravenous: Result, String>, + metabolites: Result, String>, + oral: Result, String>, + oral_er: Result, String>, + oral_ir: Result, String>, + oral_maoi: Result, String>, + parent: Result, String>, + rectal: Result, String>, + smoked: Result, String>, + sublingual: Result, String>, + transdermal: Result, String>, + unit: Result, String>, + value: Result, String>, + vapourized: Result, String>, + } + impl Default for Duration { + fn default() -> Self { + Self { + buccal: Ok(Default::default()), + insufflated: Ok(Default::default()), + insufflated_ir: Ok(Default::default()), + insufflated_xr: Ok(Default::default()), + intramuscular: Ok(Default::default()), + intravenous: Ok(Default::default()), + metabolites: Ok(Default::default()), + oral: Ok(Default::default()), + oral_er: Ok(Default::default()), + oral_ir: Ok(Default::default()), + oral_maoi: Ok(Default::default()), + parent: Ok(Default::default()), + rectal: Ok(Default::default()), + smoked: Ok(Default::default()), + sublingual: Ok(Default::default()), + transdermal: Ok(Default::default()), + unit: Ok(Default::default()), + value: Ok(Default::default()), + vapourized: Ok(Default::default()), + } + } + } + impl Duration { + pub fn buccal(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.buccal = value + .try_into() + .map_err(|e| format!("error converting supplied value for buccal: {}", e)); + self + } + pub fn insufflated(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.insufflated = value + .try_into() + .map_err(|e| format!("error converting supplied value for insufflated: {}", e)); + self + } + pub fn insufflated_ir(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.insufflated_ir = value + .try_into() + .map_err(|e| format!("error converting supplied value for insufflated_ir: {}", e)); + self + } + pub fn insufflated_xr(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.insufflated_xr = value + .try_into() + .map_err(|e| format!("error converting supplied value for insufflated_xr: {}", e)); + self + } + pub fn intramuscular(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.intramuscular = value + .try_into() + .map_err(|e| format!("error converting supplied value for intramuscular: {}", e)); + self + } + pub fn intravenous(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.intravenous = value + .try_into() + .map_err(|e| format!("error converting supplied value for intravenous: {}", e)); + self + } + pub fn metabolites(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.metabolites = value + .try_into() + .map_err(|e| format!("error converting supplied value for metabolites: {}", e)); + self + } + pub fn oral(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.oral = value + .try_into() + .map_err(|e| format!("error converting supplied value for oral: {}", e)); + self + } + pub fn oral_er(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.oral_er = value + .try_into() + .map_err(|e| format!("error converting supplied value for oral_er: {}", e)); + self + } + pub fn oral_ir(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.oral_ir = value + .try_into() + .map_err(|e| format!("error converting supplied value for oral_ir: {}", e)); + self + } + pub fn oral_maoi(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.oral_maoi = value + .try_into() + .map_err(|e| format!("error converting supplied value for oral_maoi: {}", e)); + self + } + pub fn parent(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.parent = value + .try_into() + .map_err(|e| format!("error converting supplied value for parent: {}", e)); + self + } + pub fn rectal(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.rectal = value + .try_into() + .map_err(|e| format!("error converting supplied value for rectal: {}", e)); + self + } + pub fn smoked(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.smoked = value + .try_into() + .map_err(|e| format!("error converting supplied value for smoked: {}", e)); + self + } + pub fn sublingual(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.sublingual = value + .try_into() + .map_err(|e| format!("error converting supplied value for sublingual: {}", e)); + self + } + pub fn transdermal(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.transdermal = value + .try_into() + .map_err(|e| format!("error converting supplied value for transdermal: {}", e)); + self + } + pub fn unit(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.unit = value + .try_into() + .map_err(|e| format!("error converting supplied value for unit: {}", e)); + self + } + pub fn value(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.value = value + .try_into() + .map_err(|e| format!("error converting supplied value for value: {}", e)); + self + } + pub fn vapourized(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.vapourized = value + .try_into() + .map_err(|e| format!("error converting supplied value for vapourized: {}", e)); + self + } + } + impl std::convert::TryFrom for super::Duration { + type Error = super::error::ConversionError; + fn try_from(value: Duration) -> Result { + Ok(Self { + buccal: value.buccal?, + insufflated: value.insufflated?, + insufflated_ir: value.insufflated_ir?, + insufflated_xr: value.insufflated_xr?, + intramuscular: value.intramuscular?, + intravenous: value.intravenous?, + metabolites: value.metabolites?, + oral: value.oral?, + oral_er: value.oral_er?, + oral_ir: value.oral_ir?, + oral_maoi: value.oral_maoi?, + parent: value.parent?, + rectal: value.rectal?, + smoked: value.smoked?, + sublingual: value.sublingual?, + transdermal: value.transdermal?, + unit: value.unit?, + value: value.value?, + vapourized: value.vapourized?, + }) + } + } + impl From for Duration { + fn from(value: super::Duration) -> Self { + Self { + buccal: Ok(value.buccal), + insufflated: Ok(value.insufflated), + insufflated_ir: Ok(value.insufflated_ir), + insufflated_xr: Ok(value.insufflated_xr), + intramuscular: Ok(value.intramuscular), + intravenous: Ok(value.intravenous), + metabolites: Ok(value.metabolites), + oral: Ok(value.oral), + oral_er: Ok(value.oral_er), + oral_ir: Ok(value.oral_ir), + oral_maoi: Ok(value.oral_maoi), + parent: Ok(value.parent), + rectal: Ok(value.rectal), + smoked: Ok(value.smoked), + sublingual: Ok(value.sublingual), + transdermal: Ok(value.transdermal), + unit: Ok(value.unit), + value: Ok(value.value), + vapourized: Ok(value.vapourized), + } + } + } + #[derive(Clone, Debug)] + pub struct Links { + experiences: Result, + pihkal: Result, String>, + tihkal: Result, String>, + } + impl Default for Links { + fn default() -> Self { + Self { + experiences: Err("no value supplied for experiences".to_string()), + pihkal: Ok(Default::default()), + tihkal: Ok(Default::default()), + } + } + } + impl Links { + pub fn experiences(mut self, value: T) -> Self + where + T: std::convert::TryInto, + T::Error: std::fmt::Display, + { + self.experiences = value + .try_into() + .map_err(|e| format!("error converting supplied value for experiences: {}", e)); + self + } + pub fn pihkal(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.pihkal = value + .try_into() + .map_err(|e| format!("error converting supplied value for pihkal: {}", e)); + self + } + pub fn tihkal(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.tihkal = value + .try_into() + .map_err(|e| format!("error converting supplied value for tihkal: {}", e)); + self + } + } + impl std::convert::TryFrom for super::Links { + type Error = super::error::ConversionError; + fn try_from(value: Links) -> Result { + Ok(Self { + experiences: value.experiences?, + pihkal: value.pihkal?, + tihkal: value.tihkal?, + }) + } + } + impl From for Links { + fn from(value: super::Links) -> Self { + Self { + experiences: Ok(value.experiences), + pihkal: Ok(value.pihkal), + tihkal: Ok(value.tihkal), + } + } + } + #[derive(Clone, Debug)] + pub struct Properties { + adverse_effects: Result, String>, + after_effects: Result, String>, + aliases: Result, String>, + avoid: Result, String>, + bioavailability: Result, String>, + calculator: Result, String>, + categories: Result, String>, + chart: Result, String>, + chemistry: Result, String>, + comeup: Result, String>, + contraindications: Result, String>, + detection: Result, String>, + dose: Result, String>, + dose_to_diazepam: Result, String>, + duration: Result, String>, + effects: Result, String>, + experiences: Result, String>, + general_advice: Result, String>, + half_life: Result, String>, + legal: Result, String>, + marquis: Result, String>, + mdma: Result, String>, + molecule: Result, String>, + note: Result, String>, + obtain: Result, String>, + onset: Result, String>, + oral: Result, String>, + overdose_symptoms: Result, String>, + pharmacodynamics: Result, String>, + pharmacokinetics: Result, String>, + pharmacology: Result, String>, + potentiators: Result, String>, + risks: Result, String>, + side_effects: Result, String>, + summary: Result, String>, + test_kits: Result, String>, + tolerance: Result, String>, + vaporization: Result, String>, + warning: Result, String>, + wiki: Result, String>, + } + impl Default for Properties { + fn default() -> Self { + Self { + adverse_effects: Ok(Default::default()), + after_effects: Ok(Default::default()), + aliases: Ok(Default::default()), + avoid: Ok(Default::default()), + bioavailability: Ok(Default::default()), + calculator: Ok(Default::default()), + categories: Ok(Default::default()), + chart: Ok(Default::default()), + chemistry: Ok(Default::default()), + comeup: Ok(Default::default()), + contraindications: Ok(Default::default()), + detection: Ok(Default::default()), + dose: Ok(Default::default()), + dose_to_diazepam: Ok(Default::default()), + duration: Ok(Default::default()), + effects: Ok(Default::default()), + experiences: Ok(Default::default()), + general_advice: Ok(Default::default()), + half_life: Ok(Default::default()), + legal: Ok(Default::default()), + marquis: Ok(Default::default()), + mdma: Ok(Default::default()), + molecule: Ok(Default::default()), + note: Ok(Default::default()), + obtain: Ok(Default::default()), + onset: Ok(Default::default()), + oral: Ok(Default::default()), + overdose_symptoms: Ok(Default::default()), + pharmacodynamics: Ok(Default::default()), + pharmacokinetics: Ok(Default::default()), + pharmacology: Ok(Default::default()), + potentiators: Ok(Default::default()), + risks: Ok(Default::default()), + side_effects: Ok(Default::default()), + summary: Ok(Default::default()), + test_kits: Ok(Default::default()), + tolerance: Ok(Default::default()), + vaporization: Ok(Default::default()), + warning: Ok(Default::default()), + wiki: Ok(Default::default()), + } + } + } + impl Properties { + pub fn adverse_effects(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.adverse_effects = value + .try_into() + .map_err(|e| format!("error converting supplied value for adverse_effects: {}", e)); + self + } + pub fn after_effects(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.after_effects = value + .try_into() + .map_err(|e| format!("error converting supplied value for after_effects: {}", e)); + self + } + pub fn aliases(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.aliases = value + .try_into() + .map_err(|e| format!("error converting supplied value for aliases: {}", e)); + self + } + pub fn avoid(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.avoid = value + .try_into() + .map_err(|e| format!("error converting supplied value for avoid: {}", e)); + self + } + pub fn bioavailability(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.bioavailability = value + .try_into() + .map_err(|e| format!("error converting supplied value for bioavailability: {}", e)); + self + } + pub fn calculator(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.calculator = value + .try_into() + .map_err(|e| format!("error converting supplied value for calculator: {}", e)); + self + } + pub fn categories(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.categories = value + .try_into() + .map_err(|e| format!("error converting supplied value for categories: {}", e)); + self + } + pub fn chart(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.chart = value + .try_into() + .map_err(|e| format!("error converting supplied value for chart: {}", e)); + self + } + pub fn chemistry(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.chemistry = value + .try_into() + .map_err(|e| format!("error converting supplied value for chemistry: {}", e)); + self + } + pub fn comeup(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.comeup = value + .try_into() + .map_err(|e| format!("error converting supplied value for comeup: {}", e)); + self + } + pub fn contraindications(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.contraindications = value.try_into().map_err(|e| { + format!( + "error converting supplied value for contraindications: {}", + e + ) + }); + self + } + pub fn detection(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.detection = value + .try_into() + .map_err(|e| format!("error converting supplied value for detection: {}", e)); + self + } + pub fn dose(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.dose = value + .try_into() + .map_err(|e| format!("error converting supplied value for dose: {}", e)); + self + } + pub fn dose_to_diazepam(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.dose_to_diazepam = value.try_into().map_err(|e| { + format!( + "error converting supplied value for dose_to_diazepam: {}", + e + ) + }); + self + } + pub fn duration(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.duration = value + .try_into() + .map_err(|e| format!("error converting supplied value for duration: {}", e)); + self + } + pub fn effects(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.effects = value + .try_into() + .map_err(|e| format!("error converting supplied value for effects: {}", e)); + self + } + pub fn experiences(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.experiences = value + .try_into() + .map_err(|e| format!("error converting supplied value for experiences: {}", e)); + self + } + pub fn general_advice(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.general_advice = value + .try_into() + .map_err(|e| format!("error converting supplied value for general_advice: {}", e)); + self + } + pub fn half_life(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.half_life = value + .try_into() + .map_err(|e| format!("error converting supplied value for half_life: {}", e)); + self + } + pub fn legal(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.legal = value + .try_into() + .map_err(|e| format!("error converting supplied value for legal: {}", e)); + self + } + pub fn marquis(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.marquis = value + .try_into() + .map_err(|e| format!("error converting supplied value for marquis: {}", e)); + self + } + pub fn mdma(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.mdma = value + .try_into() + .map_err(|e| format!("error converting supplied value for mdma: {}", e)); + self + } + pub fn molecule(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.molecule = value + .try_into() + .map_err(|e| format!("error converting supplied value for molecule: {}", e)); + self + } + pub fn note(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.note = value + .try_into() + .map_err(|e| format!("error converting supplied value for note: {}", e)); + self + } + pub fn obtain(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.obtain = value + .try_into() + .map_err(|e| format!("error converting supplied value for obtain: {}", e)); + self + } + pub fn onset(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.onset = value + .try_into() + .map_err(|e| format!("error converting supplied value for onset: {}", e)); + self + } + pub fn oral(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.oral = value + .try_into() + .map_err(|e| format!("error converting supplied value for oral: {}", e)); + self + } + pub fn overdose_symptoms(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.overdose_symptoms = value.try_into().map_err(|e| { + format!( + "error converting supplied value for overdose_symptoms: {}", + e + ) + }); + self + } + pub fn pharmacodynamics(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.pharmacodynamics = value.try_into().map_err(|e| { + format!( + "error converting supplied value for pharmacodynamics: {}", + e + ) + }); + self + } + pub fn pharmacokinetics(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.pharmacokinetics = value.try_into().map_err(|e| { + format!( + "error converting supplied value for pharmacokinetics: {}", + e + ) + }); + self + } + pub fn pharmacology(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.pharmacology = value + .try_into() + .map_err(|e| format!("error converting supplied value for pharmacology: {}", e)); + self + } + pub fn potentiators(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.potentiators = value + .try_into() + .map_err(|e| format!("error converting supplied value for potentiators: {}", e)); + self + } + pub fn risks(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.risks = value + .try_into() + .map_err(|e| format!("error converting supplied value for risks: {}", e)); + self + } + pub fn side_effects(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.side_effects = value + .try_into() + .map_err(|e| format!("error converting supplied value for side_effects: {}", e)); + self + } + pub fn summary(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.summary = value + .try_into() + .map_err(|e| format!("error converting supplied value for summary: {}", e)); + self + } + pub fn test_kits(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.test_kits = value + .try_into() + .map_err(|e| format!("error converting supplied value for test_kits: {}", e)); + self + } + pub fn tolerance(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.tolerance = value + .try_into() + .map_err(|e| format!("error converting supplied value for tolerance: {}", e)); + self + } + pub fn vaporization(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.vaporization = value + .try_into() + .map_err(|e| format!("error converting supplied value for vaporization: {}", e)); + self + } + pub fn warning(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.warning = value + .try_into() + .map_err(|e| format!("error converting supplied value for warning: {}", e)); + self + } + pub fn wiki(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.wiki = value + .try_into() + .map_err(|e| format!("error converting supplied value for wiki: {}", e)); + self + } + } + impl std::convert::TryFrom for super::Properties { + type Error = super::error::ConversionError; + fn try_from(value: Properties) -> Result { + Ok(Self { + adverse_effects: value.adverse_effects?, + after_effects: value.after_effects?, + aliases: value.aliases?, + avoid: value.avoid?, + bioavailability: value.bioavailability?, + calculator: value.calculator?, + categories: value.categories?, + chart: value.chart?, + chemistry: value.chemistry?, + comeup: value.comeup?, + contraindications: value.contraindications?, + detection: value.detection?, + dose: value.dose?, + dose_to_diazepam: value.dose_to_diazepam?, + duration: value.duration?, + effects: value.effects?, + experiences: value.experiences?, + general_advice: value.general_advice?, + half_life: value.half_life?, + legal: value.legal?, + marquis: value.marquis?, + mdma: value.mdma?, + molecule: value.molecule?, + note: value.note?, + obtain: value.obtain?, + onset: value.onset?, + oral: value.oral?, + overdose_symptoms: value.overdose_symptoms?, + pharmacodynamics: value.pharmacodynamics?, + pharmacokinetics: value.pharmacokinetics?, + pharmacology: value.pharmacology?, + potentiators: value.potentiators?, + risks: value.risks?, + side_effects: value.side_effects?, + summary: value.summary?, + test_kits: value.test_kits?, + tolerance: value.tolerance?, + vaporization: value.vaporization?, + warning: value.warning?, + wiki: value.wiki?, + }) + } + } + impl From for Properties { + fn from(value: super::Properties) -> Self { + Self { + adverse_effects: Ok(value.adverse_effects), + after_effects: Ok(value.after_effects), + aliases: Ok(value.aliases), + avoid: Ok(value.avoid), + bioavailability: Ok(value.bioavailability), + calculator: Ok(value.calculator), + categories: Ok(value.categories), + chart: Ok(value.chart), + chemistry: Ok(value.chemistry), + comeup: Ok(value.comeup), + contraindications: Ok(value.contraindications), + detection: Ok(value.detection), + dose: Ok(value.dose), + dose_to_diazepam: Ok(value.dose_to_diazepam), + duration: Ok(value.duration), + effects: Ok(value.effects), + experiences: Ok(value.experiences), + general_advice: Ok(value.general_advice), + half_life: Ok(value.half_life), + legal: Ok(value.legal), + marquis: Ok(value.marquis), + mdma: Ok(value.mdma), + molecule: Ok(value.molecule), + note: Ok(value.note), + obtain: Ok(value.obtain), + onset: Ok(value.onset), + oral: Ok(value.oral), + overdose_symptoms: Ok(value.overdose_symptoms), + pharmacodynamics: Ok(value.pharmacodynamics), + pharmacokinetics: Ok(value.pharmacokinetics), + pharmacology: Ok(value.pharmacology), + potentiators: Ok(value.potentiators), + risks: Ok(value.risks), + side_effects: Ok(value.side_effects), + summary: Ok(value.summary), + test_kits: Ok(value.test_kits), + tolerance: Ok(value.tolerance), + vaporization: Ok(value.vaporization), + warning: Ok(value.warning), + wiki: Ok(value.wiki), + } + } + } + #[derive(Clone, Debug)] + pub struct SourceData { + author: Result, String>, + title: Result, String>, + url: Result, String>, + } + impl Default for SourceData { + fn default() -> Self { + Self { + author: Ok(Default::default()), + title: Ok(Default::default()), + url: Ok(Default::default()), + } + } + } + impl SourceData { + pub fn author(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.author = value + .try_into() + .map_err(|e| format!("error converting supplied value for author: {}", e)); + self + } + pub fn title(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.title = value + .try_into() + .map_err(|e| format!("error converting supplied value for title: {}", e)); + self + } + pub fn url(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.url = value + .try_into() + .map_err(|e| format!("error converting supplied value for url: {}", e)); + self + } + } + impl std::convert::TryFrom for super::SourceData { + type Error = super::error::ConversionError; + fn try_from(value: SourceData) -> Result { + Ok(Self { + author: value.author?, + title: value.title?, + url: value.url?, + }) + } + } + impl From for SourceData { + fn from(value: super::SourceData) -> Self { + Self { + author: Ok(value.author), + title: Ok(value.title), + url: Ok(value.url), + } + } + } + #[derive(Clone, Debug)] + pub struct Sources { + bioavailability: Result, String>, + dose: Result, String>, + duration: Result, String>, + general: Result, String>, + legality: Result, String>, + onset: Result, String>, + } + impl Default for Sources { + fn default() -> Self { + Self { + bioavailability: Ok(Default::default()), + dose: Ok(Default::default()), + duration: Ok(Default::default()), + general: Ok(Default::default()), + legality: Ok(Default::default()), + onset: Ok(Default::default()), + } + } + } + impl Sources { + pub fn bioavailability(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.bioavailability = value + .try_into() + .map_err(|e| format!("error converting supplied value for bioavailability: {}", e)); + self + } + pub fn dose(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.dose = value + .try_into() + .map_err(|e| format!("error converting supplied value for dose: {}", e)); + self + } + pub fn duration(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.duration = value + .try_into() + .map_err(|e| format!("error converting supplied value for duration: {}", e)); + self + } + pub fn general(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.general = value + .try_into() + .map_err(|e| format!("error converting supplied value for general: {}", e)); + self + } + pub fn legality(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.legality = value + .try_into() + .map_err(|e| format!("error converting supplied value for legality: {}", e)); + self + } + pub fn onset(mut self, value: T) -> Self + where + T: std::convert::TryInto>, + T::Error: std::fmt::Display, + { + self.onset = value + .try_into() + .map_err(|e| format!("error converting supplied value for onset: {}", e)); + self + } + } + impl std::convert::TryFrom for super::Sources { + type Error = super::error::ConversionError; + fn try_from(value: Sources) -> Result { + Ok(Self { + bioavailability: value.bioavailability?, + dose: value.dose?, + duration: value.duration?, + general: value.general?, + legality: value.legality?, + onset: value.onset?, + }) + } + } + impl From for Sources { + fn from(value: super::Sources) -> Self { + Self { + bioavailability: Ok(value.bioavailability), + dose: Ok(value.dose), + duration: Ok(value.duration), + general: Ok(value.general), + legality: Ok(value.legality), + onset: Ok(value.onset), + } + } + } +} diff --git a/client/src/drugs/mod.rs b/client/src/drugs/mod.rs new file mode 100644 index 0000000..42027dc --- /dev/null +++ b/client/src/drugs/mod.rs @@ -0,0 +1 @@ +mod drug_schema; diff --git a/client/src/main.rs b/client/src/main.rs index 574adc0..a358080 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -17,12 +17,12 @@ mod util; mod drugs_parser; -mod substances_new; +mod drugs; -mod ingestions; -mod ingestions_util; -mod substance_util; -mod substances; +// mod ingestions; +// mod ingestions_util; +// mod substance_util; +// mod substances; // mod drug_parser; @@ -77,19 +77,19 @@ fn print_completions(gen: G, cmd: &mut Command) { fn main() { drugs_parser::parse(); - ensure_files(); + // ensure_files(); let cli = Cli::parse(); match cli.command { - Some(Commands::AddIngestion) => ingestions::add_ingestion(), - Some(Commands::EditIngestion) => ingestions::edit_ingestion().unwrap(), - Some(Commands::ListIngestions) => ingestions::list_ingestions().unwrap(), - Some(Commands::RemoveIngestion) => {} - Some(Commands::AddSubstance) => substances::add_substance().unwrap(), - Some(Commands::EditSubstance) => substances::edit_substance().unwrap(), - Some(Commands::ListSubstances) => substances::list_substances().unwrap(), - Some(Commands::RemoveSubstance) => substances::remove_substance().unwrap(), + // Some(Commands::AddIngestion) => ingestions::add_ingestion(), + // Some(Commands::EditIngestion) => ingestions::edit_ingestion().unwrap(), + // Some(Commands::ListIngestions) => ingestions::list_ingestions().unwrap(), + // Some(Commands::RemoveIngestion) => {} + // Some(Commands::AddSubstance) => substances::add_substance().unwrap(), + // Some(Commands::EditSubstance) => substances::edit_substance().unwrap(), + // Some(Commands::ListSubstances) => substances::list_substances().unwrap(), + // Some(Commands::RemoveSubstance) => substances::remove_substance().unwrap(), Some(Commands::GenerateCompletions { shell }) => { let mut cmd = Cli::command(); eprintln!("Generating completion file for {shell}..."); @@ -103,45 +103,46 @@ fn main() { } None => {} + _ => {} } } -fn ensure_files() { - if !util::path_exists(LOCAL_PATH.to_string()) { - match std::fs::create_dir(LOCAL_PATH.to_string()) { - Ok(_) => {} - Err(e) => { - eprintln!("Could not create data directory with error: {:?}", e); - std::process::exit(1); - } - } - } - if !util::path_exists(SUBSTANCES_FILE.to_string()) { - match substance_util::create_substances_file() { - Ok(_) => { - println!( - "Created substances file at {:?}", - SUBSTANCES_FILE.to_string() - ) - } - Err(_) => { - eprintln!("Could not create substances file"); - panic!() - } - }; - } - if !util::path_exists(INGESTIONS_FILE.to_string()) { - match ingestions::create_ingestions_file() { - Ok(_) => { - println!( - "Created ingestions file at {:?}", - INGESTIONS_FILE.to_string() - ) - } - Err(_) => { - eprintln!("Could not create substances file"); - panic!() - } - }; - } -} +// fn ensure_files() { +// if !util::path_exists(LOCAL_PATH.to_string()) { +// match std::fs::create_dir(LOCAL_PATH.to_string()) { +// Ok(_) => {} +// Err(e) => { +// eprintln!("Could not create data directory with error: {:?}", e); +// std::process::exit(1); +// } +// } +// } +// if !util::path_exists(SUBSTANCES_FILE.to_string()) { +// match substance_util::create_substances_file() { +// Ok(_) => { +// println!( +// "Created substances file at {:?}", +// SUBSTANCES_FILE.to_string() +// ) +// } +// Err(_) => { +// eprintln!("Could not create substances file"); +// panic!() +// } +// }; +// } +// if !util::path_exists(INGESTIONS_FILE.to_string()) { +// match ingestions::create_ingestions_file() { +// Ok(_) => { +// println!( +// "Created ingestions file at {:?}", +// INGESTIONS_FILE.to_string() +// ) +// } +// Err(_) => { +// eprintln!("Could not create substances file"); +// panic!() +// } +// }; +// } +// } diff --git a/client/src/substances_new/mod.rs b/client/src/substances_new/mod.rs deleted file mode 100644 index cf371fc..0000000 --- a/client/src/substances_new/mod.rs +++ /dev/null @@ -1,356 +0,0 @@ -// export type Drug = { -// aliases?: string[]; -// categories?: Category[]; -// formatted_aftereffects?: Duration; -// formatted_dose?: Dose; -// formatted_duration?: Duration; -// formatted_effects?: string[]; -// formatted_onset?: Duration; -// links?: Links; -// name: string; -// pretty_name: string; -// properties: Properties; -// pweffects?: { [key: string]: string }; -// dose_note?: string; -// sources?: Sources; -// combos?: Interactions; -// }; -// -// export enum Category { -// Barbiturate = "barbiturate", -// Benzodiazepine = "benzodiazepine", -// Common = "common", -// Deliriant = "deliriant", -// Depressant = "depressant", -// Dissociative = "dissociative", -// Empathogen = "empathogen", -// HabitForming = "habit-forming", -// Inactive = "inactive", -// Nootropic = "nootropic", -// Opioid = "opioid", -// Psychedelic = "psychedelic", -// ResearchChemical = "research-chemical", -// Ssri = "ssri", -// Stimulant = "stimulant", -// Supplement = "supplement", -// Tentative = "tentative", -// } -// -// export type Duration = { -// _unit: Unit; -// value?: string; -// insufflated?: string; -// oral?: string; -// rectal?: string; -// vapourized?: string; -// smoked?: string; -// Oral_ER?: string; -// Oral_IR?: string; -// Oral_MAOI?: string; -// intramuscular?: string; -// intravenous?: string; -// metabolites?: string; -// parent?: string; -// oralMAOI?: string; -// buccal?: string; -// transdermal?: string; -// sublingual?: string; -// Insufflated_IR?: string; -// Insufflated_XR?: string; -// }; -// -// export type Dose = { -// oral?: Dosage; -// insufflated?: Dosage; -// rectal?: Dosage; -// vapourized?: Dosage; -// intravenous?: Dosage; -// smoked?: Dosage; -// sublingual?: Dosage; -// buccal?: Dosage; -// intramuscular?: Dosage; -// transdermal?: Dosage; -// hbwr?: Dosage; -// Morning_Glory?: Dosage; -// dried?: Dosage; -// fresh?: Dosage; -// "Insufflated(Pure)"?: Dosage; -// "Oral(Benzedrex)"?: Dosage; -// "Oral(Pure)"?: Dosage; -// dry?: Dosage; -// wet?: Dosage; -// }; -// -// export type Dosage = { -// common?: string; -// light?: string; -// strong?: string; -// threshold?: string; -// heavy?: string; -// dangerous?: string; -// fatal?: string; -// note?: string; -// }; -// -// export type Links = { -// experiences: string; -// pihkal?: string; -// tihkal?: string; -// }; -// -// export type Properties = { -// "after-effects"?: string; -// aliases?: string[]; -// avoid?: string; -// categories?: Category[]; -// dose?: string; -// duration?: string; -// "half-life"?: string; -// onset?: string; -// summary?: string; -// "test-kits"?: string; -// experiences?: string; -// warning?: string; -// marquis?: string; -// effects?: string; -// risks?: string; -// comeup?: string; -// note?: string; -// detection?: string; -// wiki?: string; -// mdma?: string; -// tolerance?: string; -// bioavailability?: string; -// dose_to_diazepam?: string; -// "adverse-effects"?: string; -// chemistry?: string; -// contraindications?: string; -// legal?: string; -// "overdose-symptoms"?: string; -// pharmacokinetics?: string; -// pharmacology?: string; -// obtain?: string; -// pharmacodynamics?: string; -// "side-effects"?: string; -// molecule?: string; -// vaporization?: string; -// calculator?: string; -// chart?: string; -// oral?: string; -// "general-advice"?: string; -// potentiators?: string; -// }; -// -// export interface Combos { -// "2c-t-x": Interactions; -// "2c-x": Interactions; -// "5-meo-xxt": Interactions; -// alcohol: Interactions; -// amphetamines: Interactions; -// amt: Interactions; -// benzodiazepines: Interactions; -// caffeine: Interactions; -// cannabis: Interactions; -// cocaine: Interactions; -// diphenhydramine: Interactions; -// dextromethorphan: Interactions; -// dmt: Interactions; -// dox: Interactions; -// "ghb/gbl": Interactions; -// ketamine: Interactions; -// lithium: Interactions; -// lsd: Interactions; -// maois: Interactions; -// mdma: Interactions; -// mephedrone: Interactions; -// mescaline: Interactions; -// mushrooms: Interactions; -// mxe: Interactions; -// nbomes: Interactions; -// nitrous: Interactions; -// opioids: Interactions; -// pcp: Interactions; -// ssris: Interactions; -// tramadol: Interactions; -// } -// -// export interface Interactions { -// "2c-t-x"?: ComboData; -// "2c-x"?: ComboData; -// "5-meo-xxt"?: ComboData; -// alcohol?: ComboData; -// amphetamines?: ComboData; -// amt?: ComboData; -// benzodiazepines?: ComboData; -// caffeine?: ComboData; -// cannabis?: ComboData; -// cocaine?: ComboData; -// diphenhydramine?: ComboData; -// dextromethorphan?: ComboData; -// dmt?: ComboData; -// dox?: ComboData; -// "ghb/gbl"?: ComboData; -// lithium?: ComboData; -// ketamine?: ComboData; -// lsd?: ComboData; -// maois?: ComboData; -// mdma?: ComboData; -// mephedrone?: ComboData; -// mescaline?: ComboData; -// mushrooms?: ComboData; -// mxe?: ComboData; -// nbomes?: ComboData; -// nitrous?: ComboData; -// opioids?: ComboData; -// pcp?: ComboData; -// ssris?: ComboData; -// tramadol?: ComboData; -// } -// -// export interface ComboData { -// note?: string; -// sources?: { -// author: string; -// title: string; -// url: string; -// }[]; -// status: Status; -// } -// -// export enum Status { -// Caution = "Caution", -// Dangerous = "Dangerous", -// LowRiskDecrease = "Low Risk & Decrease", -// LowRiskNoSynergy = "Low Risk & No Synergy", -// LowRiskSynergy = "Low Risk & Synergy", -// Self = "Self", -// Unsafe = "Unsafe", -// } -// -// export type ComboDefinitions = { -// status: Status; -// emoji: string; -// color: string; -// definition: string; -// thumbnail: string; -// } -// -// export enum Unit { -// Hours = "hours", -// Minutes = "minutes", -// } -// -// export type Sources = { -// general?: string[]; -// dose?: string[]; -// duration?: string[]; -// bioavailability?: string[]; -// legality?: string[]; -// onset?: string[]; -// }; - -pub struct Dug { - aliases: Option>, - categories: Option>, - formatted_aftereffects: Option, - formatted_dose: Option, - formatted_duration: Option, - formatted_effects: Option>, - formatted_onset: Option, - links: Option, - name: String, - pretty_name: String, - properties: Properties, - pweffects: Option<(String, Strin)>, - dose_note: Option, - sources: Option, - combos: Option, -} - -pub enum Category { - Barbiturate, - Benzodiazepine, - Common, - Deliriant, - Depressant, - Dissociative, - Empathogen, - HabitForming, - Inactive, - Nootropic, - Opioid, - Psychedelic, - ResearchChemical, - Ssri, - Stimulant, - Supplement, - Tentative, -} - -pub struct Duration { - unit: Unit, - value: Option, - insufflated: Option, - oral: Option, - rectal: Option, - vapourized: Option, - smoked: Option, - oral_ER: Option, - oral_IR: Option, - oral_MAOI: Option, - intramuscular: Option, - intravenous: Option, - metabolites: Option, - parent: Option, - oralMAOI: Option, - buccal: Option, - transdermal: Option, - sublingual: Option, - Insufflated_IR: Option, - Insufflated_XR: Option, -} - -pub struct Dose { - oral: Option, - insufflated: Option, - rectal: Option, - vapourized: Option, - intravenous: Option, - smoked: Option, - sublingual: Option, - buccal: Option, - intramuscular: Option, - transdermal: Option, - hbwr: Option, - morning_glory: Option, - dried: Option, - fresh: Option, - insufflated_pure: Option, - oral_benzedrex: Option, - oral_pure: Option, - dry: Option, - wet: Option, -} - -pub struct Dosage { - common: Option, - light: Option, - strong: Option, - threshold: Option, - heavy: Option, - dangerous: Option, - fatal: Option, - note: Option, -} - -pub struct Links { - experiences: String, - pihkal: Option, - tihkal: Option, -} - -pub struct Properties { - after_effects: Option, - aliases: Option>, - avoid: Option, -} diff --git a/server/src/main.rs b/server/src/main.rs index 7bf897d..3296c36 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -1,6 +1,6 @@ use tonic; fn main() { - let addr = "[::1]:50051".parse(); + // let addr = "[::1]:50051".parse(); println!("Hello, world!"); }