OWissett / freesasa-rs

A rust crate to interface with the freesasa library for protein surface area calculations
https://crates.io/crates/freesasa-rs
Other
6 stars 1 forks source link

Replace Bitfields #1

Open OWissett opened 1 year ago

OWissett commented 1 year ago

In C it is common for functions to take bit fields to specify options. This is not very good practice in Rust.

E.g.

In structure.rs, you will find:

pub fn from_path(
        pdb_path: &str,
        options: Option<raw::c_int>,
    ) -> Result<Structure, &'static str> {
             ...
}

This takes an optional c_int value, which represents a bit field. This should be replaced with a function that simply has the function parameters in it. These parameters will need to be converted to the correct bit field, which is then given to this function.

In this example, the program calls the C-API function freesasa_structure_from_pdb.

See: https://freesasa.github.io/doxygen/group__structure.html#gacb6a13014452a7c3501fa7661d197f47

OWissett commented 1 year ago

Have a look around the code to see if there are other examples of this

asinineAbbreviations commented 1 year ago

Have a look around the code to see if there are other examples of this

Should I look at structure.rs specifically, or other Rust files within freesasa-rs as well?

OWissett commented 1 year ago

Start at this one, but have a look to see if you can see any other bit fields

OWissett commented 1 year ago

@asinineAbbreviations this is probably the ticket you want to start with. Its probably one of the easier tickets

OWissett commented 1 year ago

I good way of doing this would be to create an enum which can be converted directly to the freesasa-sys types