Skip to main content

Crate use_content_negotiation

Crate use_content_negotiation 

Source
Expand description

§use-content-negotiation

Content negotiation primitives for RustUse.

Models accepted media types, quality values, content preferences, language preferences, and encoding preferences with conservative parsing.

§Example

use use_content_negotiation::{PreferenceKind, AcceptedMediaType};

let value = AcceptedMediaType::new("application/json").expect("valid API primitive");

assert_eq!(value.as_str(), "application/json");
assert_eq!(PreferenceKind::MediaType.to_string(), "media-type");

§Scope

  • Small validated types for API metadata.
  • Stable display labels and conservative parsing helpers.
  • Dependency-light primitives that can be reused by other RustUse crates.

§Non-goals

  • No full Accept parser.
  • No locale matching engine.
  • No content transformation.

§License

Licensed under either of the following, at your option:

  • Apache License, Version 2.0
  • MIT license

Structs§

AcceptedMediaType
ContentPreference
EncodingPreference
LanguagePreference
PrimitiveMetadata
Lightweight metadata tying this crate’s primary text and label together.
QualityValue
A quality value scaled from 0 to 1000.

Enums§

ApiPrimitiveError
Error returned when API primitive text or labels are invalid.
PreferenceKind
Content negotiation preference kind labels.