pub struct ClientConfig {
pub base_url: String,
pub token: String,
pub dataset_id: Option<String>,
pub timeout: Duration,
}Expand description
Configuration for RESO client
Holds all configuration needed to connect to a RESO Web API server, including the base URL, authentication token, optional dataset ID, and HTTP timeout settings.
§Examples
// Create basic configuration
let config = ClientConfig::new(
"https://api.mls.com/odata",
"your-token"
);
// With dataset ID
let config = ClientConfig::new(
"https://api.mls.com/odata",
"your-token"
)
.with_dataset_id("actris_ref");
// With custom timeout
let config = ClientConfig::new(
"https://api.mls.com/odata",
"your-token"
)
.with_timeout(Duration::from_secs(60));Fields§
§base_url: StringBase URL of the RESO Web API server
token: StringOAuth bearer token
dataset_id: Option<String>Optional dataset ID (inserted between base_url and resource)
timeout: DurationHTTP timeout duration
Implementations§
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Create configuration from environment variables
Expects:
RESO_BASE_URL- Base URL of the RESO server (e.g.,https://api.mls.com/api/v2/OData)RESO_TOKEN- OAuth bearer tokenRESO_DATASET_ID(optional) - Dataset ID inserted in URL pathRESO_TIMEOUT(optional) - Timeout in seconds (default: 30)
§Examples
// Reads RESO_BASE_URL, RESO_TOKEN, and optional variables from environment
let config = ClientConfig::from_env()?;Sourcepub fn new(base_url: impl Into<String>, token: impl Into<String>) -> Self
pub fn new(base_url: impl Into<String>, token: impl Into<String>) -> Self
Create configuration manually
§Examples
let config = ClientConfig::new(
"https://api.mls.com/odata",
"your-bearer-token"
);Sourcepub fn with_dataset_id(self, dataset_id: impl Into<String>) -> Self
pub fn with_dataset_id(self, dataset_id: impl Into<String>) -> Self
Set dataset ID
Some RESO servers require a dataset identifier in the URL path.
When set, URLs will be formatted as: {base_url}/{dataset_id}/{resource}
§Examples
let config = ClientConfig::new("https://api.mls.com/odata", "token")
.with_dataset_id("actris_ref");Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set custom timeout
§Examples
let config = ClientConfig::new("https://api.mls.com/odata", "token")
.with_timeout(Duration::from_secs(60));Trait Implementations§
Source§impl Clone for ClientConfig
impl Clone for ClientConfig
Source§fn clone(&self) -> ClientConfig
fn clone(&self) -> ClientConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ClientConfig
impl RefUnwindSafe for ClientConfig
impl Send for ClientConfig
impl Sync for ClientConfig
impl Unpin for ClientConfig
impl UnwindSafe for ClientConfig
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