Skip to content

Commit d0f0420

Browse files
committed
Use FixedArray and FixedString in model enums (serenity-rs#2675)
Simply missed these when finding and replacing.
1 parent deb151a commit d0f0420

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

src/model/application/command_interaction.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,10 @@ impl CommandData {
349349
for opt in opts {
350350
let value = match &opt.value {
351351
CommandDataOptionValue::SubCommand(opts) => {
352-
ResolvedValue::SubCommand(resolve_options(opts, resolved))
352+
ResolvedValue::SubCommand(resolve_options(opts, resolved).into())
353353
},
354354
CommandDataOptionValue::SubCommandGroup(opts) => {
355-
ResolvedValue::SubCommandGroup(resolve_options(opts, resolved))
355+
ResolvedValue::SubCommandGroup(resolve_options(opts, resolved).into())
356356
},
357357
CommandDataOptionValue::Autocomplete {
358358
kind,
@@ -457,8 +457,8 @@ pub enum ResolvedValue<'a> {
457457
Integer(i64),
458458
Number(f64),
459459
String(&'a str),
460-
SubCommand(Vec<ResolvedOption<'a>>),
461-
SubCommandGroup(Vec<ResolvedOption<'a>>),
460+
SubCommand(FixedArray<ResolvedOption<'a>>),
461+
SubCommandGroup(FixedArray<ResolvedOption<'a>>),
462462
Attachment(&'a Attachment),
463463
Channel(&'a PartialChannel),
464464
Role(&'a Role),

src/model/channel/message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ impl MessageId {
12251225
#[derive(Clone, Debug, Serialize)]
12261226
#[serde(untagged)]
12271227
pub enum Nonce {
1228-
String(String),
1228+
String(FixedString),
12291229
Number(u64),
12301230
}
12311231

src/model/guild/audit_log/change.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub struct AffectedRole {
3030
#[non_exhaustive]
3131
pub enum EntityType {
3232
Int(u64),
33-
Str(String),
33+
Str(FixedString),
3434
}
3535

3636
impl<'de> serde::Deserialize<'de> for EntityType {
@@ -72,20 +72,20 @@ macro_rules! generate_change {
7272
RolesAdded {
7373
#[serde(skip_serializing_if = "Option::is_none")]
7474
#[serde(rename = "old_value")]
75-
old: Option<Vec<AffectedRole>>,
75+
old: Option<FixedArray<AffectedRole>>,
7676
#[serde(skip_serializing_if = "Option::is_none")]
7777
#[serde(rename = "new_value")]
78-
new: Option<Vec<AffectedRole>>,
78+
new: Option<FixedArray<AffectedRole>>,
7979
},
8080
/// Role was removed to a member.
8181
#[serde(rename = "$remove")]
8282
RolesRemove {
8383
#[serde(skip_serializing_if = "Option::is_none")]
8484
#[serde(rename = "old_value")]
85-
old: Option<Vec<AffectedRole>>,
85+
old: Option<FixedArray<AffectedRole>>,
8686
#[serde(skip_serializing_if = "Option::is_none")]
8787
#[serde(rename = "new_value")]
88-
new: Option<Vec<AffectedRole>>,
88+
new: Option<FixedArray<AffectedRole>>,
8989
},
9090

9191
/// Unknown key was changed.
@@ -120,7 +120,7 @@ macro_rules! generate_change {
120120
}
121121

122122
generate_change! {
123-
"actions" => Actions(Vec<Action>),
123+
"actions" => Actions(FixedArray<Action>),
124124
/// AFK channel was changed.
125125
"afk_channel_id" => AfkChannelId(ChannelId),
126126
/// AFK timeout duration was changed.
@@ -131,7 +131,7 @@ generate_change! {
131131
"application_id" => ApplicationId(ApplicationId),
132132
/// Thread is now archived/unarchived.
133133
"archived" => Archived(bool),
134-
"asset" => Asset(String),
134+
"asset" => Asset(FixedString),
135135
/// Auto archive duration of a thread was changed.
136136
"auto_archive_duration" => AutoArchiveDuration(u16),
137137
/// Availability of a sticker was changed.
@@ -145,7 +145,7 @@ generate_change! {
145145
/// Channel for invite code or guild scheduled event was changed.
146146
"channel_id" => ChannelId(ChannelId),
147147
/// Invite code was changed.
148-
"code" => Code(String),
148+
"code" => Code(FixedString),
149149
/// Role color was changed.
150150
"color" => Color(u32),
151151
/// Member timeout state was changed.
@@ -159,7 +159,7 @@ generate_change! {
159159
/// Permission on a text or voice channel was denied for a role.
160160
"deny" => Deny(Permissions),
161161
/// Description for guild, sticker, or guild scheduled event was changed.
162-
"description" => Description(String),
162+
"description" => Description(FixedString),
163163
/// Guild's discovery splash was changed.
164164
"discovery_splash_hash" => DiscoverySplashHash(ImageHash),
165165
"enabled" => Enabled(bool),
@@ -168,8 +168,8 @@ generate_change! {
168168
/// Entity type of guild scheduled event was changed.
169169
"entity_type" => EntityType(u64),
170170
"event_type" => EventType(EventType),
171-
"exempt_channels" => ExemptChannels(Vec<ChannelId>),
172-
"exempt_roles" => ExemptRoles(Vec<RoleId>),
171+
"exempt_channels" => ExemptChannels(FixedArray<ChannelId>),
172+
"exempt_roles" => ExemptRoles(FixedArray<RoleId>),
173173
/// Behavior of the expiration of an integration was changed.
174174
"expire_behavior" => ExpireBehavior(u64),
175175
/// Grace period of the expiration of an integration was changed.
@@ -195,7 +195,7 @@ generate_change! {
195195
/// ID of the user who created the invite.
196196
"inviter_id" => InviterId(UserId),
197197
/// Location for a guild scheduled event was changed.
198-
"location" => Location(String),
198+
"location" => Location(FixedString),
199199
/// Thread was locked/unlocked.
200200
"locked" => Locked(bool),
201201
/// How long invite code lasts was changed.
@@ -209,21 +209,21 @@ generate_change! {
209209
/// User was server muted/unmuted.
210210
"mute" => Mute(bool),
211211
/// Name of an entity was changed.
212-
"name" => Name(String),
212+
"name" => Name(FixedString),
213213
/// Nickname of a member was changed.
214-
"nick" => Nick(String),
214+
"nick" => Nick(FixedString),
215215
/// Channel NSFW restriction was changed.
216216
"nsfw" => Nsfw(bool),
217217
/// Owner of a guild was changed.
218218
"owner_id" => OwnerId(UserId),
219219
/// Permissions on a channel were changed.
220-
"permission_overwrites" => PermissionOverwrites(Vec<PermissionOverwrite>),
220+
"permission_overwrites" => PermissionOverwrites(FixedArray<PermissionOverwrite>),
221221
/// Permissions for a role were changed.
222222
"permissions" => Permissions(Permissions),
223223
/// Channel or role position was changed.
224224
"position" => Position(u32),
225225
/// Preferred locale of a guild was changed.
226-
"preferred_locale" => PreferredLocale(String),
226+
"preferred_locale" => PreferredLocale(FixedString),
227227
/// Privacy level of the stage instance was changed.
228228
"privacy_level" => PrivacyLevel(u64),
229229
/// Number of days after which inactive and role-unassigned members are kicked was changed.
@@ -233,7 +233,7 @@ generate_change! {
233233
/// Ratelimit per user in a text channel was changed.
234234
"rate_limit_per_user" => RateLimitPerUser(u16),
235235
/// Region of a guild was changed.
236-
"region" => Region(String),
236+
"region" => Region(FixedString),
237237
/// ID of the rules channel was changed.
238238
"rules_channel_id" => RulesChannelId(ChannelId),
239239
/// Invite splash page artwork was changed.
@@ -245,23 +245,23 @@ generate_change! {
245245
/// ID of the system channel was changed.
246246
"system_channel_id" => SystemChannelId(ChannelId),
247247
/// Related emoji of a sticker was changed.
248-
"tags" => Tags(String),
248+
"tags" => Tags(FixedString),
249249
/// Whether an invite is temporary or never expires was changed.
250250
"temporary" => Temporary(bool),
251251
/// Topic of a text channel or stage instance was changed.
252-
"topic" => Topic(String),
252+
"topic" => Topic(FixedString),
253253
"trigger_metadata" => TriggerMetadata(TriggerMetadata),
254254
"trigger_type" => TriggerType(TriggerType),
255255
/// Type of a created entity.
256256
"type" => Type(EntityType),
257257
/// Unicode emoji of a role icon was changed.
258-
"unicode_emoji" => UnicodeEmoji(String),
258+
"unicode_emoji" => UnicodeEmoji(FixedString),
259259
/// Maximum number of users in a voice channel was changed.
260260
"user_limit" => UserLimit(u64),
261261
/// Number of uses of an invite was changed.
262262
"uses" => Uses(u64),
263263
/// Guild invite vanity url was changed.
264-
"vanity_url_code" => VanityUrlCode(String),
264+
"vanity_url_code" => VanityUrlCode(FixedString),
265265
/// Required verification level for new members was changed.
266266
"verification_level" => VerificationLevel(VerificationLevel),
267267
/// Channel of the server widget was changed.
@@ -302,7 +302,7 @@ mod tests {
302302
fn entity_type_variant() {
303303
let value = Change::Type {
304304
old: Some(EntityType::Int(123)),
305-
new: Some(EntityType::Str("discord".into())),
305+
new: Some(EntityType::Str("discord".to_string().into())),
306306
};
307307
assert_json(&value, json!({"key": "type", "old_value": 123, "new_value": "discord"}));
308308
}

0 commit comments

Comments
 (0)