pub struct UploadthingConfigBuilder { /* private fields */ }
Expand description

A builder for UploadthingConfig.

This builder allows for a fluent interface to construct a UploadthingConfig instance with custom values. It starts with default values and allows the user to set properties such as host, user agent, API key, and version before building the final configuration object.

Implementations§

source§

impl UploadthingConfigBuilder

source

pub fn new() -> Self

Creates a new UploadthingConfigBuilder with default configuration values.

This uses UploadthingConfig::default() to initialize the internal config with default values.

source

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

Sets the host URL in the configuration.

§Arguments
  • host - A string slice that holds the URL of the Uploadthing service.
§Examples
let builder = UploadthingConfigBuilder::new().host("https://example.com");
source

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

Sets the user agent in the configuration.

§Arguments
  • user_agent - A string slice that represents the user agent to be sent with each request.
§Examples
let builder = UploadthingConfigBuilder::new().user_agent("MyUploader/1.0");
source

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

Sets the API key in the configuration.

This method allows the user to provide an API key as a string slice that will be used for authenticating with the Uploadthing service. It attempts to parse the provided string into an ApiKey instance using the FromStr trait implementation for ApiKey. If parsing is successful, the ApiKey is wrapped in a Some and set in the configuration. If parsing fails, it falls back to the default ApiKey which is obtained from the environment variable UPLOADTHING_SECRET.

§Arguments
  • api_key - A string slice that represents the API key for authenticating with the service.
§Examples
let builder = UploadthingConfigBuilder::new().api_key("your_api_key");
§Panics

This method will panic if the provided api_key string is not in a valid format and there is no UPLOADTHING_SECRET environment variable set to fall back on.

source

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

Sets the version in the configuration.

§Arguments
  • version - A string slice that represents the version of the client application.
§Examples
let builder = UploadthingConfigBuilder::new().version("2.0.0");
source

pub fn build(self) -> UploadthingConfig

Builds the UploadthingConfig with the current settings of the builder.

Consumes the builder and returns the configured UploadthingConfig instance.

§Examples
let config = UploadthingConfigBuilder::new()
    .host("https://example.com")
    .user_agent("MyUploader/1.0")
    .api_key("your_api_key")
    .version("2.0.0")
    .build();

Trait Implementations§

source§

impl Default for UploadthingConfigBuilder

Implements the Default trait for UploadthingConfigBuilder.

This allows for the creation of a builder with the default configuration by calling UploadthingConfigBuilder::default().

source§

fn default() -> Self

Returns a new UploadthingConfigBuilder initialized with default values.

Auto Trait Implementations§

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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

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