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<String>, 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<String>, 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(&mut self, retry_config: RetryConfig) -> &mut Self

source

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

Set the connect timeout.

source

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

Set the read timeout.

source

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

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 set_connector_retry_service<S>( &self, connector: Client<S, String> ) -> Retry<RetryConfig, Client<S, String>>

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

source

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

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>
where Svc: RefUnwindSafe, Auth: RefUnwindSafe, Config: RefUnwindSafe, LayerReady: RefUnwindSafe,

§

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

§

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

§

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>
where Svc: UnwindSafe, Auth: UnwindSafe, Config: UnwindSafe, LayerReady: UnwindSafe,

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