A gemini client/server library and interactive client in Rust.
Go to file
Emii Tatsuo 34dca8d92d
continuous-integration/drone/pr Build is failing Details
Impl ToString for Builder, accept AsRef<[Node]> in `render()`
This adds a to_string method to the `Builder` allowing for the easy conversion of a Vec<Node> into a String, for any usecases where a library might not be directly writing to an io::Write, or may want to do String-y things with your document first.  Without this, users would have to write to a Vec<u8> and convert to a String, which is kinda unintuitive, takes a lot of steps, and doesn't produce very readable code.  This simplifies it to one method call.

* Implementation of the std::str::ToString method for Builder
* Accepting any AsRef<[Node]> in render (including accepting the old Vec<Node>, so not breaking)
* Addition of estimate_len() to Node, used to pre-allocate the correct size of the String buffer

* `estimate_len` has some quick doctests and examples.  I know most of the rest of the project uses test methods, but I hope this is alright given that the tests may add some more clarity to the purpose and function of the method.
* `to_string` has a single line of unsafe code.  As the associated comment explains, this is provably safe, and exists just to avoid having to choose between having a bunch of duplicate code or inefficiently performing a UTF-8 check on a whole bunch bytes that we already know are safe.  That said, I totally get it if you're just generally against unsafe code and will change it to be an alternative if you so wish
* ToString is implemented instead of Display.  This is to discourage users from directly using this in a println!() or write!() macro, which would not be a thing you would normally expect to do with this.  It also gives us the advantage of being able to pre-allocate a buffer size, meaning less expensive String resizing.
* I couldn't think of a clever way to get `render()` to work with both `io::Write`s or `fmt::Write`s without duplicating the code, but I'm dumb and might be missing something, so if there's a way to do that instead of doing my funky unsafe hack that's cool and I can do that instead.
2020-11-29 23:17:15 -05:00
gemtext Impl ToString for Builder, accept AsRef<[Node]> in `render()` 2020-11-29 23:17:15 -05:00
majc majc: fix redirects 2020-08-08 16:05:13 -04:00
majd start ideas for majd 2020-07-26 17:47:22 -04:00
pilno/karnycukta add CGI support 2020-08-08 11:23:44 -04:00
site oops 2020-08-08 12:14:13 -04:00
src refactor gemtext tools into its own crate 2020-08-08 16:10:20 -04:00
testdata majc: fix rendering of gemlog.blue 2020-07-28 16:02:48 -04:00
.drone.yml fix? 2020-08-06 14:45:48 -04:00
.envrc add basic gemeni response parsing 2020-07-23 22:25:35 -04:00
.gitignore move majsite to its own crate, crate2nix 2020-07-25 21:11:00 -04:00
CHANGELOG.md version bump for gemtext 2020-09-26 19:21:03 -04:00
Cargo.toml version bump for gemtext 2020-09-26 19:21:03 -04:00
LICENSE add basic gemeni response parsing 2020-07-23 22:25:35 -04:00
README.md Update 'README.md' 2020-07-24 12:12:00 +00:00
VERSION version bump for gemtext 2020-09-26 19:21:03 -04:00
shell.nix Remove kindlegen from shell.nix 2020-11-01 22:47:28 +00:00

README.md

maj

A gemini ecosystem for Rust.

Build Status