diff --git a/README.md b/README.md index 3a62829..c5b733b 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ use ntfy::prelude::*; #[tokio::main] async fn main() -> Result<(), Error> { - let dispatcher = DispatcherBuilder::new("https://ntfy.sh") + let dispatcher = dispatcher::builder("https://ntfy.sh") .credentials(Auth::credentials("username", "password")) // Add optional credentials .proxy("socks5h://127.0.0.1:9050") // Add optional proxy .build_async()?; // Build dispatcher diff --git a/examples/blocking.rs b/examples/blocking.rs index aba2e26..f896a8d 100644 --- a/examples/blocking.rs +++ b/examples/blocking.rs @@ -4,7 +4,7 @@ use ntfy::prelude::*; fn main() -> Result<(), Error> { - let dispatcher = DispatcherBuilder::new("https://ntfy.sh") + let dispatcher = dispatcher::builder("https://ntfy.sh") .credentials(Auth::credentials("username", "password")) // Add optional credentials .proxy("socks5://127.0.0.1:9050") // Add optional proxy .build_blocking()?; // Build dispatcher diff --git a/examples/client.rs b/examples/client.rs index 182c036..23f7259 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -5,7 +5,7 @@ use ntfy::prelude::*; #[tokio::main] async fn main() -> Result<(), Error> { - let dispatcher = DispatcherBuilder::new("https://ntfy.sh") + let dispatcher = dispatcher::builder("https://ntfy.sh") .credentials(Auth::credentials("username", "password")) // Add optional credentials .proxy("socks5h://127.0.0.1:9050") // Add optional proxy .build_async()?; // Build dispatcher diff --git a/src/dispatcher/mod.rs b/src/dispatcher/mod.rs index 0ed5456..8d87d3b 100644 --- a/src/dispatcher/mod.rs +++ b/src/dispatcher/mod.rs @@ -20,6 +20,15 @@ use crate::error::Error; #[cfg(any(feature = "async", feature = "blocking"))] use crate::payload::Payload; +/// Creates a [`DispatcherBuilder`] +#[inline] +pub fn builder(url: S) -> DispatcherBuilder +where + S: Into, +{ + DispatcherBuilder::new(url) +} + #[derive(Debug, Clone)] pub struct Dispatcher where @@ -34,7 +43,7 @@ where T: Clone, { /// Create new dispatcher - #[deprecated(since = "0.7.0", note = "Please use `Dispatcher::builder` instead")] + #[deprecated(since = "0.7.0", note = "Use the `DispatcherBuilder` instead")] pub fn new(_url: S, _auth: Option, _proxy: Option) -> Result where S: Into, @@ -42,7 +51,10 @@ where unimplemented!() } - #[deprecated(since = "0.7.0", note = "Please use `DispatcherBuilder::new` instead")] + #[deprecated( + since = "0.7.0", + note = "Use `dispatcher::builder` or `DispatcherBuilder::new` instead" + )] pub fn builder(url: S) -> DispatcherBuilder where S: Into,