Skip to content

Commit

Permalink
Merge #237
Browse files Browse the repository at this point in the history
237: expose a way to get a reference to HttpClient r=Emilgardis a=Emilgardis

touches on #236


Co-authored-by: Emil Gardström <emil.gardstrom@gmail.com>
  • Loading branch information
bors[bot] and Emilgardis authored Dec 13, 2021
2 parents 506682f + 3495873 commit 7194ec0
Show file tree
Hide file tree
Showing 4 changed files with 13 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 @@ -458,7 +458,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 @@ -470,7 +470,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 @@ -482,7 +482,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
3 changes: 3 additions & 0 deletions src/helix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ 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 @@ -243,16 +243,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
3 changes: 3 additions & 0 deletions src/tmi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ 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 7194ec0

Please sign in to comment.