pub struct SessionBuilder<'a, T = (), R = ()> { /* private fields */ }
Expand description
Type-state builder for a session and session event loop.
To use, you will typically first call SessionBuilder::with_endpoints to set
a list of available endpoints, then one of the connect_to
methods, then finally
SessionBuilder::build.
Implementations§
Source§impl<'a> SessionBuilder<'a, (), ()>
impl<'a> SessionBuilder<'a, (), ()>
Sourcepub fn new(config: &'a ClientConfig) -> Self
pub fn new(config: &'a ClientConfig) -> Self
Create a new, empty session builder.
Source§impl<'a, T> SessionBuilder<'a, T, ()>
impl<'a, T> SessionBuilder<'a, T, ()>
Sourcepub fn with_endpoints(
self,
endpoints: Vec<EndpointDescription>,
) -> SessionBuilder<'a, T, Vec<EndpointDescription>>
pub fn with_endpoints( self, endpoints: Vec<EndpointDescription>, ) -> SessionBuilder<'a, T, Vec<EndpointDescription>>
Set a list of available endpoints on the server.
You’ll typically get this from Client::get_server_endpoints.
Source§impl<T, R> SessionBuilder<'_, T, R>
impl<T, R> SessionBuilder<'_, T, R>
Sourcepub fn user_identity_token(self, identity_token: IdentityToken) -> Self
pub fn user_identity_token(self, identity_token: IdentityToken) -> Self
Set the user identity token to use.
Sourcepub fn session_id(self, session_id: NodeId) -> Self
pub fn session_id(self, session_id: NodeId) -> Self
Set an initial session ID. The session will try to reactivate this session before creating a new session. This can be useful to persist session IDs between program executions, to avoid having to recreate subscriptions.
Sourcepub fn type_loader(self, type_loader: Arc<dyn TypeLoader>) -> Self
pub fn type_loader(self, type_loader: Arc<dyn TypeLoader>) -> Self
Add an initial type loader to the session. You can add more of these later. Note that custom type loaders will likely not work until namespaces are fetched from the server.
Source§impl<'a> SessionBuilder<'a, (), Vec<EndpointDescription>>
impl<'a> SessionBuilder<'a, (), Vec<EndpointDescription>>
Sourcepub fn connect_to_matching_endpoint(
self,
endpoint: impl Into<EndpointDescription>,
) -> Result<SessionBuilder<'a, EndpointDescription, Vec<EndpointDescription>>, StatusCode>
pub fn connect_to_matching_endpoint( self, endpoint: impl Into<EndpointDescription>, ) -> Result<SessionBuilder<'a, EndpointDescription, Vec<EndpointDescription>>, StatusCode>
Connect to an endpoint matching the given endpoint description.
Sourcepub fn connect_to_default_endpoint(
self,
) -> Result<SessionBuilder<'a, EndpointDescription, Vec<EndpointDescription>>, String>
pub fn connect_to_default_endpoint( self, ) -> Result<SessionBuilder<'a, EndpointDescription, Vec<EndpointDescription>>, String>
Connect to the configured default endpoint, this will use the user identity token configured in the default endpoint.
Sourcepub fn connect_to_endpoint_id(
self,
endpoint_id: impl Into<String>,
) -> Result<SessionBuilder<'a, EndpointDescription, Vec<EndpointDescription>>, String>
pub fn connect_to_endpoint_id( self, endpoint_id: impl Into<String>, ) -> Result<SessionBuilder<'a, EndpointDescription, Vec<EndpointDescription>>, String>
Connect to the configured endpoint with the given id, this will use the user identity token configured in the configured endpoint.
Sourcepub fn connect_to_best_endpoint(
self,
secure: bool,
) -> Result<SessionBuilder<'a, EndpointDescription, Vec<EndpointDescription>>, String>
pub fn connect_to_best_endpoint( self, secure: bool, ) -> Result<SessionBuilder<'a, EndpointDescription, Vec<EndpointDescription>>, String>
Attempt to pick the “best” endpoint. If secure
is false
this means
any unencrypted endpoint that supports the configured identity token.
If secure
is true
, the endpoint that supports the configured identity token with the highest
securityLevel
.
Source§impl<'a, R> SessionBuilder<'a, (), R>
impl<'a, R> SessionBuilder<'a, (), R>
Sourcepub fn connect_to_endpoint_directly(
self,
endpoint: impl Into<EndpointDescription>,
) -> Result<SessionBuilder<'a, EndpointDescription, R>, String>
pub fn connect_to_endpoint_directly( self, endpoint: impl Into<EndpointDescription>, ) -> Result<SessionBuilder<'a, EndpointDescription, R>, String>
Connect directly to an endpoint description, this does not require you to list endpoints on the server first.
Source§impl<R> SessionBuilder<'_, EndpointDescription, R>
impl<R> SessionBuilder<'_, EndpointDescription, R>
Sourcepub fn build(
self,
certificate_store: Arc<RwLock<CertificateStore>>,
) -> (Arc<Session>, SessionEventLoop)
pub fn build( self, certificate_store: Arc<RwLock<CertificateStore>>, ) -> (Arc<Session>, SessionEventLoop)
Build the session and session event loop. Note that you will need to start polling the event loop before a connection is actually established.
Sourcepub fn build_channel(
self,
certificate_store: Arc<RwLock<CertificateStore>>,
) -> AsyncSecureChannel
pub fn build_channel( self, certificate_store: Arc<RwLock<CertificateStore>>, ) -> AsyncSecureChannel
Build a channel only, not creating a session. This is useful if you want to manage the session lifetime yourself.