2018-07-06 11:27:36 -04:00
|
|
|
// Copyright 2018 Ryan Dahl <ry@tinyclouds.org>
|
|
|
|
// All rights reserved. MIT License.
|
|
|
|
extern crate libc;
|
2018-07-10 14:56:12 -04:00
|
|
|
extern crate url;
|
2018-07-06 11:27:36 -04:00
|
|
|
|
|
|
|
use libc::c_char;
|
|
|
|
use std::ffi::CStr;
|
2018-07-10 14:56:12 -04:00
|
|
|
use url::Url;
|
2018-07-06 11:27:36 -04:00
|
|
|
|
|
|
|
fn string_from_ptr(ptr: *const c_char) -> String {
|
|
|
|
let cstr = unsafe { CStr::from_ptr(ptr as *const i8) };
|
|
|
|
String::from(cstr.to_str().unwrap())
|
|
|
|
}
|
|
|
|
|
2018-07-07 16:50:35 -04:00
|
|
|
#[test]
|
2018-07-10 14:56:12 -04:00
|
|
|
fn test_url() {
|
|
|
|
let issue_list_url = Url::parse("https://github.com/rust-lang").unwrap();
|
|
|
|
assert!(issue_list_url.scheme() == "https");
|
2018-07-07 16:50:35 -04:00
|
|
|
}
|
|
|
|
|
2018-07-06 11:27:36 -04:00
|
|
|
#[no_mangle]
|
|
|
|
pub extern "C" fn handle_code_fetch(
|
2018-07-08 02:45:16 +02:00
|
|
|
cmd_id: u32,
|
2018-07-06 11:27:36 -04:00
|
|
|
module_specifier: *const c_char,
|
|
|
|
containing_file: *const c_char,
|
|
|
|
) {
|
|
|
|
let module_specifier = string_from_ptr(module_specifier);
|
|
|
|
let containing_file = string_from_ptr(containing_file);
|
|
|
|
|
|
|
|
println!(
|
2018-07-08 02:45:16 +02:00
|
|
|
"handle_code_fetch. cmd_id = {} module_specifier = {} containing_file = {}",
|
2018-07-12 18:38:00 -04:00
|
|
|
cmd_id, module_specifier, containing_file
|
2018-07-06 11:27:36 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
unimplemented!();
|
|
|
|
}
|