use crate::errors::Result;
use crate::types::*;
use uuid::Uuid;
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct SetNetworkType {
#[doc(hidden)]
#[serde(rename(serialize = "@extra", deserialize = "@extra"))]
extra: Option<String>,
#[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
client_id: Option<i32>,
#[serde(rename(serialize = "type", deserialize = "type"))]
#[serde(skip_serializing_if = "NetworkType::_is_default")]
type_: NetworkType,
#[serde(rename(serialize = "@type"))]
td_type: String,
}
impl RObject for SetNetworkType {
#[doc(hidden)]
fn extra(&self) -> Option<&str> {
self.extra.as_deref()
}
#[doc(hidden)]
fn client_id(&self) -> Option<i32> {
self.client_id
}
}
impl RFunction for SetNetworkType {}
impl SetNetworkType {
pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
Ok(serde_json::from_str(json.as_ref())?)
}
pub fn builder() -> SetNetworkTypeBuilder {
let mut inner = SetNetworkType::default();
inner.extra = Some(Uuid::new_v4().to_string());
inner.td_type = "setNetworkType".to_string();
SetNetworkTypeBuilder { inner }
}
pub fn type_(&self) -> &NetworkType {
&self.type_
}
}
#[doc(hidden)]
pub struct SetNetworkTypeBuilder {
inner: SetNetworkType,
}
#[deprecated]
pub type RTDSetNetworkTypeBuilder = SetNetworkTypeBuilder;
impl SetNetworkTypeBuilder {
pub fn build(&self) -> SetNetworkType {
self.inner.clone()
}
pub fn type_<T: AsRef<NetworkType>>(&mut self, type_: T) -> &mut Self {
self.inner.type_ = type_.as_ref().clone();
self
}
}
impl AsRef<SetNetworkType> for SetNetworkType {
fn as_ref(&self) -> &SetNetworkType {
self
}
}
impl AsRef<SetNetworkType> for SetNetworkTypeBuilder {
fn as_ref(&self) -> &SetNetworkType {
&self.inner
}
}