Struct libp2p_swarm::StreamProtocol
source · 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§
source§impl StreamProtocol
impl StreamProtocol
sourcepub const fn new(s: &'static str) -> Self
pub const fn new(s: &'static str) -> Self
Construct a new protocol from a static string slice.
Panics
This function panics if the protocol does not start with a forward slash: /
.
sourcepub fn try_from_owned(protocol: String) -> Result<Self, InvalidProtocol>
pub fn try_from_owned(protocol: String) -> Result<Self, 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§
source§impl AsRef<str> for StreamProtocol
impl AsRef<str> for StreamProtocol
source§impl Clone for StreamProtocol
impl Clone for StreamProtocol
source§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 moresource§impl Debug for StreamProtocol
impl Debug for StreamProtocol
source§impl Display for StreamProtocol
impl Display for StreamProtocol
source§impl Hash for StreamProtocol
impl Hash for StreamProtocol
source§impl PartialEq<&str> for StreamProtocol
impl PartialEq<&str> for StreamProtocol
source§impl PartialEq<StreamProtocol> for &str
impl PartialEq<StreamProtocol> for &str
source§fn eq(&self, other: &StreamProtocol) -> bool
fn eq(&self, other: &StreamProtocol) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialEq for StreamProtocol
impl PartialEq for StreamProtocol
impl Eq for StreamProtocol
impl StructuralEq for StreamProtocol
Auto Trait Implementations§
impl RefUnwindSafe for StreamProtocol
impl Send for StreamProtocol
impl Sync for StreamProtocol
impl Unpin for StreamProtocol
impl UnwindSafe for StreamProtocol
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
Mutably borrows from an owned value. Read more