diff --git a/Cargo.toml b/Cargo.toml index 47d48af..dc959e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,13 +23,16 @@ path = "src/lib.rs" [features] default = [] signature-verifier = ["dep:sha2", "dep:subtle", "dep:hmac"] -hyper = ["dep:tokio", "dep:http-body-util", "dep:hyper", "dep:hyper-rustls", "dep:hyper-util", "dep:tokio-stream", "dep:tokio-tungstenite", "dep:signal-hook", "dep:signal-hook-tokio", "signature-verifier"] -axum = ["hyper", "dep:axum", "dep:tower"] +hyper-base = ["dep:tokio", "dep:http-body-util", "dep:hyper", "dep:hyper-rustls", "dep:hyper-util", "dep:tokio-stream", "dep:tokio-tungstenite", "dep:signal-hook", "dep:signal-hook-tokio", "signature-verifier"] +axum-base = ["hyper-base", "dep:axum", "dep:tower"] +rustls-native-certs = ["tokio-tungstenite/rustls-native-certs", "hyper-rustls/rustls-native-certs", "hyper-rustls/ring"] +hyper = ["hyper-base", "rustls-native-certs"] +axum = ["axum-base", "hyper-base", "rustls-native-certs"] [dependencies] -serde = { version = "1.0", features = ["derive"] } +serde = { version = "1.0", features = ["derive"], default-features = false } serde_json = "1.0" -serde_with = { version = "3.8", features = ["json"] } +serde_with = { version = "3.8", features = ["json", "macros"], default-features = false } rvstruct = "0.3" rsb_derive = "0.5" futures = "0.3" @@ -49,12 +52,12 @@ mime_guess = "2" chrono = { version = "0.4", default-features = false, features = ["clock", "std", "serde"] } url = { version = "2.5", features = ["serde"] } http-body-util = { version = "0.1", optional = true } -hyper = { version = "1.3", features = ["http2", "server", "client"], optional = true } -hyper-util = { version = "0.1", features = ["client", "client-legacy", "server"], optional = true } -tokio = { version = "1", features = ["bytes", "rt-multi-thread", "signal", "tracing"], optional = true } +hyper = { version = "1.3", features = ["http2", "server", "client"], default-features = false, optional = true } +hyper-util = { version = "0.1", features = ["client", "client-legacy", "server", "tokio"], default-features = false, optional = true } +tokio = { version = "1", features = ["bytes", "rt-multi-thread", "signal", "tracing"], default-features = false, optional = true } tokio-stream = { version = "0.1", optional = true } -hyper-rustls = { version = "0.27", features = ["rustls-native-certs", "http2"], optional = true } -tokio-tungstenite = { version = "0.28.0", features = ["rustls-tls-native-roots"], optional = true } +hyper-rustls = { version = "0.27", features = ["http2", "native-tokio"], default-features = false, optional = true } +tokio-tungstenite = { version = "0.28.0", features = [], optional = true } axum = { version = "0.8", optional = true } tower = { version = "0.5", optional = true } sha2 = { version = "0.10", optional = true } diff --git a/docs/src/intro.md b/docs/src/intro.md index 8883cad..0315a1a 100644 --- a/docs/src/intro.md +++ b/docs/src/intro.md @@ -20,3 +20,7 @@ Includes also all type/models definitions that used for Slack Web/Events APIs. This library provided the following features: - `hyper`: Slack client support/binding for Hyper/Tokio/Tungstenite. - `axum`: Slack client support/binding for [axum framework](https://github.com/tokio-rs/axum) support. + +### TLS-related configuration features +By default, `hyper` and `axum` features use `rustls-native-certs` and `hyper-rustls/ring` setup for TLS configuration, +but you can switch off default-features and use `hyper-base` and `axum-base` features and have your own TLS configuration. diff --git a/src/lib.rs b/src/lib.rs index fd53b64..76bd62a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -105,10 +105,10 @@ pub mod socket_mode; pub mod multipart_form; mod token; -#[cfg(feature = "hyper")] +#[cfg(feature = "hyper-base")] pub mod hyper_tokio; -#[cfg(feature = "axum")] +#[cfg(feature = "axum-base")] pub mod axum_support; pub mod prelude; diff --git a/src/models/events/interaction.rs b/src/models/events/interaction.rs index 06e2497..9d7b179 100644 --- a/src/models/events/interaction.rs +++ b/src/models/events/interaction.rs @@ -80,7 +80,7 @@ pub struct SlackInteractionActionMessageContainer { #[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)] pub struct SlackInteractionActionMessageAttachmentContainer { pub message_ts: SlackTs, - pub attachment_id: i64, + pub attachment_id: SlackMessageAttachmentId, pub channel_id: Option, pub is_ephemeral: Option, pub is_app_unfurl: Option, diff --git a/src/models/messages/mod.rs b/src/models/messages/mod.rs index 8f970d2..ec7df6c 100644 --- a/src/models/messages/mod.rs +++ b/src/models/messages/mod.rs @@ -2,6 +2,7 @@ use crate::blocks::*; use crate::events::SlackMessageEventType; use crate::*; use rsb_derive::Builder; +use rvstruct::ValueStruct; use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; @@ -115,12 +116,15 @@ pub enum SlackMessageResponseType { Ephemeral, } +#[derive(Debug, Eq, PartialEq, Hash, Clone, Serialize, Deserialize, ValueStruct)] +pub struct SlackMessageAttachmentId(i64); + // This model is not well typed since Slack message attachments are deprecated // Please avoid using this if you can #[skip_serializing_none] #[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)] pub struct SlackMessageAttachment { - pub id: Option, + pub id: Option, pub color: Option, pub fallback: Option, pub title: Option, diff --git a/src/multipart_form.rs b/src/multipart_form.rs index 1cd8943..256a603 100644 --- a/src/multipart_form.rs +++ b/src/multipart_form.rs @@ -8,7 +8,7 @@ pub struct FileMultipartData<'a> { pub data: &'a [u8], } -#[cfg(feature = "hyper")] +#[cfg(feature = "hyper-base")] pub fn generate_multipart_boundary() -> String { format!( "----WebKitFormBoundarySlackMorphismRust{}", @@ -16,7 +16,7 @@ pub fn generate_multipart_boundary() -> String { ) } -#[cfg(feature = "hyper")] +#[cfg(feature = "hyper-base")] pub fn create_multipart_file_content<'p, PT, TS>( fields: &'p PT, multipart_boundary: &str, diff --git a/src/prelude.rs b/src/prelude.rs index 3703bec..b4775c4 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -11,8 +11,8 @@ pub use crate::models::blocks::*; // Slack Block Kit models pub use crate::models::events::*; pub use crate::models::*; // common Slack models like SlackUser, etc and macros // Slack Events Models -#[cfg(feature = "hyper")] +#[cfg(feature = "hyper-base")] pub use crate::hyper_tokio::*; -#[cfg(feature = "axum")] +#[cfg(feature = "axum-base")] pub use crate::axum_support::*;