@@ -5,8 +5,10 @@ use serde::Serialize;
55use crate :: model:: prelude:: * ;
66
77#[ derive( Clone , Debug ) ]
8+ #[ cfg( feature = "unstable" ) ]
89struct StaticU8 < const VAL : u8 > ;
910
11+ #[ cfg( feature = "unstable" ) ]
1012impl < const VAL : u8 > Serialize for StaticU8 < VAL > {
1113 fn serialize < S : serde:: Serializer > ( & self , ser : S ) -> Result < S :: Ok , S :: Error > {
1214 ser. serialize_u8 ( VAL )
@@ -75,6 +77,7 @@ impl serde::Serialize for CreateActionRow<'_> {
7577#[ derive( Clone , Debug , Serialize ) ]
7678#[ must_use]
7779#[ serde( untagged) ]
80+ #[ cfg( feature = "unstable" ) ]
7881pub enum CreateComponent < ' a > {
7982 /// Represents an action row component (V1).
8083 ///
@@ -112,6 +115,7 @@ pub enum CreateComponent<'a> {
112115/// accessory.
113116#[ derive( Clone , Debug , Serialize ) ]
114117#[ must_use]
118+ #[ cfg( feature = "unstable" ) ]
115119pub struct CreateSection < ' a > {
116120 #[ serde( rename = "type" ) ]
117121 kind : StaticU8 < 9 > ,
@@ -120,6 +124,7 @@ pub struct CreateSection<'a> {
120124 accessory : CreateSectionAccessory < ' a > ,
121125}
122126
127+ #[ cfg( feature = "unstable" ) ]
123128impl < ' a > CreateSection < ' a > {
124129 /// Creates a new builder with the specified components and accessory.
125130 ///
@@ -166,19 +171,22 @@ impl<'a> CreateSection<'a> {
166171#[ derive( Clone , Debug , Serialize ) ]
167172#[ must_use]
168173#[ serde( untagged) ]
174+ #[ cfg( feature = "unstable" ) ]
169175pub enum CreateSectionComponent < ' a > {
170176 TextDisplay ( CreateTextDisplay < ' a > ) ,
171177}
172178
173179/// A builder to create a text display component.
174180#[ derive( Clone , Debug , Serialize ) ]
175181#[ must_use]
182+ #[ cfg( feature = "unstable" ) ]
176183pub struct CreateTextDisplay < ' a > {
177184 #[ serde( rename = "type" ) ]
178185 kind : StaticU8 < 10 > ,
179186 content : Cow < ' a , str > ,
180187}
181188
189+ #[ cfg( feature = "unstable" ) ]
182190impl < ' a > CreateTextDisplay < ' a > {
183191 /// Creates a new text display component.
184192 ///
@@ -204,6 +212,7 @@ impl<'a> CreateTextDisplay<'a> {
204212#[ derive( Clone , Debug , Serialize ) ]
205213#[ must_use]
206214#[ serde( untagged) ]
215+ #[ cfg( feature = "unstable" ) ]
207216pub enum CreateSectionAccessory < ' a > {
208217 Thumbnail ( CreateThumbnail < ' a > ) ,
209218 Button ( CreateButton < ' a > ) ,
@@ -212,6 +221,7 @@ pub enum CreateSectionAccessory<'a> {
212221/// A builder to create a thumbnail for a section.
213222#[ derive( Clone , Debug , Serialize ) ]
214223#[ must_use]
224+ #[ cfg( feature = "unstable" ) ]
215225pub struct CreateThumbnail < ' a > {
216226 #[ serde( rename = "type" ) ]
217227 kind : StaticU8 < 11 > ,
@@ -222,6 +232,7 @@ pub struct CreateThumbnail<'a> {
222232 spoiler : Option < bool > ,
223233}
224234
235+ #[ cfg( feature = "unstable" ) ]
225236impl < ' a > CreateThumbnail < ' a > {
226237 /// Creates a new thumbnail with a media item.
227238 pub fn new ( media : CreateUnfurledMediaItem < ' a > ) -> Self {
@@ -255,10 +266,12 @@ impl<'a> CreateThumbnail<'a> {
255266/// A builder to create a media item.
256267#[ derive( Clone , Debug , Serialize , Default ) ]
257268#[ must_use]
269+ #[ cfg( feature = "unstable" ) ]
258270pub struct CreateUnfurledMediaItem < ' a > {
259271 url : Cow < ' a , str > ,
260272}
261273
274+ #[ cfg( feature = "unstable" ) ]
262275impl < ' a > CreateUnfurledMediaItem < ' a > {
263276 /// Creates a new media item.
264277 pub fn new ( url : impl Into < Cow < ' a , str > > ) -> Self {
@@ -279,12 +292,14 @@ impl<'a> CreateUnfurledMediaItem<'a> {
279292/// Note: May contain up to **10** items.
280293#[ derive( Clone , Debug , Serialize ) ]
281294#[ must_use]
295+ #[ cfg( feature = "unstable" ) ]
282296pub struct CreateMediaGallery < ' a > {
283297 #[ serde( rename = "type" ) ]
284298 kind : StaticU8 < 12 > ,
285299 items : Cow < ' a , [ CreateMediaGalleryItem < ' a > ] > ,
286300}
287301
302+ #[ cfg( feature = "unstable" ) ]
288303impl < ' a > CreateMediaGallery < ' a > {
289304 /// Creates a new media gallery with up to **10** items.
290305 pub fn new ( items : impl Into < Cow < ' a , [ CreateMediaGalleryItem < ' a > ] > > ) -> Self {
@@ -315,6 +330,7 @@ impl<'a> CreateMediaGallery<'a> {
315330/// Builder to create individual media gallery items.
316331#[ derive( Clone , Debug , Serialize , Default ) ]
317332#[ must_use]
333+ #[ cfg( feature = "unstable" ) ]
318334pub struct CreateMediaGalleryItem < ' a > {
319335 media : CreateUnfurledMediaItem < ' a > ,
320336 #[ serde( skip_serializing_if = "Option::is_none" ) ]
@@ -323,6 +339,7 @@ pub struct CreateMediaGalleryItem<'a> {
323339 spoiler : Option < bool > ,
324340}
325341
342+ #[ cfg( feature = "unstable" ) ]
326343impl < ' a > CreateMediaGalleryItem < ' a > {
327344 /// Create a new media gallery item.
328345 pub fn new ( media : CreateUnfurledMediaItem < ' a > ) -> Self {
@@ -372,6 +389,7 @@ impl<'a> CreateMediaGalleryItem<'a> {
372389/// refer to the [Discord Documentation](https://discord.com/developers/docs/reference#uploading-files).
373390#[ derive( Clone , Debug , Serialize ) ]
374391#[ must_use]
392+ #[ cfg( feature = "unstable" ) ]
375393pub struct CreateFile < ' a > {
376394 #[ serde( rename = "type" ) ]
377395 kind : StaticU8 < 13 > ,
@@ -380,6 +398,7 @@ pub struct CreateFile<'a> {
380398 spoiler : Option < bool > ,
381399}
382400
401+ #[ cfg( feature = "unstable" ) ]
383402impl < ' a > CreateFile < ' a > {
384403 /// Create a new builder for the file component. Refer to this builders documentation for
385404 /// limits.
@@ -408,6 +427,7 @@ impl<'a> CreateFile<'a> {
408427/// A builder for creating a separator.
409428#[ derive( Clone , Debug , Serialize ) ]
410429#[ must_use]
430+ #[ cfg( feature = "unstable" ) ]
411431pub struct CreateSeparator {
412432 #[ serde( rename = "type" ) ]
413433 kind : StaticU8 < 14 > ,
@@ -416,6 +436,7 @@ pub struct CreateSeparator {
416436 spacing : Option < Spacing > ,
417437}
418438
439+ #[ cfg( feature = "unstable" ) ]
419440impl CreateSeparator {
420441 /// Creates a new separator, with or without a divider.
421442 pub fn new ( divider : bool ) -> Self {
@@ -443,6 +464,7 @@ impl CreateSeparator {
443464/// A builder to create a container, which acts similarly to embeds.
444465#[ derive( Clone , Debug , Serialize ) ]
445466#[ must_use]
467+ #[ cfg( feature = "unstable" ) ]
446468pub struct CreateContainer < ' a > {
447469 #[ serde( rename = "type" ) ]
448470 kind : StaticU8 < 17 > ,
@@ -453,6 +475,7 @@ pub struct CreateContainer<'a> {
453475 components : Cow < ' a , [ CreateComponent < ' a > ] > ,
454476}
455477
478+ #[ cfg( feature = "unstable" ) ]
456479impl < ' a > CreateContainer < ' a > {
457480 /// Create a new container, with an array of components inside. This component may contain any
458481 /// other component except another container!
0 commit comments