Provides json/csv/protobuf streaming support for axum

Overview

Cargo tests and formatting security audit

axum streams for Rust

Library provides HTTP response streaming support for axum web framework:

  • JSON array stream format
  • JSON lines stream format
  • CSV stream
  • Protobuf len-prefixed stream format

This type of responses are useful when you are reading huge stream of objects from some source (such as database, file, etc) and want to avoid huge memory allocation.

Quick start

Cargo.toml:

[dependencies]
axum-streams = { version = "0.7", features=["json", "csv", "protobuf"] }

Example code:

#[derive(Debug, Clone, Deserialize, Serialize)]
struct MyTestStructure {
  some_test_field: String
}

fn my_source_stream() -> impl Stream<Item=MyTestStructure> {
  // Simulating a stream with a plain vector and throttling to show how it works
  stream::iter(vec![
    MyTestStructure {
      some_test_field: "test1".to_string()
    }; 1000
  ]).throttle(std::time::Duration::from_millis(50))
}

async fn test_json_array_stream() -> impl IntoResponse {
  StreamBodyAs::json_array(source_test_stream())
}

async fn test_json_nl_stream() -> impl IntoResponse {
  StreamBodyAs::json_nl(source_test_stream())
}

async fn test_csv_stream() -> impl IntoResponse {
  StreamBodyAs::csv(source_test_stream())
}

All examples available at examples directory.

To run example use:

# cargo run --example json-example

Need client support?

There is the same functionality for:

Licence

Apache Software License (ASL)

Author

Abdulla Abdurakhmanov

Comments
  • Update Rust crate tokio to 1.24

    Update Rust crate tokio to 1.24

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | tokio (source) | dev-dependencies | minor | 1.23 -> 1.24 | | tokio (source) | dependencies | minor | 1.23 -> 1.24 |


    Release Notes

    tokio-rs/tokio

    v1.24.0: Tokio v1.24.0

    Compare Source

    The highlight of this release is the reduction of lock contention for all I/O operations (#​5300). We have received reports of up to a 20% improvement in CPU utilization and increased throughput for real-world I/O heavy applications.

    Fixed
    • rt: improve native AtomicU64 support detection (#​5284)
    Added
    • rt: add configuration option for max number of I/O events polled from the OS per tick (#​5186)
    • rt: add an environment variable for configuring the default number of worker threads per runtime instance (#​4250)
    Changed
    • sync: reduce MPSC channel stack usage (#​5294)
    • io: reduce lock contention in I/O operations (#​5300)
    • fs: speed up read_dir() by chunking operations (#​5309)
    • rt: use internal ThreadId implementation (#​5329)
    • test: don't auto-advance time when a spawn_blocking task is running (#​5115)

    v1.23.1: Tokio v1.23.1

    Compare Source

    This release forward ports changes from 1.18.4.

    Fixed
    • net: fix Windows named pipe server builder to maintain option when toggling pipe mode (#​5336).

    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about these updates again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Update Rust crate tokio to 1.23

    Update Rust crate tokio to 1.23

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | tokio (source) | dev-dependencies | minor | 1.22 -> 1.23 | | tokio (source) | dependencies | minor | 1.22 -> 1.23 |


    Release Notes

    tokio-rs/tokio

    v1.23.0: Tokio v1.23.0

    Compare Source

    Fixed
    • net: fix Windows named pipe connect (#​5208)
    • io: support vectored writes for ChildStdin (#​5216)
    • io: fix async fn ready() false positive for OS-specific events (#​5231)
    Changed
    • runtime: yield_now defers task until after driver poll (#​5223)
    • runtime: reduce amount of codegen needed per spawned task (#​5213)
    • windows: replace winapi dependency with windows-sys (#​5204)

    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about these updates again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Update Rust crate axum to 0.6 - autoclosed

    Update Rust crate axum to 0.6 - autoclosed

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | axum | dependencies | minor | 0.5 -> 0.6 |


    Release Notes

    tokio-rs/axum

    v0.6.0: axum - v0.6.0

    Compare Source

    Routing

    • fixed: Nested routers are now allowed to have fallbacks (#​1521):

      let api_router = Router::new()
          .route("/users", get(|| { ... }))
          .fallback(api_fallback);
      
      let app = Router::new()
          // this would panic in 0.5 but in 0.6 it just works
          //
          // requests starting with `/api` but not handled by `api_router`
          // will go to `/api_fallback`
          .nest("/api", api_router);
      

      The outer router's fallback will still apply if a nested router doesn't have its own fallback:

      // this time without a fallback
      let api_router = Router::new().route("/users", get(|| { ... }));
      
      let app = Router::new()
          .nest("/api", api_router)
          // `api_fallback` will inherit this fallback
          .fallback(app_fallback);
      
    • breaking: The request /foo/ no longer matches /foo/*rest. If you want to match /foo/ you have to add a route specifically for that (#​1086)

      For example:

      use axum::{Router, routing::get, extract::Path};
      
      let app = Router::new()
          // this will match `/foo/bar/baz`
          .route("/foo/*rest", get(handler))
          // this will match `/foo/`
          .route("/foo/", get(handler))
          // if you want `/foo` to match you must also add an explicit route for it
          .route("/foo", get(handler));
      
      async fn handler(
          // use an `Option` because `/foo/` and `/foo` don't have any path params
          params: Option<Path<String>>,
      ) {}
      
    • breaking: Path params for wildcard routes no longer include the prefix /. e.g. /foo.js will match /*filepath with a value of foo.js, not /foo.js (#​1086)

      For example:

      use axum::{Router, routing::get, extract::Path};
      
      let app = Router::new().route("/foo/*rest", get(handler));
      
      async fn handler(
          Path(params): Path<String>,
      ) {
          // for the request `/foo/bar/baz` the value of `params` will be `bar/baz`
          //
          // on 0.5 it would be `/bar/baz`
      }
      
    • fixed: Routes like /foo and /*rest are no longer considered overlapping. /foo will take priority (#​1086)

      For example:

      use axum::{Router, routing::get};
      
      let app = Router::new()
          // this used to not be allowed but now just works
          .route("/foo/*rest", get(foo))
          .route("/foo/bar", get(bar));
      
      async fn foo() {}
      
      async fn bar() {}
      
    • breaking: Automatic trailing slash redirects have been removed. Previously if you added a route for /foo, axum would redirect calls to /foo/ to /foo (or vice versa for /foo/):

      use axum::{Router, routing::get};
      
      let app = Router::new()
          // a request to `GET /foo/` will now get `404 Not Found`
          // whereas in 0.5 axum would redirect to `/foo`
          //
          // same goes the other way if you had the route `/foo/`
          // axum will no longer redirect from `/foo` to `/foo/`
          .route("/foo", get(handler));
      
      async fn handler() {}
      

      Either explicitly add routes for /foo and /foo/ or use axum_extra::routing::RouterExt::route_with_tsr if you want the old behavior (#​1119)

    • breaking: Router::fallback now only accepts Handlers (similarly to what get, post, etc. accept). Use the new Router::fallback_service for setting any Service as the fallback (#​1155)

      This fallback on 0.5:

      use axum::{Router, handler::Handler};
      
      let app = Router::new().fallback(fallback.into_service());
      
      async fn fallback() {}
      

      Becomes this in 0.6

      use axum::Router;
      
      let app = Router::new().fallback(fallback);
      
      async fn fallback() {}
      
    • changed: Router::nest now only accepts Routers, the general-purpose Service nesting method has been renamed to nest_service (#​1368)

    • breaking: Allow Error: Into<Infallible> for Route::{layer, route_layer} (#​924)

    • breaking: MethodRouter now panics on overlapping routes (#​1102)

    • breaking: Router::route now only accepts MethodRouters created with get, post, etc. Use the new Router::route_service for routing to any Services (#​1155)

    • breaking: Adding a .route_layer onto a Router or MethodRouter without any routes will now result in a panic. Previously, this just did nothing. #​1327

    • breaking: RouterService has been removed since Router now implements Service when the state is (). Use Router::with_state to provide the state and get a Router<()>. Note that RouterService only existed in the pre-releases, not 0.5 (#​1552)

    Extractors

    • added: Added new type safe State extractor. This can be used with Router::with_state and gives compile errors for missing states, whereas Extension would result in runtime errors (#​1155)

      We recommend migrating from Extension to State for sharing application state since that is more type safe and faster. That is done by using Router::with_state and State.

      This setup in 0.5

      use axum::{routing::get, Extension, Router};
      
      let app = Router::new()
          .route("/", get(handler))
          .layer(Extension(AppState {}));
      
      async fn handler(Extension(app_state): Extension<AppState>) {}
      
      #[derive(Clone)]
      struct AppState {}
      

      Becomes this in 0.6 using State:

      use axum::{routing::get, extract::State, Router};
      
      let app = Router::new()
          .route("/", get(handler))
          .with_state(AppState {});
      
      async fn handler(State(app_state): State<AppState>) {}
      
      #[derive(Clone)]
      struct AppState {}
      

      If you have multiple extensions, you can use fields on AppState and implement FromRef:

      use axum::{extract::{State, FromRef}, routing::get, Router};
      
      let state = AppState {
          client: HttpClient {},
          database: Database {},
      };
      
      let app = Router::new().route("/", get(handler)).with_state(state);
      
      async fn handler(
          State(client): State<HttpClient>,
          State(database): State<Database>,
      ) {}
      
      // the derive requires enabling the "macros" feature
      #[derive(Clone, FromRef)]
      struct AppState {
          client: HttpClient,
          database: Database,
      }
      
      #[derive(Clone)]
      struct HttpClient {}
      
      #[derive(Clone)]
      struct Database {}
      
    • breaking: It is now only possible for one extractor per handler to consume the request body. In 0.5 doing so would result in runtime errors but in 0.6 it is a compile error (#​1272)

      axum enforces this by only allowing the last extractor to consume the request.

      For example:

      use axum::{Json, http::HeaderMap};
      
      // This wont compile on 0.6 because both `Json` and `String` need to consume
      // the request body. You can use either `Json` or `String`, but not both.
      async fn handler_1(
          json: Json<serde_json::Value>,
          string: String,
      ) {}
      
      // This won't work either since `Json` is not the last extractor.
      async fn handler_2(
          json: Json<serde_json::Value>,
          headers: HeaderMap,
      ) {}
      
      // This works!
      async fn handler_3(
          headers: HeaderMap,
          json: Json<serde_json::Value>,
      ) {}
      

      This is done by reworking the FromRequest trait and introducing a new FromRequestParts trait.

      If your extractor needs to consume the request body then you should implement FromRequest, otherwise implement FromRequestParts.

      This extractor in 0.5:

      struct MyExtractor { /* ... */ }
      
      #[async_trait]
      impl<B> FromRequest<B> for MyExtractor
      where
          B: Send,
      {
          type Rejection = StatusCode;
      
          async fn from_request(req: &mut RequestParts<B>) -> Result<Self, Self::Rejection> {
              // ...
          }
      }
      

      Becomes this in 0.6:

      use axum::{
          extract::{FromRequest, FromRequestParts},
          http::{StatusCode, Request, request::Parts},
          async_trait,
      };
      
      struct MyExtractor { /* ... */ }
      
      // implement `FromRequestParts` if you don't need to consume the request body
      #[async_trait]
      impl<S> FromRequestParts<S> for MyExtractor
      where
          S: Send + Sync,
      {
          type Rejection = StatusCode;
      
          async fn from_request_parts(parts: &mut Parts, state: &S) -> Result<Self, Self::Rejection> {
              // ...
          }
      }
      
      // implement `FromRequest` if you do need to consume the request body
      #[async_trait]
      impl<S, B> FromRequest<S, B> for MyExtractor
      where
          S: Send + Sync,
          B: Send + 'static,
      {
          type Rejection = StatusCode;
      
          async fn from_request(req: Request<B>, state: &S) -> Result<Self, Self::Rejection> {
              // ...
          }
      }
      

      For an example of how to write an extractor that accepts different Content-Types see the [parse-body-based-on-content-type][parse-body-based-on-content-type] example.

    • added: FromRequest and FromRequestParts derive macro re-exports from [axum-macros][axum-macros] behind the macros feature (#​1352)

    • added: Add RequestExt and RequestPartsExt which adds convenience methods for running extractors to http::Request and http::request::Parts (#​1301)

    • added: JsonRejection now displays the path at which a deserialization error occurred (#​1371)

    • added: Add extract::RawForm for accessing raw urlencoded query bytes or request body (#​1487)

    • fixed: Used 400 Bad Request for FailedToDeserializeQueryString rejections, instead of 422 Unprocessable Entity (#​1387)

    • changed: The inner error of a JsonRejection is now serde_path_to_error::Error<serde_json::Error>. Previously it was serde_json::Error (#​1371)

    • changed: The default body limit now applies to the Multipart extractor (#​1420)

    • breaking: ContentLengthLimit has been removed. Use DefaultBodyLimit instead (#​1400)

    • breaking: RequestParts has been removed as part of the FromRequest rework (#​1272)

    • breaking: BodyAlreadyExtracted has been removed (#​1272)

    • breaking: The following types or traits have a new S type param which represents the state (#​1155):

      • Router, defaults to ()
      • MethodRouter, defaults to ()
      • FromRequest, no default
      • Handler, no default
    • breaking: MatchedPath can now no longer be extracted in middleware for nested routes. In previous versions it returned invalid data when extracted from a middleware applied to a nested router. MatchedPath can still be extracted from handlers and middleware that aren't on nested routers (#​1462)

    • breaking: Rename FormRejection::FailedToDeserializeQueryString to FormRejection::FailedToDeserializeForm (#​1496)

    Middleware

    • added: Support running extractors on middleware::from_fn functions (#​1088)
    • added: Add middleware::from_fn_with_state to enable running extractors that require state (#​1342)
    • added: Add middleware::from_extractor_with_state (#​1396)
    • added: Add map_request, map_request_with_state for transforming the request with an async function (#​1408)
    • added: Add map_response, map_response_with_state for transforming the response with an async function (#​1414)
    • added: Support any middleware response that implements IntoResponse (#​1152)
    • breaking: Remove extractor_middleware which was previously deprecated. Use axum::middleware::from_extractor instead (#​1077)
    • breaking: Require middleware added with Handler::layer to have Infallible as the error type (#​1152)

    Misc

    • added: Support compiling to WASM. See the simple-router-wasm example for more details (#​1382)
    • added: Add ServiceExt with methods for turning any Service into a MakeService similarly to Router::into_make_service (#​1302)
    • added: String and binary From impls have been added to extract::ws::Message to be more inline with tungstenite (#​1421)
    • added: Add #[derive(axum::extract::FromRef)] (#​1430)
    • added: Add accept_unmasked_frames setting in WebSocketUpgrade (#​1529)
    • added: Add WebSocketUpgrade::on_failed_upgrade to customize what to do when upgrading a connection fails (#​1539)
    • fixed: Annotate panicking functions with #[track_caller] so the error message points to where the user added the invalid route, rather than somewhere internally in axum (#​1248)
    • changed: axum's MSRV is now 1.60 (#​1239)
    • changed: For methods that accept some S: Service, the bounds have been relaxed so the response type must implement IntoResponse rather than being a literal Response
    • breaking: New tokio default feature needed for WASM support. If you don't need WASM support but have default_features = false for other reasons you likely need to re-enable the tokio feature (#​1382)
    • breaking: handler::{WithState, IntoService} are merged into one type, named HandlerService (#​1418)

    v0.5.17: axum - v0.5.17

    Compare Source

    • fixed: Annotate panicking functions with #[track_caller] so the error message points to where the user added the invalid router, rather than somewhere internally in axum (#​1248)
    • fixed: Make Multipart extractor work with RequestBodyLimit middleware (#​1379)
    • added: Add DefaultBodyLimit::max for changing the default body limit (#​1397)
    • added: Various documentation improvements

    v0.5.16: axum - v0.5.16

    Compare Source

    Security

    • breaking: Added default limit to how much data Bytes::from_request will consume. Previously it would attempt to consume the entire request body without checking its length. This meant if a malicious peer sent an large (or infinite) request body your server might run out of memory and crash.

      The default limit is at 2 MB and can be disabled by adding the new DefaultBodyLimit::disable() middleware. See its documentation for more details.

      This also applies to these extractors which used Bytes::from_request internally:

      • Form
      • Json
      • String

      Thanks to Shachar Menashe for reporting this vulnerability.

      (#​1346)

    v0.5.15: axum - v0.5.15

    Compare Source

    Note: This is a re-release of 0.5.14 that fixes an accidental breaking change.

    • fixed: Don't expose internal type names in QueryRejection response. (#​1171)
    • fixed: Improve performance of JSON serialization (#​1178)
    • fixed: Improve build times by generating less IR (#​1192)

    v0.5.14: axum - v0.5.14

    Compare Source

    Yanked, as it contained an accidental breaking change.

    v0.5.13: axum - v0.5.13

    Compare Source

    • fixed: If WebSocketUpgrade cannot upgrade the connection it will return a WebSocketUpgradeRejection::ConnectionNotUpgradable rejection (#​1135)
    • changed: WebSocketUpgradeRejection has a new variant ConnectionNotUpgradable variant (#​1135)

    v0.5.12: axum - v0.5.12

    Compare Source

    • added: Added debug_handler which is an attribute macro that improves type errors when applied to handler function. It is re-exported from axum-macros (#​1144)

    v0.5.11: axum - v0.5.11

    Compare Source

    • added: Implement TryFrom<http:: Method> for MethodFilter and use new NoMatchingMethodFilter error in case of failure (#​1130)
    • added: Document how to run extractors from middleware (#​1140)

    v0.5.10: axum - v0.5.10

    Compare Source

    • fixed: Make Router cheaper to clone (#​1123)
    • fixed: Fix possible panic when doing trailing slash redirect (#​1124)

    v0.5.9: axum - v0.5.9

    Compare Source

    • fixed: Fix compile error when the headers is enabled and the form feature is disabled (#​1107)

    v0.5.8: axum - v0.5.8

    Compare Source

    • added: Support resolving host name via Forwarded header in Host extractor (#​1078)
    • added: Implement IntoResponse for Form (#​1095)
    • change: axum's MSRV is now 1.56 (#​1098)

    v0.5.7: axum - v0.5.7

    Compare Source

    • added: Implement Default for Extension (#​1043)
    • fixed: Support deserializing Vec<(String, String)> in extract::Path<_> to get vector of key/value pairs (#​1059)
    • added: Add extract::ws::close_code which contains constants for close codes (#​1067)
    • fixed: Use impl IntoResponse less in docs (#​1049)

    v0.5.6: axum - v0.5.6

    Compare Source

    • added: Add WebSocket::protocol to return the selected WebSocket subprotocol, if there is one. (#​1022)
    • fixed: Improve error message for PathRejection::WrongNumberOfParameters to hint at using Path<(String, String)> or Path<SomeStruct> (#​1023)
    • fixed: PathRejection::WrongNumberOfParameters now uses 500 Internal Server Error since it's a programmer error and not a client error (#​1023)
    • fixed: Fix InvalidFormContentType mentioning the wrong content type

    v0.5.5: axum - v0.5.5

    Compare Source

    • fixed: Correctly handle GET, HEAD, and OPTIONS requests in ContentLengthLimit. Request with these methods are now accepted if they do not have a Content-Length header, and the request body will not be checked. If they do have a Content-Length header they'll be rejected. This allows ContentLengthLimit to be used as middleware around several routes, including GET routes (#​989)
    • added: Add MethodRouter::{into_make_service, into_make_service_with_connect_info} (#​1010)

    v0.5.4: axum - v0.5.4

    Compare Source

    • added: Add response::ErrorResponse and response::Result for IntoResponse-based error handling (#​921)
    • added: Add middleware::from_extractor and deprecate extract::extractor_middleware (#​957)
    • changed: Update to tower-http 0.3 (#​965)

    v0.5.3: axum - v0.5.3

    Compare Source

    • added: Add AppendHeaders for appending headers to a response rather than overriding them (#​927)
    • added: Add axum::extract::multipart::Field::chunk method for streaming a single chunk from the field (#​901)
    • fixed: Fix trailing slash redirection with query parameters (#​936)

    v0.5.2: axum - v0.5.2

    Compare Source

    Yanked, as it contained an accidental breaking change.

    v0.5.1: axum - v0.5.1

    Compare Source

    • added: Add RequestParts::extract which allows applying an extractor as a method call ([#​897)

    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [x] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Update Rust crate bytes to 1.3

    Update Rust crate bytes to 1.3

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | bytes | dependencies | minor | 1.2 -> 1.3 |


    Release Notes

    tokio-rs/bytes

    v1.3.0

    Added
    • Rename and expose BytesMut::spare_capacity_mut (#​572)
    • Implement native-endian get and put functions for Buf and BufMut (#​576)
    Fixed
    • Don't have important data in unused capacity when calling reserve (#​563)
    Documented
    • Bytes::new etc should return Self not Bytes (#​568)

    v1.2.1

    Compare Source

    Fixed
    • Fix unbounded memory growth when using reserve (#​560)

    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Update Rust crate tokio to 1.22

    Update Rust crate tokio to 1.22

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | tokio (source) | dev-dependencies | minor | 1.21 -> 1.22 | | tokio (source) | dependencies | minor | 1.21 -> 1.22 |


    Release Notes

    tokio-rs/tokio

    v1.22.0: Tokio v1.22.0

    Compare Source

    Added
    • runtime: add Handle::runtime_flavor (#​5138)
    • sync: add Mutex::blocking_lock_owned (#​5130)
    • sync: add Semaphore::MAX_PERMITS (#​5144)
    • sync: add merge() to semaphore permits (#​4948)
    • sync: add mpsc::WeakUnboundedSender (#​5189)
    Added (unstable)
    • process: add Command::process_group (#​5114)
    • runtime: export metrics about the blocking thread pool (#​5161)
    • task: add task::id() and task::try_id() (#​5171)
    Fixed
    • macros: don't take ownership of futures in macros (#​5087)
    • runtime: fix Stacked Borrows violation in LocalOwnedTasks (#​5099)
    • runtime: mitigate ABA with 32-bit queue indices when possible (#​5042)
    • task: wake local tasks to the local queue when woken by the same thread (#​5095)
    • time: panic in release mode when mark_pending called illegally (#​5093)
    • runtime: fix typo in expect message (#​5169)
    • runtime: fix unsync_load on atomic types (#​5175)
    • task: elaborate safety comments in task deallocation (#​5172)
    • runtime: fix LocalSet drop in thread local (#​5179)
    • net: remove libc type leakage in a public API (#​5191)
    • runtime: update the alignment of CachePadded (#​5106)
    Changed
    • io: make tokio::io::copy continue filling the buffer when writer stalls (#​5066)
    • runtime: remove coop::budget from LocalSet::run_until (#​5155)
    • sync: make Notify panic safe (#​5154)
    Documented
    • io: fix doc for write_i8 to use signed integers (#​5040)
    • net: fix doc typos for TCP and UDP set_tos methods (#​5073)
    • net: fix function name in UdpSocket::recv documentation (#​5150)
    • sync: typo in TryLockError for RwLock::try_write (#​5160)
    • task: document that spawned tasks execute immediately (#​5117)
    • time: document return type of timeout (#​5118)
    • time: document that timeout checks only before poll (#​5126)
    • sync: specify return type of oneshot::Receiver in docs (#​5198)
    Internal changes
    • runtime: use const Mutex::new for globals (#​5061)
    • runtime: remove Option around mio::Events in io driver (#​5078)
    • runtime: remove a conditional compilation clause (#​5104)
    • runtime: remove a reference to internal time handle (#​5107)
    • runtime: misc time driver cleanup (#​5120)
    • runtime: move signal driver to runtime module (#​5121)
    • runtime: signal driver now uses I/O driver directly (#​5125)
    • runtime: start decoupling I/O driver and I/O handle (#​5127)
    • runtime: switch io::handle refs with scheduler:Handle (#​5128)
    • runtime: remove Arc from I/O driver (#​5134)
    • runtime: use signal driver handle via scheduler::Handle (#​5135)
    • runtime: move internal clock fns out of context (#​5139)
    • runtime: remove runtime::context module (#​5140)
    • runtime: keep driver cfgs in driver.rs (#​5141)
    • runtime: add runtime::context to unify thread-locals (#​5143)
    • runtime: rename some confusing internal variables/fns (#​5151)
    • runtime: move coop mod into runtime (#​5152)
    • runtime: move budget state to context thread-local (#​5157)
    • runtime: move park logic into runtime module (#​5158)
    • runtime: move Runtime into its own file (#​5159)
    • runtime: unify entering a runtime with Handle::enter (#​5163)
    • runtime: remove handle reference from each scheduler (#​5166)
    • runtime: move enter into context (#​5167)
    • runtime: combine context and entered thread-locals (#​5168)
    • runtime: fix accidental unsetting of current handle (#​5178)
    • runtime: move CoreStage methods to Core (#​5182)
    • sync: name mpsc semaphore types (#​5146)

    v1.21.2: Tokio v1.21.2

    Compare Source

    1.21.2 (September 27, 2022)

    This release removes the dependency on the once_cell crate to restore the MSRV of 1.21.x, which is the latest minor version at the time of release. (#​5048)

    v1.21.1: Tokio v1.21.1

    Compare Source

    1.21.1 (September 13, 2022)

    Fixed
    • net: fix dependency resolution for socket2 (#​5000)
    • task: ignore failure to set TLS in LocalSet Drop (#​4976)

    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about these updates again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Update Rust crate tokio to 1.21

    Update Rust crate tokio to 1.21

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | tokio (source) | dev-dependencies | minor | 1.20 -> 1.21 | | tokio (source) | dependencies | minor | 1.20 -> 1.21 |


    Release Notes

    tokio-rs/tokio

    v1.21.2

    Compare Source

    1.21.2 (September 27, 2022)

    This release removes the dependency on the once_cell crate to restore the MSRV of 1.21.x, which is the latest minor version at the time of release. (#​5048)

    v1.21.1

    Compare Source

    1.21.1 (September 13, 2022)
    Fixed
    • net: fix dependency resolution for socket2 (#​5000)
    • task: ignore failure to set TLS in LocalSet Drop (#​4976)

    v1.21.0

    Compare Source

    1.21.0 (September 2, 2022)

    This release is the first release of Tokio to intentionally support WASM. The sync,macros,io-util,rt,time features are stabilized on WASM. Additionally the wasm32-wasi target is given unstable support for the net feature.

    Added
    • net: add device and bind_device methods to TCP/UDP sockets (#​4882)
    • net: add tos and set_tos methods to TCP and UDP sockets (#​4877)
    • net: add security flags to named pipe ServerOptions (#​4845)
    • signal: add more windows signal handlers (#​4924)
    • sync: add mpsc::Sender::max_capacity method (#​4904)
    • sync: implement Weak version of mpsc::Sender (#​4595)
    • task: add LocalSet::enter (#​4765)
    • task: stabilize JoinSet and AbortHandle (#​4920)
    • tokio: add track_caller to public APIs (#​4805, #​4848, #​4852)
    • wasm: initial support for wasm32-wasi target (#​4716)
    Fixed
    • miri: improve miri compatibility by avoiding temporary references in linked_list::Link impls (#​4841)
    • signal: don't register write interest on signal pipe (#​4898)
    • sync: add #[must_use] to lock guards (#​4886)
    • sync: fix hang when calling recv on closed and reopened broadcast channel (#​4867)
    • task: propagate attributes on task-locals (#​4837)
    Changed
    • fs: change panic to error in File::start_seek (#​4897)
    • io: reduce syscalls in poll_read (#​4840)
    • process: use blocking threadpool for child stdio I/O (#​4824)
    • signal: make SignalKind methods const (#​4956)
    Internal changes
    • rt: extract basic_scheduler::Config (#​4935)
    • rt: move I/O driver into runtime module (#​4942)
    • rt: rename internal scheduler types (#​4945)
    Documented
    • chore: fix typos and grammar (#​4858, #​4894, #​4928)
    • io: fix typo in AsyncSeekExt::rewind docs (#​4893)
    • net: add documentation to try_read() for zero-length buffers (#​4937)
    • runtime: remove incorrect panic section for Builder::worker_threads (#​4849)
    • sync: doc of watch::Sender::send improved (#​4959)
    • task: add cancel safety docs to JoinHandle (#​4901)
    • task: expand on cancellation of spawn_blocking (#​4811)
    • time: clarify that the first tick of Interval::tick happens immediately (#​4951)
    Unstable
    • rt: add unstable option to disable the LIFO slot (#​4936)
    • task: fix incorrect signature in Builder::spawn_on (#​4953)
    • task: make task::Builder::spawn* methods fallible (#​4823)

    v1.20.2

    Compare Source

    1.20.2 (September 27, 2022)

    This release removes the dependency on the once_cell crate to restore the MSRV of the 1.20.x LTS release. (#​5048)

    v1.20.1

    Compare Source

    1.20.1 (July 25, 2022)
    Fixed
    • chore: fix version detection in build script (#​4860)

    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about these updates again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Update Rust crate prost to 0.11 - autoclosed

    Update Rust crate prost to 0.11 - autoclosed

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | prost | dev-dependencies | minor | 0.10 -> 0.11 | | prost | dependencies | minor | 0.10 -> 0.11 |


    Release Notes

    tokio-rs/prost

    v0.11.0

    Compare Source

    v0.10.4

    Compare Source

    v0.10.3

    Compare Source

    v0.10.2

    Compare Source

    v0.10.1

    Compare Source


    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about these updates again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Update Rust crate bytes to 1.2 - autoclosed

    Update Rust crate bytes to 1.2 - autoclosed

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | bytes | dependencies | minor | 1.1 -> 1.2 |


    Release Notes

    tokio-rs/bytes

    v1.2.1

    Fixed
    • Fix unbounded memory growth when using reserve (#​560)

    v1.2.0

    Compare Source

    Added
    • Add BytesMut::zeroed (#​517)
    • Implement Extend<Bytes> for BytesMut (#​527)
    • Add conversion from BytesMut to Vec<u8> (#​543, #​554)
    • Add conversion from Bytes to Vec<u8> (#​547)
    • Add UninitSlice::as_uninit_slice_mut() (#​548)
    • Add const to Bytes::{len,is_empty} (#​514)
    Changed
    Fixed
    Documented
    • Redraw layout diagram with box drawing characters (#​539)
    • Clarify BytesMut::unsplit docs (#​535)

    Configuration

    📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

    🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

    Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    🔕 Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Configure Renovate

    Configure Renovate

    Mend Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • Cargo.toml (cargo)
    • .github/workflows/security-audit.yml (github-actions)
    • .github/workflows/tests.yml (github-actions)

    Configuration Summary

    Based on the default config's presets, Renovate will:

    • Start dependency updates only once this onboarding PR is merged
    • Enable Renovate Dependency Dashboard creation.
    • If Renovate detects semantic commits, it will use semantic commit type fix for dependencies and chore for all others.
    • Ignore node_modules, bower_components, vendor and various test/tests directories.
    • Autodetect whether to pin dependencies or maintain ranges.
    • Rate limit PR creation to a maximum of two per hour.
    • Limit to maximum 10 open PRs at any time.
    • Group known monorepo packages together.
    • Use curated list of recommended non-monorepo package groupings.
    • A collection of workarounds for known problems with packages.

    🔡 Would you like to change the way Renovate is upgrading your dependencies? Simply edit the renovate.json in this branch with your custom config and the list of Pull Requests in the "What to Expect" section below will be updated the next time Renovate runs.


    What to Expect

    With your current configuration, Renovate will create 1 Pull Request:

    Update Rust crate bytes to 1.2
    • Schedule: ["at any time"]
    • Branch name: renovate/bytes-1.x
    • Merge into: master
    • Upgrade bytes to 1.2

    ❓ Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 0
  • Dependency Dashboard

    Dependency Dashboard

    This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

    This repository currently has no open or pending branches.

    Detected dependencies

    cargo
    Cargo.toml
    • axum 0.6
    • bytes 1.3
    • futures-util 0.3
    • http 0.2
    • mime 0.3
    • tokio 1.24
    • serde 1.0
    • serde_json 1.0
    • tokio-stream 0.1
    • tokio-util 0.7
    • futures 0.3
    • csv 1.1
    • prost 0.11
    • futures 0.3
    • hyper 0.14
    • reqwest 0.11
    • tower 0.4
    • tower-http 0.3
    • tower-layer 0.3
    • tower-service 0.3
    • tokio 1.24
    • prost 0.11
    • cargo-husky 1.5
    github-actions
    .github/workflows/security-audit.yml
    • actions/checkout v3
    • actions-rs/toolchain v1
    .github/workflows/tests.yml
    • actions/checkout v3
    • actions-rs/toolchain v1

    • [ ] Check this box to trigger a request for Renovate to run again on this repository
    opened by renovate[bot] 0
Releases(v0.8.0)
  • v0.8.0(Nov 25, 2022)

    What's Changed

    • Axum v0.6
    • Update Rust crate tokio to 1.22 by @renovate in https://github.com/abdolence/axum-streams-rs/pull/7
    • Update Rust crate bytes to 1.3 by @renovate in https://github.com/abdolence/axum-streams-rs/pull/8

    Full Changelog: https://github.com/abdolence/axum-streams-rs/compare/v0.7.0...v0.8.0

    Source code(tar.gz)
    Source code(zip)
  • v0.7.0(Aug 14, 2022)

    • Generic streams support instead of/additionally to BoxStream<>

    Full Changelog: https://github.com/abdolence/axum-streams-rs/compare/v0.6.0...v0.7.0

    Source code(tar.gz)
    Source code(zip)
  • v0.6.0(Aug 7, 2022)

    • StreamBodyWith name is deprecated in favour of StreamBodyAs

    Full Changelog: https://github.com/abdolence/axum-streams-rs/compare/v0.5.1...v0.6.0

    Source code(tar.gz)
    Source code(zip)
  • v0.5.1(Aug 7, 2022)

  • v0.5.0(Jul 31, 2022)

  • v0.4.2(Jul 31, 2022)

  • v0.4.1(Jul 31, 2022)

  • v0.4.0(Jul 31, 2022)

  • v0.3.0(Jul 30, 2022)

  • v0.2.0(Jul 30, 2022)

    What's Changed

    • Configure Renovate by @renovate in https://github.com/abdolence/axum-streams-rs/pull/2
    • Simplified API

    Full Changelog: https://github.com/abdolence/axum-streams-rs/compare/v0.1.1...v0.2.0

    Source code(tar.gz)
    Source code(zip)
  • v0.1.1(Jul 29, 2022)

    What's Changed

    • Docs updates by @abdolence in https://github.com/abdolence/axum-streams-rs/pull/1
    • Small memory optimizations

    Full Changelog: https://github.com/abdolence/axum-streams-rs/compare/v0.1.0...v0.1.1

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Jul 29, 2022)

Owner
Abdulla Abdurakhmanov
Functional Programming Enthusiast (Scala, Rust, Haskell).
Abdulla Abdurakhmanov
Experiments with Rust CRDTs using Tokio web application framework Axum.

crdt-genome Synopsis Experiments with Rust CRDTs using Tokio web application framework Axum. Background Exploring some ideas of Martin Kleppmann, part

dougfort 3 Mar 18, 2022
Axum web framework tutorial for beginners.

Axum Tutorial For Beginners Hello web developers! This tutorial will cover how to write simple web applications in rust with axum framework. If you ar

Eray Karatay 46 Jan 5, 2023
Yew + Axum + blog = Yab

Yew + Axum + blog = Yab

STUDIO RSBM 13 Dec 5, 2022
Demo of Rust and axum web framework

Demo of Rust and axum web framework Demonstration of: Rust: programming language that focuses on reliability and stability. axum: web framework that f

Joel Parker Henderson 115 Dec 29, 2022
Rust Axum+SQLx Sample

rust-axum-sqlx-sample Install git clone https://github.com/web3ten0/rust-axum-sqlx-1.git cd rust-axum-sqlx-1/local docker-compose up -d sh scripts/exe

web3ten0 5 Jul 9, 2022
🪪 Session-based user authentication for Axum.

axum-login ?? Session-based user authentication for Axum. ?? Overview axum-login is a Tower middleware providing session-based user authentication for

Max Countryman 99 Jan 5, 2023
Layers, extractors and template engine wrappers for axum based Web MVC applications

axum-template Layers, extractors and template engine wrappers for axum based Web MVC applications Getting started Cargo.toml [dependencies] axum-templ

Altair Bueno 11 Dec 15, 2022
🔎 Prometheus metrics middleware for Axum

Axum-Prometheus A Prometheus middleware to collect HTTP metrics for Axum applications. axum-prometheus relies on metrics_exporter_prometheus as a back

Péter Leéh 14 Jan 4, 2023
Simple example of axum, sqlx with sqlite and utoipa (swagger) - without auth

axum_crud_api Simple example to learn creating CRUD rest apis in Rust with axum, sqlx with sqlite and utoipa (swagger) - without auth Also shows how t

null 2 Nov 12, 2022
Heavy Metal Leptos Stack with Tailwind, Axum, Sqlite, and Cargo Leptos

Heavy Metal Stack Leptos stack with Axum, TailwindCSS, and Sqlite This example creates a basic todo app with an Axum backend that uses Leptos' server

Ben Wishovich 7 Dec 31, 2022
A crate built on top of `axum-sessions`, implementing the CSRF Synchronizer Token Pattern

Axum Synchronizer Token Pattern CSRF prevention This crate provides a Cross-Site Request Forgery protection layer and middleware for use with the axum

null 3 Dec 15, 2022
Rate Limiting middleware for Tower/Axum/Tonic/Hyper utilizing the governor crate

A Tower service and layer that provides a rate-limiting backend by governor. Based heavily on the work done for actix-governor. Works with Axum, Hyper

Ben Wishovich 31 Feb 15, 2023
An adapter to easily allow an Axum server to be run within a Cloudflare worker.

axum-cloudflare-adapter An adapter to easily allow an Axum server to be run within a Cloudflare worker. Usage use worker::*; use axum::{ response

Logan Keenan 4 Feb 28, 2023
Starter template for use with the Leptos web framework and Axum.

Leptos Axum Starter Template This is a template for use with the Leptos web framework and the cargo-leptos tool using Axum. Creating your template rep

Leptos 10 Mar 4, 2023
Type safe multipart/form-data handling for axum.

axum_typed_multipart Designed to seamlessly integrate with Axum, this crate simplifies the process of handling multipart/form-data requests in your we

Lorenzo Murarotto 10 Mar 28, 2023
Axum + Connect-Web = ♥️

Axum Connect-Web ⚠️ This project isn't even Alpha state yet. Don't use it. Brings the protobuf-based Connect-Web RPC framework to Rust via idiomatic A

Alec Thilenius 10 Mar 19, 2023
Rust Axum Full Course code.

Rust Axum Full Course source code. YouTube Full Course: https://youtube.com/watch?v=XZtlD_m59sM&list=PL7r-PXl6ZPcCIOFaL7nVHXZvBmHNhrh_Q MIT OR Apache,

null 27 Apr 19, 2023
JWT Authentication in Rust using Axum Framework

Are you interested in building a secure authentication system for your Rust web application? Look no further than the Axum framework and JSON Web Tokens (JWTs)! Axum is a fast and scalable Rust web framework that provides a reliable and efficient platform for developing microservices and APIs.

CODEVO 16 Jun 11, 2023
This is a simple Api template for Rust ( Axum framework )

Axum-Rust-Rest-Api-Template This project is an open source Rest Api Template built with Rust's Axum framework. Why this project? I have been learning

Thani 20 Jun 16, 2023