[−][src]Struct portal_lib::Portal
The primary interface into the library. The Portal struct contains data associated with either a new request or a response from a peer.
Implementations
impl Portal
[src]
pub fn init(
direction: Direction,
id: String,
password: String,
filename: Option<String>
) -> (Portal, Vec<u8>)
[src]
direction: Direction,
id: String,
password: String,
filename: Option<String>
) -> (Portal, Vec<u8>)
Initialize a new portal request
Example
use portal_lib::{Portal,Direction}; // the shared password should be secret and hard to guess/crack // see the portal-client as an example of potential usage let id = "my client ID".to_string(); let password = "testpasswd".to_string(); let portal = Portal::init(Direction::Sender,id,password,None);
pub fn parse(data: &[u8]) -> Result<Portal>
[src]
Initialize with existing data, attempting to deserialize bytes into a Portal struct
Example
use portal_lib::Portal; use std::io::Read; fn example(mut client: std::net::TcpStream) { let mut buf = [0; 1024]; let len = client.read(&mut buf); let response = match Portal::parse(&buf) { Ok(r) => r, Err(_) => { println!("Failed to read request/response..."); return; } }; }
pub fn read_response_from<R>(reader: R) -> Result<Portal> where
R: Read,
[src]
R: Read,
Initialize by reading from a stream that implements the std::io::Read trait, consuming the bytes
Example
use portal_lib::Portal; fn example(client: std::net::TcpStream) { let response = match Portal::read_response_from(&client) { Ok(r) => r, Err(_) => { println!("Failed to read response..."); return; } }; }
pub fn read_confirmation_from<R>(reader: R) -> Result<PortalConfirmation> where
R: Read,
[src]
R: Read,
Receive the bytes necessary for a confirmation message from a stream that implements std::io::Read, consuming the bytes
pub fn serialize(&self) -> Result<Vec<u8>>
[src]
Attempt to serialize a Portal struct into a vector
pub fn load_file<'a>(&'a self, f: &str) -> Result<PortalFile>
[src]
pub fn create_file<'a>(&'a self, f: &str, size: u64) -> Result<PortalFile>
[src]
pub fn derive_key(&mut self, msg_data: &[u8]) -> Result<()>
[src]
Derive a shared key with the exchanged data at this point in the exchange we have not verified that our peer has derived the same key as us
pub fn confirm_peer<R>(&mut self, client: R) -> Result<()> where
R: Read + Write,
[src]
R: Read + Write,
Confirm that the peer has derived the same key
pub fn get_file_size(&self) -> u64
[src]
Returns the file size associated with this request
pub fn set_file_size(&mut self, size: u64)
[src]
Sets the file size associated with this request
pub fn get_file_name<'a>(&'a self) -> Result<&'a str>
[src]
Returns the file name associated with this request or a PortalError::NoneError if none exists
pub fn get_direction(&self) -> Direction
[src]
Returns a copy of the Portal::Direction associated with this Portal request
pub fn set_direction(&mut self, direction: Direction)
[src]
Sets the Portal::Direction associated with this Poral request
pub fn get_id(&self) -> &String
[src]
Returns a reference to the ID associated with this Portal request
pub fn set_id(&mut self, id: String)
[src]
Sets the ID associated with this Poral request
Trait Implementations
impl Debug for Portal
[src]
impl<'de> Deserialize<'de> for Portal
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl PartialEq<Portal> for Portal
[src]
impl Serialize for Portal
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralPartialEq for Portal
[src]
Auto Trait Implementations
impl RefUnwindSafe for Portal
impl Send for Portal
impl Sync for Portal
impl Unpin for Portal
impl UnwindSafe for Portal
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> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,