use crate::errors::Result;
use crate::types::*;
use uuid::Uuid;
use std::fmt::Debug;
pub trait TDInputChatPhoto: Debug + RObject {}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
#[serde(tag = "@type")]
pub enum InputChatPhoto {
#[doc(hidden)]
#[default]
_Default,
#[serde(rename = "inputChatPhotoAnimation")]
Animation(InputChatPhotoAnimation),
#[serde(rename = "inputChatPhotoPrevious")]
Previous(InputChatPhotoPrevious),
#[serde(rename = "inputChatPhotoStatic")]
Static(InputChatPhotoStatic),
}
impl RObject for InputChatPhoto {
#[doc(hidden)]
fn extra(&self) -> Option<&str> {
match self {
InputChatPhoto::Animation(t) => t.extra(),
InputChatPhoto::Previous(t) => t.extra(),
InputChatPhoto::Static(t) => t.extra(),
_ => None,
}
}
#[doc(hidden)]
fn client_id(&self) -> Option<i32> {
match self {
InputChatPhoto::Animation(t) => t.client_id(),
InputChatPhoto::Previous(t) => t.client_id(),
InputChatPhoto::Static(t) => t.client_id(),
_ => None,
}
}
}
impl InputChatPhoto {
pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
Ok(serde_json::from_str(json.as_ref())?)
}
#[doc(hidden)]
pub fn _is_default(&self) -> bool {
matches!(self, InputChatPhoto::_Default)
}
}
impl AsRef<InputChatPhoto> for InputChatPhoto {
fn as_ref(&self) -> &InputChatPhoto {
self
}
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct InputChatPhotoAnimation {
#[doc(hidden)]
#[serde(rename(serialize = "@extra", deserialize = "@extra"))]
extra: Option<String>,
#[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
client_id: Option<i32>,
#[serde(skip_serializing_if = "InputFile::_is_default")]
animation: InputFile,
#[serde(default)]
main_frame_timestamp: f32,
}
impl RObject for InputChatPhotoAnimation {
#[doc(hidden)]
fn extra(&self) -> Option<&str> {
self.extra.as_deref()
}
#[doc(hidden)]
fn client_id(&self) -> Option<i32> {
self.client_id
}
}
impl TDInputChatPhoto for InputChatPhotoAnimation {}
impl InputChatPhotoAnimation {
pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
Ok(serde_json::from_str(json.as_ref())?)
}
pub fn builder() -> InputChatPhotoAnimationBuilder {
let mut inner = InputChatPhotoAnimation::default();
inner.extra = Some(Uuid::new_v4().to_string());
InputChatPhotoAnimationBuilder { inner }
}
pub fn animation(&self) -> &InputFile {
&self.animation
}
pub fn main_frame_timestamp(&self) -> f32 {
self.main_frame_timestamp
}
}
#[doc(hidden)]
pub struct InputChatPhotoAnimationBuilder {
inner: InputChatPhotoAnimation,
}
#[deprecated]
pub type RTDInputChatPhotoAnimationBuilder = InputChatPhotoAnimationBuilder;
impl InputChatPhotoAnimationBuilder {
pub fn build(&self) -> InputChatPhotoAnimation {
self.inner.clone()
}
pub fn animation<T: AsRef<InputFile>>(&mut self, animation: T) -> &mut Self {
self.inner.animation = animation.as_ref().clone();
self
}
pub fn main_frame_timestamp(&mut self, main_frame_timestamp: f32) -> &mut Self {
self.inner.main_frame_timestamp = main_frame_timestamp;
self
}
}
impl AsRef<InputChatPhotoAnimation> for InputChatPhotoAnimation {
fn as_ref(&self) -> &InputChatPhotoAnimation {
self
}
}
impl AsRef<InputChatPhotoAnimation> for InputChatPhotoAnimationBuilder {
fn as_ref(&self) -> &InputChatPhotoAnimation {
&self.inner
}
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct InputChatPhotoPrevious {
#[doc(hidden)]
#[serde(rename(serialize = "@extra", deserialize = "@extra"))]
extra: Option<String>,
#[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
client_id: Option<i32>,
#[serde(
deserialize_with = "super::_common::number_from_string",
serialize_with = "super::_common::string_to_number"
)]
#[serde(default)]
chat_photo_id: i64,
}
impl RObject for InputChatPhotoPrevious {
#[doc(hidden)]
fn extra(&self) -> Option<&str> {
self.extra.as_deref()
}
#[doc(hidden)]
fn client_id(&self) -> Option<i32> {
self.client_id
}
}
impl TDInputChatPhoto for InputChatPhotoPrevious {}
impl InputChatPhotoPrevious {
pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
Ok(serde_json::from_str(json.as_ref())?)
}
pub fn builder() -> InputChatPhotoPreviousBuilder {
let mut inner = InputChatPhotoPrevious::default();
inner.extra = Some(Uuid::new_v4().to_string());
InputChatPhotoPreviousBuilder { inner }
}
pub fn chat_photo_id(&self) -> i64 {
self.chat_photo_id
}
}
#[doc(hidden)]
pub struct InputChatPhotoPreviousBuilder {
inner: InputChatPhotoPrevious,
}
#[deprecated]
pub type RTDInputChatPhotoPreviousBuilder = InputChatPhotoPreviousBuilder;
impl InputChatPhotoPreviousBuilder {
pub fn build(&self) -> InputChatPhotoPrevious {
self.inner.clone()
}
pub fn chat_photo_id(&mut self, chat_photo_id: i64) -> &mut Self {
self.inner.chat_photo_id = chat_photo_id;
self
}
}
impl AsRef<InputChatPhotoPrevious> for InputChatPhotoPrevious {
fn as_ref(&self) -> &InputChatPhotoPrevious {
self
}
}
impl AsRef<InputChatPhotoPrevious> for InputChatPhotoPreviousBuilder {
fn as_ref(&self) -> &InputChatPhotoPrevious {
&self.inner
}
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct InputChatPhotoStatic {
#[doc(hidden)]
#[serde(rename(serialize = "@extra", deserialize = "@extra"))]
extra: Option<String>,
#[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
client_id: Option<i32>,
#[serde(skip_serializing_if = "InputFile::_is_default")]
photo: InputFile,
}
impl RObject for InputChatPhotoStatic {
#[doc(hidden)]
fn extra(&self) -> Option<&str> {
self.extra.as_deref()
}
#[doc(hidden)]
fn client_id(&self) -> Option<i32> {
self.client_id
}
}
impl TDInputChatPhoto for InputChatPhotoStatic {}
impl InputChatPhotoStatic {
pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
Ok(serde_json::from_str(json.as_ref())?)
}
pub fn builder() -> InputChatPhotoStaticBuilder {
let mut inner = InputChatPhotoStatic::default();
inner.extra = Some(Uuid::new_v4().to_string());
InputChatPhotoStaticBuilder { inner }
}
pub fn photo(&self) -> &InputFile {
&self.photo
}
}
#[doc(hidden)]
pub struct InputChatPhotoStaticBuilder {
inner: InputChatPhotoStatic,
}
#[deprecated]
pub type RTDInputChatPhotoStaticBuilder = InputChatPhotoStaticBuilder;
impl InputChatPhotoStaticBuilder {
pub fn build(&self) -> InputChatPhotoStatic {
self.inner.clone()
}
pub fn photo<T: AsRef<InputFile>>(&mut self, photo: T) -> &mut Self {
self.inner.photo = photo.as_ref().clone();
self
}
}
impl AsRef<InputChatPhotoStatic> for InputChatPhotoStatic {
fn as_ref(&self) -> &InputChatPhotoStatic {
self
}
}
impl AsRef<InputChatPhotoStatic> for InputChatPhotoStaticBuilder {
fn as_ref(&self) -> &InputChatPhotoStatic {
&self.inner
}
}