pub struct GistsHandler<'octo> { /* private fields */ }
Expand description
Handler for GitHub’s gist API.
Created with Octocrab::gists
.
Implementations§
source§impl<'octo> GistsHandler<'octo>
impl<'octo> GistsHandler<'octo>
sourcepub fn list_all_gists(&self) -> ListAllGistsBuilder<'octo>
pub fn list_all_gists(&self) -> ListAllGistsBuilder<'octo>
List all gists from GitHub’s gist API.
See: GitHub API Documentation for GET /gists
§Note
-
Calling with an authentication token will list all the gists of the authenticated user
-
If no authentication token will list all the public gists from GitHub’s API. This can potentially produce a lot of results, so care is advised.
§Example
- This shows one page of (10) results for all public gists created a from the day before:
let yesterday: chrono::DateTime<chrono::Utc> =
chrono::Utc::now()
.checked_sub_days(chrono::Days::new(1)).unwrap();
octocrab::instance()
.gists()
.list_all_gists()
.since(yesterday)
.page(1u32)
.per_page(10u8)
.send()
.await?;
sourcepub fn list_all_recent_public_gists(&self) -> ListPublicGistsBuilder<'octo>
pub fn list_all_recent_public_gists(&self) -> ListPublicGistsBuilder<'octo>
List public gists sorted by most recently updated to least recently
updated. This works similarly to the GistsHandler::list_all_gists
See: GitHub API Documentation for GET /gists/public
§Example
let yesterday: chrono::DateTime<chrono::Utc> =
chrono::Utc::now()
.checked_sub_days(chrono::Days::new(1)).unwrap();
let all_public_gists = octocrab::instance()
.gists()
.list_all_recent_public_gists()
.since(yesterday)
.page(1u32)
.per_page(10u8)
.send()
.await?;
sourcepub fn list_user_gists(
&self,
username: impl AsRef<str>,
) -> ListUserGistsBuilder<'octo>
pub fn list_user_gists( &self, username: impl AsRef<str>, ) -> ListUserGistsBuilder<'octo>
List gists for the given username, allowing for pagination.
See GitHub API Documentation for details on GET /users/{username}/gists
§Examples
- Fetch 10 recent gists for the user with login “foouser”:
octocrab::instance()
.gists()
.list_user_gists("foouser")
.page(1u32)
.per_page(10u8)
.send()
.await?;
sourcepub fn create(&self) -> CreateGistBuilder<'octo>
pub fn create(&self) -> CreateGistBuilder<'octo>
Create a new gist.
let gitignore = octocrab::instance()
.gists()
.create()
.file("hello_world.rs", "fn main() {\n println!(\"Hello World!\");\n}")
// Optional Parameters
.description("Hello World in Rust")
.public(false)
.send()
.await?;
sourcepub fn update(&self, id: impl AsRef<str>) -> UpdateGistBuilder<'octo>
pub fn update(&self, id: impl AsRef<str>) -> UpdateGistBuilder<'octo>
Update an existing gist.
let gitignore = octocrab::instance()
.gists()
.update("aa5a315d61ae9438b18d")
// Optional Parameters
.description("Updated!")
.file("hello_world.rs")
.rename_to("fibonacci.rs")
.with_content("fn main() {\n println!(\"I should be a Fibonacci!\");\n}")
.file("delete_me.rs")
.delete()
.send()
.await?;
sourcepub async fn get(&self, id: impl AsRef<str>) -> Result<Gist>
pub async fn get(&self, id: impl AsRef<str>) -> Result<Gist>
Get a single gist.
let gist = octocrab::instance().gists().get("00000000000000000000000000000000").await?;
sourcepub async fn delete(&self, gist_id: impl AsRef<str>) -> Result<()>
pub async fn delete(&self, gist_id: impl AsRef<str>) -> Result<()>
Delete a single gist.
octocrab::instance().gists().delete("00000000000000000000000000000000").await?;
sourcepub async fn get_revision(
&self,
id: impl AsRef<str>,
sha1: impl AsRef<str>,
) -> Result<GistRevision>
pub async fn get_revision( &self, id: impl AsRef<str>, sha1: impl AsRef<str>, ) -> Result<GistRevision>
Get a single gist revision.
let revision = octocrab::instance()
.gists()
.get_revision("00000000000000000000000000000000", "1111111111111111111111111111111111111111")
.await?;
sourcepub fn list_commits(
&self,
gist_id: impl Into<String>,
) -> ListCommitsBuilder<'_, '_>
pub fn list_commits( &self, gist_id: impl Into<String>, ) -> ListCommitsBuilder<'_, '_>
List commits for the specified gist.
use octocrab::params;
// Get the least active repos belonging to `owner`.
let page = octocrab::instance()
.gists()
.list_commits("00000000000000000000000000000000")
// Optional Parameters
.per_page(25)
.page(5u32)
// Send the request.
.send()
.await?;
sourcepub async fn is_starred(&self, gist_id: impl AsRef<str>) -> Result<bool>
pub async fn is_starred(&self, gist_id: impl AsRef<str>) -> Result<bool>
Check if the given is gist is already starred by the authenticated user. See GitHub API Documentation more information about response data.
let is_starred: bool = octocrab::instance()
.gists()
.is_starred("00000000000000000000000000000000")
.await?;
sourcepub async fn star(&self, gist_id: impl AsRef<str>) -> Result<()>
pub async fn star(&self, gist_id: impl AsRef<str>) -> Result<()>
Star the given gist. See GitHub API Documentation more information about response data.
octocrab::instance()
.gists()
.star("00000000000000000000000000000000")
.await?;
sourcepub async fn unstar(&self, gist_id: impl AsRef<str>) -> Result<()>
pub async fn unstar(&self, gist_id: impl AsRef<str>) -> Result<()>
Unstar the given gist. See GitHub API Documentation more information about response data.
octocrab::instance()
.gists()
.unstar("00000000000000000000000000000000")
.await?;
sourcepub fn list_forks(
&self,
gist_id: impl Into<String>,
) -> ListGistForksBuilder<'_, '_>
pub fn list_forks( &self, gist_id: impl Into<String>, ) -> ListGistForksBuilder<'_, '_>
Retrieve all the gists that forked the given gist_id
. See
GitHub API Docs for information about request parameters, and
response schema.
octocrab::instance()
.gists()
.list_forks("00000000000000000000000000000000")
.send()
.await?;
Auto Trait Implementations§
impl<'octo> Freeze for GistsHandler<'octo>
impl<'octo> !RefUnwindSafe for GistsHandler<'octo>
impl<'octo> Send for GistsHandler<'octo>
impl<'octo> Sync for GistsHandler<'octo>
impl<'octo> Unpin for GistsHandler<'octo>
impl<'octo> !UnwindSafe for GistsHandler<'octo>
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
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> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more