Skip to main content

Crate r_description

Crate r_description 

Source
Expand description

Lossless, failure-tolerant operations on R DESCRIPTION files.

RDescription::parse always returns a recovered document, even when its DCF structure is malformed. Structural issues remain available through RDescription::syntax_issues, while typed fields are validated only when their accessors are called. A malformed field therefore does not prevent access to valid unrelated fields.

Unmodified syntax is retained byte-for-byte. Named setters validate and canonically format the field they replace while preserving unrelated syntax.

use r_description::{RDescription, Relation};

let source = "Package example\n\
              Version: 1.2-0\n\
              Imports: cli (>= 3.0), glue\n\
              URL: not-a-url\n";
let description = RDescription::parse(source);

assert!(!description.syntax_issues().is_empty());
assert_eq!(description.version()?.as_str(), "1.2-0");
let imports: Vec<Relation> = description.imports()?.collect();
assert_eq!(imports.len(), 2);
assert!(description.urls().is_err());
assert_eq!(description.to_string(), source);

Structural issues, Spanned values, and positioned collection errors use absolute ranges into the current document rendering. Standalone parsers and nested errors such as VersionParseError may use ranges relative to their typed input, as documented by those types. Reacquire document-relative issues and spanned values after mutation.

Structs§

BioconductorCredentials
Credentials embedded in a Bioconductor source declaration.
BioconductorRemote
A Bioconductor Git source declaration.
CranRemote
A CRAN source declaration.
GenericGitRemote
A generic Git source declaration.
HostedGitRemote
A hosted Git repository declaration.
InvalidRelationPackage
Error constructing a relation with an ambiguous package name.
LocalRemote
A local source declaration.
PositionedParseError
A positioned parse error containing location information.
PositionedRelationParseError
A relation parse error paired with its byte range.
PositionedRemoteParseError
A remote parse error paired with its half-open UTF-8 byte range.
PositionedUrlParseError
A URL parse error paired with its byte range.
RDescription
A losslessly parsed R DESCRIPTION document.
Relation
A package dependency and its version requirement.
Remote
One source declaration from a Remotes field.
Spanned
A logical value paired with its absolute range in a DESCRIPTION document.
SvnRemote
A Subversion source declaration.
TextRange
A range in text, represented as a pair of TextSize.
UnknownRemote
An unknown explicit source declaration.
Url
A parsed URL record.
UrlMutationError
Error writing a typed URL collection field.
UrlRemote
A URL source declaration.
Version
A valid R package version with its original spelling preserved.

Enums§

AdditionalRepositoriesError
Errors returned while parsing the Additional_repositories field.
AuthorError
Errors returned by RDescription::author.
AuthorsAtRError
Errors returned by RDescription::authors_at_r.
BiarchError
Errors returned by RDescription::biarch.
BugReportsError
Errors returned by RDescription::bug_reports.
BuildVignettesError
Errors returned by RDescription::build_vignettes.
ByteCompileError
Errors returned by RDescription::byte_compile.
ContactError
Errors returned by RDescription::contact.
CopyrightError
Errors returned by RDescription::copyright.
DateError
Errors returned by RDescription::date.
DependsError
Errors returned by RDescription::depends.
DescriptionError
Errors returned by RDescription::description.
EncodingError
Errors returned by RDescription::encoding.
EnhancesError
Errors returned by RDescription::enhances.
FieldMutationError
Error validating caller-provided field mutation input.
ImportsError
Errors returned by RDescription::imports.
KeepSourceError
Errors returned by RDescription::keep_source.
LazyDataError
Errors returned by RDescription::lazy_data.
LazyLoadError
Errors returned by RDescription::lazy_load.
LicenseError
Errors returned by RDescription::license.
LicenseIsFossError
Errors returned by RDescription::license_is_foss.
LicenseRestrictsUseError
Errors returned by RDescription::license_restricts_use.
LinkingToError
Errors returned by RDescription::linking_to.
MailingListError
Errors returned by RDescription::mailing_list.
MaintainerError
Errors returned by RDescription::maintainer.
NeedsCompilationError
Errors returned by RDescription::needs_compilation.
NoteError
Errors returned by RDescription::note.
OsTypeError
Errors returned by RDescription::os_type.
PackageError
Errors returned by RDescription::package.
PackageTypeError
Errors returned by RDescription::package_type.
PriorityError
Errors returned by RDescription::priority.
RelationParseError
A typed parse error found in a package relation.
RemoteMutationError
Error writing a Remotes field from caller-provided semantic values.
RemoteParseError
A typed parse error found in one remote specification.
RemoteSource
A source supported by the Remotes syntax.
RemotesError
Errors returned by RDescription::remotes.
RepositoryError
Errors returned by RDescription::repository.
StagedInstallError
Errors returned by RDescription::staged_install.
SuggestsError
Errors returned by RDescription::suggests.
SystemRequirementsError
Errors returned by RDescription::system_requirements.
TitleError
Errors returned by RDescription::title.
UrlError
Errors returned while parsing the URL field.
UrlParseError
A typed parse error found in a URL collection field.
UseLtoError
Errors returned by RDescription::use_lto.
VersionError
Errors returned by RDescription::version.
VersionParseError
Error parsing an R package version.
VersionRequirement
One of the seven semantic version-requirement states supported by R.
ZipDataError
Errors returned by RDescription::zip_data.