pub struct RestApiBuilder { /* private fields */ }Expand description
A builder for creating configured Bitfinex REST API clients.
The RestApiBuilder provides a fluent interface for setting configuration options
before creating a RestApi instance. It handles URL parsing and HTTP client creation.
§Examples
use bothan_bitfinex::api::builder::RestApiBuilder;
// Create a builder with default URL
let api = RestApiBuilder::default()
.build()
.expect("Failed to build API client");
// Create a builder with custom URL
let api = RestApiBuilder::new("https://api-pub.bitfinex.com/v2/")
.build()
.expect("Failed to build API client");
// Use the fluent interface
let api = RestApiBuilder::default()
.with_url("https://api-pub.bitfinex.com/v2/")
.build()
.expect("Failed to build API client");Implementations§
Source§impl RestApiBuilder
impl RestApiBuilder
Sourcepub fn new<T: Into<String>>(url: T) -> Self
pub fn new<T: Into<String>>(url: T) -> Self
Creates a new RestApiBuilder with the specified URL.
§Parameters
url: The URL for the Bitfinex API as a string
§Returns
A new RestApiBuilder instance with the specified URL.
§Examples
use bothan_bitfinex::api::builder::RestApiBuilder;
let builder = RestApiBuilder::new("https://api-pub.bitfinex.com/v2/");Sourcepub fn with_url<T: Into<String>>(self, url: T) -> Self
pub fn with_url<T: Into<String>>(self, url: T) -> Self
Sets the URL for the Bitfinex API.
This method allows changing the URL after the builder has been created. It returns the builder instance for method chaining.
§Parameters
url: The new URL for the Bitfinex API
§Returns
The builder instance with the updated URL for method chaining.
§Examples
use bothan_bitfinex::api::builder::RestApiBuilder;
let builder = RestApiBuilder::default()
.with_url("https://api-pub.bitfinex.com/v2/");Sourcepub fn build(self) -> Result<RestApi, BuildError>
pub fn build(self) -> Result<RestApi, BuildError>
Builds a RestApi instance with the current configuration.
This method validates the URL, creates an HTTP client, and returns a configured
RestApi instance. If the URL is invalid or the HTTP client cannot be created,
an error is returned.
§Returns
Returns a Result containing a RestApi instance on success,
or a BuildError if the configuration is invalid.
§Errors
Returns a BuildError if:
- The URL is invalid and cannot be parsed (
InvalidURL) - The HTTP client cannot be created (
FailedToBuild)
§Examples
use bothan_bitfinex::api::builder::RestApiBuilder;
match RestApiBuilder::new("https://api-pub.bitfinex.com/v2/").build() {
Ok(api) => println!("API client created successfully"),
Err(e) => eprintln!("Failed to create API client: {}", e),
}Trait Implementations§
Source§impl Default for RestApiBuilder
impl Default for RestApiBuilder
Source§fn default() -> Self
fn default() -> Self
Creates a new RestApiBuilder with the default Bitfinex API URL.
This method initializes the builder with the default Bitfinex API URL, which can then be customized using the builder methods.
§Returns
A new RestApiBuilder instance with the default URL.
§Examples
use bothan_bitfinex::api::builder::RestApiBuilder;
let builder = RestApiBuilder::default();
let api = builder.build().expect("Failed to build API client");Auto Trait Implementations§
impl Freeze for RestApiBuilder
impl RefUnwindSafe for RestApiBuilder
impl Send for RestApiBuilder
impl Sync for RestApiBuilder
impl Unpin for RestApiBuilder
impl UnsafeUnpin for RestApiBuilder
impl UnwindSafe for RestApiBuilder
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request