pub struct ClientConfig {
pub tls: Option<TLSConfig>,
pub http: Option<HttpConfig>,
}
Expand description
Complete client configuration.
Fields§
§tls: Option<TLSConfig>
TLS configuration, used for both HTTP and WebSocket connections.
http: Option<HttpConfig>
HTTP configuration.
Implementations§
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn http_only(url: impl Into<String>) -> Self
pub fn http_only(url: impl Into<String>) -> Self
Create a new configuration with only HTTP support.
§Example
use sms_client::config::ClientConfig;
let config = ClientConfig::http_only("http://192.168.1.2:3000");
Sourcepub fn with_auth(self, token: impl Into<String>) -> Self
pub fn with_auth(self, token: impl Into<String>) -> Self
Set authorization for both HTTP and WebSocket. This only sets the authorization value for components that already exist.
§Example
use sms_client::config::ClientConfig;
let config = ClientConfig::both(
"http://192.168.1.2:3000",
"ws://192.168.1.2:3000/ws"
).with_auth("my-token");
Sourcepub fn with_certificate(
self,
certificate: impl Into<PathBuf>,
) -> ClientResult<Self>
pub fn with_certificate( self, certificate: impl Into<PathBuf>, ) -> ClientResult<Self>
Modify/Set a TLSConfig with certificate filepath.
§Example
use sms_client::config::ClientConfig;
let config = ClientConfig::http_only("https://192.168.1.2:3000")
.with_certificate("./certificate.crt")?;
Sourcepub fn configure_http<F>(self, f: F) -> Self
pub fn configure_http<F>(self, f: F) -> Self
Configure the HTTP component if present.
§Example
use sms_client::config::ClientConfig;
use std::time::Duration;
let config = ClientConfig::http_only("http://192.168.1.2:3000")
.configure_http(|http| {
http.with_base_timeout(Duration::from_secs(30))
.with_auth("token")
});
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 moreSource§impl Debug for ClientConfig
impl Debug for ClientConfig
Source§impl Default for ClientConfig
impl Default for ClientConfig
Source§impl From<HttpConfig> for ClientConfig
impl From<HttpConfig> for ClientConfig
Source§fn from(http: HttpConfig) -> Self
fn from(http: HttpConfig) -> Self
Converts to this type from the input type.
Auto 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