*: format code with rustfmt and fix clippy suggestions
* Add avformat_close_input call to clean up AVFormantContext * Format code with rustfmt * Fix clippy lint double_parens * Fix clippy lint deref_addrof * Fix clippy lint identity_conversion * Fix clippy lint match_ref_pats * Fix clippy lint cast_lossless * Fix clippy lint cmp_null * Fix clippy lint clone_on_ref_ptr * Fix clippy lint map_clone * Fix clippy lint needless_borrow * Fix clippy lint needless_pass_by_value * Fix clippy lints for examples * Fix clippy lint unused_io_amount * Fix clippy lint new_without_default * Ignore inline_always clippy lint * Add vim temp files to .gitignore
This commit is contained in:
@ -1,113 +1,107 @@
|
||||
use ::Codec;
|
||||
use codec::{Id, Audio, Video};
|
||||
use super::{decoder, encoder};
|
||||
use codec::{Audio, Id, Video};
|
||||
use Codec;
|
||||
|
||||
pub trait Decoder {
|
||||
fn decoder(self) -> Option<Codec>;
|
||||
fn decoder(self) -> Option<Codec>;
|
||||
}
|
||||
|
||||
impl<'a> Decoder for &'a str {
|
||||
fn decoder(self) -> Option<Codec> {
|
||||
decoder::find_by_name(self)
|
||||
}
|
||||
fn decoder(self) -> Option<Codec> {
|
||||
decoder::find_by_name(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Decoder for Id {
|
||||
fn decoder(self) -> Option<Codec> {
|
||||
decoder::find(self)
|
||||
}
|
||||
fn decoder(self) -> Option<Codec> {
|
||||
decoder::find(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Decoder for Codec {
|
||||
fn decoder(self) -> Option<Codec> {
|
||||
if self.is_decoder() {
|
||||
Some(self)
|
||||
}
|
||||
else {
|
||||
None
|
||||
}
|
||||
}
|
||||
fn decoder(self) -> Option<Codec> {
|
||||
if self.is_decoder() {
|
||||
Some(self)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Decoder for Option<Codec> {
|
||||
fn decoder(self) -> Option<Codec> {
|
||||
self.and_then(|c| c.decoder())
|
||||
}
|
||||
fn decoder(self) -> Option<Codec> {
|
||||
self.and_then(|c| c.decoder())
|
||||
}
|
||||
}
|
||||
|
||||
impl Decoder for Audio {
|
||||
fn decoder(self) -> Option<Codec> {
|
||||
if self.is_decoder() {
|
||||
Some(*&*self)
|
||||
}
|
||||
else {
|
||||
None
|
||||
}
|
||||
}
|
||||
fn decoder(self) -> Option<Codec> {
|
||||
if self.is_decoder() {
|
||||
Some(*self)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Decoder for Video {
|
||||
fn decoder(self) -> Option<Codec> {
|
||||
if self.is_decoder() {
|
||||
Some(*&*self)
|
||||
}
|
||||
else {
|
||||
None
|
||||
}
|
||||
}
|
||||
fn decoder(self) -> Option<Codec> {
|
||||
if self.is_decoder() {
|
||||
Some(*self)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Encoder {
|
||||
fn encoder(self) -> Option<Codec>;
|
||||
fn encoder(self) -> Option<Codec>;
|
||||
}
|
||||
|
||||
impl<'a> Encoder for &'a str {
|
||||
fn encoder(self) -> Option<Codec> {
|
||||
encoder::find_by_name(self)
|
||||
}
|
||||
fn encoder(self) -> Option<Codec> {
|
||||
encoder::find_by_name(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Encoder for Id {
|
||||
fn encoder(self) -> Option<Codec> {
|
||||
encoder::find(self)
|
||||
}
|
||||
fn encoder(self) -> Option<Codec> {
|
||||
encoder::find(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Encoder for Codec {
|
||||
fn encoder(self) -> Option<Codec> {
|
||||
if self.is_encoder() {
|
||||
Some(self)
|
||||
}
|
||||
else {
|
||||
None
|
||||
}
|
||||
}
|
||||
fn encoder(self) -> Option<Codec> {
|
||||
if self.is_encoder() {
|
||||
Some(self)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Encoder for Option<Codec> {
|
||||
fn encoder(self) -> Option<Codec> {
|
||||
self.and_then(|c| c.encoder())
|
||||
}
|
||||
fn encoder(self) -> Option<Codec> {
|
||||
self.and_then(|c| c.encoder())
|
||||
}
|
||||
}
|
||||
|
||||
impl Encoder for Audio {
|
||||
fn encoder(self) -> Option<Codec> {
|
||||
if self.is_encoder() {
|
||||
Some(*&*self)
|
||||
}
|
||||
else {
|
||||
None
|
||||
}
|
||||
}
|
||||
fn encoder(self) -> Option<Codec> {
|
||||
if self.is_encoder() {
|
||||
Some(*self)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Encoder for Video {
|
||||
fn encoder(self) -> Option<Codec> {
|
||||
if self.is_encoder() {
|
||||
Some(*&*self)
|
||||
}
|
||||
else {
|
||||
None
|
||||
}
|
||||
}
|
||||
fn encoder(self) -> Option<Codec> {
|
||||
if self.is_encoder() {
|
||||
Some(*self)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user