🏡 index : ~doyle/bin.git

author Jordan Doyle <jordan@doyle.la> 2025-05-25 16:47:11.0 +08:00:00
committer Jordan Doyle <jordan@doyle.la> 2025-05-25 16:47:11.0 +08:00:00
commit
b82b03652b3568434912b589566a5a510a162062 [patch]
tree
a6b7dc227fd50d60f1c0dd8599e1c0726c3d8fb7
parent
29a4ad6b9f0cd555202c02b30e84d09e646c8af6
download
b82b03652b3568434912b589566a5a510a162062.tar.gz

Update MSRV



Diff

 Cargo.lock       |  3 +--
 Cargo.toml       |  1 -
 flake.lock       | 48 ++++++++++++++++++++++++++++++++++++++++--------
 flake.nix        |  7 +++++--
 src/errors.rs    |  1 +
 src/highlight.rs |  4 ++--
 src/io.rs        |  8 ++++----
 src/main.rs      |  4 ++--
 8 files changed, 49 insertions(+), 27 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 2fab9bf..2e59a23 100644
--- a/Cargo.lock
+++ a/Cargo.lock
@@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4

[[package]]
name = "actix"
@@ -489,7 +489,6 @@
 "htmlescape",
 "linked-hash-map",
 "log",
 "once_cell",
 "parking_lot",
 "pretty_env_logger",
 "rand 0.8.5",
diff --git a/Cargo.toml b/Cargo.toml
index b2e59bb..7889b7b 100644
--- a/Cargo.toml
+++ a/Cargo.toml
@@ -12,7 +12,6 @@
log = "0.4"
pretty_env_logger = "0.5"
linked-hash-map = "0.5"
once_cell = "1.19"
parking_lot = "0.12"
bytes = { version = "1.2", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] }
diff --git a/flake.lock b/flake.lock
index d2134be..da54921 100644
--- a/flake.lock
+++ a/flake.lock
@@ -5,11 +5,11 @@
        "nixpkgs": "nixpkgs"
      },

      "locked": {
        "lastModified": 1662220400,
        "narHash": "sha256-9o2OGQqu4xyLZP9K6kNe1pTHnyPz0Wr3raGYnr9AIgY=",
        "lastModified": 1745925850,
        "narHash": "sha256-cyAAMal0aPrlb1NgzMxZqeN1mAJ2pJseDhm2m6Um8T0=",
        "owner": "nix-community",
        "repo": "naersk",
        "rev": "6944160c19cb591eb85bbf9b2f2768a935623ed3",
        "rev": "38bc60bbc157ae266d4a0c96671c6c742ee17a5f",
        "type": "github"
      },

      "original": {
@@ -21,25 +21,27 @@
    },

    "nixpkgs": {
      "locked": {
        "lastModified": 1670118144,
        "narHash": "sha256-tdh9H4oomljZaKpCkZox8jmwt8p78oGLpK9cjFBy3Qk=",
        "lastModified": 1747958103,
        "narHash": "sha256-qmmFCrfBwSHoWw7cVK4Aj+fns+c54EBP8cGqp/yK410=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "95f1ec721652d91a2993311d6cf537d3724690be",
        "rev": "fe51d34885f7b5e3e7b59572796e1bcb427eccb1",
        "type": "github"
      },

      "original": {
        "id": "nixpkgs",
        "type": "indirect"
        "owner": "NixOS",
        "ref": "nixpkgs-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }

    },

    "nixpkgs_2": {
      "locked": {
        "lastModified": 1670118144,
        "narHash": "sha256-tdh9H4oomljZaKpCkZox8jmwt8p78oGLpK9cjFBy3Qk=",
        "lastModified": 1747958103,
        "narHash": "sha256-qmmFCrfBwSHoWw7cVK4Aj+fns+c54EBP8cGqp/yK410=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "95f1ec721652d91a2993311d6cf537d3724690be",
        "rev": "fe51d34885f7b5e3e7b59572796e1bcb427eccb1",
        "type": "github"
      },

      "original": {
@@ -54,15 +56,33 @@
        "naersk": "naersk",
        "nixpkgs": "nixpkgs_2",
        "utils": "utils"
      }

    },

    "systems": {
      "locked": {
        "lastModified": 1681028828,
        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
        "owner": "nix-systems",
        "repo": "default",
        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
        "type": "github"
      },

      "original": {
        "owner": "nix-systems",
        "repo": "default",
        "type": "github"
      }

    },

    "utils": {
      "inputs": {
        "systems": "systems"
      },

      "locked": {
        "lastModified": 1667395993,
        "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
        "lastModified": 1731533236,
        "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
        "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
        "type": "github"
      },

      "original": {
diff --git a/flake.nix b/flake.nix
index 1891f98..0bfc5a5 100644
--- a/flake.nix
+++ a/flake.nix
@@ -12,9 +12,12 @@
        naersk-lib = pkgs.callPackage naersk { };
      in
      {
        defaultPackage = naersk-lib.buildPackage ./.;
        defaultPackage = naersk-lib.buildPackage {
          src = ./.;
          nativeBuildInputs = with pkgs; [ zlib ];
        };
        devShell = with pkgs; mkShell {
          buildInputs = [ cargo rustc rustfmt pre-commit rustPackages.clippy ];
          buildInputs = [ cargo rustc rustfmt pre-commit rustPackages.clippy zlib pkg-config ];
          RUST_SRC_PATH = rustPlatform.rustLibSrc;
        };

diff --git a/src/errors.rs b/src/errors.rs
index 09c81e1..9892649 100644
--- a/src/errors.rs
+++ a/src/errors.rs
@@ -30,6 +30,7 @@
impl_response_error_for_http_resp!(NotFound, "../templates/404.html", StatusCode::NOT_FOUND);

#[derive(Debug)]
#[allow(dead_code)]
pub struct InternalServerError(pub Box<dyn std::error::Error>);

impl_response_error_for_http_resp!(
diff --git a/src/highlight.rs b/src/highlight.rs
index 53cd51e..5bf4dfe 100644
--- a/src/highlight.rs
+++ a/src/highlight.rs
@@ -1,5 +1,5 @@
use bat::assets::HighlightingAssets;
use once_cell::sync::Lazy;
use std::sync::LazyLock;
use syntect::{
    html::{ClassStyle, ClassedHTMLGenerator},
    parsing::SyntaxSet,
@@ -12,7 +12,7 @@
///

/// Returns `None` if the extension isn't supported.

pub fn highlight(content: &str, ext: &str) -> Option<String> {
    static SS: Lazy<SyntaxSet> = Lazy::new(SyntaxSet::load_defaults_newlines);
    static SS: LazyLock<SyntaxSet> = LazyLock::new(SyntaxSet::load_defaults_newlines);

    BAT_ASSETS
        .with(|f| {
diff --git a/src/io.rs b/src/io.rs
index 3719ebc..174c5d9 100644
--- a/src/io.rs
+++ a/src/io.rs
@@ -1,13 +1,13 @@
use actix_web::web::Bytes;
use linked_hash_map::LinkedHashMap;
use once_cell::sync::Lazy;
use parking_lot::RwLock;
use rand::{distributions::Alphanumeric, thread_rng, Rng};
use std::cell::RefCell;
use std::{cell::RefCell, sync::LazyLock};

pub type PasteStore = RwLock<LinkedHashMap<String, Bytes>>;

static BUFFER_SIZE: Lazy<usize> = Lazy::new(|| argh::from_env::<crate::BinArgs>().buffer_size);
static BUFFER_SIZE: LazyLock<usize> =
    LazyLock::new(|| argh::from_env::<crate::BinArgs>().buffer_size);

/// Ensures `ENTRIES` is less than the size of `BIN_BUFFER_SIZE`. If it isn't then

/// `ENTRIES.len() - BIN_BUFFER_SIZE` elements will be popped off the front of the map.

@@ -50,5 +50,5 @@
/// Returns `None` if the paste doesn't exist.

pub fn get_paste(entries: &PasteStore, id: &str) -> Option<Bytes> {
    // need to box the guard until owning_ref understands Pin is a stable address
    entries.read().get(id).map(Bytes::clone)
    entries.read().get(id).cloned()
}
diff --git a/src/main.rs b/src/main.rs
index ffa608f..45052b3 100644
--- a/src/main.rs
+++ a/src/main.rs
@@ -20,10 +20,10 @@
};
use askama::{Html as AskamaHtml, MarkupDisplay, Template};
use log::{error, info};
use once_cell::sync::Lazy;
use std::{
    borrow::Cow,
    net::{IpAddr, Ipv4Addr, SocketAddr},
    sync::LazyLock,
};
use syntect::html::{css_for_theme_with_class_style, ClassStyle};

@@ -168,7 +168,7 @@
}

async fn highlight_css() -> HttpResponse {
    static CSS: Lazy<Bytes> = Lazy::new(|| {
    static CSS: LazyLock<Bytes> = LazyLock::new(|| {
        highlight::BAT_ASSETS.with(|s| {
            Bytes::from(
                css_for_theme_with_class_style(s.get_theme("OneHalfDark"), ClassStyle::Spaced)