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<Config, Auth> OctocrabBuilder<NoSvc, Config, Auth, NotLayerReady>
impl<Config, Auth> OctocrabBuilder<NoSvc, Config, Auth, NotLayerReady>
pub fn with_service<Svc>( self, service: Svc, ) -> OctocrabBuilder<Svc, Config, Auth, LayerReady>
Source§impl<Svc, Config, Auth, B> OctocrabBuilder<Svc, Config, Auth, LayerReady>
impl<Svc, Config, Auth, B> OctocrabBuilder<Svc, Config, Auth, LayerReady>
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>
impl<Svc, Config, Auth, B> OctocrabBuilder<Svc, Config, Auth, LayerReady>
Sourcepub fn with_layer<L: Layer<Svc>>(
self,
layer: &L,
) -> OctocrabBuilder<L::Service, Config, Auth, LayerReady>
pub fn with_layer<L: Layer<Svc>>( self, layer: &L, ) -> OctocrabBuilder<L::Service, Config, Auth, LayerReady>
Source§impl<Svc, B, LayerState> OctocrabBuilder<Svc, NoConfig, AuthState, LayerState>
impl<Svc, B, LayerState> OctocrabBuilder<Svc, NoConfig, AuthState, LayerState>
Source§impl<Svc, Config, LayerState> OctocrabBuilder<Svc, Config, NoAuth, LayerState>
impl<Svc, Config, LayerState> OctocrabBuilder<Svc, Config, NoAuth, LayerState>
pub fn with_auth<Auth>( self, auth: Auth, ) -> OctocrabBuilder<Svc, Config, Auth, LayerState>
Source§impl OctocrabBuilder<NoSvc, DefaultOctocrabBuilderConfig, NoAuth, NotLayerReady>
impl OctocrabBuilder<NoSvc, DefaultOctocrabBuilderConfig, NoAuth, NotLayerReady>
Sourcepub fn add_retry_config(self, retry_config: RetryConfig) -> Self
Available on crate feature retry
only.
pub fn add_retry_config(self, retry_config: RetryConfig) -> Self
retry
only.Set the retry configuration
Sourcepub fn set_connect_timeout(self, timeout: Option<Duration>) -> Self
Available on crate feature timeout
only.
pub fn set_connect_timeout(self, timeout: Option<Duration>) -> Self
timeout
only.Set the connect timeout.
Sourcepub fn set_read_timeout(self, timeout: Option<Duration>) -> Self
Available on crate feature timeout
only.
pub fn set_read_timeout(self, timeout: Option<Duration>) -> Self
timeout
only.Set the read timeout.
Sourcepub fn set_write_timeout(self, timeout: Option<Duration>) -> Self
Available on crate feature timeout
only.
pub fn set_write_timeout(self, timeout: Option<Duration>) -> Self
timeout
only.Set the write timeout.
Sourcepub fn add_preview(self, preview: &'static str) -> Self
pub fn add_preview(self, preview: &'static str) -> Self
Enable a GitHub preview.
Sourcepub fn add_header(self, key: HeaderName, value: String) -> Self
pub fn add_header(self, key: HeaderName, value: String) -> Self
Add an additional header to include with every request.
Sourcepub fn personal_token<S: Into<SecretString>>(self, token: S) -> Self
pub fn personal_token<S: Into<SecretString>>(self, token: S) -> Self
Add a personal token to use for authentication.
Sourcepub fn app(self, app_id: AppId, key: EncodingKey) -> Self
pub fn app(self, app_id: AppId, key: EncodingKey) -> Self
Authenticate as a Github App.
key
: RSA private key in DER or PEM formats.
Sourcepub fn basic_auth(self, username: String, password: String) -> Self
pub fn basic_auth(self, username: String, password: String) -> Self
Authenticate as a Basic Auth username and password
Sourcepub fn user_access_token<S: Into<SecretString>>(self, token: S) -> Self
pub fn user_access_token<S: Into<SecretString>>(self, token: S) -> Self
Authenticate with a user access token.
Sourcepub fn base_uri(self, base_uri: impl TryInto<Uri>) -> Result<Self>
pub fn base_uri(self, base_uri: impl TryInto<Uri>) -> Result<Self>
Set the base url for Octocrab
.
Sourcepub fn upload_uri(self, upload_uri: impl TryInto<Uri>) -> Result<Self>
pub fn upload_uri(self, upload_uri: impl TryInto<Uri>) -> Result<Self>
Set the base upload url for Octocrab
.
pub fn set_connector_retry_service<S>( &self, connector: Client<S, OctoBody>, ) -> Retry<RetryConfig, Client<S, OctoBody>>
Available on crate feature
retry
only.pub fn set_connect_timeout_service<T>( &self, connector: T, ) -> TimeoutConnector<T>
Available on crate feature
timeout
only.Trait Implementations§
Source§impl Default for OctocrabBuilder<NoSvc, DefaultOctocrabBuilderConfig, NoAuth, NotLayerReady>
impl Default for OctocrabBuilder<NoSvc, DefaultOctocrabBuilderConfig, NoAuth, NotLayerReady>
Source§fn default() -> OctocrabBuilder<NoSvc, DefaultOctocrabBuilderConfig, NoAuth, NotLayerReady>
fn default() -> OctocrabBuilder<NoSvc, DefaultOctocrabBuilderConfig, NoAuth, NotLayerReady>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<Svc, Config, Auth, LayerReady> Freeze for OctocrabBuilder<Svc, Config, Auth, LayerReady>
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>
impl<Svc, Config, Auth, LayerReady> !UnwindSafe for OctocrabBuilder<Svc, Config, Auth, LayerReady>
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
Mutably borrows from an owned value. Read more
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>
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 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>
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