Struct StreamProtocol
pub struct StreamProtocol { /* private fields */ }
Expand description
Identifies a protocol for a stream.
libp2p nodes use stream protocols to negotiate what to do with a newly opened stream.
Stream protocols are string-based and must start with a forward slash: /
.
Implementations§
§impl StreamProtocol
impl StreamProtocol
pub const fn new(s: &'static str) -> StreamProtocol
pub const fn new(s: &'static str) -> StreamProtocol
Construct a new protocol from a static string slice.
§Panics
This function panics if the protocol does not start with a forward slash: /
.
pub fn try_from_owned(
protocol: String,
) -> Result<StreamProtocol, InvalidProtocol>
pub fn try_from_owned( protocol: String, ) -> Result<StreamProtocol, InvalidProtocol>
Attempt to construct a protocol from an owned string.
This function will fail if the protocol does not start with a forward slash: /
.
Where possible, you should use StreamProtocol::new
instead to avoid allocations.
Trait Implementations§
§impl AsRef<str> for StreamProtocol
impl AsRef<str> for StreamProtocol
§impl Clone for StreamProtocol
impl Clone for StreamProtocol
§fn clone(&self) -> StreamProtocol
fn clone(&self) -> StreamProtocol
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl Debug for StreamProtocol
impl Debug for StreamProtocol
§impl Display for StreamProtocol
impl Display for StreamProtocol
§impl Hash for StreamProtocol
impl Hash for StreamProtocol
§impl PartialEq<&str> for StreamProtocol
impl PartialEq<&str> for StreamProtocol
§impl PartialEq<StreamProtocol> for &str
impl PartialEq<StreamProtocol> for &str
§impl PartialEq for StreamProtocol
impl PartialEq for StreamProtocol
impl Eq for StreamProtocol
Auto Trait Implementations§
impl Freeze for StreamProtocol
impl RefUnwindSafe for StreamProtocol
impl Send for StreamProtocol
impl Sync for StreamProtocol
impl Unpin for StreamProtocol
impl UnwindSafe for StreamProtocol
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
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 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> ⓘ
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