musikr: reformat

This commit is contained in:
Alexander Capehart 2025-02-15 16:02:55 -07:00
parent b45e41bc3b
commit c8d645c282
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
14 changed files with 128 additions and 105 deletions

View file

@ -1,7 +1,7 @@
use crate::taglib::iostream::IOStream; use crate::taglib::iostream::IOStream;
use crate::SharedEnv;
use jni::objects::{JObject, JValue}; use jni::objects::{JObject, JValue};
use std::io::{Read, Seek, SeekFrom, Write}; use std::io::{Read, Seek, SeekFrom, Write};
use crate::SharedEnv;
pub struct JInputStream<'local> { pub struct JInputStream<'local> {
env: SharedEnv<'local>, env: SharedEnv<'local>,
@ -9,10 +9,7 @@ pub struct JInputStream<'local> {
} }
impl<'local, 'a> JInputStream<'local> { impl<'local, 'a> JInputStream<'local> {
pub fn new( pub fn new(env: SharedEnv<'local>, input: JObject<'local>) -> Self {
env: SharedEnv<'local>,
input: JObject<'local>,
) -> Self {
Self { env, input } Self { env, input }
} }
} }

View file

@ -1,14 +1,14 @@
use std::cell::RefCell;
use std::rc::Rc;
use jni::objects::{JClass, JObject}; use jni::objects::{JClass, JObject};
use jni::sys::jstring; use jni::sys::jstring;
use jni::JNIEnv; use jni::JNIEnv;
use std::cell::RefCell;
use std::rc::Rc;
mod taglib;
mod jstream; mod jstream;
mod taglib;
use taglib::file_ref::FileRef;
use jstream::JInputStream; use jstream::JInputStream;
use taglib::file_ref::FileRef;
type SharedEnv<'local> = Rc<RefCell<JNIEnv<'local>>>; type SharedEnv<'local> = Rc<RefCell<JNIEnv<'local>>>;
@ -52,6 +52,9 @@ pub extern "C" fn Java_org_oxycblt_musikr_metadata_MetadataJNI_openFile<'local>(
}); });
// Return the title // Return the title
let output = shared_env.borrow_mut().new_string("title").expect("Couldn't create string!"); let output = shared_env
.borrow_mut()
.new_string("title")
.expect("Couldn't create string!");
output.into_raw() output.into_raw()
} }

View file

@ -2,7 +2,7 @@ use super::bridge::CppAudioProperties;
use std::pin::Pin; use std::pin::Pin;
pub struct AudioProperties<'file_ref> { pub struct AudioProperties<'file_ref> {
this: Pin<&'file_ref CppAudioProperties> this: Pin<&'file_ref CppAudioProperties>,
} }
impl<'file_ref> AudioProperties<'file_ref> { impl<'file_ref> AudioProperties<'file_ref> {

View file

@ -105,7 +105,9 @@ mod bridge_impl {
#[cxx_name = "PictureList"] #[cxx_name = "PictureList"]
type CPPPictureList; type CPPPictureList;
#[namespace = "taglib_shim"] #[namespace = "taglib_shim"]
fn PictureList_to_vector(list: Pin<&CPPPictureList>) -> UniquePtr<CxxVector<CPPFLACPicturePointer>>; fn PictureList_to_vector(
list: Pin<&CPPPictureList>,
) -> UniquePtr<CxxVector<CPPFLACPicturePointer>>;
#[namespace = "taglib_shim"] #[namespace = "taglib_shim"]
#[cxx_name = "PicturePointer"] #[cxx_name = "PicturePointer"]
@ -136,7 +138,7 @@ mod bridge_impl {
#[cxx_name = "XiphComment"] #[cxx_name = "XiphComment"]
type CPPXiphComment; type CPPXiphComment;
#[cxx_name = "fieldListMap"] #[cxx_name = "fieldListMap"]
fn fieldListMap(self: Pin<& CPPXiphComment>) -> &CPPFieldListMap; fn fieldListMap(self: Pin<&CPPXiphComment>) -> &CPPFieldListMap;
#[namespace = "TagLib"] #[namespace = "TagLib"]
#[cxx_name = "SimplePropertyMap"] #[cxx_name = "SimplePropertyMap"]
@ -164,7 +166,9 @@ mod bridge_impl {
#[cxx_name = "FrameList"] #[cxx_name = "FrameList"]
type CPPID3v2FrameList; type CPPID3v2FrameList;
#[namespace = "taglib_shim"] #[namespace = "taglib_shim"]
fn FrameList_to_vector(list: Pin<&CPPID3v2FrameList>) -> UniquePtr<CxxVector<CPPFramePointer>>; fn FrameList_to_vector(
list: Pin<&CPPID3v2FrameList>,
) -> UniquePtr<CxxVector<CPPFramePointer>>;
#[namespace = "taglib_shim"] #[namespace = "taglib_shim"]
#[cxx_name = "FramePointer"] #[cxx_name = "FramePointer"]
@ -175,30 +179,41 @@ mod bridge_impl {
#[cxx_name = "Frame"] #[cxx_name = "Frame"]
type CPPID3v2Frame; type CPPID3v2Frame;
#[namespace = "taglib_shim"] #[namespace = "taglib_shim"]
unsafe fn Frame_asTextIdentification(frame: *const CPPID3v2Frame) -> *const CPPID3v2TextIdentificationFrame; unsafe fn Frame_asTextIdentification(
frame: *const CPPID3v2Frame,
) -> *const CPPID3v2TextIdentificationFrame;
#[namespace = "taglib_shim"] #[namespace = "taglib_shim"]
unsafe fn Frame_asUserTextIdentification(frame: *const CPPID3v2Frame) -> *const CPPID3v2UserTextIdentificationFrame; unsafe fn Frame_asUserTextIdentification(
frame: *const CPPID3v2Frame,
) -> *const CPPID3v2UserTextIdentificationFrame;
#[namespace = "taglib_shim"] #[namespace = "taglib_shim"]
unsafe fn Frame_asAttachedPicture(frame: *const CPPID3v2Frame) -> *const CPPID3v2AttachedPictureFrame; unsafe fn Frame_asAttachedPicture(
frame: *const CPPID3v2Frame,
) -> *const CPPID3v2AttachedPictureFrame;
#[namespace = "TagLib::ID3v2"] #[namespace = "TagLib::ID3v2"]
#[cxx_name = "TextIdentificationFrame"] #[cxx_name = "TextIdentificationFrame"]
type CPPID3v2TextIdentificationFrame; type CPPID3v2TextIdentificationFrame;
#[namespace = "taglib_shim"] #[namespace = "taglib_shim"]
fn TextIdentificationFrame_fieldList(frame: Pin<&CPPID3v2TextIdentificationFrame>) -> UniquePtr<CPPStringList>; fn TextIdentificationFrame_fieldList(
frame: Pin<&CPPID3v2TextIdentificationFrame>,
) -> UniquePtr<CPPStringList>;
#[namespace = "TagLib::ID3v2"] #[namespace = "TagLib::ID3v2"]
#[cxx_name = "UserTextIdentificationFrame"] #[cxx_name = "UserTextIdentificationFrame"]
type CPPID3v2UserTextIdentificationFrame; type CPPID3v2UserTextIdentificationFrame;
#[namespace = "taglib_shim"] #[namespace = "taglib_shim"]
fn UserTextIdentificationFrame_fieldList(frame: Pin<&CPPID3v2UserTextIdentificationFrame>) -> UniquePtr<CPPStringList>; fn UserTextIdentificationFrame_fieldList(
frame: Pin<&CPPID3v2UserTextIdentificationFrame>,
) -> UniquePtr<CPPStringList>;
#[namespace = "TagLib::ID3v2"] #[namespace = "TagLib::ID3v2"]
#[cxx_name = "AttachedPictureFrame"] #[cxx_name = "AttachedPictureFrame"]
type CPPID3v2AttachedPictureFrame; type CPPID3v2AttachedPictureFrame;
#[namespace = "taglib_shim"] #[namespace = "taglib_shim"]
fn AttachedPictureFrame_picture(frame: Pin<&CPPID3v2AttachedPictureFrame>) -> UniquePtr<CPPByteVector>; fn AttachedPictureFrame_picture(
frame: Pin<&CPPID3v2AttachedPictureFrame>,
) -> UniquePtr<CPPByteVector>;
#[namespace = "TagLib"] #[namespace = "TagLib"]
#[cxx_name = "String"] #[cxx_name = "String"]
@ -210,7 +225,9 @@ mod bridge_impl {
#[cxx_name = "StringList"] #[cxx_name = "StringList"]
type CPPStringList; type CPPStringList;
#[namespace = "taglib_shim"] #[namespace = "taglib_shim"]
fn StringList_to_vector(string_list: Pin<&CPPStringList>) -> UniquePtr<CxxVector<CPPString>>; fn StringList_to_vector(
string_list: Pin<&CPPStringList>,
) -> UniquePtr<CxxVector<CPPString>>;
#[namespace = "TagLib"] #[namespace = "TagLib"]
#[cxx_name = "ByteVector"] #[cxx_name = "ByteVector"]

View file

@ -1,14 +1,14 @@
use std::pin::Pin;
use super::bridge::{self, CPPFile, CPPMPEGFile};
use super::audioproperties::AudioProperties; use super::audioproperties::AudioProperties;
use super::bridge::{self, CPPFile, CPPMPEGFile};
use super::flac::FLACFile;
use super::id3v2::ID3v2Tag;
use super::mpeg::MPEGFile; use super::mpeg::MPEGFile;
use super::ogg::OpusFile; use super::ogg::OpusFile;
use super::ogg::VorbisFile; use super::ogg::VorbisFile;
use super::flac::FLACFile; use std::pin::Pin;
use super::id3v2::ID3v2Tag;
pub struct File<'file_ref> { pub struct File<'file_ref> {
this: Pin<&'file_ref mut CPPFile> this: Pin<&'file_ref mut CPPFile>,
} }
impl<'file_ref> File<'file_ref> { impl<'file_ref> File<'file_ref> {

View file

@ -1,14 +1,14 @@
pub use super::bridge::CPPFLACFile; pub use super::bridge::CPPFLACFile;
pub use super::bridge::CPPFLACPicture; pub use super::bridge::CPPFLACPicture;
pub use super::xiph::XiphComment; use super::bridge::{CPPPictureList, FLACFile_pictureList, PictureList_to_vector, Picture_data};
use super::bridge::{CPPPictureList, PictureList_to_vector, FLACFile_pictureList, Picture_data};
use super::tk::ByteVector; use super::tk::ByteVector;
use std::marker::PhantomData; pub use super::xiph::XiphComment;
use cxx::UniquePtr; use cxx::UniquePtr;
use std::marker::PhantomData;
use std::pin::Pin; use std::pin::Pin;
pub struct FLACFile<'file_ref> { pub struct FLACFile<'file_ref> {
this: Pin<&'file_ref mut CPPFLACFile> this: Pin<&'file_ref mut CPPFLACFile>,
} }
impl<'file_ref> FLACFile<'file_ref> { impl<'file_ref> FLACFile<'file_ref> {
@ -44,7 +44,10 @@ pub struct PictureList<'file_ref> {
impl<'file_ref> PictureList<'file_ref> { impl<'file_ref> PictureList<'file_ref> {
pub(super) fn new(this: UniquePtr<CPPPictureList>) -> Self { pub(super) fn new(this: UniquePtr<CPPPictureList>) -> Self {
Self { _data: PhantomData, this } Self {
_data: PhantomData,
this,
}
} }
pub fn to_vec(&self) -> Vec<Picture<'file_ref>> { pub fn to_vec(&self) -> Vec<Picture<'file_ref>> {
@ -71,7 +74,7 @@ impl<'file_ref> PictureList<'file_ref> {
} }
pub struct Picture<'file_ref> { pub struct Picture<'file_ref> {
this: Pin<&'file_ref CPPFLACPicture> this: Pin<&'file_ref CPPFLACPicture>,
} }
impl<'file_ref> Picture<'file_ref> { impl<'file_ref> Picture<'file_ref> {

View file

@ -1,14 +1,14 @@
use super::bridge::{ use super::bridge::{
self, CPPID3v2Frame, CPPID3v2TextIdentificationFrame, self, CPPID3v2AttachedPictureFrame, CPPID3v2Frame, CPPID3v2FrameList, CPPID3v2Tag,
CPPID3v2UserTextIdentificationFrame, CPPID3v2AttachedPictureFrame, CPPID3v2Tag, CPPID3v2FrameList CPPID3v2TextIdentificationFrame, CPPID3v2UserTextIdentificationFrame,
}; };
use super::tk::{ByteVector, StringList}; use super::tk::{ByteVector, StringList};
use std::pin::Pin;
use std::marker::PhantomData;
use cxx::UniquePtr; use cxx::UniquePtr;
use std::marker::PhantomData;
use std::pin::Pin;
pub struct ID3v2Tag<'file_ref> { pub struct ID3v2Tag<'file_ref> {
this: Pin<&'file_ref CPPID3v2Tag> this: Pin<&'file_ref CPPID3v2Tag>,
} }
impl<'file_ref> ID3v2Tag<'file_ref> { impl<'file_ref> ID3v2Tag<'file_ref> {
@ -24,28 +24,34 @@ impl<'file_ref> ID3v2Tag<'file_ref> {
pub struct FrameList<'file_ref> { pub struct FrameList<'file_ref> {
_data: PhantomData<&'file_ref CPPID3v2FrameList>, _data: PhantomData<&'file_ref CPPID3v2FrameList>,
this: UniquePtr<CPPID3v2FrameList> this: UniquePtr<CPPID3v2FrameList>,
} }
impl<'file_ref> FrameList<'file_ref> { impl<'file_ref> FrameList<'file_ref> {
pub(super) fn new(this: UniquePtr<CPPID3v2FrameList>) -> Self { pub(super) fn new(this: UniquePtr<CPPID3v2FrameList>) -> Self {
Self { _data: PhantomData, this } Self {
_data: PhantomData,
this,
}
} }
pub fn to_vec(&self) -> Vec<Frame<'file_ref>> { pub fn to_vec(&self) -> Vec<Frame<'file_ref>> {
let this = unsafe { Pin::new_unchecked(self.this.as_ref().unwrap()) }; let this = unsafe { Pin::new_unchecked(self.this.as_ref().unwrap()) };
let frames = bridge::FrameList_to_vector(this); let frames = bridge::FrameList_to_vector(this);
frames.iter().map(|frame| { frames
.iter()
.map(|frame| {
let frame_ptr = frame.get(); let frame_ptr = frame.get();
let frame_ref = unsafe { frame_ptr.as_ref().unwrap() }; let frame_ref = unsafe { frame_ptr.as_ref().unwrap() };
let frame_pin = unsafe { Pin::new_unchecked(frame_ref) }; let frame_pin = unsafe { Pin::new_unchecked(frame_ref) };
Frame::new(frame_pin) Frame::new(frame_pin)
}).collect() })
.collect()
} }
} }
pub struct Frame<'file_ref> { pub struct Frame<'file_ref> {
this: Pin<&'file_ref CPPID3v2Frame> this: Pin<&'file_ref CPPID3v2Frame>,
} }
impl<'file_ref> Frame<'file_ref> { impl<'file_ref> Frame<'file_ref> {
@ -54,27 +60,23 @@ impl<'file_ref> Frame<'file_ref> {
} }
pub fn as_text_identification(&mut self) -> Option<TextIdentificationFrame<'file_ref>> { pub fn as_text_identification(&mut self) -> Option<TextIdentificationFrame<'file_ref>> {
let frame = unsafe { let frame = unsafe { bridge::Frame_asTextIdentification(self.this.as_ref().get_ref()) };
bridge::Frame_asTextIdentification(self.this.as_ref().get_ref())
};
let frame_ref = unsafe { frame.as_ref() }; let frame_ref = unsafe { frame.as_ref() };
let frame_pin = frame_ref.map(|frame| unsafe { Pin::new_unchecked(frame) }); let frame_pin = frame_ref.map(|frame| unsafe { Pin::new_unchecked(frame) });
frame_pin.map(|frame| TextIdentificationFrame::new(frame)) frame_pin.map(|frame| TextIdentificationFrame::new(frame))
} }
pub fn as_user_text_identification(&mut self) -> Option<UserTextIdentificationFrame<'file_ref>> { pub fn as_user_text_identification(
let frame = unsafe { &mut self,
bridge::Frame_asUserTextIdentification(self.this.as_ref().get_ref()) ) -> Option<UserTextIdentificationFrame<'file_ref>> {
}; let frame = unsafe { bridge::Frame_asUserTextIdentification(self.this.as_ref().get_ref()) };
let frame_ref = unsafe { frame.as_ref() }; let frame_ref = unsafe { frame.as_ref() };
let frame_pin = frame_ref.map(|frame| unsafe { Pin::new_unchecked(frame) }); let frame_pin = frame_ref.map(|frame| unsafe { Pin::new_unchecked(frame) });
frame_pin.map(|frame| UserTextIdentificationFrame::new(frame)) frame_pin.map(|frame| UserTextIdentificationFrame::new(frame))
} }
pub fn as_attached_picture(&mut self) -> Option<AttachedPictureFrame<'file_ref>> { pub fn as_attached_picture(&mut self) -> Option<AttachedPictureFrame<'file_ref>> {
let frame = unsafe { let frame = unsafe { bridge::Frame_asAttachedPicture(self.this.as_ref().get_ref()) };
bridge::Frame_asAttachedPicture(self.this.as_ref().get_ref())
};
let frame_ref = unsafe { frame.as_ref() }; let frame_ref = unsafe { frame.as_ref() };
let frame_pin = frame_ref.map(|frame| unsafe { Pin::new_unchecked(frame) }); let frame_pin = frame_ref.map(|frame| unsafe { Pin::new_unchecked(frame) });
frame_pin.map(|frame| AttachedPictureFrame::new(frame)) frame_pin.map(|frame| AttachedPictureFrame::new(frame))
@ -82,7 +84,7 @@ impl<'file_ref> Frame<'file_ref> {
} }
pub struct TextIdentificationFrame<'file_ref> { pub struct TextIdentificationFrame<'file_ref> {
this: Pin<&'file_ref CPPID3v2TextIdentificationFrame> this: Pin<&'file_ref CPPID3v2TextIdentificationFrame>,
} }
impl<'file_ref> TextIdentificationFrame<'file_ref> { impl<'file_ref> TextIdentificationFrame<'file_ref> {
@ -97,7 +99,7 @@ impl<'file_ref> TextIdentificationFrame<'file_ref> {
} }
pub struct UserTextIdentificationFrame<'file_ref> { pub struct UserTextIdentificationFrame<'file_ref> {
this: Pin<&'file_ref CPPID3v2UserTextIdentificationFrame> this: Pin<&'file_ref CPPID3v2UserTextIdentificationFrame>,
} }
impl<'file_ref> UserTextIdentificationFrame<'file_ref> { impl<'file_ref> UserTextIdentificationFrame<'file_ref> {
@ -112,7 +114,7 @@ impl<'file_ref> UserTextIdentificationFrame<'file_ref> {
} }
pub struct AttachedPictureFrame<'file_ref> { pub struct AttachedPictureFrame<'file_ref> {
this: Pin<&'file_ref CPPID3v2AttachedPictureFrame> this: Pin<&'file_ref CPPID3v2AttachedPictureFrame>,
} }
impl<'file_ref> AttachedPictureFrame<'file_ref> { impl<'file_ref> AttachedPictureFrame<'file_ref> {

View file

@ -1,27 +1,25 @@
use super::bridge::{self, CPPIOStream}; use super::bridge::{self, CPPIOStream};
use std::io::{Read, Write, Seek, SeekFrom};
use std::pin::Pin;
use cxx::UniquePtr; use cxx::UniquePtr;
use std::io::{Read, Seek, SeekFrom, Write};
use std::pin::Pin;
pub trait IOStream : Read + Write + Seek { pub trait IOStream: Read + Write + Seek {
fn name(&self) -> String; fn name(&self) -> String;
fn is_readonly(&self) -> bool; fn is_readonly(&self) -> bool;
} }
pub(super) struct BridgedIOStream<'io_stream> { pub(super) struct BridgedIOStream<'io_stream> {
rs_stream: Pin<Box<DynIOStream<'io_stream>>>, rs_stream: Pin<Box<DynIOStream<'io_stream>>>,
cpp_stream: UniquePtr<CPPIOStream> cpp_stream: UniquePtr<CPPIOStream>,
} }
impl<'io_stream> BridgedIOStream<'io_stream> { impl<'io_stream> BridgedIOStream<'io_stream> {
pub fn new<T : IOStream + 'io_stream>(stream: T) -> Self { pub fn new<T: IOStream + 'io_stream>(stream: T) -> Self {
let mut rs_stream = Box::pin(DynIOStream(Box::new(stream))); let mut rs_stream = Box::pin(DynIOStream(Box::new(stream)));
let cpp_stream = bridge::wrap_RsIOStream(rs_stream.as_mut()); let cpp_stream = bridge::wrap_RsIOStream(rs_stream.as_mut());
BridgedIOStream { BridgedIOStream {
rs_stream, rs_stream,
cpp_stream cpp_stream,
} }
} }
@ -44,7 +42,6 @@ impl<'io_stream> Drop for BridgedIOStream<'io_stream> {
pub(super) struct DynIOStream<'io_stream>(Box<dyn IOStream + 'io_stream>); pub(super) struct DynIOStream<'io_stream>(Box<dyn IOStream + 'io_stream>);
impl<'io_stream> DynIOStream<'io_stream> { impl<'io_stream> DynIOStream<'io_stream> {
// Implement the exposed functions for cxx bridge // Implement the exposed functions for cxx bridge
pub fn name(&mut self) -> String { pub fn name(&mut self) -> String {
self.0.name() self.0.name()

View file

@ -1,12 +1,12 @@
mod bridge; mod bridge;
pub mod file_ref;
pub mod iostream;
pub mod file;
pub mod audioproperties; pub mod audioproperties;
pub mod ogg; pub mod file;
pub mod file_ref;
pub mod flac; pub mod flac;
pub mod xiph;
pub mod mpeg;
pub mod tk;
pub mod id3v2; pub mod id3v2;
pub mod iostream;
pub mod mpeg;
pub mod ogg;
pub mod tk;
pub mod xiph;

View file

@ -1,9 +1,9 @@
use std::pin::Pin;
use super::bridge::{self, CPPMPEGFile}; use super::bridge::{self, CPPMPEGFile};
use super::id3v2::ID3v2Tag; use super::id3v2::ID3v2Tag;
use std::pin::Pin;
pub struct MPEGFile<'file_ref> { pub struct MPEGFile<'file_ref> {
this: Pin<&'file_ref mut CPPMPEGFile> this: Pin<&'file_ref mut CPPMPEGFile>,
} }
impl<'file_ref> MPEGFile<'file_ref> { impl<'file_ref> MPEGFile<'file_ref> {

View file

@ -3,7 +3,7 @@ use super::xiph::XiphComment;
use std::pin::Pin; use std::pin::Pin;
pub struct VorbisFile<'file_ref> { pub struct VorbisFile<'file_ref> {
this: Pin<&'file_ref mut CPPVorbisFile> this: Pin<&'file_ref mut CPPVorbisFile>,
} }
impl<'file_ref> VorbisFile<'file_ref> { impl<'file_ref> VorbisFile<'file_ref> {
@ -25,7 +25,7 @@ impl<'file_ref> VorbisFile<'file_ref> {
} }
pub struct OpusFile<'file_ref> { pub struct OpusFile<'file_ref> {
this: Pin<&'file_ref mut CPPOpusFile> this: Pin<&'file_ref mut CPPOpusFile>,
} }
impl<'file_ref> OpusFile<'file_ref> { impl<'file_ref> OpusFile<'file_ref> {

View file

@ -1,17 +1,17 @@
use super::bridge::{self, CPPByteVector, CPPString, CPPStringList}; use super::bridge::{self, CPPByteVector, CPPString, CPPStringList};
use cxx::{UniquePtr, memory::UniquePtrTarget}; use cxx::{memory::UniquePtrTarget, UniquePtr};
use std::marker::PhantomData; use std::marker::PhantomData;
use std::pin::Pin; use std::pin::Pin;
use std::{ffi::CStr, string::ToString}; use std::{ffi::CStr, string::ToString};
enum This<'file_ref, T : UniquePtrTarget> { enum This<'file_ref, T: UniquePtrTarget> {
Owned { Owned {
data: PhantomData<&'file_ref T>, data: PhantomData<&'file_ref T>,
this: UniquePtr<T>, this: UniquePtr<T>,
}, },
Ref { Ref {
this: Pin<&'file_ref T>, this: Pin<&'file_ref T>,
} },
} }
pub struct String<'file_ref> { pub struct String<'file_ref> {
@ -24,7 +24,6 @@ impl<'file_ref> String<'file_ref> {
} }
} }
impl<'file_ref> ToString for String<'file_ref> { impl<'file_ref> ToString for String<'file_ref> {
fn to_string(&self) -> std::string::String { fn to_string(&self) -> std::string::String {
let c_str = self.this.toCString(true); let c_str = self.this.toCString(true);
@ -51,11 +50,18 @@ pub struct StringList<'file_ref> {
impl<'file_ref> StringList<'file_ref> { impl<'file_ref> StringList<'file_ref> {
pub(super) fn owned(this: UniquePtr<CPPStringList>) -> Self { pub(super) fn owned(this: UniquePtr<CPPStringList>) -> Self {
Self { this: This::Owned { data: PhantomData, this } } Self {
this: This::Owned {
data: PhantomData,
this,
},
}
} }
pub(super) fn reference(this: Pin<&'file_ref CPPStringList>) -> Self { pub(super) fn reference(this: Pin<&'file_ref CPPStringList>) -> Self {
Self { this: This::Ref { this } } Self {
this: This::Ref { this },
}
} }
pub fn to_vec(&self) -> Vec<std::string::String> { pub fn to_vec(&self) -> Vec<std::string::String> {
@ -67,9 +73,7 @@ impl<'file_ref> StringList<'file_ref> {
cxx_values cxx_values
.iter() .iter()
.map(|value| { .map(|value| {
let this = unsafe { let this = unsafe { Pin::new_unchecked(value) };
Pin::new_unchecked(value)
};
String::new(this).to_string() String::new(this).to_string()
}) })
.collect() .collect()

View file

@ -1,12 +1,12 @@
pub use super::bridge::CPPXiphComment; pub use super::bridge::CPPXiphComment;
pub use super::flac::PictureList;
use super::bridge::{CPPFieldListMap, FieldListMap_to_entries, XiphComment_pictureList}; use super::bridge::{CPPFieldListMap, FieldListMap_to_entries, XiphComment_pictureList};
pub use super::flac::PictureList;
use super::tk; use super::tk;
use std::pin::Pin;
use std::collections::HashMap; use std::collections::HashMap;
use std::pin::Pin;
pub struct XiphComment<'file_ref> { pub struct XiphComment<'file_ref> {
this: Pin<&'file_ref mut CPPXiphComment> this: Pin<&'file_ref mut CPPXiphComment>,
} }
impl<'file_ref> XiphComment<'file_ref> { impl<'file_ref> XiphComment<'file_ref> {