glib/auto/
checksum.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use glib_sys;
6use translate::*;
7use ChecksumType;
8
9glib_wrapper! {
10    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
11    pub struct Checksum(Boxed<glib_sys::GChecksum>);
12
13    match fn {
14        copy => |ptr| glib_sys::g_checksum_copy(mut_override(ptr)),
15        free => |ptr| glib_sys::g_checksum_free(ptr),
16        get_type => || glib_sys::g_checksum_get_type(),
17    }
18}
19
20impl Checksum {
21    pub fn new(checksum_type: ChecksumType) -> Checksum {
22        unsafe { from_glib_full(glib_sys::g_checksum_new(checksum_type.to_glib())) }
23    }
24
25    pub fn reset(&mut self) {
26        unsafe {
27            glib_sys::g_checksum_reset(self.to_glib_none_mut().0);
28        }
29    }
30
31    pub fn update(&mut self, data: &[u8]) {
32        let length = data.len() as isize;
33        unsafe {
34            glib_sys::g_checksum_update(self.to_glib_none_mut().0, data.to_glib_none().0, length);
35        }
36    }
37
38    pub fn type_get_length(checksum_type: ChecksumType) -> isize {
39        unsafe { glib_sys::g_checksum_type_get_length(checksum_type.to_glib()) }
40    }
41}
42
43unsafe impl Send for Checksum {}
44unsafe impl Sync for Checksum {}