Skip to main content

VersionChange

Trait VersionChange 

Source
pub trait VersionChange:
    Send
    + Sync
    + 'static {
    // Required method
    fn description(&self) -> &str;

    // Provided methods
    fn resources(&self) -> &[&'static str] { ... }
    fn added_routes(&self) -> &[&'static str] { ... }
    fn removed_routes(&self) -> &[&'static str] { ... }
    fn unavailable_to_older_versions(&self) -> &[&'static str] { ... }
    fn legacy_handlers(&self) -> Vec<(&'static str, LegacyHandler)> { ... }
    fn transform_request(&self, payload: &mut Map<String, Value>) { ... }
    fn transform_response(&self, document: &mut Value) { ... }
}
Expand description

One backwards-incompatible change, registered under the version that introduced it.

Routes are named by method and URI pattern, as GET /v1/orders/{order}/summary; * matches anything. Resources are JSON:API types, such as customers, or route patterns.

Required Methods§

Source

fn description(&self) -> &str

What changed, for the changelog.

Provided Methods§

Source

fn resources(&self) -> &[&'static str]

The resource types or routes the transforms apply to. Empty means every response.

Source

fn added_routes(&self) -> &[&'static str]

Routes this version added: older versions get a 404.

Source

fn removed_routes(&self) -> &[&'static str]

Routes this version removed: it and newer versions get a 404.

Source

fn unavailable_to_older_versions(&self) -> &[&'static str]

Routes older versions may no longer use: they get a 410 endpoint_unavailable_for_version.

Source

fn legacy_handlers(&self) -> Vec<(&'static str, LegacyHandler)>

Routes older versions keep being served by a frozen handler.

Source

fn transform_request(&self, payload: &mut Map<String, Value>)

Upgrades a request body from the older shape to this version’s shape.

Source

fn transform_response(&self, document: &mut Value)

Downgrades a response document from this version’s shape to the older shape.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§