pub struct Tei { /* private fields */ }Expand description
A parsed TEI that still carries its original character sequence.
Implementations§
Source§impl Tei
impl Tei
Sourcepub fn parse(input: &str) -> Result<Self, TeiError>
pub fn parse(input: &str) -> Result<Self, TeiError>
Parse tei://<domain-name>/<type>/<unique-identifier>.
The returned value displays as the input. This function does not lowercase the domain, decode Base64URL, or rewrite percent-escapes.
§Errors
Returns an error when the text is not a structurally valid TEI.
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Original spelling, used for equality and for the tei query parameter.
Sourcepub fn identifier(&self) -> &str
pub fn identifier(&self) -> &str
Unique-identifier segment, still in its TEI spelling.
Sourcepub fn well_known_url(&self) -> String
pub fn well_known_url(&self) -> String
https://<domain>/.well-known/tea, using the domain spelling as written.
Sourcepub fn purl(&self) -> Option<Result<Purl, PurlError>>
pub fn purl(&self) -> Option<Result<Purl, PurlError>>
The Package URL inside a purl TEI, or None for any other TEI type.
Experimental: may change in a 0.x minor release.
The identifier is decoded from unpadded Base64URL and parsed with
crate::purl::Purl::parse. The TEI itself is not changed: a TEI is
used exactly as received, whatever the canonical form of its PURL.
use libtea_core::Tei;
let tei = Tei::parse("tei://example.com/purl/cGtnOm1hdmVuL2NvbW1vbnMtaW8vY29tbW9ucy1pb0AyLjIyLjA").unwrap();
let purl = tei.purl().unwrap().unwrap();
assert_eq!(purl.as_str(), "pkg:maven/commons-io/commons-io@2.22.0");
assert_eq!(Tei::parse("tei://example.com/uuid/2ff3ae7c-8eab-4e0b-9b8b-1a0c4c4c1c2d").unwrap().purl(), None);Sourcepub fn validate_registry(&self) -> Result<(), TeiError>
pub fn validate_registry(&self) -> Result<(), TeiError>
Check the unique identifier against the TEI type registry at the pinned commit.
Unknown types are structurally valid and return Ok(()). Their
identifiers are not given extra syntax beyond the single path segment.
§Errors
Returns an error when a registered type’s identifier syntax is not met.
Sourcepub fn publication_issues(&self) -> Vec<String>
pub fn publication_issues(&self) -> Vec<String>
Publication-form issues that do not make the TEI unparsable.
The discovery document requires vendors to publish a canonical spelling
and requires clients not to rewrite a TEI they received. These issues
are reported separately from Self::parse.