Use std file not found error
This commit is contained in:
parent
378584b626
commit
8996bbb540
3 changed files with 5 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
|||
# Vid2Img - Video to Image
|
||||
# vid2img - Video to Image
|
||||
|
||||
Vid2img is a Rust crate that allows the use of a video file as a collection of frame images. This crate exposes
|
||||
vid2img is a Rust crate that allows the use of a video file as a collection of frame images. This crate exposes
|
||||
a `FileSource` type that accepts a video file path and the desired size of the frames, then you can convert the
|
||||
instance into a iterator (`.into_iter()`). On every iteration you will receive a video frame data encoded as PNG.
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ use crate::{FrameData, VideoStream, VideoStreamIterator};
|
|||
use std::path::{Path, PathBuf};
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::io::ErrorKind;
|
||||
|
||||
pub struct FileSource {
|
||||
source: PathBuf,
|
||||
|
@ -13,7 +14,7 @@ impl FileSource {
|
|||
pub fn new(source: &Path, frame_size: (u32, u32)) -> Result<Self, CaptureError> {
|
||||
let source = fs::canonicalize(source)?;
|
||||
if !source.exists() {
|
||||
return Err(CaptureError::FileNotFound);
|
||||
return Err(CaptureError::IoError(io::Error::new(ErrorKind::NotFound, "File not found")));
|
||||
}
|
||||
Ok(Self {
|
||||
source,
|
||||
|
@ -40,7 +41,6 @@ impl IntoIterator for FileSource {
|
|||
#[derive(Debug)]
|
||||
pub enum CaptureError {
|
||||
IoError(io::Error),
|
||||
FileNotFound,
|
||||
}
|
||||
|
||||
impl From<io::Error> for CaptureError {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//! Vid2img is a Rust crate that allows the use of a video file as a collection of frame images. This crate exposes
|
||||
//! vid2img is a Rust crate that allows the use of a video file as a collection of frame images. This crate exposes
|
||||
//! a [`vid2img::FileSource`] type that accepts a video file path and the desired size of the frames, then you can convert the
|
||||
//! instance into a iterator (`.into_iter()`). On every iteration you will receive a video frame data encoded as PNG.
|
||||
//!
|
||||
|
|
Loading…
Reference in a new issue