mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
34 lines
731 B
Rust
34 lines
731 B
Rust
|
use libc::c_char;
|
||
|
use std::ffi::CString;
|
||
|
use std::mem;
|
||
|
|
||
|
use librespot::metadata::Artist;
|
||
|
|
||
|
use metadata::SpMetadata;
|
||
|
|
||
|
#[allow(non_camel_case_types)]
|
||
|
pub type sp_artist = SpMetadata<Artist>;
|
||
|
|
||
|
#[no_mangle]
|
||
|
pub unsafe extern "C" fn sp_artist_is_loaded(c_artist: *mut sp_artist) -> bool {
|
||
|
let artist = &*c_artist;
|
||
|
artist.is_loaded()
|
||
|
}
|
||
|
|
||
|
#[no_mangle]
|
||
|
pub unsafe extern "C" fn sp_artist_name(c_artist: *mut sp_artist) -> *const c_char {
|
||
|
let artist = &*c_artist;
|
||
|
|
||
|
let name = artist.get()
|
||
|
.map(|metadata| metadata.name.clone())
|
||
|
.unwrap_or("".to_owned());
|
||
|
|
||
|
let name = CString::new(name).unwrap();
|
||
|
let c_name = name.as_ptr();
|
||
|
|
||
|
// FIXME
|
||
|
mem::forget(name);
|
||
|
|
||
|
c_name
|
||
|
}
|