Skip to content

Commit 144bf17

Browse files
FreezyLemonshssoichiro
authored andcommitted
Replace util::Range with std::ops::RangeBounds
1 parent 764ec83 commit 144bf17

File tree

3 files changed

+15
-47
lines changed

3 files changed

+15
-47
lines changed

src/format/context/input.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
use std::ffi::CString;
22
use std::mem;
3-
use std::ops::{Deref, DerefMut};
3+
use std::ops::{Bound, Deref, DerefMut, RangeBounds};
44

55
use super::common::Context;
66
use super::destructor;
77
use crate::ffi::*;
8-
use crate::util::range::Range;
98
#[cfg(not(feature = "ffmpeg_5_0"))]
109
use crate::Codec;
1110
use crate::{format, Error, Packet, Stream};
@@ -117,16 +116,21 @@ impl Input {
117116
}
118117
}
119118

120-
pub fn seek<R: Range<i64>>(&mut self, ts: i64, range: R) -> Result<(), Error> {
119+
pub fn seek<R: RangeBounds<i64>>(&mut self, ts: i64, range: R) -> Result<(), Error> {
121120
unsafe {
122-
match avformat_seek_file(
123-
self.as_mut_ptr(),
124-
-1,
125-
range.start().cloned().unwrap_or(i64::MIN),
126-
ts,
127-
range.end().cloned().unwrap_or(i64::MAX),
128-
0,
129-
) {
121+
let start = match range.start_bound().cloned() {
122+
Bound::Included(i) => i,
123+
Bound::Excluded(i) => i.saturating_add(1),
124+
Bound::Unbounded => i64::MIN,
125+
};
126+
127+
let end = match range.end_bound().cloned() {
128+
Bound::Included(i) => i,
129+
Bound::Excluded(i) => i.saturating_sub(1),
130+
Bound::Unbounded => i64::MAX,
131+
};
132+
133+
match avformat_seek_file(self.as_mut_ptr(), -1, start, ts, end, 0) {
130134
s if s >= 0 => Ok(()),
131135
e => Err(Error::from(e)),
132136
}

src/util/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub mod mathematics;
1212
pub mod media;
1313
pub mod option;
1414
pub mod picture;
15-
pub mod range;
1615
pub mod rational;
1716
pub mod time;
1817

src/util/range.rs

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)