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 crate::{translate::*, ChecksumType};
6
7crate::wrapper! {
8 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
9 pub struct Checksum(Boxed<ffi::GChecksum>);
10
11 match fn {
12 copy => |ptr| ffi::g_checksum_copy(ptr),
13 free => |ptr| ffi::g_checksum_free(ptr),
14 type_ => || ffi::g_checksum_get_type(),
15 }
16}
17
18impl Checksum {
19 #[doc(alias = "g_checksum_new")]
20 pub fn new(checksum_type: ChecksumType) -> Option<Checksum> {
21 unsafe { from_glib_full(ffi::g_checksum_new(checksum_type.into_glib())) }
22 }
23
24 #[doc(alias = "g_checksum_reset")]
25 pub fn reset(&mut self) {
26 unsafe {
27 ffi::g_checksum_reset(self.to_glib_none_mut().0);
28 }
29 }
30
31 #[doc(alias = "g_checksum_update")]
32 pub fn update(&mut self, data: &[u8]) {
33 let length = data.len() as _;
34 unsafe {
35 ffi::g_checksum_update(self.to_glib_none_mut().0, data.to_glib_none().0, length);
36 }
37 }
38
39 #[doc(alias = "g_checksum_type_get_length")]
40 pub fn type_get_length(checksum_type: ChecksumType) -> isize {
41 unsafe { ffi::g_checksum_type_get_length(checksum_type.into_glib()) }
42 }
43}
44
45unsafe impl Send for Checksum {}
46unsafe impl Sync for Checksum {}
47