Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }

Implementations§

Source§

impl Client

Source

pub fn from_env() -> Self

Source

pub fn with_api_url(self, url: &str) -> Self

The same client, sending to another API root, such as a test’s fake server.

Source

pub fn with_token(self, token: &str) -> Self

The same client, using only token: no environment variable and no gh. For a test’s fake server.

Source

pub fn graphql( &mut self, query: &str, variables: &Value, ) -> Result<Value, String>

Runs a GraphQL query and returns its data. Paths GitHub reports as NOT_FOUND come back as null in the data; every other error fails the call.

Source

pub fn mutate( &mut self, query: &str, variables: &Value, ) -> Result<Value, String>

Runs a GraphQL mutation. Unlike a query it is not retried after a 5xx or a dropped connection, which can follow a write that succeeded.

Source

pub fn rest_get(&mut self, path: &str) -> Result<Option<Value>, String>

GETs a REST path such as /repos/OWNER/NAME/activity. A 404 comes back as None.

Source

pub fn get(&mut self, path: &str, etag: Option<&str>) -> Result<Rest, Failure>

GETs a REST path such as /repos/o/r/pulls/1, or a full URL, sending If-None-Match when etag is given. Statuses other than 401 are the caller’s to read, and an exhausted rate limit says when it resets, so a caller can wait it out.

Source

pub fn put(&mut self, path: &str, body: &Value) -> Result<Rest, Failure>

PUTs a JSON body to a REST path such as /repos/o/r/pulls/1/merge. A write is not retried after a 5xx or a dropped connection, which can follow one that succeeded. Statuses other than 401 are the caller’s to read.

Source

pub fn write( &mut self, method: Method, path: &str, body: &Value, ) -> Result<Rest, Failure>

Sends a JSON body to a REST path with a method that writes. Like Client::put, it is not retried after a 5xx or a dropped connection, and statuses other than 401 are the caller’s to read.

Trait Implementations§

Source§

impl Host for Client

Source§

fn files( &mut self, pr: &PrThreads, oid: &str, paths: &[String], ) -> Result<Vec<(String, String)>, String>

Reads every file in one GraphQL query.

Source§

fn forge(&self) -> Forge

Source§

fn lacks(&mut self, _feature: Feature) -> Option<String>

Why the forge cannot do feature, or None when it can.
Source§

fn fetch(&mut self, lookups: Vec<Lookup>) -> Result<FetchResult, String>

The PRs the lookups name, in the order named, as pr status reports them before attention codes are derived.
Source§

fn threads( &mut self, target: &Target, extra: bool, bots: &[String], ) -> Result<Option<PrThreads>, String>

A PR’s review threads, and with extra its reviews and conversation comments. None when there is no such PR.
Source§

fn pushed_at(&mut self, pr: &PrThreads, sha: &str) -> Result<Pushed, Lookup>

When sha (a prefix) was pushed to the PR.
Source§

fn merge_base(&mut self, pr: &PrThreads) -> Result<String, String>

The commit the PR’s diff is taken against.
Source§

fn on_branch(&mut self, pr: &PrThreads, head: &str) -> Result<bool, String>

Whether head is on the PR’s branch, for a head this clone cannot place.
Source§

fn reply( &mut self, _pr: &PrThreads, thread: &Thread, body: &str, ) -> Result<String, String>

Posts body as a reply in thread, returning the reply’s URL.
Source§

fn set_resolved( &mut self, _pr: &PrThreads, thread: &Thread, resolved: bool, ) -> Result<(), String>

Resolves or unresolves thread.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Client

§

impl !UnwindSafe for Client

§

impl Forget for Client

§

impl Freeze for Client

§

impl Move for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl UnsafeUnpin for Client

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, 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.