1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#[cxx::bridge(namespace = "spoa")]
pub mod ffi {
    /// Enumerates the possible alignment types
    #[repr(u32)]
    enum AlignmentType {
        /// Smith-Waterman alignment
        kSW,
        /// Needleman-Wunsch alignment
        kNW,
        /// Overlap alignment
        kOV,
    }

    unsafe extern "C++" {
        include!("spoa-sys/include/bindings.hpp");

        type Alignment;
        type AlignmentEngine;
        type AlignmentType;
        type Graph;

        fn create_graph() -> UniquePtr<Graph>;
        /// # Safety
        /// this function is unsafe because cxx says pointer arguments are unsafe
        unsafe fn add_alignment(
            graph: Pin<&mut Graph>,
            alignment: &Alignment,
            sequence: *const c_char,
            sequence_len: u32,
            quality: *const c_char,
            quality_len: u32,
        );
        fn generate_consensus(graph: Pin<&mut Graph>) -> UniquePtr<CxxString>;
        fn generate_multiple_sequence_alignment(
            graph: Pin<&mut Graph>,
            include_consensus: bool,
        ) -> UniquePtr<CxxVector<CxxString>>;

        fn create_alignment_engine(
            typ: AlignmentType,
            m: i8,
            n: i8,
            g: i8,
            e: i8,
            q: i8,
            c: i8,
        ) -> UniquePtr<AlignmentEngine>;
        /// # Safety
        /// this function is unsafe because cxx says pointer arguments are unsafe
        unsafe fn align(
            alignment_engine: Pin<&mut AlignmentEngine>,
            sequence: *const c_char,
            sequence_len: u32,
            graph: &Graph,
        ) -> UniquePtr<Alignment>;
    }
}