fn handle_stream(w: &mut MyWorker, ctx: &mut Context, r: Routed<Response>) -> bool {
    match &*r {
        Response::Init(Init { stream_name }) => {
            w.stream = Some(stream_name.clone());
            w.peer = r.return_route();

            println!("Init Ok! Sending a PushRequest for vec![1, 3, 5, 7]");

            block_future(
                &ctx.runtime(),
                ctx.send(w.peer.clone(), PushRequest::new(5, vec![1, 3, 5, 7])),
            )
            .unwrap();
            true
        }
        Response::PushConfirm(PushConfirm {
            request_id,
            status,
            index,
        }) => {
            println!(
                "PushConfirm req_id: {:?}, status: {:?}, index: {:?}",
                request_id, status, index
            );

            block_future(
                &ctx.runtime(),
                ctx.send(w.peer.clone(), PullRequest::new(0, 0, 8)),
            )
            .unwrap();
            true
        }

        Response::PullResponse(PullResponse {
            request_id,
            messages,
        }) => {
            println!(
                "PullResponse req_id: {:?}, num messages: {}",
                request_id,
                messages.len()
            );
            true
        }
        _ => false,
    }
}
/// Util function that maps stream-protocol responses to worker state
Util function that maps stream-protocol responses to worker state
Util function that maps stream - protocol responses to worker state
fn handle_stream(w: &mut MyWorker, ctx: &mut Context, r: Routed<Response>) -> bool {
    match &*r {
        Response::Init(Init { stream_name }) => {
            w.stream = Some(stream_name.clone());
            w.peer = r.return_route();
            println!("Init Ok! Sending a PushRequest for vec![1, 3, 5, 7]");
            block_future(
                &ctx.runtime(),
                ctx.send(w.peer.clone(), PushRequest::new(5, vec![1, 3, 5, 7])),
            )
            .unwrap();
            true
        }
        Response::PushConfirm(PushConfirm {
            request_id,
            status,
            index,
        }) => {
            println!(
                "PushConfirm req_id: {:?}, status: {:?}, index: {:?}",
                request_id, status, index
            );
            block_future(
                &ctx.runtime(),
                ctx.send(w.peer.clone(), PullRequest::new(0, 0, 8)),
            )
            .unwrap();
            true
        }
        Response::PullResponse(PullResponse {
            request_id,
            messages,
        }) => {
            println!(
                "PullResponse req_id: {:?}, num messages: {}",
                request_id,
                messages.len()
            );
            true
        }
        _ => false,
    }
}
fn handle_stream ( w : & mut MyWorker , ctx : & mut Context , r : Routed < Response > ) -> bool { match & * r { Response :: Init ( Init { stream_name } ) => { w . stream = Some ( stream_name . clone ( ) ) ; w . peer = r . return_route ( ) ; println ! ( " " ) ; block_future ( & ctx . runtime ( ) , ctx . send ( w . peer . clone ( ) , PushRequest :: new ( 5 , vec ! [ 1 3 5 7 ] ) ) , ) . unwrap ( ) ; true } Response :: PushConfirm ( PushConfirm { request_id , status , index , } ) => { println ! ( " " request_id status index ) ; block_future ( & ctx . runtime ( ) , ctx . send ( w . peer . clone ( ) , PullRequest :: new ( 0 , 0 , 8 ) ) , ) . unwrap ( ) ; true } Response :: PullResponse ( PullResponse { request_id , messages , } ) => { println ! ( " " request_id messages len ( ) ) ; true } _ => false , } }
Util function that maps stream-protocol responses to worker state
Util function that maps stream - protocol responses to worker state
w
&mut MyWorker
ctx
&mut Context
r
Routed<Response>