cargo fix --all

* it added "dyn" to trait objects
* it changed "..." in patterns to "..="

cargo --version says: "cargo 1.37.0-nightly (545f35425 2019-05-23)"
This commit is contained in:
Scott Lamb 2019-06-14 08:47:11 -07:00
parent 7dd98bb76a
commit 7fe9d34655
22 changed files with 83 additions and 83 deletions

View File

@ -56,7 +56,7 @@ pub trait Clocks : Send + Sync + 'static {
timeout: StdDuration) -> Result<T, mpsc::RecvTimeoutError>;
}
pub fn retry_forever<C, T, E>(clocks: &C, f: &mut FnMut() -> Result<T, E>) -> T
pub fn retry_forever<C, T, E>(clocks: &C, f: &mut dyn FnMut() -> Result<T, E>) -> T
where C: Clocks, E: Into<Error> {
loop {
let e = match f() {

View File

@ -47,7 +47,7 @@ impl Error {
}
impl Fail for Error {
fn cause(&self) -> Option<&Fail> {
fn cause(&self) -> Option<&dyn Fail> {
self.inner.cause()
}

View File

@ -44,8 +44,8 @@ pub fn hex(raw: &[u8]) -> String {
/// Returns [0, 16) or error.
fn dehex_byte(hex_byte: u8) -> Result<u8, ()> {
match hex_byte {
b'0' ... b'9' => Ok(hex_byte - b'0'),
b'a' ... b'f' => Ok(hex_byte - b'a' + 10),
b'0' ..= b'9' => Ok(hex_byte - b'0'),
b'a' ..= b'f' => Ok(hex_byte - b'a' + 10),
_ => Err(()),
}
}

View File

@ -346,7 +346,7 @@ impl State {
from
user
"#)?;
let mut rows = stmt.query(&[] as &[&ToSql])?;
let mut rows = stmt.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let id = row.get(0)?;
let name: String = row.get(1)?;
@ -596,7 +596,7 @@ impl State {
let addr = req.addr_buf();
let addr: Option<&[u8]> = addr.as_ref().map(|a| a.as_ref());
stmt.execute(&[
&req.when_sec as &ToSql,
&req.when_sec as &dyn ToSql,
&req.user_agent,
&addr,
&(reason as i32),

View File

@ -58,7 +58,7 @@ pub fn run(conn: &rusqlite::Connection, opts: &Options) -> Result<(), Error> {
"#)?;
let mut garbage_stmt = conn.prepare_cached(
"select composite_id from garbage where sample_file_dir_id = ?")?;
let mut rows = dir_stmt.query(&[] as &[&ToSql])?;
let mut rows = dir_stmt.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let mut meta = schema::DirMeta::default();
let dir_id: i32 = row.get(0)?;
@ -92,7 +92,7 @@ pub fn run(conn: &rusqlite::Connection, opts: &Options) -> Result<(), Error> {
let mut stmt = conn.prepare(r#"
select id, sample_file_dir_id from stream where sample_file_dir_id is not null
"#)?;
let mut rows = stmt.query(&[] as &[&ToSql])?;
let mut rows = stmt.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let stream_id = row.get(0)?;
let dir_id = row.get(1)?;

View File

@ -446,7 +446,7 @@ pub struct Stream {
/// The number of recordings in `uncommitted` which are synced and ready to commit.
synced_recordings: usize,
on_live_segment: Vec<Box<FnMut(LiveSegment) -> bool + Send>>,
on_live_segment: Vec<Box<dyn FnMut(LiveSegment) -> bool + Send>>,
}
/// Bounds of a single keyframe and the frames dependent on it.
@ -620,7 +620,7 @@ pub struct LockedDatabase {
cameras_by_uuid: BTreeMap<Uuid, i32>, // values are ids.
video_sample_entries_by_id: BTreeMap<i32, Arc<VideoSampleEntry>>,
video_index_cache: RefCell<LruCache<i64, Box<[u8]>, fnv::FnvBuildHasher>>,
on_flush: Vec<Box<Fn() + Send>>,
on_flush: Vec<Box<dyn Fn() + Send>>,
}
/// Represents a row of the `open` database table.
@ -867,7 +867,7 @@ impl LockedDatabase {
/// Registers a callback to run on every live segment immediately after it's recorded.
/// The callback is run with the database lock held, so it must not call back into the database
/// or block. The callback should return false to unregister.
pub fn watch_live(&mut self, stream_id: i32, cb: Box<FnMut(LiveSegment) -> bool + Send>)
pub fn watch_live(&mut self, stream_id: i32, cb: Box<dyn FnMut(LiveSegment) -> bool + Send>)
-> Result<(), Error> {
let s = match self.streams_by_id.get_mut(&stream_id) {
None => bail!("no such stream {}", stream_id),
@ -958,7 +958,7 @@ impl LockedDatabase {
let mut stmt = tx.prepare_cached(
r"update open set duration_90k = ?, end_time_90k = ? where id = ?")?;
let rows = stmt.execute(&[
&(recording::Time::new(clocks.monotonic()) - self.open_monotonic).0 as &ToSql,
&(recording::Time::new(clocks.monotonic()) - self.open_monotonic).0 as &dyn ToSql,
&recording::Time::new(clocks.realtime()).0,
&o.id,
])?;
@ -1024,7 +1024,7 @@ impl LockedDatabase {
/// Sets a watcher which will receive an (empty) event on successful flush.
/// The lock will be held while this is run, so it should not do any I/O.
pub(crate) fn on_flush(&mut self, run: Box<Fn() + Send>) {
pub(crate) fn on_flush(&mut self, run: Box<dyn Fn() + Send>) {
self.on_flush.push(run);
}
@ -1084,7 +1084,7 @@ impl LockedDatabase {
update sample_file_dir set last_complete_open_id = ? where id = ?
"#)?;
for &id in in_progress.keys() {
if stmt.execute(&[&o.id as &ToSql, &id])? != 1 {
if stmt.execute(&[&o.id as &dyn ToSql, &id])? != 1 {
bail!("unable to update dir {}", id);
}
}
@ -1124,7 +1124,7 @@ impl LockedDatabase {
/// Uncommitted recordings are returned id order after the others.
pub fn list_recordings_by_time(
&self, stream_id: i32, desired_time: Range<recording::Time>,
f: &mut FnMut(ListRecordingsRow) -> Result<(), Error>) -> Result<(), Error> {
f: &mut dyn FnMut(ListRecordingsRow) -> Result<(), Error>) -> Result<(), Error> {
let s = match self.streams_by_id.get(&stream_id) {
None => bail!("no such stream {}", stream_id),
Some(s) => s,
@ -1152,7 +1152,7 @@ impl LockedDatabase {
/// Lists the specified recordings in ascending order by id.
pub fn list_recordings_by_id(
&self, stream_id: i32, desired_ids: Range<i32>,
f: &mut FnMut(ListRecordingsRow) -> Result<(), Error>) -> Result<(), Error> {
f: &mut dyn FnMut(ListRecordingsRow) -> Result<(), Error>) -> Result<(), Error> {
let s = match self.streams_by_id.get(&stream_id) {
None => bail!("no such stream {}", stream_id),
Some(s) => s,
@ -1186,7 +1186,7 @@ impl LockedDatabase {
pub fn list_aggregated_recordings(
&self, stream_id: i32, desired_time: Range<recording::Time>,
forced_split: recording::Duration,
f: &mut FnMut(&ListAggregatedRecordingsRow) -> Result<(), Error>)
f: &mut dyn FnMut(&ListAggregatedRecordingsRow) -> Result<(), Error>)
-> Result<(), Error> {
// Iterate, maintaining a map from a recording_id to the aggregated row for the latest
// batch of recordings from the run starting at that id. Runs can be split into multiple
@ -1255,7 +1255,7 @@ impl LockedDatabase {
/// Note the lock is held for the duration of `f`.
/// This uses a LRU cache to reduce the number of retrievals from the database.
pub fn with_recording_playback<R>(&self, id: CompositeId,
f: &mut FnMut(&RecordingPlayback) -> Result<R, Error>)
f: &mut dyn FnMut(&RecordingPlayback) -> Result<R, Error>)
-> Result<R, Error> {
// Check for uncommitted path.
let s = self.streams_by_id
@ -1292,7 +1292,7 @@ impl LockedDatabase {
/// Deletes the oldest recordings that aren't already queued for deletion.
/// `f` should return true for each row that should be deleted.
pub(crate) fn delete_oldest_recordings(
&mut self, stream_id: i32, f: &mut FnMut(&ListOldestRecordingsRow) -> bool)
&mut self, stream_id: i32, f: &mut dyn FnMut(&ListOldestRecordingsRow) -> bool)
-> Result<(), Error> {
let s = match self.streams_by_id.get_mut(&stream_id) {
None => bail!("no stream {}", stream_id),
@ -1326,7 +1326,7 @@ impl LockedDatabase {
from
video_sample_entry
"#)?;
let mut rows = stmt.query(&[] as &[&ToSql])?;
let mut rows = stmt.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let id = row.get(0)?;
let mut sha1 = [0u8; 20];
@ -1365,7 +1365,7 @@ impl LockedDatabase {
from
sample_file_dir d left join open o on (d.last_complete_open_id = o.id);
"#)?;
let mut rows = stmt.query(&[] as &[&ToSql])?;
let mut rows = stmt.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let id = row.get(0)?;
let dir_uuid: FromSqlUuid = row.get(2)?;
@ -1406,7 +1406,7 @@ impl LockedDatabase {
from
camera;
"#)?;
let mut rows = stmt.query(&[] as &[&ToSql])?;
let mut rows = stmt.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let id = row.get(0)?;
let uuid: FromSqlUuid = row.get(1)?;
@ -1444,7 +1444,7 @@ impl LockedDatabase {
from
stream;
"#)?;
let mut rows = stmt.query(&[] as &[&ToSql])?;
let mut rows = stmt.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let id = row.get(0)?;
let type_: String = row.get(1)?;
@ -1549,7 +1549,7 @@ impl LockedDatabase {
self.conn.execute(r#"
insert into sample_file_dir (path, uuid, last_complete_open_id)
values (?, ?, ?)
"#, &[&path as &ToSql, &uuid_bytes, &o.id])?;
"#, &[&path as &dyn ToSql, &uuid_bytes, &o.id])?;
let id = self.conn.last_insert_rowid() as i32;
use ::std::collections::btree_map::Entry;
let e = self.sample_file_dirs_by_id.entry(id);
@ -1796,7 +1796,7 @@ impl LockedDatabase {
self.signal.types_by_uuid()
}
pub fn list_changes_by_time(
&self, desired_time: Range<recording::Time>, f: &mut FnMut(&signal::ListStateChangesRow)) {
&self, desired_time: Range<recording::Time>, f: &mut dyn FnMut(&signal::ListStateChangesRow)) {
self.signal.list_changes_by_time(desired_time, f)
}
pub fn update_signals(
@ -1810,7 +1810,7 @@ impl LockedDatabase {
/// Note this doesn't set journal options, so that it can be used on in-memory databases for
/// test code.
pub fn init(conn: &mut rusqlite::Connection) -> Result<(), Error> {
conn.execute("pragma foreign_keys = on", &[] as &[&ToSql])?;
conn.execute("pragma foreign_keys = on", &[] as &[&dyn ToSql])?;
let tx = conn.transaction()?;
tx.execute_batch(include_str!("schema.sql"))?;
{
@ -1829,11 +1829,11 @@ pub fn init(conn: &mut rusqlite::Connection) -> Result<(), Error> {
pub fn get_schema_version(conn: &rusqlite::Connection) -> Result<Option<i32>, Error> {
let ver_tables: i32 = conn.query_row_and_then(
"select count(*) from sqlite_master where name = 'version'",
&[] as &[&ToSql], |row| row.get(0))?;
&[] as &[&dyn ToSql], |row| row.get(0))?;
if ver_tables == 0 {
return Ok(None);
}
Ok(Some(conn.query_row_and_then("select max(id) from version", &[] as &[&ToSql],
Ok(Some(conn.query_row_and_then("select max(id) from version", &[] as &[&dyn ToSql],
|row| row.get(0))?))
}
@ -1871,7 +1871,7 @@ impl<C: Clocks + Clone> Database<C> {
/// Creates the database from a caller-supplied SQLite connection.
pub fn new(clocks: C, conn: rusqlite::Connection,
read_write: bool) -> Result<Database<C>, Error> {
conn.execute("pragma foreign_keys = on", &[] as &[&ToSql])?;
conn.execute("pragma foreign_keys = on", &[] as &[&dyn ToSql])?;
{
let ver = get_schema_version(&conn)?.ok_or_else(|| format_err!(
"no such table: version. \
@ -1901,7 +1901,7 @@ impl<C: Clocks + Clone> Database<C> {
let mut stmt = conn.prepare(" insert into open (uuid, start_time_90k) values (?, ?)")?;
let uuid = Uuid::new_v4();
let uuid_bytes = &uuid.as_bytes()[..];
stmt.execute(&[&uuid_bytes as &ToSql, &real.0])?;
stmt.execute(&[&uuid_bytes as &dyn ToSql, &real.0])?;
Some(Open {
id: conn.last_insert_rowid() as u32,
uuid,

View File

@ -302,8 +302,8 @@ pub(crate) fn parse_id(id: &[u8]) -> Result<CompositeId, ()> {
let mut v: u64 = 0;
for i in 0..16 {
v = (v << 4) | match id[i] {
b @ b'0'...b'9' => b - b'0',
b @ b'a'...b'f' => b - b'a' + 10,
b @ b'0'..=b'9' => b - b'0',
b @ b'a'..=b'f' => b - b'a' + 10,
_ => return Err(()),
} as u64;
}

View File

@ -123,7 +123,7 @@ const LIST_OLDEST_RECORDINGS_SQL: &'static str = r#"
/// function. Given that the function is called with the database lock held, it should be quick.
pub(crate) fn list_recordings_by_time(
conn: &rusqlite::Connection, stream_id: i32, desired_time: Range<recording::Time>,
f: &mut FnMut(db::ListRecordingsRow) -> Result<(), Error>) -> Result<(), Error> {
f: &mut dyn FnMut(db::ListRecordingsRow) -> Result<(), Error>) -> Result<(), Error> {
let mut stmt = conn.prepare_cached(LIST_RECORDINGS_BY_TIME_SQL)?;
let rows = stmt.query_named(&[
(":stream_id", &stream_id),
@ -135,7 +135,7 @@ pub(crate) fn list_recordings_by_time(
/// Lists the specified recordings in ascending order by id.
pub(crate) fn list_recordings_by_id(
conn: &rusqlite::Connection, stream_id: i32, desired_ids: Range<i32>,
f: &mut FnMut(db::ListRecordingsRow) -> Result<(), Error>) -> Result<(), Error> {
f: &mut dyn FnMut(db::ListRecordingsRow) -> Result<(), Error>) -> Result<(), Error> {
let mut stmt = conn.prepare_cached(LIST_RECORDINGS_BY_ID_SQL)?;
let rows = stmt.query_named(&[
(":start", &CompositeId::new(stream_id, desired_ids.start).0),
@ -145,7 +145,7 @@ pub(crate) fn list_recordings_by_id(
}
fn list_recordings_inner(mut rows: rusqlite::Rows,
f: &mut FnMut(db::ListRecordingsRow) -> Result<(), Error>)
f: &mut dyn FnMut(db::ListRecordingsRow) -> Result<(), Error>)
-> Result<(), Error> {
while let Some(row) = rows.next()? {
f(db::ListRecordingsRow {
@ -165,7 +165,7 @@ fn list_recordings_inner(mut rows: rusqlite::Rows,
}
pub(crate) fn get_db_uuid(conn: &rusqlite::Connection) -> Result<Uuid, Error> {
Ok(conn.query_row("select uuid from meta", &[] as &[&ToSql], |row| -> rusqlite::Result<Uuid> {
Ok(conn.query_row("select uuid from meta", &[] as &[&dyn ToSql], |row| -> rusqlite::Result<Uuid> {
let uuid: FromSqlUuid = row.get(0)?;
Ok(uuid.0)
})?)
@ -266,7 +266,7 @@ pub(crate) fn delete_recordings(tx: &rusqlite::Transaction, sample_file_dir_id:
(":start", &ids.start.0),
(":end", &ids.end.0),
])?;
let p: &[(&str, &rusqlite::types::ToSql)] = &[
let p: &[(&str, &dyn rusqlite::types::ToSql)] = &[
(":start", &ids.start.0),
(":end", &ids.end.0),
];
@ -360,7 +360,7 @@ pub(crate) fn list_garbage(conn: &rusqlite::Connection, dir_id: i32)
/// Lists the oldest recordings for a stream, starting with the given id.
/// `f` should return true as long as further rows are desired.
pub(crate) fn list_oldest_recordings(conn: &rusqlite::Connection, start: CompositeId,
f: &mut FnMut(db::ListOldestRecordingsRow) -> bool)
f: &mut dyn FnMut(db::ListOldestRecordingsRow) -> bool)
-> Result<(), Error> {
let mut stmt = conn.prepare_cached(LIST_OLDEST_RECORDINGS_SQL)?;
let mut rows = stmt.query_named(&[

View File

@ -252,13 +252,13 @@ impl ::protobuf::Message for DirMeta {
&mut self.unknown_fields
}
fn as_any(&self) -> &::std::any::Any {
self as &::std::any::Any
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut ::std::any::Any {
self as &mut ::std::any::Any
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: Box<Self>) -> ::std::boxed::Box<::std::any::Any> {
fn into_any(self: Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
@ -462,13 +462,13 @@ impl ::protobuf::Message for DirMeta_Open {
&mut self.unknown_fields
}
fn as_any(&self) -> &::std::any::Any {
self as &::std::any::Any
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut ::std::any::Any {
self as &mut ::std::any::Any
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: Box<Self>) -> ::std::boxed::Box<::std::any::Any> {
fn into_any(self: Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}

View File

@ -227,7 +227,7 @@ impl State {
}
pub fn list_changes_by_time(
&self, desired_time: Range<recording::Time>, f: &mut FnMut(&ListStateChangesRow)) {
&self, desired_time: Range<recording::Time>, f: &mut dyn FnMut(&ListStateChangesRow)) {
// First find the state immediately before. If it exists, include it.
if let Some((&when, p)) = self.points_by_time.range(..desired_time.start).next_back() {

View File

@ -54,7 +54,7 @@ pub struct Args<'a> {
fn set_journal_mode(conn: &rusqlite::Connection, requested: &str) -> Result<(), Error> {
assert!(!requested.contains(';')); // quick check for accidental sql injection.
let actual = conn.query_row(&format!("pragma journal_mode = {}", requested), &[] as &[&ToSql],
let actual = conn.query_row(&format!("pragma journal_mode = {}", requested), &[] as &[&dyn ToSql],
|row| row.get::<_, String>(0))?;
info!("...database now in journal_mode {} (requested {}).", actual, requested);
Ok(())
@ -71,7 +71,7 @@ pub fn run(args: &Args, conn: &mut rusqlite::Connection) -> Result<(), Error> {
{
assert_eq!(upgraders.len(), db::EXPECTED_VERSION as usize);
let old_ver =
conn.query_row("select max(id) from version", &[] as &[&ToSql],
conn.query_row("select max(id) from version", &[] as &[&dyn ToSql],
|row| row.get(0))?;
if old_ver > db::EXPECTED_VERSION {
bail!("Database is at version {}, later than expected {}",
@ -88,7 +88,7 @@ pub fn run(args: &Args, conn: &mut rusqlite::Connection) -> Result<(), Error> {
tx.execute(r#"
insert into version (id, unix_time, notes)
values (?, cast(strftime('%s', 'now') as int32), ?)
"#, &[&(ver + 1) as &ToSql, &UPGRADE_NOTES])?;
"#, &[&(ver + 1) as &dyn ToSql, &UPGRADE_NOTES])?;
tx.commit()?;
}
}
@ -97,7 +97,7 @@ pub fn run(args: &Args, conn: &mut rusqlite::Connection) -> Result<(), Error> {
// compiles the SQLite3 amalgamation with -DSQLITE_DEFAULT_FOREIGN_KEYS=1). Ensure it's
// always on. Note that our foreign keys are immediate rather than deferred, so we have to
// be careful about the order of operations during the upgrade.
conn.execute("pragma foreign_keys = on", &[] as &[&ToSql])?;
conn.execute("pragma foreign_keys = on", &[] as &[&dyn ToSql])?;
// WAL is the preferred journal mode for normal operation; it reduces the number of syncs
// without compromising safety.

View File

@ -142,7 +142,7 @@ fn fill_recording(tx: &rusqlite::Transaction) -> Result<HashMap<i32, CameraState
insert into recording_playback values (:composite_id, :sample_file_uuid, :sample_file_sha1,
:video_index)
"#)?;
let mut rows = select.query(&[] as &[&ToSql])?;
let mut rows = select.query(&[] as &[&dyn ToSql])?;
let mut camera_state: HashMap<i32, CameraState> = HashMap::new();
while let Some(row) = rows.next()? {
let camera_id: i32 = row.get(0)?;
@ -216,7 +216,7 @@ fn fill_camera(tx: &rusqlite::Transaction, camera_state: HashMap<i32, CameraStat
insert into camera values (:id, :uuid, :short_name, :description, :host, :username, :password,
:main_rtsp_path, :sub_rtsp_path, :retain_bytes, :next_recording_id)
"#)?;
let mut rows = select.query(&[] as &[&ToSql])?;
let mut rows = select.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let id: i32 = row.get(0)?;
let uuid: Vec<u8> = row.get(1)?;

View File

@ -122,7 +122,7 @@ pub fn run(args: &super::Args, tx: &rusqlite::Transaction) -> Result<(), Error>
tx.execute(r#"
insert into sample_file_dir (path, uuid, last_complete_open_id)
values (?, ?, ?)
"#, &[&sample_file_path as &ToSql, &dir_uuid_bytes, &open_id])?;
"#, &[&sample_file_path as &dyn ToSql, &dir_uuid_bytes, &open_id])?;
tx.execute_batch(r#"
drop table reserved_sample_files;
@ -298,7 +298,7 @@ fn verify_dir_contents(sample_file_path: &str, tx: &rusqlite::Transaction) -> Re
from
(select count(*) as c from recording) a,
(select count(*) as c from reserved_sample_files) b;
"#, &[] as &[&ToSql], |r| r.get(0))?;
"#, &[] as &[&dyn ToSql], |r| r.get(0))?;
let mut files = ::fnv::FnvHashSet::with_capacity_and_hasher(n as usize, Default::default());
for e in fs::read_dir(sample_file_path)? {
let e = e?;
@ -329,7 +329,7 @@ fn verify_dir_contents(sample_file_path: &str, tx: &rusqlite::Transaction) -> Re
// Iterate through the database and check that everything has a matching file.
{
let mut stmt = tx.prepare(r"select sample_file_uuid from recording_playback")?;
let mut rows = stmt.query(&[] as &[&ToSql])?;
let mut rows = stmt.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let uuid: crate::db::FromSqlUuid = row.get(0)?;
if !files.remove(&uuid.0) {
@ -339,7 +339,7 @@ fn verify_dir_contents(sample_file_path: &str, tx: &rusqlite::Transaction) -> Re
}
let mut stmt = tx.prepare(r"select uuid from reserved_sample_files")?;
let mut rows = stmt.query(&[] as &[&ToSql])?;
let mut rows = stmt.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let uuid: crate::db::FromSqlUuid = row.get(0)?;
files.remove(&uuid.0);
@ -366,7 +366,7 @@ fn fix_video_sample_entry(tx: &rusqlite::Transaction) -> Result<(), Error> {
let mut insert = tx.prepare(r#"
insert into video_sample_entry values (:id, :sha1, :width, :height, :rfc6381_codec, :data)
"#)?;
let mut rows = select.query(&[] as &[&ToSql])?;
let mut rows = select.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let data: Vec<u8> = row.get(4)?;
insert.execute_named(&[

View File

@ -57,7 +57,7 @@ fn open_sample_file_dir(tx: &rusqlite::Transaction) -> Result<Arc<dir::SampleFil
sample_file_dir s
join open o on (s.last_complete_open_id = o.id)
cross join meta m
"#, &[] as &[&ToSql], |row| {
"#, &[] as &[&dyn ToSql], |row| {
Ok((row.get(0)?,
row.get(1)?,
row.get(2)?,
@ -84,7 +84,7 @@ pub fn run(_args: &super::Args, tx: &rusqlite::Transaction) -> Result<(), Error>
from
recording_playback
"#)?;
let mut rows = stmt.query(&[] as &[&ToSql])?;
let mut rows = stmt.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let id = db::CompositeId(row.get(0)?);
let sample_file_uuid: FromSqlUuid = row.get(1)?;

View File

@ -867,9 +867,9 @@ mod tests {
struct MockDir(Arc<Mutex<VecDeque<MockDirAction>>>);
enum MockDirAction {
Create(CompositeId, Box<Fn(CompositeId) -> Result<MockFile, io::Error> + Send>),
Sync(Box<Fn() -> Result<(), io::Error> + Send>),
Unlink(CompositeId, Box<Fn(CompositeId) -> Result<(), io::Error> + Send>),
Create(CompositeId, Box<dyn Fn(CompositeId) -> Result<MockFile, io::Error> + Send>),
Sync(Box<dyn Fn() -> Result<(), io::Error> + Send>),
Unlink(CompositeId, Box<dyn Fn(CompositeId) -> Result<(), io::Error> + Send>),
}
impl MockDir {
@ -919,8 +919,8 @@ mod tests {
struct MockFile(Arc<Mutex<VecDeque<MockFileAction>>>);
enum MockFileAction {
SyncAll(Box<Fn() -> Result<(), io::Error> + Send>),
Write(Box<Fn(&[u8]) -> Result<usize, io::Error> + Send>),
SyncAll(Box<dyn Fn() -> Result<(), io::Error> + Send>),
Write(Box<dyn Fn(&[u8]) -> Result<usize, io::Error> + Send>),
}
impl MockFile {

View File

@ -323,7 +323,7 @@ impl std::error::Error for Error {
"ffmpeg error"
}
fn cause(&self) -> Option<&std::error::Error> { None }
fn cause(&self) -> Option<&dyn std::error::Error> { None }
}
impl fmt::Display for Error {

View File

@ -39,8 +39,8 @@ use std::error::Error as StdError;
pub struct Chunk(ARefs<'static, [u8]>);
//pub type CompatError = ::failure::Compat<Error>;
pub type BoxedError = Box<StdError + Send + Sync>;
pub type BodyStream = Box<Stream<Item = Chunk, Error = BoxedError> + Send + 'static>;
pub type BoxedError = Box<dyn StdError + Send + Sync>;
pub type BodyStream = Box<dyn Stream<Item = Chunk, Error = BoxedError> + Send + 'static>;
pub fn wrap_error(e: Error) -> BoxedError {
Box::new(e.compat())

View File

@ -265,7 +265,7 @@ pub fn run() -> Result<(), Error> {
// Start the web interface.
let addr = args.flag_http_addr.parse().unwrap();
let server = ::hyper::server::Server::bind(&addr).tcp_nodelay(true).serve(
move || Ok::<_, Box<StdError + Send + Sync>>(s.clone()));
move || Ok::<_, Box<dyn StdError + Send + Sync>>(s.clone()));
let shutdown = setup_shutdown().shared();

View File

@ -641,7 +641,7 @@ impl slices::Slice for Slice {
fn end(&self) -> u64 { return self.0 & 0xFF_FF_FF_FF_FF }
fn get_range(&self, f: &File, range: Range<u64>, len: u64)
-> Box<Stream<Item = Self::Chunk, Error = BoxedError> + Send> {
-> Box<dyn Stream<Item = Self::Chunk, Error = BoxedError> + Send> {
trace!("getting mp4 slice {:?}'s range {:?} / {}", self, range, len);
let p = self.p();
let res = match self.t() {
@ -1518,7 +1518,7 @@ impl http_serve::Entity for File {
fn etag(&self) -> Option<HeaderValue> { Some(self.0.etag.clone()) }
fn len(&self) -> u64 { self.0.slices.len() }
fn get_range(&self, range: Range<u64>)
-> Box<Stream<Item = Self::Data, Error = Self::Error> + Send> {
-> Box<dyn Stream<Item = Self::Data, Error = Self::Error> + Send> {
self.0.slices.get_range(self, range)
}
}

View File

@ -52,7 +52,7 @@ pub trait Slice : fmt::Debug + Sized + Sync + 'static {
/// The additional argument `ctx` is as supplied to the `Slices`.
/// The additional argument `l` is the length of this slice, as determined by the `Slices`.
fn get_range(&self, ctx: &Self::Ctx, r: Range<u64>, len: u64)
-> Box<Stream<Item = Self::Chunk, Error = BoxedError> + Send>;
-> Box<dyn Stream<Item = Self::Chunk, Error = BoxedError> + Send>;
fn get_slices(ctx: &Self::Ctx) -> &Slices<Self>;
}
@ -111,7 +111,7 @@ impl<S> Slices<S> where S: Slice {
/// Writes `range` to `out`.
/// This interface mirrors `http_serve::Entity::write_to`, with the additional `ctx` argument.
pub fn get_range(&self, ctx: &S::Ctx, range: Range<u64>)
-> Box<Stream<Item = S::Chunk, Error = BoxedError> + Send> {
-> Box<dyn Stream<Item = S::Chunk, Error = BoxedError> + Send> {
if range.start > range.end || range.end > self.len {
return Box::new(stream::once(Err(wrap_error(format_err_t!(
Internal, "Bad range {:?} for slice of length {}", range, self.len)))));
@ -176,7 +176,7 @@ mod tests {
fn end(&self) -> u64 { self.end }
fn get_range(&self, _ctx: &&'static Slices<FakeSlice>, r: Range<u64>, _l: u64)
-> Box<Stream<Item = FakeChunk, Error = BoxedError> + Send> {
-> Box<dyn Stream<Item = FakeChunk, Error = BoxedError> + Send> {
Box::new(stream::once(Ok(FakeChunk{slice: self.name, range: r})))
}

View File

@ -43,7 +43,7 @@ pub static ROTATE_INTERVAL_SEC: i64 = 60;
/// Common state that can be used by multiple `Streamer` instances.
pub struct Environment<'a, 'b, C, S> where C: Clocks + Clone, S: 'a + stream::Stream {
pub opener: &'a stream::Opener<S>,
pub opener: &'a dyn stream::Opener<S>,
pub db: &'b Arc<Database<C>>,
pub shutdown: &'b Arc<AtomicBool>,
}
@ -57,7 +57,7 @@ pub struct Streamer<'a, C, S> where C: Clocks + Clone, S: 'a + stream::Stream {
db: Arc<Database<C>>,
dir: Arc<dir::SampleFileDir>,
syncer_channel: writer::SyncerChannel<::std::fs::File>,
opener: &'a stream::Opener<S>,
opener: &'a dyn stream::Opener<S>,
stream_id: i32,
short_name: String,
url: String,

View File

@ -798,7 +798,7 @@ impl Service {
///
/// Use with `and_then` to chain logic which consumes the form body.
fn with_form_body(&self, mut req: Request<hyper::Body>)
-> Box<Future<Item = (Request<hyper::Body>, hyper::Chunk),
-> Box<dyn Future<Item = (Request<hyper::Body>, hyper::Chunk),
Error = Response<Body>> +
Send + 'static> {
if *req.method() != http::method::Method::POST {
@ -911,11 +911,11 @@ impl ::hyper::service::Service for Service {
type ReqBody = ::hyper::Body;
type ResBody = Body;
type Error = BoxedError;
type Future = Box<Future<Item = Response<Self::ResBody>, Error = Self::Error> + Send + 'static>;
type Future = Box<dyn Future<Item = Response<Self::ResBody>, Error = Self::Error> + Send + 'static>;
fn call(&mut self, req: Request<::hyper::Body>) -> Self::Future {
fn wrap<R>(is_private: bool, r: R)
-> Box<Future<Item = Response<Body>, Error = BoxedError> + Send + 'static>
-> Box<dyn Future<Item = Response<Body>, Error = BoxedError> + Send + 'static>
where R: Future<Item = Response<Body>, Error = Response<Body>> + Send + 'static {
return Box::new(r.or_else(|e| Ok(e)).map(move |mut r| {
if is_private {
@ -926,7 +926,7 @@ impl ::hyper::service::Service for Service {
}
fn wrap_r(is_private: bool, r: ResponseResult)
-> Box<Future<Item = Response<Body>, Error = BoxedError> + Send + 'static> {
-> Box<dyn Future<Item = Response<Body>, Error = BoxedError> + Send + 'static> {
return wrap(is_private, future::result(r))
}
@ -1009,7 +1009,7 @@ mod tests {
}).unwrap();
let server = hyper::server::Server::bind(&addr)
.tcp_nodelay(true)
.serve(move || Ok::<_, Box<StdError + Send + Sync>>(service.clone()));
.serve(move || Ok::<_, Box<dyn StdError + Send + Sync>>(service.clone()));
let addr = server.local_addr(); // resolve port 0 to a real ephemeral port number.
let handle = ::std::thread::spawn(move || {
::tokio::run(server.with_graceful_shutdown(shutdown_rx).map_err(|e| panic!(e)));