Skip to content

Commit

Permalink
#138 #140 Make the utils functions as pub (crate) to avoid confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
astonbitecode committed Dec 6, 2024
1 parent 5535fc9 commit 7c9199f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions rust/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,36 @@ use crate::api::{
};
use crate::{cache, errors, InvocationArg, JavaClass};

pub unsafe fn to_rust_string(pointer: *const c_char) -> errors::Result<String> {
pub(crate) unsafe fn to_rust_string(pointer: *const c_char) -> errors::Result<String> {
let slice = CStr::from_ptr(pointer).to_bytes();
Ok(from_java_cesu8(slice)?.to_string())
}

pub fn to_c_string(string: &str) -> *mut c_char {
pub(crate) fn to_c_string(string: &str) -> *mut c_char {
let cs = CString::new(string.as_bytes()).unwrap();
cs.into_raw()
}

pub fn to_c_string_struct(string: &str) -> CString {
pub(crate) fn to_c_string_struct(string: &str) -> CString {
let enc = to_java_cesu8(string).into_owned();
unsafe { CString::from_vec_unchecked(enc) }
}

pub unsafe fn drop_c_string(ptr: *mut c_char) {
pub(crate) unsafe fn drop_c_string(ptr: *mut c_char) {
let _ = CString::from_raw(ptr);
}

#[cfg(not(target_os = "windows"))]
pub fn classpath_sep() -> &'static str {
pub(crate) fn classpath_sep() -> &'static str {
":"
}

#[cfg(target_os = "windows")]
pub fn classpath_sep() -> &'static str {
pub(crate) fn classpath_sep() -> &'static str {
";"
}

pub fn java_library_path() -> errors::Result<String> {
pub(crate) fn java_library_path() -> errors::Result<String> {
let default = format!("-Djava.library.path={}", deps_dir()?);
if cfg!(windows) {
Ok(default)
Expand Down

0 comments on commit 7c9199f

Please sign in to comment.