Trillium 0.2.0 #100
jbr
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Trillium 0.2.0 represents a number of breaking changes to trillium's API that hopefully will provide a better long term basis for iterative improvement. In particular, this release primarily serves to move trillium away from http-types, in order to make development more flexible and specialized. There is no intention to support the use of trillium-http's types outside of trillium, unlike http-types, which intends to be a general purpose library.
Previously, trillium-http had been using a fork of http-types, but that meant that trillium was still exposing (and thus supporting) a substantial amount of superfluous code that in the form of typed headers. This represented a maintenance liability with little upside. Trillium's approach will be to implement header parsers as needed, in subcrates that use the specific headers, and only when driven by use cases trillium supports.
Additionally, trillium-http@0.2.0 introduces a new header map implementation and response body type and renames several types from http-types. These types provide performance gains over the http-types equivalents, as determined by local http benchmarks.
General note:
This release introduces a number of type renamings and signature changes, and I would like to communicate that changes like this will be rare and decreasing over time. I appreciate the cost that unnecessary changes have to application authors, but at this early stage of development, it's preferable to break things sooner than later.
Continued support and patches for 0.1.x
As a matter of practice to set expectations for future versions of trillium, the 0.1.x branch will be maintained and all bugfixes backported for at least a year from today.
Specific Changes
trillium 0.2.0:
trillium-http 0.2.0:
trillium_http::Conn::response_headers
→trillium_http::Conn::response_headers_mut
, addedtrillium_http::Conn::response_headers
which does not require&mut
, addedtrillium_http::Conn::request_headers_mut
for parityFrom<&str>
, but onlyFrom<String>
andFrom<&'static str>
— If you need to make a new body from a borrowed string, you must clone it.trillium-testing 0.3.1:
assert_headers!
no longer requires a&mut conn
because of the above change to trillium-httptrillium-conn-id 0.2.0:
In order to accept KnownHeaderNames, the following changes have been made:
with_request_header(Option<&'static str>)
has been replaced withwith_request_header(impl Into<HeaderName<'static>>)
andwithout_request_header()
with_response_header(Option<&'static str>)
has been replaced withwith_response_header(impl Into<HeaderName<'static>>)
andwithout_response_header()
Migration
with_header((name, value))
→with_header(name, value)
This is the most prominent breaking change, and is highly likely to impact your trillium application. Any circumstance that previously was
conn.with_header((x, y))
should now becomeconn.with_header(x, y)
, eliminating the extra parentheses.becomes
or, for a small performance gain on every request:
conn_unwrap(conn, option)
→conn_unwrap(option, conn)
andconn_try(conn, result)
→conn_unwrap(result, conn)
This is a straightforward argument swap, as suggested by @mathiversen here in a discussion
This discussion was created from the release Trillium 0.2.0.
Beta Was this translation helpful? Give feedback.
All reactions