Skip to content

Commit e6aae90

Browse files
authored
Merge pull request #90 from dscottboggs/fix/derive-is_variant
Fix: derive `is_variant`
2 parents 7324a6c + e279f4b commit e6aae90

10 files changed

+21
-25
lines changed

Cargo.toml

+1-5
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ edition.workspace = true
2828
[package.metadata.docs.rs]
2929
features = ["all"]
3030

31-
[patch.crates-io.is_variant]
32-
git = "https://github.com/dscottboggs/rust_macro_is_variant.git"
33-
branch = "fixes"
34-
3531
[dependencies.mastodon-async-entities]
3632
path = "./entities"
3733
version = "1.0.3"
@@ -48,7 +44,7 @@ static_assertions = "1.1.0"
4844
percent-encoding = "2.2.0"
4945
thiserror = "1.0.38"
5046
derive_deref = "1.1.1"
51-
is_variant = "1.0.0"
47+
derive_is_enum_variant = "0.1.1"
5248

5349
[dependencies.parse_link_header]
5450
version = "0.3.3"

entities/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ edition.workspace = true
1313
futures = "0.3.25"
1414
thiserror = "1"
1515
static_assertions = "1"
16-
is_variant = "1.0.0"
16+
derive_is_enum_variant = "0.1.1"
1717

1818
[dependencies.log]
1919
version = "0.4"

entities/src/attachment.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Module containing everything related to media attachements.
22
33
use crate::AttachmentId;
4-
use is_variant::IsVariant;
4+
use derive_is_enum_variant::is_enum_variant;
55
use serde::{Deserialize, Serialize};
66

77
/// A struct representing a media attachment.
@@ -63,7 +63,7 @@ pub struct ImageDetails {
6363
}
6464

6565
/// The type of media attachment.
66-
#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq, IsVariant)]
66+
#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq, is_enum_variant)]
6767
pub enum MediaType {
6868
/// An image.
6969
#[serde(rename = "image")]

entities/src/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use is_variant::IsVariant;
1+
use derive_is_enum_variant::is_enum_variant;
22

33
/// Error type
4-
#[derive(Debug, thiserror::Error, IsVariant)]
4+
#[derive(Debug, thiserror::Error, is_enum_variant)]
55
pub enum Error {
66
#[error("unrecognized visibility '{invalid}'")]
77
VisibilityParsingError { invalid: String },

entities/src/event.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::{notification::Notification, status::Status};
2-
use is_variant::IsVariant;
2+
use derive_is_enum_variant::is_enum_variant;
33
use serde::{Deserialize, Serialize};
44

5-
#[derive(Debug, Clone, Deserialize, Serialize, IsVariant)]
5+
#[derive(Debug, Clone, Deserialize, Serialize, is_enum_variant)]
66
/// Events that come from the /streaming/user API call
77
pub enum Event {
88
/// Update event

entities/src/filter.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use is_variant::IsVariant;
1+
use derive_is_enum_variant::is_enum_variant;
22
use serde::{de::Visitor, Deserialize, Deserializer, Serialize};
33
use time::{serde::iso8601, OffsetDateTime};
44

@@ -55,7 +55,7 @@ pub struct Filter {
5555
}
5656

5757
/// Represents the various types of Filter contexts
58-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, IsVariant)]
58+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, is_enum_variant)]
5959
#[serde(rename_all = "lowercase")]
6060
pub enum FilterContext {
6161
/// Represents the "home" context
@@ -74,7 +74,7 @@ pub enum FilterContext {
7474
///
7575
/// Please note that the spec requests that any unknown value be interpreted
7676
/// as "warn".
77-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, IsVariant)]
77+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, is_enum_variant)]
7878
#[serde(rename_all = "lowercase")]
7979
pub enum Action {
8080
/// Indicates filtered toots should show up, but with a warning

entities/src/notification.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::NotificationId;
44

55
use super::{account::Account, status::Status};
6-
use is_variant::IsVariant;
6+
use derive_is_enum_variant::is_enum_variant;
77
use serde::{Deserialize, Serialize};
88
use time::{serde::iso8601, OffsetDateTime};
99

@@ -26,7 +26,7 @@ pub struct Notification {
2626
}
2727

2828
/// The type of notification.
29-
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, IsVariant)]
29+
#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, is_enum_variant)]
3030
#[serde(rename_all = "lowercase")]
3131
pub enum NotificationType {
3232
/// Someone mentioned the application client in another status.

entities/src/visibility.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use is_variant::IsVariant;
1+
use derive_is_enum_variant::is_enum_variant;
22
use serde::Deserialize;
33
use serde::Serialize;
44

55
/// The visibility of a status.
6-
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq, IsVariant)]
6+
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq, is_enum_variant)]
77
#[serde(rename_all = "lowercase")]
88
pub enum Visibility {
99
/// A Direct message to a user

src/errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::string::FromUtf8Error;
22
use std::{error, fmt, io::Error as IoError, num::TryFromIntError};
33

4+
use derive_is_enum_variant::is_enum_variant;
45
#[cfg(feature = "env")]
56
use envy::Error as EnvyError;
6-
use is_variant::IsVariant;
77
use reqwest::{header::ToStrError as HeaderStrError, Error as HttpError, StatusCode};
88
use serde::Deserialize;
99
use serde_json::Error as SerdeError;
@@ -18,7 +18,7 @@ use url::ParseError as UrlError;
1818
pub type Result<T> = ::std::result::Result<T, Error>;
1919

2020
/// enum of possible errors encountered using the mastodon API.
21-
#[derive(Debug, thiserror::Error, IsVariant)]
21+
#[derive(Debug, thiserror::Error, is_enum_variant)]
2222
pub enum Error {
2323
/// Error from the Mastodon API. This typically means something went
2424
/// wrong with your authentication or data.

src/scopes.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use std::{
66
str::FromStr,
77
};
88

9-
use is_variant::IsVariant;
109
use serde::ser::{Serialize, Serializer};
1110

1211
use crate::errors::Error;
12+
use derive_is_enum_variant::is_enum_variant;
1313
use serde::{
1414
de::{self, Visitor},
1515
Deserialize, Deserializer,
@@ -258,7 +258,7 @@ impl fmt::Display for Scopes {
258258
/// Permission scope of the application.
259259
/// [Details on what each permission provides][1]
260260
/// [1]: https://github.com/tootsuite/documentation/blob/master/Using-the-API/OAuth-details.md)
261-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, IsVariant)]
261+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, is_enum_variant)]
262262
#[serde(rename_all = "lowercase")]
263263
pub enum Scope {
264264
/// Read only permissions.
@@ -353,7 +353,7 @@ impl Default for Scope {
353353
}
354354

355355
/// Represents the granular "read:___" oauth scopes
356-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, IsVariant)]
356+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, is_enum_variant)]
357357
pub enum Read {
358358
/// Accounts
359359
#[serde(rename = "accounts")]
@@ -448,7 +448,7 @@ impl fmt::Display for Read {
448448
}
449449

450450
/// Represents the granular "write:___" oauth scopes
451-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, IsVariant)]
451+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, is_enum_variant)]
452452
pub enum Write {
453453
/// Accounts
454454
#[serde(rename = "accounts")]

0 commit comments

Comments
 (0)