Skip to main content

Tei

Struct Tei 

Source
pub struct Tei { /* private fields */ }
Expand description

A parsed TEI that still carries its original character sequence.

Implementations§

Source§

impl Tei

Source

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.

Source

pub fn as_str(&self) -> &str

Original spelling, used for equality and for the tei query parameter.

Source

pub fn domain(&self) -> &str

DNS name carried by the TEI. This is not normalized.

Source

pub fn tei_type(&self) -> &str

Registered type segment.

Source

pub fn identifier(&self) -> &str

Unique-identifier segment, still in its TEI spelling.

Source

pub fn well_known_url(&self) -> String

https://<domain>/.well-known/tea, using the domain spelling as written.

Source

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);
Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Tei

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Tei

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Tei

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Tei

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Tei

Source§

impl Hash for Tei

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Tei

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Tei

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Tei

Auto Trait Implementations§

§

impl Forget for Tei

§

impl Freeze for Tei

§

impl Move for Tei

§

impl RefUnwindSafe for Tei

§

impl Send for Tei

§

impl Sync for Tei

§

impl Unpin for Tei

§

impl UnsafeUnpin for Tei

§

impl UnwindSafe for Tei

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.