diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e2d7cbd..d808aa64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ [Commits](https://github.com/twitch-rs/twitch_types/compare/v0.4.5...Unreleased) +- Added `SharedChatSessionId` and `WhisperId` (feature `chat`) +- Added `EntitlementId`, `BenefitId`, `OrganizationId`, and `EntitlementCampaignId` (feature `entitlements`) +- Added `ConduitId` and `ConduitShardId` (feature `eventsub`) +- Added `ExtensionId` (feature `extensions`) +- Added `UnbanRequestid` (feature `moderation`) +- Added `CclId`, `GuestStarSessionId`, `GuestStarSlotId`, and `StreamMarkerId` (feature `stream`) + ## [v0.4.5] - 2024-04-15 [Commits](https://github.com/twitch-rs/twitch_types/compare/v0.4.4...v0.4.5) diff --git a/Cargo.toml b/Cargo.toml index 15457fb3..4b3662cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,13 +34,16 @@ zerofrom = { version = "0.1.0", optional = true } [features] default = [] +chat = [] emote = ["serde"] +entitlement = [] moderation = ["serde"] points = ["serde"] stream = ["serde"] timestamp = [] user = ["serde"] goal = ["serde"] +extension = [] eventsub = [] sub = [] color = ["serde"] diff --git a/src/chat.rs b/src/chat.rs new file mode 100644 index 00000000..c0d12dc1 --- /dev/null +++ b/src/chat.rs @@ -0,0 +1,13 @@ +manual_braid! { + /// A Shared Chat Session ID + pub struct SharedChatSessionId; + pub struct SharedChatSessionIdRef; +} +impl_extra!(SharedChatSessionId, SharedChatSessionIdRef); + +manual_braid! { + /// A Whisper ID + pub struct WhisperId; + pub struct WhisperIdRef; +} +impl_extra!(WhisperId, WhisperIdRef); diff --git a/src/collection.rs b/src/collection.rs index 5df7b27c..e4fe4c64 100644 --- a/src/collection.rs +++ b/src/collection.rs @@ -146,7 +146,7 @@ where } } - fn index(&'c self, range: impl std::ops::RangeBounds) -> Option> { + fn index(&'c self, range: impl std::ops::RangeBounds) -> Option> { let range = (range.start_bound().cloned(), range.end_bound().cloned()); let new: Collection<'_, T> = match self { Collection::Owned(v) => Collection::Owned(Cow::Borrowed(v.get(range)?)), @@ -162,7 +162,7 @@ where } /// Returns chunks of items, similar to [`slice::chunks`] - pub fn chunks(&'c self, chunk_size: usize) -> impl Iterator> + '_ { + pub fn chunks(&'c self, chunk_size: usize) -> impl Iterator> + 'c { let len = self.iter().len(); let mut start = 0; std::iter::from_fn(move || { @@ -193,7 +193,7 @@ where pub fn is_empty(&self) -> bool { self.len() == 0 } } -impl<'a, T: std::ops::Deref + std::fmt::Debug> std::fmt::Debug for Collection<'a, T> +impl std::fmt::Debug for Collection<'_, T> where [T]: ToOwned, <[T] as ToOwned>::Owned: std::fmt::Debug, diff --git a/src/color.rs b/src/color.rs index 9fec43c7..42695595 100644 --- a/src/color.rs +++ b/src/color.rs @@ -226,7 +226,7 @@ impl<'a> From> for NamedUserColor<'a> { fn from(color: Cow<'a, HexColorRef>) -> Self { NamedUserColor::Hex(color) } } -impl<'a> From for NamedUserColor<'a> { +impl From for NamedUserColor<'_> { fn from(color: HexColor) -> Self { NamedUserColor::Hex(color.into()) } } diff --git a/src/entitlement.rs b/src/entitlement.rs new file mode 100644 index 00000000..ef9916b7 --- /dev/null +++ b/src/entitlement.rs @@ -0,0 +1,27 @@ +manual_braid! { + /// An entitlement ID + pub struct EntitlementId; + pub struct EntitlementIdRef; +} +impl_extra!(EntitlementId, EntitlementIdRef); + +manual_braid! { + /// A benefit ID + pub struct BenefitId; + pub struct BenefitIdRef; +} +impl_extra!(BenefitId, BenefitIdRef); + +manual_braid! { + /// An organization ID + pub struct OrganizationId; + pub struct OrganizationIdRef; +} +impl_extra!(OrganizationId, OrganizationIdRef); + +manual_braid! { + /// An entitlement campaign ID + pub struct EntitlementCampaignId; + pub struct EntitlementCampaignIdRef; +} +impl_extra!(EntitlementCampaignId, EntitlementCampaignIdRef); diff --git a/src/eventsub.rs b/src/eventsub.rs index 1122de0d..c23bf63b 100644 --- a/src/eventsub.rs +++ b/src/eventsub.rs @@ -4,3 +4,17 @@ manual_braid! { pub struct EventSubIdRef; } impl_extra!(EventSubId, EventSubIdRef); + +manual_braid! { + /// An ID of a Conduit + pub struct ConduitId; + pub struct ConduitIdRef; +} +impl_extra!(ConduitId, ConduitIdRef); + +manual_braid! { + /// An ID of a Conduit Shard + pub struct ConduitShardId; + pub struct ConduitShardIdRef; +} +impl_extra!(ConduitShardId, ConduitShardIdRef); diff --git a/src/extension.rs b/src/extension.rs new file mode 100644 index 00000000..43ee7368 --- /dev/null +++ b/src/extension.rs @@ -0,0 +1,6 @@ +manual_braid! { + /// An Extension ID + pub struct ExtensionId; + pub struct ExtensionIdRef; +} +impl_extra!(ExtensionId, ExtensionIdRef); diff --git a/src/lib.rs b/src/lib.rs index 74fc144b..d18565c4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -60,15 +60,24 @@ where mod basic; // cc: https://github.com/rust-lang/rust/issues/83428, can't use glob imports and keep the modules private +#[cfg(feature = "chat")] +/// types for chat +pub mod chat; #[cfg(feature = "color")] /// types for colors pub mod color; #[cfg(feature = "emote")] /// types for emotes pub mod emote; +#[cfg(feature = "entitlement")] +/// types for entitlements +pub mod entitlement; #[cfg(feature = "eventsub")] /// types for eventsub related things pub mod eventsub; +#[cfg(feature = "extension")] +/// types for extensions +pub mod extension; #[cfg(feature = "goal")] /// types for goals pub mod goal; @@ -93,12 +102,18 @@ pub mod user; pub use basic::*; +#[cfg(feature = "chat")] +pub use crate::chat::*; #[cfg(feature = "color")] pub use crate::color::*; #[cfg(feature = "emote")] pub use crate::emote::*; +#[cfg(feature = "entitlement")] +pub use crate::entitlement::*; #[cfg(feature = "eventsub")] pub use crate::eventsub::*; +#[cfg(feature = "extension")] +pub use crate::extension::*; #[cfg(feature = "goal")] pub use crate::goal::*; #[cfg(feature = "moderation")] diff --git a/src/macros.rs b/src/macros.rs index 47ab8283..58c9a3c6 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -181,7 +181,7 @@ macro_rules! manual_braid { impl ::std::cmp::PartialOrd for $Owned { #[inline] #[allow(unknown_lints)] - #[allow(clippy::incorrect_partial_ord_impl_on_ord_type)] + #[allow(clippy::non_canonical_partial_ord_impl)] fn partial_cmp(&self, other: &Self) -> ::std::option::Option<::std::cmp::Ordering> { ::std::option::Option::Some(::std::cmp::Ord::cmp(self, other)) } diff --git a/src/moderation.rs b/src/moderation.rs index fb5810e2..1b6a4915 100644 --- a/src/moderation.rs +++ b/src/moderation.rs @@ -5,6 +5,13 @@ manual_braid! { } impl_extra!(BlockedTermId, BlockedTermIdRef); +manual_braid! { + /// An unban request ID + pub struct UnbanRequestId; + pub struct UnbanRequestIdRef; +} +impl_extra!(UnbanRequestId, UnbanRequestIdRef); + /// Status of a message that is or was in AutoMod queue #[derive(PartialEq, Eq, Debug, Clone)] #[cfg_attr( diff --git a/src/stream.rs b/src/stream.rs index 33ca59cf..94790cfa 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -78,6 +78,27 @@ manual_braid! { } impl_extra!(IgdbId, IgdbIdRef); +manual_braid! { + /// A Guest Star Session ID + pub struct GuestStarSessionId; + pub struct GuestStarSessionIdRef; +} +impl_extra!(GuestStarSessionId, GuestStarSessionIdRef); + +manual_braid! { + /// A Guest Star Slot ID + pub struct GuestStarSlotId; + pub struct GuestStarSlotIdRef; +} +impl_extra!(GuestStarSlotId, GuestStarSlotIdRef); + +manual_braid! { + /// A stream marker ID + pub struct StreamMarkerId; + pub struct StreamMarkerIdRef; +} +impl_extra!(StreamMarkerId, StreamMarkerIdRef); + /// A game or category as defined by Twitch #[derive(PartialEq, Eq, Debug, Clone)] #[cfg_attr( diff --git a/src/time.rs b/src/time.rs index 5c57d048..36530140 100644 --- a/src/time.rs +++ b/src/time.rs @@ -96,7 +96,7 @@ impl<'a> ::std::convert::From<::std::borrow::Cow<'a, TimestampRef>> for Timestam } } -impl<'a> ::std::convert::From for ::std::borrow::Cow<'a, TimestampRef> { +impl ::std::convert::From for ::std::borrow::Cow<'_, TimestampRef> { #[inline] fn from(owned: Timestamp) -> Self { ::std::borrow::Cow::Owned(owned) } } @@ -107,7 +107,7 @@ impl ::std::convert::TryFrom<::std::string::String> for Timestamp { #[inline] fn try_from(s: ::std::string::String) -> Result { const fn ensure_try_from_string_error_converts_to_validator_error< - T: ?Sized + From<>::Error>, + T: From<>::Error>, >() { }