Struct SessionBuilder

Source
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, (), ()>

Source

pub fn new(config: &'a ClientConfig) -> Self

Create a new, empty session builder.

Source§

impl<'a, T> SessionBuilder<'a, T, ()>

Source

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>

Source

pub fn user_identity_token(self, identity_token: IdentityToken) -> Self

Set the user identity token to use.

Source

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.

Source

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>>

Source

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.

Source

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.

Source

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.

Source

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>

Source

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>

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'a, T, R> Freeze for SessionBuilder<'a, T, R>
where T: Freeze, R: Freeze,

§

impl<'a, T = (), R = ()> !RefUnwindSafe for SessionBuilder<'a, T, R>

§

impl<'a, T, R> Send for SessionBuilder<'a, T, R>
where T: Send, R: Send,

§

impl<'a, T, R> Sync for SessionBuilder<'a, T, R>
where T: Sync, R: Sync,

§

impl<'a, T, R> Unpin for SessionBuilder<'a, T, R>
where T: Unpin, R: Unpin,

§

impl<'a, T = (), R = ()> !UnwindSafe for SessionBuilder<'a, T, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T