This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use anyhow::Context; | |
| use serde::Serialize; | |
| use std::hash::{Hash, Hasher}; | |
| use tokio::fs::File; | |
| use tokio::io::AsyncWriteExt; | |
| #[derive(Serialize)] | |
| struct LibReport { | |
| name: String, | |
| fingerprint: String, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// This macro takes a list of crate names and "touches" them | |
| /// by referencing their absolute path. If the crate is missing, | |
| /// the code will fail to compile. | |
| macro_rules! verify_libraries { | |
| ($($lib:ident),*) => { | |
| println!("--- Verifying Library Linkage ---"); | |
| $( | |
| // We use a statement that references the crate without side effects | |
| let _ = stringify!($lib); | |
| println!("✅ [{}] is linked and accessible.", stringify!($lib)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use anyhow::{anyhow, Result}; | |
| use serde::Deserialize; | |
| use async_trait::async_trait; // Using async-trait from your list | |
| #[derive(Debug, Deserialize, Clone)] | |
| struct SimpleIpResponse { | |
| ip: String, | |
| } | |
| // 1. Define a trait for the fetching logic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// Represents a point in 4D space | |
| #[derive(Debug, Clone, Copy)] | |
| struct Point4D { | |
| x: i32, | |
| y: i32, | |
| z: i32, | |
| w: i32, | |
| } | |
| impl Point4D { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// A collection of digital logic gate algorithms. | |
| struct LogicGates; | |
| impl LogicGates { | |
| /// NOT gate: The output is the opposite of the input. | |
| fn not(a: u8) -> u8 { | |
| match a { | |
| 0 => 1, | |
| _ => 0, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// A verbose example of Bitcoin's two variable integer types. | |
| fn main() { | |
| let value: u64 = 515; | |
| // 1. CompactSize (Little-Endian) - Used in P2P/Transactions | |
| let compact = encode_compact_size(value); | |
| println!("Value: {}", value); | |
| println!("CompactSize (LE-based) hex: {:02x?}", compact); | |
| // 2. VarInt (Base-128 Big-Endian) - Used in LevelDB/Disk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::collections::HashMap; | |
| /// Calculates Shannon Entropy for a slice of data. | |
| /// H = -sum(p(x) * log2(p(x))) | |
| fn calculate_entropy(data: &[&str]) -> f64 { | |
| let len = data.len() as f64; | |
| if len == 0.0 { | |
| return 0.0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use image::{ImageBuffer, Rgb}; | |
| use std::f64::consts::PI; | |
| fn main() { | |
| let grid_size = 11; | |
| let cell_size = 200; | |
| let padding = 20; | |
| let width = grid_size * cell_size; | |
| let height = grid_size * cell_size; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use approx::assert_relative_eq; | |
| fn gaussian_integral_approximation(start: f64, end: f64, steps: usize) -> f64 { | |
| let dx = (end - start) / steps as f64; | |
| let f = |x: f64| (-x.powi(2)).exp(); | |
| let mut sum = (f(start) + f(end)) * 0.5; | |
| for i in 1..steps { | |
| let x = start + (i as f64 * dx); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use async_trait::async_trait; | |
| use serde::{Deserialize, Serialize}; | |
| use thiserror::Error; | |
| use anyhow::{Context, Result}; | |
| use std::time::Duration; | |
| use tokio::task::JoinSet; | |
| use std::sync::Arc; | |
| // --- 1. Error Definitions --- |
NewerOlder