This clears the way to start working on making the functions safe.
But small PRs are good PRs so let's get this rename out of the way and
have future PRs less noisy.
Also stop making this #[repr(C)] and start making fields that are not
used private. Lastly clean up some comments by moving them or
deleting them, so they make sense again after the translation.
This makes interactively running the tests a much more pleasant
experience rather than something one dreads. These tests will still
be run on the CI. To run these manually run:
cargo test [TESTNAME] -- --ignored
With the API changes already done, notably .is_open(), the
implementation of the sqlite can and should now be private.
This also doesn't need to be #[repr(C)] anymore since the C API does
not need to access the fields in the struct.
Experiment with refactoring the internal sql interface a bit. My
original goal was to modify the schema and thus refactor to a state
where it would be sane to write tests for dc_sqlite_open() (and/or
however it ends up refactored) to assert schame changes before/after.
The C API allows passing a NULL pointer is for the callback function.
However when calling the callback nothing checks for this null pointer
and thus things fail badly. Even worse since the C API is defined
using an "fn pointer" rather than a "*-ptr" or raw pointer to the
function rust does not realise this can be invalid and therefore the
typechecker does not catch this even though there are no unsafe casts.
Fix this by making the callback an Option in rust, this can be easily
checked when calling. Also add a Context.call_cb() function which
simplifies calling the callback, hides the weird syntax due to the
function pointer and makes the call a little easier. Finally it also
means the option checking is only needed in one place.
For the C API this needs to check if this is a NULL pointer or not,
this is implicitly done by rust using the "nullable pointer
optimisation":
https://doc.rust-lang.org/nomicon/ffi.html#the-nullable-pointer-optimization
This stops using the deprecated libc::uint32_t and libc::uint64_t
types in favour of the native u32 and u64 types.
It also uses a newer nightly compiler to get rid of the incorrect
"unused no_mangle" warning when compiling incrementally.
Finally the newer compiler prefers us to be explicit when implementing
traits using the new dyn keyword.
* Add utility to convert OsStr to CString
This is approach seems acceptable in the context of deltachat, it
should work correctly on unix and on Windows requires paths to be
valid utf-8.
* Use failure crate for error types
* Add OsStrExt impl for Path, fix windows and update docs
- Adds an OsStrExt impl for Path directly, a little more convenience.
- Fix the windows code to actually use the right function name. Test
the impl function on unix too since that was the point of having it
implemented in a separate function to begin with.
- Improve the docs, do hyperlinks a bit better.
* Another attempt at learing to type
Having your compiler in the cloud is just painful.
* Do not treat this as a fatal error
When PRs are made from forks the passwords are unavailable. We don't
want CI to fail because of this.
* Implement using the AsRef<OsStr> trait
This means any type with implements this trait will get this
implementation, thus covering both OsStr and Path instead of having
duplicate implementations for those like before.
* fix format
The function does a cast and does not create a new objects. The
stdlib convention is to use to_*() for functions which return new
objects and as_*() for functions which keep referring to the same data
but using a different type. Follow that convention.