pub struct SlackClient { /* private fields */ }Expand description
Slack Web API client. A clone shares one connection pool.
Get it from a handler with crate::SlackContext::client, or from the
app state with SlackClient::from_state.
Implementations§
Source§impl SlackClient
impl SlackClient
Sourcepub fn from_state(state: &AppState) -> Option<Self>
pub fn from_state(state: &AppState) -> Option<Self>
Returns the client that the plugin put in the app state at startup.
Sourcepub async fn call(
&self,
method: &str,
params: &Value,
) -> Result<Value, SlackError>
pub async fn call( &self, method: &str, params: &Value, ) -> Result<Value, SlackError>
Calls a write method. It retries only on 429.
params is a JSON object. The client sends strings unchanged and other
values as JSON text. It does not send null values.
§Errors
Returns SlackError::Api for ok: false, or a transport, HTTP,
rate-limit, decode, or config error.
Sourcepub async fn chat_post_message(
&self,
channel: &str,
msg: &Message,
) -> Result<MessageRef, SlackError>
pub async fn chat_post_message( &self, channel: &str, msg: &Message, ) -> Result<MessageRef, SlackError>
Sourcepub async fn chat_post_ephemeral(
&self,
channel: &str,
user: &str,
msg: &Message,
) -> Result<String, SlackError>
pub async fn chat_post_ephemeral( &self, channel: &str, user: &str, msg: &Message, ) -> Result<String, SlackError>
Sourcepub async fn chat_update(
&self,
channel: &str,
ts: &str,
msg: &Message,
) -> Result<MessageRef, SlackError>
pub async fn chat_update( &self, channel: &str, ts: &str, msg: &Message, ) -> Result<MessageRef, SlackError>
Sourcepub async fn chat_delete(
&self,
channel: &str,
ts: &str,
) -> Result<(), SlackError>
pub async fn chat_delete( &self, channel: &str, ts: &str, ) -> Result<(), SlackError>
Sourcepub async fn reactions_add(
&self,
channel: &str,
ts: &str,
name: &str,
) -> Result<(), SlackError>
pub async fn reactions_add( &self, channel: &str, ts: &str, name: &str, ) -> Result<(), SlackError>
Sourcepub async fn views_open(
&self,
trigger_id: &str,
view: &Value,
) -> Result<Value, SlackError>
pub async fn views_open( &self, trigger_id: &str, view: &Value, ) -> Result<Value, SlackError>
Sourcepub async fn views_update(
&self,
view_id: &str,
view: &Value,
hash: Option<&str>,
) -> Result<Value, SlackError>
pub async fn views_update( &self, view_id: &str, view: &Value, hash: Option<&str>, ) -> Result<Value, SlackError>
views.update. hash stops an update that would overwrite a newer
view. Returns the view.
§Errors
Same as Self::call.
Sourcepub async fn views_push(
&self,
trigger_id: &str,
view: &Value,
) -> Result<Value, SlackError>
pub async fn views_push( &self, trigger_id: &str, view: &Value, ) -> Result<Value, SlackError>
Sourcepub async fn views_publish(
&self,
user_id: &str,
view: &Value,
) -> Result<Value, SlackError>
pub async fn views_publish( &self, user_id: &str, view: &Value, ) -> Result<Value, SlackError>
Sourcepub async fn users_info(&self, user: &str) -> Result<Value, SlackError>
pub async fn users_info(&self, user: &str) -> Result<Value, SlackError>
Sourcepub async fn auth_test(&self) -> Result<AuthTest, SlackError>
pub async fn auth_test(&self) -> Result<AuthTest, SlackError>
Sourcepub async fn paginate(
&self,
method: &str,
params: &Value,
key: &str,
max_pages: usize,
) -> Result<Vec<Value>, SlackError>
pub async fn paginate( &self, method: &str, params: &Value, key: &str, max_pages: usize, ) -> Result<Vec<Value>, SlackError>
Calls a read method once per page and joins the key arrays.
It follows response_metadata.next_cursor for at most max_pages.
§Errors
Same as Self::call.
Sourcepub async fn respond(
&self,
response_url: &str,
msg: &Message,
) -> Result<(), SlackError>
pub async fn respond( &self, response_url: &str, msg: &Message, ) -> Result<(), SlackError>
Posts msg as JSON to a response_url. It sends no token.
§Errors
Returns SlackError::BadResponseUrl for a URL that is not HTTPS on
an allowed host. Returns an HTTP or transport error.
Trait Implementations§
Source§impl Clone for SlackClient
impl Clone for SlackClient
Auto Trait Implementations§
impl !RefUnwindSafe for SlackClient
impl !UnwindSafe for SlackClient
impl Forget for SlackClient
impl Freeze for SlackClient
impl Send for SlackClient
impl Sync for SlackClient
impl Unpin for SlackClient
impl UnsafeUnpin for SlackClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Scoped for T
impl<T> Scoped for T
Source§fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
ScopeQuery for this type. Resolves the
registered scope at .load() time, not here.