Skip to main content

Crate libtea_core

Crate libtea_core 

Source
Expand description

Domain types and protocol rules for the Transparency Exchange API consumer.

Independent implementation. Not an official CycloneDX project release. Not a conformance certificate. IntegrityOutcome::Verified means declared digests matched decoded artifact bytes only — it is not publisher authenticity and not cryptographic signature verification.

This crate does not open network connections, read the filesystem, or depend on an async runtime. libtea_client performs HTTP.

The pinned specification is TEA OpenAPI 1.0.0 from https://github.com/CycloneDX/transparency-exchange-api commit 962a0228af1bfcc1232ac3f79239317ff33fdb04.

The crate README follows; its Rust snippets run as doctests.

§libtea-core

Independent Rust types and protocol rules for the CycloneDX Transparency Exchange API. This crate does not open network connections.

Independent implementation. Not an official CycloneDX project. No conformance certification. IntegrityOutcome::Verified means declared digests matched decoded bytes only — not publisher authenticity. No signature verification lives in this crate.

Implemented against Transparency Exchange API commit 962a0228af1bfcc1232ac3f79239317ff33fdb04. The TEA specification is still beta.

[dependencies]
libtea-core = "0.1.5"

The snippet below needs nothing else. For the async client add libtea-client (its README lists the dependencies its example needs).

Edition 2021. MSRV 1.89. License Apache-2.0.

MSRV. The minimum supported Rust version is 1.89 for 0.1.5. Policy: the latest stable release minus about four releases; it is raised only in minor releases, and every raise is listed in the CHANGELOG.md. Dependencies use plain caret ranges and Cargo.lock is committed, so MSRV is verified with the committed lock file (cargo +1.89.0 test --workspace --all-targets --locked).

This snippet is compiled as a doctest. Another example that builds is examples/parse_tei.rs.

use libtea_core::Tei;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let tei = Tei::parse("tei://example.com/uuid/d4d9f54a-abcf-11ee-ac79-1a52914d44b1")?;
    assert_eq!(tei.tei_type(), "uuid");
    // The legacy `urn:tei:` form is rejected with its own error.
    assert!(Tei::parse("urn:tei:uuid:example.com:d4d9f54a-abcf-11ee-ac79-1a52914d44b1").is_err());
    Ok(())
}

Semver surface. url::Url, semver::Version and uuid::Uuid appear in public signatures (DestinationPolicy::check_url, ApiVersion::semver, TeaUuid::as_uuid). They are re-exported as libtea_core::{url, semver, uuid}, so use those paths to get exactly the version this crate was built against. A major-version bump of any of the three is a breaking change of libtea-core.

HTTP is in libtea-client. The workspace guide is at https://github.com/Mehrn0ush/libtea-rs.

Re-exports§

pub use checksum::verify_checksums;
pub use checksum::verify_checksums_with_policy;
pub use checksum::Checksum;
pub use checksum::ChecksumCheck;
pub use checksum::ChecksumPolicy;
pub use checksum::ChecksumVerifier;
pub use checksum::IntegrityOutcome;
pub use checksum::IntegrityReport;
pub use discovery::is_json_content_type;
pub use discovery::tea_error_code;
pub use discovery::DiscoveryInfo;
pub use discovery::WellKnownDocument;
pub use enums::ChecksumAlgorithm;
pub use enums::SortOrder;
pub use error::escape_control_chars;
pub use error::ModelError;
pub use error::PolicyError;
pub use error::TeiError;
pub use ids::ArtifactId;
pub use ids::CollectionId;
pub use ids::ComponentId;
pub use ids::ComponentReleaseId;
pub use ids::DistributionId;
pub use ids::ProductId;
pub use ids::ProductReleaseId;
pub use ids::TeaTimestamp;
pub use ids::TeaUuid;
pub use lock::diff as diff_locks;
pub use lock::ChangedArtifact;
pub use lock::FieldChange;
pub use lock::LockDiff;
pub use lock::LockFile;
pub use lock::LockedArtifact;
pub use lock::LockedChecksum;
pub use lock::LockedIntegrity;
pub use lock::LOCK_SCHEMA_VERSION;
pub use model::parse_artifact;
pub use model::parse_collection;
pub use model::parse_component_release;
pub use model::parse_product_release;
pub use model::Artifact;
pub use model::ArtifactFormat;
pub use model::Cle;
pub use model::Collection;
pub use model::Component;
pub use model::ComponentRef;
pub use model::ComponentRelease;
pub use model::ComponentReleaseWithCollection;
pub use model::Identifier;
pub use model::Page;
pub use model::Product;
pub use model::ProductRelease;
pub use model::ProductReleaseWithCollection;
pub use model::TeaErrorBody;
pub use model::TokenResponse;
pub use policy::classify_ip;
pub use policy::origin_key;
pub use policy::parse_api_base;
pub use policy::DestinationPolicy;
pub use policy::IpClass;
pub use tei::encode_query_component;
pub use tei::Tei;
pub use version::select_endpoints;
pub use version::versioned_api_prefix;
pub use version::ApiVersion;
pub use version::SelectedEndpoint;
pub use version::SupportedApi;
pub use semver;
pub use url;
pub use uuid;

Modules§

checksum
Artifact checksum calculation and verification.
discovery
.well-known/tea documents and /discovery responses.
enums
Closed request enums and forward-compatible response enums.
error
Protocol errors for parsing and validation.
http_cache
Pure pieces of the client’s HTTP cache: key derivation, Cache-Control and Retry-After parsing, the storage decision, and the on-disk entry format.
ids
Identifier newtypes.
lock
Lock file: a record of what a TEI resolved to and what the artifacts were.
model
TEA data model for the pinned OpenAPI 1.0.0 schemas.
policy
Destination checks that do not perform DNS lookups.
spec
Pinned TEA specification identity.
tei
Transparency Exchange Identifier parsing and type-specific validation.
version
TEA API version selection.

Structs§

ListParams
Query parameters shared by list operations.