From 7fe9d346555f8dec1abfb02c323645cb8d04ad0c Mon Sep 17 00:00:00 2001 From: Scott Lamb Date: Fri, 14 Jun 2019 08:47:11 -0700 Subject: [PATCH] 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)" --- base/clock.rs | 2 +- base/error.rs | 2 +- base/strutil.rs | 4 ++-- db/auth.rs | 4 ++-- db/check.rs | 4 ++-- db/db.rs | 44 +++++++++++++++++++++--------------------- db/dir.rs | 4 ++-- db/raw.rs | 12 ++++++------ db/schema.rs | 20 +++++++++---------- db/signal.rs | 2 +- db/upgrade/mod.rs | 8 ++++---- db/upgrade/v0_to_v1.rs | 4 ++-- db/upgrade/v1_to_v2.rs | 10 +++++----- db/upgrade/v2_to_v3.rs | 4 ++-- db/writer.rs | 10 +++++----- ffmpeg/lib.rs | 2 +- src/body.rs | 4 ++-- src/cmds/run.rs | 2 +- src/mp4.rs | 4 ++-- src/slices.rs | 6 +++--- src/streamer.rs | 4 ++-- src/web.rs | 10 +++++----- 22 files changed, 83 insertions(+), 83 deletions(-) diff --git a/base/clock.rs b/base/clock.rs index a6ccdcd..fb02bbd 100644 --- a/base/clock.rs +++ b/base/clock.rs @@ -56,7 +56,7 @@ pub trait Clocks : Send + Sync + 'static { timeout: StdDuration) -> Result; } -pub fn retry_forever(clocks: &C, f: &mut FnMut() -> Result) -> T +pub fn retry_forever(clocks: &C, f: &mut dyn FnMut() -> Result) -> T where C: Clocks, E: Into { loop { let e = match f() { diff --git a/base/error.rs b/base/error.rs index 28ae79d..b0c093e 100644 --- a/base/error.rs +++ b/base/error.rs @@ -47,7 +47,7 @@ impl Error { } impl Fail for Error { - fn cause(&self) -> Option<&Fail> { + fn cause(&self) -> Option<&dyn Fail> { self.inner.cause() } diff --git a/base/strutil.rs b/base/strutil.rs index f081fcf..ed4a992 100644 --- a/base/strutil.rs +++ b/base/strutil.rs @@ -44,8 +44,8 @@ pub fn hex(raw: &[u8]) -> String { /// Returns [0, 16) or error. fn dehex_byte(hex_byte: u8) -> Result { 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(()), } } diff --git a/db/auth.rs b/db/auth.rs index 2bb585c..ef4642e 100644 --- a/db/auth.rs +++ b/db/auth.rs @@ -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), diff --git a/db/check.rs b/db/check.rs index e3c7aed..f773d44 100644 --- a/db/check.rs +++ b/db/check.rs @@ -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)?; diff --git a/db/db.rs b/db/db.rs index 7bb03dc..44ad53f 100644 --- a/db/db.rs +++ b/db/db.rs @@ -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 bool + Send>>, + on_live_segment: Vec bool + Send>>, } /// Bounds of a single keyframe and the frames dependent on it. @@ -620,7 +620,7 @@ pub struct LockedDatabase { cameras_by_uuid: BTreeMap, // values are ids. video_sample_entries_by_id: BTreeMap>, video_index_cache: RefCell, fnv::FnvBuildHasher>>, - on_flush: Vec>, + on_flush: Vec>, } /// 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 bool + Send>) + pub fn watch_live(&mut self, stream_id: i32, cb: Box 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) { + pub(crate) fn on_flush(&mut self, run: Box) { 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, - 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, - 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, 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(&self, id: CompositeId, - f: &mut FnMut(&RecordingPlayback) -> Result) + f: &mut dyn FnMut(&RecordingPlayback) -> Result) -> Result { // 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, f: &mut FnMut(&signal::ListStateChangesRow)) { + &self, desired_time: Range, 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, 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 Database { /// Creates the database from a caller-supplied SQLite connection. pub fn new(clocks: C, conn: rusqlite::Connection, read_write: bool) -> Result, 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 Database { 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, diff --git a/db/dir.rs b/db/dir.rs index e7c2cb5..6a2c49e 100644 --- a/db/dir.rs +++ b/db/dir.rs @@ -302,8 +302,8 @@ pub(crate) fn parse_id(id: &[u8]) -> Result { 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; } diff --git a/db/raw.rs b/db/raw.rs index b5b3c5e..1d7a94d 100644 --- a/db/raw.rs +++ b/db/raw.rs @@ -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, - 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, - 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 { - Ok(conn.query_row("select uuid from meta", &[] as &[&ToSql], |row| -> rusqlite::Result { + Ok(conn.query_row("select uuid from meta", &[] as &[&dyn ToSql], |row| -> rusqlite::Result { 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(&[ diff --git a/db/schema.rs b/db/schema.rs index 599f615..c83e7eb 100644 --- a/db/schema.rs +++ b/db/schema.rs @@ -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) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: Box) -> ::std::boxed::Box { 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) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: Box) -> ::std::boxed::Box { self } diff --git a/db/signal.rs b/db/signal.rs index 1b9edd9..2908057 100644 --- a/db/signal.rs +++ b/db/signal.rs @@ -227,7 +227,7 @@ impl State { } pub fn list_changes_by_time( - &self, desired_time: Range, f: &mut FnMut(&ListStateChangesRow)) { + &self, desired_time: Range, 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() { diff --git a/db/upgrade/mod.rs b/db/upgrade/mod.rs index 6a3830b..7b2f3c5 100644 --- a/db/upgrade/mod.rs +++ b/db/upgrade/mod.rs @@ -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. diff --git a/db/upgrade/v0_to_v1.rs b/db/upgrade/v0_to_v1.rs index 001416a..17f3e5a 100644 --- a/db/upgrade/v0_to_v1.rs +++ b/db/upgrade/v0_to_v1.rs @@ -142,7 +142,7 @@ fn fill_recording(tx: &rusqlite::Transaction) -> Result = 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 = row.get(1)?; diff --git a/db/upgrade/v1_to_v2.rs b/db/upgrade/v1_to_v2.rs index dfb1d1e..c19684b 100644 --- a/db/upgrade/v1_to_v2.rs +++ b/db/upgrade/v1_to_v2.rs @@ -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 = row.get(4)?; insert.execute_named(&[ diff --git a/db/upgrade/v2_to_v3.rs b/db/upgrade/v2_to_v3.rs index 0ccf6a5..adb72f5 100644 --- a/db/upgrade/v2_to_v3.rs +++ b/db/upgrade/v2_to_v3.rs @@ -57,7 +57,7 @@ fn open_sample_file_dir(tx: &rusqlite::Transaction) -> Result 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)?; diff --git a/db/writer.rs b/db/writer.rs index b3b2995..336f53a 100644 --- a/db/writer.rs +++ b/db/writer.rs @@ -867,9 +867,9 @@ mod tests { struct MockDir(Arc>>); enum MockDirAction { - Create(CompositeId, Box Result + Send>), - Sync(Box Result<(), io::Error> + Send>), - Unlink(CompositeId, Box Result<(), io::Error> + Send>), + Create(CompositeId, Box Result + Send>), + Sync(Box Result<(), io::Error> + Send>), + Unlink(CompositeId, Box Result<(), io::Error> + Send>), } impl MockDir { @@ -919,8 +919,8 @@ mod tests { struct MockFile(Arc>>); enum MockFileAction { - SyncAll(Box Result<(), io::Error> + Send>), - Write(Box Result + Send>), + SyncAll(Box Result<(), io::Error> + Send>), + Write(Box Result + Send>), } impl MockFile { diff --git a/ffmpeg/lib.rs b/ffmpeg/lib.rs index 350551b..29210d7 100644 --- a/ffmpeg/lib.rs +++ b/ffmpeg/lib.rs @@ -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 { diff --git a/src/body.rs b/src/body.rs index 39e93f0..e7f45d6 100644 --- a/src/body.rs +++ b/src/body.rs @@ -39,8 +39,8 @@ use std::error::Error as StdError; pub struct Chunk(ARefs<'static, [u8]>); //pub type CompatError = ::failure::Compat; -pub type BoxedError = Box; -pub type BodyStream = Box + Send + 'static>; +pub type BoxedError = Box; +pub type BodyStream = Box + Send + 'static>; pub fn wrap_error(e: Error) -> BoxedError { Box::new(e.compat()) diff --git a/src/cmds/run.rs b/src/cmds/run.rs index d7893df..0a20cd7 100644 --- a/src/cmds/run.rs +++ b/src/cmds/run.rs @@ -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>(s.clone())); + move || Ok::<_, Box>(s.clone())); let shutdown = setup_shutdown().shared(); diff --git a/src/mp4.rs b/src/mp4.rs index e96e043..687ef25 100644 --- a/src/mp4.rs +++ b/src/mp4.rs @@ -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, len: u64) - -> Box + Send> { + -> Box + 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 { Some(self.0.etag.clone()) } fn len(&self) -> u64 { self.0.slices.len() } fn get_range(&self, range: Range) - -> Box + Send> { + -> Box + Send> { self.0.slices.get_range(self, range) } } diff --git a/src/slices.rs b/src/slices.rs index aa4febe..007a7a9 100644 --- a/src/slices.rs +++ b/src/slices.rs @@ -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, len: u64) - -> Box + Send>; + -> Box + Send>; fn get_slices(ctx: &Self::Ctx) -> &Slices; } @@ -111,7 +111,7 @@ impl Slices 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) - -> Box + Send> { + -> Box + 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, r: Range, _l: u64) - -> Box + Send> { + -> Box + Send> { Box::new(stream::once(Ok(FakeChunk{slice: self.name, range: r}))) } diff --git a/src/streamer.rs b/src/streamer.rs index f853969..297cba8 100644 --- a/src/streamer.rs +++ b/src/streamer.rs @@ -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, + pub opener: &'a dyn stream::Opener, pub db: &'b Arc>, pub shutdown: &'b Arc, } @@ -57,7 +57,7 @@ pub struct Streamer<'a, C, S> where C: Clocks + Clone, S: 'a + stream::Stream { db: Arc>, dir: Arc, syncer_channel: writer::SyncerChannel<::std::fs::File>, - opener: &'a stream::Opener, + opener: &'a dyn stream::Opener, stream_id: i32, short_name: String, url: String, diff --git a/src/web.rs b/src/web.rs index a4bead4..75620e9 100644 --- a/src/web.rs +++ b/src/web.rs @@ -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) - -> Box, hyper::Chunk), + -> Box, hyper::Chunk), Error = Response> + 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, Error = Self::Error> + Send + 'static>; + type Future = Box, Error = Self::Error> + Send + 'static>; fn call(&mut self, req: Request<::hyper::Body>) -> Self::Future { fn wrap(is_private: bool, r: R) - -> Box, Error = BoxedError> + Send + 'static> + -> Box, Error = BoxedError> + Send + 'static> where R: Future, Error = Response> + 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, Error = BoxedError> + Send + 'static> { + -> Box, 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>(service.clone())); + .serve(move || Ok::<_, Box>(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)));