diff --git a/.clippy.toml b/.clippy.toml new file mode 100644 index 00000000..16caf02e --- /dev/null +++ b/.clippy.toml @@ -0,0 +1 @@ +msrv = "1.60.0" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68432f7a..7f40faf4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: continue-on-error: ${{ matrix.required }} strategy: matrix: - build: [stable, nightly] + build: [stable, nightly, msrv] include: - build: stable required: true @@ -19,6 +19,9 @@ jobs: - build: nightly required: false toolchain: nightly + - build: msrv + required: true + toolchain: "1.60.0" services: postgres: @@ -47,7 +50,6 @@ jobs: profile: minimal toolchain: ${{ matrix.toolchain }} override: true - components: rustfmt - name: Rust cache uses: Swatinem/rust-cache@v2 @@ -163,4 +165,4 @@ jobs: uses: actions-rs/clippy-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - args: --all-features + args: --all-features --all --all-targets diff --git a/eventually-postgres/src/aggregate.rs b/eventually-postgres/src/aggregate.rs index b07ab089..c93697b4 100644 --- a/eventually-postgres/src/aggregate.rs +++ b/eventually-postgres/src/aggregate.rs @@ -89,8 +89,7 @@ pub enum SaveError { impl From for Option { fn from(err: SaveError) -> Self { match err { - SaveError::Conflict(v) => Some(v), - SaveError::Concurrency(v) => Some(v), + SaveError::Conflict(v) | SaveError::Concurrency(v) => Some(v), _ => None, } } diff --git a/eventually-postgres/src/event.rs b/eventually-postgres/src/event.rs index 8d80f7f4..c498d582 100644 --- a/eventually-postgres/src/event.rs +++ b/eventually-postgres/src/event.rs @@ -10,12 +10,7 @@ use eventually::{ version::Version, }; use futures::{future::ready, StreamExt, TryStreamExt}; -use lazy_static::lazy_static; -use regex::Regex; -use sqlx::{ - postgres::{PgDatabaseError, PgRow}, - PgPool, Postgres, Row, Transaction, -}; +use sqlx::{postgres::PgRow, PgPool, Postgres, Row, Transaction}; #[derive(Debug, thiserror::Error)] pub enum StreamError { @@ -54,8 +49,7 @@ pub enum AppendError { impl From for Option { fn from(err: AppendError) -> Self { match err { - AppendError::Conflict(v) => Some(v), - AppendError::Concurrency(v) => Some(v), + AppendError::Conflict(v) | AppendError::Concurrency(v) => Some(v), _ => None, } } @@ -184,11 +178,11 @@ where fn event_row_to_persisted_event( &self, stream_id: Id, - row: PgRow, + row: &PgRow, ) -> Result, StreamError> { - let version_column: i32 = try_get_column(&row, "version")?; - let event_column: Vec = try_get_column(&row, "event")?; - let metadata_column: sqlx::types::Json = try_get_column(&row, "metadata")?; + let version_column: i32 = try_get_column(row, "version")?; + let event_column: Vec = try_get_column(row, "event")?; + let metadata_column: sqlx::types::Json = try_get_column(row, "metadata")?; let deserialized_event = self .serde @@ -240,7 +234,7 @@ where .bind(from_version) .fetch(&self.pool) .map_err(StreamError::Database) - .and_then(move |row| ready(self.event_row_to_persisted_event(id.clone(), row))) + .and_then(move |row| ready(self.event_row_to_persisted_event(id.clone(), &row))) .boxed() } } diff --git a/eventually/src/aggregate.rs b/eventually/src/aggregate.rs index 8fc86666..712ef192 100644 --- a/eventually/src/aggregate.rs +++ b/eventually/src/aggregate.rs @@ -366,9 +366,7 @@ pub(crate) mod test_user_domain { return Err(UserError::EmptyPassword); } - Ok(Self::record_new( - UserEvent::WasCreated { email, password }.into(), - )?) + Self::record_new(UserEvent::WasCreated { email, password }.into()) } pub(crate) fn change_password(&mut self, password: String) -> Result<(), UserError> {