[][src]Struct oblivc::ProtocolDesc

pub struct ProtocolDesc { /* fields omitted */ }

Describes a protocol that can be executed via Obliv-C. Currently, only two-party Yao protocols are supported.

Apart from native TCP sockets created via accept or connect, applications can use anything that implements Read and Write for communication by calling use_stream.

Methods

impl ProtocolDesc[src]

pub fn new() -> Self[src]

Returns a new ProtocolDesc

pub fn party(self, party: c_int) -> Self[src]

Sets the party id of this ProtocolDesc.

Panics

if party is not 1 or 2

Examples

let mut pd = oblivc::protocol_desc().party(0); // panics

pub fn accept<P: Into<Vec<u8>>>(self, port: P) -> Result<Self, ConnectionError>[src]

Accepts an incoming connection on port using Obliv-C's networking stack.

Error

pub fn connect_loop<H: Into<Vec<u8>>, P: Into<Vec<u8>>>(
    self,
    host: H,
    port: P,
    sleep_time: Duration,
    num_tries: Option<usize>
) -> Result<Self, ConnectionError>
[src]

Tries to connect to host:port for num_tries times, waiting sleep_time between attempts. If num_tries is None, this function tries forever.

Errors

  • If either host or port contain a null byte, a NulError is returned.
  • If no connection could be established after trying num_tries times, a ConnectionError::Other is returned.

pub fn connect<H: Into<Vec<u8>>, P: Into<Vec<u8>>>(
    self,
    host: H,
    port: P
) -> Result<Self, ConnectionError>
[src]

Tries to connect to host:port in an infinite loop, waiting 100ms between attempts.

Errors

See connect_loop

pub fn connect_once<H: Into<Vec<u8>>, P: Into<Vec<u8>>>(
    self,
    host: H,
    port: P
) -> Result<Self, ConnectionError>
[src]

Tries to connect to host:port once.

Errors

See connect_loop

pub fn use_stream<'a, S: 'a + Read + Write>(self, stream: &mut S) -> Self[src]

Uses stream for communication.

pub unsafe fn exec_yao_protocol<Arg>(self, f: ProtocolFn, arg: &mut Arg)[src]

Executes f with argument arg as a two-party Yao protocol

Panics

Safety

This function is unsafe, since calling arbitrary Obliv-C functions with arbitrary arguments may lead to undefined behavior. It is the caller's responsibility to ensure that the arguments match the function being executed and that f is safe.

Trait Implementations

impl Drop for ProtocolDesc[src]

Auto Trait Implementations

impl RefUnwindSafe for ProtocolDesc

impl !Send for ProtocolDesc

impl !Sync for ProtocolDesc

impl Unpin for ProtocolDesc

impl UnwindSafe for ProtocolDesc

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, 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.