[][src]Struct tough::Repository

pub struct Repository<'a, T: Transport> { /* fields omitted */ }

A TUF repository.

You can create a Repository using the load method.

Methods

impl<'a, T: Transport> Repository<'a, T>[src]

pub fn load<R: Read>(
    transport: &'a T,
    settings: Settings<'a, R>
) -> Result<Self>
[src]

Load and verify TUF repository metadata.

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.)

datastore is a Path to a directory on a persistent filesystem. This directory's contents store the most recently fetched timestamp, snapshot, and targets metadata files. The directory must exist prior to calling this method.

max_root_size and max_timestamp_size are the maximum size for the root.json and timestamp.json files, respectively, downloaded from the repository. These must be sufficiently large such that future updates to your repository's key management strategy will still be supported, but sufficiently small such that you are protected against an endless data attack (defined by TUF as an attacker responding to clients with extremely large files that interfere with the client's system).

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

pub fn targets(&self) -> &HashMap<String, Target>[src]

Returns the list of targets present in the repository.

pub fn read_target(&self, name: &str) -> Result<Option<impl Read>>[src]

Fetches a target from the repository.

If the repository metadata is expired or there is an issue making the request, Err is returned.

If the requested target is not listed in the repository metadata, Ok(None) is returned.

Otherwise, a reader is returned, which provides streaming access to the target contents before its checksum is validated. If the maximum size is reached or there is a checksum mismatch, the reader returns a std::io::Error. Consumers of this library must not use data from the reader if it returns an error.

Trait Implementations

impl<'a, T: Clone + Transport> Clone for Repository<'a, T>[src]

impl<'a, T: Debug + Transport> Debug for Repository<'a, T>[src]

Auto Trait Implementations

impl<'a, T> Send for Repository<'a, T> where
    T: Sync

impl<'a, T> Sync for Repository<'a, T> where
    T: Sync

impl<'a, T> Unpin for Repository<'a, T>

impl<'a, T> UnwindSafe for Repository<'a, T> where
    T: RefUnwindSafe

impl<'a, T> RefUnwindSafe for Repository<'a, T> where
    T: RefUnwindSafe

Blanket Implementations

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

impl<T> From<T> for 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<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self