Skip to content

v0.4.0

Choose a tag to compare

@amsokol amsokol released this 07 Oct 17:30
· 23 commits to main since this release
v0.4.0
f996dc6

Added

  • Feature tokio (off by default) adds serde_markdown::tokio, the async
    twin of every function under the same name: to_string,
    to_string_with_format, to_string_with, to_vec, to_writer (tokio
    AsyncWrite), from_str, from_slice, from_reader (tokio
    AsyncRead). It writes and reads the same documents as the sync form. It
    is native: the same steps, with a cooperative yield between them when the
    task's budget is spent; no thread and no spawn_blocking, so an async
    caller awaits it as it is.
  • The runnable example example-tokio (rust/examples/tokio): the async
    form on a tokio runtime, with a file round-trip over tokio::fs and
    pages rendered in parallel tasks.

Changed

  • The README is rewritten for users of the crate: how to depend on it, the
    document shape, body fields, language and layout, errors, the async API
    (with a file round-trip over tokio::fs), and protobuf messages; the
    development notes moved to the end. Its examples are checked against the
    crate.
  • When a required body section and front-matter keys are both missing,
    the error is the first missing field in declaration order:
    ErrorKind::Type for a front-matter key. Before, the missing body
    section (ErrorKind::Body) was reported first.
  • markdown/options.proto, the (markdown.body) option, moved into the crate:
    rust/markdown/proto/markdown/options.proto. The import path is the same,
    markdown/options.proto. The Cargo dependency now brings the option too, so
    a consumer needs no second channel for it.
  • PROTO_INCLUDE points into the crate (<crate>/proto), so it works for a
    crate fetched alone, not only from a checkout of this repository.

Removed

  • The Bazel label @serde_markdown//proto/markdown:options.proto. A Bazel
    consumer drops its bazel_dep and git_override of serde_markdown and
    reaches the file through its crate_universe hub with an annotation
    (additive_build_file_content plus extra_aliased_targets); the README
    shows it. With one dependency the proto and the crate can no longer drift
    to different versions.
  • The fixtures crate serde_markdown-proto (not published) no longer carries
    the generated markdown.body extension constant.

Fixed

  • Enum fields read back. A field of an enum type (Serde's default,
    externally tagged form) failed to read with ErrorKind::Type, in the
    fields block and in a body section. Unit variants and variants with
    content now round-trip in YAML, JSON, and TOML; a unit variant in a body
    section is its raw name.
  • #[derive(Markdown)] follows the struct's #[serde(rename_all = "...")]
    (and rename_all(serialize = ..., deserialize = ...)) and drops the r#
    of a raw identifier. Before, a body field of such a struct was written
    into the fields block, with no error. A body field whose serialize and
    deserialize names differ is now a compile error.
  • A Vec<u8> body whose text reads as a YAML or JSON list ([1, 2],
    - a) reads back as its bytes; before, it read as the list's numbers or
    failed. A Vec<u8> whose text reads as an empty list ([]) is
    ErrorKind::Body on write, since it cannot be told from an empty list.
  • A body field with #[serde(default)] may be missing from the document:
    a field without a section is no longer handed to the value, so Serde
    applies its default (or None). A required one is still
    ErrorKind::Body.
  • A TOML date-time in the fields block (when = 1979-05-27T07:32:00Z)
    reads into a string or Timestamp field; before, ErrorKind::Type.
  • Built without the yaml feature, a document whose first slice is prose
    reads as body, and a body-only document is written with no empty fields
    block. Before, reading failed with ErrorKind::FormatDisabled and writing
    added an empty JSON or TOML block.
  • Leading --- lines are skipped in linear time. A document of many of
    them took quadratic time (40 000 lines: 1.4 s).
  • Every feature set builds and tests, none at all included.