[][src]Struct networking::BitcoinCodec

pub struct BitcoinCodec { /* fields omitted */ }

A Codec converting a raw TcpStream into a Sink + Stream of Bitcoin Wire Protocol Messages.

This struct handles the serialization and sending of Messages. Callers simply construct a Framed instance containing the codec and the TcpStream.

// Note: This example does not compile outside the context of an async runtime.
let connection = tokio::net::TcpStream::connect("127.0.0.1:8333".into()).await?;
let codec = networking::BitcoinCodec::new(0);
let connection = Framed::new(connection, codec);

// Create and send a message.
let msg = Message::Verack{};
connection.send(msg).await?;
// Await the response.
let response: Message  = connection.next().await?;

Implementations

impl Codec[src]

pub fn new(magic: u32) -> Codec[src]

Trait Implementations

impl Debug for Codec[src]

impl Decoder for Codec[src]

type Error = DeserializationError

The type of unrecoverable frame decoding errors. Read more

type Item = Message

The type of decoded frames.

impl Encoder<Message> for Codec[src]

type Error = Error

The type of encoding errors. Read more

Auto Trait Implementations

impl RefUnwindSafe for Codec

impl Send for Codec

impl Sync for Codec

impl Unpin for Codec

impl UnwindSafe for Codec

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.