@@ -10,7 +10,7 @@ pub mod ssa;
10
10
pub mod vobsub;
11
11
12
12
use crate :: errors:: * ;
13
- use crate :: SubtitleFile ;
13
+ use crate :: SubtitleFileInterface ;
14
14
use encoding_rs:: Encoding ;
15
15
use std:: ffi:: OsStr ;
16
16
@@ -124,22 +124,22 @@ pub fn get_subtitle_format_err(extension: Option<&OsStr>, content: &[u8]) -> Res
124
124
}
125
125
126
126
/// This trick works around the limitation, that trait objects can not require Sized (or Clone).
127
- pub trait ClonableSubtitleFile : SubtitleFile + Send + Sync {
127
+ pub trait ClonableSubtitleFileInterface : SubtitleFileInterface + Send + Sync {
128
128
/// Returns a boxed clone
129
- fn clone_box ( & self ) -> Box < ClonableSubtitleFile > ;
129
+ fn clone_box ( & self ) -> Box < ClonableSubtitleFileInterface > ;
130
130
}
131
- impl < T > ClonableSubtitleFile for T
131
+ impl < T > ClonableSubtitleFileInterface for T
132
132
where
133
- T : SubtitleFile + Clone + Send + Sync + ' static ,
133
+ T : SubtitleFileInterface + Clone + Send + Sync + ' static ,
134
134
{
135
- fn clone_box ( & self ) -> Box < ClonableSubtitleFile > {
135
+ fn clone_box ( & self ) -> Box < ClonableSubtitleFileInterface > {
136
136
Box :: new ( Clone :: clone ( self ) )
137
137
}
138
138
}
139
139
140
140
// We can now implement Clone manually by forwarding to clone_box.
141
- impl Clone for Box < ClonableSubtitleFile > {
142
- fn clone ( & self ) -> Box < ClonableSubtitleFile > {
141
+ impl Clone for Box < ClonableSubtitleFileInterface > {
142
+ fn clone ( & self ) -> Box < ClonableSubtitleFileInterface > {
143
143
self . clone_box ( )
144
144
}
145
145
}
@@ -151,7 +151,7 @@ impl Clone for Box<ClonableSubtitleFile> {
151
151
/// # Mandatory format specific options
152
152
///
153
153
/// See `parse_bytes`.
154
- pub fn parse_str ( format : SubtitleFormat , content : & str , fps : f64 ) -> Result < Box < ClonableSubtitleFile > > {
154
+ pub fn parse_str ( format : SubtitleFormat , content : & str , fps : f64 ) -> Result < Box < ClonableSubtitleFileInterface > > {
155
155
match format {
156
156
SubtitleFormat :: SubRip => Ok ( Box :: new ( srt:: SrtFile :: parse ( content) ?) ) ,
157
157
SubtitleFormat :: SubStationAlpha => Ok ( Box :: new ( ssa:: SsaFile :: parse ( content) ?) ) ,
@@ -185,7 +185,7 @@ fn decode_bytes_to_string(content: &[u8], encoding: &'static Encoding) -> Result
185
185
/// seconds/minutes/... but in frame numbers. So the timing `0 to 30` means "show subtitle for one second"
186
186
/// for a 30fps video, and "show subtitle for half second" for 60fps videos. The parameter specifies how
187
187
/// frame numbers are converted into timestamps.
188
- pub fn parse_bytes ( format : SubtitleFormat , content : & [ u8 ] , encoding : & ' static Encoding , fps : f64 ) -> Result < Box < ClonableSubtitleFile > > {
188
+ pub fn parse_bytes ( format : SubtitleFormat , content : & [ u8 ] , encoding : & ' static Encoding , fps : f64 ) -> Result < Box < ClonableSubtitleFileInterface > > {
189
189
match format {
190
190
SubtitleFormat :: SubRip => Ok ( Box :: new ( srt:: SrtFile :: parse ( & decode_bytes_to_string ( content, encoding) ?) ?) ) ,
191
191
SubtitleFormat :: SubStationAlpha => Ok ( Box :: new ( ssa:: SsaFile :: parse ( & decode_bytes_to_string ( content, encoding) ?) ?) ) ,
0 commit comments