Compare commits

..

No commits in common. "c7d324b3f43b68eae0568153ca7e0976cc356734" and "05f047ec637c87754f536f43cd4ebaf0f684101b" have entirely different histories.

10 changed files with 558 additions and 524 deletions

23
.github/workflows/build_nix.yml vendored Normal file
View file

@ -0,0 +1,23 @@
name: "build nix"
on:
pull_request:
push:
jobs:
check_flurry_package:
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: nix flake check -L --all-systems
build_flurry_package:
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: nix build -L
build_flurry_shell:
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: nix shell -L --command echo 'it works'

45
.github/workflows/rust.yml vendored Normal file
View file

@ -0,0 +1,45 @@
name: rust build
on:
push:
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
check:
name: cargo check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
- run: cargo check
test:
name: cargo test
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
- run: cargo test --features all
clippy:
name: Clippy
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
components: clippy
- run: cargo clippy --features all --tests -- -Dclippy::all

26
.github/workflows/update.yml vendored Normal file
View file

@ -0,0 +1,26 @@
name: update dependencies
on:
workflow_dispatch: # allows manual triggering
schedule:
- cron: '0 4 * * *' # at 04:00 every day
jobs:
update:
name: Update dependencies
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v4
- run: nix shell -L nixpkgs#cargo --command cargo update
- run: nix shell -L nixpkgs#git --command git add Cargo.lock
- name: Check flake
uses: DeterminateSystems/flake-checker-action@main
- run: nix build -L
- name: Update Nix Flake Lock
uses: DeterminateSystems/update-flake-lock@main
with:
pr-title: "flake: update flake.lock"
pr-labels: |
dependencies
automated
token: ${{ secrets.GH_TOKEN_FOR_UPDATES }}

923
Cargo.lock generated

File diff suppressed because it is too large Load diff

24
flake.lock generated
View file

@ -3,11 +3,11 @@
"advisory-db": {
"flake": false,
"locked": {
"lastModified": 1758521157,
"narHash": "sha256-cDl1Qf/bTILEwq6DzMaTsrv6gWYZ47TO4sy7+NOA8Ok=",
"lastModified": 1745915470,
"narHash": "sha256-jmfA08xkDtjy9pT6YC5sL4iRtW4TlCSaURSaUnpc4/g=",
"owner": "rustsec",
"repo": "advisory-db",
"rev": "fb0d06e8e2cc04c9aa359e51ffa0a09e3bf58822",
"rev": "d63efe8c21f28b0690df6dc0a9879856bc0ffd88",
"type": "github"
},
"original": {
@ -34,11 +34,11 @@
},
"crane": {
"locked": {
"lastModified": 1758758545,
"narHash": "sha256-NU5WaEdfwF6i8faJ2Yh+jcK9vVFrofLcwlD/mP65JrI=",
"lastModified": 1745454774,
"narHash": "sha256-oLvmxOnsEKGtwczxp/CwhrfmQUG2ym24OMWowcoRhH8=",
"owner": "ipetkov",
"repo": "crane",
"rev": "95d528a5f54eaba0d12102249ce42f4d01f4e364",
"rev": "efd36682371678e2b6da3f108fdb5c613b3ec598",
"type": "github"
},
"original": {
@ -70,11 +70,11 @@
"rust-analyzer-src": []
},
"locked": {
"lastModified": 1758695884,
"narHash": "sha256-rnHjtBRkcwRkrUZxg0RqN1qWTG+QC/gj4vn9uzEkBww=",
"lastModified": 1745908826,
"narHash": "sha256-LNElDnQlQXiSGfJiPu4IJJ3PzHnoM31qEWElhz2VyH0=",
"owner": "nix-community",
"repo": "fenix",
"rev": "9cdb79384d02234fb2868eba6c7d390253ef6f83",
"rev": "6d93c0f68d080e6f5b42d2958708955c8ab8acd9",
"type": "github"
},
"original": {
@ -145,11 +145,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1758446476,
"narHash": "sha256-5rdAi7CTvM/kSs6fHe1bREIva5W3TbImsto+dxG4mBo=",
"lastModified": 1745900683,
"narHash": "sha256-ZGi2gjgPtmPmplCVz7dNufqkBr00g6EeAloX3GrFQls=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a1f79a1770d05af18111fbbe2a3ab2c42c0f6cd0",
"rev": "ffa0bb043c25cfc79ff3bc20ba2e44c3724499b1",
"type": "github"
},
"original": {

View file

@ -12,9 +12,9 @@ pub enum Color {
impl Display for Color {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Color::RGB24(r, g, b) => write!(f, "#{r:02X}{g:02X}{b:02X}FF"),
Color::RGBA32(r, g, b, a) => write!(f, "#{r:02X}{g:02X}{b:02X}{a:02X}"),
Color::W8(w) => write!(f, "#{w:02X}{w:02X}{w:02X}FF"),
Color::RGB24(r, g, b) => write!(f, "#{:02X}{:02X}{:02X}FF", r, g, b),
Color::RGBA32(r, g, b, a) => write!(f, "#{:02X}{:02X}{:02X}{:02X}", r, g, b, a),
Color::W8(w) => write!(f, "#{:02X}{:02X}{:02X}FF", w, w, w),
}
}
}

View file

@ -18,7 +18,7 @@ pub trait Grid<I, V> {
pub struct Flut<T> {
size_x: usize,
size_y: usize,
cells: SyncUnsafeCell<Box<[T]>>,
cells: SyncUnsafeCell<Vec<T>>,
last_hash: SyncUnsafeCell<u64>,
jpgbuf: RwLock<Vec<u8>>,
}
@ -32,7 +32,7 @@ impl<T: Clone> Flut<T> {
Flut {
size_x,
size_y,
cells: vec.into_boxed_slice().into(),
cells: vec.into(),
last_hash: 0.into(),
jpgbuf: RwLock::new(Vec::new()),
}
@ -60,19 +60,19 @@ impl<T> Flut<T> {
impl<T> Grid<Coordinate, T> for Flut<T> {
fn get(&self, x: Coordinate, y: Coordinate) -> Option<&T> {
self.index(x, y)
.map(|idx| unsafe { &(&(*self.cells.get()))[idx] })
.map(|idx| unsafe { &(*self.cells.get())[idx] })
}
fn set(&self, x: Coordinate, y: Coordinate, value: T) {
match self.index(x, y) {
None => (),
Some(idx) => unsafe { (&mut (*self.cells.get()))[idx] = value },
Some(idx) => unsafe { (*self.cells.get())[idx] = value },
}
}
fn get_unchecked(&self, x: Coordinate, y: Coordinate) -> &T {
let idx = y as usize * self.size_x + x as usize;
unsafe { &(&(*self.cells.get()))[idx] }
unsafe { &(*self.cells.get())[idx] }
}
}
@ -128,10 +128,7 @@ mod tests {
async fn test_grid_init_values() {
let grid = Flut::init(3, 3, 0);
assert_eq!(
grid.cells.into_inner(),
vec![0, 0, 0, 0, 0, 0, 0, 0, 0].into()
);
assert_eq!(grid.cells.into_inner(), vec![0, 0, 0, 0, 0, 0, 0, 0, 0]);
}
#[tokio::test]
@ -147,10 +144,7 @@ mod tests {
let grid = Flut::init(3, 3, 0);
grid.set(1, 1, 255);
grid.set(2, 1, 256);
assert_eq!(
grid.cells.into_inner(),
vec![0, 0, 0, 0, 255, 256, 0, 0, 0].into()
);
assert_eq!(grid.cells.into_inner(), vec![0, 0, 0, 0, 255, 256, 0, 0, 0]);
}
#[tokio::test]
@ -158,10 +152,7 @@ mod tests {
let grid = Flut::init(3, 3, 0);
grid.set(1, 1, 255);
grid.set(3, 1, 256);
assert_eq!(
grid.cells.into_inner(),
vec![0, 0, 0, 0, 255, 0, 0, 0, 0].into()
);
assert_eq!(grid.cells.into_inner(), vec![0, 0, 0, 0, 255, 0, 0, 0, 0]);
}
#[tokio::test]

View file

@ -113,12 +113,12 @@ To set a pixel using RGB, use ({SET_PX_RGB_BIN:02X}) (u8 canvas) (x as u16_le) (
match protocol {
crate::ProtocolStatus::Enabled(proto) => {
writer
.write_all(format!("Enabled: {proto}\n").as_bytes())
.write_all(format!("Enabled: {}\n", proto).as_bytes())
.await?;
}
crate::ProtocolStatus::Disabled(proto) => {
writer
.write_all(format!("Disabled: {proto}\n").as_bytes())
.write_all(format!("Disabled: {}\n", proto).as_bytes())
.await?;
}
}

View file

@ -153,12 +153,12 @@ impl<W: AsyncWriteExt + std::marker::Unpin> Responder<W> for TextParser {
match protocol {
crate::ProtocolStatus::Enabled(proto) => {
writer
.write_all(format!("Enabled: {proto}\n").as_bytes())
.write_all(format!("Enabled: {}\n", proto).as_bytes())
.await?;
}
crate::ProtocolStatus::Disabled(proto) => {
writer
.write_all(format!("Disabled: {proto}\n").as_bytes())
.write_all(format!("Disabled: {}\n", proto).as_bytes())
.await?;
}
}

View file

@ -89,7 +89,7 @@ fn make_image_stream(
fn make_stats() -> Message {
let pixels: u64 = COUNTER.load(std::sync::atomic::Ordering::Relaxed);
let clients: u64 = CLIENTS.load(std::sync::atomic::Ordering::Relaxed);
format!("{{\"c\":{clients}, \"p\":{pixels}}}").into()
format!("{{\"c\":{}, \"p\":{}}}", clients, pixels).into()
}
async fn stats_stream(ws: WebSocketUpgrade) -> Response {