houqp / leptess

Productive and safe Rust binding for leptonica and tesseract
https://houqp.github.io/leptess/leptess/index.html
MIT License
259 stars 29 forks source link

Switch to plumbing crate #35

Closed ccouzens closed 3 years ago

ccouzens commented 3 years ago

Switch to being based off the plumbing crate

git diff origin/HEAD --stat
 Cargo.toml                             |   3 +-
 examples/low_level_ocr_word_by_word.rs |   4 +-
 src/capi.rs                            |   7 +-
 src/leptonica.rs                       | 170 +++++++++-----------------------
 src/lib.rs                             |  22 ++---
 src/tesseract.rs                       | 230 ++++++++++++++-----------------------------
 tests/full_page_ocr.rs                 |  24 ++---
 7 files changed, 143 insertions(+), 317 deletions(-)

by switching to being built on the plumbing crate, we

  1. Remove a lot of code from leptess
  2. Remove the unsafe keyword from leptess
  3. Will more quickly be able to roll out new features like setvariable

There are some small changes to the API, mostly around some methods now requiring mut. As this isn't yet version 1.0.0, semantic versioning will allow us to break the API. But maybe once this is merged and the next few feature requests are dealt with, it will be time to have the version 1.0.0 release.

The other major API change is around leptonica's Box. I think it was previously sometimes incorrectly wrapping the struct when it only had a borrowed reference (the issue being the drop trait might have freed it prematurely). I've introduced a BorrowedBox in leptonica-plumbing, and made leptess's Box struct generic over the two types.

The examples and the tests barely changing show that the API changes are minor.

https://github.com/houqp/leptess/issues/34

ccouzens commented 3 years ago

looks like we can reexport Boxa as well?

We'd lose the Iterator trait if we went with the plumbing Boxa.

It crossed my mind that maybe instead of exposing Boxa we could read the values into a Vec. But I think exposing Boxa is fine.