# Changes in 0.2.0-rc1

This release includes an accumulation of breaking changes that hindered further enhancements and maintenance.

* Read and written messages are unified in that rather than using two traits for their data storage,
  they now use compatible nested traits, and the same mechanism for building on them.
  (Both originally started out as being around a shared or mutable slice, and developed inconsistent generalizations).

  Both are now maintained in the `inmemory` module.

  * `inmemory::Message` used to be a newtype around the more generic `EncodedMessageView`; the latter is now `Message`, and users of the former can keep using `Message<SliceBuffer>`.
  * `inmemory_write::MessageMut` used to be a type alias for `inmemory_write::GenericMessage<inmemory_write::SliceBuffer>`. Those have been renamed to `MessageMut<SliceBufferMut>`.
  * The traits `EncodedMessage` of the `inmemory` and `inmemory_write` modules are now `MessageBuffer` and `MessageBufferMut`.
  * Constructors were renamed for consistency:
    The `::new()` functions dating back to the earliest versions were renamed to `_slice` variants,
    with the versions that take a message buffer taking their names.
    More exotic constructors were renamed for consistency.

* `MessageMut` now checks at construction that its buffer has valid content;
  consequently, creation is fallible but operations have fewer error cases.

  * Consequently, `retain_options()` is now infallible.

* `MessageMut`'s `add_option()` has and still does tolerate the presence of payload,
  exceeding what `MutableWritableMessage` requires.
  Previously, payload was truncated silently;
  now, payload needs to be truncated suitably by the user,
  and adding an option that would truncate the payload is an error.

* `BoxBuffer` was added as an owned implementation of the buffer traits.

* `Message` now uses internal memoization for faster payload access,
  and more efficient conversion to a `MessageMut` through the new `into_mutable()` method.

* Minor API changes that are best caught by following compiler output:

  * `Message::code()` returns `u8` instead of `&u8`.
  * The `MessageMut::finish()` destructor returns both the written length and the buffer,
    like the now removed `finish_and_return()` destructor did.
  * Downcasting now works on any buffer, provided it returns `Some` to its `static_variant` method
    (doing which requires calling an unsafe function, as it is a promise for the downcast transmutation).

# Changes in 0.1.11

* New methods on writable messages:
  - `insert_option()` for adding options later
  - `untruncate()` for extending the payload range
  - `retain_options()` for selectively removing options
* Various bug fixes:
  - Adding an option did not reliably cause out-of-space errors.
  - Attempting to add an option that could not be added put the message into an invalid state.
* Minor internal refactoring.
* Additions in tests.

Thanks to Joel Köper for pointing out the shortcomings and providing enhancements and fixes.

# Changes in 0.1.10

* Add `inmemory_write::GenericMessage::finish_and_return()` to enable recovering `'static` backends
* Derive `Clone` for `inmemory_write` types where applicable.
* Implement `core::error::Error` on error types.

# Changes in 0.1.9

* Readable inmemory messages are guaranteed to be sorted.

# Changes in 0.1.8

* Update internally used heapless to 0.9.
* Default implemented for HeapMessage.
* MSRV updated to 1.88.
* Documentation and style fixes.

# Changes in 0.1.7

* Trivially provide WithSortedOptions for serialized messages.
* Provide ReadableMessage for all of the generalizations introduced in 0.1.6.
* Provide Debug and defmt::Format for message types.

# Changes in 0.1.6

* Split up the writable message into generic part and an encoded message part
  (similar to what was already present in the readable message),
  allowing more types (eg. cell's RefMut) to back them.

# Changes in 0.1.5

* Support coap-message 0.3.3's `promote_to_mutable_writable_message`.
* Update Rust version to 1.79.

# Changes in 0.1.4

* Add defmt feature, deriving defmt::Format where it makes sense.

# Changes in 0.1.3

* Update heapless dependency.
  While this change may be observable to those who attempt to downcast the heapless item returned through an `impl Trait` return,
  that change is not regarded as breaking
  (for this is the very kind of change such a return is there to allow).
* Update README.

# Changes in 0.1.2

* Added `downcast` feature providing a `downcast_from` method to readable and writable messages based on coap-message 0.3.2 features.
* Fixed read view of options of writable message to not emit spurious empty options.

# Changes in 0.1.1

* Added alloc feature / heap::HeapMessage implementation.

# Changes in 0.1.0

* Moved out of coap-message-utils.
