pub struct GistsHandler<'octo> { /* private fields */ }
Expand description

Handler for GitHub’s gist API.

Created with Octocrab::gists.

Implementations§

source§

impl<'octo> GistsHandler<'octo>

source

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
  1. 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?;
source

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?;
source

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?;
source

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?;
source

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?;
source

pub async fn get(&self, id: impl AsRef<str>) -> Result<Gist>

Get a single gist.

let gist = octocrab::instance().gists().get("00000000000000000000000000000000").await?;
source

pub async fn delete(&self, gist_id: impl AsRef<str>) -> Result<()>

Delete a single gist.

octocrab::instance().gists().delete("00000000000000000000000000000000").await?;
source

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?;
source

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?;
source

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?;
source

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?;
source

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?;
source

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?;
source

pub async fn fork(&self, gist_id: impl AsRef<str>) -> Result<Gist>

Create a fork of the given gist_id associated with the authenticated user’s account. See GitHub API docs for more information about request parameters and response schema.

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> PolicyExt for T
where T: ?Sized,

source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more