Vvinhnx

hyper-0-14-to-1-0

Migrate Rust hyper legacy client imports and type paths from 0.14 to 1.x with deterministic rewrites

rusthyperhttpclientwebmigration0.14-to-1.0tokio
Public
0 executions
2 stars
How to Use
Run this codemod on your codebase using the following command

The easiest way to run this codemod without installing anything globally:

Documentation

hyper-0-14-to-1-0

Automate deterministic parts of the Rust hyper migration from v0.14 to v1.x for legacy client usage.

What it does

Rust source updates

  • Rewrites legacy client imports:
    • use hyper::Client; -> use hyper_util::client::legacy::Client;
    • use hyper::client::HttpConnector; -> use hyper_util::client::legacy::connect::HttpConnector;
    • use hyper::client::connect::HttpConnector; -> use hyper_util::client::legacy::connect::HttpConnector;
  • Rewrites grouped imports:
    • use hyper::{Body, Client}; -> split into use hyper::{Body}; and use hyper_util::client::legacy::Client;
  • Rewrites fully-qualified type paths in code:
    • hyper::Client -> hyper_util::client::legacy::Client
    • hyper::client::HttpConnector -> hyper_util::client::legacy::connect::HttpConnector

Usage

bash

Manual follow-up

After running, you should:

  1. Update Cargo.toml to Hyper 1 and add hyper-util with required features for your runtime/protocol usage
  2. Review client construction sites and switch to the Hyper v1 builder APIs where needed
  3. Migrate body handling (to_bytes, body types, and response collection) as needed for your codebase
  4. Run cargo check and cargo test

Development

bash

References

License

MIT

Before

This is one example from the codemod's test cases. The codemod may handle many more cases.

Ready to contribute?

Build your own codemod and share it with the community.