Commit 78c41fd96d45c58d91a8ed00e7f50891561b7859

Cléo Rebert 2023-09-11T10:46:57

Add docs and changelog Signed-off-by: Cléo Rebert <cleo.rebert@gmail.com>

diff --git a/qrcodegen-image/CHANGELOG.md b/qrcodegen-image/CHANGELOG.md
new file mode 100644
index 0000000..2f299da
--- /dev/null
+++ b/qrcodegen-image/CHANGELOG.md
@@ -0,0 +1,18 @@
+# Changelog
+
+## [1.1.0](https://github.com/constantoine/totp-rs/releases/tag/qrcodegen-image%2Fv1.1.0) (11/09/2023)
+
+### What's new
+
+- Added documentation for `draw_png` and `draw_base64`.
+- Add changelog.
+
+## [1.0.0](https://github.com/constantoine/totp-rs/releases/tag/qrcodegen-image%2Fv1.0.0) (10/09/2023)
+
+### What's new
+
+- Creation of a new `qrcodegen-image` subcrate to handle image creation, as the wrapper is actually nice and could be used in placed not related to `totp-rs`. (#61)
+
+### Special thanks
+
+- [@tmpfs](https://github.com/tmpfs) for their work on #60 and implementation in #61.
diff --git a/qrcodegen-image/Cargo.toml b/qrcodegen-image/Cargo.toml
index 5bcb45a..e9d8703 100644
--- a/qrcodegen-image/Cargo.toml
+++ b/qrcodegen-image/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "qrcodegen-image"
-version = "1.0.0"
+version = "1.1.0"
 edition = "2021"
 authors = ["Cleo Rebert <cleo.rebert@gmail.com>"]
 rust-version = "1.61"
diff --git a/qrcodegen-image/src/lib.rs b/qrcodegen-image/src/lib.rs
index b37eac4..6ab8552 100644
--- a/qrcodegen-image/src/lib.rs
+++ b/qrcodegen-image/src/lib.rs
@@ -47,6 +47,14 @@ pub fn draw_canvas(qr: qrcodegen::QrCode) -> image::ImageBuffer<Luma<u8>, Vec<u8
 }
 
 /// Draw text to a PNG QR code.
+///     
+/// # Errors
+///
+/// This will return an error in case the URL gets too long to encode into a QR code.
+/// This would require the get_url method to generate an url bigger than 2000 characters,
+/// Which would be too long for some browsers anyway.
+///
+/// It will also return an error in case it can't encode the qr into a png. This shouldn't happen unless either the qrcode library returns malformed data, or the image library doesn't encode the data correctly.
 pub fn draw_png(text: &str) -> Result<Vec<u8>, String> {
     use image::ImageEncoder;
 
@@ -84,6 +92,14 @@ pub fn draw_png(text: &str) -> Result<Vec<u8>, String> {
 }
 
 /// Draw text to a Base64-encoded PNG QR code.
+///
+/// # Errors
+///
+/// This will return an error in case the URL gets too long to encode into a QR code.
+/// This would require the get_url method to generate an url bigger than 2000 characters,
+/// Which would be too long for some browsers anyway.
+///
+/// It will also return an error in case it can't encode the qr into a png. This shouldn't happen unless either the qrcode library returns malformed data, or the image library doesn't encode the data correctly.
 #[cfg(feature = "base64")]
 pub fn draw_base64(text: &str) -> Result<String, String> {
     use base64::{engine::general_purpose, Engine as _};