Skip to content

Commit

Permalink
expose a way to get a reference to HttpClient
Browse files Browse the repository at this point in the history
touches on #236
  • Loading branch information
Emilgardis committed Dec 13, 2021
1 parent 6489987 commit 124c2d5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ impl<'a, C: Client<'a> + Sync> twitch_oauth2::client::Client<'a> for crate::Heli
&'a self,
request: Req,
) -> BoxedFuture<'a, Result<Response, <Self as twitch_oauth2::client::Client>::Error>> {
self.client.req(request)
self.get_client().req(request)
}
}

Expand All @@ -383,7 +383,7 @@ impl<'a, C: Client<'a> + Sync> twitch_oauth2::client::Client<'a> for crate::TmiC
&'a self,
request: Req,
) -> BoxedFuture<'a, Result<Response, <Self as twitch_oauth2::client::Client>::Error>> {
self.client.req(request)
self.get_client().req(request)
}
}

Expand All @@ -395,7 +395,7 @@ impl<'a, C: Client<'a> + Sync> twitch_oauth2::client::Client<'a> for crate::Twit
&'a self,
request: Req,
) -> BoxedFuture<'a, Result<Response, <Self as twitch_oauth2::client::Client>::Error>> {
self.client().req(request)
self.get_client().req(request)
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/helix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ impl<'a, C: crate::HttpClient<'a>> HelixClient<'a, C> {
self.client.clone()
}

/// Retrieve a reference of the [`HttpClient`][crate::HttpClient] inside this [`HelixClient`]
pub fn get_client(&self) -> &C {
&self.client
}

/// Request on a valid [`RequestGet`] endpoint
///
/// ```rust,no_run
Expand Down
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,17 @@ impl<'a, C: HttpClient<'a>> TwitchClient<'a, C> {
}
}

pub(crate) fn client(&self) -> &C {
/// Retrieve a reference of the [`HttpClient`][crate::HttpClient] inside this [`TwitchClient`]
pub fn get_client(&self) -> &C {
#[cfg(feature = "helix")]
{
&self.helix.client
self.helix.get_client()
}
#[cfg(not(feature = "helix"))]
{
#[cfg(feature = "tmi")]
{
&self.tmi.client
self.tmi.get_client()
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/tmi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ impl<'a, C: crate::HttpClient<'a>> TmiClient<'a, C> {
self.client.clone()
}

/// Retrieve a reference of the [`HttpClient`][crate::HttpClient] inside this [`TmiClient`]
pub fn get_client(&self) -> &C {
&self.client
}

/// Get all the chatters in the chat
///
/// # Notes
Expand Down

0 comments on commit 124c2d5

Please sign in to comment.