tsproto-types 0.1.0

Basic types and enums that are used within the TeamSpeak protocol.
Documentation
<#@ template cleanws="true" #>
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[non_exhaustive]
#[allow(non_camel_case_types)]
pub enum Version {
<# for v in &**self { #>
	<#= v.get_enum_name() #>,
<# } #>
	Custom { platform: String, version: String, signature: Vec<u8> },
}

impl Version {
	pub fn get_platform(&self) -> &str {
		match *self {
		<# for v in &**self { #>
			Version::<#= v.get_enum_name() #> => "<#= v.platform #>",
		<# } #>
			Version::Custom { ref platform, .. } => platform,
		}
	}

	pub fn get_version_string(&self) -> &str {
		match *self {
		<# for v in &**self { #>
			Version::<#= v.get_enum_name() #> => "<#= v.version #>",
		<# } #>
			Version::Custom { ref version, .. } => version,
		}
	}

	pub fn get_signature(&self) -> &[u8] {
		match *self {
		<# for v in &**self { #>
			Version::<#= v.get_enum_name() #> => &[<#= v.get_sign_array() #>],
		<# } #>
			Version::Custom { ref signature, .. } => signature,
		}
	}
}