[−][src]Struct oblivc::ProtocolDesc
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
- If
port
contains a null byte, aNulError
is returned. - If the accept call fails, a
ConnectionError::Other
is returned.
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]
self,
host: H,
port: P,
sleep_time: Duration,
num_tries: Option<usize>
) -> Result<Self, ConnectionError>
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
orport
contain a null byte, aNulError
is returned. - If no connection could be established after trying
num_tries
times, aConnectionError::Other
is returned.
pub fn connect<H: Into<Vec<u8>>, P: Into<Vec<u8>>>(
self,
host: H,
port: P
) -> Result<Self, ConnectionError>
[src]
self,
host: H,
port: P
) -> Result<Self, ConnectionError>
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]
self,
host: H,
port: P
) -> Result<Self, ConnectionError>
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
- if not connected either via
connect
,connect_loop
,connect_once
,accept
, oruse_stream
- if
party
was not called
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,