[−][src]Struct snarkos_network::message::channel::Channel
A Channel for reading and writing messages to a peer. Storing two streams allows for simultaneous reading/writing. Each stream is protected by an Arc + Mutex to allow for channel cloning.
Fields
address: SocketAddr
reader: Arc<Mutex<TcpStream>>
writer: Arc<Mutex<TcpStream>>
Implementations
impl Channel
[src]
pub async fn new(
address: SocketAddr,
reader: Arc<Mutex<TcpStream>>,
writer: Arc<Mutex<TcpStream>>
) -> Result<Self, ConnectError>
[src]
address: SocketAddr,
reader: Arc<Mutex<TcpStream>>,
writer: Arc<Mutex<TcpStream>>
) -> Result<Self, ConnectError>
pub async fn new_write_only(address: SocketAddr) -> Result<Self, ConnectError>
[src]
Returns a new channel with a writer only stream.
pub fn new_read_only(reader: TcpStream) -> Result<Self, ConnectError>
[src]
Returns a new channel with a reader only stream.
pub fn update_address(&self, address: SocketAddr) -> Self
[src]
Returns a new channel with the specified address.
pub fn update_reader(&self, reader: Arc<Mutex<TcpStream>>) -> Self
[src]
Returns a new channel with the specified reader stream.
pub async fn update_writer<'_>(
&'_ self,
address: SocketAddr
) -> Result<Self, ConnectError>
[src]
&'_ self,
address: SocketAddr
) -> Result<Self, ConnectError>
Returns a new channel with the specified address and new writer stream.
pub async fn write<M: Message, '_, '_>(
&'_ self,
message: &'_ M
) -> Result<(), ConnectError>
[src]
&'_ self,
message: &'_ M
) -> Result<(), ConnectError>
Writes a message header + message.
pub async fn read<'_>(&'_ self) -> Result<(MessageName, Vec<u8>), ConnectError>
[src]
Reads a message header + message.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Channel
impl Send for Channel
impl Sync for Channel
impl Unpin for Channel
impl !UnwindSafe for Channel
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,