Struct eventsource_client::ClientBuilder
source · pub struct ClientBuilder { /* private fields */ }
Expand description
ClientBuilder provides a series of builder methods to easily construct a Client
.
Implementations§
source§impl ClientBuilder
impl ClientBuilder
sourcepub fn for_url(url: &str) -> Result<ClientBuilder>
pub fn for_url(url: &str) -> Result<ClientBuilder>
Create a builder for a given URL.
sourcepub fn method(self, method: String) -> ClientBuilder
pub fn method(self, method: String) -> ClientBuilder
Set the request method used for the initial connection to the SSE endpoint.
sourcepub fn body(self, body: String) -> ClientBuilder
pub fn body(self, body: String) -> ClientBuilder
Set the request body used for the initial connection to the SSE endpoint.
sourcepub fn last_event_id(self, last_event_id: String) -> ClientBuilder
pub fn last_event_id(self, last_event_id: String) -> ClientBuilder
Set the last event id for a stream when it is created. If it is set, it will be sent to the server in case it can replay missed events.
sourcepub fn header(self, name: &str, value: &str) -> Result<ClientBuilder>
pub fn header(self, name: &str, value: &str) -> Result<ClientBuilder>
Set a HTTP header on the SSE request.
sourcepub fn connect_timeout(self, connect_timeout: Duration) -> ClientBuilder
pub fn connect_timeout(self, connect_timeout: Duration) -> ClientBuilder
Set a connect timeout for the underlying connection. There is no connect timeout by default.
sourcepub fn read_timeout(self, read_timeout: Duration) -> ClientBuilder
pub fn read_timeout(self, read_timeout: Duration) -> ClientBuilder
Set a read timeout for the underlying connection. There is no read timeout by default.
sourcepub fn reconnect(self, opts: ReconnectOptions) -> ClientBuilder
pub fn reconnect(self, opts: ReconnectOptions) -> ClientBuilder
Configure the client’s reconnect behaviour according to the supplied
ReconnectOptions
.
sourcepub fn redirect_limit(self, limit: u32) -> ClientBuilder
pub fn redirect_limit(self, limit: u32) -> ClientBuilder
Customize the client’s following behavior when served a redirect.
To disable following redirects, pass 0
.
By default, the limit is DEFAULT_REDIRECT_LIMIT
.
sourcepub fn build_with_conn<C>(self, conn: C) -> impl Client
pub fn build_with_conn<C>(self, conn: C) -> impl Client
Build with a specific client connector.
sourcepub fn build_http(self) -> impl Client
pub fn build_http(self) -> impl Client
Build with an HTTP client connector.
sourcepub fn build(self) -> impl Client
pub fn build(self) -> impl Client
Build with an HTTPS client connector, using the OS root certificate store.
sourcepub fn build_with_http_client<C>(self, http: Client<C>) -> impl Client
pub fn build_with_http_client<C>(self, http: Client<C>) -> impl Client
Build with the given hyper::client::Client
.