librespot/capi/src/artist.rs

26 lines
596 B
Rust
Raw Normal View History

2016-01-26 23:21:57 +00:00
use libc::c_char;
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 = &mut *c_artist;
2016-01-26 23:21:57 +00:00
let name = artist.get()
.map(|metadata| &metadata.name as &str)
.unwrap_or("");
2016-01-26 23:21:57 +00:00
artist.intern(name).as_ptr()
2016-01-26 23:21:57 +00:00
}