[−][src]Struct portal_lib::file::PortalFile
A file mapping that contains state to encrypt/decrypt files in memory
Fields
mmap: MmapMut
cipher: ChaCha20Poly1305
Implementations
impl PortalFile
[src]
pub fn init(mmap: MmapMut, cipher: ChaCha20Poly1305) -> PortalFile
[src]
pub fn encrypt(&mut self) -> Result<()>
[src]
Encrypts the current PortalFile, by encrypting the mmap'd memory in-place
pub fn decrypt(&mut self) -> Result<()>
[src]
Decrypts the current PortalFile, by decrypting the mmap'd memory in-place
pub fn sync_file_state<W>(&mut self, writer: W) -> Result<usize> where
W: Write,
[src]
W: Write,
Writes the nonce and tag for this file to the provided writer. Use after encrypting a file to communicate state data to the peer that will decrypt the file
pub fn download_file<R, F>(&mut self, reader: R, callback: F) -> Result<u64> where
R: Read,
F: Fn(u64),
[src]
R: Read,
F: Fn(u64),
Downloads a file, first by retrieving the Tag and Nonce communicated by sync_file_state() and then reading in the file until EOF
Peer A Peer B encrypt() download_file() sync_file_state() decrypt() // send chunks
pub fn get_chunks<'a>(
&'a self,
chunk_size: usize
) -> impl Iterator<Item = &'a [u8]>
[src]
&'a self,
chunk_size: usize
) -> impl Iterator<Item = &'a [u8]>
Returns an iterator over the chunks to send it over the network
Examples
for data in file.get_chunks(portal::CHUNK_SIZE) { client.write_all(&data)? total += data.len(); pb.set_position(total as u64); }
pub fn write_given_chunk(&mut self, data: &[u8]) -> Result<u64>
[src]
Writes the provided data to the file in-memory at the current position
Auto Trait Implementations
impl RefUnwindSafe for PortalFile
impl Send for PortalFile
impl Sync for PortalFile
impl Unpin for PortalFile
impl UnwindSafe for PortalFile
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> 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>,