CPointerWrap

Struct CPointerWrap 

Source
pub struct CPointerWrap<T> { /* private fields */ }
Expand description

Holds the pointer generated by the Voicevox core and performs memory management through RAII.

Implementations§

Source§

impl<T> CPointerWrap<T>

Source

pub fn new(bytes: *mut T, length: usize, free_fn: fn(*mut T)) -> Self

Source

pub fn as_slice(&self) -> &[T]

Examples found in repository?
examples/simple-tts.rs (line 15)
4fn main() -> Result<(), vvcore::ResultCode> {
5    println!("VOICEVOX CORE version: {}", VoicevoxCore::get_version());
6
7    let dir = std::ffi::CString::new("open_jtalk_dic_utf_8-1.11").unwrap();
8    let vvc = VoicevoxCore::new_from_options(AccelerationMode::Auto, 0, true, dir.as_c_str())?;
9
10    let text: &str = "こんにちは";
11    let speaker: u32 = 1;
12    let wav = vvc.tts_simple(text, speaker)?;
13
14    let mut file = std::fs::File::create("audio.wav").unwrap();
15    file.write_all(&wav.as_slice()).unwrap();
16
17    Ok(())
18}

Trait Implementations§

Source§

impl<T> Drop for CPointerWrap<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for CPointerWrap<T>

§

impl<T> RefUnwindSafe for CPointerWrap<T>
where T: RefUnwindSafe,

§

impl<T> !Send for CPointerWrap<T>

§

impl<T> !Sync for CPointerWrap<T>

§

impl<T> Unpin for CPointerWrap<T>

§

impl<T> UnwindSafe for CPointerWrap<T>
where T: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.