[][src]Struct tough::Repository

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

A TUF repository.

You can create a Repository using the load method.

Implementations

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

pub fn cache<P1, P2, S>(
    &self,
    metadata_outdir: P1,
    targets_outdir: P2,
    targets_subset: Option<&[S]>,
    cache_root_chain: bool
) -> Result<()> where
    P1: AsRef<Path>,
    P2: AsRef<Path>,
    S: AsRef<str>, 
[src]

Cache an entire or partial repository to disk, including all required metadata. The cached repo will be local, using filesystem paths.

  • metadata_outdir is the directory where cached metadata files will be saved.
  • targets_outdir is the directory where cached targets files will be saved.
  • targets_subset is the list of targets to include in the cached repo. If no subset is specified (None), then all targets are included in the cache.
  • cache_root_chain specifies whether or not we will cache all versions of root.json.

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 targets_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) -> &Signed<Targets>[src]

Returns the list of targets present in the repository.

pub fn root(&self) -> &Signed<Root>[src]

Returns a reference to the signed root

pub fn snapshot(&self) -> &Signed<Snapshot>[src]

Returns a reference to the signed snapshot

pub fn timestamp(&self) -> &Signed<Timestamp>[src]

Returns a reference to the signed timestamp

pub fn all_targets<'b>(&'b self) -> impl Iterator + 'b[src]

return a vec of all targets including all target files delegated by targets

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.

pub fn delegated_role(&self, name: &str) -> Option<&DelegatedRole>[src]

Return the named DelegatedRole if found.

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> RefUnwindSafe for Repository<'a, T> where
    T: RefUnwindSafe

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

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