lavalink_rs/model/
http.rs

1use crate::model::*;
2
3#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
4#[serde(rename_all = "camelCase")]
5#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))]
6/// Updates or creates the player for this guild.
7///
8/// If every field is None, the player will stop playing.
9pub struct UpdatePlayer {
10    /// The track to play.
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub track: Option<UpdatePlayerTrack>,
13    /// The track end time in milliseconds.
14    ///
15    /// It must be a value above 0 or None.
16    ///
17    /// None resets this if it was set previously.
18    #[serde(skip_serializing_if = "Option::is_none")]
19    pub end_time: Option<u64>,
20    /// The player volume.
21    ///
22    /// In percentage, from 0 to 1000.
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub volume: Option<u16>,
25    /// The track position in milliseconds.
26    ///
27    /// This value can be set to start a track at a specific time.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub position: Option<u64>,
30    /// Whether the player should be paused.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub paused: Option<bool>,
33    /// The filters to apply.
34    ///
35    /// This will override all previously applied filters.
36    #[serde(skip_serializing_if = "Option::is_none")]
37    pub filters: Option<player::Filters>,
38    /// The discord websocket connection information.
39    ///
40    /// Required for creating a player.
41    #[serde(skip_serializing_if = "Option::is_none")]
42    pub voice: Option<player::ConnectionInfo>,
43}
44
45#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
46#[serde(rename_all = "camelCase")]
47#[cfg_attr(feature = "python", pyo3::pyclass)]
48pub struct UpdatePlayerTrack {
49    /// The base64 encoded track to play.
50    ///
51    /// Mutually exclusive with `identifier`.
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub encoded: Option<String>,
54    /// The identifier of the track to play.
55    ///
56    /// Mutually exclusive with `encoded`.
57    #[serde(skip_serializing_if = "Option::is_none")]
58    pub identifier: Option<String>,
59    /// Additional track data to be sent back with the `Track` object.
60    #[serde(skip_serializing_if = "Option::is_none")]
61    pub user_data: Option<serde_json::Value>,
62}
63
64#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
65#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))]
66/// Updates the session with the resuming state and timeout.
67///
68/// You must call this method if you wish to restart the discord bot without having all players
69/// stop, and provide the current `session_id` when creating the node connection.
70pub struct ResumingState {
71    /// Whether resuming should be, or is enabled for this session or not.
72    #[serde(skip_serializing_if = "Option::is_none")]
73    pub resuming: Option<bool>,
74    /// The timeout in seconds.
75    ///
76    /// default is 60s
77    #[serde(skip_serializing_if = "Option::is_none")]
78    pub timeout: Option<u32>,
79}
80
81#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
82#[serde(rename_all = "camelCase")]
83#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))]
84/// Information about the Lavalink node.
85pub struct Info {
86    /// The semver version of the Lavalink server.
87    pub version: Version,
88    /// The millisecond unix timestamp when the Lavalink jar was built.
89    pub build_time: u64,
90    /// The git information of the Lavalink server.
91    pub git: Git,
92    /// The JVM version the Lavalink server is running on.
93    pub jvm: String,
94    /// The Lavaplayer version being used by the Lavalink server.
95    pub lavaplayer: String,
96    /// The enabled source managers for the Lavalink server.
97    pub source_managers: Vec<String>,
98    /// The enabled filters for the Lavalink server.
99    pub filters: Vec<String>,
100    /// The enabled plugins for the Lavalink server.
101    pub plugins: Vec<Plugin>,
102}
103
104#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
105#[serde(rename_all = "camelCase")]
106#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))]
107pub struct Git {
108    /// The branch the Lavalink server was built on.
109    pub branch: String,
110    /// The commit the Lavalink server was built on.
111    pub commit: String,
112    /// The millisecond unix timestamp for when the commit was created.
113    pub commit_time: u64,
114}
115
116#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
117#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))]
118pub struct Plugin {
119    /// The name of the plugin
120    pub name: String,
121    /// The version of the plugin
122    pub version: String,
123}
124
125#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
126#[serde(rename_all = "camelCase")]
127#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))]
128/// Check out [Semantic Versioning 2.0.0](https://semver.org/) to know what these fields mean.
129pub struct Version {
130    pub semver: String,
131    pub major: u8,
132    pub minor: u8,
133    pub patch: u8,
134    pub pre_release: Option<String>,
135    pub build: Option<String>,
136}