From 9bc75b9627032b12141808f6710201a5822643b0 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Tue, 30 Apr 2024 08:44:33 +0200 Subject: [PATCH] Rename emgauwa-lib to emgauwa-common --- .forgejo/workflows/release.yaml | 33 ++++++++++++++++++ Cargo.lock | Bin 69752 -> 69761 bytes Cargo.toml | 2 +- {emgauwa-lib => emgauwa-common}/Cargo.toml | 2 +- {emgauwa-lib => emgauwa-common}/build.rs | 0 .../src/constants.rs | 0 .../src/db/controllers.rs | 0 .../src/db/junction_relay_schedule.rs | 0 .../src/db/junction_tag.rs | 0 .../src/db/macro.rs | 0 .../src/db/macro_action.rs | 0 {emgauwa-lib => emgauwa-common}/src/db/mod.rs | 0 .../src/db/model_utils.rs | 0 .../src/db/relays.rs | 0 .../src/db/schedules.rs | 0 {emgauwa-lib => emgauwa-common}/src/db/tag.rs | 0 .../src/drivers/gpio.rs | 0 .../src/drivers/mod.rs | 0 .../src/drivers/null.rs | 0 .../src/drivers/piface.rs | 0 .../src/errors/api_error.rs | 0 .../src/errors/database_error.rs | 0 .../src/errors/emgauwa_error.rs | 0 .../src/errors/mod.rs | 0 {emgauwa-lib => emgauwa-common}/src/lib.rs | 0 .../src/models/controller.rs | 0 .../src/models/macro.rs | 0 .../src/models/macro_action.rs | 0 .../src/models/mod.rs | 0 .../src/models/relay.rs | 0 .../src/models/schedule.rs | 0 .../src/models/tag.rs | 0 .../src/settings.rs | 0 .../src/types/emgauwa_uid.rs | 0 .../src/types/mod.rs | 0 .../src/types/request.rs | 0 .../src/types/schedule_uid.rs | 0 {emgauwa-lib => emgauwa-common}/src/utils.rs | 0 emgauwa-controller/Cargo.toml | 2 +- emgauwa-controller/src/app_state.rs | 10 +++--- emgauwa-controller/src/main.rs | 12 +++---- emgauwa-controller/src/relay_loop.rs | 14 ++++---- emgauwa-controller/src/settings.rs | 4 +-- emgauwa-controller/src/utils.rs | 6 ++-- emgauwa-controller/src/ws/mod.rs | 10 +++--- emgauwa-core/Cargo.toml | 2 +- emgauwa-core/src/app_state.rs | 8 ++--- emgauwa-core/src/handlers/v1/controllers.rs | 8 ++--- emgauwa-core/src/handlers/v1/macros.rs | 8 ++--- emgauwa-core/src/handlers/v1/relays.rs | 12 ++++--- emgauwa-core/src/handlers/v1/schedules.rs | 8 ++--- emgauwa-core/src/handlers/v1/tags.rs | 8 ++--- .../handlers/v1/ws/controllers/handlers.rs | 10 +++--- .../src/handlers/v1/ws/controllers/mod.rs | 6 ++-- emgauwa-core/src/handlers/v1/ws/mod.rs | 2 +- emgauwa-core/src/handlers/v1/ws/relays/mod.rs | 4 +-- emgauwa-core/src/main.rs | 8 ++--- emgauwa-core/src/settings.rs | 4 +-- 58 files changed, 109 insertions(+), 74 deletions(-) create mode 100644 .forgejo/workflows/release.yaml rename {emgauwa-lib => emgauwa-common}/Cargo.toml (96%) rename {emgauwa-lib => emgauwa-common}/build.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/constants.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/db/controllers.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/db/junction_relay_schedule.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/db/junction_tag.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/db/macro.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/db/macro_action.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/db/mod.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/db/model_utils.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/db/relays.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/db/schedules.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/db/tag.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/drivers/gpio.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/drivers/mod.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/drivers/null.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/drivers/piface.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/errors/api_error.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/errors/database_error.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/errors/emgauwa_error.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/errors/mod.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/lib.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/models/controller.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/models/macro.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/models/macro_action.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/models/mod.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/models/relay.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/models/schedule.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/models/tag.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/settings.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/types/emgauwa_uid.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/types/mod.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/types/request.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/types/schedule_uid.rs (100%) rename {emgauwa-lib => emgauwa-common}/src/utils.rs (100%) diff --git a/.forgejo/workflows/release.yaml b/.forgejo/workflows/release.yaml new file mode 100644 index 0000000..4f2a74d --- /dev/null +++ b/.forgejo/workflows/release.yaml @@ -0,0 +1,33 @@ +on: + push: + tags: + - v** +jobs: + build-artifacts: + runs-on: docker + strategy: + matrix: + arch: + #- x86_64-unknown-linux-musl # for docker + - arm-unknown-linux-gnueabihf # for raspberry pi + steps: + - uses: https://code.forgejo.org/actions/checkout@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - id: install-dependencies + run: | + curl https://sh.rustup.rs -sSf | sh -s -- -y + shell: bash + - id: cargo-build-release + run: | + source "$HOME/.cargo/env" + cross build --target ${{ matrix.arch }} --release + shell: bash + - uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: emgauwa-core_${{ matrix.arch }} + path: ${{ github.workspace }}/target/${{ matrix.arch }}/release/emgauwa-core + - uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: emgauwa-controller_${{ matrix.arch }} + path: ${{ github.workspace }}/target/${{ matrix.arch }}/release/emgauwa-controller diff --git a/Cargo.lock b/Cargo.lock index 346f9a490310d35a64064ed9dc97e4c51dc95b5f..3f48599ee033a9f2dec875686e0e9d6fa78816b0 100644 GIT binary patch delta 58 zcmeydfTeLE%LZFVmfYO@yvbEg=9BL`|D2rf#5vj4(T6QLA0)iF$1#Nw%AWk$Y4zqC IE(=Zr0LdE}IsgCw delta 48 zcmZo%$ns+W%LZG=$yH81%sH7!o6k6"] diff --git a/emgauwa-lib/build.rs b/emgauwa-common/build.rs similarity index 100% rename from emgauwa-lib/build.rs rename to emgauwa-common/build.rs diff --git a/emgauwa-lib/src/constants.rs b/emgauwa-common/src/constants.rs similarity index 100% rename from emgauwa-lib/src/constants.rs rename to emgauwa-common/src/constants.rs diff --git a/emgauwa-lib/src/db/controllers.rs b/emgauwa-common/src/db/controllers.rs similarity index 100% rename from emgauwa-lib/src/db/controllers.rs rename to emgauwa-common/src/db/controllers.rs diff --git a/emgauwa-lib/src/db/junction_relay_schedule.rs b/emgauwa-common/src/db/junction_relay_schedule.rs similarity index 100% rename from emgauwa-lib/src/db/junction_relay_schedule.rs rename to emgauwa-common/src/db/junction_relay_schedule.rs diff --git a/emgauwa-lib/src/db/junction_tag.rs b/emgauwa-common/src/db/junction_tag.rs similarity index 100% rename from emgauwa-lib/src/db/junction_tag.rs rename to emgauwa-common/src/db/junction_tag.rs diff --git a/emgauwa-lib/src/db/macro.rs b/emgauwa-common/src/db/macro.rs similarity index 100% rename from emgauwa-lib/src/db/macro.rs rename to emgauwa-common/src/db/macro.rs diff --git a/emgauwa-lib/src/db/macro_action.rs b/emgauwa-common/src/db/macro_action.rs similarity index 100% rename from emgauwa-lib/src/db/macro_action.rs rename to emgauwa-common/src/db/macro_action.rs diff --git a/emgauwa-lib/src/db/mod.rs b/emgauwa-common/src/db/mod.rs similarity index 100% rename from emgauwa-lib/src/db/mod.rs rename to emgauwa-common/src/db/mod.rs diff --git a/emgauwa-lib/src/db/model_utils.rs b/emgauwa-common/src/db/model_utils.rs similarity index 100% rename from emgauwa-lib/src/db/model_utils.rs rename to emgauwa-common/src/db/model_utils.rs diff --git a/emgauwa-lib/src/db/relays.rs b/emgauwa-common/src/db/relays.rs similarity index 100% rename from emgauwa-lib/src/db/relays.rs rename to emgauwa-common/src/db/relays.rs diff --git a/emgauwa-lib/src/db/schedules.rs b/emgauwa-common/src/db/schedules.rs similarity index 100% rename from emgauwa-lib/src/db/schedules.rs rename to emgauwa-common/src/db/schedules.rs diff --git a/emgauwa-lib/src/db/tag.rs b/emgauwa-common/src/db/tag.rs similarity index 100% rename from emgauwa-lib/src/db/tag.rs rename to emgauwa-common/src/db/tag.rs diff --git a/emgauwa-lib/src/drivers/gpio.rs b/emgauwa-common/src/drivers/gpio.rs similarity index 100% rename from emgauwa-lib/src/drivers/gpio.rs rename to emgauwa-common/src/drivers/gpio.rs diff --git a/emgauwa-lib/src/drivers/mod.rs b/emgauwa-common/src/drivers/mod.rs similarity index 100% rename from emgauwa-lib/src/drivers/mod.rs rename to emgauwa-common/src/drivers/mod.rs diff --git a/emgauwa-lib/src/drivers/null.rs b/emgauwa-common/src/drivers/null.rs similarity index 100% rename from emgauwa-lib/src/drivers/null.rs rename to emgauwa-common/src/drivers/null.rs diff --git a/emgauwa-lib/src/drivers/piface.rs b/emgauwa-common/src/drivers/piface.rs similarity index 100% rename from emgauwa-lib/src/drivers/piface.rs rename to emgauwa-common/src/drivers/piface.rs diff --git a/emgauwa-lib/src/errors/api_error.rs b/emgauwa-common/src/errors/api_error.rs similarity index 100% rename from emgauwa-lib/src/errors/api_error.rs rename to emgauwa-common/src/errors/api_error.rs diff --git a/emgauwa-lib/src/errors/database_error.rs b/emgauwa-common/src/errors/database_error.rs similarity index 100% rename from emgauwa-lib/src/errors/database_error.rs rename to emgauwa-common/src/errors/database_error.rs diff --git a/emgauwa-lib/src/errors/emgauwa_error.rs b/emgauwa-common/src/errors/emgauwa_error.rs similarity index 100% rename from emgauwa-lib/src/errors/emgauwa_error.rs rename to emgauwa-common/src/errors/emgauwa_error.rs diff --git a/emgauwa-lib/src/errors/mod.rs b/emgauwa-common/src/errors/mod.rs similarity index 100% rename from emgauwa-lib/src/errors/mod.rs rename to emgauwa-common/src/errors/mod.rs diff --git a/emgauwa-lib/src/lib.rs b/emgauwa-common/src/lib.rs similarity index 100% rename from emgauwa-lib/src/lib.rs rename to emgauwa-common/src/lib.rs diff --git a/emgauwa-lib/src/models/controller.rs b/emgauwa-common/src/models/controller.rs similarity index 100% rename from emgauwa-lib/src/models/controller.rs rename to emgauwa-common/src/models/controller.rs diff --git a/emgauwa-lib/src/models/macro.rs b/emgauwa-common/src/models/macro.rs similarity index 100% rename from emgauwa-lib/src/models/macro.rs rename to emgauwa-common/src/models/macro.rs diff --git a/emgauwa-lib/src/models/macro_action.rs b/emgauwa-common/src/models/macro_action.rs similarity index 100% rename from emgauwa-lib/src/models/macro_action.rs rename to emgauwa-common/src/models/macro_action.rs diff --git a/emgauwa-lib/src/models/mod.rs b/emgauwa-common/src/models/mod.rs similarity index 100% rename from emgauwa-lib/src/models/mod.rs rename to emgauwa-common/src/models/mod.rs diff --git a/emgauwa-lib/src/models/relay.rs b/emgauwa-common/src/models/relay.rs similarity index 100% rename from emgauwa-lib/src/models/relay.rs rename to emgauwa-common/src/models/relay.rs diff --git a/emgauwa-lib/src/models/schedule.rs b/emgauwa-common/src/models/schedule.rs similarity index 100% rename from emgauwa-lib/src/models/schedule.rs rename to emgauwa-common/src/models/schedule.rs diff --git a/emgauwa-lib/src/models/tag.rs b/emgauwa-common/src/models/tag.rs similarity index 100% rename from emgauwa-lib/src/models/tag.rs rename to emgauwa-common/src/models/tag.rs diff --git a/emgauwa-lib/src/settings.rs b/emgauwa-common/src/settings.rs similarity index 100% rename from emgauwa-lib/src/settings.rs rename to emgauwa-common/src/settings.rs diff --git a/emgauwa-lib/src/types/emgauwa_uid.rs b/emgauwa-common/src/types/emgauwa_uid.rs similarity index 100% rename from emgauwa-lib/src/types/emgauwa_uid.rs rename to emgauwa-common/src/types/emgauwa_uid.rs diff --git a/emgauwa-lib/src/types/mod.rs b/emgauwa-common/src/types/mod.rs similarity index 100% rename from emgauwa-lib/src/types/mod.rs rename to emgauwa-common/src/types/mod.rs diff --git a/emgauwa-lib/src/types/request.rs b/emgauwa-common/src/types/request.rs similarity index 100% rename from emgauwa-lib/src/types/request.rs rename to emgauwa-common/src/types/request.rs diff --git a/emgauwa-lib/src/types/schedule_uid.rs b/emgauwa-common/src/types/schedule_uid.rs similarity index 100% rename from emgauwa-lib/src/types/schedule_uid.rs rename to emgauwa-common/src/types/schedule_uid.rs diff --git a/emgauwa-lib/src/utils.rs b/emgauwa-common/src/utils.rs similarity index 100% rename from emgauwa-lib/src/utils.rs rename to emgauwa-common/src/utils.rs diff --git a/emgauwa-controller/Cargo.toml b/emgauwa-controller/Cargo.toml index 4f31798..9947bc5 100644 --- a/emgauwa-controller/Cargo.toml +++ b/emgauwa-controller/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" authors = ["Tobias Reisinger "] [dependencies] -emgauwa-lib = { path = "../emgauwa-lib" } +emgauwa-common = { path = "../emgauwa-common" } actix = "0.13" diff --git a/emgauwa-controller/src/app_state.rs b/emgauwa-controller/src/app_state.rs index a6b3bbf..ec9e262 100644 --- a/emgauwa-controller/src/app_state.rs +++ b/emgauwa-controller/src/app_state.rs @@ -2,11 +2,11 @@ use std::sync::Arc; use std::time::{Duration, Instant}; use actix::{Actor, Context, Handler, Message}; -use emgauwa_lib::constants; -use emgauwa_lib::drivers::RelayDriver; -use emgauwa_lib::errors::EmgauwaError; -use emgauwa_lib::models::Controller; -use emgauwa_lib::types::RelayStates; +use emgauwa_common::constants; +use emgauwa_common::drivers::RelayDriver; +use emgauwa_common::errors::EmgauwaError; +use emgauwa_common::models::Controller; +use emgauwa_common::types::RelayStates; use futures::executor::block_on; use sqlx::{Pool, Sqlite}; use tokio::sync::Notify; diff --git a/emgauwa-controller/src/main.rs b/emgauwa-controller/src/main.rs index e290d06..1ba2d42 100644 --- a/emgauwa-controller/src/main.rs +++ b/emgauwa-controller/src/main.rs @@ -1,10 +1,10 @@ use actix::Actor; -use emgauwa_lib::db; -use emgauwa_lib::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbSchedule}; -use emgauwa_lib::errors::EmgauwaError; -use emgauwa_lib::models::{Controller, FromDbModel}; -use emgauwa_lib::types::EmgauwaUid; -use emgauwa_lib::utils::{drop_privileges, init_logging}; +use emgauwa_common::db; +use emgauwa_common::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbSchedule}; +use emgauwa_common::errors::EmgauwaError; +use emgauwa_common::models::{Controller, FromDbModel}; +use emgauwa_common::types::EmgauwaUid; +use emgauwa_common::utils::{drop_privileges, init_logging}; use rppal_pfd::PiFaceDigital; use sqlx::pool::PoolConnection; use sqlx::Sqlite; diff --git a/emgauwa-controller/src/relay_loop.rs b/emgauwa-controller/src/relay_loop.rs index 2bf2bb5..3247f7f 100644 --- a/emgauwa-controller/src/relay_loop.rs +++ b/emgauwa-controller/src/relay_loop.rs @@ -2,11 +2,11 @@ use std::time::{Duration, Instant}; use actix::Addr; use chrono::{Local, Timelike}; -use emgauwa_lib::constants::RELAYS_RETRY_TIMEOUT; -use emgauwa_lib::errors::EmgauwaError; -use emgauwa_lib::models::Controller; -use emgauwa_lib::types::{RelayStates, Weekday}; -use emgauwa_lib::utils::printable_relay_states; +use emgauwa_common::constants::RELAYS_RETRY_TIMEOUT; +use emgauwa_common::errors::EmgauwaError; +use emgauwa_common::models::Controller; +use emgauwa_common::types::{RelayStates, Weekday}; +use emgauwa_common::utils::printable_relay_states; use futures::pin_mut; use tokio::time; use tokio::time::timeout; @@ -29,7 +29,7 @@ pub async fn run_relays_loop(app_state: Addr) { async fn run_relays(app_state: &Addr) -> Result<(), EmgauwaError> { let notifier = &*app_state_get_controller_notifier(app_state).await?; - let mut last_weekday = emgauwa_lib::utils::get_weekday(); + let mut last_weekday = emgauwa_common::utils::get_weekday(); let mut this = utils::app_state_get_this(app_state).await?; let mut relay_states: RelayStates = Vec::new(); init_relay_states(&mut relay_states, &this); @@ -138,7 +138,7 @@ async fn check_weekday( last_weekday: &mut Weekday, changed: &mut bool, ) -> Result<(), EmgauwaError> { - let current_weekday = emgauwa_lib::utils::get_weekday(); + let current_weekday = emgauwa_common::utils::get_weekday(); if current_weekday.ne(last_weekday) { log::debug!("Weekday changed"); *last_weekday = current_weekday; diff --git a/emgauwa-controller/src/settings.rs b/emgauwa-controller/src/settings.rs index 3eead14..0e6562a 100644 --- a/emgauwa-controller/src/settings.rs +++ b/emgauwa-controller/src/settings.rs @@ -1,5 +1,5 @@ -use emgauwa_lib::errors::EmgauwaError; -use emgauwa_lib::{drivers, settings}; +use emgauwa_common::errors::EmgauwaError; +use emgauwa_common::{drivers, settings}; use rppal_pfd::PiFaceDigital; use serde_derive::Deserialize; diff --git a/emgauwa-controller/src/utils.rs b/emgauwa-controller/src/utils.rs index 674a561..c6d2830 100644 --- a/emgauwa-controller/src/utils.rs +++ b/emgauwa-controller/src/utils.rs @@ -1,9 +1,9 @@ use std::sync::Arc; use actix::Addr; -use emgauwa_lib::errors::EmgauwaError; -use emgauwa_lib::models::Controller; -use emgauwa_lib::types::RelayStates; +use emgauwa_common::errors::EmgauwaError; +use emgauwa_common::models::Controller; +use emgauwa_common::types::RelayStates; use tokio::sync::Notify; use crate::app_state; diff --git a/emgauwa-controller/src/ws/mod.rs b/emgauwa-controller/src/ws/mod.rs index e2a66fe..994cec6 100644 --- a/emgauwa-controller/src/ws/mod.rs +++ b/emgauwa-controller/src/ws/mod.rs @@ -1,9 +1,9 @@ use actix::Addr; -use emgauwa_lib::constants::WEBSOCKET_RETRY_TIMEOUT; -use emgauwa_lib::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbSchedule}; -use emgauwa_lib::errors::{DatabaseError, EmgauwaError}; -use emgauwa_lib::models::{Controller, Relay}; -use emgauwa_lib::types::{ControllerWsAction, ScheduleUid}; +use emgauwa_common::constants::WEBSOCKET_RETRY_TIMEOUT; +use emgauwa_common::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbSchedule}; +use emgauwa_common::errors::{DatabaseError, EmgauwaError}; +use emgauwa_common::models::{Controller, Relay}; +use emgauwa_common::types::{ControllerWsAction, ScheduleUid}; use futures::{future, pin_mut, SinkExt, StreamExt}; use sqlx::pool::PoolConnection; use sqlx::{Pool, Sqlite}; diff --git a/emgauwa-core/Cargo.toml b/emgauwa-core/Cargo.toml index a3dd89a..29d5a12 100644 --- a/emgauwa-core/Cargo.toml +++ b/emgauwa-core/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" authors = ["Tobias Reisinger "] [dependencies] -emgauwa-lib = { path = "../emgauwa-lib" } +emgauwa-common = { path = "../emgauwa-common" } actix = "0.13" actix-web = "4.4" diff --git a/emgauwa-core/src/app_state.rs b/emgauwa-core/src/app_state.rs index c31a092..840fd1b 100644 --- a/emgauwa-core/src/app_state.rs +++ b/emgauwa-core/src/app_state.rs @@ -1,10 +1,10 @@ use std::collections::HashMap; use actix::{Actor, Addr, Context, Handler, Message, Recipient}; -use emgauwa_lib::db::DbController; -use emgauwa_lib::errors::EmgauwaError; -use emgauwa_lib::models::{convert_db_list, Controller, Relay}; -use emgauwa_lib::types::{ControllerWsAction, EmgauwaUid, RelayStates}; +use emgauwa_common::db::DbController; +use emgauwa_common::errors::EmgauwaError; +use emgauwa_common::models::{convert_db_list, Controller, Relay}; +use emgauwa_common::types::{ControllerWsAction, EmgauwaUid, RelayStates}; use futures::executor::block_on; use sqlx::{Pool, Sqlite}; diff --git a/emgauwa-core/src/handlers/v1/controllers.rs b/emgauwa-core/src/handlers/v1/controllers.rs index 2bfafca..3fdb931 100644 --- a/emgauwa-core/src/handlers/v1/controllers.rs +++ b/emgauwa-core/src/handlers/v1/controllers.rs @@ -1,9 +1,9 @@ use actix::Addr; use actix_web::{delete, get, put, web, HttpResponse}; -use emgauwa_lib::db::DbController; -use emgauwa_lib::errors::{DatabaseError, EmgauwaError}; -use emgauwa_lib::models::{convert_db_list, Controller, FromDbModel}; -use emgauwa_lib::types::{ControllerWsAction, EmgauwaUid, RequestControllerUpdate}; +use emgauwa_common::db::DbController; +use emgauwa_common::errors::{DatabaseError, EmgauwaError}; +use emgauwa_common::models::{convert_db_list, Controller, FromDbModel}; +use emgauwa_common::types::{ControllerWsAction, EmgauwaUid, RequestControllerUpdate}; use sqlx::{Pool, Sqlite}; use crate::app_state; diff --git a/emgauwa-core/src/handlers/v1/macros.rs b/emgauwa-core/src/handlers/v1/macros.rs index d4ab7eb..0e3fc60 100644 --- a/emgauwa-core/src/handlers/v1/macros.rs +++ b/emgauwa-core/src/handlers/v1/macros.rs @@ -1,9 +1,9 @@ use actix::Addr; use actix_web::{delete, get, post, put, web, HttpResponse}; -use emgauwa_lib::db::DbMacro; -use emgauwa_lib::errors::{DatabaseError, EmgauwaError}; -use emgauwa_lib::models::{convert_db_list, FromDbModel, Macro, MacroAction, Relay}; -use emgauwa_lib::types::{ +use emgauwa_common::db::DbMacro; +use emgauwa_common::errors::{DatabaseError, EmgauwaError}; +use emgauwa_common::models::{convert_db_list, FromDbModel, Macro, MacroAction, Relay}; +use emgauwa_common::types::{ ControllerWsAction, EmgauwaUid, RequestMacroCreate, RequestMacroExecute, RequestMacroUpdate, }; use itertools::Itertools; diff --git a/emgauwa-core/src/handlers/v1/relays.rs b/emgauwa-core/src/handlers/v1/relays.rs index 578745d..f07c081 100644 --- a/emgauwa-core/src/handlers/v1/relays.rs +++ b/emgauwa-core/src/handlers/v1/relays.rs @@ -1,10 +1,12 @@ use actix::Addr; use actix_web::{get, post, put, web, HttpResponse}; -use emgauwa_lib::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbTag}; -use emgauwa_lib::errors::{DatabaseError, EmgauwaError}; -use emgauwa_lib::models::{convert_db_list, FromDbModel, Relay}; -use emgauwa_lib::types::{ControllerWsAction, EmgauwaUid, RequestRelayPulse, RequestRelayUpdate}; -use emgauwa_lib::utils; +use emgauwa_common::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbTag}; +use emgauwa_common::errors::{DatabaseError, EmgauwaError}; +use emgauwa_common::models::{convert_db_list, FromDbModel, Relay}; +use emgauwa_common::types::{ + ControllerWsAction, EmgauwaUid, RequestRelayPulse, RequestRelayUpdate, +}; +use emgauwa_common::utils; use sqlx::{Pool, Sqlite}; use crate::app_state; diff --git a/emgauwa-core/src/handlers/v1/schedules.rs b/emgauwa-core/src/handlers/v1/schedules.rs index 3018d3c..7c8ccc6 100644 --- a/emgauwa-core/src/handlers/v1/schedules.rs +++ b/emgauwa-core/src/handlers/v1/schedules.rs @@ -1,9 +1,9 @@ use actix::Addr; use actix_web::{delete, get, post, put, web, HttpResponse}; -use emgauwa_lib::db::{DbController, DbJunctionRelaySchedule, DbSchedule, DbTag}; -use emgauwa_lib::errors::{ApiError, DatabaseError, EmgauwaError}; -use emgauwa_lib::models::{convert_db_list, FromDbModel, Schedule}; -use emgauwa_lib::types::{ +use emgauwa_common::db::{DbController, DbJunctionRelaySchedule, DbSchedule, DbTag}; +use emgauwa_common::errors::{ApiError, DatabaseError, EmgauwaError}; +use emgauwa_common::models::{convert_db_list, FromDbModel, Schedule}; +use emgauwa_common::types::{ ControllerWsAction, RequestScheduleCreate, RequestScheduleUpdate, ScheduleUid, }; use itertools::Itertools; diff --git a/emgauwa-core/src/handlers/v1/tags.rs b/emgauwa-core/src/handlers/v1/tags.rs index a34e29a..cf4ef36 100644 --- a/emgauwa-core/src/handlers/v1/tags.rs +++ b/emgauwa-core/src/handlers/v1/tags.rs @@ -1,8 +1,8 @@ use actix_web::{delete, get, post, web, HttpResponse}; -use emgauwa_lib::db::DbTag; -use emgauwa_lib::errors::{DatabaseError, EmgauwaError}; -use emgauwa_lib::models::{FromDbModel, Tag}; -use emgauwa_lib::types::RequestTagCreate; +use emgauwa_common::db::DbTag; +use emgauwa_common::errors::{DatabaseError, EmgauwaError}; +use emgauwa_common::models::{FromDbModel, Tag}; +use emgauwa_common::types::RequestTagCreate; use sqlx::{Pool, Sqlite}; #[get("/tags")] diff --git a/emgauwa-core/src/handlers/v1/ws/controllers/handlers.rs b/emgauwa-core/src/handlers/v1/ws/controllers/handlers.rs index 8980f60..9a01a7b 100644 --- a/emgauwa-core/src/handlers/v1/ws/controllers/handlers.rs +++ b/emgauwa-core/src/handlers/v1/ws/controllers/handlers.rs @@ -1,9 +1,9 @@ use actix::{Actor, AsyncContext}; -use emgauwa_lib::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbSchedule}; -use emgauwa_lib::errors::{DatabaseError, EmgauwaError}; -use emgauwa_lib::models::{Controller, FromDbModel}; -use emgauwa_lib::types::{ControllerWsAction, EmgauwaUid, RelayStates}; -use emgauwa_lib::utils; +use emgauwa_common::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbSchedule}; +use emgauwa_common::errors::{DatabaseError, EmgauwaError}; +use emgauwa_common::models::{Controller, FromDbModel}; +use emgauwa_common::types::{ControllerWsAction, EmgauwaUid, RelayStates}; +use emgauwa_common::utils; use futures::executor::block_on; use sqlx::pool::PoolConnection; use sqlx::Sqlite; diff --git a/emgauwa-core/src/handlers/v1/ws/controllers/mod.rs b/emgauwa-core/src/handlers/v1/ws/controllers/mod.rs index a54c9aa..2b39e5a 100644 --- a/emgauwa-core/src/handlers/v1/ws/controllers/mod.rs +++ b/emgauwa-core/src/handlers/v1/ws/controllers/mod.rs @@ -5,9 +5,9 @@ use std::time::Instant; use actix::{Actor, ActorContext, Addr, AsyncContext, Handler, StreamHandler}; use actix_web_actors::ws; use actix_web_actors::ws::ProtocolError; -use emgauwa_lib::constants::{HEARTBEAT_INTERVAL, HEARTBEAT_TIMEOUT}; -use emgauwa_lib::errors::EmgauwaError; -use emgauwa_lib::types::{ControllerWsAction, EmgauwaUid}; +use emgauwa_common::constants::{HEARTBEAT_INTERVAL, HEARTBEAT_TIMEOUT}; +use emgauwa_common::errors::EmgauwaError; +use emgauwa_common::types::{ControllerWsAction, EmgauwaUid}; use futures::executor::block_on; use sqlx::pool::PoolConnection; use sqlx::{Pool, Sqlite}; diff --git a/emgauwa-core/src/handlers/v1/ws/mod.rs b/emgauwa-core/src/handlers/v1/ws/mod.rs index 4fb3bf7..8507a67 100644 --- a/emgauwa-core/src/handlers/v1/ws/mod.rs +++ b/emgauwa-core/src/handlers/v1/ws/mod.rs @@ -3,7 +3,7 @@ use std::time::Instant; use actix::Addr; use actix_web::{get, web, HttpRequest, HttpResponse}; use actix_web_actors::ws; -use emgauwa_lib::errors::EmgauwaError; +use emgauwa_common::errors::EmgauwaError; use sqlx::{Pool, Sqlite}; use crate::app_state::AppState; diff --git a/emgauwa-core/src/handlers/v1/ws/relays/mod.rs b/emgauwa-core/src/handlers/v1/ws/relays/mod.rs index 5788aec..f4dd9e2 100644 --- a/emgauwa-core/src/handlers/v1/ws/relays/mod.rs +++ b/emgauwa-core/src/handlers/v1/ws/relays/mod.rs @@ -3,8 +3,8 @@ use std::time::Instant; use actix::{Actor, ActorContext, Addr, AsyncContext, Handler, Message, StreamHandler}; use actix_web_actors::ws; use actix_web_actors::ws::ProtocolError; -use emgauwa_lib::constants::{HEARTBEAT_INTERVAL, HEARTBEAT_TIMEOUT}; -use emgauwa_lib::errors::EmgauwaError; +use emgauwa_common::constants::{HEARTBEAT_INTERVAL, HEARTBEAT_TIMEOUT}; +use emgauwa_common::errors::EmgauwaError; use futures::executor::block_on; use crate::app_state::{AppState, ConnectRelayClient}; diff --git a/emgauwa-core/src/main.rs b/emgauwa-core/src/main.rs index f4e654f..adbd86f 100644 --- a/emgauwa-core/src/main.rs +++ b/emgauwa-core/src/main.rs @@ -4,9 +4,9 @@ use actix::{Actor, Arbiter}; use actix_cors::Cors; use actix_web::middleware::TrailingSlash; use actix_web::{middleware, web, App, HttpServer}; -use emgauwa_lib::db::DbController; -use emgauwa_lib::errors::EmgauwaError; -use emgauwa_lib::utils::{drop_privileges, init_logging}; +use emgauwa_common::db::DbController; +use emgauwa_common::errors::EmgauwaError; +use emgauwa_common::utils::{drop_privileges, init_logging}; use serde_json::json; use utoipa_swagger_ui::SwaggerUi; @@ -26,7 +26,7 @@ async fn main() -> Result<(), std::io::Error> { init_logging(&settings.logging.level)?; - let pool = emgauwa_lib::db::init(&settings.database).await?; + let pool = emgauwa_common::db::init(&settings.database).await?; let mut conn = pool.acquire().await.map_err(EmgauwaError::from)?; DbController::all_inactive(&mut conn) diff --git a/emgauwa-core/src/settings.rs b/emgauwa-core/src/settings.rs index c2e7bc4..620bf7a 100644 --- a/emgauwa-core/src/settings.rs +++ b/emgauwa-core/src/settings.rs @@ -1,5 +1,5 @@ -use emgauwa_lib::errors::EmgauwaError; -use emgauwa_lib::settings; +use emgauwa_common::errors::EmgauwaError; +use emgauwa_common::settings; use serde_derive::Deserialize; #[derive(Clone, Debug, Deserialize)]