Extend lifetimes on WhisperState and WhisperToken
This commit is contained in:
parent
4e2c466e79
commit
31c1527abe
2 changed files with 8 additions and 8 deletions
|
|
@ -105,7 +105,7 @@ impl<'a> WhisperSegment<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_raw_cstr(&self) -> Result<&CStr, WhisperError> {
|
fn to_raw_cstr(&self) -> Result<&'a CStr, WhisperError> {
|
||||||
let ret = unsafe {
|
let ret = unsafe {
|
||||||
whisper_rs_sys::whisper_full_get_segment_text_from_state(
|
whisper_rs_sys::whisper_full_get_segment_text_from_state(
|
||||||
self.state.ptr,
|
self.state.ptr,
|
||||||
|
|
@ -126,7 +126,7 @@ impl<'a> WhisperSegment<'a> {
|
||||||
///
|
///
|
||||||
/// # C++ equivalent
|
/// # C++ equivalent
|
||||||
/// `const char * whisper_full_get_segment_text(struct whisper_context * ctx, int i_segment)`
|
/// `const char * whisper_full_get_segment_text(struct whisper_context * ctx, int i_segment)`
|
||||||
pub fn to_bytes(&self) -> Result<&[u8], WhisperError> {
|
pub fn to_bytes(&self) -> Result<&'a [u8], WhisperError> {
|
||||||
Ok(self.to_raw_cstr()?.to_bytes())
|
Ok(self.to_raw_cstr()?.to_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,7 +138,7 @@ impl<'a> WhisperSegment<'a> {
|
||||||
///
|
///
|
||||||
/// # C++ equivalent
|
/// # C++ equivalent
|
||||||
/// `const char * whisper_full_get_segment_text(struct whisper_context * ctx, int i_segment)`
|
/// `const char * whisper_full_get_segment_text(struct whisper_context * ctx, int i_segment)`
|
||||||
pub fn to_str(&self) -> Result<&str, WhisperError> {
|
pub fn to_str(&self) -> Result<&'a str, WhisperError> {
|
||||||
Ok(self.to_raw_cstr()?.to_str()?)
|
Ok(self.to_raw_cstr()?.to_str()?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,7 +154,7 @@ impl<'a> WhisperSegment<'a> {
|
||||||
///
|
///
|
||||||
/// # C++ equivalent
|
/// # C++ equivalent
|
||||||
/// `const char * whisper_full_get_segment_text(struct whisper_context * ctx, int i_segment)`
|
/// `const char * whisper_full_get_segment_text(struct whisper_context * ctx, int i_segment)`
|
||||||
pub fn to_str_lossy(&self) -> Result<Cow<'_, str>, WhisperError> {
|
pub fn to_str_lossy(&self) -> Result<Cow<'a, str>, WhisperError> {
|
||||||
Ok(self.to_raw_cstr()?.to_string_lossy())
|
Ok(self.to_raw_cstr()?.to_string_lossy())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ impl<'a, 'b> WhisperToken<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_raw_cstr(&self) -> Result<&CStr, WhisperError> {
|
fn to_raw_cstr(&self) -> Result<&'b CStr, WhisperError> {
|
||||||
let ret = unsafe {
|
let ret = unsafe {
|
||||||
whisper_rs_sys::whisper_full_get_token_text_from_state(
|
whisper_rs_sys::whisper_full_get_token_text_from_state(
|
||||||
self.segment.get_state().ctx.ctx,
|
self.segment.get_state().ctx.ctx,
|
||||||
|
|
@ -92,7 +92,7 @@ impl<'a, 'b> WhisperToken<'a, 'b> {
|
||||||
///
|
///
|
||||||
/// # C++ equivalent
|
/// # C++ equivalent
|
||||||
/// `const char * whisper_full_get_token_text(struct whisper_context * ctx, int i_segment, int i_token)`
|
/// `const char * whisper_full_get_token_text(struct whisper_context * ctx, int i_segment, int i_token)`
|
||||||
pub fn to_bytes(&self) -> Result<&[u8], WhisperError> {
|
pub fn to_bytes(&self) -> Result<&'b [u8], WhisperError> {
|
||||||
Ok(self.to_raw_cstr()?.to_bytes())
|
Ok(self.to_raw_cstr()?.to_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,7 +104,7 @@ impl<'a, 'b> WhisperToken<'a, 'b> {
|
||||||
///
|
///
|
||||||
/// # C++ equivalent
|
/// # C++ equivalent
|
||||||
/// `const char * whisper_full_get_token_text(struct whisper_context * ctx, int i_segment, int i_token)`
|
/// `const char * whisper_full_get_token_text(struct whisper_context * ctx, int i_segment, int i_token)`
|
||||||
pub fn to_str(&self) -> Result<&str, WhisperError> {
|
pub fn to_str(&self) -> Result<&'b str, WhisperError> {
|
||||||
Ok(self.to_raw_cstr()?.to_str()?)
|
Ok(self.to_raw_cstr()?.to_str()?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,7 +120,7 @@ impl<'a, 'b> WhisperToken<'a, 'b> {
|
||||||
///
|
///
|
||||||
/// # C++ equivalent
|
/// # C++ equivalent
|
||||||
/// `const char * whisper_full_get_token_text(struct whisper_context * ctx, int i_segment, int i_token)`
|
/// `const char * whisper_full_get_token_text(struct whisper_context * ctx, int i_segment, int i_token)`
|
||||||
pub fn to_str_lossy(&self) -> Result<Cow<'_, str>, WhisperError> {
|
pub fn to_str_lossy(&self) -> Result<Cow<'b, str>, WhisperError> {
|
||||||
Ok(self.to_raw_cstr()?.to_string_lossy())
|
Ok(self.to_raw_cstr()?.to_string_lossy())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue