plantuml_encoding
Encoding and decoding text plantuml diagrams to facilitate communication of them through URL.
Overview
Consider the next plain text plantuml diagram:
@startuml
PUML -> RUST: HELLO
@enduml
It can be encoded to 0IO0sVz0StHXSdHrRMmAK5LDJ20jFY1ILLDKEY18HKnCJo0AG6LkP7LjR000
and with the help of the plantuml server (https://www.plantuml.com/plantuml/uml/
) it can be shared through URL.
Also, it can be decoded in the opposite direction.
Plantuml declares support for the following compression algorithms:
But in fact, plantuml supports only deflate
(with additional transformations close to base64) and hex
(with additional prefix ~h
). brotli
is turned off. So the crate supports only deflate
and hex
too.
Installation
In order to use this crate, you have to add it under [dependencies]
to your Cargo.toml
:
[]
= "2.0.3"
Article
There is an article very close describing the library under the hood.
Examples
use ;
And console output after cargo run
for these examples:
Original puml:
@startuml
PUML -> RUST
@enduml
Encoded deflate: SoWkIImgAStDuGe8zVLHqBLJ20eD3k5oICrB0Ge20000
Decoded deflate:
@startuml
PUML -> RUST
@enduml
Encoded hex: ~h407374617274756d6c0a50554d4c202d3e20525553540a40656e64756d6c
Decoded hex:
@startuml
PUML -> RUST
@enduml
Decoded deflate error:
It's not decoded deflate
Decoded deflate error: "there is a problem during deflate decoding: `deflate decompression error`"
Match decoded deflate error result:
Result from deflate error
Decoded hex error: "there is a problem during hex decoding: `Odd number of digits`"
Match decoded hex error result:
Result from hex error
Also, you can consider tests inside the files.