1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
mod scopes_mut;
use std::{ops::Deref, str::FromStr};
use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer};
use std::{collections::HashSet, fmt::Display};
pub use scopes_mut::{
AdScopes, AnalyticScopes, BitScopes, CCLScopes, ChannelPointScopes, ChannelScopes,
CharityScopes, ChatScopes, ChatbotScopes, ClipScopes, ConduitScopes, EntitlementScopes,
EventSubScopes, ExtensionScopes, GameScopes, GoalScopes, GuestStarScopes, HypeTrainScopes,
IRCScopes, ModerationScopes, PollScopes, PredictionScopes, RaidScopes, ScheduleScopes,
ScopesMut, SearchScopes, StreamScopes, SubscriptionScopes, TagScopes, TeamScopes, UserScopes,
VideoScopes, WhisperScopes,
};
pub(crate) fn scopes_mut(scopes: &mut HashSet<Scope>) -> ScopesMut<'_> {
scopes_mut::new(scopes)
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Scope {
/// View analytics data for the Twitch Extensions owned by the authenticated account.
/// API
/// Get Extension Analytics
/// <https://dev.twitch.tv/docs/api/reference/#get-extension-analytics>
AnalyticsReadExtensions,
/// View analytics data for the games owned by the authenticated account.
/// API
/// Get Game Analytics
/// <https://dev.twitch.tv/docs/api/reference/#get-game-analytics>
AnalyticsReadGames,
/// View Bits information for a channel.
///
/// API
/// Get Bits Leaderboard
/// <https://dev.twitch.tv/docs/api/reference/#get-bits-leaderboard>
///
/// EventSub
/// Channel Cheer
/// <https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types/#channelcheer>
BitsRead,
/// Joins your channel’s chatroom as a bot user, and perform chat-related actions as that user.
///
/// API
/// Send Chat Message
/// <https://dev.twitch.tv/docs/api/reference/#send-chat-message>
///
/// EventSub
/// Channel Chat Clear
/// <https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types/#channelchatclear>
/// Channel Chat Clear User Messages
/// <https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types/#channelchatclear_user_messages>
/// Channel Chat Message
/// <https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types/#channelchatmessage>
/// Channel Chat Message Delete
/// <https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types/#channelchatmessage_delete>
/// Channel Chat Notification
/// <https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types/#channelchatnotification>
/// Channel Chat Settings Update
/// <https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types/#channelchat_settingsupdate>
ChannelBot,
/// Manage ads schedule on a channel.
///
/// API
/// Snooze Next Ad
/// <https://dev.twitch.tv/docs/api/reference/#snooze-next-ad>
ChannelManageAds,
/// Read the ads schedule and details on your channel.
///
/// API
/// Get Ad Schedule
/// <https://dev.twitch.tv/docs/api/reference/#get-ad-schedule>
///
/// EventSub
/// Channel Ad Break Begin
/// <https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types/#channelad_breakbegin>
ChannelReadAds,
/// Manage a channel’s broadcast configuration, including updating channel configuration and managing stream markers and stream tags.
///
/// API
/// Modify Channel Information
/// Create Stream Marker
/// Replace Stream Tags
ChannelManageBroadcast,
/// Read charity campaign details and user donations on your channel.
///
/// API
/// Get Charity Campaign
/// Get Charity Campaign Donations
///
/// EventSub
/// Charity Donation
/// Charity Campaign Start
/// Charity Campaign Progress
/// Charity Campaign Stop
ChannelReadCharity,
/// Run commercials on a channel.
///
/// API
/// Start Commercial
ChannelEditCommercial,
/// View a list of users with the editor role for a channel.
///
/// API
/// Get Channel Editors
ChannelReadEditors,
/// Manage a channel’s Extension configuration, including activating Extensions.
///
/// API
/// Get User Active Extensions
/// Update User Extensions
ChannelManageExtensions,
/// View Creator Goals for a channel.
///
/// API
/// Get Creator Goals
///
/// EventSub
/// Goal Begin
/// Goal Progress
/// Goal End
ChannelReadGoals,
/// Read Guest Star details for your channel.
///
/// API
/// Get Channel Guest Star Settings
/// Get Guest Star Session
/// Get Guest Star Invites
///
/// EventSub
/// Channel Guest Star Session Begin
/// Channel Guest Star Session End
/// Channel Guest Star Guest Update
/// Channel Guest Star Settings Update
ChannelReadGuestStar,
/// Manage Guest Star for your channel.
///
/// API
/// Update Channel Guest Star Settings
/// Create Guest Star Session
/// End Guest Star Session
/// Send Guest Star Invite
/// Delete Guest Star Invite
/// Assign Guest Star Slot
/// Update Guest Star Slot
/// Delete Guest Star Slot
/// Update Guest Star Slot Settings
///
/// EventSub
/// Channel Guest Star Session Begin
/// Channel Guest Star Session End
/// Channel Guest Star Guest Update
/// Channel Guest Star Settings Update
ChannelManageGuestStar,
/// View Hype Train information for a channel.
///
/// API
/// Get Hype Train Events
///
/// EventSub
/// Hype Train Begin
/// Hype Train Progress
/// Hype Train End
ChannelReadHypeTrain,
/// Add or remove the moderator role from users in your channel.
///
/// API
/// Add Channel Moderator
/// Remove Channel Moderator
/// Get Moderators
ChannelManageModerators,
/// Perform moderation actions in a channel.
///
/// EventSub
/// Channel Moderate
/// Channel Moderate v2
ChannelModerate,
/// View a channel’s polls.
///
/// API
/// Get Polls
///
/// EventSub
/// Channel Poll Begin
/// Channel Poll Progress
/// Channel Poll End
ChannelReadPolls,
/// Manage a channel’s polls.
///
/// API
/// Get Polls
/// Create Poll
/// End Poll
///
/// EventSub
/// Channel Poll Begin
/// Channel Poll Progress
/// Channel Poll End
ChannelManagePolls,
/// View a channel’s Channel Points Predictions.
///
/// API
/// Get Channel Points Predictions
///
/// EventSub
/// Channel Prediction Begin
/// Channel Prediction Progress
/// Channel Prediction Lock
/// Channel Prediction End
ChannelReadPredictions,
/// Manage of channel’s Channel Points Predictions
///
/// API
/// Get Channel Points Predictions
/// Create Channel Points Prediction
/// End Channel Points Prediction
///
/// EventSub
/// Channel Prediction Begin
/// Channel Prediction Progress
/// Channel Prediction Lock
/// Channel Prediction End
ChannelManagePredictions,
/// Manage a channel raiding another channel.
///
/// API
/// Start a raid
/// Cancel a raid
ChannelManageRaids,
/// View Channel Points custom rewards and their redemptions on a channel.
///
/// API
/// Get Custom Reward
/// Get Custom Reward Redemption
///
/// EventSub
/// Channel Points Automatic Reward Redemption
/// Channel Points Custom Reward Add
/// Channel Points Custom Reward Update
/// Channel Points Custom Reward Remove
/// Channel Points Custom Reward Redemption Add
/// Channel Points Custom Reward Redemption Update
ChannelReadRedemptions,
/// Manage Channel Points custom rewards and their redemptions on a channel.
///
/// API
/// Get Custom Reward
/// Get Custom Reward Redemption
/// Create Custom Rewards
/// Delete Custom Reward
/// Update Custom Reward
/// Update Redemption Status
///
/// EventSub
/// Channel Points Automatic Reward Redemption
/// Channel Points Custom Reward Add
/// Channel Points Custom Reward Update
/// Channel Points Custom Reward Remove
/// Channel Points Custom Reward Redemption Add
/// Channel Points Custom Reward Redemption Update
ChannelManageRedemptions,
/// Manage a channel’s stream schedule.
///
/// API
/// Update Channel Stream Schedule
/// Create Channel Stream Schedule Segment
/// Update Channel Stream Schedule Segment
/// Delete Channel Stream Schedule Segment
ChannelManageSchedule,
/// View an authorized user’s stream key.
///
/// API
/// Get Stream Key
ChannelReadStreamKey,
/// View a list of all subscribers to a channel and check if a user is subscribed to a channel.
///
/// API
/// Get Broadcaster Subscriptions
///
/// EventSub
/// Channel Subscribe
/// Channel Subscription End
/// Channel Subscription Gift
/// Channel Subscription Message
ChannelReadSubscriptions,
/// Manage a channel’s videos, including deleting videos.
///
/// API
/// Delete Videos
ChannelManageVideos,
/// Read the list of VIPs in your channel.
///
/// API
/// Get VIPs
///
/// EventSub
/// Channel VIP Add
/// Channel VIP Remove
ChannelReadVips,
/// Add or remove the VIP role from users in your channel.
///
/// API
/// Get VIPs
/// Add Channel VIP
/// Remove Channel VIP
///
/// EventSub
/// Channel VIP Add
/// Channel VIP Remove
ChannelManageVips,
/// Manage Clips for a channel.
///
/// API
/// Create Clip
ClipsEdit,
/// View a channel’s moderation data including Moderators, Bans, Timeouts, and Automod settings.
///
/// API
/// Check AutoMod Status
/// Get Banned Users
/// Get Moderators
///
/// EventSub
/// Channel Moderator Add
/// Channel Moderator Remove
ChannelManageClips,
EditorManageClips,
ModerationRead,
/// Send announcements in channels where you have the moderator role.
///
/// API
/// Send Chat Announcement
ModeratorManageAnnouncements,
/// Manage messages held for review by AutoMod in channels where you are a moderator.
///
/// API
/// Manage Held AutoMod Messages
///
/// EventSub
/// AutoMod Message Hold
/// AutoMod Message Update
/// AutoMod Terms Update
ModeratorManageAutomod,
/// View a broadcaster’s AutoMod settings.
///
/// API
/// Get AutoMod Settings
///
/// EventSub
/// AutoMod Settings Update
ModeratorReadAutomodSettings,
/// Manage a broadcaster’s AutoMod settings.
///
/// API
/// Update AutoMod Settings
ModeratorManageAutomodSettings,
/// Read the list of bans or unbans in channels where you have the moderator role.
///
/// EventSub
/// Channel Moderate
/// Channel Moderate v2
ModeratorReadBannedUsers,
/// Ban and unban users.
///
/// API
/// Get Banned Users
/// Ban User
/// Unban User
///
/// EventSub
/// Channel Moderate
/// Channel Moderate v2
ModeratorManageBannedUsers,
/// View a broadcaster’s list of blocked terms.
///
/// API
/// Get Blocked Terms
///
/// EventSub
/// Channel Moderate
ModeratorReadBlockedTerms,
/// Read deleted chat messages in channels where you have the moderator role.
///
/// EventSub
/// Channel Moderate
ModeratorReadChatMessages,
/// Manage a broadcaster’s list of blocked terms.
///
/// API
/// Get Blocked Terms
/// Add Blocked Term
/// Remove Blocked Term
///
/// EventSub
/// Channel Moderate
ModeratorManageBlockedTerms,
/// Delete chat messages in channels where you have the moderator role
///
/// API
/// Delete Chat Messages
///
/// EventSub
/// Channel Moderate
ModeratorManageChatMessages,
/// View a broadcaster’s chat room settings.
///
/// API
/// Get Chat Settings
///
/// EventSub
/// Channel Moderate
ModeratorReadChatSettings,
/// Manage a broadcaster’s chat room settings.
///
/// API
/// Update Chat Settings
///
/// EventSub
/// Channel Moderate
ModeratorManageChatSettings,
/// View the chatters in a broadcaster’s chat room.
///
/// API
/// Get Chatters
ModeratorReadChatters,
/// Read the followers of a broadcaster.
///
/// API
/// Get Channel Followers
///
/// EventSub
/// Channel Follow
ModeratorReadFollowers,
/// Read Guest Star details for channels where you are a Guest Star moderator.
///
/// API
/// Get Channel Guest Star Settings
/// Get Guest Star Session
/// Get Guest Star Invites
///
/// EventSub
/// Channel Guest Star Session Begin
/// Channel Guest Star Session End
/// Channel Guest Star Guest Update
/// Channel Guest Star Settings Update
ModeratorReadGuestStar,
/// Manage Guest Star for channels where you are a Guest Star moderator.
///
/// API
/// Send Guest Star Invite
/// Delete Guest Star Invite
/// Assign Guest Star Slot
/// Update Guest Star Slot
/// Delete Guest Star Slot
/// Update Guest Star Slot Settings
///
/// EventSub
/// Channel Guest Star Session Begin
/// Channel Guest Star Session End
/// Channel Guest Star Guest Update
/// Channel Guest Star Settings Update
ModeratorManageGuestStar,
/// Read the list of moderators in channels where you have the moderator role.
///
/// EventSub
/// Channel Moderate
/// Channel Moderate v2
ModeratorReadModerators,
/// View a broadcaster’s Shield Mode status.
///
/// API
/// Get Shield Mode Status
///
/// EventSub
/// Shield Mode Begin
/// Shield Mode End
ModeratorReadShieldMode,
/// Manage a broadcaster’s Shield Mode status.
///
/// API
/// Update Shield Mode Status
///
/// EventSub
/// Shield Mode Begin
/// Shield Mode End
ModeratorManageShieldMode,
/// View a broadcaster’s shoutouts.
///
/// EventSub
/// Shoutout Create
/// Shoutout Received
ModeratorReadShoutouts,
/// Manage a broadcaster’s shoutouts.
///
/// API
/// Send a Shoutout
///
/// EventSub
/// Shoutout Create
/// Shoutout Received
ModeratorManageShoutouts,
/// Read chat messages from suspicious users and see users flagged as suspicious in channels where you have the moderator role.
///
/// EventSub
/// Channel Suspicious User Message
/// Channel Suspicious User Update
ModeratorReadSuspiciousUsers,
/// View a broadcaster’s unban requests.
///
/// API
/// Get Unban Requests
///
/// EventSub
/// Channel Unban Request Create
/// Channel Unban Request Resolve
/// Channel Moderate
ModeratorReadUnbanRequests,
/// Manage a broadcaster’s unban requests.
///
/// API
/// Resolve Unban Requests
///
/// EventSub
/// Channel Unban Request Create
/// Channel Unban Request Resolve
/// Channel Moderate
ModeratorManageUnbanRequests,
/// Read the list of VIPs in channels where you have the moderator role.
///
/// EventSub
/// Channel Moderate
/// Channel Moderate v2
ModeratorReadVips,
/// Read warnings in channels where you have the moderator role.
///
/// EventSub
/// Channel Moderate v2
/// Channel Warning Acknowledge
/// Channel Warning Send
ModeratorReadWarnings,
/// Warn users in channels where you have the moderator role.
///
/// API
/// Warn Chat User
///
/// EventSub
/// Channel Moderate v2
/// Channel Warning Acknowledge
/// Channel Warning Send
ModeratorManageWarnings,
ModeratorManageSuspiciousUsers,
/// Join a specified chat channel as your user and appear as a bot,
/// and perform chat-related actions as your user.
///
/// API
/// Send Chat Message
/// <https://dev.twitch.tv/docs/api/reference/#send-chat-message>
///
/// EventSub
/// Channel Chat Clear
/// Channel Chat Clear User Messages
/// Channel Chat Message
/// Channel Chat Message Delete
/// Channel Chat Notification
/// Channel Chat Settings Update
/// Channel Chat User Message Hold
/// Channel Chat User Message Update
UserBot,
/// Manage a user object.
///
/// API
/// Update User
UserEdit,
/// View and edit a user’s broadcasting configuration, including Extension configurations.
///
/// API
/// Get User Extensions
/// Get User Active Extensions
/// Update User Extensions
UserEditBroadcast,
/// View the block list of a user.
///
/// API
/// Get User Block List
/// <https://dev.twitch.tv/docs/api/reference/#get-user-block-list>
UserReadBlockedUsers,
/// Manage the block list of a user.
///
/// API
/// Block User
/// <https://dev.twitch.tv/docs/api/reference/#block-user>
/// Unblock User
/// <https://dev.twitch.tv/docs/api/reference/#unblock-user>
UserManageBlockedUsers,
/// View a user’s broadcasting configuration, including Extension configurations.
///
/// API
/// Get Stream Markers
/// Get User Extensions
/// Get User Active Extensions
UserReadBroadcast,
/// Receive chatroom messages and informational notifications relating to a channel’s chatroom.
///
/// EventSub
/// Channel Chat Clear
/// Channel Chat Clear User Messages
/// Channel Chat Message
/// Channel Chat Message Delete
/// Channel Chat Notification
/// Channel Chat Settings Update
/// Channel Chat User Message Hold
/// Channel Chat User Message Update
UserReadChat,
/// Update the color used for the user’s name in chat.
///
/// API
/// Update User Chat Color
UserManageChatColor,
/// View a user’s email address.
///
/// API
/// Get Users (optional)
/// Update User (optional)
///
/// EventSub
/// User Update (optional)
UserReadEmail,
/// View emotes available to a user
///
/// API
/// Get User Emotes
/// <https://dev.twitch.tv/docs/api/reference/#get-user-emotes>
UserReadEmotes,
/// View the list of channels a user follows.
///
/// API
/// Get Followed Channels
/// Get Followed Streams
UserReadFollows,
/// Read the list of channels you have moderator privileges in.
///
/// API
/// Get Moderated Channels
UserReadModeratedChannels,
/// View if an authorized user is subscribed to specific channels.
///
/// API
/// Check User Subscription
UserReadSubscriptions,
/// Receive whispers sent to your user.
///
/// EventSub
/// Whisper Received
UserReadWhispers,
/// Receive whispers sent to your user, and send whispers on your user’s behalf.
///
/// API
/// Send Whisper
///
/// EventSub
/// Whisper Received
UserManageWhispers,
/// Send chat messages to a chatroom.
///
/// API
/// Send Chat Message
/// <https://dev.twitch.tv/docs/api/reference/#send-chat-message>
UserWriteChat,
/// Send chat messages to a chatroom using an IRC connection.
///
/// <https://dev.twitch.tv/docs/chat/irc>
ChatEdit,
/// View chat messages sent in a chatroom using an IRC connection.
///
/// <https://dev.twitch.tv/docs/chat/irc>
ChatRead,
/// The following table lists the scopes used only by PubSub.
/// There may be additional scopes needed for some PubSub topics, but those are not listed here.
/// Receive whisper messages for your user using PubSub.
///
/// <https://dev.twitch.tv/docs/pubsub>
WhispersRead,
}
impl Scope {
pub const fn as_str(&self) -> &'static str {
match self {
Self::AnalyticsReadExtensions => "analytics:read:extensions",
Self::AnalyticsReadGames => "analytics:read:games",
Self::BitsRead => "bits:read",
Self::ChannelBot => "channel:bot",
Self::ChannelManageAds => "channel:manage:ads",
Self::ChannelReadAds => "channel:read:ads",
Self::ChannelManageBroadcast => "channel:manage:broadcast",
Self::ChannelReadCharity => "channel:read:charity",
Self::ChannelEditCommercial => "channel:edit:commercial",
Self::ChannelReadEditors => "channel:read:editors",
Self::ChannelManageExtensions => "channel:manage:extensions",
Self::ChannelReadGoals => "channel:read:goals",
Self::ChannelReadGuestStar => "channel:read:guest_star",
Self::ChannelManageGuestStar => "channel:manage:guest_star",
Self::ChannelReadHypeTrain => "channel:read:hype_train",
Self::ChannelManageModerators => "channel:manage:moderators",
Self::ChannelModerate => "channel:moderate",
Self::ChannelReadPolls => "channel:read:polls",
Self::ChannelManagePolls => "channel:manage:polls",
Self::ChannelReadPredictions => "channel:read:predictions",
Self::ChannelManagePredictions => "channel:manage:predictions",
Self::ChannelManageRaids => "channel:manage:raids",
Self::ChannelReadRedemptions => "channel:read:redemptions",
Self::ChannelManageRedemptions => "channel:manage:redemptions",
Self::ChannelManageSchedule => "channel:manage:schedule",
Self::ChannelReadStreamKey => "channel:read:stream_key",
Self::ChannelReadSubscriptions => "channel:read:subscriptions",
Self::ChannelManageVideos => "channel:manage:videos",
Self::ChannelReadVips => "channel:read:vips",
Self::ChannelManageVips => "channel:manage:vips",
Self::ClipsEdit => "clips:edit",
Self::ChannelManageClips => "channel:manage:clips",
Self::EditorManageClips => "editor:manage:clips",
Self::ModerationRead => "moderation:read",
Self::ModeratorManageAnnouncements => "moderator:manage:announcements",
Self::ModeratorManageAutomod => "moderator:manage:automod",
Self::ModeratorReadAutomodSettings => "moderator:read:automod_settings",
Self::ModeratorManageAutomodSettings => "moderator:manage:automod_settings",
Self::ModeratorReadBannedUsers => "moderator:read:banned_users",
Self::ModeratorManageBannedUsers => "moderator:manage:banned_users",
Self::ModeratorReadBlockedTerms => "moderator:read:blocked_terms",
Self::ModeratorReadChatMessages => "moderator:read:chat_messages",
Self::ModeratorManageBlockedTerms => "moderator:manage:blocked_terms",
Self::ModeratorManageChatMessages => "moderator:manage:chat_messages",
Self::ModeratorReadChatSettings => "moderator:read:chat_settings",
Self::ModeratorManageChatSettings => "moderator:manage:chat_settings",
Self::ModeratorReadChatters => "moderator:read:chatters",
Self::ModeratorReadFollowers => "moderator:read:followers",
Self::ModeratorReadGuestStar => "moderator:read:guest_star",
Self::ModeratorManageGuestStar => "moderator:manage:guest_star",
Self::ModeratorReadModerators => "moderator:read:moderators",
Self::ModeratorReadShieldMode => "moderator:read:shield_mode",
Self::ModeratorManageShieldMode => "moderator:manage:shield_mode",
Self::ModeratorReadShoutouts => "moderator:read:shoutouts",
Self::ModeratorManageShoutouts => "moderator:manage:shoutouts",
Self::ModeratorReadSuspiciousUsers => "moderator:read:suspicious_users",
Self::ModeratorReadUnbanRequests => "moderator:read:unban_requests",
Self::ModeratorManageUnbanRequests => "moderator:manage:unban_requests",
Self::ModeratorReadVips => "moderator:read:vips",
Self::ModeratorReadWarnings => "moderator:read:warnings",
Self::ModeratorManageWarnings => "moderator:manage:warnings",
Self::ModeratorManageSuspiciousUsers => "moderator:manage:suspicious_users",
Self::UserBot => "user:bot",
Self::UserEdit => "user:edit",
Self::UserEditBroadcast => "user:edit:broadcast",
Self::UserReadBlockedUsers => "user:read:blocked_users",
Self::UserManageBlockedUsers => "user:manage:blocked_users",
Self::UserReadBroadcast => "user:read:broadcast",
Self::UserReadChat => "user:read:chat",
Self::UserManageChatColor => "user:manage:chat_color",
Self::UserReadEmail => "user:read:email",
Self::UserReadEmotes => "user:read:emotes",
Self::UserReadFollows => "user:read:follows",
Self::UserReadModeratedChannels => "user:read:moderated_channels",
Self::UserReadSubscriptions => "user:read:subscriptions",
Self::UserReadWhispers => "user:read:whispers",
Self::UserManageWhispers => "user:manage:whispers",
Self::UserWriteChat => "user:write:chat",
Self::WhispersRead => "whispers:read",
Self::ChatEdit => "chat:edit",
Self::ChatRead => "chat:read",
}
}
}
impl Display for Scope {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
impl From<Scope> for String {
fn from(value: Scope) -> Self {
value.as_str().to_string()
}
}
#[derive(Debug)]
pub struct InvalidScopeError(String);
impl Display for InvalidScopeError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Invalid scope: '{}'", self.0)
}
}
impl std::error::Error for InvalidScopeError {}
impl FromStr for Scope {
type Err = InvalidScopeError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"analytics:read:extensions" => Ok(Self::AnalyticsReadExtensions),
"analytics:read:games" => Ok(Self::AnalyticsReadGames),
"bits:read" => Ok(Self::BitsRead),
"channel:bot" => Ok(Self::ChannelBot),
"channel:manage:ads" => Ok(Self::ChannelManageAds),
"channel:read:ads" => Ok(Self::ChannelReadAds),
"channel:manage:broadcast" => Ok(Self::ChannelManageBroadcast),
"channel:read:charity" => Ok(Self::ChannelReadCharity),
"channel:edit:commercial" => Ok(Self::ChannelEditCommercial),
"channel:read:editors" => Ok(Self::ChannelReadEditors),
"channel:manage:extensions" => Ok(Self::ChannelManageExtensions),
"channel:read:goals" => Ok(Self::ChannelReadGoals),
"channel:read:guest_star" => Ok(Self::ChannelReadGuestStar),
"channel:manage:guest_star" => Ok(Self::ChannelManageGuestStar),
"channel:read:hype_train" => Ok(Self::ChannelReadHypeTrain),
"channel:manage:moderators" => Ok(Self::ChannelManageModerators),
"channel:moderate" => Ok(Self::ChannelModerate),
"channel:read:polls" => Ok(Self::ChannelReadPolls),
"channel:manage:polls" => Ok(Self::ChannelManagePolls),
"channel:read:predictions" => Ok(Self::ChannelReadPredictions),
"channel:manage:predictions" => Ok(Self::ChannelManagePredictions),
"channel:manage:raids" => Ok(Self::ChannelManageRaids),
"channel:read:redemptions" => Ok(Self::ChannelReadRedemptions),
"channel:manage:redemptions" => Ok(Self::ChannelManageRedemptions),
"channel:manage:schedule" => Ok(Self::ChannelManageSchedule),
"channel:read:stream_key" => Ok(Self::ChannelReadStreamKey),
"channel:read:subscriptions" => Ok(Self::ChannelReadSubscriptions),
"channel:manage:videos" => Ok(Self::ChannelManageVideos),
"channel:read:vips" => Ok(Self::ChannelReadVips),
"channel:manage:vips" => Ok(Self::ChannelManageVips),
"clips:edit" => Ok(Self::ClipsEdit),
"channel:manage:clips" => Ok(Self::ChannelManageClips),
"editor:manage:clips" => Ok(Self::EditorManageClips),
"moderation:read" => Ok(Self::ModerationRead),
"moderator:manage:announcements" => Ok(Self::ModeratorManageAnnouncements),
"moderator:manage:automod" => Ok(Self::ModeratorManageAutomod),
"moderator:read:automod_settings" => Ok(Self::ModeratorReadAutomodSettings),
"moderator:manage:automod_settings" => Ok(Self::ModeratorManageAutomodSettings),
"moderator:read:banned_users" => Ok(Self::ModeratorReadBannedUsers),
"moderator:manage:banned_users" => Ok(Self::ModeratorManageBannedUsers),
"moderator:read:blocked_terms" => Ok(Self::ModeratorReadBlockedTerms),
"moderator:read:chat_messages" => Ok(Self::ModeratorReadChatMessages),
"moderator:manage:blocked_terms" => Ok(Self::ModeratorManageBlockedTerms),
"moderator:manage:chat_messages" => Ok(Self::ModeratorManageChatMessages),
"moderator:read:chat_settings" => Ok(Self::ModeratorReadChatSettings),
"moderator:manage:chat_settings" => Ok(Self::ModeratorManageChatSettings),
"moderator:read:chatters" => Ok(Self::ModeratorReadChatters),
"moderator:read:followers" => Ok(Self::ModeratorReadFollowers),
"moderator:read:guest_star" => Ok(Self::ModeratorReadGuestStar),
"moderator:manage:guest_star" => Ok(Self::ModeratorManageGuestStar),
"moderator:read:moderators" => Ok(Self::ModeratorReadModerators),
"moderator:read:shield_mode" => Ok(Self::ModeratorReadShieldMode),
"moderator:manage:shield_mode" => Ok(Self::ModeratorManageShieldMode),
"moderator:read:shoutouts" => Ok(Self::ModeratorReadShoutouts),
"moderator:manage:shoutouts" => Ok(Self::ModeratorManageShoutouts),
"moderator:read:suspicious_users" => Ok(Self::ModeratorReadSuspiciousUsers),
"moderator:read:unban_requests" => Ok(Self::ModeratorReadUnbanRequests),
"moderator:manage:unban_requests" => Ok(Self::ModeratorManageUnbanRequests),
"moderator:read:vips" => Ok(Self::ModeratorReadVips),
"moderator:read:warnings" => Ok(Self::ModeratorReadWarnings),
"moderator:manage:warnings" => Ok(Self::ModeratorManageWarnings),
"moderator:manage:suspicious_users" => Ok(Self::ModeratorManageSuspiciousUsers),
"user:bot" => Ok(Self::UserBot),
"user:edit" => Ok(Self::UserEdit),
"user:edit:broadcast" => Ok(Self::UserEditBroadcast),
"user:read:blocked_users" => Ok(Self::UserReadBlockedUsers),
"user:manage:blocked_users" => Ok(Self::UserManageBlockedUsers),
"user:read:broadcast" => Ok(Self::UserReadBroadcast),
"user:read:chat" => Ok(Self::UserReadChat),
"user:manage:chat_color" => Ok(Self::UserManageChatColor),
"user:read:email" => Ok(Self::UserReadEmail),
"user:read:emotes" => Ok(Self::UserReadEmotes),
"user:read:follows" => Ok(Self::UserReadFollows),
"user:read:moderated_channels" => Ok(Self::UserReadModeratedChannels),
"user:read:subscriptions" => Ok(Self::UserReadSubscriptions),
"user:read:whispers" => Ok(Self::UserReadWhispers),
"user:manage:whispers" => Ok(Self::UserManageWhispers),
"user:write:chat" => Ok(Self::UserWriteChat),
"whispers:read" => Ok(Self::WhispersRead),
"chat:edit" => Ok(Self::ChatEdit),
"chat:read" => Ok(Self::ChatRead),
_ => Err(InvalidScopeError(s.to_string())),
}
}
}
impl AsRef<str> for Scope {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl Deref for Scope {
type Target = str;
fn deref(&self) -> &str {
self.as_str()
}
}
impl Serialize for Scope {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for Scope {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
s.parse()
.map_err(|e: InvalidScopeError| D::Error::custom(e))
}
}