aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.rs
Commit message (Collapse)AuthorAge
* fix infinite recursionDirk Van Haerenborgh2018-03-20
|
* fix some compiler warning regarding opaque structsDirk Van Haerenborgh2018-03-20
|
* Add `NewFromPtr` trait.C. Morgan Hamill2015-03-27
| | | | Crate-private utility trait for `new()` methods on types.
* Remove `NotmuchType` trait.C. Morgan Hamill2015-03-26
| | | | No longer necessary with the `From` and `Into` traits from std::convert.
* Make `ToCString` trait use std::convert traits.C. Morgan Hamill2015-03-26
| | | | Use `AsRef<Path>` instead of `AsOsStr`.
* Remove `ToStaticStr` trait.C. Morgan Hamill2015-03-24
| | | | | Changes in commit 95d4fba8436417a6c27522ed9b51c19a9fd7c6f9 make the trait unnecessary. The `ToStr` trait is now sufficient.
* Rename `NotmuchEnum` trait to `NotmuchType`.C. Morgan Hamill2015-03-24
| | | | Turns out to be useful outside of just enums.
* Make `to_str()` method generic over lifetime.C. Morgan Hamill2015-03-20
| | | | | | | | | | | | | | | | If I have this correct: The output `&str` will have the same lifetime as whatever the lifetime of the block in which it is called. This allows using it one the output of notmuch FFI calls, by propogating the lifetime of the safe wrapper object (e.g., `Database`) to the `&str` returned from `to_str()`. This mirrors the lifetime of the actual underlying C string. If I don't grok lifetimes as well as I think, this could be a lie. Future self: you should add unit tests to test the above explanation.
* Add `ToCString` trait.C. Morgan Hamill2015-03-20
| | | | | | | | Allows easy conversion of any `T: AsOsStr` to a `CString`, whose `as_ptr()` method is quite convenient for FFI calls. Note that `std::path::Path` implements `AsOsStr`, which means we can easily take paths and get a pointer to `*const libc::c_char`.
* Add `ToStr` and `ToStaticStr` traits.C. Morgan Hamill2015-03-20
| | | | | | | | Allow easy mapping of borrowed C strings to borrowed strings with appropriate lifetimes. I have some doubts about this, as I'm not 100% on how lifetimes interact with the notmuch-provided strings yet.
* Add `NotmuchEnum` trait and `notmuch_enum!` macro.C. Morgan Hamill2015-03-19
Implements enum types in pairs, specifying the type and variant names of each, like so: notmuch_enum! { pub enum enum_name => EnumName { variant_one => VariantOne, variant_two => VariantTwo } } Which expands to: pub enum enum_name { variant_one, variant_two } pub enum EnumName { VariantOne, VariantTwo } The `NotmuchEnum` trait also entails two functions to convert between the defined pairs, `from_notmuch_t()` and `to_notmuch_t()`. The macro takes care of their implementation, also. Yes, this is purely aesthetic whimsy: I wanted the types in the `ffi` module to match the types from the `notmuch.h` file, and I wanted the types I used within (and exported by) this crate to match the expected Rust convention.