-
Notifications
You must be signed in to change notification settings - Fork 16
fix: return types in ffi #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
impl AsRef<str> for ada_string { | ||
fn as_ref(&self) -> &str { | ||
impl ada_string { | ||
pub fn as_str(self) -> &'static str { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is internal API, and the lifetime of &str
is aligned with ada_url
, so it's safe to mark it as 'static
here
} | ||
} | ||
|
||
pub fn parse<U: AsRef<str>>(url: U) -> Result<Url, Error> { | ||
let url_with_0_terminate = std::ffi::CString::new(url.as_ref()).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need a parse(char* string, size_t length)
API in ada
to avoid memory copy here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the Rust &str
is not the null-terminated
@@ -8,7 +8,7 @@ fn main() { | |||
let mut build = cc::Build::new(); | |||
build | |||
.file("./deps/ada.cpp") | |||
.file("./deps/ada.h") | |||
.include("./deps/ada.h") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is the root cause of the linking error
No description provided.