aw-test 0.0.2

Appwrite Rust SDK
Documentation
#![allow(unused)]
use serde::{Deserialize, Serialize, Deserializer};
use std::collections::HashMap;
use serde_json::value::Value;
use std::fmt::Display;
use super::*;

#[derive(Debug, Serialize, Clone)]
#[serde(deny_unknown_fields)]
#[serde(untagged)]
pub enum EmptyOption<T> {
    Some(T),
    None {},
}

impl<T> Display for EmptyOption<T>
where
    T: Display,
{
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        match self {
            EmptyOption::Some(t) => write!(f, "{}", t),
            EmptyOption::None {} => write!(f, ""),
        }
    }
}

impl<'de, T> Deserialize<'de> for EmptyOption<T>
where
    T: Deserialize<'de>,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: Deserializer<'de>,
    {
        Option::deserialize(deserializer).map(Into::into)
    }
}

impl<T> From<EmptyOption<T>> for Option<T> {
    fn from(empty_option: EmptyOption<T>) -> Option<T> {
        match empty_option {
            EmptyOption::Some(option) => Some(option),
            EmptyOption::None {} => None,
        }
    }
}

impl<T> From<Option<T>> for EmptyOption<T> {
    fn from(option: Option<T>) -> EmptyOption<T> {
        match option {
            Some(option) => EmptyOption::Some(option),
            None {} => EmptyOption::None {},
        }
    }
}

impl<T> EmptyOption<T> {
    fn into_option(self) -> Option<T> {
        self.into()
    }
    fn as_option(&self) -> Option<&T> {
        match self {
            EmptyOption::Some(option) => Some(option),
            EmptyOption::None {} => None,
        }
    }
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Deployment {
        #[serde(rename(serialize = "id", deserialize = "$id"))]
        pub id: String,
        pub resourceId: String,
        pub resourceType: String,
        pub dateCreated: i64,
        pub entrypoint: String,
        pub size: i64,
        pub buildId: String,
        pub activate: bool,
        pub status: String,
        pub buildStdout: String,
        pub buildStderr: String,
}

impl Display for Deployment {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let mut formatBuffer = String::new();
        formatBuffer.push_str(&format!("{:?}", self.id));
        formatBuffer.push_str(&format!("{:?}", self.resourceId));
        formatBuffer.push_str(&format!("{:?}", self.resourceType));
        formatBuffer.push_str(&format!("{:?}", self.dateCreated));
        formatBuffer.push_str(&format!("{:?}", self.entrypoint));
        formatBuffer.push_str(&format!("{:?}", self.size));
        formatBuffer.push_str(&format!("{:?}", self.buildId));
        formatBuffer.push_str(&format!("{:?}", self.activate));
        formatBuffer.push_str(&format!("{:?}", self.status));
        formatBuffer.push_str(&format!("{:?}", self.buildStdout));
        formatBuffer.push_str(&format!("{:?}", self.buildStderr));

        write!(f, "{}", formatBuffer)
    }
}

impl Deployment {
    pub fn new(id: String, resourceId: String, resourceType: String, dateCreated: i64, entrypoint: String, size: i64, buildId: String, activate: bool, status: String, buildStdout: String, buildStderr: String, ) -> Self {
        Self {
            id: id,
            resourceId: resourceId,
            resourceType: resourceType,
            dateCreated: dateCreated,
            entrypoint: entrypoint,
            size: size,
            buildId: buildId,
            activate: activate,
            status: status,
            buildStdout: buildStdout,
            buildStderr: buildStderr,
            }
    }
}