Skip to content

Commit 8339a2e

Browse files
authored
Merge pull request #1406 from pranjalkole/add-checksum-for-string
glib/functions: add compute_checksum_for_string
2 parents 7b51b72 + 24872f3 commit 8339a2e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

glib/src/functions.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::ptr;
1515
// #[cfg(windows)]
1616
// #[cfg(feature = "v2_58")]
1717
// use std::os::windows::io::AsRawHandle;
18-
use crate::{translate::*, GStr};
18+
use crate::{translate::*, ChecksumType, GStr};
1919
#[cfg(not(windows))]
2020
use crate::{Error, Pid, SpawnFlags};
2121

@@ -222,6 +222,20 @@ pub fn charset() -> (bool, Option<&'static GStr>) {
222222
}
223223
}
224224

225+
#[doc(alias = "g_compute_checksum_for_string")]
226+
pub fn compute_checksum_for_string(
227+
checksum_type: ChecksumType,
228+
str: impl IntoGStr,
229+
) -> Option<crate::GString> {
230+
str.run_with_gstr(|str| unsafe {
231+
from_glib_full(ffi::g_compute_checksum_for_string(
232+
checksum_type.into_glib(),
233+
str.as_ptr(),
234+
str.len() as _,
235+
))
236+
})
237+
}
238+
225239
#[cfg(unix)]
226240
#[doc(alias = "g_unix_open_pipe")]
227241
pub fn unix_open_pipe(flags: i32) -> Result<(RawFd, RawFd), Error> {

0 commit comments

Comments
 (0)