summaryrefslogtreecommitdiffstats
path: root/netwerk/base/rust-url-capi/src/string_utils.rs
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-03-13 10:21:40 +0100
committerwolfbeast <mcwerewolf@gmail.com>2018-03-13 11:55:28 +0100
commita1f143420203395d9a7f347bb232ca86daa40f2b (patch)
tree0b86da1541334bbd760c91a1d652957818a830ba /netwerk/base/rust-url-capi/src/string_utils.rs
parent565bf7514506110a53e37ca686a222527e1ed4e4 (diff)
downloadUXP-a1f143420203395d9a7f347bb232ca86daa40f2b.tar
UXP-a1f143420203395d9a7f347bb232ca86daa40f2b.tar.gz
UXP-a1f143420203395d9a7f347bb232ca86daa40f2b.tar.lz
UXP-a1f143420203395d9a7f347bb232ca86daa40f2b.tar.xz
UXP-a1f143420203395d9a7f347bb232ca86daa40f2b.zip
Remove Rust URL parser CAPI
Part 2 for #58
Diffstat (limited to 'netwerk/base/rust-url-capi/src/string_utils.rs')
-rw-r--r--netwerk/base/rust-url-capi/src/string_utils.rs57
1 files changed, 0 insertions, 57 deletions
diff --git a/netwerk/base/rust-url-capi/src/string_utils.rs b/netwerk/base/rust-url-capi/src/string_utils.rs
deleted file mode 100644
index ae68a60dc..000000000
--- a/netwerk/base/rust-url-capi/src/string_utils.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-extern crate libc;
-use libc::size_t;
-
-extern crate std;
-use std::ptr;
-
-use error_mapping::*;
-
-extern "C" {
- fn c_fn_set_size(user: *mut libc::c_void, size: size_t) -> i32;
- fn c_fn_get_buffer(user: *mut libc::c_void) -> *mut libc::c_char;
-}
-
-pub trait StringContainer {
- fn set_size(&self, size_t) -> i32;
- fn get_buffer(&self) -> *mut libc::c_char;
- fn assign(&self, content: &str) -> i32;
-}
-
-impl StringContainer for *mut libc::c_void {
- fn set_size(&self, size: size_t) -> i32 {
- if (*self).is_null() {
- return NSError::InvalidArg.error_code();
- }
- unsafe {
- c_fn_set_size(*self, size);
- }
-
- return NSError::OK.error_code();
- }
- fn get_buffer(&self) -> *mut libc::c_char {
- if (*self).is_null() {
- return 0 as *mut libc::c_char;
- }
- unsafe {
- c_fn_get_buffer(*self)
- }
- }
- fn assign(&self, content: &str) -> i32 {
- if (*self).is_null() {
- return NSError::InvalidArg.error_code();
- }
-
- unsafe {
- let slice = content.as_bytes();
- c_fn_set_size(*self, slice.len());
- let buf = c_fn_get_buffer(*self);
- if buf.is_null() {
- return NSError::Failure.error_code();
- }
-
- ptr::copy(slice.as_ptr(), buf as *mut u8, slice.len());
- }
-
- NSError::OK.error_code()
- }
-}