[][src]Struct embly::Conn

pub struct Conn { /* fields omitted */ }

Connections that handle communication between functions or gateways

Receive Bytes

When a function begins execution it can optionally read in any bytes that it might have been sent. Maybe there are bytes ready on startup, maybe it'll receive them later.

use embly::{Conn};
use embly::prelude::*;
use std::io;
use failure::Error;

fn entrypoint(mut conn: Conn) -> Result<(), Error> {
    let mut buffer = Vec::new();
    // Conn implements std::io::Read
    conn.wait()?;
    conn.read_to_end(&mut buffer)?;
     
    // a little while later you might get another message
    conn.wait()?;
    conn.read_to_end(&mut buffer)?;
    return Ok(())
}

Write Bytes

Bytes can be written back. A spark is always executed by something. This could be a command line call, a load balancer or another spark. Writing to a connection will send those bytes back to the spark runner.

use embly::Conn;
use std::io;
use std::io::Write;

fn entrypoint(mut conn: Conn) -> io::Result<()> {
    // you can call write_all to send one message
    conn.write_all("Hello World".as_bytes())?;


    // Or you can make multiple calls with write if you want to construct a
    // message and then flush the response
    conn.write(b"Hello")?;
    conn.write(b"World")?;
    conn.flush()?;
    return Ok(())
}

Trait Implementations

impl Waitable for Conn[src]

type Output = Result<(), Error>

asdfasdf

fn id(&self) -> i32[src]

wait for it

fn fetch_result(&mut self) -> Result<(), Error>[src]

asdfasdf

impl Clone for Conn[src]

impl Copy for Conn[src]

impl Debug for Conn[src]

impl Write for Conn[src]

impl Read for Conn[src]

Auto Trait Implementations

impl Send for Conn

impl Sync for Conn

impl Unpin for Conn

impl UnwindSafe for Conn

impl RefUnwindSafe for Conn

Blanket Implementations

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

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

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

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

impl<R> ReadBytesExt for R where
    R: Read + ?Sized

impl<W> WriteBytesExt for W where
    W: Write + ?Sized