Skip to main content

LocalUri

Struct LocalUri 

Source
pub struct LocalUri<T> { /* private fields */ }
Expand description

URI in format local://room_id/member_id/endpoint_id.

This kind of URI used for pointing to some element in spec (Room, Member, WebRtcPlayEndpoint, WebRtcPublishEndpoint, etc) based on state.

LocalUri can be in three states: ToRoom, ToMember, ToRoom. This is used for compile time guarantees that some LocalUri have all mandatory fields.

You also can take value from LocalUri without clone, but you have to do it consistently. For example, if you wish to get RoomId, MemberId and Endpoint ID from LocalUri in ToEndpoint state you should make this steps:

let orig_room_id = RoomId::from("room");
let orig_member_id = MemberId::from("member");
let orig_endpoint_id = EndpointId::from("endpoint");

// Create new LocalUri for endpoint.
let local_uri = LocalUri::<ToEndpoint>::new(
    orig_room_id.clone(),
    orig_member_id.clone(),
    orig_endpoint_id.clone()
);
let local_uri_clone = local_uri.clone();

// We can get reference to room_id from this LocalUri
// without taking ownership:
assert_eq!(local_uri.room_id(), &orig_room_id);

// If you want to take all IDs ownership, you should do this steps:
let (endpoint_id, member_uri) = local_uri.take_endpoint_id();
assert_eq!(endpoint_id, orig_endpoint_id);

let (member_id, room_uri) = member_uri.take_member_id();
assert_eq!(member_id, orig_member_id);

let room_id = room_uri.take_room_id();
assert_eq!(room_id, orig_room_id);

// Or simply
let (room_id, member_id, endpoint_id) = local_uri_clone.take_all();

This is necessary so that it is not possible to get the address in the wrong state (local://room_id//endpoint_id for example).

Implementations§

Source§

impl LocalUri<ToRoom>

Source

pub fn new(room_id: RoomId) -> Self

Create new reference in ToRoom state.

Source

pub fn room_id(&self) -> &RoomId

Returns borrowed RoomId.

Source

pub fn take_room_id(self) -> RoomId

Returns RoomId.

Source

pub fn push_member_id(self, member_id: MemberId) -> LocalUri<ToMember>

Pushes MemberId to the end of URI and returns reference in ToMember state.

Source§

impl LocalUri<ToMember>

Source

pub fn new(room_id: RoomId, member_id: MemberId) -> Self

Create new reference in ToMember state.

Source

pub fn room_id(&self) -> &RoomId

Returns borrowed RoomId.

Source

pub fn member_id(&self) -> &MemberId

Returns borrowed MemberId.

Source

pub fn take_member_id(self) -> (MemberId, LocalUri<ToRoom>)

Return MemberId and reference in state ToRoom.

Source

pub fn push_endpoint_id(self, endpoint_id: EndpointId) -> LocalUri<ToEndpoint>

Push endpoint ID to the end of URI and returns reference in ToEndpoint state.

Source

pub fn take_all(self) -> (RoomId, MemberId)

Returns RoomId and MemberId.

Source§

impl LocalUri<ToEndpoint>

Source

pub fn new( room_id: RoomId, member_id: MemberId, endpoint_id: EndpointId, ) -> Self

Creates new reference in ToEndpoint state.

Source

pub fn room_id(&self) -> &RoomId

Returns borrowed RoomId.

Source

pub fn member_id(&self) -> &MemberId

Returns borrowed MemberId.

Source

pub fn endpoint_id(&self) -> &EndpointId

Returns borrowed EndpointId.

Source

pub fn take_endpoint_id(self) -> (EndpointId, LocalUri<ToMember>)

Returns Endpoint id and reference in ToMember state.

Source

pub fn take_all(self) -> (RoomId, MemberId, EndpointId)

Returns EndpointId, RoomId and MemberId.

Trait Implementations§

Source§

impl<T: Clone> Clone for LocalUri<T>

Source§

fn clone(&self) -> LocalUri<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for LocalUri<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for LocalUri<ToRoom>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for LocalUri<ToMember>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for LocalUri<ToEndpoint>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Eq> Eq for LocalUri<T>

Source§

impl From<LocalUri<ToEndpoint>> for StatefulLocalUri

Source§

fn from(original: LocalUri<ToEndpoint>) -> StatefulLocalUri

Converts to this type from the input type.
Source§

impl From<LocalUri<ToEndpoint>> for SrcUri

Source§

fn from(uri: LocalUri<ToEndpoint>) -> Self

Converts to this type from the input type.
Source§

impl From<LocalUri<ToMember>> for StatefulLocalUri

Source§

fn from(original: LocalUri<ToMember>) -> StatefulLocalUri

Converts to this type from the input type.
Source§

impl From<LocalUri<ToRoom>> for StatefulLocalUri

Source§

fn from(original: LocalUri<ToRoom>) -> StatefulLocalUri

Converts to this type from the input type.
Source§

impl From<SrcUri> for LocalUri<ToEndpoint>

Source§

fn from(uri: SrcUri) -> Self

Converts to this type from the input type.
Source§

impl From<StatefulLocalUri> for LocalUri<ToRoom>

Source§

fn from(from: StatefulLocalUri) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash> Hash for LocalUri<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: PartialEq> PartialEq for LocalUri<T>

Source§

fn eq(&self, other: &LocalUri<T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T: PartialEq> StructuralPartialEq for LocalUri<T>

Auto Trait Implementations§

§

impl<T> Freeze for LocalUri<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for LocalUri<T>
where T: RefUnwindSafe,

§

impl<T> Send for LocalUri<T>
where T: Send,

§

impl<T> Sync for LocalUri<T>
where T: Sync,

§

impl<T> Unpin for LocalUri<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for LocalUri<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for LocalUri<T>
where T: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SendSyncUnwindSafe for T
where T: Send + Sync + UnwindSafe + ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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> 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