fn send_request(&mut self, message: NetlinkMessage) -> AsyncSink<NetlinkMessage> {
        if !self.requests_buffer.is_empty() {
            trace!("there are already requests waiting for being sent");
            return AsyncSink::NotReady(message);
        }

        // FIXME: in futures 0.2, use poll_ready before reading from pending_responses, and
        // don't panic here.
        trace!("sending message: {:?}", message);
        match self.socket.start_send((message, *KERNEL_PORT)).unwrap() {
            AsyncSink::NotReady((message, _)) => {
                // The sink is full atm. There is no need to try to call poll_send() because
                // internally start_send should call it:
                //
                //     https://docs.rs/tokio/0.1.7/tokio/prelude/trait.Sink.html#tymethod.start_send
                //
                //     The method returns AsyncSink::NotReady if the sink was unable to begin
                //     sending, usually due to being full. The sink must have attempted to complete
                //     processing any outstanding requests (equivalent to poll_complete) before
                //     yielding this result.
                trace!("the sink is full, cannot send the message now");
                AsyncSink::NotReady(message)
            }
            AsyncSink::Ready => {
                // NetlinkFramed can only buffer one frame, so to avoid clogging the sink, we need
                // to flush it as soon as we call start_send(). We don't care about the result
                // however.
                let _ = self.socket.poll_complete().unwrap();
                // Return Ready, because the message is being sent
                AsyncSink::Ready
            }
        }
    }
// FIXME: this should probably return an error when the sink is full and we don't have any more
// space to buffer the message
this should probably return an error when the sink is full and we don't have any more
space to buffer the message
this should probably return an error when the sink is full and we don ' t have any more space to buffer the message
fn send_request(&mut self, message: NetlinkMessage) -> AsyncSink<NetlinkMessage> {
        if !self.requests_buffer.is_empty() {
            trace!("there are already requests waiting for being sent");
            return AsyncSink::NotReady(message);
        }
        // FIXME: in futures 0.2, use poll_ready before reading from pending_responses, and
        // don't panic here.
        trace!("sending message: {:?}", message);
        match self.socket.start_send((message, *KERNEL_PORT)).unwrap() {
            AsyncSink::NotReady((message, _)) => {
                // The sink is full atm. There is no need to try to call poll_send() because
                // internally start_send should call it:
                //
                //     https://docs.rs/tokio/0.1.7/tokio/prelude/trait.Sink.html#tymethod.start_send
                //
                //     The method returns AsyncSink::NotReady if the sink was unable to begin
                //     sending, usually due to being full. The sink must have attempted to complete
                //     processing any outstanding requests (equivalent to poll_complete) before
                //     yielding this result.
                trace!("the sink is full, cannot send the message now");
                AsyncSink::NotReady(message)
            }
            AsyncSink::Ready => {
                // NetlinkFramed can only buffer one frame, so to avoid clogging the sink, we need
                // to flush it as soon as we call start_send(). We don't care about the result
                // however.
                let _ = self.socket.poll_complete().unwrap();
                // Return Ready, because the message is being sent
                AsyncSink::Ready
            }
        }
    }
fn send_request ( & mut self , message : NetlinkMessage ) -> AsyncSink < NetlinkMessage > { if ! self . requests_buffer . is_empty ( ) { trace ! ( " " ) ; return AsyncSink :: NotReady ( message ) ; } // FIXME: in futures 0.2, use poll_ready before reading from pending_responses, and // don't panic here. trace ! ( " " message ) ; match self . socket . start_send ( ( message , * KERNEL_PORT ) ) . unwrap ( ) { AsyncSink :: NotReady ( ( message , _ ) ) => { // The sink is full atm. There is no need to try to call poll_send() because // internally start_send should call it: // //     https://docs.rs/tokio/0.1.7/tokio/prelude/trait.Sink.html#tymethod.start_send // //     The method returns AsyncSink::NotReady if the sink was unable to begin //     sending, usually due to being full. The sink must have attempted to complete //     processing any outstanding requests (equivalent to poll_complete) before //     yielding this result. trace ! ( " " ) ; AsyncSink :: NotReady ( message ) } AsyncSink :: Ready => { // NetlinkFramed can only buffer one frame, so to avoid clogging the sink, we need // to flush it as soon as we call start_send(). We don't care about the result // however. let _ = self . socket . poll_complete ( ) . unwrap ( ) ; // Return Ready, because the message is being sent AsyncSink :: Ready } } }
FIXME: this should probably return an error when the sink is full and we don't have any more
space to buffer the message
FIXME : this should probably return an error when the sink is full and we don ' t have any more space to buffer the message
&mut self
message
NetlinkMessage
&mut self
message
NetlinkMessage