-
-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eval: use traits github interactions
- Loading branch information
Showing
4 changed files
with
84 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
use hubcaps::gists::{Gist, GistOptions}; | ||
|
||
pub struct Client<'a> { | ||
pub trait Client { | ||
fn create_gist(&self, gist: &GistOptions) -> hubcaps::Result<Gist>; | ||
} | ||
|
||
pub struct Hubcaps<'a> { | ||
github: &'a hubcaps::Github, | ||
} | ||
|
||
impl<'a> Client<'a> { | ||
impl<'a> Hubcaps<'a> { | ||
pub fn new(github: &'a hubcaps::Github) -> Self { | ||
Client { github } | ||
Hubcaps { github } | ||
} | ||
} | ||
|
||
pub fn create_gist(&self, gist: &GistOptions) -> hubcaps::Result<Gist> { | ||
impl Client for Hubcaps<'_> { | ||
fn create_gist(&self, gist: &GistOptions) -> hubcaps::Result<Gist> { | ||
self.github.gists().create(gist) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters