Re: [PATCH v4 4/5] libgit: add higher-level libgit crate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 8, 2024 at 7:19 PM Josh Steadmon <steadmon@xxxxxxxxxx> wrote:
> Wrap `struct config_set` and a few of its associated functions in
> libgit-sys. Also introduce a higher-level "libgit" crate which provides
> a more Rust-friendly interface to config_set structs.
>
> Signed-off-by: Calvin Wan <calvinwan@xxxxxxxxxx>
> Signed-off-by: Josh Steadmon <steadmon@xxxxxxxxxx>
> ---
> diff --git a/contrib/libgit-rs/src/lib.rs b/contrib/libgit-rs/src/lib.rs
> @@ -0,0 +1,95 @@
> +pub struct ConfigSet(*mut libgit_config_set);
> +impl ConfigSet {
> +    pub fn get_int(&mut self, key: &str) -> Option<c_int> {
> +        let key = CString::new(key).expect("Couldn't convert to CString");
> +        let mut val: c_int = 0;
> +        unsafe {
> +            if libgit_configset_get_int(self.0, key.as_ptr(), &mut val as *mut c_int) != 0 {
> +                return None;
> +            }
> +        }
> +        Some(val)
> +    }

Considering that v4 finally gets around to swapping out `CString` for
`String` in order to make this high-level crate more
Rust-programmer-friendly, I was more than a little surprised to see
that this function is still exposing `c_int` rather than, say, `i64`
or such.





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux