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<ToMember>
impl LocalUri<ToMember>
Sourcepub fn new(room_id: RoomId, member_id: MemberId) -> Self
pub fn new(room_id: RoomId, member_id: MemberId) -> Self
Create new reference in ToMember state.
Sourcepub fn take_member_id(self) -> (MemberId, LocalUri<ToRoom>)
pub fn take_member_id(self) -> (MemberId, LocalUri<ToRoom>)
Sourcepub fn push_endpoint_id(self, endpoint_id: EndpointId) -> LocalUri<ToEndpoint>
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§impl LocalUri<ToEndpoint>
impl LocalUri<ToEndpoint>
Sourcepub fn new(
room_id: RoomId,
member_id: MemberId,
endpoint_id: EndpointId,
) -> Self
pub fn new( room_id: RoomId, member_id: MemberId, endpoint_id: EndpointId, ) -> Self
Creates new reference in ToEndpoint state.
Sourcepub fn endpoint_id(&self) -> &EndpointId
pub fn endpoint_id(&self) -> &EndpointId
Returns borrowed EndpointId.
Sourcepub fn take_endpoint_id(self) -> (EndpointId, LocalUri<ToMember>)
pub fn take_endpoint_id(self) -> (EndpointId, LocalUri<ToMember>)
Sourcepub fn take_all(self) -> (RoomId, MemberId, EndpointId)
pub fn take_all(self) -> (RoomId, MemberId, EndpointId)
Returns EndpointId, RoomId and MemberId.
Trait Implementations§
Source§impl Display for LocalUri<ToEndpoint>
impl Display for LocalUri<ToEndpoint>
impl<T: Eq> Eq for LocalUri<T>
Source§impl From<LocalUri<ToEndpoint>> for StatefulLocalUri
impl From<LocalUri<ToEndpoint>> for StatefulLocalUri
Source§fn from(original: LocalUri<ToEndpoint>) -> StatefulLocalUri
fn from(original: LocalUri<ToEndpoint>) -> StatefulLocalUri
Source§impl From<LocalUri<ToEndpoint>> for SrcUri
impl From<LocalUri<ToEndpoint>> for SrcUri
Source§fn from(uri: LocalUri<ToEndpoint>) -> Self
fn from(uri: LocalUri<ToEndpoint>) -> Self
Source§impl From<StatefulLocalUri> for LocalUri<ToRoom>
impl From<StatefulLocalUri> for LocalUri<ToRoom>
Source§fn from(from: StatefulLocalUri) -> Self
fn from(from: StatefulLocalUri) -> Self
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> 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request