mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-11-23 02:57:43 -05:00
upgrade to 2018 Rust edition
This is mostly just "cargo fix --edition" + Cargo.toml changes. There's one fix for upgrading to NLL in db/writer.rs: Writer::previously_opened wouldn't build with NLL because of a double-borrow the previous borrow checker somehow didn't catch. Restructure to avoid it. I'll put elective NLL changes in a following commit.
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
|
||||
//! Subcommand to check the database and sample file dir for errors.
|
||||
|
||||
use db::check;
|
||||
use crate::db::check;
|
||||
use failure::Error;
|
||||
|
||||
static USAGE: &'static str = r#"
|
||||
|
||||
@@ -33,12 +33,12 @@ extern crate cursive;
|
||||
use self::cursive::Cursive;
|
||||
use self::cursive::traits::{Boxable, Identifiable, Finder};
|
||||
use self::cursive::views;
|
||||
use db::{self, writer};
|
||||
use crate::db::{self, writer};
|
||||
use failure::Error;
|
||||
use std::collections::BTreeMap;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use stream::{self, Opener, Stream};
|
||||
use crate::stream::{self, Opener, Stream};
|
||||
use super::{decode_size, encode_size};
|
||||
|
||||
/// Builds a `CameraChange` from an active `edit_camera_dialog`.
|
||||
|
||||
@@ -33,7 +33,7 @@ extern crate cursive;
|
||||
use self::cursive::Cursive;
|
||||
use self::cursive::traits::{Boxable, Identifiable};
|
||||
use self::cursive::views;
|
||||
use db::{self, writer};
|
||||
use crate::db::{self, writer};
|
||||
use failure::Error;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
@@ -37,8 +37,8 @@ extern crate cursive;
|
||||
|
||||
use self::cursive::Cursive;
|
||||
use self::cursive::views;
|
||||
use clock;
|
||||
use db;
|
||||
use crate::clock;
|
||||
use crate::db;
|
||||
use failure::Error;
|
||||
use regex::Regex;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -33,7 +33,7 @@ extern crate cursive;
|
||||
use self::cursive::Cursive;
|
||||
use self::cursive::traits::{Boxable, Identifiable};
|
||||
use self::cursive::views;
|
||||
use db;
|
||||
use crate::db;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Builds a `UserChange` from an active `edit_user_dialog`.
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use db;
|
||||
use crate::db;
|
||||
use failure::Error;
|
||||
|
||||
static USAGE: &'static str = r#"
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use db::dir;
|
||||
use crate::db::dir;
|
||||
use docopt;
|
||||
use failure::{Error, Fail};
|
||||
use libc;
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use clock;
|
||||
use db::{self, dir, writer};
|
||||
use crate::clock;
|
||||
use crate::db::{self, dir, writer};
|
||||
use failure::Error;
|
||||
use fnv::FnvHashMap;
|
||||
use futures::{Future, Stream};
|
||||
@@ -37,11 +37,11 @@ use std::error::Error as StdError;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::thread;
|
||||
use stream;
|
||||
use streamer;
|
||||
use crate::stream;
|
||||
use crate::streamer;
|
||||
use tokio;
|
||||
use tokio_signal::unix::{Signal, SIGINT, SIGTERM};
|
||||
use web;
|
||||
use crate::web;
|
||||
|
||||
// These are used in a hack to get the name of the current time zone (e.g. America/Los_Angeles).
|
||||
// They seem to be correct for Linux and macOS at least.
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use db::recording;
|
||||
use crate::db::recording;
|
||||
use failure::Error;
|
||||
|
||||
const USAGE: &'static str = r#"
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
///
|
||||
/// See `guide/schema.md` for more information.
|
||||
|
||||
use db;
|
||||
use crate::db;
|
||||
use failure::Error;
|
||||
|
||||
const USAGE: &'static str = r#"
|
||||
|
||||
@@ -248,7 +248,7 @@ pub fn transform_sample_data(annexb_sample: &[u8], avc_sample: &mut Vec<u8>) ->
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use db::testutil;
|
||||
use crate::db::testutil;
|
||||
|
||||
const ANNEX_B_TEST_INPUT: [u8; 35] = [
|
||||
0x00, 0x00, 0x00, 0x01, 0x67, 0x4d, 0x00, 0x1f,
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use db::{self, auth::SessionHash};
|
||||
use crate::db::{self, auth::SessionHash};
|
||||
use failure::Error;
|
||||
use serde::ser::{SerializeMap, SerializeSeq, Serializer};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
@@ -67,7 +67,7 @@ extern crate tokio_signal;
|
||||
extern crate url;
|
||||
extern crate uuid;
|
||||
|
||||
use base::clock as clock;
|
||||
use crate::base::clock as clock;
|
||||
|
||||
mod body;
|
||||
mod cmds;
|
||||
@@ -141,7 +141,7 @@ fn main() {
|
||||
.build();
|
||||
h.clone().install().unwrap();
|
||||
|
||||
if let Err(e) = { let _a = h.async(); args.arg_command.unwrap().run() } {
|
||||
if let Err(e) = { let _a = h.r#async(); args.arg_command.unwrap().run() } {
|
||||
error!("{:?}", e);
|
||||
::std::process::exit(1);
|
||||
}
|
||||
|
||||
22
src/mp4.rs
22
src/mp4.rs
@@ -78,12 +78,12 @@
|
||||
|
||||
extern crate time;
|
||||
|
||||
use base::strutil;
|
||||
use crate::base::strutil;
|
||||
use bytes::{Buf, BytesMut};
|
||||
use byteorder::{BigEndian, ByteOrder, WriteBytesExt};
|
||||
use body::{Chunk, BoxedError, wrap_error};
|
||||
use db::recording::{self, TIME_UNITS_PER_SEC};
|
||||
use db::{self, dir};
|
||||
use crate::body::{Chunk, BoxedError, wrap_error};
|
||||
use crate::db::recording::{self, TIME_UNITS_PER_SEC};
|
||||
use crate::db::{self, dir};
|
||||
use failure::Error;
|
||||
use futures::Stream;
|
||||
use futures::stream;
|
||||
@@ -94,7 +94,7 @@ use memmap;
|
||||
use openssl::hash;
|
||||
use parking_lot::{Once, ONCE_INIT};
|
||||
use reffers::ARefs;
|
||||
use slices::{self, Slices};
|
||||
use crate::slices::{self, Slices};
|
||||
use smallvec::SmallVec;
|
||||
use std::cell::UnsafeCell;
|
||||
use std::cmp;
|
||||
@@ -1530,13 +1530,13 @@ impl http_serve::Entity for File {
|
||||
/// to verify the output is byte-for-byte as expected.
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use base::strutil;
|
||||
use crate::base::strutil;
|
||||
use bytes::Buf;
|
||||
use byteorder::{BigEndian, ByteOrder};
|
||||
use clock::RealClocks;
|
||||
use db::recording::{self, TIME_UNITS_PER_SEC};
|
||||
use db::testutil::{self, TestDb, TEST_STREAM_ID};
|
||||
use db::writer;
|
||||
use crate::clock::RealClocks;
|
||||
use crate::db::recording::{self, TIME_UNITS_PER_SEC};
|
||||
use crate::db::testutil::{self, TestDb, TEST_STREAM_ID};
|
||||
use crate::db::writer;
|
||||
use futures::Future;
|
||||
use futures::Stream as FuturesStream;
|
||||
use openssl::hash;
|
||||
@@ -1546,7 +1546,7 @@ mod tests {
|
||||
use std::path::Path;
|
||||
use std::str;
|
||||
use super::*;
|
||||
use stream::{self, Opener, Stream};
|
||||
use crate::stream::{self, Opener, Stream};
|
||||
|
||||
fn fill_slice<E: http_serve::Entity>(slice: &mut [u8], e: &E, start: u64)
|
||||
where E::Error : ::std::fmt::Debug {
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
//! Tools for implementing a `http_serve::Entity` body composed from many "slices".
|
||||
|
||||
use body::{BoxedError, wrap_error};
|
||||
use crate::body::{BoxedError, wrap_error};
|
||||
use failure::Error;
|
||||
use futures::stream;
|
||||
use futures::Stream;
|
||||
@@ -149,8 +149,8 @@ impl<S> Slices<S> where S: Slice {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use body::BoxedError;
|
||||
use db::testutil;
|
||||
use crate::body::BoxedError;
|
||||
use crate::db::testutil;
|
||||
use futures::{Future, Stream};
|
||||
use futures::stream;
|
||||
use std::ops::Range;
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use failure::Error;
|
||||
use h264;
|
||||
use crate::h264;
|
||||
use moonfire_ffmpeg;
|
||||
use std::os::raw::c_char;
|
||||
use std::ffi::{CStr, CString};
|
||||
|
||||
@@ -28,14 +28,14 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use clock::{Clocks, TimerGuard};
|
||||
use db::{Camera, Database, Stream, dir, recording, writer};
|
||||
use crate::clock::{Clocks, TimerGuard};
|
||||
use crate::db::{Camera, Database, Stream, dir, recording, writer};
|
||||
use failure::Error;
|
||||
use h264;
|
||||
use crate::h264;
|
||||
use std::result::Result;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use stream;
|
||||
use crate::stream;
|
||||
use time;
|
||||
|
||||
pub static ROTATE_INTERVAL_SEC: i64 = 60;
|
||||
@@ -186,18 +186,18 @@ impl<'a, C, S> Streamer<'a, C, S> where C: 'a + Clocks + Clone, S: 'a + stream::
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use clock::{self, Clocks};
|
||||
use db::{self, CompositeId};
|
||||
use db::recording;
|
||||
use db::testutil;
|
||||
use crate::clock::{self, Clocks};
|
||||
use crate::db::{self, CompositeId};
|
||||
use crate::db::recording;
|
||||
use crate::db::testutil;
|
||||
use failure::Error;
|
||||
use h264;
|
||||
use crate::h264;
|
||||
use moonfire_ffmpeg;
|
||||
use parking_lot::Mutex;
|
||||
use std::cmp;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use stream::{self, Opener, Stream};
|
||||
use crate::stream::{self, Opener, Stream};
|
||||
use time;
|
||||
|
||||
struct ProxyingStream<'a> {
|
||||
|
||||
22
src/web.rs
22
src/web.rs
@@ -30,24 +30,24 @@
|
||||
|
||||
extern crate hyper;
|
||||
|
||||
use base::clock::Clocks;
|
||||
use base::strutil;
|
||||
use body::{Body, BoxedError};
|
||||
use crate::base::clock::Clocks;
|
||||
use crate::base::strutil;
|
||||
use crate::body::{Body, BoxedError};
|
||||
use base64;
|
||||
use bytes::{BufMut, BytesMut};
|
||||
use core::borrow::Borrow;
|
||||
use core::str::FromStr;
|
||||
use db::{self, auth, recording};
|
||||
use db::dir::SampleFileDir;
|
||||
use crate::db::{self, auth, recording};
|
||||
use crate::db::dir::SampleFileDir;
|
||||
use failure::Error;
|
||||
use fnv::FnvHashMap;
|
||||
use futures::{Future, Stream, future};
|
||||
use futures_cpupool;
|
||||
use json;
|
||||
use crate::json;
|
||||
use http::{self, Request, Response, status::StatusCode};
|
||||
use http_serve;
|
||||
use http::header::{self, HeaderValue};
|
||||
use mp4;
|
||||
use crate::mp4;
|
||||
use regex::Regex;
|
||||
use serde_json;
|
||||
use std::collections::HashMap;
|
||||
@@ -842,8 +842,8 @@ impl ::hyper::service::Service for Service {
|
||||
mod tests {
|
||||
extern crate reqwest;
|
||||
|
||||
use db;
|
||||
use db::testutil::{self, TestDb};
|
||||
use crate::db;
|
||||
use crate::db::testutil::{self, TestDb};
|
||||
use futures::Future;
|
||||
use http::{self, header};
|
||||
use std::collections::HashMap;
|
||||
@@ -851,7 +851,7 @@ mod tests {
|
||||
use super::Segments;
|
||||
|
||||
struct Server {
|
||||
db: TestDb<::base::clock::RealClocks>,
|
||||
db: TestDb<crate::base::clock::RealClocks>,
|
||||
base_url: String,
|
||||
//test_camera_uuid: Uuid,
|
||||
handle: Option<::std::thread::JoinHandle<()>>,
|
||||
@@ -860,7 +860,7 @@ mod tests {
|
||||
|
||||
impl Server {
|
||||
fn new() -> Server {
|
||||
let db = TestDb::new(::base::clock::RealClocks {});
|
||||
let db = TestDb::new(crate::base::clock::RealClocks {});
|
||||
let (shutdown_tx, shutdown_rx) = futures::sync::oneshot::channel::<()>();
|
||||
let addr = "127.0.0.1:0".parse().unwrap();
|
||||
let require_auth = true;
|
||||
|
||||
Reference in New Issue
Block a user