Struct tough::RepositoryLoader[][src]

pub struct RepositoryLoader<R> where
    R: Read
{ /* fields omitted */ }

A builder for settings with which to load a Repository. Required settings are provided in the RepositoryLoader::new function. Optional parameters can be added after calling new. Finally, call RepositoryLoader::load to load the Repository.

Examples

Basic usage:


let repository = RepositoryLoader::new(
    File::open(root).unwrap(),
    metadata_base_url,
    targets_base_url,
)
.load()
.unwrap();

With optional settings:


let repository = RepositoryLoader::new(
    File::open(root).unwrap(),
    metadata_base_url,
    targets_base_url,
)
.transport(FilesystemTransport)
.expiration_enforcement(ExpirationEnforcement::Unsafe)
.load()
.unwrap();

Implementations

impl<R: Read> RepositoryLoader<R>[src]

pub fn new(root: R, metadata_base_url: Url, targets_base_url: Url) -> Self[src]

Create a new RepositoryLoader.

root is a Reader for the trusted root metadata file, which you must ship with your software using an out-of-band process. It should be a copy of the most recent root.json from your repository. (It’s okay if it becomes out of date later; the client establishes trust up to the most recent root.json file.)

metadata_base_url and targets_base_url are the base URLs where the client can find metadata (such as root.json) and targets (as listed in targets.json).

pub fn load(self) -> Result<Repository>[src]

Load and verify TUF repository metadata.

pub fn transport<T: Transport + 'static>(self, transport: T) -> Self[src]

Set the transport. If no transport has been set, DefaultTransport will be used.

pub fn limits(self, limits: Limits) -> Self[src]

Set a the repository Limits.

pub fn datastore<P: Into<PathBuf>>(self, datastore: P) -> Self[src]

Set a datastore directory path. datastore is a directory on a persistent filesystem. This directory’s contents store the most recently fetched timestamp, snapshot, and targets metadata files to detect version rollback attacks.

You may chose to provide a PathBuf to a directory on a persistent filesystem, which must exist prior to calling RepositoryLoader::load. If no datastore is provided, a temporary directory will be created and cleaned up for for you.

pub fn expiration_enforcement(self, exp: ExpirationEnforcement) -> Self[src]

Set the ExpirationEnforcement.

CAUTION: TUF metadata expiration dates, particularly timestamp.json, are designed to limit a replay attack window. By setting expiration_enforcement to Unsafe, you are disabling this feature of TUF. Use Safe unless you have a good reason to use Unsafe.

Trait Implementations

impl<R: Clone> Clone for RepositoryLoader<R> where
    R: Read
[src]

impl<R: Debug> Debug for RepositoryLoader<R> where
    R: Read
[src]

Auto Trait Implementations

impl<R> !RefUnwindSafe for RepositoryLoader<R>

impl<R> !Send for RepositoryLoader<R>

impl<R> !Sync for RepositoryLoader<R>

impl<R> Unpin for RepositoryLoader<R> where
    R: Unpin

impl<R> !UnwindSafe for RepositoryLoader<R>

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> DynClone for T where
    T: Clone
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,