pub struct RepositoryLoader<'a> { /* private fields */ }Expand description
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(
&tokio::fs::read(root).await.unwrap(),
metadata_base_url,
targets_base_url,
)
.load()
.await
.unwrap();
§With optional settings:
let repository = RepositoryLoader::new(
&tokio::fs::read(root).await.unwrap(),
metadata_base_url,
targets_base_url,
)
.transport(FilesystemTransport)
.expiration_enforcement(ExpirationEnforcement::Unsafe)
.load()
.await
.unwrap();
Implementations§
Source§impl<'a> RepositoryLoader<'a>
impl<'a> RepositoryLoader<'a>
Sourcepub fn new(
root: &'a impl AsRef<[u8]>,
metadata_base_url: Url,
targets_base_url: Url,
) -> Self
pub fn new( root: &'a impl AsRef<[u8]>, metadata_base_url: Url, targets_base_url: Url, ) -> Self
Create a new RepositoryLoader.
root is the content of a 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).
Sourcepub async fn load(self) -> Result<Repository>
pub async fn load(self) -> Result<Repository>
Load and verify TUF repository metadata.
Sourcepub fn transport<T: Transport + Send + Sync + 'static>(
self,
transport: T,
) -> Self
pub fn transport<T: Transport + Send + Sync + 'static>( self, transport: T, ) -> Self
Set the transport. If no transport has been set, DefaultTransport will be used.
Sourcepub fn datastore<P: Into<PathBuf>>(self, datastore: P) -> Self
pub fn datastore<P: Into<PathBuf>>(self, datastore: P) -> Self
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.
Sourcepub fn expiration_enforcement(self, exp: ExpirationEnforcement) -> Self
pub fn expiration_enforcement(self, exp: ExpirationEnforcement) -> Self
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§
Source§impl<'a> Clone for RepositoryLoader<'a>
impl<'a> Clone for RepositoryLoader<'a>
Source§fn clone(&self) -> RepositoryLoader<'a>
fn clone(&self) -> RepositoryLoader<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more