pub struct Deprecated {
pub sunset: String,
pub link: Option<String>,
}Expand description
Deprecation metadata for an API resource or endpoint.
Carries the Sunset date (RFC 8594) and an optional Link to replacement
documentation. Use inject_headers to attach
the standard headers to an HTTP response.
Fields§
§sunset: StringRFC 7231 HTTP-date (or RFC 3339 date) after which the resource is gone.
Example: "2025-12-31" or "Sat, 31 Dec 2025 00:00:00 GMT".
link: Option<String>URL of the replacement resource or migration guide (rel="successor-version").
Implementations§
Source§impl Deprecated
impl Deprecated
Sourcepub fn new(sunset: impl Into<String>) -> Self
pub fn new(sunset: impl Into<String>) -> Self
Create a new deprecation marker with the given sunset date.
§Examples
use api_bones::deprecated::Deprecated;
let d = Deprecated::new("2025-12-31");
assert_eq!(d.sunset, "2025-12-31");
assert!(d.link.is_none());Sourcepub fn with_link(self, link: impl Into<String>) -> Self
pub fn with_link(self, link: impl Into<String>) -> Self
Attach a replacement link.
§Examples
use api_bones::deprecated::Deprecated;
let d = Deprecated::new("2025-12-31")
.with_link("https://api.example.com/v2");
assert_eq!(d.link.as_deref(), Some("https://api.example.com/v2"));Sourcepub fn deprecation_header_value(&self) -> &'static str
pub fn deprecation_header_value(&self) -> &'static str
Build the value for the Deprecation header.
Per RFC 8594 the value is true for a permanently-deprecated resource.
Sourcepub fn sunset_header_value(&self) -> &str
pub fn sunset_header_value(&self) -> &str
Build the value for the Sunset header (the sunset date as-is).
§Examples
use api_bones::deprecated::Deprecated;
let d = Deprecated::new("Sat, 31 Dec 2025 00:00:00 GMT");
assert_eq!(d.sunset_header_value(), "Sat, 31 Dec 2025 00:00:00 GMT");Sourcepub fn link_header_value(&self) -> Option<String>
pub fn link_header_value(&self) -> Option<String>
Build the Link header value for the replacement URL if present.
Produces <url>; rel="successor-version" per RFC 8288.
§Examples
use api_bones::deprecated::Deprecated;
let d = Deprecated::new("2025-12-31")
.with_link("https://api.example.com/v2");
assert_eq!(
d.link_header_value().as_deref(),
Some("<https://api.example.com/v2>; rel=\"successor-version\"")
);Trait Implementations§
Source§impl Clone for Deprecated
impl Clone for Deprecated
Source§fn clone(&self) -> Deprecated
fn clone(&self) -> Deprecated
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more