Skip to content

Commit

Permalink
new formatting rules (webrtc-rs#462)
Browse files Browse the repository at this point in the history
Closes webrtc-rs#397
Co-authored-by: koushiro <koushiro.cqx@gmail.com>
  • Loading branch information
melekes authored Jun 19, 2023
1 parent 0d5d7d7 commit 8ae0acb
Show file tree
Hide file tree
Showing 531 changed files with 3,348 additions and 3,108 deletions.
10 changes: 5 additions & 5 deletions constraints/examples/json.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::iter::FromIterator;

use webrtc_constraints::algorithms::{
select_settings_candidates, ClosestToIdealPolicy, DeviceInformationExposureMode,
TieBreakingPolicy,
};
use webrtc_constraints::property::all::name::*;
use webrtc_constraints::{
algorithms::{
select_settings_candidates, ClosestToIdealPolicy, DeviceInformationExposureMode,
TieBreakingPolicy,
},
property::all::name::*,
MediaTrackConstraints, MediaTrackSettings, MediaTrackSupportedConstraints,
};

Expand Down
14 changes: 6 additions & 8 deletions constraints/examples/macros.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use std::iter::FromIterator;

use webrtc_constraints::{
algorithms::{
select_settings_candidates, ClosestToIdealPolicy, DeviceInformationExposureMode,
TieBreakingPolicy,
},
macros::*,
property::all::name::*,
settings, MediaTrackSupportedConstraints, ResizeMode,
use webrtc_constraints::algorithms::{
select_settings_candidates, ClosestToIdealPolicy, DeviceInformationExposureMode,
TieBreakingPolicy,
};
use webrtc_constraints::macros::*;
use webrtc_constraints::property::all::name::*;
use webrtc_constraints::{settings, MediaTrackSupportedConstraints, ResizeMode};

fn main() {
let supported_constraints =
Expand Down
10 changes: 5 additions & 5 deletions constraints/examples/native.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::iter::FromIterator;

use webrtc_constraints::algorithms::{
select_settings_candidates, ClosestToIdealPolicy, DeviceInformationExposureMode,
TieBreakingPolicy,
};
use webrtc_constraints::property::all::name::*;
use webrtc_constraints::{
algorithms::{
select_settings_candidates, ClosestToIdealPolicy, DeviceInformationExposureMode,
TieBreakingPolicy,
},
property::all::name::*,
AdvancedMediaTrackConstraints, MandatoryMediaTrackConstraints, MediaTrackConstraintSet,
MediaTrackConstraints, MediaTrackSettings, MediaTrackSupportedConstraints, ResizeMode,
ResolvedValueConstraint, ResolvedValueRangeConstraint, ValueConstraint, ValueRangeConstraint,
Expand Down
6 changes: 2 additions & 4 deletions constraints/src/algorithms/fitness_distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ mod value_sequence_constraint;

use std::cmp::Ordering;

pub use self::{
setting::{SettingFitnessDistanceError, SettingFitnessDistanceErrorKind},
settings::SettingsFitnessDistanceError,
};
pub use self::setting::{SettingFitnessDistanceError, SettingFitnessDistanceErrorKind};
pub use self::settings::SettingsFitnessDistanceError;

fn nearly_cmp(lhs: f64, rhs: f64) -> Ordering {
// Based on: https://stackoverflow.com/a/32334103/227536
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::setting::SettingFitnessDistanceError;
use super::FitnessDistance;
use crate::constraint::EmptyConstraint;

use super::{setting::SettingFitnessDistanceError, FitnessDistance};

impl<'a, T> FitnessDistance<Option<&'a T>> for EmptyConstraint {
type Error = SettingFitnessDistanceError;

Expand Down
19 changes: 7 additions & 12 deletions constraints/src/algorithms/fitness_distance/setting.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::{MediaTrackSetting, ResolvedMediaTrackConstraint};

use super::FitnessDistance;
use crate::{MediaTrackSetting, ResolvedMediaTrackConstraint};

/// An error indicating a rejected fitness distance computation,
/// likely caused by a mismatched yet required constraint.
Expand Down Expand Up @@ -117,9 +116,9 @@ impl<'a> FitnessDistance<Option<&'a MediaTrackSetting>> for ResolvedMediaTrackCo

#[cfg(test)]
mod tests {
use crate::{constraint::EmptyConstraint, MediaTrackSetting, ResolvedMediaTrackConstraint};

use super::*;
use crate::constraint::EmptyConstraint;
use crate::{MediaTrackSetting, ResolvedMediaTrackConstraint};

#[test]
fn empty_constraint() {
Expand Down Expand Up @@ -150,9 +149,8 @@ mod tests {
}

mod bool_constraint {
use crate::ResolvedValueConstraint;

use super::*;
use crate::ResolvedValueConstraint;

#[test]
fn bool_setting() {
Expand Down Expand Up @@ -231,9 +229,8 @@ mod tests {
}

mod numeric_constraint {
use crate::ResolvedValueRangeConstraint;

use super::*;
use crate::ResolvedValueRangeConstraint;

#[test]
fn missing_settings() {
Expand Down Expand Up @@ -357,9 +354,8 @@ mod tests {
}

mod string_constraint {
use crate::ResolvedValueConstraint;

use super::*;
use crate::ResolvedValueConstraint;

#[test]
fn missing_settings() {
Expand Down Expand Up @@ -445,9 +441,8 @@ mod tests {
}

mod string_sequence_constraint {
use crate::ResolvedValueSequenceConstraint;

use super::*;
use crate::ResolvedValueSequenceConstraint;

#[test]
fn missing_settings() {
Expand Down
4 changes: 2 additions & 2 deletions constraints/src/algorithms/fitness_distance/settings.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::collections::HashMap;

use super::setting::SettingFitnessDistanceError;
use super::FitnessDistance;
use crate::{MediaTrackProperty, MediaTrackSettings, SanitizedMediaTrackConstraintSet};

use super::{setting::SettingFitnessDistanceError, FitnessDistance};

/// A list of media track properties and their corresponding fitness distance errors.
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct SettingsFitnessDistanceError {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use super::setting::SettingFitnessDistanceError;
use super::{FitnessDistance, SettingFitnessDistanceErrorKind};
use crate::constraint::ResolvedValueConstraint;

use super::{
setting::SettingFitnessDistanceError, FitnessDistance, SettingFitnessDistanceErrorKind,
};

// Standard implementation for value constraints of arbitrary `Setting` and `Constraint`
// types where `Setting: PartialEq<Constraint>`:
macro_rules! impl_non_numeric_value_constraint {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use super::setting::SettingFitnessDistanceError;
use super::{FitnessDistance, SettingFitnessDistanceErrorKind};
use crate::ResolvedValueRangeConstraint;

use super::{
setting::SettingFitnessDistanceError, FitnessDistance, SettingFitnessDistanceErrorKind,
};

macro_rules! impl_value_range_constraint {
(setting: $s:ty, constraint: $c:ty) => {
impl<'a> FitnessDistance<Option<&'a $s>> for ResolvedValueRangeConstraint<$c> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::algorithms::SettingFitnessDistanceErrorKind;

use super::*;
use crate::algorithms::SettingFitnessDistanceErrorKind;

mod basic {
use super::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::algorithms::SettingFitnessDistanceErrorKind;

use super::*;
use crate::algorithms::SettingFitnessDistanceErrorKind;

mod basic {
use super::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use super::setting::SettingFitnessDistanceError;
use super::{FitnessDistance, SettingFitnessDistanceErrorKind};
use crate::ResolvedValueSequenceConstraint;

use super::{
setting::SettingFitnessDistanceError, FitnessDistance, SettingFitnessDistanceErrorKind,
};

macro_rules! impl_non_numeric_value_sequence_constraint {
(setting: $s:ty, constraint: $c:ty) => {
impl<'a> FitnessDistance<Option<&'a $s>> for ResolvedValueSequenceConstraint<$c>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::algorithms::SettingFitnessDistanceErrorKind;

use super::*;
use crate::algorithms::SettingFitnessDistanceErrorKind;

mod basic {
use super::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::algorithms::SettingFitnessDistanceErrorKind;

use super::*;
use crate::algorithms::SettingFitnessDistanceErrorKind;

mod basic {
use super::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::algorithms::SettingFitnessDistanceErrorKind;

use super::*;
use crate::algorithms::SettingFitnessDistanceErrorKind;

mod basic {
use super::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::algorithms::SettingFitnessDistanceErrorKind;

use super::*;
use crate::algorithms::SettingFitnessDistanceErrorKind;

mod basic {
use super::*;
Expand Down
12 changes: 6 additions & 6 deletions constraints/src/algorithms/select_settings.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use std::collections::HashSet;

use crate::{
algorithms::fitness_distance::SettingFitnessDistanceError, errors::OverconstrainedError,
MediaTrackSettings, SanitizedMediaTrackConstraints,
};
use crate::algorithms::fitness_distance::SettingFitnessDistanceError;
use crate::errors::OverconstrainedError;
use crate::{MediaTrackSettings, SanitizedMediaTrackConstraints};

mod apply_advanced;
mod apply_mandatory;
mod select_optimal;
mod tie_breaking;

use self::apply_advanced::*;
use self::apply_mandatory::*;
use self::select_optimal::*;
pub use self::tie_breaking::*;

use self::{apply_advanced::*, apply_mandatory::*, select_optimal::*};

/// A mode indicating whether device information may be exposed.
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum DeviceInformationExposureMode {
Expand Down
16 changes: 7 additions & 9 deletions constraints/src/algorithms/select_settings/apply_advanced.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{
algorithms::FitnessDistance, constraints::SanitizedAdvancedMediaTrackConstraints,
MediaTrackSettings,
};
use crate::algorithms::FitnessDistance;
use crate::constraints::SanitizedAdvancedMediaTrackConstraints;
use crate::MediaTrackSettings;

/// Returns the set of settings for which all non-overconstraining advanced constraints'
/// fitness distance is finite.
Expand Down Expand Up @@ -56,14 +55,13 @@ pub(super) fn apply_advanced_constraints<'a>(
mod tests {
use std::iter::FromIterator;

use super::*;
use crate::property::all::name::*;
use crate::{
property::all::name::*, MediaTrackSupportedConstraints, ResizeMode,
ResolvedAdvancedMediaTrackConstraints, ResolvedMediaTrackConstraintSet,
ResolvedValueConstraint, ResolvedValueRangeConstraint,
MediaTrackSupportedConstraints, ResizeMode, ResolvedAdvancedMediaTrackConstraints,
ResolvedMediaTrackConstraintSet, ResolvedValueConstraint, ResolvedValueRangeConstraint,
};

use super::*;

// Advanced constraint sets that doe not match any
// candidates should just get ignored:
#[test]
Expand Down
21 changes: 8 additions & 13 deletions constraints/src/algorithms/select_settings/apply_mandatory.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
use std::collections::HashMap;

use crate::{
algorithms::{
select_settings::{ConstraintFailureInfo, DeviceInformationExposureMode},
FitnessDistance,
},
errors::OverconstrainedError,
MediaTrackProperty, MediaTrackSettings, SanitizedMediaTrackConstraintSet,
};
use crate::algorithms::select_settings::{ConstraintFailureInfo, DeviceInformationExposureMode};
use crate::algorithms::FitnessDistance;
use crate::errors::OverconstrainedError;
use crate::{MediaTrackProperty, MediaTrackSettings, SanitizedMediaTrackConstraintSet};

/// Returns the set of settings for which all mandatory constraints'
/// fitness distance is finite.
Expand Down Expand Up @@ -68,14 +64,13 @@ where
mod tests {
use std::iter::FromIterator;

use super::*;
use crate::property::all::name::*;
use crate::{
property::all::name::*, MediaTrackSupportedConstraints, ResizeMode,
ResolvedMandatoryMediaTrackConstraints, ResolvedValueConstraint,
ResolvedValueRangeConstraint,
MediaTrackSupportedConstraints, ResizeMode, ResolvedMandatoryMediaTrackConstraints,
ResolvedValueConstraint, ResolvedValueRangeConstraint,
};

use super::*;

// Advanced constraint sets that do not match any candidates should just get ignored:
#[test]
fn overconstrained() {
Expand Down
3 changes: 1 addition & 2 deletions constraints/src/algorithms/select_settings/select_optimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ where

#[cfg(test)]
mod tests {
use crate::MediaTrackSettings;

use super::select_optimal_candidates;
use crate::MediaTrackSettings;

#[test]
fn monotonic_increasing() {
Expand Down
16 changes: 7 additions & 9 deletions constraints/src/algorithms/select_settings/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ use std::iter::FromIterator;

use lazy_static::lazy_static;

use super::DeviceInformationExposureMode;
use crate::algorithms::{select_settings_candidates, SelectSettingsError};
use crate::errors::OverconstrainedError;
use crate::property::all::name::*;
use crate::property::all::names as all_properties;
use crate::{
algorithms::{select_settings_candidates, SelectSettingsError},
errors::OverconstrainedError,
property::all::{name::*, names as all_properties},
AdvancedMediaTrackConstraints, FacingMode, MandatoryMediaTrackConstraints,
MediaTrackConstraints, MediaTrackSettings, MediaTrackSupportedConstraints, ResizeMode,
ResolvedAdvancedMediaTrackConstraints, ResolvedMandatoryMediaTrackConstraints,
ResolvedMediaTrackConstraint, ResolvedMediaTrackConstraints, ResolvedValueConstraint,
ResolvedValueRangeConstraint, ResolvedValueSequenceConstraint, SanitizedMediaTrackConstraints,
};

use super::DeviceInformationExposureMode;

lazy_static! {
static ref VIDEO_IDEAL: MediaTrackSettings = MediaTrackSettings::from_iter([
(&ASPECT_RATIO, 0.5625.into()),
Expand Down Expand Up @@ -161,9 +161,8 @@ mod unconstrained {
}

mod overconstrained {
use crate::MediaTrackProperty;

use super::*;
use crate::MediaTrackProperty;

#[test]
fn protected() {
Expand Down Expand Up @@ -502,9 +501,8 @@ mod constrained {
// selected settings: ─────────────────────────────────────────┘
// ```
mod smoke {
use crate::{MediaTrackConstraintSet, ValueConstraint, ValueRangeConstraint};

use super::*;
use crate::{MediaTrackConstraintSet, ValueConstraint, ValueRangeConstraint};

#[test]
fn native() {
Expand Down
Loading

0 comments on commit 8ae0acb

Please sign in to comment.