octocrab

Struct OctocrabBuilder

Source
pub struct OctocrabBuilder<Svc, Config, Auth, LayerReady> { /* private fields */ }
Expand description

A builder struct for Octocrab, allowing you to configure the client, such as using GitHub previews, the github instance, authentication, etc.

let octocrab = octocrab::OctocrabBuilder::default()
    .add_preview("machine-man")
    .base_uri("https://github.example.com")?
    .build()?;

A builder struct for Octocrab. OctocrabBuilder can be extended with a custom config, see DefaultOctocrabBuilderConfig for an example

Implementations§

Source§

impl OctocrabBuilder<NoSvc, NoConfig, NoAuth, NotLayerReady>

Source

pub fn new_empty() -> Self

Source§

impl OctocrabBuilder<NoSvc, DefaultOctocrabBuilderConfig, NoAuth, NotLayerReady>

Source

pub fn new() -> Self

Source§

impl<Config, Auth> OctocrabBuilder<NoSvc, Config, Auth, NotLayerReady>

Source

pub fn with_service<Svc>( self, service: Svc, ) -> OctocrabBuilder<Svc, Config, Auth, LayerReady>

Source§

impl<Svc, Config, Auth, B> OctocrabBuilder<Svc, Config, Auth, LayerReady>
where Svc: Service<Request<OctoBody>, Response = Response<B>> + Send + 'static, Svc::Future: Send + 'static, Svc::Error: Into<BoxError>, B: Body<Data = Bytes> + Send + 'static, B::Error: Into<BoxError>,

Source

pub fn with_executor( self, executor: Box<dyn Fn(Pin<Box<dyn Future<Output = ()>>>)>, ) -> OctocrabBuilder<Svc, Config, Auth, LayerReady>

Source§

impl<Svc, Config, Auth, B> OctocrabBuilder<Svc, Config, Auth, LayerReady>
where Svc: Service<Request<OctoBody>, Response = Response<B>> + Send + 'static, Svc::Future: Send + 'static, Svc::Error: Into<BoxError>, B: Body<Data = Bytes> + Send + 'static, B::Error: Into<BoxError>,

Source

pub fn with_layer<L: Layer<Svc>>( self, layer: &L, ) -> OctocrabBuilder<L::Service, Config, Auth, LayerReady>

Add a Layer to the current Service stack.

Source§

impl<Svc, B, LayerState> OctocrabBuilder<Svc, NoConfig, AuthState, LayerState>
where Svc: Service<Request<OctoBody>, Response = Response<B>> + Send + 'static, Svc::Future: Send + 'static, Svc::Error: Into<BoxError>, B: Body<Data = Bytes> + Send + Sync + 'static, B::Error: Into<BoxError>,

Source

pub fn build(self) -> Result<Octocrab, Infallible>

Build a [Client] instance with the current Service stack.

Source§

impl<Svc, Config, LayerState> OctocrabBuilder<Svc, Config, NoAuth, LayerState>

Source

pub fn with_auth<Auth>( self, auth: Auth, ) -> OctocrabBuilder<Svc, Config, Auth, LayerState>

Source§

impl OctocrabBuilder<NoSvc, DefaultOctocrabBuilderConfig, NoAuth, NotLayerReady>

Source

pub fn add_retry_config(self, retry_config: RetryConfig) -> Self

Available on crate feature retry only.

Set the retry configuration

Source

pub fn set_connect_timeout(self, timeout: Option<Duration>) -> Self

Available on crate feature timeout only.

Set the connect timeout.

Source

pub fn set_read_timeout(self, timeout: Option<Duration>) -> Self

Available on crate feature timeout only.

Set the read timeout.

Source

pub fn set_write_timeout(self, timeout: Option<Duration>) -> Self

Available on crate feature timeout only.

Set the write timeout.

Source

pub fn add_preview(self, preview: &'static str) -> Self

Enable a GitHub preview.

Source

pub fn add_header(self, key: HeaderName, value: String) -> Self

Add an additional header to include with every request.

Source

pub fn personal_token<S: Into<SecretString>>(self, token: S) -> Self

Add a personal token to use for authentication.

Source

pub fn app(self, app_id: AppId, key: EncodingKey) -> Self

Authenticate as a Github App. key: RSA private key in DER or PEM formats.

Source

pub fn basic_auth(self, username: String, password: String) -> Self

Authenticate as a Basic Auth username and password

Source

pub fn oauth(self, oauth: OAuth) -> Self

Authenticate with an OAuth token.

Source

pub fn user_access_token<S: Into<SecretString>>(self, token: S) -> Self

Authenticate with a user access token.

Source

pub fn base_uri(self, base_uri: impl TryInto<Uri>) -> Result<Self>

Set the base url for Octocrab.

Source

pub fn upload_uri(self, upload_uri: impl TryInto<Uri>) -> Result<Self>

Set the base upload url for Octocrab.

Source

pub fn set_connector_retry_service<S>( &self, connector: Client<S, OctoBody>, ) -> Retry<RetryConfig, Client<S, OctoBody>>

Available on crate feature retry only.
Source

pub fn set_connect_timeout_service<T>( &self, connector: T, ) -> TimeoutConnector<T>
where T: Service<Uri> + Send, T::Response: Read + Write + Send + Unpin, T::Future: Send + 'static, T::Error: Into<BoxError>,

Available on crate feature timeout only.
Source

pub fn build(self) -> Result<Octocrab>

Available on crate feature default-client only.

Build a [Client] instance with the current Service stack.

Trait Implementations§

Auto Trait Implementations§

§

impl<Svc, Config, Auth, LayerReady> Freeze for OctocrabBuilder<Svc, Config, Auth, LayerReady>
where Svc: Freeze, Auth: Freeze, Config: Freeze,

§

impl<Svc, Config, Auth, LayerReady> !RefUnwindSafe for OctocrabBuilder<Svc, Config, Auth, LayerReady>

§

impl<Svc, Config, Auth, LayerReady> !Send for OctocrabBuilder<Svc, Config, Auth, LayerReady>

§

impl<Svc, Config, Auth, LayerReady> !Sync for OctocrabBuilder<Svc, Config, Auth, LayerReady>

§

impl<Svc, Config, Auth, LayerReady> Unpin for OctocrabBuilder<Svc, Config, Auth, LayerReady>
where Svc: Unpin, Auth: Unpin, Config: Unpin, LayerReady: Unpin,

§

impl<Svc, Config, Auth, LayerReady> !UnwindSafe for OctocrabBuilder<Svc, Config, Auth, LayerReady>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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>,

Source§

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>,

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.
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
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T