pub struct OcflRepo { /* private fields */ }
Expand description
OCFL repository
Implementations
sourceimpl OcflRepo
impl OcflRepo
sourcepub fn fs_repo(
storage_root: impl AsRef<Path>,
staging: Option<&Path>
) -> Result<Self>
pub fn fs_repo(
storage_root: impl AsRef<Path>,
staging: Option<&Path>
) -> Result<Self>
Creates a new OcflRepo
instance backed by the local filesystem. storage_root
is the
location of the OCFL repository to open. The OCFL repository must already exist.
sourcepub fn init_fs_repo(
storage_root: impl AsRef<Path>,
staging: Option<&Path>,
layout: Option<StorageLayout>
) -> Result<Self>
pub fn init_fs_repo(
storage_root: impl AsRef<Path>,
staging: Option<&Path>,
layout: Option<StorageLayout>
) -> Result<Self>
Initializes a new OcflRepo
instance backed by the local filesystem. The OCFL repository
most not already exist.
sourcepub fn init_s3_repo(
region: Region,
bucket: &str,
prefix: Option<&str>,
staging_root: impl AsRef<Path>,
layout: Option<StorageLayout>,
profile: Option<&str>
) -> Result<Self>
pub fn init_s3_repo(
region: Region,
bucket: &str,
prefix: Option<&str>,
staging_root: impl AsRef<Path>,
layout: Option<StorageLayout>,
profile: Option<&str>
) -> Result<Self>
Initializes a new OcflRepo
instance backed by S3. The OCFL repository
most not already exist.
sourcepub fn s3_repo(
region: Region,
bucket: &str,
prefix: Option<&str>,
staging_root: impl AsRef<Path>,
profile: Option<&str>
) -> Result<Self>
pub fn s3_repo(
region: Region,
bucket: &str,
prefix: Option<&str>,
staging_root: impl AsRef<Path>,
profile: Option<&str>
) -> Result<Self>
Creates a new OcflRepo
instance backed by S3. prefix
used to specify a
sub directory within a bucket that the OCFL repository is rooted in.
sourcepub fn close(&self)
pub fn close(&self)
Instructs the repo to gracefully stop any in-flight work and not accept any additional requests.
sourcepub fn validate_object(
&self,
object_id: &str,
fixity_check: bool
) -> Result<ObjectValidationResult>
pub fn validate_object(
&self,
object_id: &str,
fixity_check: bool
) -> Result<ObjectValidationResult>
Validates the specified object and returns any problems found. Err will only be returned if a non-validation problem was encountered.
sourcepub fn validate_object_at(
&self,
path: &str,
fixity_check: bool
) -> Result<ObjectValidationResult>
pub fn validate_object_at(
&self,
path: &str,
fixity_check: bool
) -> Result<ObjectValidationResult>
Validates the specified object at the specified path, relative the storage root, and returns any problems found. Err will only be returned if a non-validation problem was encountered.
sourcepub fn validate_repo<'a>(
&'a self,
fixity_check: bool
) -> Result<Box<dyn IncrementalValidator + 'a>>
pub fn validate_repo<'a>(
&'a self,
fixity_check: bool
) -> Result<Box<dyn IncrementalValidator + 'a>>
Validates the structure of an OCFL repository as well as all of the objects in the repository
When fixity_check
is false
, then the digests of object content files are not validated.
The storage root is validated immediately, and an incremental validator is returned that is used to lazily validate the rest of the repository.
sourcepub fn list_objects<'a>(
&'a self,
filter_glob: Option<&str>
) -> Result<Box<dyn Iterator<Item = Result<ObjectVersionDetails>> + 'a>>
pub fn list_objects<'a>(
&'a self,
filter_glob: Option<&str>
) -> Result<Box<dyn Iterator<Item = Result<ObjectVersionDetails>> + 'a>>
Returns an iterator that iterate through all of the objects in an OCFL repository. Objects are lazy-loaded. An optional glob pattern may be provided to filter the objects that are returned.
The iterator returns an error if it encounters a problem accessing an object. This does
terminate the iterator; there are still more objects until it returns None
.
sourcepub fn list_staged_objects<'a>(
&'a self,
filter_glob: Option<&str>
) -> Result<Box<dyn Iterator<Item = Result<ObjectVersionDetails>> + 'a>>
pub fn list_staged_objects<'a>(
&'a self,
filter_glob: Option<&str>
) -> Result<Box<dyn Iterator<Item = Result<ObjectVersionDetails>> + 'a>>
Returns an iterator that iterate through all of the staged objects in an OCFL repository. Objects are lazy-loaded. An optional glob pattern may be provided to filter the objects that are returned.
The iterator returns an error if it encounters a problem accessing an object. This does
terminate the iterator; there are still more objects until it returns None
.
sourcepub fn get_object(
&self,
object_id: &str,
version_num: VersionRef
) -> Result<ObjectVersion>
pub fn get_object(
&self,
object_id: &str,
version_num: VersionRef
) -> Result<ObjectVersion>
Returns a view of a version of an object. If a VersionNum
is not specified,
then the head version of the object is returned.
If the object or version of the object cannot be found, then a RocflError::NotFound
error is returned.
sourcepub fn get_staged_object(&self, object_id: &str) -> Result<ObjectVersion>
pub fn get_staged_object(&self, object_id: &str) -> Result<ObjectVersion>
Same as get_object()
except that it returns the staged version of an object.
If the object does not have a staged version, then a RocflError::NotFound
error is returned.
sourcepub fn get_object_details(
&self,
object_id: &str,
version_num: VersionRef
) -> Result<ObjectVersionDetails>
pub fn get_object_details(
&self,
object_id: &str,
version_num: VersionRef
) -> Result<ObjectVersionDetails>
Returns high-level details about an object version. This method is similar to
OcflRepo::get_object()
except that it does less processing and does not
include the version’s state.
If the object or version of the object cannot be found, then a RocflError::NotFound
error is returned.
sourcepub fn get_staged_object_details(
&self,
object_id: &str
) -> Result<ObjectVersionDetails>
pub fn get_staged_object_details(
&self,
object_id: &str
) -> Result<ObjectVersionDetails>
Same as get_object_details()
, but for the staged version of an object.
If the object does not have a staged version, then a RocflError::NotFound
error is returned.
sourcepub fn list_object_versions(
&self,
object_id: &str
) -> Result<Vec<VersionDetails>>
pub fn list_object_versions(
&self,
object_id: &str
) -> Result<Vec<VersionDetails>>
Returns a vector containing the version metadata for ever version of an object. The vector is sorted in ascending order.
If the object cannot be found, then a RocflError::NotFound
error is returned.
sourcepub fn get_object_file(
&self,
object_id: &str,
path: &LogicalPath,
version_num: VersionRef,
sink: &mut dyn Write
) -> Result<()>
pub fn get_object_file(
&self,
object_id: &str,
path: &LogicalPath,
version_num: VersionRef,
sink: &mut dyn Write
) -> Result<()>
Writes the specified file to the sink.
If the file cannot be found, then a RocflError::NotFound
error is returned.
sourcepub fn get_staged_object_file(
&self,
object_id: &str,
path: &LogicalPath,
sink: &mut dyn Write
) -> Result<()>
pub fn get_staged_object_file(
&self,
object_id: &str,
path: &LogicalPath,
sink: &mut dyn Write
) -> Result<()>
Writes the specified file from the staged version of the object to the sink.
If the file cannot be found, then a RocflError::NotFound
error is returned.
sourcepub fn list_file_versions(
&self,
object_id: &str,
path: &LogicalPath
) -> Result<Vec<VersionDetails>>
pub fn list_file_versions(
&self,
object_id: &str,
path: &LogicalPath
) -> Result<Vec<VersionDetails>>
Returns a vector contain the version metadata for every version of an object that affected the specified file. The vector is sorted in ascending order.
If the object or path cannot be found, then a `RocflError::NotFound’ error is returned.
sourcepub fn diff(
&self,
object_id: &str,
left_version: Option<VersionNum>,
right_version: VersionNum
) -> Result<Vec<Diff>>
pub fn diff(
&self,
object_id: &str,
left_version: Option<VersionNum>,
right_version: VersionNum
) -> Result<Vec<Diff>>
Returns the diff of two object versions. If only one version is specified, then the diff is between the specified version and the version before it.
If the object cannot be found, then a RocflError::NotFound
error is returned.
sourcepub fn diff_staged(&self, object_id: &str) -> Result<Vec<Diff>>
pub fn diff_staged(&self, object_id: &str) -> Result<Vec<Diff>>
Returns all of the staged changes to the specified object, if there are any.
sourcepub fn purge_object(&self, object_id: &str) -> Result<()>
pub fn purge_object(&self, object_id: &str) -> Result<()>
Completely removes the specified object from the repository. If the object doest not exist, nothing happens.
sourcepub fn create_object(
&self,
object_id: &str,
digest_algorithm: DigestAlgorithm,
content_dir: &str,
padding_width: u32
) -> Result<()>
pub fn create_object(
&self,
object_id: &str,
digest_algorithm: DigestAlgorithm,
content_dir: &str,
padding_width: u32
) -> Result<()>
Stages a new OCFL object if there is not an existing object with the same ID. The object is not inserted into the repository until it is committed.
sourcepub fn copy_files_external(
&self,
object_id: &str,
src: &[impl AsRef<Path>],
dst: &str,
recursive: bool
) -> Result<()>
pub fn copy_files_external(
&self,
object_id: &str,
src: &[impl AsRef<Path>],
dst: &str,
recursive: bool
) -> Result<()>
Copies files from outside the OCFL repository into the specified OCFL object.
A destination of /
specifies the object’s root.
sourcepub fn copy_files_internal(
&self,
object_id: &str,
version_num: VersionRef,
src: &[impl AsRef<str>],
dst: &str,
recursive: bool
) -> Result<()>
pub fn copy_files_internal(
&self,
object_id: &str,
version_num: VersionRef,
src: &[impl AsRef<str>],
dst: &str,
recursive: bool
) -> Result<()>
Copies files within an OCFL object. The source paths may be glob patterns.
sourcepub fn move_files_external(
&self,
object_id: &str,
src: &[impl AsRef<Path>],
dst: &str
) -> Result<()>
pub fn move_files_external(
&self,
object_id: &str,
src: &[impl AsRef<Path>],
dst: &str
) -> Result<()>
Moves files from outside the OCFL repository into the specified OCFL object.
A destination of /
specifies the object’s root.
sourcepub fn move_files_internal(
&self,
object_id: &str,
src: &[impl AsRef<str>],
dst: &str
) -> Result<()>
pub fn move_files_internal(
&self,
object_id: &str,
src: &[impl AsRef<str>],
dst: &str
) -> Result<()>
Moves files within an OCFL object. The source paths may be glob patterns.
sourcepub fn remove_files<P: AsRef<str>>(
&self,
object_id: &str,
paths: &[P],
recursive: bool
) -> Result<()>
pub fn remove_files<P: AsRef<str>>(
&self,
object_id: &str,
paths: &[P],
recursive: bool
) -> Result<()>
Removes the specified files from the staged version of the object. The files still exist in prior versions.
sourcepub fn reset_all(&self, object_id: &str) -> Result<()>
pub fn reset_all(&self, object_id: &str) -> Result<()>
Reset all staged changes for an object by dropping the object’s staged version completely.
sourcepub fn reset<P: AsRef<str>>(
&self,
object_id: &str,
paths: &[P],
recursive: bool
) -> Result<()>
pub fn reset<P: AsRef<str>>(
&self,
object_id: &str,
paths: &[P],
recursive: bool
) -> Result<()>
Resets to specified staged changes to an object. Paths may be a glob and is resolved against both the staged version and the previous version. Matches in the staged version are treated as add/update resets and matches in the previous version are treated as remove resets.
sourcepub fn commit(
&self,
object_id: &str,
meta: CommitMeta,
object_root: Option<&str>,
pretty_print: bool
) -> Result<()>
pub fn commit(
&self,
object_id: &str,
meta: CommitMeta,
object_root: Option<&str>,
pretty_print: bool
) -> Result<()>
Commits all of an object’s staged changes. If user_address
is provided, then user_name
must also be. If created
is not provided, then it defaults to the current time.
object_root
may be specified to define the storage root relative path to the object’s
root. This value is only respected if the object does not already exist, and the
repo does not have defined storage layout.
Auto Trait Implementations
impl !RefUnwindSafe for OcflRepo
impl Send for OcflRepo
impl Sync for OcflRepo
impl Unpin for OcflRepo
impl !UnwindSafe for OcflRepo
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more