Struct brane_shr::fs::DownloadSecurity
source · pub struct DownloadSecurity<'c> {
pub checksum: Option<&'c [u8]>,
pub https: bool,
}
Expand description
Defines things to do to assert a downloaded file is secure and what we expect.
Fields§
§checksum: Option<&'c [u8]>
If not None
, then it defined the checksum that the file should have.
https: bool
If true, then the file can only be downloaded over HTTPS.
Implementations§
source§impl<'c> DownloadSecurity<'c>
impl<'c> DownloadSecurity<'c>
sourcepub fn all(checkum: &'c [u8]) -> Self
pub fn all(checkum: &'c [u8]) -> Self
Constructor for the DownloadSecurity that enables with all security measures enabled.
This will provide you with the most security, but is also the slowest method (since it does both encryption and checksum computation).
Usually, it sufficies to only use a checksum (DownloadSecurity::checksum()
) if you know what the file looks like a-priori.
§Arguments
checksum
: The checksum that we want the file to have. If you are unsure, give a garbage checksum, then run the function once and check what the file had (after making sure the download went correctly, of course).
§Returns
A new DownloadSecurity instance that will make your downloaded file so secure you can use it to store a country’s defecit (not legal advice).
sourcepub fn checksum(checkum: &'c [u8]) -> Self
pub fn checksum(checkum: &'c [u8]) -> Self
Constructor for the DownloadSecurity that enables checksum verification only.
Using this method is considered secure, since it guarantees that the downloaded file is what we expect. It is thus safe to use if you don’t trust either the network or the remote praty.
Note, however, that this method only works if you know a-priori what the downloaded file should look like. If not, you must use another security method (e.g., DownloadSecurity::https()
).
§Arguments
checksum
: The checksum that we want the file to have. If you are unsure, give a garbage checksum, then run the function once and check what the file had (after making sure the download went correctly, of course).
§Returns
A new DownloadSecurity instance that will make sure your file has the given checksum before returning.
sourcepub fn https() -> Self
pub fn https() -> Self
Constructor for the DownloadSecurity that forces downloads to go over HTTPS.
You should only use this method if you trust the remote party. However, if you do, then it guarantees that there was no man-in-the-middle changing the downloaded file.
§Returns
A new DownloadSecurity instance that will make sure your file if downloaded over HTTPS only.
sourcepub fn none() -> Self
pub fn none() -> Self
Constructor for the DownloadSecurity that disabled all security measures.
For obvious reasons, this security is not recommended unless you trust both the network and the remote party.
§Returns
A new DownloadSecurity instance that will require no additional security measures on the downloaded file.
Trait Implementations§
source§impl<'c> Clone for DownloadSecurity<'c>
impl<'c> Clone for DownloadSecurity<'c>
source§fn clone(&self) -> DownloadSecurity<'c>
fn clone(&self) -> DownloadSecurity<'c>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'c> Debug for DownloadSecurity<'c>
impl<'c> Debug for DownloadSecurity<'c>
Auto Trait Implementations§
impl<'c> Freeze for DownloadSecurity<'c>
impl<'c> RefUnwindSafe for DownloadSecurity<'c>
impl<'c> Send for DownloadSecurity<'c>
impl<'c> Sync for DownloadSecurity<'c>
impl<'c> Unpin for DownloadSecurity<'c>
impl<'c> UnwindSafe for DownloadSecurity<'c>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request