pub struct Client<A> { /* private fields */ }
Expand description
Entrypoint for making requests to the Trovo api.
Implementations
sourceimpl<A> Client<A> where
A: ClientIdProvider,
impl<A> Client<A> where
A: ClientIdProvider,
sourcepub async fn chat_token_for_channel(
&self,
channel_id: impl AsRef<str>
) -> Result<ChatToken, RequestError>
pub async fn chat_token_for_channel(
&self,
channel_id: impl AsRef<str>
) -> Result<ChatToken, RequestError>
Get a chat token for the provided channel id
sourcepub async fn chat_messages_for_channel(
&self,
channel_id: impl AsRef<str>
) -> Result<ChatMessageStream, ChatMessagesForChannelError>
pub async fn chat_messages_for_channel(
&self,
channel_id: impl AsRef<str>
) -> Result<ChatMessageStream, ChatMessagesForChannelError>
Connect to the given channel id and receive a stream of messages.
sourceimpl<A> Client<A> where
A: AccessTokenProvider,
impl<A> Client<A> where
A: AccessTokenProvider,
sourcepub async fn chat_token_for_user(
&self
) -> Result<ChatToken, AuthenticatedRequestError<A::Error>>
pub async fn chat_token_for_user(
&self
) -> Result<ChatToken, AuthenticatedRequestError<A::Error>>
Get a chat token for the authenticated user’s channel
sourcepub async fn chat_messages_for_user(
&self
) -> Result<ChatMessageStream, ChatMessagesForUserError<A::Error>>
pub async fn chat_messages_for_user(
&self
) -> Result<ChatMessageStream, ChatMessagesForUserError<A::Error>>
Connect to the authenticated user’s channel and receive a stream of messages.
sourcepub async fn send_chat_message(
&self,
channel_id: Option<String>,
message: impl Into<String>
) -> Result<(), AuthenticatedRequestError<A::Error>>
pub async fn send_chat_message(
&self,
channel_id: Option<String>,
message: impl Into<String>
) -> Result<(), AuthenticatedRequestError<A::Error>>
Send a chat message to a channel
Scopes
Sending to your own channel
Requires chat_send_self
Sending to other channels
To send a message as sender (user A) to channel (owned by user B), the application needs to
get scopes chat_send_self
of user A, and send_to_my_channel
of user B.
sourceimpl<A> Client<A>
impl<A> Client<A>
sourcepub fn new(auth_provider: A) -> Self
pub fn new(auth_provider: A) -> Self
Creates a new default trovo client.
If you are already using reqwest in your program, it is advisable
to use Client::from_reqwest
instead to allow for connection
pool sharing.
Panics
This method panics if a TLS backend cannot be initialized, or the resolver cannot load the system configuration.
sourcepub fn from_reqwest(http: Client, auth_provider: A) -> Self
pub fn from_reqwest(http: Client, auth_provider: A) -> Self
Creates a new trovo client using the provided reqwest client.
This can be useful to allow sharing of a reqwest client’s connection pool across your program
sourceimpl<A> Client<A> where
A: ClientIdProvider,
impl<A> Client<A> where
A: ClientIdProvider,
sourcepub async fn users(
&self,
usernames: Vec<String>
) -> Result<Vec<User>, RequestError>
pub async fn users(
&self,
usernames: Vec<String>
) -> Result<Vec<User>, RequestError>
Gets a list of user’s channel id, user id, and nickname, by usernames.
Note: Even if just one of the usernames doesn’t exist, the result will be an empty vec due to api limitations.
sourcepub async fn user(
&self,
username: impl Into<String>
) -> Result<Option<User>, RequestError>
pub async fn user(
&self,
username: impl Into<String>
) -> Result<Option<User>, RequestError>
Gets a user’s channel id, user id, and nickname, by username.
Returns None if the user was not found
sourcepub async fn channel_by_id(
&self,
channel_id: impl Into<String>
) -> Result<Option<ChannelInfo>, RequestError>
pub async fn channel_by_id(
&self,
channel_id: impl Into<String>
) -> Result<Option<ChannelInfo>, RequestError>
Gets channel information for the given id
Returns None if the channel was not found
sourcepub async fn emotes(
&self,
emote_type: EmoteFetchType,
channel_ids: Vec<String>
) -> Result<EmoteChannels, RequestError>
pub async fn emotes(
&self,
emote_type: EmoteFetchType,
channel_ids: Vec<String>
) -> Result<EmoteChannels, RequestError>
Gets list of emotes for each channel and global/event emotes if requested.
sourceimpl<A> Client<A> where
A: AccessTokenProvider,
impl<A> Client<A> where
A: AccessTokenProvider,
sourcepub async fn update_channel(
&self,
channel_id: impl Into<String>,
update: ChannelUpdate
) -> Result<(), AuthenticatedRequestError<A::Error>>
pub async fn update_channel(
&self,
channel_id: impl Into<String>,
update: ChannelUpdate
) -> Result<(), AuthenticatedRequestError<A::Error>>
Allows you to update the user’s channel settings, including title, category, language, audience type. You may update only part of the info.
Trait Implementations
Auto Trait Implementations
impl<A> !RefUnwindSafe for Client<A>
impl<A> Send for Client<A> where
A: Send,
impl<A> Sync for Client<A> where
A: Sync,
impl<A> Unpin for Client<A> where
A: Unpin,
impl<A> !UnwindSafe for Client<A>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more