repo
stringlengths
6
65
file_url
stringlengths
81
311
file_path
stringlengths
6
227
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:31:58
2026-01-04 20:25:31
truncated
bool
2 classes
Charlie-XIAO/tauri-plugin-desktop-underlay
https://github.com/Charlie-XIAO/tauri-plugin-desktop-underlay/blob/d5200ed0a70ecec83dd707087bbbcda2c7abeef3/examples/desktop-clock/src-tauri/build.rs
examples/desktop-clock/src-tauri/build.rs
fn main() { tauri_build::build() }
rust
MIT
d5200ed0a70ecec83dd707087bbbcda2c7abeef3
2026-01-04T20:21:17.039147Z
false
Charlie-XIAO/tauri-plugin-desktop-underlay
https://github.com/Charlie-XIAO/tauri-plugin-desktop-underlay/blob/d5200ed0a70ecec83dd707087bbbcda2c7abeef3/examples/desktop-clock/src-tauri/src/main.rs
examples/desktop-clock/src-tauri/src/main.rs
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] use tauri::{generate_context, Builder, Manager}; use tauri_plugin_desktop_underlay::DesktopUnderlayExt; fn main() { Builder::default() .setup(|app| { let clock = app.get_webview_window("clock").unwrap(); clock.set_desktop_underlay(true)?; println!( "Desktop underlay enabled for clock window: {}", clock.is_desktop_underlay() ); clock.show()?; Ok(()) }) .plugin(tauri_plugin_process::init()) .plugin(tauri_plugin_desktop_underlay::init()) .run(generate_context!()) .expect("Error while initializing the application"); }
rust
MIT
d5200ed0a70ecec83dd707087bbbcda2c7abeef3
2026-01-04T20:21:17.039147Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/util.rs
src/util.rs
//! Utility functions and extension traits use crate::types::*; /// Extension trait for combined bit shift and mask pub trait ShiftMask: Sized { /// Output type of shift operation type MaskedOutput; /// Apply a right shift to a value, and return both the result and the /// bytes that were shifted out fn shift_mask(self, shift: u8) -> (Self, Self::MaskedOutput); } impl ShiftMask for u32 { type MaskedOutput = u32; fn shift_mask(self, shift: u8) -> (u32, u32) { let mask = (1 << shift) - 1; (self >> shift, self & mask) } } impl ShiftMask for i32 { type MaskedOutput = u32; #[inline] fn shift_mask(self, shift: u8) -> (i32, u32) { let mask = (1 << shift) - 1; (self >> shift, (self as u32) & mask) } } /// Combines a coordinate split into region, chunk and block number to /// a single linear coordinate #[inline] pub fn to_flat_coord<const AXIS: u8>( region: i8, chunk: ChunkCoord<AXIS>, block: BlockCoord<AXIS>, ) -> i32 { ((region as i32) << (BLOCK_BITS + CHUNK_BITS)) | ((chunk.0 as i32) << BLOCK_BITS) | (block.0 as i32) } /// Splits a flat (linear) coordinate into region, chunk and block numbers #[inline] pub fn from_flat_coord<const AXIS: u8>(coord: i32) -> (i8, ChunkCoord<AXIS>, BlockCoord<AXIS>) { let (region_chunk, block) = coord.shift_mask(BLOCK_BITS); let (region, chunk) = region_chunk.shift_mask(CHUNK_BITS); debug_assert!(i8::try_from(region).is_ok()); (region as i8, ChunkCoord::new(chunk), BlockCoord::new(block)) } /// Offsets a chunk and block coordinate pair by a number of blocks /// /// As the new coordinate may end up in a different region, a region offset /// is returned together with the new chunk and block coordinates. #[inline] pub fn coord_offset<const AXIS: u8>( chunk: ChunkCoord<AXIS>, block: BlockCoord<AXIS>, offset: i32, ) -> (i8, ChunkCoord<AXIS>, BlockCoord<AXIS>) { from_flat_coord(to_flat_coord(0, chunk, block) + offset) } #[cfg(test)] mod test { use super::*; #[test] fn test_coord_offset() { const CHUNKS: i32 = CHUNKS_PER_REGION as i32; const BLOCKS: i32 = BLOCKS_PER_CHUNK as i32; for chunk in ChunkX::iter() { for block in BlockX::iter() { assert_eq!(coord_offset(chunk, block, 0), (0, chunk, block)); assert_eq!( coord_offset(chunk, block, -(CHUNKS * BLOCKS)), (-1, chunk, block) ); assert_eq!( coord_offset(chunk, block, CHUNKS * BLOCKS), (1, chunk, block) ); for offset in -(CHUNKS * BLOCKS)..(CHUNKS * BLOCKS) { let (region2, chunk2, block2) = coord_offset(chunk, block, offset); assert!((-1..=1).contains(&region2)); let coord = chunk.0 as i32 * BLOCKS + block.0 as i32 + offset; let coord2 = ((region2 as i32 * CHUNKS) + chunk2.0 as i32) * BLOCKS + block2.0 as i32; assert_eq!(coord2, coord); } } } } }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/main.rs
src/main.rs
#![doc = env!("CARGO_PKG_DESCRIPTION")] #![warn(missing_docs)] #![warn(clippy::missing_docs_in_private_items)] #[cfg(feature = "jemalloc-auto")] extern crate minedmap_default_alloc; mod core; mod io; mod util; mod world; use minedmap_nbt as nbt; use minedmap_resource as resource; use minedmap_types as types; use anyhow::Result; fn main() -> Result<()> { core::cli() }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/world/sign.rs
src/world/sign.rs
//! Processing of sign text use std::fmt::Display; use bincode::{Decode, Encode}; use minedmap_resource::Color; use serde::Serialize; use super::{ de, text_value::{FormattedText, FormattedTextList, TextValue}, }; /// Version-independent reference to (front or back) sign text #[derive(Debug, Default)] pub struct RawSignText<'a> { /// Lines of sign text /// /// A regular sign always has 4 lines of text. The back of pre-1.20 /// signs is represented as a [SignText] without any `messages`. pub messages: Vec<&'a TextValue>, /// Sign color /// /// Defaults to "black". pub color: Option<&'a str>, } /// The color to use for signs without a color attribute ("black") const DEFAULT_COLOR: Color = Color([0, 0, 0]); /// Map of text colors associated with dyes (except for black) static DYE_COLORS: phf::Map<&'static str, Color> = phf::phf_map! { "white" => Color([255, 255, 255]), "orange" => Color([255, 104, 31]), "magenta" => Color([255, 0, 255]), "light_blue" => Color([154, 192, 205]), "yellow" => Color([255, 255, 0]), "lime" => Color([191, 255, 0]), "pink" => Color([255, 105, 180]), "gray" => Color([128, 128, 128]), "light_gray" => Color([211, 211, 211]), "cyan" => Color([0, 255, 255]), "purple" => Color([160, 32, 240]), "blue" => Color([0, 0, 255]), "brown" => Color([139, 69, 19]), "green" => Color([0, 255, 0]), "red" => Color([255, 0, 0]), }; impl RawSignText<'_> { /// Decodes the [RawSignText] into a [SignText] pub fn decode(&self, data_version: u32) -> SignText { let color = self .color .map(|c| DYE_COLORS.get(c).copied().unwrap_or(DEFAULT_COLOR)); let parent = FormattedText { color, ..Default::default() }; SignText( self.messages .iter() .map(|message| message.deserialize(data_version).linearize(&parent)) .collect(), ) } } impl<'a> From<&'a de::BlockEntitySignV1_20Text> for RawSignText<'a> { fn from(value: &'a de::BlockEntitySignV1_20Text) -> Self { RawSignText { messages: value.messages.iter().collect(), color: value.color.as_deref(), } } } /// Helper methods for [de::BlockEntitySign] pub trait BlockEntitySignExt { /// Returns the front and back text of a sign in a version-indepentent format fn text(&self) -> (RawSignText<'_>, RawSignText<'_>); } impl BlockEntitySignExt for de::BlockEntitySign { fn text(&self) -> (RawSignText<'_>, RawSignText<'_>) { match self { de::BlockEntitySign::V0 { text1, text2, text3, text4, color, } => ( RawSignText { messages: vec![text1, text2, text3, text4], color: color.as_deref(), }, Default::default(), ), de::BlockEntitySign::V1_20 { front_text, back_text, } => (front_text.into(), back_text.into()), } } } #[derive(Debug, Default, Serialize, PartialEq, Eq, PartialOrd, Ord, Encode, Decode)] /// Deserialized and linearized sign text pub struct SignText(pub Vec<FormattedTextList>); impl SignText { /// Checks if all lines of the sign text are empty pub fn is_empty(&self) -> bool { self.0.iter().all(|line| line.is_empty()) } } impl Display for SignText { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut iter = self.0.iter(); let Some(first) = iter.next() else { return Ok(()); }; first.fmt(f)?; for text in iter { f.write_str("\n")?; text.fmt(f)?; } Ok(()) } } #[cfg(test)] mod test { use super::*; fn formatted_text(text: &str) -> FormattedText { FormattedText { text: text.to_string(), ..Default::default() } } #[test] fn test_sign_text_display() { let sign_text = SignText(vec![ FormattedTextList(vec![formatted_text("a"), formatted_text("b")]), FormattedTextList(vec![formatted_text("c")]), FormattedTextList(vec![formatted_text("d")]), FormattedTextList(vec![formatted_text("e")]), ]); assert_eq!("ab\nc\nd\ne", sign_text.to_string()); } }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/world/text_value.rs
src/world/text_value.rs
//! Newtype and helper methods for handling Minecraft text values use std::{collections::VecDeque, fmt::Display}; use bincode::{Decode, Encode}; use minedmap_resource::Color; use serde::{Deserialize, Serialize}; /// A span of formatted text /// /// A [TextValue] consists of a tree of [FormattedText] nodes (canonically /// represented as a [FormattedTextTree], but other kinds are possible with /// is handled by [DeserializedText]. /// /// Formatting that is not set in a node is inherited from the parent. #[derive( Debug, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Encode, Decode, )] pub struct FormattedText { #[serde(default)] /// Text content pub text: String, /// Text color #[serde(skip_serializing_if = "Option::is_none", with = "text_color")] pub color: Option<Color>, /// Bold formatting #[serde(skip_serializing_if = "Option::is_none")] pub bold: Option<bool>, /// Italic formatting #[serde(skip_serializing_if = "Option::is_none")] pub italic: Option<bool>, /// Underlines formatting #[serde(skip_serializing_if = "Option::is_none")] pub underlined: Option<bool>, /// Strikethrough formatting #[serde(skip_serializing_if = "Option::is_none")] pub strikethrough: Option<bool>, /// Obfuscated formatting #[serde(skip_serializing_if = "Option::is_none")] pub obfuscated: Option<bool>, } impl FormattedText { /// Fills in unset formatting fields from a parent node pub fn inherit(self, parent: &Self) -> Self { FormattedText { text: self.text, color: self.color.or(parent.color), bold: self.bold.or(parent.bold), italic: self.italic.or(parent.italic), underlined: self.underlined.or(parent.underlined), strikethrough: self.strikethrough.or(parent.strikethrough), obfuscated: self.obfuscated.or(parent.obfuscated), } } } impl Display for FormattedText { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.text.fmt(f) } } /// A tree of [FormattedText] nodes /// /// Each node including the root has a `text` and a list of children (`extra`). #[derive(Debug, Deserialize, Default)] pub struct FormattedTextTree { /// Root node content #[serde(flatten)] text: FormattedText, /// List of child trees #[serde(default)] extra: VecDeque<DeserializedText>, } impl From<String> for FormattedTextTree { fn from(value: String) -> Self { FormattedTextTree { text: FormattedText { text: value, ..Default::default() }, extra: VecDeque::new(), } } } /// List of [FormattedText] #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Encode, Decode)] pub struct FormattedTextList(pub Vec<FormattedText>); impl FormattedTextList { /// Returns `true` when [FormattedTextList] does not contain any text pub fn is_empty(&self) -> bool { self.0.iter().all(|text| text.text.is_empty()) } } impl Display for FormattedTextList { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { for text in &self.0 { text.fmt(f)?; } Ok(()) } } /// Raw deserialized [TextValue] /// /// A [TextValue] can contain various different types serialized as JSON or NBT. #[derive(Debug, Deserialize)] #[serde(untagged)] pub enum DeserializedText { /// Unformatted string String(String), /// Unformatted number (will be converted to a string) Number(f32), /// Unformatted boolean (will be converted to a string) Boolean(bool), /// List of [DeserializedText] /// /// The tail elements are appended as children of the head element. List(VecDeque<DeserializedText>), /// The canonical [FormattedTextTree] structure Object(FormattedTextTree), } impl DeserializedText { /// Converts a [DeserializedText] into the regular [FormattedTextTree] format /// /// Most variants are simply converted to strings. A list is handled by /// appending all tail elements to the `extra` field of the head. pub fn canonicalize(self) -> FormattedTextTree { match self { DeserializedText::Object(obj) => obj, DeserializedText::String(s) => FormattedTextTree::from(s), DeserializedText::Number(n) => FormattedTextTree::from(n.to_string()), DeserializedText::Boolean(b) => FormattedTextTree::from(b.to_string()), DeserializedText::List(mut list) => { let mut obj = list .pop_front() .map(|t| t.canonicalize()) .unwrap_or_default(); obj.extra.append(&mut list); obj } } } /// Converts the tree of [FormattedText] nodes into a linear list by /// copying formatting flags into each node. pub fn linearize(self, parent: &FormattedText) -> FormattedTextList { let obj = self.canonicalize(); let mut ret = vec![obj.text.inherit(parent)]; for extra in obj.extra { ret.append(&mut extra.linearize(&ret[0]).0); } FormattedTextList(ret) } } impl Default for DeserializedText { fn default() -> Self { DeserializedText::Object(FormattedTextTree::from(String::new())) } } /// Minecraft raw text value #[derive(Debug, Deserialize)] pub struct TextValue(pub fastnbt::Value); impl TextValue { /// Deserializes a [TextValue] into a [DeserializedText] pub fn deserialize(&self, data_version: u32) -> DeserializedText { // TODO: Improve error handling // // Unfortunately, there are a number of weird ways an empty sign coould // be encoded (for example a compound with an "" key), so for now we // simply interpret undecodable data as empty. if data_version < 4290 { let fastnbt::Value::String(json) = &self.0 else { return DeserializedText::default(); }; serde_json::from_str(json).unwrap_or_default() } else { fastnbt::from_value(&self.0).unwrap_or_default() } } } mod text_color { //! Helpers for serializing and deserializing [FormattedText](super::FormattedText) colors use minedmap_resource::Color; use serde::{ Deserializer, Serializer, de::{self, Visitor}, ser::Error as _, }; /// Named text colors static COLORS: phf::Map<&'static str, Color> = phf::phf_map! { "black" => Color([0x00, 0x00, 0x00]), "dark_blue" => Color([0x00, 0x00, 0xAA]), "dark_green" => Color([0x00, 0xAA, 0x00]), "dark_aqua" => Color([0x00, 0xAA, 0xAA]), "dark_red" => Color([0xAA, 0x00, 0x00]), "dark_purple" => Color([0xAA, 0x00, 0xAA]), "gold" => Color([0xFF, 0xAA, 0x00]), "gray" => Color([0xAA, 0xAA, 0xAA]), "dark_gray" => Color([0x55, 0x55, 0x55]), "blue" => Color([0x55, 0x55, 0xFF]), "green" => Color([0x55, 0xFF, 0x55]), "aqua" => Color([0x55, 0xFF, 0xFF]), "red" => Color([0xFF, 0x55, 0x55]), "light_purple" => Color([0xFF, 0x55, 0xFF]), "yellow" => Color([0xFF, 0xFF, 0x55]), "white" => Color([0xFF, 0xFF, 0xFF]), }; /// serde serialize function for [FormattedText::color](super::FormattedText::color) pub fn serialize<S>(color: &Option<Color>, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { let &Some(color) = color else { return Err(S::Error::custom("serialize called for None sign color")); }; let text = format!("#{:02x}{:02x}{:02x}", color.0[0], color.0[1], color.0[2]); serializer.serialize_str(&text) } /// serde [Visitor] for use by [deserialize] struct ColorVisitor; impl Visitor<'_> for ColorVisitor { type Value = Option<Color>; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { formatter.write_str("a string representing a color") } fn visit_str<E>(self, color: &str) -> Result<Self::Value, E> where E: de::Error, { if let Some(hex) = color.strip_prefix("#") && let Ok(value) = u32::from_str_radix(hex, 16) { return Ok(Some(Color([ (value >> 16) as u8, (value >> 8) as u8, value as u8, ]))); } Ok(COLORS.get(color).copied()) } } /// serde deserialize function for [FormattedText::color](super::FormattedText::color) pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Color>, D::Error> where D: Deserializer<'de>, { deserializer.deserialize_str(ColorVisitor) } }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/world/layer.rs
src/world/layer.rs
//! Functions to search the "top" layer of a chunk use std::num::NonZeroU16; use anyhow::{Context, Result}; use bincode::{Decode, Encode}; use indexmap::IndexSet; use super::chunk::{Chunk, SectionIterItem}; use crate::{ resource::{Biome, BlockColor, BlockFlag}, types::*, }; /// Height (Y coordinate) of a block #[derive(Debug, Clone, Copy, PartialEq, Eq, Encode, Decode)] pub struct BlockHeight(pub i32); impl BlockHeight { /// Constructs a new [BlockHeight] from section and block Y indices /// /// Returns an error if the resulting coordindate does not fit into /// an [i32]. pub fn new(section: SectionY, block: BlockY) -> Result<Self> { let height = section .0 .checked_mul(BLOCKS_PER_CHUNK as i32) .and_then(|y| y.checked_add_unsigned(block.0.into())) .context("Block height out of bounds")?; Ok(BlockHeight(height)) } } /// Array optionally storing a [BlockColor] for each coordinate of a chunk pub type BlockArray = LayerBlockArray<Option<BlockColor>>; /// Array optionally storing a biome index for each coordinate of a chunk /// /// The entries refer to a biome list generated with the top layer data. /// Indices are stored incremented by 1 to allow using a [NonZeroU16]. pub type BiomeArray = LayerBlockArray<Option<NonZeroU16>>; /// Array storing a block light value for each coordinate for a chunk pub type BlockLightArray = LayerBlockArray<u8>; /// Array optionally storing a depth value for each coordinate for a chunk pub type DepthArray = LayerBlockArray<Option<BlockHeight>>; /// References to LayerData entries for a single coordinate pair struct LayerEntry<'a> { /// The block type of the referenced entry block: &'a mut Option<BlockColor>, /// The biome type of the referenced entry biome: &'a mut Option<NonZeroU16>, /// The block light of the referenced entry block_light: &'a mut u8, /// The depth value of the referenced entry depth: &'a mut Option<BlockHeight>, } impl LayerEntry<'_> { /// Returns true if the entry has not been filled yet (no opaque block has been encountered) /// /// The depth value is filled separately when a non-water block is encountered after the block type /// has already been filled. fn is_empty(&self) -> bool { self.block.is_none() } /// Returns true if the entry has been filled including its depth (an opaque non-water block has been /// encountered) fn done(&self) -> bool { self.depth.is_some() } /// Fills in the LayerEntry /// /// Checks whether the passed coordinates point at an opaque or non-water block and /// fills in the entry accordingly. Returns true when the block has been filled including its depth. fn fill( &mut self, biome_list: &mut IndexSet<Biome>, section: SectionIterItem, coords: SectionBlockCoords, ) -> Result<bool> { let Some(block_type) = section .section .block_at(coords)? .filter(|block_type| block_type.block_color.is(BlockFlag::Opaque)) else { if self.is_empty() { *self.block_light = section.block_light.block_light_at(coords); } return Ok(false); }; if self.is_empty() { *self.block = Some(block_type.block_color); let biome = section.biomes.biome_at(section.y, coords)?; let (biome_index, _) = biome_list.insert_full(*biome); *self.biome = NonZeroU16::new( (biome_index + 1) .try_into() .expect("biome index not in range"), ); } if block_type.block_color.is(BlockFlag::Water) { return Ok(false); } let height = BlockHeight::new(section.y, coords.y)?; *self.depth = Some(height); Ok(true) } } /// Top layer data /// /// A LayerData stores block type, biome, block light and depth data for /// each coordinate of a chunk. #[derive(Debug, Default)] pub struct LayerData { /// Block type data pub blocks: Box<BlockArray>, /// Biome data pub biomes: Box<BiomeArray>, /// Block light data pub block_light: Box<BlockLightArray>, /// Depth data pub depths: Box<DepthArray>, } impl LayerData { /// Builds a [LayerEntry] referencing the LayerData at a given coordinate pair fn entry(&mut self, coords: LayerBlockCoords) -> LayerEntry<'_> { LayerEntry { block: &mut self.blocks[coords], biome: &mut self.biomes[coords], block_light: &mut self.block_light[coords], depth: &mut self.depths[coords], } } } /// Fills in a [LayerData] with the information of the chunk's top /// block layer /// /// For each (X, Z) coordinate pair, the topmost opaque block is /// determined as the block that should be visible on the rendered /// map. For water blocks, the height of the first non-water block /// is additionally filled in as the water depth (the block height is /// used as depth otherwise). pub fn top_layer(biome_list: &mut IndexSet<Biome>, chunk: &Chunk) -> Result<Option<LayerData>> { use BLOCKS_PER_CHUNK as N; if chunk.is_empty() { return Ok(None); } let mut done = 0; let mut ret = LayerData::default(); for section in chunk.sections().rev() { for y in BlockY::iter().rev() { for z in BlockZ::iter() { for x in BlockX::iter() { let xz = LayerBlockCoords { x, z }; let mut entry = ret.entry(xz); if entry.done() { continue; } let coords = SectionBlockCoords { xz, y }; if !entry.fill(biome_list, section, coords)? { continue; } assert!(entry.done()); done += 1; if done == N * N { break; } } } } } Ok(Some(ret)) }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/world/block_entity.rs
src/world/block_entity.rs
//! Processing of block entity data use bincode::{Decode, Encode}; use minedmap_resource::{BlockFlag, BlockType}; use serde::Serialize; use super::{ de, sign::{BlockEntitySignExt, SignText}, }; /// Kind of sign block #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Encode, Decode, Serialize)] #[serde(rename_all = "snake_case")] pub enum SignKind { /// Standing sign Sign, /// Sign attached to wall WallSign, /// Hanging sign HangingSign, /// Hanging sign attached to wall HangingWallSign, } /// Processed sign data #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Encode, Decode, Serialize)] pub struct Sign { /// The kind of the sign pub kind: SignKind, /// The material of the sign #[serde(skip_serializing_if = "Option::is_none", default)] pub material: Option<String>, /// The sign's front text #[serde(skip_serializing_if = "SignText::is_empty", default)] pub front_text: SignText, /// The sign's back text #[serde(skip_serializing_if = "SignText::is_empty", default)] pub back_text: SignText, } impl Sign { /// Processes a [de::BlockEntitySign] into a [Sign] fn new( sign: &de::BlockEntitySign, kind: SignKind, material: Option<String>, data_version: u32, ) -> Sign { let (front_text, back_text) = sign.text(); let front_text = front_text.decode(data_version); let back_text = back_text.decode(data_version); Sign { kind, material, front_text, back_text, } } } /// Data for different kinds of [BlockEntity] #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Encode, Decode, Serialize)] #[serde(tag = "type", rename_all = "snake_case")] pub enum BlockEntityData { /// A sign block Sign(Sign), } /// A processed block entity #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Encode, Decode, Serialize)] pub struct BlockEntity { /// Global X coordinate pub x: i32, /// Global Y coordinate pub y: i32, /// Global Z coordinate pub z: i32, /// Entity data #[serde(flatten)] pub data: BlockEntityData, } impl BlockEntity { /// Processes a [de::BlockEntity] into a [BlockEntity] pub fn new( entity: &de::BlockEntity, block_type: Option<&BlockType>, data_version: u32, ) -> Option<Self> { let wall_sign = block_type .map(|block_type| block_type.block_color.is(BlockFlag::WallSign)) .unwrap_or_default(); let (kind, sign) = match (&entity.data, wall_sign) { (de::BlockEntityData::Sign(sign), false) => (SignKind::Sign, sign), (de::BlockEntityData::Sign(sign), true) => (SignKind::WallSign, sign), (de::BlockEntityData::HangingSign(sign), false) => (SignKind::HangingSign, sign), (de::BlockEntityData::HangingSign(sign), true) => (SignKind::HangingWallSign, sign), (de::BlockEntityData::Other, _) => return None, }; let material = block_type .as_ref() .and_then(|block_type| block_type.sign_material.as_ref()); let data = BlockEntityData::Sign(Sign::new(sign, kind, material.cloned(), data_version)); Some(BlockEntity { x: entity.x, y: entity.y, z: entity.z, data, }) } }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/world/mod.rs
src/world/mod.rs
//! Data structures describing Minecraft save data pub mod block_entity; pub mod chunk; pub mod de; pub mod layer; pub mod section; pub mod sign; pub mod text_value;
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/world/section.rs
src/world/section.rs
//! Higher-level interfaces to section data //! //! The data types in this module attempt to provide interfaces abstracting //! over different data versions as much as possible. use std::fmt::Debug; use anyhow::{Context, Result, bail}; use num_integer::div_rem; use tracing::debug; use super::de; use crate::{ resource::{Biome, BiomeTypes, BlockType, BlockTypes}, types::*, }; use BLOCKS_PER_CHUNK as N; /// Maximum height of pre-1.18 levels const HEIGHT: usize = 256; /// Number of biome entries per chunk in each direction const BN: usize = N >> 2; /// Pre-1.18 height of level measured in 4-block spans (resolution of 1.15+ biome data) const BHEIGHT: usize = HEIGHT >> 2; /// Determine the number of bits required for indexing into a palette of a given length /// /// This is basically a base-2 logarithm, with clamping to a minimum value and /// check against a maximum value. If the result would be greater than the passed /// `max` value, [None] is returned. fn palette_bits(len: usize, min: u8, max: u8) -> Option<u8> { let mut bits = min; while (1 << bits) < len { bits += 1; if bits > max { return None; } } Some(bits) } /// Trait for common functions of [SectionV1_13] and [SectionV0] pub trait Section: Debug { /// Returns the [BlockType] at a coordinate tuple inside the section fn block_at(&self, coords: SectionBlockCoords) -> Result<Option<&BlockType>>; } /// Minecraft v1.13+ section block data #[derive(Debug)] pub struct SectionV1_13<'a> { /// Packed block type data block_states: Option<&'a [i64]>, /// List of block types indexed by entries encoded in *block_states* palette: Vec<Option<&'a BlockType>>, /// Number of bits per block in *block_states* bits: u8, /// Set to true if packed block entries in *block_states* are aligned to i64 /// /// In older data formats, entries are unaligned and a single block can span /// two i64 entries. aligned_blocks: bool, } impl<'a> SectionV1_13<'a> { /// Constructs a new [SectionV1_13] from deserialized data structures /// /// The block IDs in the section's palette are resolved to their [BlockType]s /// to allow for faster lookup later. pub fn new( data_version: u32, block_states: Option<&'a [i64]>, palette: &'a [de::BlockStatePaletteEntry], block_types: &'a BlockTypes, ) -> Result<(Self, bool)> { let aligned_blocks = data_version >= 2529; let bits = palette_bits(palette.len(), 4, 12).context("Unsupported block palette size")?; if let Some(block_states) = block_states { let expected_length = if aligned_blocks { let blocks_per_word = 64 / bits as usize; 4096usize.div_ceil(blocks_per_word) } else { 64 * bits as usize }; if block_states.len() != expected_length { bail!("Invalid section block data"); } } let mut has_unknown = false; let palette_types = palette .iter() .map(|entry| { let block_type = block_types.get(&entry.name); if block_type.is_none() { debug!("Unknown block type: {}", entry.name); has_unknown = true; } block_type }) .collect(); Ok(( Self { block_states, palette: palette_types, bits, aligned_blocks, }, has_unknown, )) } /// Looks up the block type palette index at the given coordinates fn palette_index_at(&self, coords: SectionBlockCoords) -> usize { let Some(block_states) = self.block_states else { return 0; }; let bits = self.bits as usize; let mask = (1 << bits) - 1; let offset = coords.offset(); let shifted = if self.aligned_blocks { let blocks_per_word = 64 / bits; let (word, shift) = div_rem(offset, blocks_per_word); block_states[word] as u64 >> (shift * bits) } else { let bit_offset = offset * bits; let (word, bit_shift) = div_rem(bit_offset, 64); let mut tmp = (block_states[word] as u64) >> bit_shift; if bit_shift + bits > 64 { tmp |= (block_states[word + 1] as u64) << (64 - bit_shift); } tmp }; (shifted & mask) as usize } } impl Section for SectionV1_13<'_> { fn block_at(&self, coords: SectionBlockCoords) -> Result<Option<&BlockType>> { let index = self.palette_index_at(coords); Ok(*self .palette .get(index) .context("Palette index out of bounds")?) } } /// Pre-1.13 section block data #[derive(Debug)] pub struct SectionV0<'a> { /// Block type data /// /// Each i8 entry corresponds to a block in the 16x16x16 section blocks: &'a [i8], /// Block damage/subtype data /// /// Uses 4 bits for each block in the 16x16x16 section data: &'a [i8], /// Used to look up block type IDs block_types: &'a BlockTypes, } impl<'a> SectionV0<'a> { /// Constructs a new [SectionV0] from deserialized data structures pub fn new(blocks: &'a [i8], data: &'a [i8], block_types: &'a BlockTypes) -> Result<Self> { if blocks.len() != N * N * N { bail!("Invalid section block data"); } if data.len() != N * N * N / 2 { bail!("Invalid section extra data"); } Ok(SectionV0 { blocks, data, block_types, }) } } impl Section for SectionV0<'_> { fn block_at(&self, coords: SectionBlockCoords) -> Result<Option<&BlockType>> { let offset = coords.offset(); let block = self.blocks[offset] as u8; let (data_offset, data_nibble) = div_rem(offset, 2); let data_byte = self.data[data_offset] as u8; let data = if data_nibble == 1 { data_byte >> 4 } else { data_byte & 0xf }; Ok(self.block_types.get_legacy(block, data)) } } /// Trait for common functions of [BiomesV1_18] and [BiomesV0] pub trait Biomes: Debug { /// Returns the [Biome] at a coordinate tuple inside the chunk fn biome_at(&self, section: SectionY, coords: SectionBlockCoords) -> Result<&Biome>; } /// Minecraft v1.18+ section biome data /// /// The biome data is part of the section structure in Minecraft v1.18+, with /// the biomes laid out as an array of indices into a palette, similar to the /// v1.13+ block data. #[derive(Debug)] pub struct BiomesV1_18<'a> { /// Packed biome data /// /// Each entry specifies the biome of a 4x4x4 block area. /// /// Unlike block type data in [SectionV1_13], biome data is always aligned /// to whole i64 values. biomes: Option<&'a [i64]>, /// Biome palette indexed by entries encoded in *biomes* palette: Vec<&'a Biome>, /// Number of bits used for each entry in *biomes* bits: u8, } impl<'a> BiomesV1_18<'a> { /// Constructs a new [BiomesV1_18] from deserialized data structures pub fn new( biomes: Option<&'a [i64]>, palette: &'a [String], biome_types: &'a BiomeTypes, ) -> Result<(Self, bool)> { let bits = palette_bits(palette.len(), 1, 6).context("Unsupported block palette size")?; if let Some(biomes) = biomes { let biomes_per_word = 64 / bits as usize; let expected_length = 64usize.div_ceil(biomes_per_word); if biomes.len() != expected_length { bail!("Invalid section biome data"); } } let mut has_unknown = false; let palette_types = palette .iter() .map(|entry| { biome_types.get(entry).unwrap_or_else(|| { debug!("Unknown biome type: {}", entry); has_unknown = true; biome_types.get_fallback() }) }) .collect(); Ok(( BiomesV1_18 { biomes, palette: palette_types, bits, }, has_unknown, )) } /// Looks up the block type palette index at the given coordinates fn palette_index_at(&self, coords: SectionBlockCoords) -> usize { let Some(biomes) = self.biomes else { return 0; }; let bits = self.bits as usize; let mask = (1 << bits) - 1; let x = (coords.xz.x.0 >> 2) as usize; let y = (coords.y.0 >> 2) as usize; let z = (coords.xz.z.0 >> 2) as usize; let offset = BN * BN * y + BN * z + x; let blocks_per_word = 64 / bits; let (word, shift) = div_rem(offset, blocks_per_word); let shifted = biomes[word] as u64 >> (shift * bits); (shifted & mask) as usize } } impl Biomes for BiomesV1_18<'_> { fn biome_at(&self, _section: SectionY, coords: SectionBlockCoords) -> Result<&Biome> { let index = self.palette_index_at(coords); Ok(*self .palette .get(index) .context("Palette index out of bounds")?) } } /// Pre-v1.18 section biome data variants /// /// There are a 3 formats for biome data that were used in /// different pre-v1.18 Minecraft versions #[derive(Debug)] enum BiomesV0Data<'a> { /// Biome data stored as IntArray in 1.15+ format /// /// Minecraft 1.15 switched to 3-dimensional biome information, but reduced /// the resolution to only use one entry for every 4x4x4 block area. IntArrayV15(&'a fastnbt::IntArray), /// Biome data stored as IntArray in some pre-1.15 versions IntArrayV0(&'a fastnbt::IntArray), /// Biome data stored as ByteArray in some pre-1.15 versions ByteArray(&'a fastnbt::ByteArray), } /// Pre-v1.18 section biome data #[derive(Debug)] pub struct BiomesV0<'a> { /// Biome data from save data data: Option<BiomesV0Data<'a>>, /// Used to look up biome IDs biome_types: &'a BiomeTypes, } impl<'a> BiomesV0<'a> { /// Constructs a new [BiomesV0] from deserialized data structures pub fn new(biomes: Option<&'a de::BiomesV0>, biome_types: &'a BiomeTypes) -> Result<Self> { let data = biomes .map(|biomes| { Ok(match biomes { de::BiomesV0::IntArray(data) if data.len() == BN * BN * BHEIGHT => { BiomesV0Data::IntArrayV15(data) } de::BiomesV0::IntArray(data) if data.len() == N * N => { BiomesV0Data::IntArrayV0(data) } de::BiomesV0::ByteArray(data) if data.len() == N * N => { BiomesV0Data::ByteArray(data) } _ => bail!("Invalid biome data"), }) }) .transpose()?; Ok(BiomesV0 { data, biome_types }) } } impl Biomes for BiomesV0<'_> { fn biome_at(&self, section: SectionY, coords: SectionBlockCoords) -> Result<&Biome> { let id = self .data .as_ref() .map(|data| match data { BiomesV0Data::IntArrayV15(data) => { let LayerBlockCoords { x, z } = coords.xz; let y = section .0 .checked_mul(BLOCKS_PER_CHUNK as i32) .and_then(|y| y.checked_add_unsigned(coords.y.0.into())) .filter(|&height| height >= 0 && (height as usize) < HEIGHT) .context("Y coordinate out of range")? as usize; let offset = (y >> 2) * BN * BN + (z.0 >> 2) as usize * BN + (x.0 >> 2) as usize; let id = data[offset] as u32; let id = id.try_into().context("Biome index out of range")?; Ok::<_, anyhow::Error>(id) } BiomesV0Data::IntArrayV0(data) => { let id = data[coords.xz.offset()] as u32; let id = id.try_into().context("Biome index out of range")?; Ok(id) } BiomesV0Data::ByteArray(data) => Ok(data[coords.xz.offset()] as u8), }) .transpose()?; Ok(id .and_then(|id| self.biome_types.get_legacy(id)) .unwrap_or(self.biome_types.get_fallback())) } } /// Wrapper around chunk block light data array #[derive(Debug, Clone, Copy)] pub struct BlockLight<'a>(Option<&'a [i8]>); impl<'a> BlockLight<'a> { /// Creates a new [BlockLight], checking validity pub fn new(block_light: Option<&'a [i8]>) -> Result<Self> { if let Some(block_light) = block_light && block_light.len() != N * N * N / 2 { bail!("Invalid section block light data"); } Ok(BlockLight(block_light)) } /// Returns the block light value at the given coordinates pub fn block_light_at(&self, coords: SectionBlockCoords) -> u8 { let Some(block_light) = self.0 else { return 0; }; let (offset, nibble) = div_rem(coords.offset(), 2); let byte = block_light[offset] as u8; if nibble == 1 { byte >> 4 } else { byte & 0xf } } }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/world/chunk.rs
src/world/chunk.rs
//! Higher-level interfaces to chunk data //! //! The data types in this module attempt to provide interfaces abstracting //! over different data versions as much as possible. use std::{ collections::{BTreeMap, btree_map}, iter::{self, FusedIterator}, }; use anyhow::{Context, Result, bail}; use super::{block_entity::BlockEntity, de, section::*}; use crate::{ resource::{BiomeTypes, BlockType, BlockTypes}, types::*, util::{self, ShiftMask}, }; /// Version-specific part of [Chunk] #[derive(Debug)] pub enum ChunkInner<'a> { /// Minecraft v1.18+ chunk with biome data moved into sections V1_18 { /// Section data section_map: BTreeMap<SectionY, (SectionV1_13<'a>, BiomesV1_18<'a>, BlockLight<'a>)>, }, /// Minecraft v1.13+ chunk /// /// Block data is stored in an indexed format with variable bit width /// (depending on the total numer of distinct block types used in a /// section), and a palette mapping these indices to namespaced /// block IDs V1_13 { /// Section data section_map: BTreeMap<SectionY, (SectionV1_13<'a>, BlockLight<'a>)>, /// Biome data biomes: BiomesV0<'a>, }, /// Original pre-1.13 chunk /// /// The original chunk format with fixed 8-bit numeric block IDs V0 { /// Section data section_map: BTreeMap<SectionY, (SectionV0<'a>, BlockLight<'a>)>, /// Biome data biomes: BiomesV0<'a>, }, /// Unpopulated chunk without any block data Empty, } /// Chunk data structure wrapping a [de::Chunk] for convenient access to /// block and biome data #[derive(Debug)] pub struct Chunk<'a> { /// Version-specific data inner: ChunkInner<'a>, /// Unprocessed block entities block_entities: &'a Vec<de::BlockEntity>, /// Chunk data version data_version: u32, } impl<'a> Chunk<'a> { /// Creates a new [Chunk] from a deserialized [de::Chunk] pub fn new( data: &'a de::Chunk, block_types: &'a BlockTypes, biome_types: &'a BiomeTypes, ) -> Result<(Self, bool)> { let data_version = data.data_version.unwrap_or_default(); let ((inner, has_unknown), block_entities) = match &data.chunk { de::ChunkVariant::V1_18 { sections, block_entities, } => ( Self::new_v1_18(data_version, sections, block_types, biome_types)?, block_entities, ), de::ChunkVariant::V0 { level } => ( Self::new_v0(data_version, level, block_types, biome_types)?, &level.tile_entities, ), }; Ok(( Chunk { inner, block_entities, data_version, }, has_unknown, )) } /// [Chunk::new] implementation for Minecraft v1.18+ chunks fn new_v1_18( data_version: u32, sections: &'a Vec<de::SectionV1_18>, block_types: &'a BlockTypes, biome_types: &'a BiomeTypes, ) -> Result<(ChunkInner<'a>, bool)> { let mut section_map = BTreeMap::new(); let mut has_unknown = false; for section in sections { match &section.section { de::SectionV1_18Variant::V1_18 { block_states, biomes, block_light, } => { let (loaded_section, unknown_blocks) = SectionV1_13::new( data_version, block_states.data.as_deref(), &block_states.palette, block_types, ) .with_context(|| format!("Failed to load section at Y={}", section.y))?; has_unknown |= unknown_blocks; let (loaded_biomes, unknown_biomes) = BiomesV1_18::new(biomes.data.as_deref(), &biomes.palette, biome_types) .with_context(|| { format!("Failed to load section biomes at Y={}", section.y) })?; has_unknown |= unknown_biomes; section_map.insert( SectionY(section.y), ( loaded_section, loaded_biomes, BlockLight::new(block_light.as_deref()).with_context(|| { format!("Failed to load section block light at Y={}", section.y) })?, ), ); } de::SectionV1_18Variant::Empty {} => {} }; } let chunk = ChunkInner::V1_18 { section_map }; Ok((chunk, has_unknown)) } /// [Chunk::new] implementation for all pre-1.18 chunk variants fn new_v0( data_version: u32, level: &'a de::LevelV0, block_types: &'a BlockTypes, biome_types: &'a BiomeTypes, ) -> Result<(ChunkInner<'a>, bool)> { let mut section_map_v1_13 = BTreeMap::new(); let mut section_map_v0 = BTreeMap::new(); let mut has_unknown = false; for section in &level.sections { let block_light = BlockLight::new(section.block_light.as_deref()).with_context(|| { format!("Failed to load section block light at Y={}", section.y) })?; match &section.section { de::SectionV0Variant::V1_13 { block_states, palette, } => { let (loaded_section, unknown_blocks) = SectionV1_13::new(data_version, Some(block_states), palette, block_types) .with_context(|| format!("Failed to load section at Y={}", section.y))?; has_unknown |= unknown_blocks; section_map_v1_13 .insert(SectionY(section.y.into()), (loaded_section, block_light)); } de::SectionV0Variant::V0 { blocks, data } => { section_map_v0.insert( SectionY(section.y.into()), ( SectionV0::new(blocks, data, block_types).with_context(|| { format!("Failed to load section at Y={}", section.y) })?, block_light, ), ); } de::SectionV0Variant::Empty {} => {} } } let biomes = BiomesV0::new(level.biomes.as_ref(), biome_types); let chunk = match (section_map_v1_13.is_empty(), section_map_v0.is_empty()) { (true, true) => ChunkInner::Empty, (false, true) => ChunkInner::V1_13 { section_map: section_map_v1_13, biomes: biomes?, }, (true, false) => ChunkInner::V0 { section_map: section_map_v0, biomes: biomes?, }, (false, false) => { bail!("Mixed section versions"); } }; Ok((chunk, has_unknown)) } /// Returns true if the chunk does not contain any sections pub fn is_empty(&self) -> bool { match &self.inner { ChunkInner::V1_18 { section_map } => section_map.is_empty(), ChunkInner::V1_13 { section_map, .. } => section_map.is_empty(), ChunkInner::V0 { section_map, .. } => section_map.is_empty(), ChunkInner::Empty => true, } } /// Returns an interator over the chunk's sections and their Y coordinates pub fn sections(&self) -> SectionIter<'_> { use SectionIterInner::*; SectionIter { inner: match &self.inner { ChunkInner::V1_18 { section_map } => V1_18 { iter: section_map.iter(), }, ChunkInner::V1_13 { section_map, biomes, } => V1_13 { iter: section_map.iter(), biomes, }, ChunkInner::V0 { section_map, biomes, } => V0 { iter: section_map.iter(), biomes, }, ChunkInner::Empty => Empty, }, } } /// Returns the section at a [SectionY] coordinate fn section_at(&self, y: SectionY) -> Option<&dyn Section> { match &self.inner { ChunkInner::V1_18 { section_map } => section_map .get(&y) .map(|(section, _, _)| -> &dyn Section { section }), ChunkInner::V1_13 { section_map, .. } => section_map .get(&y) .map(|(section, _)| -> &dyn Section { section }), ChunkInner::V0 { section_map, .. } => section_map .get(&y) .map(|(section, _)| -> &dyn Section { section }), ChunkInner::Empty => None, } } /// Returns the [BlockType] at a given coordinate fn block_type_at(&self, y: SectionY, coords: SectionBlockCoords) -> Result<Option<&BlockType>> { let Some(section) = self.section_at(y) else { return Ok(None); }; section.block_at(coords) } /// Returns the [BlockType] at the coordinates of a [de::BlockEntity] fn block_type_at_block_entity( &self, block_entity: &de::BlockEntity, ) -> Result<Option<&BlockType>> { let x: BlockX = util::from_flat_coord(block_entity.x).2; let z: BlockZ = util::from_flat_coord(block_entity.z).2; let (section_y, block_y) = block_entity.y.shift_mask(BLOCK_BITS); let coords = SectionBlockCoords { xz: LayerBlockCoords { x, z }, y: BlockY::new(block_y), }; self.block_type_at(SectionY(section_y), coords) } /// Processes all of the chunk's block entities pub fn block_entities(&self) -> Result<Vec<BlockEntity>> { let entities: Vec<Option<BlockEntity>> = self .block_entities .iter() .map(|block_entity| { let block_type = self.block_type_at_block_entity(block_entity)?; Ok(BlockEntity::new( block_entity, block_type, self.data_version, )) }) .collect::<Result<_>>()?; Ok(entities.into_iter().flatten().collect()) } } /// Reference to block, biome and block light data of a section #[derive(Debug, Clone, Copy)] pub struct SectionIterItem<'a> { /// The Y coordinate of the section pub y: SectionY, /// Section block data pub section: &'a dyn Section, /// Section biome data pub biomes: &'a dyn Biomes, /// Section block light data pub block_light: BlockLight<'a>, } /// Helper trait to specify section iterator trait bounds trait SectionIterTrait<'a>: Iterator<Item = SectionIterItem<'a>> + DoubleEndedIterator + ExactSizeIterator + FusedIterator { } impl<'a, T> SectionIterTrait<'a> for T where T: Iterator<Item = SectionIterItem<'a>> + DoubleEndedIterator + ExactSizeIterator + FusedIterator { } /// Inner data structure of [SectionIter] #[derive(Debug, Clone)] enum SectionIterInner<'a> { /// Iterator over sections of [ChunkInner::V1_18] V1_18 { /// Inner iterator into section map iter: btree_map::Iter<'a, SectionY, (SectionV1_13<'a>, BiomesV1_18<'a>, BlockLight<'a>)>, }, /// Iterator over sections of [ChunkInner::V1_13] V1_13 { /// Inner iterator into section map iter: btree_map::Iter<'a, SectionY, (SectionV1_13<'a>, BlockLight<'a>)>, /// Chunk biome data biomes: &'a BiomesV0<'a>, }, /// Iterator over sections of [ChunkInner::V0] V0 { /// Inner iterator into section map iter: btree_map::Iter<'a, SectionY, (SectionV0<'a>, BlockLight<'a>)>, /// Chunk biome data biomes: &'a BiomesV0<'a>, }, /// Empty iterator over an unpopulated chunk ([ChunkInner::Empty]) Empty, } /// Iterator over the sections of a [Chunk] #[derive(Debug, Clone)] pub struct SectionIter<'a> { /// Inner iterator enum inner: SectionIterInner<'a>, } impl<'a> SectionIter<'a> { /// Helper to run a closure on the inner section iterator fn with_iter<F, T>(&mut self, f: F) -> T where F: FnOnce(&mut dyn SectionIterTrait<'a>) -> T, { match &mut self.inner { SectionIterInner::V1_18 { iter } => f(&mut iter.map( |(&y, (section, biomes, block_light))| SectionIterItem { y, section, biomes, block_light: *block_light, }, )), SectionIterInner::V1_13 { iter, biomes } => f(&mut iter.map( |(&y, (section, block_light))| SectionIterItem { y, section, biomes: *biomes, block_light: *block_light, }, )), SectionIterInner::V0 { iter, biomes } => f(&mut iter.map( |(&y, (section, block_light))| SectionIterItem { y, section, biomes: *biomes, block_light: *block_light, }, )), SectionIterInner::Empty => f(&mut iter::empty()), } } } impl<'a> Iterator for SectionIter<'a> { type Item = SectionIterItem<'a>; fn next(&mut self) -> Option<Self::Item> { self.with_iter(|iter| iter.next()) } fn size_hint(&self) -> (usize, Option<usize>) { match &self.inner { SectionIterInner::V1_18 { iter } => iter.size_hint(), SectionIterInner::V1_13 { iter, .. } => iter.size_hint(), SectionIterInner::V0 { iter, .. } => iter.size_hint(), SectionIterInner::Empty => (0, Some(0)), } } fn last(mut self) -> Option<Self::Item> { self.next_back() } } impl DoubleEndedIterator for SectionIter<'_> { fn next_back(&mut self) -> Option<Self::Item> { self.with_iter(|iter| iter.next_back()) } } impl ExactSizeIterator for SectionIter<'_> { fn len(&self) -> usize { match &self.inner { SectionIterInner::V1_18 { iter } => iter.len(), SectionIterInner::V1_13 { iter, .. } => iter.len(), SectionIterInner::V0 { iter, .. } => iter.len(), SectionIterInner::Empty => 0, } } } impl FusedIterator for SectionIter<'_> {}
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/world/de.rs
src/world/de.rs
//! Data structures used to deserialize Minecraft save data use serde::Deserialize; use super::text_value::TextValue; /// Element of the `palette` list of 1.18+ [block states](BlockStatesV1_18) #[derive(Debug, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct BlockStatePaletteEntry { /// Block type ID pub name: String, } /// 1.18+ `block_states` element found in a [section](SectionV1_18) #[derive(Debug, Deserialize)] pub struct BlockStatesV1_18 { /// Palette of block types, indexed by block data pub palette: Vec<BlockStatePaletteEntry>, /// Block data pub data: Option<fastnbt::LongArray>, } /// 1.18+ `biomes` element found in a [section](SectionV1_18) #[derive(Debug, Deserialize)] pub struct BiomesV1_18 { /// Palette of biome types, indexed by biome data pub palette: Vec<String>, /// Biome data #[serde(default)] pub data: Option<fastnbt::LongArray>, } /// Variable part of a [SectionV1_18] #[derive(Debug, Deserialize)] #[serde(untagged)] pub enum SectionV1_18Variant { /// Populated 1.18+ section V1_18 { /// Block type data block_states: BlockStatesV1_18, /// Biome data biomes: BiomesV1_18, /// Block light data #[serde(rename = "BlockLight")] block_light: Option<fastnbt::ByteArray>, }, /// Empty section Empty {}, } /// Element of the 1.18+ `sections` list found in a [Chunk] #[derive(Debug, Deserialize)] pub struct SectionV1_18 { /// Y coordinate #[serde(rename = "Y")] pub y: i32, /// Variable part of section #[serde(flatten)] pub section: SectionV1_18Variant, } /// Version-specific part of a pre-1.18 [Section](SectionV0) #[derive(Debug, Deserialize)] #[serde(untagged)] pub enum SectionV0Variant { /// v1.13+ data #[serde(rename_all = "PascalCase")] V1_13 { /// Block data block_states: fastnbt::LongArray, /// Block type palette, indexed by block data palette: Vec<BlockStatePaletteEntry>, }, /// Pre-1.13 data #[serde(rename_all = "PascalCase")] V0 { /// Block type data blocks: fastnbt::ByteArray, /// Block damage / subtype data data: fastnbt::ByteArray, }, /// Empty section Empty {}, } /// Pre-1.18 section element found in the [Level](LevelV0) compound #[derive(Debug, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct SectionV0 { /// Y coordinate pub y: i8, /// Block light data pub block_light: Option<fastnbt::ByteArray>, /// Version-specific data #[serde(flatten)] pub section: SectionV0Variant, } /// Pre-1.18 biome fields found in the [Level](LevelV0) compound #[derive(Debug, Deserialize)] #[serde(untagged)] pub enum BiomesV0 { /// Data for Minecraft versions storing biome data as an IntArray IntArray(fastnbt::IntArray), /// Data for Minecraft versions storing biome data as an ByteArray ByteArray(fastnbt::ByteArray), } /// Front/back text of a Minecraft 1.20+ sign block entry #[derive(Debug, Deserialize)] pub struct BlockEntitySignV1_20Text { /// Lines of sign text pub messages: Vec<TextValue>, /// Default text color pub color: Option<String>, } /// A sign (standing or hanging) block entity #[derive(Debug, Deserialize)] #[serde(untagged)] pub enum BlockEntitySign { /// Pre-1.20 sign block entity /// /// Pre-1.20 signs only have front text. #[serde(rename_all = "PascalCase")] V0 { /// Line 1 of the sign text text1: TextValue, /// Line 2 of the sign text text2: TextValue, /// Line 3 of the sign text text3: TextValue, /// Line 4 of the sign text text4: TextValue, /// Default text color color: Option<String>, }, /// 1.20+ sign block entity V1_20 { /// The sign's front text front_text: BlockEntitySignV1_20Text, /// The sign's back text back_text: BlockEntitySignV1_20Text, }, } /// Data for different kinds of block entities #[derive(Debug, Deserialize)] #[serde(tag = "id")] pub enum BlockEntityData { /// Regular sign /// /// This includes standing signs and signs attached to the side of blocks #[serde(rename = "minecraft:sign", alias = "minecraft:standing_sign")] Sign(BlockEntitySign), /// Hanging sign #[serde(rename = "minecraft:hanging_sign")] HangingSign(BlockEntitySign), /// Other block entity types not handled by MinedMap #[serde(other)] Other, } /// A block entity /// /// Block entities were called tile entities pre-1.18 #[derive(Debug, Deserialize)] pub struct BlockEntity { /// Entity global X coordinate pub x: i32, /// Entity global Y coordinate pub y: i32, /// Entity global Z coordinate pub z: i32, /// Kind-specific entity data #[serde(flatten)] pub data: BlockEntityData, } /// `Level` compound element found in pre-1.18 [chunks](Chunk) #[derive(Debug, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct LevelV0 { /// Section data #[serde(default)] pub sections: Vec<SectionV0>, /// Biome data #[serde(default)] pub biomes: Option<BiomesV0>, /// List of block entities #[serde(default)] pub tile_entities: Vec<BlockEntity>, } /// Version-specific part of a [Chunk] compound #[derive(Debug, Deserialize)] #[serde(untagged)] pub enum ChunkVariant { /// 1.18+ chunk data V1_18 { /// List of chunk sections sections: Vec<SectionV1_18>, /// List of block entities #[serde(default)] block_entities: Vec<BlockEntity>, }, /// Pre-1.18 chunk data #[serde(rename_all = "PascalCase")] V0 { /// `Level` field of the chunk level: LevelV0, }, } /// Toplevel compound element of a Minecraft chunk #[derive(Debug, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct Chunk { /// The data version of the chunk pub data_version: Option<u32>, /// Version-specific chunk data #[serde(flatten)] pub chunk: ChunkVariant, } /// 1.21.9+ `spawn` compound element of level.dat #[derive(Debug, Deserialize)] pub struct LevelDatSpawnV1_21_9 { /// X/Y/Z coordinate of spawn point for new players pub pos: fastnbt::IntArray, /// Dimension of the spawn point for new players (for example "minecraft:overworld") pub dimension: String, } /// `Data` compound element of level.dat #[derive(Debug, Deserialize)] #[serde(untagged)] pub enum LevelDatData { /// 1.21.9+ `Data` element V1_21_9 { /// Spawn point for new players spawn: LevelDatSpawnV1_21_9, }, /// Pre-1.21.9 `Data` element #[serde(rename_all = "PascalCase")] V0 { /// X coordinate of spawn point for new players spawn_x: i32, /// Z coordinate of spawn point for new players spawn_z: i32, }, } /// Toplevel compound element of level.dat #[derive(Debug, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct LevelDat { /// The `Data` field pub data: LevelDatData, }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/core/region_group.rs
src/core/region_group.rs
//! The generic [RegionGroup] data structure use std::{future::Future, iter}; use anyhow::Result; use futures_util::future::OptionFuture; /// A generic array of 3x3 elements /// /// A RegionGroup is used to store information about a 3x3 neighborhood of /// regions. /// /// The center element is always populated, while the 8 adjacent elements may be None. #[derive(Debug, Clone, Copy)] pub struct RegionGroup<T> { /// The element corresponding to the center of the 9x9 neighborhood center: T, /// The remaining elements, stored in row-first order /// /// The center element is always None. neighs: [Option<T>; 9], } impl<T> RegionGroup<T> { /// Constructs a new RegionGroup from a closure called for each element /// /// The X and Z coordinates relative to the center (in the range -1..1) /// are passed to the closure. /// /// Panics of the closure returns None for the center element. pub fn new<F>(f: F) -> Self where F: Fn(i8, i8) -> Option<T>, { RegionGroup { center: f(0, 0).expect("Center element of RegionGroup must not be None"), neighs: [ f(-1, -1), f(-1, 0), f(-1, 1), f(0, -1), None, f(0, 1), f(1, -1), f(1, 0), f(1, 1), ], } } /// Returns a reference to the center element pub fn center(&self) -> &T { &self.center } /// Returns a reference to an element of the RegionGroup, if populated /// /// Always returns None for X and Z coordinates outside of the -1..1 range. pub fn get(&self, x: i8, z: i8) -> Option<&T> { if (x, z) == (0, 0) { return Some(&self.center); } if !(-1..=1).contains(&x) || !(-1..=1).contains(&z) { return None; } self.neighs.get((3 * x + z + 4) as usize)?.as_ref() } /// Runs a closure on each element to construct a new RegionGroup pub fn map<U, F>(self, mut f: F) -> RegionGroup<U> where F: FnMut(T) -> U, { RegionGroup { center: f(self.center), neighs: self.neighs.map(|entry| entry.map(&mut f)), } } /// Runs a fallible closure on each element to construct a new RegionGroup /// /// [Err] return values for the center element are passed up. Outer elements /// become unpopulated when the closure fails. pub fn try_map<U, F>(self, mut f: F) -> Result<RegionGroup<U>> where F: FnMut(T) -> Result<U>, { let RegionGroup { center, neighs } = self; let center = f(center)?; let neighs = neighs.map(|entry| entry.and_then(|value| f(value).ok())); Ok(RegionGroup { center, neighs }) } /// Runs an asynchronous closure on each element to construct a new RegionGroup #[allow(dead_code)] pub async fn async_map<U, F, Fut>(self, mut f: F) -> RegionGroup<U> where Fut: Future<Output = U>, F: FnMut(T) -> Fut, { let center = f(self.center); let neighs = futures_util::future::join_all( self.neighs .map(|entry| OptionFuture::from(entry.map(&mut f))), ); let (center, neighs) = futures_util::join!(center, neighs); RegionGroup { center, neighs: <[Option<_>; 9]>::try_from(neighs).ok().unwrap(), } } /// Runs a fallible asynchronous closure on each element to construct a new RegionGroup /// /// [Err] return values for the center element are passed up. Outer elements /// become unpopulated when the closure fails. pub async fn async_try_map<U, F, Fut>(self, mut f: F) -> Result<RegionGroup<U>> where Fut: Future<Output = Result<U>>, F: FnMut(T) -> Fut, { let center = f(self.center); let neighs = futures_util::future::join_all( self.neighs .map(|entry| OptionFuture::from(entry.map(&mut f))), ); let (center, neighs) = futures_util::join!(center, neighs); let center = center?; let neighs: Vec<_> = neighs .into_iter() .map(|entry| entry.and_then(Result::ok)) .collect(); let neighs = <[Option<_>; 9]>::try_from(neighs).ok().unwrap(); Ok(RegionGroup { center, neighs }) } /// Returns an [Iterator] over all populated elements pub fn iter(&self) -> impl Iterator<Item = &T> { iter::once(&self.center).chain(self.neighs.iter().filter_map(Option::as_ref)) } }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/core/entity_collector.rs
src/core/entity_collector.rs
//! The [EntityCollector] use std::path::Path; use anyhow::{Context, Result}; use tracing::{info, warn}; use super::{common::*, tile_collector::TileCollector, tile_merger::TileMerger}; use crate::io::{fs, storage}; /// Generates mipmap tiles from full-resolution tile images pub struct EntityCollector<'a> { /// Common MinedMap configuration from command line config: &'a Config, /// List of populated tiles for base mipmap level (level 0) regions: &'a [TileCoords], } impl TileMerger for EntityCollector<'_> { fn file_meta_version(&self) -> fs::FileMetaVersion { ENTITIES_FILE_META_VERSION } fn tile_path(&self, level: usize, coords: TileCoords) -> std::path::PathBuf { self.config.entities_path(level, coords) } fn write_tile( &self, file: &mut std::io::BufWriter<std::fs::File>, sources: &[super::tile_merger::Source], ) -> Result<()> { Self::merge_entity_lists(file, sources.iter().map(|source| &source.1)) } } impl TileCollector for EntityCollector<'_> { type CollectOutput = (); fn tiles(&self) -> &[TileCoords] { self.regions } fn prepare(&self, level: usize) -> Result<()> { fs::create_dir_all(&self.config.entities_dir(level)) } fn finish( &self, _level: usize, _outputs: impl Iterator<Item = Self::CollectOutput>, ) -> Result<()> { Ok(()) } fn collect_one( &self, level: usize, coords: TileCoords, prev: &TileCoordMap, ) -> Result<Self::CollectOutput> { self.merge_tiles(level, coords, prev)?; Ok(()) } } impl<'a> EntityCollector<'a> { /// Constructs a new EntityCollector pub fn new(config: &'a Config, regions: &'a [TileCoords]) -> Self { EntityCollector { config, regions } } /// Merges multiple entity lists into one fn merge_entity_lists<P: AsRef<Path>>( file: &mut std::io::BufWriter<std::fs::File>, sources: impl Iterator<Item = P>, ) -> Result<()> { let mut output = ProcessedEntities::default(); for source_path in sources { let mut source: ProcessedEntities = match storage::read_file(source_path.as_ref()) { Ok(source) => source, Err(err) => { warn!( "Failed to read entity data file {}: {:?}", source_path.as_ref().display(), err, ); continue; } }; output.block_entities.append(&mut source.block_entities); } storage::write(file, &output).context("Failed to write entity data") } /// Runs the mipmap generation pub fn run(self) -> Result<()> { info!("Collecting entity data..."); let tile_stack = self.collect_tiles()?; // Final merge let level = tile_stack.len() - 1; let tile_map = &tile_stack[level]; let sources: Vec<_> = [(-1, -1), (-1, 0), (0, -1), (0, 0)] .into_iter() .map(|(x, z)| TileCoords { x, z }) .filter(|&coords| tile_map.contains(coords)) .map(|coords| self.tile_path(level, coords)) .collect(); fs::create_with_tmpfile(&self.config.entities_path_final, |file| { Self::merge_entity_lists(file, sources.iter()) })?; info!("Collected entity data."); Ok(()) } }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/core/metadata_writer.rs
src/core/metadata_writer.rs
//! The [MetadataWriter] and related types use anyhow::{Context, Result}; use regex::Regex; use serde::Serialize; use crate::{ core::common::*, io::{fs, storage}, world::{ block_entity::{self, BlockEntity, BlockEntityData}, de, sign, }, }; /// Minimum and maximum X and Z tile coordinates for a mipmap level #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] struct Bounds { /// Minimum X coordinate min_x: i32, /// Maximum X coordinate max_x: i32, /// Minimum Z coordinate min_z: i32, /// Maximum Z coordinate max_z: i32, } /// Mipmap level information in viewer metadata file #[derive(Debug, Serialize)] struct Mipmap<'t> { /// Minimum and maximum tile coordinates of the mipmap level bounds: Bounds, /// Map of populated tiles for the mipmap level regions: &'t TileCoordMap, } /// Initial spawn point for new players #[derive(Debug, Serialize)] struct Spawn { /// Spawn X coordinate x: i32, /// Spawn Z coordinate z: i32, } /// Keeps track of enabled MinedMap features #[derive(Debug, Serialize)] struct Features { /// Sign layer signs: bool, } /// Viewer metadata JSON data structure #[derive(Debug, Serialize)] struct Metadata<'t> { /// Tile information for each mipmap level mipmaps: Vec<Mipmap<'t>>, /// Initial spawn point for new players spawn: Spawn, /// Enabled MinedMap features features: Features, /// Format of generated map tiles tile_extension: &'static str, } /// Viewer entity JSON data structure #[derive(Debug, Serialize, Default)] struct Entities { /// List of signs signs: Vec<BlockEntity>, } /// The MetadataWriter is used to generate the viewer metadata file pub struct MetadataWriter<'a> { /// Common MinedMap configuration from command line config: &'a Config, /// Map of generated tiles for each mipmap level tiles: &'a [TileCoordMap], } impl<'a> MetadataWriter<'a> { /// Creates a new MetadataWriter pub fn new(config: &'a Config, tiles: &'a [TileCoordMap]) -> Self { MetadataWriter { config, tiles } } /// Helper to construct a [Mipmap] data structure from a [TileCoordMap] fn mipmap_entry(regions: &TileCoordMap) -> Mipmap<'_> { let mut min_x = i32::MAX; let mut max_x = i32::MIN; let mut min_z = i32::MAX; let mut max_z = i32::MIN; for (&z, xs) in &regions.0 { if z < min_z { min_z = z; } if z > max_z { max_z = z; } for &x in xs { if x < min_x { min_x = x; } if x > max_x { max_x = x; } } } Mipmap { bounds: Bounds { min_x, max_x, min_z, max_z, }, regions, } } /// Reads and deserializes the `level.dat` of the Minecraft save data fn read_level_dat(&self) -> Result<de::LevelDat> { let res = crate::nbt::data::from_file(&self.config.level_dat_path); if res.is_err() && let Ok(level_dat_old) = crate::nbt::data::from_file(&self.config.level_dat_old_path) { return Ok(level_dat_old); } res.context("Failed to read level.dat") } /// Generates [Spawn] data from a [de::LevelDat] fn spawn(level_dat: &de::LevelDat) -> Spawn { let (x, z) = match &level_dat.data { de::LevelDatData::V1_21_9 { spawn } => match spawn.dimension.as_str() { "minecraft:overworld" | "overworld" => ( #[allow(clippy::get_first)] spawn.pos.get(0).copied().unwrap_or_default(), spawn.pos.get(2).copied().unwrap_or_default(), ), // We only support the overworld dimension; simply center the // map on 0,0 if the spawn is somewhere else _ => (0, 0), }, de::LevelDatData::V0 { spawn_x, spawn_z } => (*spawn_x, *spawn_z), }; Spawn { x, z } } /// Filter signs according to the sign pattern configuration fn sign_filter(&self, sign: &block_entity::Sign) -> bool { let front_text = sign.front_text.to_string(); if self.config.sign_patterns.is_match(front_text.trim()) { return true; } let back_text = sign.back_text.to_string(); if self.config.sign_patterns.is_match(back_text.trim()) { return true; } false } /// Applies a single transform to a [sign::SignText] /// /// The regular expression is applied for each line of the sign text /// separately (actually for each element when JSON text is used) fn sign_text_transform(sign_text: &mut sign::SignText, transform: &(Regex, String)) { let (regexp, replacement) = transform; for line in &mut sign_text.0 { for text in &mut line.0 { text.text = regexp.replace_all(&text.text, replacement).into_owned() } } } /// Applies the configured transforms to the text of a sign fn sign_transform(&self, sign: &mut block_entity::Sign) { for transform in &self.config.sign_transforms { Self::sign_text_transform(&mut sign.front_text, transform); Self::sign_text_transform(&mut sign.back_text, transform); } } /// Generates [Entities] data from collected entity lists fn entities(&self) -> Result<Entities> { let data: ProcessedEntities = storage::read_file(&self.config.entities_path_final) .context("Failed to read entity data file")?; let ret = Entities { signs: data .block_entities .into_iter() .filter(|entity| match &entity.data { BlockEntityData::Sign(sign) => self.sign_filter(sign), }) .map(|mut entity| { match &mut entity.data { BlockEntityData::Sign(sign) => self.sign_transform(sign), }; entity }) .collect(), }; Ok(ret) } /// Runs the viewer metadata file generation pub fn run(self) -> Result<()> { let level_dat = self.read_level_dat()?; let features = Features { signs: !self.config.sign_patterns.is_empty(), }; let mut metadata = Metadata { mipmaps: Vec::new(), spawn: Self::spawn(&level_dat), features, tile_extension: self.config.tile_extension(), }; for tile_map in self.tiles.iter() { metadata.mipmaps.push(Self::mipmap_entry(tile_map)); } fs::create_with_tmpfile(&self.config.viewer_info_path, |file| { serde_json::to_writer(file, &metadata).context("Failed to write info.json") })?; let entities = self.entities()?; fs::create_with_tmpfile(&self.config.viewer_entities_path, |file| { serde_json::to_writer(file, &entities).context("Failed to write entities.json") })?; Ok(()) } }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/core/tile_collector.rs
src/core/tile_collector.rs
//! A trait for recursively processing tiles //! //! Used for mipmap generation and collecting entity data use std::sync::mpsc; use anyhow::Result; use rayon::prelude::*; use super::common::*; /// Helper to determine if no further mipmap levels are needed /// /// If all tile coordinates are -1 or 0, further mipmap levels will not /// decrease the number of tiles and mipmap generated is considered finished. fn done(tiles: &TileCoordMap) -> bool { tiles .0 .iter() .all(|(z, xs)| (-1..=0).contains(z) && xs.iter().all(|x| (-1..=0).contains(x))) } /// Derives the map of populated tile coordinates for the next mipmap level fn map_coords(tiles: &TileCoordMap) -> TileCoordMap { let mut ret = TileCoordMap::default(); for (&z, xs) in &tiles.0 { for &x in xs { let xt = x >> 1; let zt = z >> 1; ret.0.entry(zt).or_default().insert(xt); } } ret } /// Trait to implement for collecting tiles recursively pub trait TileCollector: Sync { /// Return value of [TileCollector::collect_one] type CollectOutput: Send; /// List of level 0 tiles fn tiles(&self) -> &[TileCoords]; /// Called at the beginning of each level of processing fn prepare(&self, level: usize) -> Result<()>; /// Called at the end of each level of processing fn finish( &self, level: usize, outputs: impl Iterator<Item = Self::CollectOutput>, ) -> Result<()>; /// Called for each tile coordinate of the level that is currently being generated fn collect_one( &self, level: usize, coords: TileCoords, prev: &TileCoordMap, ) -> Result<Self::CollectOutput>; /// Collects tiles recursively fn collect_tiles(&self) -> Result<Vec<TileCoordMap>> { let mut tile_stack = { let mut tile_map = TileCoordMap::default(); for &TileCoords { x, z } in self.tiles() { tile_map.0.entry(z).or_default().insert(x); } vec![tile_map] }; loop { let level = tile_stack.len(); let prev = &tile_stack[level - 1]; if done(prev) { break; } self.prepare(level)?; let next = map_coords(prev); let (send, recv) = mpsc::channel(); next.0 .par_iter() .flat_map(|(&z, xs)| xs.par_iter().map(move |&x| TileCoords { x, z })) .try_for_each(|coords| { let output = self.collect_one(level, coords, prev)?; send.send(output).unwrap(); anyhow::Ok(()) })?; drop(send); self.finish(level, recv.into_iter())?; tile_stack.push(next); } Ok(tile_stack) } }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/core/tile_merger.rs
src/core/tile_merger.rs
//! Mipmap-style merging of tiles use std::{ fs::File, io::BufWriter, path::{Path, PathBuf}, time::SystemTime, }; use anyhow::Result; use tracing::warn; use super::common::*; use crate::io::fs; /// [TileMerger::merge_tiles] return #[derive(Debug, Clone, Copy)] pub enum Stat { /// None of the input files were found NotFound, /// The output file is up-to-date Skipped, /// The output file is regenerated Regenerate, } /// A source file for the [TileMerger] /// /// The tuple elements are X and Z coordinate offsets in the range [0, 1], /// the file path and the time of last change of the input. pub type Source = ((i32, i32), PathBuf, SystemTime); /// Reusable trait for mipmap-style tile merging with change tracking pub trait TileMerger { /// [fs::FileMetaVersion] of input and output files /// /// The version in the file metadata on disk must match the returned /// version for the a to be considered up-to-date. fn file_meta_version(&self) -> fs::FileMetaVersion; /// Returns the paths of input and output files fn tile_path(&self, level: usize, coords: TileCoords) -> PathBuf; /// Can be used to log the processing status fn log(&self, _output_path: &Path, _stat: Stat) {} /// Handles the actual merging of source files fn write_tile(&self, file: &mut BufWriter<File>, sources: &[Source]) -> Result<()>; /// Generates a tile at given coordinates and mipmap level fn merge_tiles(&self, level: usize, coords: TileCoords, prev: &TileCoordMap) -> Result<Stat> { let version = self.file_meta_version(); let output_path = self.tile_path(level, coords); let output_timestamp = fs::read_timestamp(&output_path, version); let sources: Vec<_> = [(0, 0), (0, 1), (1, 0), (1, 1)] .into_iter() .filter_map(|(dx, dz)| { let source_coords = TileCoords { x: 2 * coords.x + dx, z: 2 * coords.z + dz, }; if !prev.contains(source_coords) { return None; } let source_path = self.tile_path(level - 1, source_coords); let timestamp = match fs::modified_timestamp(&source_path) { Ok(timestamp) => timestamp, Err(err) => { warn!("{:?}", err); return None; } }; Some(((dx, dz), source_path, timestamp)) }) .collect(); let Some(input_timestamp) = sources.iter().map(|(_, _, ts)| *ts).max() else { self.log(&output_path, Stat::NotFound); return Ok(Stat::NotFound); }; if Some(input_timestamp) <= output_timestamp { self.log(&output_path, Stat::Skipped); return Ok(Stat::Skipped); } self.log(&output_path, Stat::Regenerate); fs::create_with_timestamp(&output_path, version, input_timestamp, |file| { self.write_tile(file, &sources) })?; Ok(Stat::Regenerate) } }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/core/mod.rs
src/core/mod.rs
//! Core functions of the MinedMap CLI mod common; mod entity_collector; mod metadata_writer; mod region_group; mod region_processor; mod tile_collector; mod tile_merger; mod tile_mipmapper; mod tile_renderer; use std::{ path::PathBuf, sync::mpsc::{self, Receiver}, thread, time::Duration, }; use anyhow::{Context, Result}; use clap::Parser; use git_version::git_version; use common::{Config, ImageFormat}; use metadata_writer::MetadataWriter; use notify::{RecommendedWatcher, RecursiveMode, Watcher as _}; use rayon::ThreadPool; use region_processor::RegionProcessor; use tile_mipmapper::TileMipmapper; use tile_renderer::TileRenderer; use tokio::runtime::Runtime; use tracing::{info, warn}; use self::entity_collector::EntityCollector; /// Returns the MinedMap version number fn version() -> &'static str { option_env!("MINEDMAP_VERSION").unwrap_or( git_version!( args = ["--abbrev=7", "--match=v*", "--dirty=-modified"], cargo_prefix = "v", ) .strip_prefix("v") .unwrap(), ) } /// Command line arguments for minedmap CLI #[derive(Debug, Parser)] #[command( about, version = version(), max_term_width = 100, )] pub struct Args { /// Number of parallel threads to use for processing /// /// If not given, only a single thread is used. Pass 0 to /// use one thread per logical CPU core. #[arg(short, long)] pub jobs: Option<usize>, /// Number of parallel threads to use for initial processing /// /// Passing this option only makes sense with --watch. The first run after /// starting MinedMap will use as many parallel jobs as configured using /// --job-initial, while subsequent regenerations of tiles will use the /// the number configured using --jobs. /// /// If not given, the value from the --jobs option is used. #[arg(long)] pub jobs_initial: Option<usize>, /// Enable verbose messages #[arg(short, long)] pub verbose: bool, /// Watch for file changes and regenerate tiles automatically instead of /// exiting after generation #[arg(long)] pub watch: bool, /// Minimum delay between map generation cycles in watch mode #[arg(long, value_parser = humantime::parse_duration, default_value = "30s")] pub watch_delay: Duration, /// Format of generated map tiles #[arg(long, value_enum, default_value_t)] pub image_format: ImageFormat, /// Prefix for text of signs to show on the map #[arg(long)] pub sign_prefix: Vec<String>, /// Regular expression for text of signs to show on the map /// /// --sign-prefix and --sign-filter allow to filter for signs to display; /// by default, none are visible. The options may be passed multiple times, /// and a sign will be visible if it matches any pattern. /// /// To make all signs visible, pass an empty string to either option. #[arg(long)] pub sign_filter: Vec<String>, /// Regular expression replacement pattern for sign texts /// /// Accepts patterns of the form 's/regexp/replacement/'. Transforms /// are applied to each line of sign texts separately. #[arg(long)] pub sign_transform: Vec<String>, /// Minecraft save directory pub input_dir: PathBuf, /// MinedMap data directory pub output_dir: PathBuf, } /// Configures a Rayon thread pool for parallel processing fn setup_threads(num_threads: usize) -> Result<ThreadPool> { rayon::ThreadPoolBuilder::new() .num_threads(num_threads) .build() .context("Failed to configure thread pool") } /// Runs all MinedMap generation steps, updating all tiles as needed fn generate(config: &Config, rt: &Runtime) -> Result<()> { let regions = RegionProcessor::new(config).run()?; TileRenderer::new(config, rt, &regions).run()?; let tiles = TileMipmapper::new(config, &regions).run()?; EntityCollector::new(config, &regions).run()?; MetadataWriter::new(config, &tiles).run() } /// Creates a file watcher for the fn create_watcher(args: &Args) -> Result<(RecommendedWatcher, Receiver<()>)> { let (tx, rx) = mpsc::sync_channel::<()>(1); let mut watcher = notify::recommended_watcher(move |res| { // Ignore errors - we already have a watch trigger queued if try_send() fails let event: notify::Event = match res { Ok(event) => event, Err(err) => { warn!("Watch error: {err}"); return; } }; let notify::EventKind::Modify(modify_kind) = event.kind else { return; }; if !matches!( modify_kind, notify::event::ModifyKind::Data(_) | notify::event::ModifyKind::Name(notify::event::RenameMode::To) ) { return; } if !event .paths .iter() .any(|path| path.ends_with("level.dat") || path.extension() == Some("mcu".as_ref())) { return; } let _ = tx.try_send(()); })?; watcher.watch(&args.input_dir, RecursiveMode::Recursive)?; Ok((watcher, rx)) } /// Watches the data directory for changes, returning when a change has happened fn wait_watcher(args: &Args, watch_channel: &Receiver<()>) -> Result<()> { info!("Watching for changes..."); let () = watch_channel .recv() .context("Failed to read watch event channel")?; info!("Change detected."); thread::sleep(args.watch_delay); let _ = watch_channel.try_recv(); Ok(()) } /// MinedMap CLI main function pub fn cli() -> Result<()> { let args = Args::parse(); let config = Config::new(&args)?; tracing_subscriber::fmt() .with_max_level(if args.verbose { tracing::Level::DEBUG } else { tracing::Level::INFO }) .with_target(false) .init(); let mut pool = setup_threads(config.num_threads_initial)?; let rt = tokio::runtime::Builder::new_current_thread() .build() .unwrap(); let watch = args.watch.then(|| create_watcher(&args)).transpose()?; pool.install(|| generate(&config, &rt))?; let Some((_watcher, watch_channel)) = watch else { // watch mode disabled return Ok(()); }; if config.num_threads != config.num_threads_initial { pool = setup_threads(config.num_threads)?; } pool.install(move || { loop { wait_watcher(&args, &watch_channel)?; generate(&config, &rt)?; } }) }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/core/tile_mipmapper.rs
src/core/tile_mipmapper.rs
//! The [TileMipmapper] use std::{marker::PhantomData, ops::Add}; use anyhow::{Context, Result}; use tracing::{debug, info, warn}; use super::{ common::*, tile_collector::TileCollector, tile_merger::{self, TileMerger}, }; use crate::{io::fs, types::*}; /// Counters for the number of processed and total tiles /// /// Used as return of [TileMipmapper::collect_one] #[derive(Debug, Clone, Copy)] pub struct MipmapStat { /// Total number of tiles total: usize, /// Processed number of tiles processed: usize, } impl From<tile_merger::Stat> for MipmapStat { fn from(value: tile_merger::Stat) -> Self { match value { tile_merger::Stat::NotFound => MipmapStat { total: 0, processed: 0, }, tile_merger::Stat::Skipped => MipmapStat { total: 1, processed: 0, }, tile_merger::Stat::Regenerate => MipmapStat { total: 1, processed: 1, }, } } } impl Add for MipmapStat { type Output = MipmapStat; fn add(self, rhs: Self) -> Self::Output { MipmapStat { total: self.total + rhs.total, processed: self.processed + rhs.processed, } } } /// [TileMerger] for map tile images struct MapMerger<'a, P> { /// Common MinedMap configuration from command line config: &'a Config, /// Tile kind (map or lightmap) kind: TileKind, /// Pixel format type _pixel: PhantomData<P>, } impl<'a, P> MapMerger<'a, P> { /// Creates a new [MapMerger] fn new(config: &'a Config, kind: TileKind) -> Self { MapMerger { config, kind, _pixel: PhantomData, } } } impl<P: image::PixelWithColorType> TileMerger for MapMerger<'_, P> where [P::Subpixel]: image::EncodableLayout, image::ImageBuffer<P, Vec<P::Subpixel>>: Into<image::DynamicImage>, { fn file_meta_version(&self) -> fs::FileMetaVersion { MIPMAP_FILE_META_VERSION } fn tile_path(&self, level: usize, coords: TileCoords) -> std::path::PathBuf { self.config.tile_path(self.kind, level, coords) } fn log(&self, output_path: &std::path::Path, stat: super::tile_merger::Stat) { match stat { super::tile_merger::Stat::NotFound => {} super::tile_merger::Stat::Skipped => { debug!( "Skipping unchanged mipmap tile {}", output_path .strip_prefix(&self.config.output_dir) .expect("tile path must be in output directory") .display(), ); } super::tile_merger::Stat::Regenerate => { debug!( "Rendering mipmap tile {}", output_path .strip_prefix(&self.config.output_dir) .expect("tile path must be in output directory") .display(), ); } }; } fn write_tile( &self, file: &mut std::io::BufWriter<std::fs::File>, sources: &[super::tile_merger::Source], ) -> Result<()> { /// Tile width/height const N: u32 = (BLOCKS_PER_CHUNK * CHUNKS_PER_REGION) as u32; let mut image: image::DynamicImage = image::ImageBuffer::<P, Vec<P::Subpixel>>::new(N, N).into(); for ((dx, dz), source_path, _) in sources { let source = match image::open(source_path) { Ok(source) => source, Err(err) => { warn!( "Failed to read source image {}: {:?}", source_path.display(), err, ); continue; } }; let resized = source.resize(N / 2, N / 2, image::imageops::FilterType::Triangle); image::imageops::overlay( &mut image, &resized, *dx as i64 * (N / 2) as i64, *dz as i64 * (N / 2) as i64, ); } image .write_to(file, self.config.tile_image_format()) .context("Failed to save image") } } /// Generates mipmap tiles from full-resolution tile images pub struct TileMipmapper<'a> { /// Common MinedMap configuration from command line config: &'a Config, /// List of populated tiles for base mipmap level (level 0) regions: &'a [TileCoords], } impl TileCollector for TileMipmapper<'_> { type CollectOutput = MipmapStat; fn tiles(&self) -> &[TileCoords] { self.regions } fn prepare(&self, level: usize) -> Result<()> { info!("Generating level {} mipmaps...", level); fs::create_dir_all(&self.config.tile_dir(TileKind::Map, level))?; fs::create_dir_all(&self.config.tile_dir(TileKind::Lightmap, level))?; Ok(()) } fn finish( &self, level: usize, outputs: impl Iterator<Item = Self::CollectOutput>, ) -> Result<()> { let stat = outputs.fold( MipmapStat { total: 0, processed: 0, }, MipmapStat::add, ); info!( "Generated level {} mipmaps ({} processed, {} unchanged)", level, stat.processed, stat.total - stat.processed, ); Ok(()) } fn collect_one( &self, level: usize, coords: TileCoords, prev: &TileCoordMap, ) -> Result<Self::CollectOutput> { let map_stat = self.render_mipmap::<image::Rgba<u8>>(TileKind::Map, level, coords, prev)?; let lightmap_stat = self.render_mipmap::<image::LumaA<u8>>(TileKind::Lightmap, level, coords, prev)?; Ok(map_stat + lightmap_stat) } } impl<'a> TileMipmapper<'a> { /// Constructs a new TileMipmapper pub fn new(config: &'a Config, regions: &'a [TileCoords]) -> Self { TileMipmapper { config, regions } } /// Renders and saves a single mipmap tile image /// /// Each mipmap tile is rendered by taking 2x2 tiles from the /// previous level and scaling them down by 50%. fn render_mipmap<P: image::PixelWithColorType>( &self, kind: TileKind, level: usize, coords: TileCoords, prev: &TileCoordMap, ) -> Result<MipmapStat> where [P::Subpixel]: image::EncodableLayout, image::ImageBuffer<P, Vec<P::Subpixel>>: Into<image::DynamicImage>, { let merger = MapMerger::<P>::new(self.config, kind); let ret = merger.merge_tiles(level, coords, prev)?; Ok(ret.into()) } /// Runs the mipmap generation pub fn run(self) -> Result<Vec<TileCoordMap>> { self.collect_tiles() } }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/core/tile_renderer.rs
src/core/tile_renderer.rs
//! The [TileRenderer] and related types and functions use std::{ num::NonZeroUsize, path::PathBuf, sync::{Arc, Mutex}, time::SystemTime, }; use anyhow::{Context, Result}; use lru::LruCache; use rayon::prelude::*; use tokio::sync::OnceCell; use tracing::{debug, info}; use super::{common::*, region_group::RegionGroup}; use crate::{ io::{fs, storage}, resource::{Colorf, block_color, needs_biome}, types::*, util::coord_offset, }; /// Type for referencing loaded [ProcessedRegion] data type RegionRef = Arc<ProcessedRegion>; /// Returns the index of the biome at a block coordinate /// /// The passed chunk and block coordinates relative to the center of the /// region group is offset by *dx* and *dz*. /// /// The returned tuple contains the relative region coordinates the offset coordinate /// ends up in (in the range -1..1) and the index in that region's biome list. fn biome_at( region_group: &RegionGroup<RegionRef>, chunk: ChunkCoords, block: LayerBlockCoords, dx: i32, dz: i32, ) -> Option<(i8, i8, u16)> { let (region_x, chunk_x, block_x) = coord_offset(chunk.x, block.x, dx); let (region_z, chunk_z, block_z) = coord_offset(chunk.z, block.z, dz); let chunk = ChunkCoords { x: chunk_x, z: chunk_z, }; let block = LayerBlockCoords { x: block_x, z: block_z, }; let region = region_group.get(region_x, region_z)?; Some(( region_x, region_z, region.chunks[chunk].as_ref()?.biomes[block]?.get() - 1, )) } /// The TileRenderer generates map tiles from processed region data pub struct TileRenderer<'a> { /// Common MinedMap configuration from command line config: &'a Config, /// Runtime for asynchronous region loading rt: &'a tokio::runtime::Runtime, /// List of populated regions to render tiles for regions: &'a [TileCoords], /// Set of populated regions for fast existence checking region_set: rustc_hash::FxHashSet<TileCoords>, /// Cache of previously loaded regions region_cache: Mutex<LruCache<PathBuf, Arc<OnceCell<RegionRef>>>>, } impl<'a> TileRenderer<'a> { /// Constructs a new TileRenderer pub fn new( config: &'a Config, rt: &'a tokio::runtime::Runtime, regions: &'a [TileCoords], ) -> Self { let region_cache = Mutex::new(LruCache::new( NonZeroUsize::new(6 + 6 * config.num_threads).unwrap(), )); let region_set = regions.iter().copied().collect(); TileRenderer { config, rt, regions, region_set, region_cache, } } /// Loads [ProcessedRegion] for a region or returns previously loaded data from the region cache async fn load_region(&self, processed_path: PathBuf) -> Result<RegionRef> { let region_loader = { let mut region_cache = self.region_cache.lock().unwrap(); if let Some(region_loader) = region_cache.get(&processed_path) { Arc::clone(region_loader) } else { let region_loader = Default::default(); region_cache.put(processed_path.clone(), Arc::clone(&region_loader)); region_loader } }; region_loader .get_or_try_init(|| async { storage::read_file(&processed_path).context("Failed to load processed region data") }) .await .cloned() } /// Loads a 3x3 neighborhood of processed region data async fn load_region_group( &self, processed_paths: RegionGroup<PathBuf>, ) -> Result<RegionGroup<RegionRef>> { processed_paths .async_try_map(move |path| self.load_region(path)) .await } /// Computes the color of a tile pixel fn block_color_at( region_group: &RegionGroup<RegionRef>, chunk: &ProcessedChunk, chunk_coords: ChunkCoords, block_coords: LayerBlockCoords, ) -> Option<Colorf> { /// Helper for keys in the weight table /// /// Hashing the value as a single u32 is more efficient than hashing /// the tuple elements separately. fn biome_key((dx, dz, index): (i8, i8, u16)) -> u32 { (dx as u8 as u32) | ((dz as u8 as u32) << 8) | ((index as u32) << 16) } /// One quadrant of the kernel used to smooth biome edges /// /// The kernel is mirrored in X und Z direction to build the full 5x5 /// smoothing kernel. const SMOOTH: [[f32; 3]; 3] = [[41.0, 26.0, 7.0], [26.0, 16.0, 4.0], [7.0, 4.0, 1.0]]; /// Maximum X coordinate offset to take into account for biome smoothing const X: isize = SMOOTH[0].len() as isize - 1; /// Maximum Z coordinate offset to take into account for biome smoothing const Z: isize = SMOOTH.len() as isize - 1; let block = chunk.blocks[block_coords]?; let depth = chunk.depths[block_coords]?; if !needs_biome(block) { return Some(block_color(block, None, depth.0 as f32)); } let mut weights = rustc_hash::FxHashMap::<u32, ((i8, i8, u16), f32)>::default(); for dz in -Z..=Z { for dx in -X..=X { let w = SMOOTH[dz.unsigned_abs()][dx.unsigned_abs()]; if w == 0.0 { continue; } let Some(biome) = biome_at( region_group, chunk_coords, block_coords, dx as i32, dz as i32, ) else { continue; }; let value = weights.entry(biome_key(biome)).or_default(); value.0 = biome; value.1 += w; } } if weights.is_empty() { return None; } let mut color = Colorf::ZERO; let mut total = 0.0; for ((region_x, region_z, index), w) in weights.into_values() { let region = region_group.get(region_x, region_z)?; let biome = region.biome_list.get(usize::from(index))?; total += w; color += w * block_color(block, Some(biome), depth.0 as f32); } Some(color / total) } /// Renders a chunk subtile into a region tile image fn render_chunk( image: &mut image::RgbaImage, region_group: &RegionGroup<RegionRef>, chunk: &ProcessedChunk, chunk_coords: ChunkCoords, ) { /// Width/height of a chunk subtile const N: u32 = BLOCKS_PER_CHUNK as u32; let chunk_image = image::RgbaImage::from_fn(N, N, |x, z| { let block_coords = LayerBlockCoords { x: BlockX::new(x), z: BlockZ::new(z), }; let color = Self::block_color_at(region_group, chunk, chunk_coords, block_coords); image::Rgba( color .map(|c| [c[0] as u8, c[1] as u8, c[2] as u8, 255]) .unwrap_or_default(), ) }); overlay_chunk(image, &chunk_image, chunk_coords); } /// Renders a region tile image fn render_region(image: &mut image::RgbaImage, region_group: &RegionGroup<RegionRef>) { for (coords, chunk) in region_group.center().chunks.iter() { let Some(chunk) = chunk else { continue; }; Self::render_chunk(image, region_group, chunk, coords); } } /// Returns the filename of the processed data for a region and the time of its last modification fn processed_source(&self, coords: TileCoords) -> Result<(PathBuf, SystemTime)> { let path = self.config.processed_path(coords); let timestamp = fs::modified_timestamp(&path)?; Ok((path, timestamp)) } /// Returns the filenames of the processed data for a 3x3 neighborhood of a region /// and the time of last modification for any of them fn processed_sources(&self, coords: TileCoords) -> Result<(RegionGroup<PathBuf>, SystemTime)> { let sources = RegionGroup::new(|x, z| { Some(TileCoords { x: coords.x + (x as i32), z: coords.z + (z as i32), }) .filter(|entry| self.region_set.contains(entry)) }) .try_map(|entry| self.processed_source(entry)) .with_context(|| format!("Region {coords:?} from previous step must exist"))?; let max_timestamp = *sources .iter() .map(|(_, timestamp)| timestamp) .max() .expect("at least one timestamp must exist"); let paths = sources.map(|(path, _)| path); Ok((paths, max_timestamp)) } /// Renders and saves a region tile image fn render_tile(&self, coords: TileCoords) -> Result<bool> { /// Width/height of a tile image const N: u32 = (BLOCKS_PER_CHUNK * CHUNKS_PER_REGION) as u32; let (processed_paths, processed_timestamp) = self.processed_sources(coords)?; let output_path = self.config.tile_path(TileKind::Map, 0, coords); let output_timestamp = fs::read_timestamp(&output_path, MAP_FILE_META_VERSION); if Some(processed_timestamp) <= output_timestamp { debug!( "Skipping unchanged tile {}", output_path .strip_prefix(&self.config.output_dir) .expect("tile path must be in output directory") .display(), ); return Ok(false); } debug!( "Rendering tile {}", output_path .strip_prefix(&self.config.output_dir) .expect("tile path must be in output directory") .display(), ); let region_group = self .rt .block_on(self.load_region_group(processed_paths)) .with_context(|| format!("Region {coords:?} from previous step must be loadable"))?; let mut image = image::RgbaImage::new(N, N); Self::render_region(&mut image, &region_group); fs::create_with_timestamp( &output_path, MAP_FILE_META_VERSION, processed_timestamp, |file| { image .write_to(file, self.config.tile_image_format()) .context("Failed to save image") }, )?; Ok(true) } /// Runs the tile generation pub fn run(self) -> Result<()> { fs::create_dir_all(&self.config.tile_dir(TileKind::Map, 0))?; info!("Rendering map tiles..."); // Use par_bridge to process items in order (for better use of region cache) let processed = self .regions .iter() .par_bridge() .map(|&coords| { anyhow::Ok(usize::from( self.render_tile(coords) .with_context(|| format!("Failed to render tile {coords:?}"))?, )) }) .try_reduce(|| 0, |a, b| Ok(a + b))?; info!( "Rendered map tiles ({} processed, {} unchanged)", processed, self.regions.len() - processed, ); Ok(()) } }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/core/common.rs
src/core/common.rs
//! Common data types and functions used by multiple generation steps use std::{ collections::{BTreeMap, BTreeSet}, fmt::Debug, hash::Hash, path::{Path, PathBuf}, }; use anyhow::{Context, Result}; use bincode::{Decode, Encode}; use clap::ValueEnum; use regex::{Regex, RegexSet}; use serde::Serialize; use crate::{ io::fs::FileMetaVersion, resource::Biome, types::*, world::{block_entity::BlockEntity, layer}, }; // Increase to force regeneration of all output files /// MinedMap processed region data version number /// /// Increase when the generation of processed regions from region data changes /// (usually because of updated resource data) pub const REGION_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(9); /// MinedMap map tile data version number /// /// Increase when the generation of map tiles from processed regions changes /// (because of code changes in tile generation) pub const MAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0); /// MinedMap lightmap data version number /// /// Increase when the generation of lightmap tiles from region data changes /// (usually because of updated resource data) pub const LIGHTMAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(7); /// MinedMap mipmap data version number /// /// Increase when the mipmap generation changes (this should not happen) pub const MIPMAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0); /// MinedMap processed entity data version number /// /// Increase when entity collection changes bacause of code changes. pub const ENTITIES_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(3); /// Coordinate pair of a generated tile /// /// Each tile corresponds to one Minecraft region file #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct TileCoords { /// The X coordinate pub x: i32, /// The Z coordinate pub z: i32, } impl Debug for TileCoords { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "({}, {})", self.x, self.z) } } /// Set of tile coordinates /// /// Used to store list of populated tiles for each mipmap level in the /// viewer metadata file. #[derive(Debug, Clone, Default, Serialize)] #[serde(transparent)] pub struct TileCoordMap(pub BTreeMap<i32, BTreeSet<i32>>); impl TileCoordMap { /// Checks whether the map contains a given coordinate pair pub fn contains(&self, coords: TileCoords) -> bool { let Some(xs) = self.0.get(&coords.z) else { return false; }; xs.contains(&coords.x) } } /// Data structure for storing chunk data between processing and rendering steps #[derive(Debug, Encode, Decode)] pub struct ProcessedChunk { /// Block type data pub blocks: Box<layer::BlockArray>, /// Biome data pub biomes: Box<layer::BiomeArray>, /// Block height/depth data pub depths: Box<layer::DepthArray>, } /// Data structure for storing region data between processing and rendering steps #[derive(Debug, Default, Encode, Decode)] pub struct ProcessedRegion { /// List of biomes used in the region /// /// Indexed by [ProcessedChunk] biome data pub biome_list: Vec<Biome>, /// Processed chunk data pub chunks: ChunkArray<Option<Box<ProcessedChunk>>>, } /// Data structure for storing entity data between processing and collection steps #[derive(Debug, Default, Encode, Decode)] pub struct ProcessedEntities { /// List of block entities pub block_entities: Vec<BlockEntity>, } /// Derives a filename from region coordinates and a file extension /// /// Can be used for input regions, processed data or rendered tiles fn coord_filename(coords: TileCoords, ext: &str) -> String { format!("r.{}.{}.{}", coords.x, coords.z, ext) } /// Tile kind corresponding to a map layer #[derive(Debug, Clone, Copy)] pub enum TileKind { /// Regular map tile contains block colors Map, /// Lightmap tile for illumination layer Lightmap, } /// Common configuration based on command line arguments #[derive(Debug)] pub struct Config { /// Number of threads for parallel processing pub num_threads: usize, /// Number of threads for initial parallel processing pub num_threads_initial: usize, /// Path of input region directory pub region_dir: PathBuf, /// Path of input `level.dat` file pub level_dat_path: PathBuf, /// Path of input `level.dat_old` file pub level_dat_old_path: PathBuf, /// Base path for storage of rendered tile data pub output_dir: PathBuf, /// Path for storage of intermediate processed data files pub processed_dir: PathBuf, /// Path for storage of processed entity data files pub entities_dir: PathBuf, /// Path for storage of the final merged processed entity data file pub entities_path_final: PathBuf, /// Path of viewer metadata file pub viewer_info_path: PathBuf, /// Path of viewer entities file pub viewer_entities_path: PathBuf, /// Format of generated map tiles pub image_format: ImageFormat, /// Sign text filter patterns pub sign_patterns: RegexSet, /// Sign text transformation pattern pub sign_transforms: Vec<(Regex, String)>, } impl Config { /// Crates a new [Config] from [command line arguments](super::Args) pub fn new(args: &super::Args) -> Result<Self> { let num_threads = match args.jobs { Some(0) => num_cpus::get(), Some(threads) => threads, None => 1, }; let num_threads_initial = args.jobs_initial.unwrap_or(num_threads); let region_dir = [&args.input_dir, Path::new("region")].iter().collect(); let level_dat_path = [&args.input_dir, Path::new("level.dat")].iter().collect(); let level_dat_old_path = [&args.input_dir, Path::new("level.dat_old")] .iter() .collect(); let processed_dir: PathBuf = [&args.output_dir, Path::new("processed")].iter().collect(); let entities_dir: PathBuf = [&processed_dir, Path::new("entities")].iter().collect(); let entities_path_final = [&entities_dir, Path::new("entities.bin")].iter().collect(); let viewer_info_path = [&args.output_dir, Path::new("info.json")].iter().collect(); let viewer_entities_path = [&args.output_dir, Path::new("entities.json")] .iter() .collect(); let sign_patterns = Self::sign_patterns(args).context("Failed to parse sign patterns")?; let sign_transforms = Self::sign_transforms(args).context("Failed to parse sign transforms")?; Ok(Config { num_threads, num_threads_initial, region_dir, level_dat_path, level_dat_old_path, output_dir: args.output_dir.clone(), processed_dir, entities_dir, entities_path_final, viewer_info_path, viewer_entities_path, image_format: args.image_format, sign_patterns, sign_transforms, }) } /// Parses the sign prefixes and sign filters into a [RegexSet] fn sign_patterns(args: &super::Args) -> Result<RegexSet> { let prefix_patterns: Vec<_> = args .sign_prefix .iter() .map(|prefix| format!("^{}", regex::escape(prefix))) .collect(); Ok(RegexSet::new( prefix_patterns.iter().chain(args.sign_filter.iter()), )?) } /// Parses the sign transform argument into a vector of [Regex] and /// corresponding replacement strings fn sign_transforms(args: &super::Args) -> Result<Vec<(Regex, String)>> { let splitter = Regex::new(r"^s/((?:[^\\/]|\\.)*)/((?:[^\\/]|\\.)*)/$").unwrap(); args.sign_transform .iter() .map(|t| Self::sign_transform(&splitter, t)) .collect() } /// Parses the sign transform argument into a [Regex] and its corresponding /// replacement string fn sign_transform(splitter: &Regex, transform: &str) -> Result<(Regex, String)> { let captures = splitter .captures(transform) .with_context(|| format!("Invalid transform pattern '{transform}'"))?; let regexp = Regex::new(&captures[1])?; let replacement = captures[2].to_string(); Ok((regexp, replacement)) } /// Constructs the path to an input region file pub fn region_path(&self, coords: TileCoords) -> PathBuf { let filename = coord_filename(coords, "mca"); [&self.region_dir, Path::new(&filename)].iter().collect() } /// Constructs the path of an intermediate processed region file pub fn processed_path(&self, coords: TileCoords) -> PathBuf { let filename = coord_filename(coords, "bin"); [&self.processed_dir, Path::new(&filename)].iter().collect() } /// Constructs the base output path for processed entity data pub fn entities_dir(&self, level: usize) -> PathBuf { [&self.entities_dir, Path::new(&level.to_string())] .iter() .collect() } /// Constructs the path of a processed entity data file pub fn entities_path(&self, level: usize, coords: TileCoords) -> PathBuf { let filename = coord_filename(coords, "bin"); let dir = self.entities_dir(level); [Path::new(&dir), Path::new(&filename)].iter().collect() } /// Constructs the base output path for a [TileKind] and mipmap level pub fn tile_dir(&self, kind: TileKind, level: usize) -> PathBuf { let prefix = match kind { TileKind::Map => "map", TileKind::Lightmap => "light", }; let dir = format!("{prefix}/{level}"); [&self.output_dir, Path::new(&dir)].iter().collect() } /// Returns the file extension for the configured image format pub fn tile_extension(&self) -> &'static str { match self.image_format { ImageFormat::Png => "png", ImageFormat::Webp => "webp", } } /// Returns the configurured image format for the image library pub fn tile_image_format(&self) -> image::ImageFormat { match self.image_format { ImageFormat::Png => image::ImageFormat::Png, ImageFormat::Webp => image::ImageFormat::WebP, } } /// Constructs the path of an output tile image pub fn tile_path(&self, kind: TileKind, level: usize, coords: TileCoords) -> PathBuf { let filename = coord_filename(coords, self.tile_extension()); let dir = self.tile_dir(kind, level); [Path::new(&dir), Path::new(&filename)].iter().collect() } } /// Format of generated map tiles #[derive(Debug, Clone, Copy, Default, ValueEnum)] pub enum ImageFormat { /// Generate PNG images #[default] Png, /// Generate WebP images Webp, } /// Copies a chunk image into a region tile pub fn overlay_chunk<I, J>(image: &mut I, chunk: &J, coords: ChunkCoords) where I: image::GenericImage, J: image::GenericImageView<Pixel = I::Pixel>, { image::imageops::overlay( image, chunk, coords.x.0 as i64 * BLOCKS_PER_CHUNK as i64, coords.z.0 as i64 * BLOCKS_PER_CHUNK as i64, ); }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/core/region_processor.rs
src/core/region_processor.rs
//! The [RegionProcessor] and related functions use std::{ffi::OsStr, path::PathBuf, sync::mpsc, time::SystemTime}; use anyhow::{Context, Result}; use enum_map::{Enum, EnumMap}; use indexmap::IndexSet; use minedmap_resource::Biome; use rayon::prelude::*; use tracing::{debug, info, warn}; use super::common::*; use crate::{ io::{fs, storage}, resource, types::*, world::{self, layer}, }; /// Parses a filename in the format r.X.Z.mca into the contained X and Z values fn parse_region_filename(file_name: &OsStr) -> Option<TileCoords> { let parts: Vec<_> = file_name.to_str()?.split('.').collect(); let &["r", x, z, "mca"] = parts.as_slice() else { return None; }; Some(TileCoords { x: x.parse().ok()?, z: z.parse().ok()?, }) } /// [RegionProcessor::process_region] return values #[derive(Debug, Clone, Copy, PartialEq, Eq, Enum)] enum RegionProcessorStatus { /// Region was processed Ok, /// Region was processed, unknown blocks or biomes were encountered OkWithUnknown, /// Region was unchanged and skipped Skipped, /// Reading the region failed, previous processed data is reused ErrorOk, /// Reading the region failed, no previous data available ErrorMissing, } /// Data of a region being processed by a [SingleRegionProcessor] #[derive(Debug)] struct SingleRegionData { /// [IndexSet] of biomes used by the processed region biome_list: IndexSet<Biome>, /// Processed region chunk intermediate data chunks: ChunkArray<Option<Box<ProcessedChunk>>>, /// Lightmap intermediate data lightmap: image::GrayAlphaImage, /// Processed entity intermediate data entities: ProcessedEntities, /// True if any unknown block or biome types were encountered during processing has_unknown: bool, } impl Default for SingleRegionData { fn default() -> Self { /// Width/height of the region data const N: u32 = (BLOCKS_PER_CHUNK * CHUNKS_PER_REGION) as u32; let lightmap = image::GrayAlphaImage::new(N, N); Self { biome_list: Default::default(), chunks: Default::default(), lightmap, entities: Default::default(), has_unknown: false, } } } /// Handles processing for a single region struct SingleRegionProcessor<'a> { /// Registry of known block types block_types: &'a resource::BlockTypes, /// Registry of known biome types biome_types: &'a resource::BiomeTypes, /// Coordinates of the region this instance is processing coords: TileCoords, /// Input region filename input_path: PathBuf, /// Processed region data output filename output_path: PathBuf, /// Lightmap output filename lightmap_path: PathBuf, /// Processed entity output filename entities_path: PathBuf, /// Timestamp of last modification of input file input_timestamp: SystemTime, /// Timestamp of last modification of processed region output file (if valid) output_timestamp: Option<SystemTime>, /// Timestamp of last modification of lightmap output file (if valid) lightmap_timestamp: Option<SystemTime>, /// Timestamp of last modification of entity list output file (if valid) entities_timestamp: Option<SystemTime>, /// True if processed region output file needs to be updated output_needed: bool, /// True if lightmap output file needs to be updated lightmap_needed: bool, /// True if entity output file needs to be updated entities_needed: bool, /// Format of generated map tiles image_format: image::ImageFormat, } impl<'a> SingleRegionProcessor<'a> { /// Initializes a [SingleRegionProcessor] fn new(processor: &'a RegionProcessor<'a>, coords: TileCoords) -> Result<Self> { let input_path = processor.config.region_path(coords); let input_timestamp = fs::modified_timestamp(&input_path)?; let output_path = processor.config.processed_path(coords); let output_timestamp = fs::read_timestamp(&output_path, REGION_FILE_META_VERSION); let lightmap_path = processor.config.tile_path(TileKind::Lightmap, 0, coords); let lightmap_timestamp = fs::read_timestamp(&lightmap_path, LIGHTMAP_FILE_META_VERSION); let entities_path = processor.config.entities_path(0, coords); let entities_timestamp = fs::read_timestamp(&entities_path, ENTITIES_FILE_META_VERSION); let output_needed = Some(input_timestamp) > output_timestamp; let lightmap_needed = Some(input_timestamp) > lightmap_timestamp; let entities_needed = Some(input_timestamp) > entities_timestamp; Ok(SingleRegionProcessor { block_types: &processor.block_types, biome_types: &processor.biome_types, coords, input_path, output_path, lightmap_path, entities_path, input_timestamp, output_timestamp, lightmap_timestamp, entities_timestamp, output_needed, lightmap_needed, entities_needed, image_format: processor.config.tile_image_format(), }) } /// Renders a lightmap subtile from chunk block light data fn render_chunk_lightmap( block_light: Box<world::layer::BlockLightArray>, ) -> image::GrayAlphaImage { /// Width/height of generated chunk lightmap const N: u32 = BLOCKS_PER_CHUNK as u32; image::GrayAlphaImage::from_fn(N, N, |x, z| { let v: f32 = block_light[LayerBlockCoords { x: BlockX::new(x), z: BlockZ::new(z), }] .into(); image::LumaA([0, (192.0 * (1.0 - v / 15.0)) as u8]) }) } /// Saves processed region data /// /// The timestamp is the time of the last modification of the input region data. fn save_region(&self, processed_region: &ProcessedRegion) -> Result<()> { if !self.output_needed { return Ok(()); } storage::write_file( &self.output_path, processed_region, REGION_FILE_META_VERSION, self.input_timestamp, ) } /// Saves a lightmap tile /// /// The timestamp is the time of the last modification of the input region data. fn save_lightmap(&self, lightmap: &image::GrayAlphaImage) -> Result<()> { if !self.lightmap_needed { return Ok(()); } fs::create_with_timestamp( &self.lightmap_path, LIGHTMAP_FILE_META_VERSION, self.input_timestamp, |file| { lightmap .write_to(file, self.image_format) .context("Failed to save image") }, ) } /// Saves processed entity data /// /// The timestamp is the time of the last modification of the input region data. fn save_entities(&self, entities: &mut ProcessedEntities) -> Result<()> { if !self.entities_needed { return Ok(()); } entities.block_entities.sort_unstable(); storage::write_file( &self.entities_path, entities, ENTITIES_FILE_META_VERSION, self.input_timestamp, ) } /// Processes a single chunk fn process_chunk( &self, data: &mut SingleRegionData, chunk_coords: ChunkCoords, chunk_data: world::de::Chunk, ) -> Result<()> { let (chunk, has_unknown) = world::chunk::Chunk::new(&chunk_data, self.block_types, self.biome_types) .with_context(|| format!("Failed to decode chunk {chunk_coords:?}"))?; data.has_unknown |= has_unknown; if (self.output_needed || self.lightmap_needed) && let Some(layer::LayerData { blocks, biomes, block_light, depths, }) = world::layer::top_layer(&mut data.biome_list, &chunk) .with_context(|| format!("Failed to process chunk {chunk_coords:?}"))? { if self.output_needed { data.chunks[chunk_coords] = Some(Box::new(ProcessedChunk { blocks, biomes, depths, })); } if self.lightmap_needed { let chunk_lightmap = Self::render_chunk_lightmap(block_light); overlay_chunk(&mut data.lightmap, &chunk_lightmap, chunk_coords); } } if self.entities_needed { let mut block_entities = chunk.block_entities().with_context(|| { format!("Failed to process block entities for chunk {chunk_coords:?}") })?; data.entities.block_entities.append(&mut block_entities); } Ok(()) } /// Processes the chunks of the region fn process_chunks(&self, data: &mut SingleRegionData) -> Result<()> { crate::nbt::region::from_file(&self.input_path)?.foreach_chunk( |chunk_coords, chunk_data| self.process_chunk(data, chunk_coords, chunk_data), ) } /// Processes the region fn run(&self) -> Result<RegionProcessorStatus> { if !self.output_needed && !self.lightmap_needed && !self.entities_needed { debug!( "Skipping unchanged region r.{}.{}.mca", self.coords.x, self.coords.z ); return Ok(RegionProcessorStatus::Skipped); } debug!( "Processing region r.{}.{}.mca", self.coords.x, self.coords.z ); let mut data = SingleRegionData::default(); if let Err(err) = self.process_chunks(&mut data) { if self.output_timestamp.is_some() && self.lightmap_timestamp.is_some() && self.entities_timestamp.is_some() { warn!( "Failed to process region {:?}, using old data: {:?}", self.coords, err ); return Ok(RegionProcessorStatus::ErrorOk); } else { warn!( "Failed to process region {:?}, no old data available: {:?}", self.coords, err ); return Ok(RegionProcessorStatus::ErrorMissing); } } let processed_region = ProcessedRegion { biome_list: data.biome_list.into_iter().collect(), chunks: data.chunks, }; self.save_region(&processed_region)?; self.save_lightmap(&data.lightmap)?; self.save_entities(&mut data.entities)?; Ok(if data.has_unknown { RegionProcessorStatus::OkWithUnknown } else { RegionProcessorStatus::Ok }) } } /// Type with methods for processing the regions of a Minecraft save directory /// /// The RegionProcessor builds lightmap tiles as well as processed region data /// consumed by subsequent generation steps. pub struct RegionProcessor<'a> { /// Registry of known block types block_types: resource::BlockTypes, /// Registry of known biome types biome_types: resource::BiomeTypes, /// Common MinedMap configuration from command line config: &'a Config, } impl<'a> RegionProcessor<'a> { /// Constructs a new RegionProcessor pub fn new(config: &'a Config) -> Self { RegionProcessor { block_types: resource::BlockTypes::default(), biome_types: resource::BiomeTypes::default(), config, } } /// Generates a list of all regions of the input Minecraft save data fn collect_regions(&self) -> Result<Vec<TileCoords>> { Ok(self .config .region_dir .read_dir() .with_context(|| { format!( "Failed to read directory {}", self.config.region_dir.display() ) })? .filter_map(|entry| entry.ok()) .filter(|entry| { (|| { // We are only interested in regular files let file_type = entry.file_type().ok()?; if !file_type.is_file() { return None; } let metadata = entry.metadata().ok()?; if metadata.len() == 0 { return None; } Some(()) })() .is_some() }) .filter_map(|entry| parse_region_filename(&entry.file_name())) .collect()) } /// Processes a single region file fn process_region(&self, coords: TileCoords) -> Result<RegionProcessorStatus> { SingleRegionProcessor::new(self, coords)?.run() } /// Iterates over all region files of a Minecraft save directory /// /// Returns a list of the coordinates of all processed regions pub fn run(self) -> Result<Vec<TileCoords>> { use RegionProcessorStatus as Status; fs::create_dir_all(&self.config.processed_dir)?; fs::create_dir_all(&self.config.tile_dir(TileKind::Lightmap, 0))?; fs::create_dir_all(&self.config.entities_dir(0))?; info!("Processing region files..."); let (region_send, region_recv) = mpsc::channel(); let (status_send, status_recv) = mpsc::channel(); self.collect_regions()?.par_iter().try_for_each(|&coords| { let ret = self .process_region(coords) .with_context(|| format!("Failed to process region {coords:?}"))?; if ret != Status::ErrorMissing { region_send.send(coords).unwrap(); } status_send.send(ret).unwrap(); anyhow::Ok(()) })?; drop(region_send); let mut regions: Vec<_> = region_recv.into_iter().collect(); drop(status_send); let mut status = EnumMap::<_, usize>::default(); for ret in status_recv { status[ret] += 1; } info!( "Processed region files ({} processed, {} unchanged, {} errors)", status[Status::Ok] + status[Status::OkWithUnknown], status[Status::Skipped], status[Status::ErrorOk] + status[Status::ErrorMissing], ); if status[Status::OkWithUnknown] > 0 { warn!("Unknown block or biome types found during processing"); eprint!(concat!( "\n", " If you're encountering this issue with an unmodified Minecraft version supported by MinedMap,\n", " please file a bug report including the output with the --verbose flag.\n", "\n", )); } // Sort regions in a zig-zag pattern to optimize cache usage regions.sort_unstable_by_key(|&TileCoords { x, z }| (x, if x % 2 == 0 { z } else { -z })); Ok(regions) } }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/io/fs.rs
src/io/fs.rs
//! Helpers and common functions for filesystem access use std::{ fs::{self, File}, io::{BufReader, BufWriter, Read, Write}, path::{Path, PathBuf}, time::SystemTime, }; use anyhow::{Context, Ok, Result}; use serde::{Deserialize, Serialize}; /// A file metadata version number /// /// Deserialized metadata with non-current version number are considered invalid #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] pub struct FileMetaVersion(pub u32); /// Metadata stored with generated files to track required incremental updates #[derive(Debug, Serialize, Deserialize)] struct FileMeta { /// Version of data described by the FileMeta version: FileMetaVersion, /// Timestamp stored with generated data /// /// This timestamp is always the time of last modification of the inputs /// that were used to generate the file described by the FileMeta. timestamp: SystemTime, } /// Helper for creating suffixed file paths fn suffix_name(path: &Path, suffix: &str) -> PathBuf { let mut file_name = path.file_name().unwrap_or_default().to_os_string(); file_name.push(suffix); let mut ret = path.to_path_buf(); ret.set_file_name(file_name); ret } /// Derives the filename for temporary storage of data during generation fn tmpfile_name(path: &Path) -> PathBuf { suffix_name(path, ".tmp") } /// Derives the filename for associated metadata for generated files fn metafile_name(path: &Path) -> PathBuf { suffix_name(path, ".meta") } /// Creates a directory including all its parents /// /// Wrapper around [fs::create_dir_all] that adds a more descriptive error message pub fn create_dir_all(path: &Path) -> Result<()> { fs::create_dir_all(path) .with_context(|| format!("Failed to create directory {}", path.display(),)) } /// Renames a file or directory /// /// Wrapper around [fs::rename] that adds a more descriptive error message pub fn rename(from: &Path, to: &Path) -> Result<()> { fs::rename(from, to) .with_context(|| format!("Failed to rename {} to {}", from.display(), to.display())) } /// Creates a new file /// /// The contents of the file are defined by the passed function. pub fn create<T, F>(path: &Path, f: F) -> Result<T> where F: FnOnce(&mut BufWriter<File>) -> Result<T>, { (|| { let file = File::create(path)?; let mut writer = BufWriter::new(file); let ret = f(&mut writer)?; writer.flush()?; Ok(ret) })() .with_context(|| format!("Failed to write file {}", path.display())) } /// Checks whether the contents of two files are equal pub fn equal(path1: &Path, path2: &Path) -> Result<bool> { let mut file1 = BufReader::new( fs::File::open(path1) .with_context(|| format!("Failed to open file {}", path1.display()))?, ) .bytes(); let mut file2 = BufReader::new( fs::File::open(path2) .with_context(|| format!("Failed to open file {}", path2.display()))?, ) .bytes(); Ok(loop { match (file1.next().transpose()?, file2.next().transpose()?) { (Some(b1), Some(b2)) if b1 == b2 => continue, (None, None) => break true, _ => break false, }; }) } /// Creates a new file, temporarily storing its contents in a temporary file /// /// Storing the data in a temporary file prevents leaving half-written files /// when the function is interrupted. In addition, the old and new contents of /// the file are compared if a file with the same name already exists, and the /// file timestamp is only updated if the contents have changed. pub fn create_with_tmpfile<T, F>(path: &Path, f: F) -> Result<T> where F: FnOnce(&mut BufWriter<File>) -> Result<T>, { let tmp_path = tmpfile_name(path); let mut cleanup = true; let ret = (|| { let ret = create(&tmp_path, f)?; if !matches!(equal(path, &tmp_path), Result::Ok(true)) { rename(&tmp_path, path)?; cleanup = false; } Ok(ret) })(); if cleanup { let _ = fs::remove_file(&tmp_path); } ret } /// Returns the time of last modification for a given file path pub fn modified_timestamp(path: &Path) -> Result<SystemTime> { fs::metadata(path) .and_then(|meta| meta.modified()) .with_context(|| { format!( "Failed to get modified timestamp of file {}", path.display() ) }) } /// Reads the stored timestamp from file metadata for a file previously written /// using [create_with_timestamp] pub fn read_timestamp(path: &Path, version: FileMetaVersion) -> Option<SystemTime> { let meta_path = metafile_name(path); let mut file = BufReader::new(fs::File::open(meta_path).ok()?); let meta: FileMeta = serde_json::from_reader(&mut file).ok()?; if meta.version != version { return None; } Some(meta.timestamp) } /// Creates a new file, temporarily storing its contents in a temporary file /// like [create_with_tmpfile], and storing a timestamp in a metadata file /// if successful /// /// The timestamp can be retrieved later using [read_timestamp]. pub fn create_with_timestamp<T, F>( path: &Path, version: FileMetaVersion, timestamp: SystemTime, f: F, ) -> Result<T> where F: FnOnce(&mut BufWriter<File>) -> Result<T>, { let ret = create_with_tmpfile(path, f)?; let meta_path = metafile_name(path); create(&meta_path, |file| { serde_json::to_writer(file, &FileMeta { version, timestamp })?; Ok(()) })?; Ok(ret) }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/io/storage.rs
src/io/storage.rs
//! Functions for serializing and deserializing MinedMap data structures efficiently //! //! Data is serialized using Bincode and compressed using zstd. use std::{ fs::File, io::{Read, Write}, path::Path, time::SystemTime, }; use anyhow::{Context, Result}; use bincode::{Decode, Encode}; use super::fs; /// Bincode configuration const BINCODE_CONFIG: bincode::config::Configuration = bincode::config::standard(); /// Serializes data and writes it to a writer pub fn write<W: Write, T: Encode>(writer: &mut W, value: &T) -> Result<()> { let data = bincode::encode_to_vec(value, BINCODE_CONFIG)?; let len = u32::try_from(data.len())?; let compressed = zstd::bulk::compress(&data, 1)?; drop(data); writer.write_all(&len.to_be_bytes())?; writer.write_all(&compressed)?; Ok(()) } /// Serializes data and stores it in a file /// /// A timestamp is stored in an assiciated metadata file. pub fn write_file<T: Encode>( path: &Path, value: &T, version: fs::FileMetaVersion, timestamp: SystemTime, ) -> Result<()> { fs::create_with_timestamp(path, version, timestamp, |file| write(file, value)) } /// Reads data from a reader and deserializes it pub fn read<R, T>(reader: &mut R) -> Result<T> where R: Read, T: Decode<()>, { let mut len_buf = [0u8; 4]; reader.read_exact(&mut len_buf)?; let len = usize::try_from(u32::from_be_bytes(len_buf))?; let mut compressed = vec![]; reader.read_to_end(&mut compressed)?; let data = zstd::bulk::decompress(&compressed, len)?; drop(compressed); Ok(bincode::decode_from_slice(&data, BINCODE_CONFIG)?.0) } /// Reads data from a file and deserializes it pub fn read_file<T>(path: &Path) -> Result<T> where T: Decode<()>, { (|| -> Result<T> { let mut file = File::open(path)?; read(&mut file) })() .with_context(|| format!("Failed to read file {}", path.display())) }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/src/io/mod.rs
src/io/mod.rs
//! Input/output functions pub mod fs; pub mod storage;
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/crates/resource/src/lib.rs
crates/resource/src/lib.rs
#![doc = env!("CARGO_PKG_DESCRIPTION")] #![warn(missing_docs)] #![warn(clippy::missing_docs_in_private_items)] mod biomes; mod block_color; mod block_types; mod legacy_biomes; mod legacy_block_types; use std::collections::HashMap; use bincode::{BorrowDecode, Decode, Encode}; use enumflags2::{BitFlags, bitflags}; /// Flags describing special properties of [BlockType]s #[bitflags] #[repr(u8)] #[derive(Debug, Clone, Copy, PartialEq)] pub enum BlockFlag { /// The block type is opaque Opaque, /// The block type is colored using biome grass colors Grass, /// The block type is colored using biome foliage colors Foliage, /// The block type is birch foliage Birch, /// The block type is spruce foliage Spruce, /// The block type is colored using biome water colors Water, /// The block type is a wall sign /// /// The WallSign flag is used to distinguish wall signs from /// freestanding or -hanging signs. WallSign, } /// An RGB color with u8 components #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Encode, Decode)] pub struct Color(pub [u8; 3]); /// An RGB color with f32 components pub type Colorf = glam::Vec3; /// A block type specification #[derive(Debug, Clone, Copy)] pub struct BlockColor { /// Bit set of [BlockFlag]s describing special properties of the block type pub flags: BitFlags<BlockFlag>, /// Base color of the block type pub color: Color, } impl BlockColor { /// Checks whether a block color has a given [BlockFlag] set #[inline] pub fn is(&self, flag: BlockFlag) -> bool { self.flags.contains(flag) } } impl Encode for BlockColor { fn encode<E: bincode::enc::Encoder>( &self, encoder: &mut E, ) -> Result<(), bincode::error::EncodeError> { bincode::Encode::encode(&self.flags.bits(), encoder)?; bincode::Encode::encode(&self.color, encoder)?; Ok(()) } } impl<Context> Decode<Context> for BlockColor { fn decode<D: bincode::de::Decoder<Context = Context>>( decoder: &mut D, ) -> Result<Self, bincode::error::DecodeError> { Ok(BlockColor { flags: BitFlags::from_bits(bincode::Decode::decode(decoder)?).or(Err( bincode::error::DecodeError::Other("invalid block flags"), ))?, color: bincode::Decode::decode(decoder)?, }) } } impl<'de, Context> BorrowDecode<'de, Context> for BlockColor { fn borrow_decode<D: bincode::de::BorrowDecoder<'de, Context = Context>>( decoder: &mut D, ) -> Result<Self, bincode::error::DecodeError> { Ok(BlockColor { flags: BitFlags::from_bits(bincode::BorrowDecode::borrow_decode(decoder)?).or(Err( bincode::error::DecodeError::Other("invalid block flags"), ))?, color: bincode::BorrowDecode::borrow_decode(decoder)?, }) } } /// A block type specification (for use in constants) #[derive(Debug, Clone)] struct ConstBlockType { /// Determines the rendered color of the block type pub block_color: BlockColor, /// Material of a sign block pub sign_material: Option<&'static str>, } /// A block type specification #[derive(Debug, Clone)] pub struct BlockType { /// Determines the rendered color of the block type pub block_color: BlockColor, /// Material of a sign block pub sign_material: Option<String>, } impl From<&ConstBlockType> for BlockType { fn from(value: &ConstBlockType) -> Self { BlockType { block_color: value.block_color, sign_material: value.sign_material.map(String::from), } } } /// Used to look up standard Minecraft block types #[derive(Debug)] pub struct BlockTypes { /// Map of string IDs to block types block_type_map: HashMap<String, BlockType>, /// Array used to look up old numeric block type and subtype values legacy_block_types: Box<[[BlockType; 16]; 256]>, } impl Default for BlockTypes { fn default() -> Self { let block_type_map: HashMap<_, _> = block_types::BLOCK_TYPES .iter() .map(|(k, v)| (String::from(*k), BlockType::from(v))) .collect(); let legacy_block_types = Box::new(legacy_block_types::LEGACY_BLOCK_TYPES.map(|inner| { inner.map(|id| { block_type_map .get(id) .expect("Unknown legacy block type") .clone() }) })); BlockTypes { block_type_map, legacy_block_types, } } } impl BlockTypes { /// Resolves a Minecraft 1.13+ string block type ID #[inline] pub fn get(&self, id: &str) -> Option<&BlockType> { let suffix = id.strip_prefix("minecraft:").unwrap_or(id); self.block_type_map.get(suffix) } /// Resolves a Minecraft pre-1.13 numeric block type ID #[inline] pub fn get_legacy(&self, id: u8, data: u8) -> Option<&BlockType> { Some(&self.legacy_block_types[id as usize][data as usize]) } } pub use block_color::{block_color, needs_biome}; /// Grass color modifier used by a biome #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Encode, Decode)] pub enum BiomeGrassColorModifier { /// Grass color modifier used by the dark forest biome DarkForest, /// Grass color modifier used by swamp biomes Swamp, } /// A biome specification /// /// A Biome contains all information about a biome necessary to compute a block /// color given a block type and depth #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Encode, Decode)] pub struct Biome { /// Temperature value /// /// For more efficient storage, the temperature is stored as an integer /// after mutiplying the raw value by 20 pub temp: i8, /// Downfall value /// /// For more efficient storage, the downfall is stored as an integer /// after mutiplying the raw value by 20 pub downfall: i8, /// Water color override pub water_color: Option<Color>, /// Foliage color override pub foliage_color: Option<Color>, /// Grass color override pub grass_color: Option<Color>, /// Grass color modifier pub grass_color_modifier: Option<BiomeGrassColorModifier>, } impl Biome { /// Constructs a new Biome const fn new(temp: i16, downfall: i16) -> Biome { /// Helper to encode temperature and downfall values /// /// Converts temperatue and downfall from the input format /// (mutiplied by 100) to i8 range for more efficient storage. const fn encode(v: i16) -> i8 { (v / 5) as i8 } Biome { temp: encode(temp), downfall: encode(downfall), grass_color_modifier: None, water_color: None, foliage_color: None, grass_color: None, } } /// Builder function to override the biome water color const fn water(self, water_color: [u8; 3]) -> Biome { Biome { water_color: Some(Color(water_color)), ..self } } /// Builder function to override the biome foliage color const fn foliage(self, foliage_color: [u8; 3]) -> Biome { Biome { foliage_color: Some(Color(foliage_color)), ..self } } /// Builder function to override the biome grass color const fn grass(self, grass_color: [u8; 3]) -> Biome { Biome { grass_color: Some(Color(grass_color)), ..self } } /// Builder function to set a grass color modifier const fn modify(self, grass_color_modifier: BiomeGrassColorModifier) -> Biome { Biome { grass_color_modifier: Some(grass_color_modifier), ..self } } /// Decodes a temperature or downfall value from the storage format to /// f32 for further calculation fn decode(val: i8) -> f32 { f32::from(val) / 20.0 } /// Returns the biome's temperature decoded to its original float value pub fn temp(&self) -> f32 { Self::decode(self.temp) } /// Returns the biome's downfall decoded to its original float value pub fn downfall(&self) -> f32 { Self::decode(self.downfall) } } /// Used to look up standard Minecraft biome types #[derive(Debug)] pub struct BiomeTypes { /// Map of string IDs to biome types biome_map: HashMap<String, &'static Biome>, /// Array used to look up old numeric biome IDs legacy_biomes: Box<[&'static Biome; 256]>, /// Fallback for unknown (new/modded) biomes fallback_biome: &'static Biome, } impl Default for BiomeTypes { fn default() -> Self { let mut biome_map: HashMap<_, _> = biomes::BIOMES .iter() .map(|(k, v)| (String::from(*k), v)) .collect(); for &(old, new) in legacy_biomes::BIOME_ALIASES.iter().rev() { let biome = biome_map .get(new) .copied() .expect("Biome alias for unknown biome"); assert!(biome_map.insert(String::from(old), biome).is_none()); } let legacy_biomes = (0..=255) .map(|index| { let id = legacy_biomes::legacy_biome(index); *biome_map.get(id).expect("Unknown legacy biome") }) .collect::<Box<[_]>>() .try_into() .unwrap(); let fallback_biome = *biome_map.get("plains").expect("Plains biome undefined"); Self { biome_map, legacy_biomes, fallback_biome, } } } impl BiomeTypes { /// Resolves a Minecraft 1.18+ string biome type ID #[inline] pub fn get(&self, id: &str) -> Option<&Biome> { let suffix = id.strip_prefix("minecraft:").unwrap_or(id); self.biome_map.get(suffix).copied() } /// Resolves a Minecraft pre-1.18 numeric biome type ID #[inline] pub fn get_legacy(&self, id: u8) -> Option<&Biome> { Some(self.legacy_biomes[id as usize]) } /// Returns the fallback for unknown (new/modded) biomes #[inline] pub fn get_fallback(&self) -> &Biome { self.fallback_biome } }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/crates/resource/src/block_color.rs
crates/resource/src/block_color.rs
//! Functions for computations of block colors use super::{Biome, BlockColor, Color, Colorf}; /// Converts an u8 RGB color to a float vector fn color_vec_unscaled(color: Color) -> Colorf { Colorf::from_array(color.0.map(f32::from)) } /// Converts an u8 RGB color to a float vector, scaling the components to 0.0..1.0 fn color_vec(color: Color) -> Colorf { color_vec_unscaled(color) / 255.0 } /// Helper for grass and foliage colors /// /// Biome temperature and downfall are modified based on the depth value /// before using them to compute the final color fn color_from_params(colors: &[Colorf; 3], biome: &Biome, depth: f32) -> Colorf { let temp = (biome.temp() - f32::max((depth - 64.0) / 600.0, 0.0)).clamp(0.0, 1.0); let downfall = biome.downfall().clamp(0.0, 1.0) * temp; colors[0] + temp * colors[1] + downfall * colors[2] } /// Extension trait with helpers for computing biome-specific block colors trait BiomeExt { /// Returns the grass color of the biome at a given depth fn grass_color(&self, depth: f32) -> Colorf; /// Returns the foliage color of the biome at a given depth fn foliage_color(&self, depth: f32) -> Colorf; /// Returns the water color of the biome fn water_color(&self) -> Colorf; } impl BiomeExt for Biome { fn grass_color(&self, depth: f32) -> Colorf { use super::BiomeGrassColorModifier::*; /// Color matrix extracted from grass color texture const GRASS_COLORS: [Colorf; 3] = [ Colorf::new(0.502, 0.706, 0.592), // lower right Colorf::new(0.247, 0.012, -0.259), // lower left - lower right Colorf::new(-0.471, 0.086, -0.133), // upper left - lower left ]; /// Used for dark forst grass color modifier const DARK_FOREST_GRASS_COLOR: Colorf = Colorf::new(0.157, 0.204, 0.039); // == color_vec(Color([40, 52, 10])) /// Grass color in swamp biomes const SWAMP_GRASS_COLOR: Colorf = Colorf::new(0.416, 0.439, 0.224); // == color_vec(Color([106, 112, 57])) let regular_color = || { self.grass_color .map(color_vec) .unwrap_or_else(|| color_from_params(&GRASS_COLORS, self, depth)) }; match self.grass_color_modifier { Some(DarkForest) => 0.5 * (regular_color() + DARK_FOREST_GRASS_COLOR), Some(Swamp) => SWAMP_GRASS_COLOR, None => regular_color(), } } fn foliage_color(&self, depth: f32) -> Colorf { /// Color matrix extracted from foliage color texture const FOLIAGE_COLORS: [Colorf; 3] = [ Colorf::new(0.376, 0.631, 0.482), // lower right Colorf::new(0.306, 0.012, -0.317), // lower left - lower right Colorf::new(-0.580, 0.106, -0.165), // upper left - lower left ]; self.foliage_color .map(color_vec) .unwrap_or_else(|| color_from_params(&FOLIAGE_COLORS, self, depth)) } fn water_color(&self) -> Colorf { /// Default biome water color /// /// Used for biomes that don't explicitly set a water color const DEFAULT_WATER_COLOR: Colorf = Colorf::new(0.247, 0.463, 0.894); // == color_vec(Color([63, 118, 228])) self.water_color .map(color_vec) .unwrap_or(DEFAULT_WATER_COLOR) } } /// Color multiplier for birch leaves const BIRCH_COLOR: Colorf = Colorf::new(0.502, 0.655, 0.333); // == color_vec(Color([128, 167, 85])) /// Color multiplier for spruce leaves const EVERGREEN_COLOR: Colorf = Colorf::new(0.380, 0.600, 0.380); // == color_vec(Color([97, 153, 97])) /// Determined if calling [block_color] for a given [BlockColor] needs biome information pub fn needs_biome(block: BlockColor) -> bool { use super::BlockFlag::*; block.is(Grass) || block.is(Foliage) || block.is(Water) } /// Determined the block color to display for a given [BlockColor] /// /// [needs_biome] must be used to determine whether passing a [Biome] is necessary. /// Will panic if a [Biome] is necessary, but none is passed. pub fn block_color(block: BlockColor, biome: Option<&Biome>, depth: f32) -> Colorf { use super::BlockFlag::*; let get_biome = || biome.expect("needs biome to determine block color"); let mut color = color_vec_unscaled(block.color); if block.is(Grass) { color *= get_biome().grass_color(depth); } if block.is(Foliage) { color *= get_biome().foliage_color(depth); } if block.is(Birch) { color *= BIRCH_COLOR; } if block.is(Spruce) { color *= EVERGREEN_COLOR; } if block.is(Water) { color *= get_biome().water_color(); } color * (0.5 + 0.005 * depth) }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/crates/resource/src/block_types.rs
crates/resource/src/block_types.rs
//! Block type information //! //! This file is generated using resource/generate.py, do not edit use enumflags2::make_bitflags; use super::*; /// List if known block types and their properties pub const BLOCK_TYPES: &[(&str, ConstBlockType)] = &[ ( "acacia_button", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "acacia_door", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([167, 95, 60]), }, sign_material: None, }, ), ( "acacia_fence", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([168, 90, 50]), }, sign_material: None, }, ), ( "acacia_fence_gate", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([168, 90, 50]), }, sign_material: None, }, ), ( "acacia_hanging_sign", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: Some("acacia"), }, ), ( "acacia_leaves", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque|Foliage}), color: Color([149, 148, 148]), }, sign_material: None, }, ), ( "acacia_log", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([150, 88, 55]), }, sign_material: None, }, ), ( "acacia_planks", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([168, 90, 50]), }, sign_material: None, }, ), ( "acacia_pressure_plate", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([168, 90, 50]), }, sign_material: None, }, ), ( "acacia_sapling", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([118, 117, 23]), }, sign_material: None, }, ), ( "acacia_shelf", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "acacia_sign", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: Some("acacia"), }, ), ( "acacia_slab", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([168, 90, 50]), }, sign_material: None, }, ), ( "acacia_stairs", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([168, 90, 50]), }, sign_material: None, }, ), ( "acacia_trapdoor", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([156, 87, 51]), }, sign_material: None, }, ), ( "acacia_wall_hanging_sign", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{WallSign}), color: Color([0, 0, 0]), }, sign_material: Some("acacia"), }, ), ( "acacia_wall_sign", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{WallSign}), color: Color([0, 0, 0]), }, sign_material: Some("acacia"), }, ), ( "acacia_wood", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([103, 96, 86]), }, sign_material: None, }, ), ( "activator_rail", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([115, 87, 74]), }, sign_material: None, }, ), ( "air", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "allium", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "amethyst_block", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([133, 97, 191]), }, sign_material: None, }, ), ( "amethyst_cluster", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([163, 126, 207]), }, sign_material: None, }, ), ( "ancient_debris", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([94, 66, 58]), }, sign_material: None, }, ), ( "andesite", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([136, 136, 136]), }, sign_material: None, }, ), ( "andesite_slab", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([136, 136, 136]), }, sign_material: None, }, ), ( "andesite_stairs", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([136, 136, 136]), }, sign_material: None, }, ), ( "andesite_wall", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([136, 136, 136]), }, sign_material: None, }, ), ( "anvil", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([72, 72, 72]), }, sign_material: None, }, ), ( "attached_melon_stem", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque|Grass}), color: Color([141, 142, 141]), }, sign_material: None, }, ), ( "attached_pumpkin_stem", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque|Grass}), color: Color([139, 139, 139]), }, sign_material: None, }, ), ( "azalea", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([101, 124, 47]), }, sign_material: None, }, ), ( "azalea_leaves", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([90, 114, 44]), }, sign_material: None, }, ), ( "azure_bluet", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "bamboo", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([93, 144, 19]), }, sign_material: None, }, ), ( "bamboo_block", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([139, 141, 62]), }, sign_material: None, }, ), ( "bamboo_button", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "bamboo_door", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([191, 171, 81]), }, sign_material: None, }, ), ( "bamboo_fence", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([193, 173, 80]), }, sign_material: None, }, ), ( "bamboo_fence_gate", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([193, 173, 80]), }, sign_material: None, }, ), ( "bamboo_hanging_sign", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: Some("bamboo"), }, ), ( "bamboo_mosaic", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([190, 170, 78]), }, sign_material: None, }, ), ( "bamboo_mosaic_slab", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([190, 170, 78]), }, sign_material: None, }, ), ( "bamboo_mosaic_stairs", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([190, 170, 78]), }, sign_material: None, }, ), ( "bamboo_planks", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([193, 173, 80]), }, sign_material: None, }, ), ( "bamboo_pressure_plate", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([193, 173, 80]), }, sign_material: None, }, ), ( "bamboo_sapling", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "bamboo_shelf", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "bamboo_sign", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: Some("bamboo"), }, ), ( "bamboo_slab", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([193, 173, 80]), }, sign_material: None, }, ), ( "bamboo_stairs", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([193, 173, 80]), }, sign_material: None, }, ), ( "bamboo_trapdoor", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([198, 179, 85]), }, sign_material: None, }, ), ( "bamboo_wall_hanging_sign", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{WallSign}), color: Color([0, 0, 0]), }, sign_material: Some("bamboo"), }, ), ( "bamboo_wall_sign", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{WallSign}), color: Color([0, 0, 0]), }, sign_material: Some("bamboo"), }, ), ( "barrel", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([134, 100, 58]), }, sign_material: None, }, ), ( "barrier", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "basalt", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([80, 81, 86]), }, sign_material: None, }, ), ( "beacon", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([117, 220, 215]), }, sign_material: None, }, ), ( "bedrock", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([85, 85, 85]), }, sign_material: None, }, ), ( "bee_nest", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([202, 160, 74]), }, sign_material: None, }, ), ( "beehive", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([180, 146, 90]), }, sign_material: None, }, ), ( "beetroots", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([93, 91, 30]), }, sign_material: None, }, ), ( "bell", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([253, 235, 110]), }, sign_material: None, }, ), ( "big_dripleaf", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([111, 141, 51]), }, sign_material: None, }, ), ( "big_dripleaf_stem", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "birch_button", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "birch_door", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([220, 209, 176]), }, sign_material: None, }, ), ( "birch_fence", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([192, 175, 121]), }, sign_material: None, }, ), ( "birch_fence_gate", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([192, 175, 121]), }, sign_material: None, }, ), ( "birch_hanging_sign", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: Some("birch"), }, ), ( "birch_leaves", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque|Birch}), color: Color([130, 129, 130]), }, sign_material: None, }, ), ( "birch_log", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([193, 179, 135]), }, sign_material: None, }, ), ( "birch_planks", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([192, 175, 121]), }, sign_material: None, }, ), ( "birch_pressure_plate", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([192, 175, 121]), }, sign_material: None, }, ), ( "birch_sapling", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([127, 160, 79]), }, sign_material: None, }, ), ( "birch_shelf", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "birch_sign", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: Some("birch"), }, ), ( "birch_slab", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([192, 175, 121]), }, sign_material: None, }, ), ( "birch_stairs", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([192, 175, 121]), }, sign_material: None, }, ), ( "birch_trapdoor", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([207, 194, 157]), }, sign_material: None, }, ), ( "birch_wall_hanging_sign", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{WallSign}), color: Color([0, 0, 0]), }, sign_material: Some("birch"), }, ), ( "birch_wall_sign", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{WallSign}), color: Color([0, 0, 0]), }, sign_material: Some("birch"), }, ), ( "birch_wood", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([216, 215, 210]), }, sign_material: None, }, ), ( "black_banner", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "black_bed", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "black_candle", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "black_candle_cake", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([248, 222, 214]), }, sign_material: None, }, ), ( "black_carpet", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([20, 21, 25]), }, sign_material: None, }, ), ( "black_concrete", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([8, 10, 15]), }, sign_material: None, }, ), ( "black_concrete_powder", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([25, 26, 31]), }, sign_material: None, }, ), ( "black_glazed_terracotta", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([67, 30, 32]), }, sign_material: None, }, ), ( "black_shulker_box", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([25, 25, 29]), }, sign_material: None, }, ), ( "black_stained_glass", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([25, 25, 25]), }, sign_material: None, }, ), ( "black_stained_glass_pane", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([24, 24, 24]), }, sign_material: None, }, ), ( "black_terracotta", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([37, 22, 16]), }, sign_material: None, }, ), ( "black_wall_banner", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "black_wool", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([20, 21, 25]), }, sign_material: None, }, ), ( "blackstone", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([42, 36, 41]), }, sign_material: None, }, ), ( "blackstone_slab", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([42, 36, 41]), }, sign_material: None, }, ), ( "blackstone_stairs", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([42, 36, 41]), }, sign_material: None, }, ), ( "blackstone_wall", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([42, 36, 41]), }, sign_material: None, }, ), ( "blast_furnace", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([80, 80, 81]), }, sign_material: None, }, ), ( "blue_banner", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "blue_bed", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "blue_candle", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "blue_candle_cake", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([248, 222, 214]), }, sign_material: None, }, ), ( "blue_carpet", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([53, 57, 157]), }, sign_material: None, }, ), ( "blue_concrete", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([44, 46, 143]), }, sign_material: None, }, ), ( "blue_concrete_powder", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([70, 73, 166]), }, sign_material: None, }, ), ( "blue_glazed_terracotta", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([47, 64, 139]), }, sign_material: None, }, ), ( "blue_ice", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([116, 167, 253]), }, sign_material: None, }, ), ( "blue_orchid", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "blue_shulker_box", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([43, 45, 140]), }, sign_material: None, }, ), ( "blue_stained_glass", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([51, 76, 178]), }, sign_material: None, }, ), ( "blue_stained_glass_pane", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([48, 73, 171]), }, sign_material: None, }, ), ( "blue_terracotta", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([74, 59, 91]), }, sign_material: None, }, ), ( "blue_wall_banner", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "blue_wool", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([53, 57, 157]), }, sign_material: None, }, ), ( "bone_block", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([209, 206, 179]), }, sign_material: None, }, ), ( "bookshelf", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([162, 130, 78]), }, sign_material: None, }, ), ( "brain_coral", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "brain_coral_block", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([207, 91, 159]), }, sign_material: None, }, ), ( "brain_coral_fan", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "brain_coral_wall_fan", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "brewing_stand", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([122, 100, 80]), }, sign_material: None, }, ), ( "brick_slab", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([150, 97, 83]), }, sign_material: None, }, ), ( "brick_stairs", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([150, 97, 83]), }, sign_material: None, }, ), ( "brick_wall", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([150, 97, 83]), }, sign_material: None, }, ), ( "bricks", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([150, 97, 83]), }, sign_material: None, }, ), ( "brown_banner", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "brown_bed", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "brown_candle", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "brown_candle_cake", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([248, 222, 214]), }, sign_material: None, }, ), ( "brown_carpet", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([114, 71, 40]), }, sign_material: None, }, ), ( "brown_concrete", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([96, 59, 31]), }, sign_material: None, }, ), ( "brown_concrete_powder", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([125, 84, 53]), }, sign_material: None, }, ), ( "brown_glazed_terracotta", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([119, 106, 85]), }, sign_material: None, }, ), ( "brown_mushroom", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "brown_mushroom_block", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([149, 111, 81]), }, sign_material: None, }, ), ( "brown_shulker_box", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([106, 66, 35]), }, sign_material: None, }, ), ( "brown_stained_glass", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([102, 76, 51]), }, sign_material: None, }, ), ( "brown_stained_glass_pane", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([97, 73, 48]), }, sign_material: None, }, ), ( "brown_terracotta", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([77, 51, 35]), }, sign_material: None, }, ), ( "brown_wall_banner", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "brown_wool", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([114, 71, 40]), }, sign_material: None, }, ), ( "bubble_column", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque|Water}), color: Color([177, 177, 177]), }, sign_material: None, }, ), ( "bubble_coral", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "bubble_coral_block", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([165, 26, 162]), }, sign_material: None, }, ), ( "bubble_coral_fan", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "bubble_coral_wall_fan", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "budding_amethyst", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([132, 96, 186]), }, sign_material: None, }, ), ( "bush", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque|Grass}), color: Color([119, 120, 119]), }, sign_material: None, }, ), ( "cactus", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([85, 127, 43]), }, sign_material: None, }, ), ( "cactus_flower", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([209, 120, 135]), }, sign_material: None, }, ), ( "cake", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([248, 222, 214]), }, sign_material: None, }, ), ( "calcite", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([223, 224, 220]), }, sign_material: None, }, ), ( "calibrated_sculk_sensor", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([27, 79, 100]), }, sign_material: None, }, ), ( "campfire", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([110, 88, 54]), }, sign_material: None, }, ), ( "candle", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "candle_cake", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([248, 222, 214]), }, sign_material: None, }, ), ( "carrots", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([81, 124, 37]), }, sign_material: None, }, ), ( "cartography_table", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([103, 87, 67]), }, sign_material: None, }, ), ( "carved_pumpkin", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([198, 118, 24]), }, sign_material: None, }, ), ( "cauldron", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([73, 72, 74]), }, sign_material: None, }, ), ( "cave_air", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "cave_vines", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([90, 109, 40]), }, sign_material: None, }, ), ( "cave_vines_plant", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([88, 101, 38]), }, sign_material: None, }, ), ( "chain", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "chain_command_block", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([131, 161, 147]), }, sign_material: None, }, ), ( "cherry_button", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{}), color: Color([0, 0, 0]), }, sign_material: None, }, ), ( "cherry_door", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([223, 170, 164]), }, sign_material: None, }, ), ( "cherry_fence", ConstBlockType { block_color: BlockColor { flags: make_bitflags!(BlockFlag::{Opaque}), color: Color([226, 178, 172]), },
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
true
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/crates/resource/src/biomes.rs
crates/resource/src/biomes.rs
//! Biome data //! //! This file is generated using resource/biomes.py, do not edit use super::*; use BiomeGrassColorModifier::*; /// List if known biomes and their properties pub const BIOMES: &[(&str, Biome)] = &[ ( "badlands", Biome::new(200, 0) .foliage([158, 129, 77]) .grass([144, 129, 77]), ), ("bamboo_jungle", Biome::new(95, 90)), ("basalt_deltas", Biome::new(200, 0)), ("beach", Biome::new(80, 40)), ("birch_forest", Biome::new(60, 60)), ( "cherry_grove", Biome::new(50, 80) .foliage([182, 219, 97]) .grass([182, 219, 97]) .water([93, 183, 239]), ), ("cold_ocean", Biome::new(50, 50).water([61, 87, 214])), ("crimson_forest", Biome::new(200, 0)), ("dark_forest", Biome::new(70, 80).modify(DarkForest)), ("deep_cold_ocean", Biome::new(50, 50).water([61, 87, 214])), ("deep_dark", Biome::new(80, 40)), ("deep_frozen_ocean", Biome::new(50, 50).water([57, 56, 201])), ( "deep_lukewarm_ocean", Biome::new(50, 50).water([69, 173, 242]), ), ("deep_ocean", Biome::new(50, 50)), ("desert", Biome::new(200, 0)), ("dripstone_caves", Biome::new(80, 40)), ("end_barrens", Biome::new(50, 50)), ("end_highlands", Biome::new(50, 50)), ("end_midlands", Biome::new(50, 50)), ( "eroded_badlands", Biome::new(200, 0) .foliage([158, 129, 77]) .grass([144, 129, 77]), ), ("flower_forest", Biome::new(70, 80)), ("forest", Biome::new(70, 80)), ("frozen_ocean", Biome::new(0, 50).water([57, 56, 201])), ("frozen_peaks", Biome::new(-70, 90)), ("frozen_river", Biome::new(0, 50).water([57, 56, 201])), ("grove", Biome::new(-20, 80)), ("ice_spikes", Biome::new(0, 50)), ("jagged_peaks", Biome::new(-70, 90)), ("jungle", Biome::new(95, 90)), ("lukewarm_ocean", Biome::new(50, 50).water([69, 173, 242])), ("lush_caves", Biome::new(50, 50)), ( "mangrove_swamp", Biome::new(80, 90) .foliage([141, 177, 39]) .modify(Swamp) .water([58, 122, 106]), ), ("meadow", Biome::new(50, 80).water([14, 78, 207])), ("mushroom_fields", Biome::new(90, 100)), ("nether_wastes", Biome::new(200, 0)), ("ocean", Biome::new(50, 50)), ("old_growth_birch_forest", Biome::new(60, 60)), ("old_growth_pine_taiga", Biome::new(30, 80)), ("old_growth_spruce_taiga", Biome::new(25, 80)), ( "pale_garden", Biome::new(70, 80) .foliage([135, 141, 118]) .grass([119, 130, 114]) .water([118, 136, 157]), ), ("plains", Biome::new(80, 40)), ("river", Biome::new(50, 50)), ("savanna", Biome::new(200, 0)), ("savanna_plateau", Biome::new(200, 0)), ("small_end_islands", Biome::new(50, 50)), ("snowy_beach", Biome::new(5, 30).water([61, 87, 214])), ("snowy_plains", Biome::new(0, 50)), ("snowy_slopes", Biome::new(-30, 90)), ("snowy_taiga", Biome::new(-50, 40).water([61, 87, 214])), ("soul_sand_valley", Biome::new(200, 0)), ("sparse_jungle", Biome::new(95, 80)), ("stony_peaks", Biome::new(100, 30)), ("stony_shore", Biome::new(20, 30)), ("sunflower_plains", Biome::new(80, 40)), ( "swamp", Biome::new(80, 90) .foliage([106, 112, 57]) .modify(Swamp) .water([97, 123, 100]), ), ("taiga", Biome::new(25, 80)), ("the_end", Biome::new(50, 50)), ("the_void", Biome::new(50, 50)), ("warm_ocean", Biome::new(50, 50).water([67, 213, 238])), ("warped_forest", Biome::new(200, 0)), ("windswept_forest", Biome::new(20, 30)), ("windswept_gravelly_hills", Biome::new(20, 30)), ("windswept_hills", Biome::new(20, 30)), ("windswept_savanna", Biome::new(200, 0)), ( "wooded_badlands", Biome::new(200, 0) .foliage([158, 129, 77]) .grass([144, 129, 77]), ), ];
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/crates/resource/src/legacy_block_types.rs
crates/resource/src/legacy_block_types.rs
//! Mapping of old numeric block type and damage/subtype IDs to new string IDs /// Helper for block types that don't use the damage/subtype data const fn simple(id: &str) -> [&str; 16] { [ id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, id, ] } /// Default block type for unassigned numeric IDs const DEF: &str = "air"; /// Default entry for block type numbers that are unassigned regardless of subtype const EMPTY: [&str; 16] = simple(DEF); /// Mapping from each numeric block type and damage/subtype ID to new string ID #[allow(clippy::large_const_arrays)] pub const LEGACY_BLOCK_TYPES: [[&str; 16]; 256] = [ /* 0 */ simple("air"), /* 1 */ [ "stone", "granite", "polished_granite", "diorite", "polished_diorite", "andesite", "polished_andesite", DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, ], /* 2 */ simple("grass_block"), /* 3 */ [ "dirt", "coarse_dirt", "podzol", DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, ], /* 4 */ simple("cobblestone"), /* 5 */ [ "oak_planks", "spruce_planks", "birch_planks", "jungle_planks", "acacia_planks", "dark_oak_planks", DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, ], /* 6 */ [ "oak_sapling", "spruce_sapling", "birch_sapling", "jungle_sapling", "acacia_sapling", "dark_oak_sapling", DEF, DEF, "oak_sapling", "spruce_sapling", "birch_sapling", "jungle_sapling", "acacia_sapling", "dark_oak_sapling", DEF, DEF, ], /* 7 */ simple("bedrock"), /* 8 */ simple("water"), /* 9 */ simple("water"), /* 10 */ simple("lava"), /* 11 */ simple("lava"), /* 12 */ [ "sand", "red_sand", DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, ], /* 13 */ simple("gravel"), /* 14 */ simple("gold_ore"), /* 15 */ simple("iron_ore"), /* 16 */ simple("coal_ore"), /* 17 */ [ "oak_log", "spruce_log", "birch_log", "jungle_log", "oak_log", "spruce_log", "birch_log", "jungle_log", "oak_log", "spruce_log", "birch_log", "jungle_log", "oak_log", "spruce_log", "birch_log", "jungle_log", ], /* 18 */ [ "oak_leaves", "spruce_leaves", "birch_leaves", "jungle_leaves", "oak_leaves", "spruce_leaves", "birch_leaves", "jungle_leaves", "oak_leaves", "spruce_leaves", "birch_leaves", "jungle_leaves", "oak_leaves", "spruce_leaves", "birch_leaves", "jungle_leaves", ], /* 19 */ simple("sponge"), /* 20 */ simple("glass"), /* 21 */ simple("lapis_ore"), /* 22 */ simple("lapis_block"), /* 23 */ simple("dispenser"), /* 24 */ simple("sandstone"), /* 25 */ simple("note_block"), /* 26 */ EMPTY, // bed /* 27 */ simple("powered_rail"), /* 28 */ simple("detector_rail"), /* 29 */ simple("sticky_piston"), /* 30 */ simple("cobweb"), /* 31 */ [ "grass", "fern", DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, ], /* 32 */ simple("dead_bush"), /* 33 */ simple("piston"), /* 34 */ simple("piston_head"), /* 35 */ [ "white_wool", "orange_wool", "magenta_wool", "light_blue_wool", "yellow_wool", "lime_wool", "pink_wool", "gray_wool", "light_gray_wool", "cyan_wool", "purple_wool", "blue_wool", "brown_wool", "green_wool", "red_wool", "black_wool", ], /* 36 */ simple("moving_piston"), /* 37 */ simple("dandelion"), /* 38 */ [ "poppy", "blue_orchid", "allium", "azure_bluet", "red_tulip", "orange_tulip", "white_tulip", "pink_tulip", "oxeye_daisy", DEF, DEF, DEF, DEF, DEF, DEF, DEF, ], /* 39 */ simple("brown_mushroom"), /* 40 */ simple("red_mushroom"), /* 41 */ simple("gold_block"), /* 42 */ simple("iron_block"), /* 43 */ [ "smooth_stone_slab", "sandstone_slab", "oak_slab", "cobblestone_slab", "brick_slab", "stone_brick_slab", "nether_brick_slab", "quartz_slab", DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, ], /* 44 */ [ "smooth_stone_slab", "sandstone_slab", "oak_slab", "cobblestone_slab", "brick_slab", "stone_brick_slab", "nether_brick_slab", "quartz_slab", "stone_slab", "sandstone_slab", "oak_slab", "cobblestone_slab", "brick_slab", "stone_brick_slab", "nether_brick_slab", "quartz_slab", ], /* 45 */ simple("bricks"), /* 46 */ simple("tnt"), /* 47 */ simple("bookshelf"), /* 48 */ simple("mossy_cobblestone"), /* 49 */ simple("obsidian"), /* 50 */ [ DEF, "wall_torch", "wall_torch", "wall_torch", "wall_torch", "torch", DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, ], /* 51 */ simple("fire"), /* 52 */ simple("spawner"), /* 53 */ simple("oak_stairs"), /* 54 */ simple("chest"), /* 55 */ simple("redstone_wire"), /* 56 */ simple("diamond_ore"), /* 57 */ simple("diamond_block"), /* 58 */ simple("crafting_table"), /* 59 */ simple("wheat"), /* 60 */ simple("farmland"), /* 61 */ simple("furnace"), /* 62 */ simple("furnace"), /* 63 */ simple("sign"), /* 64 */ simple("oak_door"), /* 65 */ simple("ladder"), /* 66 */ simple("rail"), /* 67 */ simple("cobblestone_stairs"), /* 68 */ simple("wall_sign"), /* 69 */ simple("lever"), /* 70 */ simple("stone_pressure_plate"), /* 71 */ simple("iron_door"), /* 72 */ simple("oak_pressure_plate"), /* 73 */ simple("redstone_ore"), /* 74 */ simple("redstone_ore"), /* 75 */ [ DEF, "redstone_wall_torch", "redstone_wall_torch", "redstone_wall_torch", "redstone_wall_torch", "redstone_torch", DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, ], /* 76 */ [ DEF, "redstone_wall_torch", "redstone_wall_torch", "redstone_wall_torch", "redstone_wall_torch", "redstone_torch", DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, ], /* 77 */ simple("stone_button"), /* 78 */ simple("snow"), /* 79 */ simple("ice"), /* 80 */ simple("snow_block"), /* 81 */ simple("cactus"), /* 82 */ simple("clay"), /* 83 */ simple("sugar_cane"), /* 84 */ simple("jukebox"), /* 85 */ simple("oak_fence"), /* 86 */ simple("pumpkin"), /* 87 */ simple("netherrack"), /* 88 */ simple("soul_sand"), /* 89 */ simple("glowstone"), /* 90 */ simple("nether_portal"), /* 91 */ simple("pumpkin"), /* 92 */ simple("cake"), /* 93 */ simple("repeater"), /* 94 */ simple("repeater"), /* 95 */ [ "white_stained_glass", "orange_stained_glass", "magenta_stained_glass", "light_blue_stained_glass", "yellow_stained_glass", "lime_stained_glass", "pink_stained_glass", "gray_stained_glass", "light_gray_stained_glass", "cyan_stained_glass", "purple_stained_glass", "blue_stained_glass", "brown_stained_glass", "green_stained_glass", "red_stained_glass", "black_stained_glass", ], /* 96 */ simple("oak_trapdoor"), /* 97 */ [ "infested_stone", "infested_cobblestone", "infested_stone_bricks", "infested_mossy_stone_bricks", "infested_cracked_stone_bricks", "infested_chiseled_stone_bricks", DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, ], /* 98 */ [ "stone_bricks", "mossy_stone_bricks", "cracked_stone_bricks", "chiseled_stone_bricks", DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, ], /* 99 */ simple("brown_mushroom_block"), /* 100 */ simple("red_mushroom_block"), /* 101 */ simple("iron_bars"), /* 102 */ simple("glass_pane"), /* 103 */ simple("melon"), /* 104 */ simple("pumpkin_stem"), /* 105 */ simple("melon_stem"), /* 106 */ simple("vine"), /* 107 */ simple("oak_fence_gate"), /* 108 */ simple("brick_stairs"), /* 109 */ simple("stone_brick_stairs"), /* 110 */ simple("mycelium"), /* 111 */ simple("lily_pad"), /* 112 */ simple("nether_bricks"), /* 113 */ simple("nether_brick_fence"), /* 114 */ simple("nether_brick_stairs"), /* 115 */ simple("nether_wart"), /* 116 */ simple("enchanting_table"), /* 117 */ simple("brewing_stand"), /* 118 */ simple("cauldron"), /* 119 */ simple("end_portal"), /* 120 */ simple("end_portal_frame"), /* 121 */ simple("end_stone"), /* 122 */ simple("dragon_egg"), /* 123 */ simple("redstone_lamp"), /* 124 */ simple("redstone_lamp"), /* 125 */ [ "oak_slab", "spruce_slab", "birch_slab", "jungle_slab", "acacia_slab", "dark_oak_slab", DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, ], /* 126 */ [ "oak_slab", "spruce_slab", "birch_slab", "jungle_slab", "acacia_slab", "dark_oak_slab", DEF, DEF, "oak_slab", "spruce_slab", "birch_slab", "jungle_slab", "acacia_slab", "dark_oak_slab", DEF, DEF, ], /* 127 */ simple("cocoa"), /* 128 */ simple("sandstone_stairs"), /* 129 */ simple("emerald_ore"), /* 130 */ simple("ender_chest"), /* 131 */ simple("tripwire_hook"), /* 132 */ simple("tripwire"), /* 133 */ simple("emerald_block"), /* 134 */ simple("spruce_stairs"), /* 135 */ simple("birch_stairs"), /* 136 */ simple("jungle_stairs"), /* 137 */ simple("command_block"), /* 138 */ simple("beacon"), /* 139 */ [ "cobblestone_wall", "mossy_cobblestone_wall", DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, ], /* 140 */ simple("flower_pot"), /* 141 */ simple("carrots"), /* 142 */ simple("potatoes"), /* 143 */ EMPTY, /* 144 */ EMPTY, /* 145 */ [ "anvil", "anvil", "anvil", "anvil", "chipped_anvil", "chipped_anvil", "chipped_anvil", "chipped_anvil", "damaged_anvil", "damaged_anvil", "damaged_anvil", "damaged_anvil", DEF, DEF, DEF, DEF, ], /* 146 */ simple("trapped_chest"), /* 147 */ simple("light_weighted_pressure_plate"), /* 148 */ simple("heavy_weighted_pressure_plate"), /* 149 */ simple("comparator"), /* 150 */ simple("comparator"), /* 151 */ simple("daylight_detector"), /* 152 */ simple("redstone_block"), /* 153 */ simple("nether_quartz_ore"), /* 154 */ simple("hopper"), /* 155 */ simple("quartz_block"), /* 156 */ simple("quartz_stairs"), /* 157 */ simple("activator_rail"), /* 158 */ simple("dropper"), /* 159 */ [ "white_terracotta", "orange_terracotta", "magenta_terracotta", "light_blue_terracotta", "yellow_terracotta", "lime_terracotta", "pink_terracotta", "gray_terracotta", "light_gray_terracotta", "cyan_terracotta", "purple_terracotta", "blue_terracotta", "brown_terracotta", "green_terracotta", "red_terracotta", "black_terracotta", ], /* 160 */ [ "white_stained_glass_pane", "orange_stained_glass_pane", "magenta_stained_glass_pane", "light_blue_stained_glass_pane", "yellow_stained_glass_pane", "lime_stained_glass_pane", "pink_stained_glass_pane", "gray_stained_glass_pane", "light_gray_stained_glass_pane", "cyan_stained_glass_pane", "purple_stained_glass_pane", "blue_stained_glass_pane", "brown_stained_glass_pane", "green_stained_glass_pane", "red_stained_glass_pane", "black_stained_glass_pane", ], /* 161 */ [ "acacia_leaves", "dark_oak_leaves", DEF, DEF, "acacia_leaves", "dark_oak_leaves", DEF, DEF, "acacia_leaves", "dark_oak_leaves", DEF, DEF, "acacia_leaves", "dark_oak_leaves", DEF, DEF, ], /* 162 */ [ "acacia_log", "dark_oak_log", DEF, DEF, "acacia_log", "dark_oak_log", DEF, DEF, "acacia_log", "dark_oak_log", DEF, DEF, "acacia_log", "dark_oak_log", DEF, DEF, ], /* 163 */ simple("acacia_stairs"), /* 164 */ simple("dark_oak_stairs"), /* 165 */ simple("slime_block"), /* 166 */ simple("barrier"), /* 167 */ simple("iron_trapdoor"), /* 168 */ [ "prismarine", "prismarine_bricks", "dark_prismarine", DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, ], /* 169 */ simple("sea_lantern"), /* 170 */ simple("hay_block"), /* 171 */ [ "white_carpet", "orange_carpet", "magenta_carpet", "light_blue_carpet", "yellow_carpet", "lime_carpet", "pink_carpet", "gray_carpet", "light_gray_carpet", "cyan_carpet", "purple_carpet", "blue_carpet", "brown_carpet", "green_carpet", "red_carpet", "black_carpet", ], /* 172 */ simple("terracotta"), /* 173 */ simple("coal_block"), /* 174 */ simple("packed_ice"), /* 175 */ [ "sunflower", "lilac", "tall_grass", "large_fern", "rose_bush", "peony", DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, DEF, ], /* 176 */ EMPTY, // banner /* 177 */ EMPTY, // wall banner /* 178 */ simple("daylight_detector"), /* 179 */ simple("red_sandstone"), /* 180 */ simple("red_sandstone_stairs"), /* 181 */ simple("red_sandstone_slab"), /* 182 */ simple("red_sandstone_slab"), /* 183 */ simple("spruce_fence_gate"), /* 184 */ simple("birch_fence_gate"), /* 185 */ simple("jungle_fence_gate"), /* 186 */ simple("dark_oak_fence_gate"), /* 187 */ simple("acacia_fence_gate"), /* 188 */ simple("spruce_fence"), /* 189 */ simple("birch_fence"), /* 190 */ simple("jungle_fence"), /* 191 */ simple("dark_oak_fence"), /* 192 */ simple("acacia_fence"), /* 193 */ simple("spruce_door"), /* 194 */ simple("birch_door"), /* 195 */ simple("jungle_door"), /* 196 */ simple("acacia_door"), /* 197 */ simple("dark_oak_door"), /* 198 */ simple("end_rod"), /* 199 */ simple("chorus_plant"), /* 200 */ simple("chorus_flower"), /* 201 */ simple("purpur_block"), /* 202 */ simple("purpur_pillar"), /* 203 */ simple("purpur_stairs"), /* 204 */ simple("purpur_slab"), /* 205 */ simple("purpur_slab"), /* 206 */ simple("end_stone_bricks"), /* 207 */ simple("beetroots"), /* 208 */ simple("grass_path"), /* 209 */ simple("end_gateway"), /* 210 */ simple("repeating_command_block"), /* 211 */ simple("chain_command_block"), /* 212 */ simple("frosted_ice"), /* 213 */ simple("magma_block"), /* 214 */ simple("nether_wart_block"), /* 215 */ simple("red_nether_bricks"), /* 216 */ simple("bone_block"), /* 217 */ simple("structure_void"), /* 218 */ simple("observer"), /* 219 */ simple("white_shulker_box"), /* 220 */ simple("orange_shulker_box"), /* 221 */ simple("magenta_shulker_box"), /* 222 */ simple("light_blue_shulker_box"), /* 223 */ simple("yellow_shulker_box"), /* 224 */ simple("lime_shulker_box"), /* 225 */ simple("pink_shulker_box"), /* 226 */ simple("gray_shulker_box"), /* 227 */ simple("light_gray_shulker_box"), /* 228 */ simple("cyan_shulker_box"), /* 229 */ simple("purple_shulker_box"), /* 230 */ simple("blue_shulker_box"), /* 231 */ simple("brown_shulker_box"), /* 232 */ simple("green_shulker_box"), /* 233 */ simple("red_shulker_box"), /* 234 */ simple("black_shulker_box"), /* 235 */ simple("white_glazed_terracotta"), /* 236 */ simple("orange_glazed_terracotta"), /* 237 */ simple("magenta_glazed_terracotta"), /* 238 */ simple("light_blue_glazed_terracotta"), /* 239 */ simple("yellow_glazed_terracotta"), /* 240 */ simple("lime_glazed_terracotta"), /* 241 */ simple("pink_glazed_terracotta"), /* 242 */ simple("gray_glazed_terracotta"), /* 243 */ simple("light_gray_glazed_terracotta"), /* 244 */ simple("cyan_glazed_terracotta"), /* 245 */ simple("purple_glazed_terracotta"), /* 246 */ simple("blue_glazed_terracotta"), /* 247 */ simple("brown_glazed_terracotta"), /* 248 */ simple("green_glazed_terracotta"), /* 249 */ simple("red_glazed_terracotta"), /* 250 */ simple("black_glazed_terracotta"), /* 251 */ [ "white_concrete", "orange_concrete", "magenta_concrete", "light_blue_concrete", "yellow_concrete", "lime_concrete", "pink_concrete", "gray_concrete", "light_gray_concrete", "cyan_concrete", "purple_concrete", "blue_concrete", "brown_concrete", "green_concrete", "red_concrete", "black_concrete", ], /* 252 */ [ "white_concrete_powder", "orange_concrete_powder", "magenta_concrete_powder", "light_blue_concrete_powder", "yellow_concrete_powder", "lime_concrete_powder", "pink_concrete_powder", "gray_concrete_powder", "light_gray_concrete_powder", "cyan_concrete_powder", "purple_concrete_powder", "blue_concrete_powder", "brown_concrete_powder", "green_concrete_powder", "red_concrete_powder", "black_concrete_powder", ], /* 253 */ EMPTY, /* 254 */ EMPTY, /* 255 */ simple("structure_block"), ];
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/crates/resource/src/legacy_biomes.rs
crates/resource/src/legacy_biomes.rs
//! Manually maintained biome data (aliases and legacy biome IDs) /// Biome ID aliases /// /// Some biomes have been renamed or merged in recent Minecraft versions. /// Maintain a list of aliases to support chunks saved by older versions. pub const BIOME_ALIASES: &[(&str, &str)] = &[ // Biomes fix ("beaches", "beach"), ("cold_beach", "snowy_beach"), ("cold_deep_ocean", "deep_cold_ocean"), ("extreme_hills", "mountains"), ("extreme_hills_with_trees", "wooded_mountains"), ("forest_hills", "wooded_hills"), ("frozen_deep_ocean", "deep_frozen_ocean"), ("hell", "nether_wastes"), ("ice_flats", "snowy_tundra"), ("ice_mountains", "snowy_mountains"), ("lukewarm_deep_ocean", "deep_lukewarm_ocean"), ("mesa", "badlands"), ("mesa_clear_rock", "badlands_plateau"), ("mesa_rock", "wooded_badlands_plateau"), ("mushroom_island", "mushroom_fields"), ("mushroom_island_shore", "mushroom_field_shore"), ("mutated_birch_forest", "tall_birch_forest"), ("mutated_birch_forest_hills", "tall_birch_hills"), ("mutated_desert", "desert_lakes"), ("mutated_extreme_hills", "gravelly_mountains"), ( "mutated_extreme_hills_with_trees", "modified_gravelly_mountains", ), ("mutated_forest", "flower_forest"), ("mutated_ice_flats", "ice_spikes"), ("mutated_jungle", "modified_jungle"), ("mutated_jungle_edge", "modified_jungle_edge"), ("mutated_mesa", "eroded_badlands"), ("mutated_mesa_clear_rock", "modified_badlands_plateau"), ("mutated_mesa_rock", "modified_wooded_badlands_plateau"), ("mutated_plains", "sunflower_plains"), ("mutated_redwood_taiga", "giant_spruce_taiga"), ("mutated_redwood_taiga_hills", "giant_spruce_taiga_hills"), ("mutated_roofed_forest", "dark_forest_hills"), ("mutated_savanna", "shattered_savanna"), ("mutated_savanna_rock", "shattered_savanna_plateau"), ("mutated_swampland", "swamp_hills"), ("mutated_taiga", "taiga_mountains"), ("mutated_taiga_cold", "snowy_taiga_mountains"), ("redwood_taiga", "giant_tree_taiga"), ("redwood_taiga_hills", "giant_tree_taiga_hills"), ("roofed_forest", "dark_forest"), ("savanna_rock", "savanna_plateau"), ("sky", "the_end"), ("sky_island_barren", "end_barrens"), ("sky_island_high", "end_highlands"), ("sky_island_low", "small_end_islands"), ("sky_island_medium", "end_midlands"), ("smaller_extreme_hills", "mountain_edge"), ("stone_beach", "stone_shore"), ("swampland", "swamp"), ("taiga_cold", "snowy_taiga"), ("taiga_cold_hills", "snowy_taiga_hills"), ("void", "the_void"), ("warm_deep_ocean", "deep_warm_ocean"), // Nether biome rename ("nether", "nether_wastes"), // Caves and Cliffs biome renames ("badlands_plateau", "badlands"), ("bamboo_jungle_hills", "bamboo_jungle"), ("birch_forest_hills", "birch_forest"), ("dark_forest_hills", "dark_forest"), ("desert_hills", "desert"), ("desert_lakes", "desert"), ("giant_spruce_taiga", "old_growth_spruce_taiga"), ("giant_spruce_taiga_hills", "old_growth_spruce_taiga"), ("giant_tree_taiga", "old_growth_pine_taiga"), ("giant_tree_taiga_hills", "old_growth_pine_taiga"), ("gravelly_mountains", "windswept_gravelly_hills"), ("jungle_edge", "sparse_jungle"), ("jungle_hills", "jungle"), ("lofty_peaks", "jagged_peaks"), ("modified_badlands_plateau", "badlands"), ("modified_gravelly_mountains", "windswept_gravelly_hills"), ("modified_jungle", "jungle"), ("modified_jungle_edge", "sparse_jungle"), ("modified_wooded_badlands_plateau", "wooded_badlands"), ("mountain_edge", "windswept_hills"), ("mountains", "windswept_hills"), ("mushroom_field_shore", "mushroom_fields"), ("shattered_savanna", "windswept_savanna"), ("shattered_savanna_plateau", "windswept_savanna"), ("snowcapped_peaks", "frozen_peaks"), ("snowy_mountains", "snowy_plains"), ("snowy_taiga_hills", "snowy_taiga"), ("snowy_taiga_mountains", "snowy_taiga"), ("snowy_tundra", "snowy_plains"), ("stone_shore", "stony_shore"), ("swamp_hills", "swamp"), ("taiga_hills", "taiga"), ("taiga_mountains", "taiga"), ("tall_birch_forest", "old_growth_birch_forest"), ("tall_birch_hills", "old_growth_birch_forest"), ("wooded_badlands_plateau", "wooded_badlands"), ("wooded_hills", "forest"), ("wooded_mountains", "windswept_forest"), // Remove Deep Warm Ocean ("deep_warm_ocean", "warm_ocean"), ]; /// Maps old numeric biome IDs to new string IDs pub fn legacy_biome(index: u8) -> &'static str { match index { 0 => "ocean", 1 => "plains", 2 => "desert", 3 => "mountains", 4 => "forest", 5 => "taiga", 6 => "swamp", 7 => "river", 8 => "nether_wastes", 9 => "the_end", 10 => "frozen_ocean", 11 => "frozen_river", 12 => "snowy_tundra", 13 => "snowy_mountains", 14 => "mushroom_fields", 15 => "mushroom_field_shore", 16 => "beach", 17 => "desert_hills", 18 => "wooded_hills", 19 => "taiga_hills", 20 => "mountain_edge", 21 => "jungle", 22 => "jungle_hills", 23 => "jungle_edge", 24 => "deep_ocean", 25 => "stone_shore", 26 => "snowy_beach", 27 => "birch_forest", 28 => "birch_forest_hills", 29 => "dark_forest", 30 => "snowy_taiga", 31 => "snowy_taiga_hills", 32 => "giant_tree_taiga", 33 => "giant_tree_taiga_hills", 34 => "wooded_mountains", 35 => "savanna", 36 => "savanna_plateau", 37 => "badlands", 38 => "wooded_badlands_plateau", 39 => "badlands_plateau", 40 => "small_end_islands", 41 => "end_midlands", 42 => "end_highlands", 43 => "end_barrens", 44 => "warm_ocean", 45 => "lukewarm_ocean", 46 => "cold_ocean", 47 => "deep_warm_ocean", 48 => "deep_lukewarm_ocean", 49 => "deep_cold_ocean", 50 => "deep_frozen_ocean", 127 => "the_void", 129 => "sunflower_plains", 130 => "desert_lakes", 131 => "gravelly_mountains", 132 => "flower_forest", 133 => "taiga_mountains", 134 => "swamp_hills", 140 => "ice_spikes", 149 => "modified_jungle", 151 => "modified_jungle_edge", 155 => "tall_birch_forest", 156 => "tall_birch_hills", 157 => "dark_forest_hills", 158 => "snowy_taiga_mountains", 160 => "giant_spruce_taiga", 161 => "giant_spruce_taiga_hills", 162 => "modified_gravelly_mountains", 163 => "shattered_savanna", 164 => "shattered_savanna_plateau", 165 => "eroded_badlands", 166 => "modified_wooded_badlands_plateau", 167 => "modified_badlands_plateau", 168 => "bamboo_jungle", 169 => "bamboo_jungle_hills", 170 => "soul_sand_valley", 171 => "crimson_forest", 172 => "warped_forest", 173 => "basalt_deltas", 174 => "dripstone_caves", 175 => "lush_caves", 177 => "meadow", 178 => "grove", 179 => "snowy_slopes", 180 => "snowcapped_peaks", 181 => "lofty_peaks", 182 => "stony_peaks", _ => "ocean", } }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/crates/types/src/lib.rs
crates/types/src/lib.rs
#![doc = env!("CARGO_PKG_DESCRIPTION")] #![warn(missing_docs)] #![warn(clippy::missing_docs_in_private_items)] use std::{ fmt::Debug, iter::FusedIterator, ops::{Index, IndexMut}, }; use bincode::{Decode, Encode}; use itertools::iproduct; /// Const generic AXIS arguments for coordinate types pub mod axis { /// The X axis pub const X: u8 = 0; /// The Y axis (height) pub const Y: u8 = 1; /// The Z axis pub const Z: u8 = 2; } /// Generates a generic coordinate type with a given range macro_rules! coord_type { ($t:ident, $max:expr, $doc:expr $(,)?) => { #[doc = $doc] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct $t<const AXIS: u8>(pub u8); impl<const AXIS: u8> $t<AXIS> { const MAX: usize = $max; /// Constructs a new value /// /// Will panic if the value is not in the valid range #[inline] pub fn new<T: TryInto<u8>>(value: T) -> Self { Self( value .try_into() .ok() .filter(|&v| (v as usize) < Self::MAX) .expect("coordinate should be in the valid range"), ) } /// Returns an iterator over all possible values of the type #[inline] pub fn iter() -> impl DoubleEndedIterator<Item = $t<AXIS>> + ExactSizeIterator + FusedIterator + Clone + Debug { (0..Self::MAX as u8).map($t) } } }; } /// Number of bits required to store a block coordinate pub const BLOCK_BITS: u8 = 4; /// Number of blocks per chunk in each dimension pub const BLOCKS_PER_CHUNK: usize = 1 << BLOCK_BITS; coord_type!( BlockCoord, BLOCKS_PER_CHUNK, "A block coordinate relative to a chunk", ); /// A block X coordinate relative to a chunk pub type BlockX = BlockCoord<{ axis::X }>; /// A block Y coordinate relative to a chunk section pub type BlockY = BlockCoord<{ axis::Y }>; /// A block Z coordinate relative to a chunk pub type BlockZ = BlockCoord<{ axis::Z }>; /// X and Z coordinates of a block in a chunk #[derive(Clone, Copy, PartialEq, Eq)] pub struct LayerBlockCoords { /// The X coordinate pub x: BlockX, /// The Z coordinate pub z: BlockZ, } impl Debug for LayerBlockCoords { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "({}, {})", self.x.0, self.z.0) } } impl LayerBlockCoords { /// Computes a block's offset in various data structures /// /// Many chunk data structures store block and biome data in the same /// order. This method computes the offset at which the data for the /// block at a given coordinate is stored. #[inline] pub fn offset(&self) -> usize { use BLOCKS_PER_CHUNK as N; let x = self.x.0 as usize; let z = self.z.0 as usize; N * z + x } } /// Generic array for data stored per block of a chunk layer /// /// Includes various convenient iteration functions. #[derive(Debug, Clone, Copy, Default, Encode, Decode)] pub struct LayerBlockArray<T>(pub [[T; BLOCKS_PER_CHUNK]; BLOCKS_PER_CHUNK]); impl<T> Index<LayerBlockCoords> for LayerBlockArray<T> { type Output = T; #[inline] fn index(&self, index: LayerBlockCoords) -> &Self::Output { &self.0[index.z.0 as usize][index.x.0 as usize] } } impl<T> IndexMut<LayerBlockCoords> for LayerBlockArray<T> { #[inline] fn index_mut(&mut self, index: LayerBlockCoords) -> &mut Self::Output { &mut self.0[index.z.0 as usize][index.x.0 as usize] } } /// X, Y and Z coordinates of a block in a chunk section #[derive(Clone, Copy, PartialEq, Eq)] pub struct SectionBlockCoords { /// The X and Z coordinates pub xz: LayerBlockCoords, /// The Y coordinate pub y: BlockY, } impl SectionBlockCoords { /// Computes a block's offset in various data structures /// /// Many chunk data structures store block and biome data in the same /// order. This method computes the offset at which the data for the /// block at a given coordinate is stored. #[inline] pub fn offset(&self) -> usize { use BLOCKS_PER_CHUNK as N; let y = self.y.0 as usize; N * N * y + self.xz.offset() } } impl Debug for SectionBlockCoords { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "({}, {}, {})", self.xz.x.0, self.y.0, self.xz.z.0) } } /// A section Y coordinate #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct SectionY(pub i32); /// Number of bits required to store a chunk coordinate pub const CHUNK_BITS: u8 = 5; /// Number of chunks per region in each dimension pub const CHUNKS_PER_REGION: usize = 1 << CHUNK_BITS; coord_type!( ChunkCoord, CHUNKS_PER_REGION, "A chunk coordinate relative to a region", ); /// A chunk X coordinate relative to a region pub type ChunkX = ChunkCoord<{ axis::X }>; /// A chunk Z coordinate relative to a region pub type ChunkZ = ChunkCoord<{ axis::Z }>; /// A pair of chunk coordinates relative to a region #[derive(Clone, Copy, PartialEq, Eq)] pub struct ChunkCoords { /// The X coordinate pub x: ChunkX, /// The Z coordinate pub z: ChunkZ, } impl Debug for ChunkCoords { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "({}, {})", self.x.0, self.z.0) } } /// Generic array for data stored per chunk of a region /// /// Includes various convenient iteration functions. #[derive(Debug, Clone, Copy, Default, Encode, Decode)] pub struct ChunkArray<T>(pub [[T; CHUNKS_PER_REGION]; CHUNKS_PER_REGION]); impl<T> ChunkArray<T> { /// Iterates over all possible chunk coordinate pairs used as [ChunkArray] keys #[inline] pub fn keys() -> impl Iterator<Item = ChunkCoords> + Clone + Debug { iproduct!(ChunkZ::iter(), ChunkX::iter()).map(|(z, x)| ChunkCoords { x, z }) } /// Iterates over all values stored in the [ChunkArray] #[inline] pub fn values(&self) -> impl Iterator<Item = &T> + Clone + Debug { Self::keys().map(|k| &self[k]) } /// Iterates over pairs of chunk coordinate pairs and corresponding stored values #[inline] pub fn iter(&self) -> impl Iterator<Item = (ChunkCoords, &T)> + Clone + Debug { Self::keys().map(|k| (k, &self[k])) } } impl<T> Index<ChunkCoords> for ChunkArray<T> { type Output = T; #[inline] fn index(&self, index: ChunkCoords) -> &Self::Output { &self.0[index.z.0 as usize][index.x.0 as usize] } } impl<T> IndexMut<ChunkCoords> for ChunkArray<T> { #[inline] fn index_mut(&mut self, index: ChunkCoords) -> &mut Self::Output { &mut self.0[index.z.0 as usize][index.x.0 as usize] } }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/crates/nbt/src/lib.rs
crates/nbt/src/lib.rs
#![doc = env!("CARGO_PKG_DESCRIPTION")] #![warn(missing_docs)] #![warn(clippy::missing_docs_in_private_items)] pub mod data; pub mod region;
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/crates/nbt/src/region.rs
crates/nbt/src/region.rs
//! Functions for reading and deserializing region data use std::{ fs::File, io::{SeekFrom, prelude::*}, path::Path, }; use anyhow::{Context, Result, bail}; use flate2::read::ZlibDecoder; use serde::de::DeserializeOwned; use minedmap_types::*; /// Data block size of region data files /// /// After one header block, the region file consists of one or more consecutive blocks /// of data for each populated chunk. const BLOCKSIZE: usize = 4096; /// Chunk descriptor extracted from region file header #[derive(Debug)] struct ChunkDesc { /// Offset of data block where the chunk starts offset: u32, /// Number of data block used by the chunk len: u8, /// Coodinates of chunk described by this descriptor coords: ChunkCoords, } /// Parses the header of a region data file fn parse_header(header: &ChunkArray<u32>) -> Vec<ChunkDesc> { let mut chunks: Vec<_> = header .iter() .filter_map(|(coords, &chunk)| { let offset_len = u32::from_be(chunk); let offset = offset_len >> 8; let len = offset_len as u8; if offset == 0 || len == 0 { return None; } Some(ChunkDesc { offset, len, coords, }) }) .collect(); chunks.sort_by_key(|chunk| chunk.offset); chunks } /// Decompresses chunk data and deserializes to a given data structure fn decode_chunk<T>(buf: &[u8]) -> Result<T> where T: DeserializeOwned, { let (format, buf) = buf.split_at(1); if format[0] != 2 { bail!("Unknown chunk format"); } let mut decoder = ZlibDecoder::new(buf); let mut decode_buffer = vec![]; decoder .read_to_end(&mut decode_buffer) .context("Failed to decompress chunk data")?; fastnbt::from_bytes(&decode_buffer).context("Failed to decode NBT data") } /// Wraps a reader used to read a region data file #[derive(Debug)] pub struct Region<R: Read + Seek> { /// The wrapper reader reader: R, } impl<R: Read + Seek> Region<R> { /// Iterates over the chunks of the region data /// /// The order of iteration is based on the order the chunks appear in the /// data file. pub fn foreach_chunk<T, F>(self, mut f: F) -> Result<()> where R: Read + Seek, T: DeserializeOwned, F: FnMut(ChunkCoords, T) -> Result<()>, { let Region { mut reader } = self; let chunks = { let mut header = ChunkArray::<u32>::default(); reader .read_exact(bytemuck::cast_mut::<_, [u8; BLOCKSIZE]>(&mut header.0)) .context("Failed to read region header")?; parse_header(&header) }; let mut seen = ChunkArray::<bool>::default(); for ChunkDesc { offset, len, coords, } in chunks { if seen[coords] { bail!("Duplicate chunk {:?}", coords); } seen[coords] = true; reader .seek(SeekFrom::Start(offset as u64 * BLOCKSIZE as u64)) .context("Failed to seek chunk data")?; let mut len_buf = [0u8; 4]; reader .read_exact(&mut len_buf) .with_context(|| format!("Failed to read length for chunk {coords:?}"))?; let byte_len = u32::from_be_bytes(len_buf) as usize; if byte_len < 1 || byte_len > (len as usize) * BLOCKSIZE - 4 { bail!("Invalid length for chunk {:?}", coords); } let mut buffer = vec![0; byte_len]; reader .read_exact(&mut buffer) .with_context(|| format!("Failed to read data for chunk {coords:?}"))?; let chunk = decode_chunk(&buffer) .with_context(|| format!("Failed to decode data for chunk {coords:?}"))?; f(coords, chunk)?; } Ok(()) } } /// Creates a new [Region] from a reader pub fn from_reader<R>(reader: R) -> Region<R> where R: Read + Seek, { Region { reader } } /// Creates a new [Region] for a file pub fn from_file<P>(path: P) -> Result<Region<File>> where P: AsRef<Path>, { let file = File::open(path).context("Failed to open file")?; Ok(from_reader(file)) }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/crates/nbt/src/data.rs
crates/nbt/src/data.rs
//! Functions for reading and deserializing compressed NBT data use std::{fs::File, io::prelude::*, path::Path}; use anyhow::{Context, Result}; use flate2::read::GzDecoder; use serde::de::DeserializeOwned; /// Reads compressed NBT data from a reader and deserializes to a given data structure pub fn from_reader<R, T>(reader: R) -> Result<T> where R: Read, T: DeserializeOwned, { let mut decoder = GzDecoder::new(reader); let mut buf = vec![]; decoder .read_to_end(&mut buf) .context("Failed to read file")?; fastnbt::from_bytes(&buf).context("Failed to decode NBT data") } /// Reads compressed NBT data from a file and deserializes to a given data structure pub fn from_file<P, T>(path: P) -> Result<T> where P: AsRef<Path>, T: DeserializeOwned, { let file = File::open(path).context("Failed to open file")?; from_reader(file) }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/crates/nbt/examples/nbtdump.rs
crates/nbt/examples/nbtdump.rs
//! Dumps data from a NBT data file in a human-readable format #![warn(missing_docs)] #![warn(clippy::missing_docs_in_private_items)] use std::path::PathBuf; use anyhow::Result; use clap::Parser; /// Dump a Minecraft NBT data file in a human-readable format #[derive(Debug, Parser)] #[command(version)] struct Args { /// Filename to dump file: PathBuf, } fn main() -> Result<()> { let args = Args::parse(); let value: fastnbt::Value = minedmap_nbt::data::from_file(args.file.as_path())?; println!("{value:#x?}"); Ok(()) }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/crates/nbt/examples/regiondump.rs
crates/nbt/examples/regiondump.rs
//! Dumps data from a region data file in a human-readable format #![warn(missing_docs)] #![warn(clippy::missing_docs_in_private_items)] use std::path::PathBuf; use anyhow::Result; use clap::Parser; /// Dump a Minecraft NBT region file in a human-readable format #[derive(Debug, Parser)] #[command(version)] struct Args { /// Filename to dump file: PathBuf, } fn main() -> Result<()> { let args = Args::parse(); minedmap_nbt::region::from_file(args.file.as_path())?.foreach_chunk( |coords, value: fastnbt::Value| { println!("Chunk {coords:?}: {value:#x?}"); Ok(()) }, ) }
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
neocturne/MinedMap
https://github.com/neocturne/MinedMap/blob/e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2/crates/default-alloc/src/lib.rs
crates/default-alloc/src/lib.rs
#[cfg(any(target_env = "musl", feature = "jemalloc"))] #[global_allocator] static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
rust
MIT
e20b6f9c09d80ccb102d1d9c2f13bc5a38a5e5c2
2026-01-04T20:21:57.104151Z
false
tower-rs/tokio-tower
https://github.com/tower-rs/tokio-tower/blob/a364571343275473a268e9616b9c94203c9e9f14/src/wrappers.rs
src/wrappers.rs
use futures_core::stream::TryStream; use futures_sink::Sink; pub(crate) struct ClientRequest<T, I> where T: Sink<I> + TryStream, { pub(crate) req: I, pub(crate) span: tracing::Span, pub(crate) res: tokio::sync::oneshot::Sender<ClientResponse<T::Ok>>, } pub(crate) struct ClientResponse<T> { pub(crate) response: T, pub(crate) span: tracing::Span, }
rust
MIT
a364571343275473a268e9616b9c94203c9e9f14
2026-01-04T20:22:11.595151Z
false
tower-rs/tokio-tower
https://github.com/tower-rs/tokio-tower/blob/a364571343275473a268e9616b9c94203c9e9f14/src/lib.rs
src/lib.rs
//! This crate provides utilities for using protocols that follow certain common patterns on //! top of [Tokio](https://tokio.rs) and [Tower](https://github.com/tower-rs/tower). //! //! # Protocols //! //! At a high level, a protocol is a mechanism that lets you take a bunch of requests and turn them //! into responses. Tower provides the [`Service`](https://docs.rs/tower-service/) trait, which is //! an interface for mapping requests into responses, but it does not deal with how those requests //! are sent between clients and servers. Tokio, on the other hand, provides asynchronous //! communication primitives, but it does not deal with high-level abstractions like services. This //! crate attempts to bridge that gap. //! //! There are many types of protocols in the wild, but they generally come in two forms: //! *pipelining* and *multiplexing*. A pipelining protocol sends requests and responses in-order //! between the consumer and provider of a service, and processes requests one at a time. A //! multiplexing protocol on the other hand constructs requests in such a way that they can be //! handled and responded to in *any* order while still allowing the client to know which response //! is for which request. Pipelining and multiplexing both have their advantages and disadvantages; //! see the module-level documentation for [`pipeline`] and [`multiplex`] for details. There is //! also good deal of discussion in [this StackOverflow //! answer](https://softwareengineering.stackexchange.com/a/325888/79642). //! //! # Transports //! //! A key part of any protocol is its transport, which is the way that it transmits requests and //! responses. In general, `tokio-tower` leaves the on-the-wire implementations of protocols to //! other crates (like [`tokio-codec`](https://docs.rs/tokio-codec/) or //! [`async-bincode`](https://docs.rs/async-bincode)) and instead operates at the level of //! [`Sink`](https://docs.rs/futures/0.1/futures/sink/trait.Sink.html)s and //! [`Stream`](https://docs.rs/futures/0.15/futures/stream/trait.Stream.html)s. //! //! At its core, `tokio-tower` wraps a type that is `Sink + Stream`. On the client side, the Sink //! is used to send requests, and the Stream is used to receive responses (from the server) to //! those requests. On the server side, the Stream is used to receive requests, and the Sink is //! used to send the responses. //! //! # Servers and clients //! //! This crate provides utilities that make writing both clients and servers easier. You'll find //! the client helper as `Client` in the protocol module you're working with (e.g., //! [`pipeline::Client`]), and the server helper as `Server` in the same place. //! //! # Example //! ```rust //! # use std::pin::Pin; //! # use std::boxed::Box; //! # use tokio::sync::mpsc; //! # use tokio::io::{AsyncWrite, AsyncRead}; //! # use futures_core::task::{Context, Poll}; //! # use futures_util::{never::Never, future::{poll_fn, ready, Ready}}; //! # use tokio_tower::pipeline; //! # use core::fmt::Debug; //! type StdError = Box<dyn std::error::Error + Send + Sync + 'static>; //! //! /// A transport implemented using a pair of `mpsc` channels. //! /// //! /// `mpsc::Sender` and `mpsc::Receiver` are both unidirectional. So, if we want to use `mpsc` //! /// to send requests and responses between a client and server, we need *two* channels, one //! /// that lets requests flow from the client to the server, and one that lets responses flow the //! /// other way. //! /// //! /// In this echo server example, requests and responses are both of type `T`, but for "real" //! /// services, the two types are usually different. //! struct ChannelTransport<T> { //! rcv: mpsc::UnboundedReceiver<T>, //! snd: mpsc::UnboundedSender<T>, //! } //! //! impl<T: Debug> futures_sink::Sink<T> for ChannelTransport<T> { //! type Error = StdError; //! //! fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> { //! Poll::Ready(Ok(())) //! } //! //! fn start_send(mut self: Pin<&mut Self>, item: T) -> Result<(), Self::Error> { //! // use map_err because `T` contained in `mpsc::SendError` may not be `Send + Sync`. //! self.snd.send(item).map_err(|e| e.to_string())?; //! Ok(()) //! } //! //! fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> { //! Poll::Ready(Ok(())) // no-op because all sends succeed immediately //! } //! //! fn poll_close( self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> { //! Poll::Ready(Ok(())) // no-op because channel is closed on drop and flush is no-op //! } //! } //! //! impl<T> futures_util::stream::Stream for ChannelTransport<T> { //! type Item = Result<T, StdError>; //! //! fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> { //! self.rcv.poll_recv(cx).map(|s| s.map(Ok)) //! } //! } //! //! /// A service that tokio-tower should serve over the transport. //! /// This one just echoes whatever it gets. //! struct Echo; //! //! impl<T> tower_service::Service<T> for Echo { //! type Response = T; //! type Error = Never; //! type Future = Ready<Result<Self::Response, Self::Error>>; //! //! fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> { //! Poll::Ready(Ok(())) //! } //! //! fn call(&mut self, req: T) -> Self::Future { //! ready(Ok(req)) //! } //! } //! //! #[tokio::main] //! async fn main() { //! let (s1, r1) = mpsc::unbounded_channel(); //! let (s2, r2) = mpsc::unbounded_channel(); //! let pair1 = ChannelTransport{snd: s1, rcv: r2}; //! let pair2 = ChannelTransport{snd: s2, rcv: r1}; //! //! tokio::spawn(pipeline::Server::new(pair1, Echo)); //! let mut client = pipeline::Client::<_, tokio_tower::Error<_, _>, _>::new(pair2); //! //! use tower_service::Service; //! poll_fn(|cx| client.poll_ready(cx)).await; //! //! let msg = "Hello, tokio-tower"; //! let resp = client.call(String::from(msg)).await.expect("client call"); //! assert_eq!(resp, msg); //! } //! //! ``` #![warn( missing_docs, missing_debug_implementations, unreachable_pub, rust_2018_idioms )] #![allow(clippy::type_complexity)] const YIELD_EVERY: usize = 24; mod error; mod mediator; pub(crate) mod wrappers; pub use error::Error; use futures_core::{ future::Future, stream::TryStream, task::{Context, Poll}, }; use futures_sink::Sink; use tower_service::Service; /// Creates new `Transport` (i.e., `Sink + Stream`) instances. /// /// Acts as a transport factory. This is useful for cases where new `Sink + Stream` /// values must be produced. /// /// This is essentially a trait alias for a `Service` of `Sink + Stream`s. pub trait MakeTransport<Target, Request>: self::sealed::Sealed<Target, Request> { /// Items produced by the transport type Item; /// Errors produced when receiving from the transport type Error; /// Errors produced when sending to the transport type SinkError; /// The `Sink + Stream` implementation created by this factory type Transport: TryStream<Ok = Self::Item, Error = Self::Error> + Sink<Request, Error = Self::SinkError>; /// Errors produced while building a transport. type MakeError; /// The future of the `Service` instance. type Future: Future<Output = Result<Self::Transport, Self::MakeError>>; /// Returns `Ready` when the factory is able to create more transports. /// /// If the service is at capacity, then `NotReady` is returned and the task /// is notified when the service becomes ready again. This function is /// expected to be called while on a task. /// /// This is a **best effort** implementation. False positives are permitted. /// It is permitted for the service to return `Ready` from a `poll_ready` /// call and the next invocation of `make_transport` results in an error. fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::MakeError>>; /// Create and return a new transport asynchronously. fn make_transport(&mut self, target: Target) -> Self::Future; } impl<M, T, Target, Request> self::sealed::Sealed<Target, Request> for M where M: Service<Target, Response = T>, T: TryStream + Sink<Request>, { } impl<M, T, Target, Request> MakeTransport<Target, Request> for M where M: Service<Target, Response = T>, T: TryStream + Sink<Request>, { type Item = <T as TryStream>::Ok; type Error = <T as TryStream>::Error; type SinkError = <T as Sink<Request>>::Error; type Transport = T; type MakeError = M::Error; type Future = M::Future; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::MakeError>> { Service::poll_ready(self, cx) } fn make_transport(&mut self, target: Target) -> Self::Future { Service::call(self, target) } } mod sealed { pub trait Sealed<A, B> {} } pub mod multiplex; pub mod pipeline;
rust
MIT
a364571343275473a268e9616b9c94203c9e9f14
2026-01-04T20:22:11.595151Z
false
tower-rs/tokio-tower
https://github.com/tower-rs/tokio-tower/blob/a364571343275473a268e9616b9c94203c9e9f14/src/error.rs
src/error.rs
use futures_core::stream::TryStream; use futures_sink::Sink; use std::{error, fmt}; /// An error that occurred while servicing a request. #[non_exhaustive] pub enum Error<T, I> where T: Sink<I> + TryStream, { /// The underlying transport failed to send a request. BrokenTransportSend(<T as Sink<I>>::Error), /// The underlying transport failed while attempting to receive a response. /// /// If `None`, the transport closed without error while there were pending requests. BrokenTransportRecv(Option<<T as TryStream>::Error>), /// The internal pending data store has dropped the pending response. Cancelled, /// Attempted to issue a `call` when no more requests can be in flight. /// /// See [`tower_service::Service::poll_ready`] and [`Client::with_limit`]. TransportFull, /// Attempted to issue a `call`, but the underlying transport has been closed. ClientDropped, /// The server sent a response that the client was not expecting. Desynchronized, /// The underlying transport task did not exit gracefully (either panic or cancellation). /// Transport task panics can happen for example when the codec logic panics. TransportDropped, } impl<T, I> fmt::Display for Error<T, I> where T: Sink<I> + TryStream, <T as Sink<I>>::Error: fmt::Display, <T as TryStream>::Error: fmt::Display, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::BrokenTransportSend(_) => f.pad("underlying transport failed to send a request"), Error::BrokenTransportRecv(Some(_)) => { f.pad("underlying transport failed while attempting to receive a response") } Error::BrokenTransportRecv(None) => f.pad("transport closed with in-flight requests"), Error::Cancelled => f.pad("request was cancelled internally"), Error::TransportFull => f.pad("no more in-flight requests allowed"), Error::ClientDropped => f.pad("Client was dropped"), Error::Desynchronized => f.pad("server sent a response the client did not expect"), Error::TransportDropped => { f.pad("underlying transport task exited unexpectedly (panic or cancellation)") } } } } impl<T, I> fmt::Debug for Error<T, I> where T: Sink<I> + TryStream, <T as Sink<I>>::Error: fmt::Debug, <T as TryStream>::Error: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::BrokenTransportSend(ref se) => write!(f, "BrokenTransportSend({:?})", se), Error::BrokenTransportRecv(Some(ref se)) => write!(f, "BrokenTransportRecv({:?})", se), Error::BrokenTransportRecv(None) => f.pad("BrokenTransportRecv"), Error::Cancelled => f.pad("Cancelled"), Error::TransportFull => f.pad("TransportFull"), Error::ClientDropped => f.pad("ClientDropped"), Error::Desynchronized => f.pad("Desynchronized"), Error::TransportDropped => f.pad("TransportDropped"), } } } impl<T, I> error::Error for Error<T, I> where T: Sink<I> + TryStream, <T as Sink<I>>::Error: error::Error + 'static, <T as TryStream>::Error: error::Error + 'static, { fn source(&self) -> Option<&(dyn error::Error + 'static)> { match *self { Error::BrokenTransportSend(ref se) => Some(se), Error::BrokenTransportRecv(Some(ref se)) => Some(se), _ => None, } } } impl<T, I> Error<T, I> where T: Sink<I> + TryStream, { pub(crate) fn from_sink_error(e: <T as Sink<I>>::Error) -> Self { Error::BrokenTransportSend(e) } pub(crate) fn from_stream_error(e: <T as TryStream>::Error) -> Self { Error::BrokenTransportRecv(Some(e)) } }
rust
MIT
a364571343275473a268e9616b9c94203c9e9f14
2026-01-04T20:22:11.595151Z
false
tower-rs/tokio-tower
https://github.com/tower-rs/tokio-tower/blob/a364571343275473a268e9616b9c94203c9e9f14/src/mediator.rs
src/mediator.rs
use crossbeam::atomic::AtomicCell; use futures_util::task; use std::fmt; use std::sync::Arc; use std::task::{Context, Poll}; #[derive(Debug)] enum CellValue<T> { /// The sender has left a value. Some(T), /// If the receiver sees this, the sender has disconnected. /// If the sender sees this, the receiver has disconnected. /// /// Will be `Some` if the sender sent a value that wasn't handled before it disconnected. Fin(Option<T>), /// The sender has not left a value. None, } impl<T> CellValue<T> { fn is_none(&self) -> bool { matches!(self, CellValue::None) } } struct Mediator<T> { value: AtomicCell<CellValue<T>>, tx_task: task::AtomicWaker, rx_task: task::AtomicWaker, } impl<T> fmt::Debug for Mediator<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Mediator") .field("tx_task", &self.tx_task) .field("rx_task", &self.rx_task) .finish() } } pub(crate) struct Receiver<T>(Arc<Mediator<T>>); impl<T> fmt::Debug for Receiver<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("Receiver").field(&self.0).finish() } } pub(crate) struct Sender<T> { inner: Arc<Mediator<T>>, checked_ready: bool, } impl<T> fmt::Debug for Sender<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Sender") .field("inner", &self.inner) .field("checked_ready", &self.checked_ready) .finish() } } impl<T> Drop for Sender<T> { fn drop(&mut self) { match self.inner.value.swap(CellValue::None) { CellValue::Some(t) => { self.inner.value.swap(CellValue::Fin(Some(t))); } CellValue::Fin(_) => { // receiver has gone away too -- all good. return; } CellValue::None => { self.inner.value.swap(CellValue::Fin(None)); } } self.inner.rx_task.wake(); } } pub(crate) fn new<T>() -> (Sender<T>, Receiver<T>) { let m = Arc::new(Mediator { value: AtomicCell::new(CellValue::None), tx_task: task::AtomicWaker::new(), rx_task: task::AtomicWaker::new(), }); ( Sender { inner: m.clone(), checked_ready: false, }, Receiver(m), ) } #[derive(Clone, Debug, PartialEq, Eq)] pub(crate) enum TrySendError<T> { Pending(T), Closed(T), } impl<T> Sender<T> { /// Returns true if there is a free slot for a client request. /// /// This method errors if the receiver has disconnected. pub(crate) fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), ()>> { // register in case we can't send self.inner.tx_task.register(cx.waker()); match self.inner.value.swap(CellValue::None) { CellValue::Some(t) => { // whoops -- put it back self.inner.value.swap(CellValue::Some(t)); // notify in case the receiver just missed us self.inner.rx_task.wake(); Poll::Pending } CellValue::None => { self.checked_ready = true; Poll::Ready(Ok(())) } f @ CellValue::Fin(_) => { // the receiver must have gone away (since we can't have gone away) // put the Fin marker back for ourselves to see again later self.inner.value.swap(f); Poll::Ready(Err(())) } } } /// Attempts to place `t` in a free client request slot. /// /// This method returns `NotReady` if `is_ready` has not previously returned `true`. /// This method errors if the receiver has disconnected since `poll_ready`. pub(crate) fn try_send(&mut self, t: T) -> Result<(), TrySendError<T>> { if !self.checked_ready { return Err(TrySendError::Pending(t)); } // we're supposed to _know_ that there is a slot here, // so no need to do a tx_task.register. match self.inner.value.swap(CellValue::Some(t)) { CellValue::None => {} CellValue::Some(_) => unreachable!("is_ready returned true, but slot occupied"), f @ CellValue::Fin(_) => { // the receiver must have gone away (since we can't have gone away) // put the Fin marker back for ourselves to see again later if let CellValue::Some(t) = self.inner.value.swap(f) { return Err(TrySendError::Closed(t)); } else { unreachable!("where did it go?"); } } } self.checked_ready = false; self.inner.rx_task.wake(); Ok(()) } } impl<T> Receiver<T> { /// Attempts to receive a value sent by the client. /// /// `Ready(None)` is returned if the client has disconnected. pub(crate) fn try_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> { self.0.rx_task.register(cx.waker()); match self.0.value.swap(CellValue::None) { CellValue::Some(v) => { // let the sender know there's room now self.0.tx_task.wake(); Poll::Ready(Some(v)) } CellValue::Fin(Some(v)) => { // leave a None in there so we know to close after if cfg!(debug_assertions) { let old = self.0.value.swap(CellValue::Fin(None)); assert!(old.is_none()); } else { self.0.value.store(CellValue::Fin(None)); } Poll::Ready(Some(v)) } CellValue::Fin(None) => Poll::Ready(None), CellValue::None => Poll::Pending, } } } impl<T> Drop for Receiver<T> { fn drop(&mut self) { self.0.value.swap(CellValue::Fin(None)); } } #[cfg(test)] mod test { use super::*; #[test] fn basic() { let (tx, rx) = new::<usize>(); let mut tx = tokio_test::task::spawn(tx); let mut rx = tokio_test::task::spawn(rx); assert_eq!( tx.enter(|cx, mut tx| tx.poll_ready(cx)), Poll::Ready(Ok(())) ); assert!(!tx.is_woken()); assert!(!rx.is_woken()); assert_eq!(tx.enter(|_, mut tx| tx.try_send(42)), Ok(())); assert!(!tx.is_woken()); assert!(!rx.is_woken()); assert_eq!( rx.enter(|cx, mut rx| rx.try_recv(cx)), Poll::Ready(Some(42)) ); assert!(tx.is_woken()); assert!(!rx.is_woken()); assert_eq!( tx.enter(|cx, mut tx| tx.poll_ready(cx)), Poll::Ready(Ok(())) ); assert_eq!(tx.enter(|_, mut tx| tx.try_send(43)), Ok(())); assert!(rx.is_woken()); assert_eq!(tx.enter(|cx, mut tx| tx.poll_ready(cx)), Poll::Pending); assert_eq!( tx.enter(|_, mut tx| tx.try_send(44)), Err(TrySendError::Pending(44)) ); assert_eq!( rx.enter(|cx, mut rx| rx.try_recv(cx)), Poll::Ready(Some(43)) ); assert!(tx.is_woken()); // sender is notified assert_eq!( tx.enter(|cx, mut tx| tx.poll_ready(cx)), Poll::Ready(Ok(())) ); assert_eq!(tx.enter(|_, mut tx| tx.try_send(44)), Ok(())); assert!(rx.is_woken()); drop(tx); assert_eq!( rx.enter(|cx, mut rx| rx.try_recv(cx)), Poll::Ready(Some(44)) ); assert_eq!(rx.enter(|cx, mut rx| rx.try_recv(cx)), Poll::Ready(None)); } #[test] fn notified_on_empty_drop() { let (tx, rx) = new::<usize>(); let tx = tokio_test::task::spawn(tx); let mut rx = tokio_test::task::spawn(rx); assert_eq!(rx.enter(|cx, mut rx| rx.try_recv(cx)), Poll::Pending); assert!(!rx.is_woken()); drop(tx); assert!(rx.is_woken()); assert_eq!(rx.enter(|cx, mut rx| rx.try_recv(cx)), Poll::Ready(None)); } #[test] fn sender_sees_receiver_drop() { let (tx, rx) = new::<usize>(); let mut tx = tokio_test::task::spawn(tx); let rx = tokio_test::task::spawn(rx); assert_eq!( tx.enter(|cx, mut tx| tx.poll_ready(cx)), Poll::Ready(Ok(())) ); drop(rx); assert_eq!( tx.enter(|cx, mut tx| tx.poll_ready(cx)), Poll::Ready(Err(())) ); assert_eq!( tx.enter(|_, mut tx| tx.try_send(42)), Err(TrySendError::Closed(42)) ); } }
rust
MIT
a364571343275473a268e9616b9c94203c9e9f14
2026-01-04T20:22:11.595151Z
false
tower-rs/tokio-tower
https://github.com/tower-rs/tokio-tower/blob/a364571343275473a268e9616b9c94203c9e9f14/src/multiplex/client.rs
src/multiplex/client.rs
use crate::mediator; use crate::mediator::TrySendError; use crate::wrappers::*; use crate::Error; use futures_core::{ready, stream::TryStream}; use futures_sink::Sink; use pin_project::pin_project; use std::collections::VecDeque; use std::fmt; use std::future::Future; use std::marker::PhantomData; use std::pin::Pin; use std::task::{Context, Poll}; use tower_service::Service; // NOTE: this implementation could be more opinionated about request IDs by using a slab, but // instead, we allow the user to choose their own identifier format. /// A transport capable of transporting tagged requests and responses must implement this /// interface in order to be used with a [`Client`]. /// /// Note that we require self to be pinned here as `assign_tag` and `finish_tag` are called on the /// transport, which is already pinned so that we can use it as a `Stream + Sink`. It wouldn't be /// safe to then give out `&mut` to the transport without `Pin`, as that might move the transport. pub trait TagStore<Request, Response> { /// The type used for tags. type Tag; /// Assign a fresh tag to the given `Request`, and return that tag. fn assign_tag(self: Pin<&mut Self>, r: &mut Request) -> Self::Tag; /// Retire and return the tag contained in the given `Response`. fn finish_tag(self: Pin<&mut Self>, r: &Response) -> Self::Tag; } /// A store used to track pending requests. /// /// Each request that is `sent` is passed to the local state used to track /// each pending request, and is expected to be able to recall that state /// through `completed` when a response later comes in with the same tag as /// the original request. pub trait PendingStore<T, Request> where T: TryStream + Sink<Request> + TagStore<Request, T::Ok>, { /// Store the provided tag and pending request. fn sent(self: Pin<&mut Self>, tag: T::Tag, pending: Pending<T::Ok>, transport: Pin<&mut T>); /// Retrieve the pending request associated with this tag. /// /// This method should return `Ok(Some(p))` where `p` is the [`Pending`] /// that was passed to `sent` with `tag`. Implementors can choose /// to ignore a given response, such as to support request cancellation, /// by returning `Ok(None)` for a tag and dropping the corresponding /// `Pending` type. Doing so will make the original request future resolve as `Err(Error::Cancelled)`. /// /// If `tag` is not recognized as belonging to an in-flight request, implementors /// should return `Err(Error::Desynchronized)`. fn completed( self: Pin<&mut Self>, tag: T::Tag, transport: Pin<&mut T>, ) -> Result<Option<Pending<T::Ok>>, Error<T, Request>>; /// Return the count of in-flight pending responses in the [`PendingStore`]. fn in_flight(&self, transport: &T) -> usize; } /// A [`PendingStore`] implementation that uses a [`VecDeque`] /// to store pending requests. /// /// When the [`Client`] recives a response with a `Tag` that does not /// exist in the internal [`PendingStore`] this implementation will return /// an `Error::Desynchronized` error. #[pin_project] pub struct VecDequePendingStore<T, Request> where T: TryStream + Sink<Request> + TagStore<Request, T::Ok>, { pending: VecDeque<(T::Tag, Pending<T::Ok>)>, _pd: PhantomData<fn((T, Request))>, } impl<T, Request> Default for VecDequePendingStore<T, Request> where T: TryStream + Sink<Request> + TagStore<Request, T::Ok>, { fn default() -> Self { Self { pending: VecDeque::new(), _pd: PhantomData, } } } impl<T, Request> fmt::Debug for VecDequePendingStore<T, Request> where T: TryStream + Sink<Request> + TagStore<Request, T::Ok>, T::Tag: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("VecDequePendingStore") .field("pending", &self.pending) .finish() } } impl<T, Request> PendingStore<T, Request> for VecDequePendingStore<T, Request> where T: TryStream + Sink<Request> + TagStore<Request, T::Ok>, T::Tag: Eq, { fn sent(self: Pin<&mut Self>, tag: T::Tag, pending: Pending<T::Ok>, _transport: Pin<&mut T>) { let this = self.project(); this.pending.push_back((tag, pending)); } fn completed( self: Pin<&mut Self>, tag: T::Tag, _transport: Pin<&mut T>, ) -> Result<Option<Pending<T::Ok>>, Error<T, Request>> { let this = self.project(); let pending = this .pending .iter() .position(|(t, _)| t == &tag) .ok_or(Error::Desynchronized)?; // this request just finished, which means it's _probably_ near the front // (i.e., was issued a while ago). so, for the swap needed for efficient // remove, we want to swap with something else that is close to the front. let response = this.pending.swap_remove_front(pending).unwrap(); Ok(Some(response.1)) } fn in_flight(&self, _transport: &T) -> usize { self.pending.len() } } // ===== Client ===== /// This type provides an implementation of a Tower /// [`Service`](https://docs.rs/tokio-service/0.1/tokio_service/trait.Service.html) on top of a /// request-at-a-time protocol transport. In particular, it wraps a transport that implements /// `Sink<SinkItem = Request>` and `Stream<Item = Response>` with the necessary bookkeeping to /// adhere to Tower's convenient `fn(Request) -> Future<Response>` API. pub struct Client<T, E, Request, P = VecDequePendingStore<T, Request>> where T: Sink<Request> + TryStream, { mediator: mediator::Sender<ClientRequest<T, Request>>, _error: PhantomData<fn(P, E)>, } impl<T, E, Request, P> fmt::Debug for Client<T, E, Request, P> where T: Sink<Request> + TryStream, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("mediator", &self.mediator) .finish() } } // ===== Pending ===== /// A type used to track in-flight requests. /// /// Each pending response has an associated `Tag` that is provided /// by the [`TagStore`], which is used to uniquely identify a request/response pair. pub struct Pending<Response> { tx: tokio::sync::oneshot::Sender<ClientResponse<Response>>, span: tracing::Span, } impl<Response> fmt::Debug for Pending<Response> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Pending").field("span", &self.span).finish() } } // ===== Builder ===== /// The default service error handler. pub type DefaultOnServiceError<E> = Box<dyn FnOnce(E) + Send>; /// Builder for [`Client`] this is used to configure the transport, pending store /// and service_handler. /// /// # Defaults /// /// By default this builder only requires a transport and sets a default [`PendingStore`] /// and error handler. The default pending store is a [`VecDeque`] and the default /// error handler is just a closure that silently drops all errors. pub struct Builder< T, E, Request, F = DefaultOnServiceError<E>, P = VecDequePendingStore<T, Request>, > { transport: T, on_service_error: F, pending_store: P, _pd: PhantomData<fn(Request, E)>, } impl<T, E, Request, F, P> Builder<T, E, Request, F, P> where T: Sink<Request> + TryStream + TagStore<Request, <T as TryStream>::Ok> + Send + 'static, P: PendingStore<T, Request> + Send + 'static, E: From<Error<T, Request>>, E: 'static + Send, Request: 'static + Send, T::Ok: 'static + Send, T::Tag: Send, F: FnOnce(E) + Send + 'static, { fn new( transport: T, ) -> Builder<T, E, Request, DefaultOnServiceError<E>, VecDequePendingStore<T, Request>> { Builder { transport, on_service_error: Box::new(|_| {}), pending_store: VecDequePendingStore::default(), _pd: PhantomData, } } /// Set the constructed client's [`PendingStore`]. pub fn pending_store<P2>(self, pending_store: P2) -> Builder<T, E, Request, F, P2> { Builder { pending_store, on_service_error: self.on_service_error, transport: self.transport, _pd: PhantomData, } } /// Set the constructed client's service error handler. /// /// If the [`Client`] encounters an error, it passes that error to `on_service_error` /// before exiting. /// /// `on_service_error` will be run from within a `Drop` implementation when the transport task /// panics, so it will likely abort if it panics. pub fn on_service_error<F2>(self, on_service_error: F2) -> Builder<T, E, Request, F2, P> where F: FnOnce(E) + Send + 'static, { Builder { on_service_error, pending_store: self.pending_store, transport: self.transport, _pd: PhantomData, } } /// Build a client based on the configured items on the builder. pub fn build(self) -> Client<T, E, Request, P> { Client::new_internal(self.transport, self.pending_store, self.on_service_error) } } impl<T, E, Request, F, P> fmt::Debug for Builder<T, E, Request, F, P> where T: fmt::Debug, P: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Builder") .field("transport", &self.transport) .field("pending_store", &self.pending_store) .finish() } } // ===== ClientInner ===== #[pin_project] struct ClientInner<T, P, E, Request> where T: Sink<Request> + TryStream + TagStore<Request, T::Ok>, P: PendingStore<T, Request>, { mediator: mediator::Receiver<ClientRequest<T, Request>>, #[pin] pending: P, #[pin] transport: T, finish: bool, rx_only: bool, #[allow(unused)] error: PhantomData<fn(E)>, } impl<T, E, Request> Client<T, E, Request> where T: Sink<Request> + TryStream + TagStore<Request, <T as TryStream>::Ok> + Send + 'static, E: From<Error<T, Request>>, E: 'static + Send, Request: 'static + Send, T::Ok: 'static + Send, T::Tag: Eq + Send, { /// Construct a new [`Client`] over the given `transport`. /// /// If the Client errors, the error is dropped when `new` is used -- use `with_error_handler` /// to handle such an error explicitly. pub fn new(transport: T) -> Self { Self::builder(transport).build() } /// Create a new builder with the provided transport. pub fn builder(transport: T) -> Builder<T, E, Request> { Builder::<_, _, _, DefaultOnServiceError<E>, VecDequePendingStore<T, Request>>::new( transport, ) } } /// Handles executing the service error handler in case awaiting the `ClientInner` Future panics. struct ClientInnerCleanup<Request, T, E, F> where T: Sink<Request> + TryStream, E: From<Error<T, Request>>, F: FnOnce(E), { on_service_error: Option<F>, _phantom_data: PhantomData<(Request, T, E)>, } impl<Request, T, E, F> Drop for ClientInnerCleanup<Request, T, E, F> where T: Sink<Request> + TryStream, E: From<Error<T, Request>>, F: FnOnce(E), { fn drop(&mut self) { if let Some(handler) = self.on_service_error.take() { (handler)(E::from(Error::<T, Request>::TransportDropped)) } } } impl<T, E, Request, P> Client<T, E, Request, P> where T: Sink<Request> + TryStream + TagStore<Request, <T as TryStream>::Ok> + Send + 'static, P: PendingStore<T, Request> + Send + 'static, E: From<Error<T, Request>>, E: 'static + Send, Request: 'static + Send, T::Ok: 'static + Send, T::Tag: Send, { fn new_internal<F>(transport: T, pending: P, on_service_error: F) -> Self where F: FnOnce(E) + Send + 'static, { let (tx, rx) = mediator::new(); tokio::spawn({ let c = ClientInner { mediator: rx, transport, pending, error: PhantomData::<fn(E)>, finish: false, rx_only: false, }; async move { let mut cleanup = ClientInnerCleanup { on_service_error: Some(on_service_error), _phantom_data: PhantomData::default(), }; let result = c.await; let error = cleanup.on_service_error.take().unwrap(); if let Err(e) = result { error(e); } } }); Client { mediator: tx, _error: PhantomData, } } } impl<T, P, E, Request> Future for ClientInner<T, P, E, Request> where T: Sink<Request> + TryStream + TagStore<Request, <T as TryStream>::Ok>, P: PendingStore<T, Request>, E: From<Error<T, Request>>, E: 'static + Send, Request: 'static + Send, T::Ok: 'static + Send, { type Output = Result<(), E>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { // go through the deref so we can do partial borrows let this = self.project(); // we never move transport, nor do we ever hand out &mut to it let mut transport: Pin<_> = this.transport; let mut pending: Pin<_> = this.pending; // track how many times we have iterated let mut i = 0; if !*this.finish { while let Poll::Ready(r) = transport.as_mut().poll_ready(cx) { if let Err(e) = r { return Poll::Ready(Err(E::from(Error::from_sink_error(e)))); } // send more requests if we have them match this.mediator.try_recv(cx) { Poll::Ready(Some(ClientRequest { mut req, span: _span, res, })) => { let id = transport.as_mut().assign_tag(&mut req); let guard = _span.enter(); tracing::trace!("request received by worker; sending to Sink"); transport .as_mut() .start_send(req) .map_err(Error::from_sink_error)?; tracing::trace!("request sent"); drop(guard); pending.as_mut().sent( id, Pending { tx: res, span: _span, }, transport.as_mut(), ); // if we have run for a while without yielding, yield so we can make progress i += 1; if i == crate::YIELD_EVERY { // we're forcing a yield, so need to ensure we get woken up again cx.waker().wake_by_ref(); // we still want to execute the code below the loop break; } } Poll::Ready(None) => { // XXX: should we "give up" the Sink::poll_ready here? *this.finish = true; break; } Poll::Pending => { // XXX: should we "give up" the Sink::poll_ready here? break; } } } } if pending.as_ref().in_flight(&transport) != 0 && !*this.rx_only { // flush out any stuff we've sent in the past // don't return on NotReady since we have to check for responses too if *this.finish { // we're closing up shop! // // poll_close() implies poll_flush() let r = transport .as_mut() .poll_close(cx) .map_err(Error::from_sink_error)?; if r.is_ready() { // now that close has completed, we should never send anything again // we only need to receive to make the in-flight requests complete *this.rx_only = true; } } else { let _ = transport .as_mut() .poll_flush(cx) .map_err(Error::from_sink_error)?; } } // and start looking for replies. // // note that we *could* have this just be a loop, but we don't want to poll the stream // if we know there's nothing for it to produce. while pending.as_ref().in_flight(&transport) != 0 { let poll_next = match transport.as_mut().try_poll_next(cx) { Poll::Pending => { // try_poll_next could mutate the pending store and actually change the number // of in_flight requests, so we check again if we have an inflight request or not if pending.as_ref().in_flight(&transport) == 0 { break; } return Poll::Pending; } Poll::Ready(x) => x, }; match poll_next.transpose().map_err(Error::from_stream_error)? { Some(r) => { let id = transport.as_mut().finish_tag(&r); let pending = if let Some(pending) = pending.as_mut().completed(id, transport.as_mut())? { pending } else { tracing::trace!( "response arrived but no associated pending tag; ignoring response" ); continue; }; tracing::trace!(parent: &pending.span, "response arrived; forwarding"); // ignore send failures // the client may just no longer care about the response let sender = pending.tx; let _ = sender.send(ClientResponse { response: r, span: pending.span, }); } None => { // the transport terminated while we were waiting for a response! // TODO: it'd be nice if we could return the transport here.. return Poll::Ready(Err(E::from(Error::BrokenTransportRecv(None)))); } } } if *this.finish && pending.as_ref().in_flight(&transport) == 0 { if *this.rx_only { // we have already closed the send side. } else { // we're completely done once close() finishes! ready!(transport.poll_close(cx)).map_err(Error::from_sink_error)?; } return Poll::Ready(Ok(())); } // to get here, we must have no requests in flight and have gotten a NotReady from // self.mediator.try_recv or self.transport.start_send. we *could* also have messages // waiting to be sent (transport.poll_complete), but if that's the case it must also have // returned NotReady. so, at this point, we know that all of our subtasks are either done // or have returned NotReady, so the right thing for us to do is return NotReady too! Poll::Pending } } impl<T, E, Request, P> Service<Request> for Client<T, E, Request, P> where T: Sink<Request> + TryStream + TagStore<Request, <T as TryStream>::Ok>, P: PendingStore<T, Request>, E: From<Error<T, Request>>, E: 'static + Send, Request: 'static + Send, T: 'static, T::Ok: 'static + Send, { type Response = T::Ok; type Error = E; type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), E>> { Poll::Ready(ready!(self.mediator.poll_ready(cx)).map_err(|_| E::from(Error::ClientDropped))) } fn call(&mut self, req: Request) -> Self::Future { let (tx, rx) = tokio::sync::oneshot::channel(); let span = tracing::Span::current(); tracing::trace!("issuing request"); let req = ClientRequest { req, span, res: tx }; let r = self.mediator.try_send(req); Box::pin(async move { match r { Ok(()) => match rx.await { Ok(r) => { tracing::trace!(parent: &r.span, "response returned"); Ok(r.response) } Err(_) => Err(E::from(Error::Cancelled)), }, Err(TrySendError::Pending(_)) => Err(E::from(Error::TransportFull)), Err(TrySendError::Closed(_)) => Err(E::from(Error::ClientDropped)), } }) } }
rust
MIT
a364571343275473a268e9616b9c94203c9e9f14
2026-01-04T20:22:11.595151Z
false
tower-rs/tokio-tower
https://github.com/tower-rs/tokio-tower/blob/a364571343275473a268e9616b9c94203c9e9f14/src/multiplex/mod.rs
src/multiplex/mod.rs
//! In a multiplexed protocol, the server responds to client requests in the order they complete. //! Request IDs ([`TagStore::Tag`]) are used to match up responses with the request that triggered //! them. This allows the server to process requests out-of-order, and eliminates the //! application-level head-of-line blocking that pipelined protocols suffer from. Example //! multiplexed protocols include SSH, HTTP/2, and AMQP. [This //! page](https://250bpm.com/blog:18/) has some further details about how multiplexing protocols //! operate. //! //! Note: multiplexing with the max number of in-flight requests set to 1 implies that for each //! request, the response must be received before sending another request on the same connection. use futures_core::stream::{Stream, TryStream}; use futures_sink::Sink; use pin_project::pin_project; use std::pin::Pin; use std::task::{Context, Poll}; /// Client bindings for a multiplexed protocol. pub mod client; pub use self::client::{Client, TagStore}; /// Server bindings for a multiplexed protocol. pub mod server; pub use self::server::Server; /// A convenience wrapper that lets you take separate transport and tag store types and use them as /// a single [`client::Transport`]. #[pin_project] #[derive(Debug)] pub struct MultiplexTransport<T, S> { #[pin] transport: T, #[pin] tagger: S, } impl<T, S> MultiplexTransport<T, S> { /// Fuse together the given `transport` and `tagger` into a single `Transport`. pub fn new(transport: T, tagger: S) -> Self { MultiplexTransport { transport, tagger } } } impl<T, S, Request> Sink<Request> for MultiplexTransport<T, S> where T: Sink<Request>, { type Error = <T as Sink<Request>>::Error; fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { self.project().transport.poll_ready(cx) } fn start_send(self: Pin<&mut Self>, item: Request) -> Result<(), Self::Error> { self.project().transport.start_send(item) } fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { self.project().transport.poll_flush(cx) } fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { self.project().transport.poll_close(cx) } } impl<T, S> Stream for MultiplexTransport<T, S> where T: TryStream, { type Item = Result<<T as TryStream>::Ok, <T as TryStream>::Error>; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { self.project().transport.try_poll_next(cx) } } impl<T, S, Request> TagStore<Request, <T as TryStream>::Ok> for MultiplexTransport<T, S> where T: Sink<Request> + TryStream, S: TagStore<Request, <T as TryStream>::Ok>, { type Tag = <S as TagStore<Request, <T as TryStream>::Ok>>::Tag; fn assign_tag(self: Pin<&mut Self>, req: &mut Request) -> Self::Tag { self.project().tagger.assign_tag(req) } fn finish_tag(self: Pin<&mut Self>, rsp: &<T as TryStream>::Ok) -> Self::Tag { self.project().tagger.finish_tag(rsp) } }
rust
MIT
a364571343275473a268e9616b9c94203c9e9f14
2026-01-04T20:22:11.595151Z
false
tower-rs/tokio-tower
https://github.com/tower-rs/tokio-tower/blob/a364571343275473a268e9616b9c94203c9e9f14/src/multiplex/server.rs
src/multiplex/server.rs
use futures_core::{ready, stream::TryStream}; use futures_sink::Sink; use futures_util::stream::FuturesUnordered; use pin_project::pin_project; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use std::{error, fmt}; use tower_service::Service; /// This type provides an implementation of a Tower /// [`Service`](https://docs.rs/tokio-service/0.1/tokio_service/trait.Service.html) on top of a /// multiplexed protocol transport. In particular, it wraps a transport that implements /// `Sink<SinkItem = Response>` and `Stream<Item = Request>` with the necessary bookkeeping to /// adhere to Tower's convenient `fn(Request) -> Future<Response>` API. #[pin_project] #[derive(Debug)] pub struct Server<T, S> where T: Sink<S::Response> + TryStream, S: Service<<T as TryStream>::Ok>, { #[pin] pending: FuturesUnordered<S::Future>, #[pin] transport: T, service: S, in_flight: usize, finish: bool, } /// An error that occurred while servicing a request. pub enum Error<T, S> where T: Sink<S::Response> + TryStream, S: Service<<T as TryStream>::Ok>, { /// The underlying transport failed to produce a request. BrokenTransportRecv(<T as TryStream>::Error), /// The underlying transport failed while attempting to send a response. BrokenTransportSend(<T as Sink<S::Response>>::Error), /// The underlying service failed to process a request. Service(S::Error), } impl<T, S> fmt::Display for Error<T, S> where T: Sink<S::Response> + TryStream, S: Service<<T as TryStream>::Ok>, <T as Sink<S::Response>>::Error: fmt::Display, <T as TryStream>::Error: fmt::Display, S::Error: fmt::Display, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::BrokenTransportRecv(_) => { f.pad("underlying transport failed to produce a request") } Error::BrokenTransportSend(_) => { f.pad("underlying transport failed while attempting to send a response") } Error::Service(_) => f.pad("underlying service failed to process a request"), } } } impl<T, S> fmt::Debug for Error<T, S> where T: Sink<S::Response> + TryStream, S: Service<<T as TryStream>::Ok>, <T as Sink<S::Response>>::Error: fmt::Debug, <T as TryStream>::Error: fmt::Debug, S::Error: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::BrokenTransportRecv(ref se) => write!(f, "BrokenTransportRecv({:?})", se), Error::BrokenTransportSend(ref se) => write!(f, "BrokenTransportSend({:?})", se), Error::Service(ref se) => write!(f, "Service({:?})", se), } } } impl<T, S> error::Error for Error<T, S> where T: Sink<S::Response> + TryStream, S: Service<<T as TryStream>::Ok>, <T as Sink<S::Response>>::Error: error::Error + 'static, <T as TryStream>::Error: error::Error + 'static, S::Error: error::Error + 'static, { fn source(&self) -> Option<&(dyn error::Error + 'static)> { match *self { Error::BrokenTransportSend(ref se) => Some(se), Error::BrokenTransportRecv(ref se) => Some(se), Error::Service(ref se) => Some(se), } } } impl<T, S> Error<T, S> where T: Sink<S::Response> + TryStream, S: Service<<T as TryStream>::Ok>, { fn from_sink_error(e: <T as Sink<S::Response>>::Error) -> Self { Error::BrokenTransportSend(e) } fn from_stream_error(e: <T as TryStream>::Error) -> Self { Error::BrokenTransportRecv(e) } fn from_service_error(e: S::Error) -> Self { Error::Service(e) } } impl<T, S> Server<T, S> where T: Sink<S::Response> + TryStream, S: Service<<T as TryStream>::Ok>, { /// Construct a new [`Server`] over the given `transport` that services requests using the /// given `service`. /// /// Requests are passed to `Service::call` as they arrive, and responses are written back to /// the underlying `transport` in the order that they complete. If a later request completes /// before an earlier request, its response is still sent immediately. pub fn new(transport: T, service: S) -> Self { Server { pending: FuturesUnordered::new(), transport, service, in_flight: 0, finish: false, } } /* /// Manage incoming new transport instances using the given service constructor. /// /// For each transport that `incoming` yields, a new instance of `service` is created to /// manage requests on that transport. This is roughly equivalent to: /// /// ```rust,ignore /// incoming.map(|t| Server::multiplexed(t, service.new_service(), limit)) /// ``` pub fn serve_on<TS, SS, E>( incoming: TS, service: SS, limit: Option<usize>, ) -> impl Stream<Item = Self, Error = E> where TS: Stream<Item = T>, SS: NewService<Request = S::Request, Response = S::Response, Error = S::Error, Service = S>, E: From<TS::Error>, E: From<SS::InitError>, { incoming.map_err(E::from).and_then(move |transport| { service .new_service() .map_err(E::from) .map(move |s| Server::multiplexed(transport, s, limit)) }) } */ } impl<T, S> Future for Server<T, S> where T: Sink<S::Response> + TryStream, S: Service<<T as TryStream>::Ok>, { type Output = Result<(), Error<T, S>>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { let span = tracing::trace_span!("poll"); let _guard = span.enter(); tracing::trace!("poll"); // go through the deref so we can do partial borrows let this = self.project(); // we never move transport or pending, nor do we ever hand out &mut to it let mut transport: Pin<_> = this.transport; let mut pending: Pin<_> = this.pending; // track how many times we have iterated let mut i = 0; loop { // first, poll pending futures to see if any have produced responses // note that we only poll for completed service futures if we can send the response while let Poll::Ready(r) = transport.as_mut().poll_ready(cx) { if let Err(e) = r { return Poll::Ready(Err(Error::from_sink_error(e))); } tracing::trace!( in_flight = *this.in_flight, pending = pending.len(), "transport.ready" ); match pending.as_mut().try_poll_next(cx) { Poll::Ready(Some(Err(e))) => { return Poll::Ready(Err(Error::from_service_error(e))); } Poll::Ready(Some(Ok(rsp))) => { tracing::trace!("transport.start_send"); // try to send the response! transport .as_mut() .start_send(rsp) .map_err(Error::from_sink_error)?; *this.in_flight -= 1; } _ => { // XXX: should we "release" the poll_ready we got from the Sink? break; } } } // also try to make progress on sending tracing::trace!(finish = *this.finish, "transport.poll_flush"); if let Poll::Ready(()) = transport .as_mut() .poll_flush(cx) .map_err(Error::from_sink_error)? { if *this.finish && pending.as_mut().is_empty() { // there are no more requests // and we've finished all the work! return Poll::Ready(Ok(())); } } if *this.finish { // there's still work to be done, but there are no more requests // so no need to check the incoming transport return Poll::Pending; } // if we have run for a while without yielding, yield back so other tasks can run i += 1; if i == crate::YIELD_EVERY { // we're forcing a yield, so need to ensure we get woken up again tracing::trace!("forced yield"); cx.waker().wake_by_ref(); return Poll::Pending; } // is the service ready? tracing::trace!("service.poll_ready"); ready!(this.service.poll_ready(cx)).map_err(Error::from_service_error)?; tracing::trace!("transport.poll_next"); let rq = ready!(transport.as_mut().try_poll_next(cx)) .transpose() .map_err(Error::from_stream_error)?; if let Some(rq) = rq { // the service is ready, and we have another request! // you know what that means: pending.push(this.service.call(rq)); *this.in_flight += 1; } else { // there are no more requests coming // check one more time for responses, and then yield assert!(!*this.finish); *this.finish = true; } } } }
rust
MIT
a364571343275473a268e9616b9c94203c9e9f14
2026-01-04T20:22:11.595151Z
false
tower-rs/tokio-tower
https://github.com/tower-rs/tokio-tower/blob/a364571343275473a268e9616b9c94203c9e9f14/src/pipeline/client.rs
src/pipeline/client.rs
use crate::mediator; use crate::wrappers::*; use crate::Error; use futures_core::{ready, stream::TryStream}; use futures_sink::Sink; use pin_project::pin_project; use std::collections::VecDeque; use std::fmt; use std::future::Future; use std::marker::PhantomData; use std::pin::Pin; use std::sync::{atomic, Arc}; use std::task::{Context, Poll}; use tower_service::Service; // ===== Client ===== /// This type provides an implementation of a Tower /// [`Service`](https://docs.rs/tokio-service/0.1/tokio_service/trait.Service.html) on top of a /// request-at-a-time protocol transport. In particular, it wraps a transport that implements /// `Sink<SinkItem = Request>` and `Stream<Item = Response>` with the necessary bookkeeping to /// adhere to Tower's convenient `fn(Request) -> Future<Response>` API. pub struct Client<T, E, Request> where T: Sink<Request> + TryStream, { mediator: mediator::Sender<ClientRequest<T, Request>>, in_flight: Arc<atomic::AtomicUsize>, _error: PhantomData<fn(E)>, } impl<T, E, Request> fmt::Debug for Client<T, E, Request> where T: Sink<Request> + TryStream, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Client") .field("mediator", &self.mediator) .field("in_flight", &self.in_flight) .finish() } } // ===== ClientInner ===== struct Pending<Item> { tx: tokio::sync::oneshot::Sender<ClientResponse<Item>>, span: tracing::Span, } #[pin_project] struct ClientInner<T, E, Request> where T: Sink<Request> + TryStream, { mediator: mediator::Receiver<ClientRequest<T, Request>>, responses: VecDeque<Pending<T::Ok>>, #[pin] transport: T, in_flight: Arc<atomic::AtomicUsize>, finish: bool, rx_only: bool, #[allow(unused)] error: PhantomData<fn(E)>, } impl<T, E, Request> Client<T, E, Request> where T: Sink<Request> + TryStream + Send + 'static, E: From<Error<T, Request>>, E: 'static + Send, Request: 'static + Send, T::Ok: 'static + Send, { /// Construct a new [`Client`] over the given `transport`. /// /// If the Client errors, the error is dropped when `new` is used -- use `with_error_handler` /// to handle such an error explicitly. pub fn new(transport: T) -> Self where { Self::with_error_handler(transport, |_| {}) } /// Construct a new [`Client`] over the given `transport`. /// /// If the `Client` errors, its error is passed to `on_service_error`. pub fn with_error_handler<F>(transport: T, on_service_error: F) -> Self where F: FnOnce(E) + Send + 'static, { let (tx, rx) = mediator::new(); let in_flight = Arc::new(atomic::AtomicUsize::new(0)); tokio::spawn({ let c = ClientInner { mediator: rx, responses: Default::default(), transport, in_flight: in_flight.clone(), error: PhantomData::<fn(E)>, finish: false, rx_only: false, }; async move { if let Err(e) = c.await { on_service_error(e); } } }); Client { mediator: tx, in_flight, _error: PhantomData, } } } impl<T, E, Request> Future for ClientInner<T, E, Request> where T: Sink<Request> + TryStream, E: From<Error<T, Request>>, E: 'static + Send, Request: 'static + Send, T::Ok: 'static + Send, { type Output = Result<(), E>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { // go through the deref so we can do partial borrows let this = self.project(); // we never move transport, nor do we ever hand out &mut to it let mut transport: Pin<_> = this.transport; // track how many times we have iterated let mut i = 0; if !*this.finish { while let Poll::Ready(r) = transport.as_mut().poll_ready(cx) { if let Err(e) = r { return Poll::Ready(Err(E::from(Error::from_sink_error(e)))); } // send more requests if we have them match this.mediator.try_recv(cx) { Poll::Ready(Some(ClientRequest { req, span: _span, res, })) => { let guard = _span.enter(); tracing::trace!("request received by worker; sending to Sink"); transport .as_mut() .start_send(req) .map_err(Error::from_sink_error)?; tracing::trace!("request sent"); drop(guard); this.responses.push_back(Pending { tx: res, span: _span, }); this.in_flight.fetch_add(1, atomic::Ordering::AcqRel); // if we have run for a while without yielding, yield so we can make progress i += 1; if i == crate::YIELD_EVERY { // we're forcing a yield, so need to ensure we get woken up again cx.waker().wake_by_ref(); // we still want to execute the code below the loop break; } } Poll::Ready(None) => { // XXX: should we "give up" the Sink::poll_ready here? *this.finish = true; break; } Poll::Pending => { // XXX: should we "give up" the Sink::poll_ready here? break; } } } } if this.in_flight.load(atomic::Ordering::Acquire) != 0 && !*this.rx_only { // flush out any stuff we've sent in the past // don't return on NotReady since we have to check for responses too if *this.finish { // we're closing up shop! // // poll_close() implies poll_flush() let r = transport .as_mut() .poll_close(cx) .map_err(Error::from_sink_error)?; if r.is_ready() { // now that close has completed, we should never send anything again // we only need to receive to make the in-flight requests complete *this.rx_only = true; } } else { let _ = transport .as_mut() .poll_flush(cx) .map_err(Error::from_sink_error)?; } } // and start looking for replies. // // note that we *could* have this just be a loop, but we don't want to poll the stream // if we know there's nothing for it to produce. while this.in_flight.load(atomic::Ordering::Acquire) != 0 { match ready!(transport.as_mut().try_poll_next(cx)) .transpose() .map_err(Error::from_stream_error)? { Some(r) => { // ignore send failures // the client may just no longer care about the response let pending = this.responses.pop_front().ok_or(Error::Desynchronized)?; tracing::trace!(parent: &pending.span, "response arrived; forwarding"); let sender = pending.tx; let _ = sender.send(ClientResponse { response: r, span: pending.span, }); this.in_flight.fetch_sub(1, atomic::Ordering::AcqRel); } None => { // the transport terminated while we were waiting for a response! // TODO: it'd be nice if we could return the transport here.. return Poll::Ready(Err(E::from(Error::BrokenTransportRecv(None)))); } } } if *this.finish && this.in_flight.load(atomic::Ordering::Acquire) == 0 { if *this.rx_only { // we have already closed the send side. } else { // we're completely done once close() finishes! ready!(transport.poll_close(cx)).map_err(Error::from_sink_error)?; } return Poll::Ready(Ok(())); } // to get here, we must have no requests in flight and have gotten a NotReady from // self.mediator.try_recv or self.transport.start_send. we *could* also have messages // waiting to be sent (transport.poll_complete), but if that's the case it must also have // returned NotReady. so, at this point, we know that all of our subtasks are either done // or have returned NotReady, so the right thing for us to do is return NotReady too! Poll::Pending } } impl<T, E, Request> Service<Request> for Client<T, E, Request> where T: Sink<Request> + TryStream, E: From<Error<T, Request>>, E: 'static + Send, Request: 'static + Send, T: 'static, T::Ok: 'static + Send, { type Response = T::Ok; type Error = E; type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), E>> { Poll::Ready(ready!(self.mediator.poll_ready(cx)).map_err(|_| E::from(Error::ClientDropped))) } fn call(&mut self, req: Request) -> Self::Future { let (tx, rx) = tokio::sync::oneshot::channel(); let span = tracing::Span::current(); tracing::trace!("issuing request"); let req = ClientRequest { req, span, res: tx }; let r = self.mediator.try_send(req); Box::pin(async move { match r { Ok(()) => match rx.await { Ok(r) => { tracing::trace!(parent: &r.span, "response returned"); Ok(r.response) } Err(_) => Err(E::from(Error::ClientDropped)), }, Err(_) => Err(E::from(Error::TransportFull)), } }) } } impl<T, E, Request> tower::load::Load for Client<T, E, Request> where T: Sink<Request> + TryStream, { type Metric = usize; fn load(&self) -> Self::Metric { self.in_flight.load(atomic::Ordering::Acquire) } }
rust
MIT
a364571343275473a268e9616b9c94203c9e9f14
2026-01-04T20:22:11.595151Z
false
tower-rs/tokio-tower
https://github.com/tower-rs/tokio-tower/blob/a364571343275473a268e9616b9c94203c9e9f14/src/pipeline/mod.rs
src/pipeline/mod.rs
//! In a pipelined protocol, the server responds to client requests in the order they were sent. //! Many requests can be in flight at the same time, but no request sees a response until all //! previous requests have been satisfied. Pipelined protocols can experience head-of-line //! blocking wherein a slow-to-process request prevents any subsequent request from being //! processed, but are often to easier to implement on the server side, and provide clearer request //! ordering semantics. Example pipelined protocols include HTTP/1.1, MySQL, and Redis. //! //! Note: pipelining with the max number of in-flight requests set to 1 implies that for each //! request, the response must be received before sending another request on the same connection. /// Client bindings for a pipelined protocol. pub mod client; pub use self::client::Client; /// Server bindings for a pipelined protocol. pub mod server; pub use self::server::Server;
rust
MIT
a364571343275473a268e9616b9c94203c9e9f14
2026-01-04T20:22:11.595151Z
false
tower-rs/tokio-tower
https://github.com/tower-rs/tokio-tower/blob/a364571343275473a268e9616b9c94203c9e9f14/src/pipeline/server.rs
src/pipeline/server.rs
use futures_core::{ready, stream::TryStream}; use futures_sink::Sink; use futures_util::stream::FuturesOrdered; use pin_project::pin_project; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use std::{error, fmt}; use tower_service::Service; /// This type provides an implementation of a Tower /// [`Service`](https://docs.rs/tokio-service/0.1/tokio_service/trait.Service.html) on top of a /// request-at-a-time protocol transport. In particular, it wraps a transport that implements /// `Sink<SinkItem = Response>` and `Stream<Item = Request>` with the necessary bookkeeping to /// adhere to Tower's convenient `fn(Request) -> Future<Response>` API. #[pin_project] #[derive(Debug)] pub struct Server<T, S> where T: Sink<S::Response> + TryStream, S: Service<<T as TryStream>::Ok>, { #[pin] pending: FuturesOrdered<S::Future>, #[pin] transport: T, service: S, in_flight: usize, finish: bool, } /// An error that occurred while servicing a request. pub enum Error<T, S> where T: Sink<S::Response> + TryStream, S: Service<<T as TryStream>::Ok>, { /// The underlying transport failed to produce a request. BrokenTransportRecv(<T as TryStream>::Error), /// The underlying transport failed while attempting to send a response. BrokenTransportSend(<T as Sink<S::Response>>::Error), /// The underlying service failed to process a request. Service(S::Error), } impl<T, S> fmt::Display for Error<T, S> where T: Sink<S::Response> + TryStream, S: Service<<T as TryStream>::Ok>, <T as Sink<S::Response>>::Error: fmt::Display, <T as TryStream>::Error: fmt::Display, S::Error: fmt::Display, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::BrokenTransportRecv(_) => { f.pad("underlying transport failed to produce a request") } Error::BrokenTransportSend(_) => { f.pad("underlying transport failed while attempting to send a response") } Error::Service(_) => f.pad("underlying service failed to process a request"), } } } impl<T, S> fmt::Debug for Error<T, S> where T: Sink<S::Response> + TryStream, S: Service<<T as TryStream>::Ok>, <T as Sink<S::Response>>::Error: fmt::Debug, <T as TryStream>::Error: fmt::Debug, S::Error: fmt::Debug, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::BrokenTransportRecv(ref se) => write!(f, "BrokenTransportRecv({:?})", se), Error::BrokenTransportSend(ref se) => write!(f, "BrokenTransportSend({:?})", se), Error::Service(ref se) => write!(f, "Service({:?})", se), } } } impl<T, S> error::Error for Error<T, S> where T: Sink<S::Response> + TryStream, S: Service<<T as TryStream>::Ok>, <T as Sink<S::Response>>::Error: error::Error + 'static, <T as TryStream>::Error: error::Error + 'static, S::Error: error::Error + 'static, { fn source(&self) -> Option<&(dyn error::Error + 'static)> { match *self { Error::BrokenTransportSend(ref se) => Some(se), Error::BrokenTransportRecv(ref se) => Some(se), Error::Service(ref se) => Some(se), } } } impl<T, S> Error<T, S> where T: Sink<S::Response> + TryStream, S: Service<<T as TryStream>::Ok>, { fn from_sink_error(e: <T as Sink<S::Response>>::Error) -> Self { Error::BrokenTransportSend(e) } fn from_stream_error(e: <T as TryStream>::Error) -> Self { Error::BrokenTransportRecv(e) } fn from_service_error(e: S::Error) -> Self { Error::Service(e) } } impl<T, S> Server<T, S> where T: Sink<S::Response> + TryStream, S: Service<<T as TryStream>::Ok>, { /// Construct a new [`Server`] over the given `transport` that services requests using the /// given `service`. /// /// Requests are passed to `Service::call` as they arrive, and responses are written back to /// the underlying `transport` in the order that the requests arrive. If a later request /// completes before an earlier request, its result will be buffered until all preceding /// requests have been sent. pub fn new(transport: T, service: S) -> Self { Server { pending: FuturesOrdered::new(), transport, service, in_flight: 0, finish: false, } } /* /// Manage incoming new transport instances using the given service constructor. /// /// For each transport that `incoming` yields, a new instance of `service` is created to /// manage requests on that transport. This is roughly equivalent to: /// /// ```rust,ignore /// incoming.map(|t| Server::pipelined(t, service.new_service(), limit)) /// ``` pub fn serve_on<TS, SS, E>( incoming: TS, service: SS, limit: Option<usize>, ) -> impl Stream<Item = Self, Error = E> where TS: Stream<Item = T>, SS: NewService<Request = S::Request, Response = S::Response, Error = S::Error, Service = S>, E: From<TS::Error>, E: From<SS::InitError>, { incoming.map_err(E::from).and_then(move |transport| { service .new_service() .map_err(E::from) .map(move |s| Server::pipelined(transport, s, limit)) }) } */ } impl<T, S> Future for Server<T, S> where T: Sink<S::Response> + TryStream, S: Service<<T as TryStream>::Ok>, { type Output = Result<(), Error<T, S>>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { let span = tracing::trace_span!("poll"); let _guard = span.enter(); tracing::trace!("poll"); // go through the deref so we can do partial borrows let this = self.project(); // we never move transport or pending, nor do we ever hand out &mut to it let mut transport: Pin<_> = this.transport; let mut pending: Pin<_> = this.pending; // track how many times we have iterated let mut i = 0; loop { // first, poll pending futures to see if any have produced responses // note that we only poll for completed service futures if we can send the response while let Poll::Ready(r) = transport.as_mut().poll_ready(cx) { if let Err(e) = r { return Poll::Ready(Err(Error::from_sink_error(e))); } tracing::trace!( in_flight = *this.in_flight, pending = pending.len(), "transport.ready" ); match pending.as_mut().try_poll_next(cx) { Poll::Ready(Some(Err(e))) => { return Poll::Ready(Err(Error::from_service_error(e))); } Poll::Ready(Some(Ok(rsp))) => { tracing::trace!("transport.start_send"); // try to send the response! transport .as_mut() .start_send(rsp) .map_err(Error::from_sink_error)?; *this.in_flight -= 1; } _ => { // XXX: should we "release" the poll_ready we got from the Sink? break; } } } // also try to make progress on sending tracing::trace!(finish = *this.finish, "transport.poll_flush"); if let Poll::Ready(()) = transport .as_mut() .poll_flush(cx) .map_err(Error::from_sink_error)? { if *this.finish && pending.as_mut().is_empty() { // there are no more requests // and we've finished all the work! return Poll::Ready(Ok(())); } } if *this.finish { // there's still work to be done, but there are no more requests // so no need to check the incoming transport return Poll::Pending; } // if we have run for a while without yielding, yield back so other tasks can run i += 1; if i == crate::YIELD_EVERY { // we're forcing a yield, so need to ensure we get woken up again tracing::trace!("forced yield"); cx.waker().wake_by_ref(); return Poll::Pending; } // is the service ready? tracing::trace!("service.poll_ready"); ready!(this.service.poll_ready(cx)).map_err(Error::from_service_error)?; tracing::trace!("transport.poll_next"); let rq = ready!(transport.as_mut().try_poll_next(cx)) .transpose() .map_err(Error::from_stream_error)?; if let Some(rq) = rq { // the service is ready, and we have another request! // you know what that means: pending.push_back(this.service.call(rq)); *this.in_flight += 1; } else { // there are no more requests coming // check one more time for responses, and then yield assert!(!*this.finish); *this.finish = true; } } } }
rust
MIT
a364571343275473a268e9616b9c94203c9e9f14
2026-01-04T20:22:11.595151Z
false
tower-rs/tokio-tower
https://github.com/tower-rs/tokio-tower/blob/a364571343275473a268e9616b9c94203c9e9f14/tests/lib.rs
tests/lib.rs
#[macro_use] extern crate serde_derive; use futures_util::future::poll_fn; use std::task::{Context, Poll}; use tower_service::Service; async fn ready<S: Service<Request>, Request>(svc: &mut S) -> Result<(), S::Error> { poll_fn(|cx| svc.poll_ready(cx)).await } #[derive(Serialize, Deserialize)] pub struct Request { tag: usize, value: u32, } impl Request { pub fn new(val: u32) -> Self { Request { tag: 0, value: val } } pub fn check(&self, expected: u32) { assert_eq!(self.value, expected); } } #[derive(Serialize, Deserialize)] pub struct Response { tag: usize, value: u32, } impl From<Request> for Response { fn from(r: Request) -> Response { Response { tag: r.tag, value: r.value, } } } impl Response { pub fn check(&self, expected: u32) { assert_eq!(self.value, expected); } pub fn get_tag(&self) -> usize { self.tag } } impl Request { pub fn set_tag(&mut self, tag: usize) { self.tag = tag; } } struct PanicError; use std::fmt; impl<E> From<E> for PanicError where E: fmt::Debug, { fn from(e: E) -> Self { panic!("{:?}", e) } } fn unwrap<T>(r: Result<T, PanicError>) -> T { if let Ok(t) = r { t } else { unreachable!(); } } struct EchoService; impl Service<Request> for EchoService { type Response = Response; type Error = (); type Future = futures_util::future::Ready<Result<Self::Response, Self::Error>>; fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> { Poll::Ready(Ok(())) } fn call(&mut self, r: Request) -> Self::Future { futures_util::future::ok(Response::from(r)) } } mod multiplex; mod pipeline;
rust
MIT
a364571343275473a268e9616b9c94203c9e9f14
2026-01-04T20:22:11.595151Z
false
tower-rs/tokio-tower
https://github.com/tower-rs/tokio-tower/blob/a364571343275473a268e9616b9c94203c9e9f14/tests/multiplex/mod.rs
tests/multiplex/mod.rs
use crate::{ready, unwrap, EchoService, PanicError, Request, Response}; use async_bincode::AsyncBincodeStream; use futures_util::pin_mut; use slab::Slab; use std::pin::Pin; use tokio::net::{TcpListener, TcpStream}; use tokio_tower::multiplex::{ client::VecDequePendingStore, Client, MultiplexTransport, Server, TagStore, }; use tower_service::Service; use tower_test::mock; pub(crate) struct SlabStore(Slab<()>); impl TagStore<Request, Response> for SlabStore { type Tag = usize; fn assign_tag(mut self: Pin<&mut Self>, request: &mut Request) -> usize { let tag = self.0.insert(()); request.set_tag(tag); tag } fn finish_tag(mut self: Pin<&mut Self>, response: &Response) -> usize { let tag = response.get_tag(); self.0.remove(tag); tag } } #[tokio::test] async fn integration() { let rx = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = rx.local_addr().unwrap(); // connect let tx = TcpStream::connect(&addr).await.unwrap(); let tx = AsyncBincodeStream::from(tx).for_async(); let mut tx: Client<_, PanicError, _> = Client::builder(MultiplexTransport::new(tx, SlabStore(Slab::new()))).build(); // accept let (rx, _) = rx.accept().await.unwrap(); let rx = AsyncBincodeStream::from(rx).for_async(); let server = Server::new(rx, EchoService); tokio::spawn(async move { server.await.unwrap() }); unwrap(ready(&mut tx).await); let fut1 = tx.call(Request::new(1)); unwrap(ready(&mut tx).await); let fut2 = tx.call(Request::new(2)); unwrap(ready(&mut tx).await); let fut3 = tx.call(Request::new(3)); unwrap(fut1.await).check(1); unwrap(fut2.await).check(2); unwrap(fut3.await).check(3); } #[tokio::test] async fn racing_close() { let rx = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = rx.local_addr().unwrap(); // connect let tx = TcpStream::connect(&addr).await.unwrap(); let tx = AsyncBincodeStream::from(tx).for_async(); let mut tx: Client<_, PanicError, _> = Client::builder(MultiplexTransport::new(tx, SlabStore(Slab::new()))) .pending_store(VecDequePendingStore::default()) .on_service_error(|_| {}) .build(); let (service, handle) = mock::pair::<Request, Response>(); pin_mut!(handle); // accept let (rx, _) = rx.accept().await.unwrap(); let rx = AsyncBincodeStream::from(rx).for_async(); let server = Server::new(rx, service); tokio::spawn(async move { server.await.unwrap() }); // we now want to set up a situation where a request has been sent to the server, and then the // client goes away while the request is still outstanding. in this case, the connection to the // server will be shut down in the write direction, but not in the read direction. // send a couple of request unwrap(ready(&mut tx).await); let fut1 = tx.call(Request::new(1)); unwrap(ready(&mut tx).await); let fut2 = tx.call(Request::new(2)); unwrap(ready(&mut tx).await); // drop client to indicate no more requests drop(tx); // respond to both requests one after the other // the response to the first should trigger the state machine to handle // a read after it has poll_closed on the transport. let (req1, rsp1) = handle.as_mut().next_request().await.unwrap(); req1.check(1); rsp1.send_response(Response::from(req1)); unwrap(fut1.await).check(1); let (req2, rsp2) = handle.as_mut().next_request().await.unwrap(); req2.check(2); rsp2.send_response(Response::from(req2)); unwrap(fut2.await).check(2); }
rust
MIT
a364571343275473a268e9616b9c94203c9e9f14
2026-01-04T20:22:11.595151Z
false
tower-rs/tokio-tower
https://github.com/tower-rs/tokio-tower/blob/a364571343275473a268e9616b9c94203c9e9f14/tests/pipeline/client.rs
tests/pipeline/client.rs
use crate::{ready, unwrap, PanicError, Request, Response}; use async_bincode::{AsyncBincodeReader, AsyncBincodeStream, AsyncBincodeWriter}; use futures_util::{sink::SinkExt, stream::StreamExt}; use tokio::net::{TcpListener, TcpStream}; use tokio_tower::pipeline::Client; use tower_service::Service; #[tokio::test] async fn it_works() { let rx = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = rx.local_addr().unwrap(); // connect let tx = TcpStream::connect(&addr).await.unwrap(); let tx: AsyncBincodeStream<_, Response, _, _> = AsyncBincodeStream::from(tx).for_async(); let mut tx: Client<_, PanicError, _> = Client::new(tx); tokio::spawn(async move { loop { let (mut stream, _) = rx.accept().await.unwrap(); tokio::spawn(async move { let (r, w) = stream.split(); let mut r: AsyncBincodeReader<_, Request> = AsyncBincodeReader::from(r); let mut w: AsyncBincodeWriter<_, Response, _> = AsyncBincodeWriter::from(w).for_async(); loop { let req = r.next().await.unwrap().unwrap(); w.send(Response::from(req)).await.unwrap(); } }); } }); unwrap(ready(&mut tx).await); unwrap(tx.call(Request::new(1)).await).check(1); }
rust
MIT
a364571343275473a268e9616b9c94203c9e9f14
2026-01-04T20:22:11.595151Z
false
tower-rs/tokio-tower
https://github.com/tower-rs/tokio-tower/blob/a364571343275473a268e9616b9c94203c9e9f14/tests/pipeline/mod.rs
tests/pipeline/mod.rs
use crate::{ready, unwrap, EchoService, PanicError, Request, Response}; use async_bincode::AsyncBincodeStream; use futures_util::pin_mut; use tokio::net::{TcpListener, TcpStream}; use tokio_tower::pipeline::{Client, Server}; use tower_service::Service; use tower_test::mock; mod client; #[tokio::test] async fn integration() { let rx = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = rx.local_addr().unwrap(); // connect let tx = TcpStream::connect(&addr).await.unwrap(); let tx: AsyncBincodeStream<_, Response, _, _> = AsyncBincodeStream::from(tx).for_async(); let mut tx: Client<_, PanicError, _> = Client::new(tx); // accept let (rx, _) = rx.accept().await.unwrap(); let rx = AsyncBincodeStream::from(rx).for_async(); let server = Server::new(rx, EchoService); tokio::spawn(async move { server.await.unwrap() }); unwrap(ready(&mut tx).await); let fut1 = tx.call(Request::new(1)); unwrap(ready(&mut tx).await); let fut2 = tx.call(Request::new(2)); unwrap(ready(&mut tx).await); let fut3 = tx.call(Request::new(3)); unwrap(fut1.await).check(1); unwrap(fut2.await).check(2); unwrap(fut3.await).check(3); } #[tokio::test] async fn racing_close() { let rx = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = rx.local_addr().unwrap(); // connect let tx = TcpStream::connect(&addr).await.unwrap(); let tx: AsyncBincodeStream<_, Response, _, _> = AsyncBincodeStream::from(tx).for_async(); let mut tx: Client<_, PanicError, _> = Client::new(tx); let (service, handle) = mock::pair::<Request, Response>(); pin_mut!(handle); // accept let (rx, _) = rx.accept().await.unwrap(); let rx = AsyncBincodeStream::from(rx).for_async(); let server = Server::new(rx, service); tokio::spawn(async move { server.await.unwrap() }); // we now want to set up a situation where a request has been sent to the server, and then the // client goes away while the request is still outstanding. in this case, the connection to the // server will be shut down in the write direction, but not in the read direction. // send a couple of request unwrap(ready(&mut tx).await); let fut1 = tx.call(Request::new(1)); unwrap(ready(&mut tx).await); let fut2 = tx.call(Request::new(2)); unwrap(ready(&mut tx).await); // drop client to indicate no more requests drop(tx); // respond to both requests one after the other // the response to the first should trigger the state machine to handle // a read after it has poll_closed on the transport. let (req1, rsp1) = handle.as_mut().next_request().await.unwrap(); req1.check(1); rsp1.send_response(Response::from(req1)); unwrap(fut1.await).check(1); let (req2, rsp2) = handle.as_mut().next_request().await.unwrap(); req2.check(2); rsp2.send_response(Response::from(req2)); unwrap(fut2.await).check(2); }
rust
MIT
a364571343275473a268e9616b9c94203c9e9f14
2026-01-04T20:22:11.595151Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/build.rs
libmaestro/build.rs
use std::io::Result; fn main() -> Result<()> { prost_build::compile_protos(&["proto/pw.rpc.packet.proto"], &["proto/"])?; prost_build::compile_protos(&["proto/maestro_pw.proto"], &["proto/"])?; Ok(()) }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/lib.rs
libmaestro/src/lib.rs
//! Library for the Maestro protocol used to change settings (ANC, equalizer, //! etc.) on the Google Pixel Buds Pro. Might support other Pixel Buds, might //! not. use uuid::{uuid, Uuid}; /// UUID under which the Maestro protocol is advertised. /// /// Defined as `25e97ff7-24ce-4c4c-8951-f764a708f7b5`. pub const UUID: Uuid = uuid!("25e97ff7-24ce-4c4c-8951-f764a708f7b5"); pub mod hdlc; pub mod protocol; pub mod pwrpc; pub mod service;
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/service/settings.rs
libmaestro/src/service/settings.rs
use num_enum::{IntoPrimitive, FromPrimitive}; use crate::protocol::types; #[repr(i32)] #[derive(Debug, Clone, Copy, PartialEq, Eq, IntoPrimitive, FromPrimitive)] pub enum SettingId { AutoOtaEnable = 1, OhdEnable = 2, OobeIsFinished = 3, GestureEnable = 4, DiagnosticsEnable = 5, OobeMode = 6, GestureControl = 7, AncAccessibilityMode = 8, AncrStateOneBud = 9, AncrStateTwoBuds = 10, MultipointEnable = 11, AncrGestureLoop = 12, CurrentAncrState = 13, OttsMode = 14, VolumeEqEnable = 15, CurrentUserEq = 16, VolumeAsymmetry = 17, LastSavedUserEq = 18, SumToMono = 19, VolumeExposureNotifications = 21, SpeechDetection = 22, #[num_enum(catch_all)] Unknown(i32), } #[derive(Debug, Clone, PartialEq)] pub enum SettingValue { AutoOtaEnable(bool), OhdEnable(bool), OobeIsFinished(bool), GestureEnable(bool), DiagnosticsEnable(bool), OobeMode(bool), GestureControl(GestureControl), MultipointEnable(bool), AncrGestureLoop(AncrGestureLoop), CurrentAncrState(AncState), OttsMode(i32), VolumeEqEnable(bool), CurrentUserEq(EqBands), VolumeAsymmetry(VolumeAsymmetry), SumToMono(bool), VolumeExposureNotifications(bool), SpeechDetection(bool), } impl SettingValue { pub fn id(&self) -> SettingId { match self { SettingValue::AutoOtaEnable(_) => SettingId::AutoOtaEnable, SettingValue::OhdEnable(_) => SettingId::OhdEnable, SettingValue::OobeIsFinished(_) => SettingId::OobeIsFinished, SettingValue::GestureEnable(_) => SettingId::GestureEnable, SettingValue::DiagnosticsEnable(_) => SettingId::DiagnosticsEnable, SettingValue::OobeMode(_) => SettingId::OobeMode, SettingValue::GestureControl(_) => SettingId::GestureControl, SettingValue::MultipointEnable(_) => SettingId::MultipointEnable, SettingValue::AncrGestureLoop(_) => SettingId::AncrGestureLoop, SettingValue::CurrentAncrState(_) => SettingId::CurrentAncrState, SettingValue::OttsMode(_) => SettingId::OttsMode, SettingValue::VolumeEqEnable(_) => SettingId::VolumeEqEnable, SettingValue::CurrentUserEq(_) => SettingId::CurrentUserEq, SettingValue::VolumeAsymmetry(_) => SettingId::VolumeAsymmetry, SettingValue::SumToMono(_) => SettingId::SumToMono, SettingValue::VolumeExposureNotifications(_) => SettingId::VolumeExposureNotifications, SettingValue::SpeechDetection(_) => SettingId::SpeechDetection, } } } impl From<types::setting_value::ValueOneof> for SettingValue { fn from(value: crate::protocol::types::setting_value::ValueOneof) -> Self { use types::setting_value::ValueOneof; match value { ValueOneof::AutoOtaEnable(x) => SettingValue::AutoOtaEnable(x), ValueOneof::OhdEnable(x) => SettingValue::OhdEnable(x), ValueOneof::OobeIsFinished(x) => SettingValue::OobeIsFinished(x), ValueOneof::GestureEnable(x) => SettingValue::GestureEnable(x), ValueOneof::DiagnosticsEnable(x) => SettingValue::DiagnosticsEnable(x), ValueOneof::OobeMode(x) => SettingValue::OobeMode(x), ValueOneof::GestureControl(x) => SettingValue::GestureControl(GestureControl::from(x)), ValueOneof::MultipointEnable(x) => SettingValue::MultipointEnable(x), ValueOneof::AncrGestureLoop(x) => SettingValue::AncrGestureLoop(AncrGestureLoop::from(x)), ValueOneof::CurrentAncrState(x) => SettingValue::CurrentAncrState(AncState::from_primitive(x)), ValueOneof::OttsMode(x) => SettingValue::OttsMode(x), ValueOneof::VolumeEqEnable(x) => SettingValue::VolumeEqEnable(x), ValueOneof::CurrentUserEq(x) => SettingValue::CurrentUserEq(EqBands::from(x)), ValueOneof::VolumeAsymmetry(x) => SettingValue::VolumeAsymmetry(VolumeAsymmetry::from_raw(x)), ValueOneof::SumToMono(x) => SettingValue::SumToMono(x), ValueOneof::VolumeExposureNotifications(x) => SettingValue::VolumeExposureNotifications(x), ValueOneof::SpeechDetection(x) => SettingValue::SpeechDetection(x), } } } impl From<SettingValue> for types::setting_value::ValueOneof { fn from(value: SettingValue) -> Self { use types::setting_value::ValueOneof; match value { SettingValue::AutoOtaEnable(x) => ValueOneof::AutoOtaEnable(x), SettingValue::OhdEnable(x) => ValueOneof::OhdEnable(x), SettingValue::OobeIsFinished(x) => ValueOneof::OobeIsFinished(x), SettingValue::GestureEnable(x) => ValueOneof::GestureEnable(x), SettingValue::DiagnosticsEnable(x) => ValueOneof::DiagnosticsEnable(x), SettingValue::OobeMode(x) => ValueOneof::OobeMode(x), SettingValue::GestureControl(x) => ValueOneof::GestureControl(x.into()), SettingValue::MultipointEnable(x) => ValueOneof::MultipointEnable(x), SettingValue::AncrGestureLoop(x) => ValueOneof::AncrGestureLoop(x.into()), SettingValue::CurrentAncrState(x) => ValueOneof::CurrentAncrState(x.into()), SettingValue::OttsMode(x) => ValueOneof::OttsMode(x), SettingValue::VolumeEqEnable(x) => ValueOneof::VolumeEqEnable(x), SettingValue::CurrentUserEq(x) => ValueOneof::CurrentUserEq(x.into()), SettingValue::VolumeAsymmetry(x) => ValueOneof::VolumeAsymmetry(x.raw()), SettingValue::SumToMono(x) => ValueOneof::SumToMono(x), SettingValue::VolumeExposureNotifications(x) => ValueOneof::VolumeExposureNotifications(x), SettingValue::SpeechDetection(x) => ValueOneof::SpeechDetection(x), } } } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct GestureControl { pub left: RegularActionTarget, pub right: RegularActionTarget, } impl From<types::GestureControl> for GestureControl { fn from(value: types::GestureControl) -> Self { let left = value.left .and_then(|v| v.value_oneof) .map(|types::device_gesture_control::ValueOneof::Type(x)| x) .map(|v| RegularActionTarget::from_primitive(v.value)) .unwrap_or(RegularActionTarget::Unknown(-1)); let right = value.right .and_then(|v| v.value_oneof) .map(|types::device_gesture_control::ValueOneof::Type(x)| x) .map(|v| RegularActionTarget::from_primitive(v.value)) .unwrap_or(RegularActionTarget::Unknown(-1)); GestureControl { left, right } } } impl From<GestureControl> for types::GestureControl { fn from(value: GestureControl) -> Self { use types::device_gesture_control::ValueOneof; let left = types::DeviceGestureControl { value_oneof: Some(ValueOneof::Type(types::GestureControlType { value: value.left.into(), })), }; let right = types::DeviceGestureControl { value_oneof: Some(ValueOneof::Type(types::GestureControlType { value: value.right.into(), })), }; Self { left: Some(left), right: Some(right), } } } impl Default for GestureControl { fn default() -> Self { Self { left: RegularActionTarget::AncControl, right: RegularActionTarget::AncControl, } } } impl std::fmt::Display for GestureControl { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "left: {}, right: {}", self.left, self.right) } } #[repr(i32)] #[derive(Debug, Clone, Copy, PartialEq, Eq, IntoPrimitive, FromPrimitive)] pub enum RegularActionTarget { CheckNotifications = 1, PreviousTrackRepeat = 2, NextTrack = 3, PlayPauseTrack = 4, AncControl = 5, AssistantQuery = 6, #[num_enum(catch_all)] Unknown(i32), } impl RegularActionTarget { pub fn as_str(&self) -> &'static str { match self { RegularActionTarget::CheckNotifications => "check-notifications", RegularActionTarget::PreviousTrackRepeat => "previous", RegularActionTarget::NextTrack => "next", RegularActionTarget::PlayPauseTrack => "play-pause", RegularActionTarget::AncControl => "anc", RegularActionTarget::AssistantQuery => "assistant", RegularActionTarget::Unknown(_) => "unknown", } } } impl std::fmt::Display for RegularActionTarget { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { RegularActionTarget::CheckNotifications => write!(f, "check-notifications"), RegularActionTarget::PreviousTrackRepeat => write!(f, "previous"), RegularActionTarget::NextTrack => write!(f, "next"), RegularActionTarget::PlayPauseTrack => write!(f, "play-pause"), RegularActionTarget::AncControl => write!(f, "anc"), RegularActionTarget::AssistantQuery => write!(f, "assistant"), RegularActionTarget::Unknown(x) => write!(f, "unknown ({x})"), } } } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct AncrGestureLoop { pub active: bool, pub off: bool, pub aware: bool, pub adaptive: bool, } impl AncrGestureLoop { pub fn is_valid(&self) -> bool { // at least two need to be set (self.active as u32 + self.off as u32 + self.aware as u32 + self.adaptive as u32) >= 2 } } impl From<types::AncrGestureLoop> for AncrGestureLoop { fn from(other: types::AncrGestureLoop) -> Self { AncrGestureLoop { active: other.active, off: other.off, aware: other.aware, adaptive: other.adaptive } } } impl From<AncrGestureLoop> for types::AncrGestureLoop { fn from(other: AncrGestureLoop) -> Self { Self { active: other.active, off: other.off, aware: other.aware, adaptive: other.adaptive, } } } impl std::fmt::Display for AncrGestureLoop { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut n = 0; write!(f, "[")?; if self.active { write!(f, "active")?; n += 1; } if self.off { if n > 0 { write!(f, ", ")?; } write!(f, "off")?; n += 1; } if self.aware { if n > 0 { write!(f, ", ")?; } write!(f, "aware")?; } if self.adaptive { if n > 0 { write!(f, ", ")?; } write!(f, "adaptive")?; } write!(f, "]") } } #[repr(i32)] #[derive(Debug, Clone, Copy, PartialEq, Eq, IntoPrimitive, FromPrimitive)] pub enum AncState { Off = 1, Active = 2, Aware = 3, Adaptive = 4, #[num_enum(catch_all)] Unknown(i32), } impl AncState { pub fn as_str(&self) -> &'static str { match self { AncState::Off => "off", AncState::Active => "active", AncState::Aware => "aware", AncState::Adaptive => "adaptive", AncState::Unknown(_) => "unknown", } } } // #[derive(Default)] clashes with #[derive(FromPrimitive)] #[allow(clippy::derivable_impls)] impl Default for AncState { fn default() -> Self { AncState::Off } } impl std::fmt::Display for AncState { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { AncState::Off => write!(f, "off"), AncState::Active => write!(f, "active"), AncState::Aware => write!(f, "aware"), AncState::Adaptive => write!(f, "adaptive"), AncState::Unknown(x) => write!(f, "unknown ({x})"), } } } #[derive(Debug, Clone, Copy, PartialEq)] pub struct EqBands { low_bass: f32, bass: f32, mid: f32, treble: f32, upper_treble: f32, } impl EqBands { pub const MIN_VALUE: f32 = -6.0; pub const MAX_VALUE: f32 = 6.0; pub fn new(low_bass: f32, bass: f32, mid: f32, treble: f32, upper_treble: f32) -> Self { Self { low_bass: low_bass.clamp(Self::MIN_VALUE, Self::MAX_VALUE), bass: bass.clamp(Self::MIN_VALUE, Self::MAX_VALUE), mid: mid.clamp(Self::MIN_VALUE, Self::MAX_VALUE), treble: treble.clamp(Self::MIN_VALUE, Self::MAX_VALUE), upper_treble: upper_treble.clamp(Self::MIN_VALUE, Self::MAX_VALUE), } } pub fn low_bass(&self) -> f32 { self.low_bass } pub fn bass(&self) -> f32 { self.bass } pub fn mid(&self) -> f32 { self.mid } pub fn treble(&self) -> f32 { self.treble } pub fn upper_treble(&self) -> f32 { self.upper_treble } pub fn set_low_bass(&mut self, value: f32) { self.low_bass = value.clamp(Self::MIN_VALUE, Self::MAX_VALUE) } pub fn set_bass(&mut self, value: f32) { self.bass = value.clamp(Self::MIN_VALUE, Self::MAX_VALUE) } pub fn set_mid(&mut self, value: f32) { self.mid = value.clamp(Self::MIN_VALUE, Self::MAX_VALUE) } pub fn set_treble(&mut self, value: f32) { self.treble = value.clamp(Self::MIN_VALUE, Self::MAX_VALUE) } pub fn set_upper_treble(&mut self, value: f32) { self.upper_treble = value.clamp(Self::MIN_VALUE, Self::MAX_VALUE) } } impl Default for EqBands { fn default() -> Self { Self { low_bass: 0.0, bass: 0.0, mid: 0.0, treble: 0.0, upper_treble: 0.0 } } } impl From<types::EqBands> for EqBands { fn from(other: types::EqBands) -> Self { Self { low_bass: other.low_bass, bass: other.bass, mid: other.mid, treble: other.treble, upper_treble: other.upper_treble, } } } impl From<EqBands> for types::EqBands { fn from(other: EqBands) -> Self { Self { low_bass: other.low_bass.clamp(EqBands::MIN_VALUE, EqBands::MAX_VALUE), bass: other.bass.clamp(EqBands::MIN_VALUE, EqBands::MAX_VALUE), mid: other.mid.clamp(EqBands::MIN_VALUE, EqBands::MAX_VALUE), treble: other.treble.clamp(EqBands::MIN_VALUE, EqBands::MAX_VALUE), upper_treble: other.upper_treble.clamp(EqBands::MIN_VALUE, EqBands::MAX_VALUE), } } } impl std::fmt::Display for EqBands { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, "[{:.2}, {:.2}, {:.2}, {:.2}, {:.2}]", self.low_bass, self.bass, self.mid, self.treble, self.upper_treble, ) } } #[derive(Default, Clone, Copy, PartialEq, Eq)] pub struct VolumeAsymmetry { value: i32, } impl VolumeAsymmetry { pub fn from_normalized(value: i32) -> Self { Self { value: value.clamp(-100, 100) } } pub fn from_raw(value: i32) -> Self { let direction = value & 0x01; let value = value >> 1; let normalized = if direction != 0 { value + 1 } else { - value }; Self { value: normalized } } pub fn raw(&self) -> i32 { if self.value > 0 { ((self.value - 1) << 1) | 0x01 } else { (-self.value) << 1 } } pub fn value(&self) -> i32 { self.value } } impl std::fmt::Debug for VolumeAsymmetry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.value) } } impl std::fmt::Display for VolumeAsymmetry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let left = (100 - self.value).min(100); let right = (100 + self.value).min(100); write!(f, "left: {left}%, right: {right}%") } } pub trait Setting { type Type; fn id(&self) -> SettingId; fn from_var(var: SettingValue) -> Option<Self::Type>; } impl Setting for SettingId { type Type = SettingValue; fn id(&self) -> SettingId { *self } fn from_var(var: SettingValue) -> Option<Self::Type> { Some(var) } } pub mod id { use super::*; pub struct AutoOtaEnable; pub struct OhdEnable; pub struct OobeIsFinished; pub struct GestureEnable; pub struct DiagnosticsEnable; pub struct OobeMode; pub struct GestureControl; pub struct MultipointEnable; pub struct AncrGestureLoop; pub struct CurrentAncrState; pub struct OttsMode; pub struct VolumeEqEnable; pub struct CurrentUserEq; pub struct VolumeAsymmetry; pub struct SumToMono; pub struct VolumeExposureNotifications; pub struct SpeechDetection; impl Setting for AutoOtaEnable { type Type = bool; fn id(&self) -> SettingId { SettingId::AutoOtaEnable } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::AutoOtaEnable(x) => Some(x), _ => None, } } } impl Setting for OhdEnable { type Type = bool; fn id(&self) -> SettingId { SettingId::OhdEnable } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::OhdEnable(x) => Some(x), _ => None, } } } impl Setting for OobeIsFinished { type Type = bool; fn id(&self) -> SettingId { SettingId::OobeIsFinished } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::OobeIsFinished(x) => Some(x), _ => None, } } } impl Setting for GestureEnable { type Type = bool; fn id(&self) -> SettingId { SettingId::GestureEnable } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::GestureEnable(x) => Some(x), _ => None, } } } impl Setting for DiagnosticsEnable { type Type = bool; fn id(&self) -> SettingId { SettingId::DiagnosticsEnable } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::DiagnosticsEnable(x) => Some(x), _ => None, } } } impl Setting for OobeMode { type Type = bool; fn id(&self) -> SettingId { SettingId::OobeMode } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::OobeMode(x) => Some(x), _ => None, } } } impl Setting for GestureControl { type Type = super::GestureControl; fn id(&self) -> SettingId { SettingId::GestureControl } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::GestureControl(x) => Some(x), _ => None, } } } impl Setting for MultipointEnable { type Type = bool; fn id(&self) -> SettingId { SettingId::MultipointEnable } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::MultipointEnable(x) => Some(x), _ => None, } } } impl Setting for AncrGestureLoop { type Type = super::AncrGestureLoop; fn id(&self) -> SettingId { SettingId::AncrGestureLoop } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::AncrGestureLoop(x) => Some(x), _ => None, } } } impl Setting for CurrentAncrState { type Type = AncState; fn id(&self) -> SettingId { SettingId::CurrentAncrState } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::CurrentAncrState(x) => Some(x), _ => None, } } } impl Setting for OttsMode { type Type = i32; fn id(&self) -> SettingId { SettingId::OttsMode } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::OttsMode(x) => Some(x), _ => None, } } } impl Setting for VolumeEqEnable { type Type = bool; fn id(&self) -> SettingId { SettingId::VolumeEqEnable } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::VolumeEqEnable(x) => Some(x), _ => None, } } } impl Setting for CurrentUserEq { type Type = EqBands; fn id(&self) -> SettingId { SettingId::CurrentUserEq } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::CurrentUserEq(x) => Some(x), _ => None, } } } impl Setting for VolumeAsymmetry { type Type = super::VolumeAsymmetry; fn id(&self) -> SettingId { SettingId::VolumeAsymmetry } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::VolumeAsymmetry(x) => Some(x), _ => None, } } } impl Setting for SumToMono { type Type = bool; fn id(&self) -> SettingId { SettingId::SumToMono } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::SumToMono(x) => Some(x), _ => None, } } } impl Setting for VolumeExposureNotifications { type Type = bool; fn id(&self) -> SettingId { SettingId::VolumeExposureNotifications } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::VolumeExposureNotifications(x) => Some(x), _ => None, } } } impl Setting for SpeechDetection { type Type = bool; fn id(&self) -> SettingId { SettingId::SpeechDetection } fn from_var(var: SettingValue) -> Option<Self::Type> { match var { SettingValue::SpeechDetection(x) => Some(x), _ => None, } } } } #[cfg(test)] mod test { use super::*; #[test] fn test_volume_assymetry_conversion() { for i in 0..=200 { assert_eq!(VolumeAsymmetry::from_raw(i).raw(), i) } } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/service/mod.rs
libmaestro/src/service/mod.rs
pub mod settings; mod impls; pub use impls::{MaestroService, MultipointService, DosimeterService};
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/service/impls/maestro.rs
libmaestro/src/service/impls/maestro.rs
use crate::protocol::types::{ self, read_setting_msg, settings_rsp, write_setting_msg, HardwareInfo, OobeActionRsp, ReadSettingMsg, RuntimeInfo, SettingsRsp, SoftwareInfo, WriteSettingMsg, }; use crate::pwrpc::client::{ClientHandle, ServerStreamRpc, StreamResponse, UnaryRpc}; use crate::pwrpc::Error; use crate::service::settings::{Setting, SettingId, SettingValue}; #[derive(Debug, Clone)] pub struct MaestroService { client: ClientHandle, channel_id: u32, rpc_get_software_info: UnaryRpc<(), SoftwareInfo>, rpc_get_hardware_info: UnaryRpc<(), HardwareInfo>, rpc_sub_runtime_info: ServerStreamRpc<(), RuntimeInfo>, rpc_write_setting: UnaryRpc<WriteSettingMsg, ()>, rpc_read_setting: UnaryRpc<ReadSettingMsg, SettingsRsp>, rpc_sub_settings_changes: ServerStreamRpc<(), SettingsRsp>, rpc_sub_oobe_actions: ServerStreamRpc<(), OobeActionRsp>, } impl MaestroService { pub fn new(client: ClientHandle, channel_id: u32) -> Self { Self { client, channel_id, rpc_get_software_info: UnaryRpc::new("maestro_pw.Maestro/GetSoftwareInfo"), rpc_get_hardware_info: UnaryRpc::new("maestro_pw.Maestro/GetHardwareInfo"), rpc_sub_runtime_info: ServerStreamRpc::new("maestro_pw.Maestro/SubscribeRuntimeInfo"), rpc_write_setting: UnaryRpc::new("maestro_pw.Maestro/WriteSetting"), rpc_read_setting: UnaryRpc::new("maestro_pw.Maestro/ReadSetting"), rpc_sub_settings_changes: ServerStreamRpc::new("maestro_pw.Maestro/SubscribeToSettingsChanges"), rpc_sub_oobe_actions: ServerStreamRpc::new("maestro_pw.Maestro/SubscribeToOobeActions"), } } pub async fn get_software_info(&mut self) -> Result<SoftwareInfo, Error> { self.rpc_get_software_info.call(&mut self.client, self.channel_id, 0, ())? .result().await } pub async fn get_hardware_info(&mut self) -> Result<HardwareInfo, Error> { self.rpc_get_hardware_info.call(&mut self.client, self.channel_id, 0, ())? .result().await } pub fn subscribe_to_runtime_info(&mut self) -> Result<StreamResponse<RuntimeInfo>, Error> { self.rpc_sub_runtime_info.call(&mut self.client, self.channel_id, 0, ()) } pub async fn write_setting_raw(&mut self, setting: WriteSettingMsg) -> Result<(), Error> { self.rpc_write_setting.call(&mut self.client, self.channel_id, 0, setting)? .result().await } pub async fn write_setting(&mut self, setting: SettingValue) -> Result<(), Error> { let setting = types::SettingValue { value_oneof: Some(setting.into()), }; let setting = WriteSettingMsg { value_oneof: Some(write_setting_msg::ValueOneof::Setting(setting)), }; self.write_setting_raw(setting).await } pub async fn read_setting_raw(&mut self, setting: ReadSettingMsg) -> Result<SettingsRsp, Error> { self.rpc_read_setting.call(&mut self.client, self.channel_id, 0, setting)? .result().await } pub async fn read_setting_var(&mut self, setting: SettingId) -> Result<SettingValue, Error> { let setting = read_setting_msg::ValueOneof::SettingsId(setting.into()); let setting = ReadSettingMsg { value_oneof: Some(setting) }; let value = self.read_setting_raw(setting).await?; let value = value.value_oneof .ok_or_else(|| Error::invalid_argument("did not receive any settings value"))?; let settings_rsp::ValueOneof::Value(value) = value; let value = value.value_oneof .ok_or_else(|| Error::invalid_argument("did not receive any settings value"))?; Ok(value.into()) } pub async fn read_setting<T>(&mut self, setting: T) -> Result<T::Type, Error> where T: Setting, { let value = self.read_setting_var(setting.id()).await?; T::from_var(value) .ok_or_else(|| Error::invalid_argument("failed to decode settings value")) } pub fn subscribe_to_settings_changes(&mut self) -> Result<StreamResponse<SettingsRsp>, Error> { self.rpc_sub_settings_changes.call(&mut self.client, self.channel_id, 0, ()) } pub fn subscribe_to_oobe_actions(&mut self) -> Result<StreamResponse<OobeActionRsp>, Error> { self.rpc_sub_oobe_actions.call(&mut self.client, self.channel_id, 0, ()) } // TODO: // - SetWallClock }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/service/impls/multipoint.rs
libmaestro/src/service/impls/multipoint.rs
use crate::protocol::types::QuietModeStatusEvent; use crate::pwrpc::client::{ClientHandle, ServerStreamRpc, StreamResponse}; use crate::pwrpc::Error; #[derive(Debug, Clone)] pub struct MultipointService { client: ClientHandle, channel_id: u32, rpc_sub_quiet_mode_status: ServerStreamRpc<(), QuietModeStatusEvent>, } impl MultipointService { pub fn new(client: ClientHandle, channel_id: u32) -> Self { Self { client, channel_id, rpc_sub_quiet_mode_status: ServerStreamRpc::new("maestro_pw.Multipoint/SubscribeToQuietModeStatus"), } } pub fn subscribe_to_quiet_mode_status(&mut self) -> Result<StreamResponse<QuietModeStatusEvent>, Error> { self.rpc_sub_quiet_mode_status.call(&mut self.client, self.channel_id, 0, ()) } // TODO: // - ForceMultipointSwitch }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/service/impls/dosimeter.rs
libmaestro/src/service/impls/dosimeter.rs
use crate::protocol::types::{ DosimeterSummary, DosimeterLiveDbMsg, }; use crate::pwrpc::client::{ClientHandle, ServerStreamRpc, StreamResponse, UnaryRpc}; use crate::pwrpc::Error; #[derive(Debug, Clone)] pub struct DosimeterService { client: ClientHandle, channel_id: u32, rpc_fetch_daily_summaries: UnaryRpc<(), DosimeterSummary>, rpc_sub_live_db: ServerStreamRpc<(), DosimeterLiveDbMsg>, } impl DosimeterService { pub fn new(client: ClientHandle, channel_id: u32) -> Self { Self { client, channel_id, rpc_fetch_daily_summaries: UnaryRpc::new("maestro_pw.Dosimeter/FetchDailySummaries"), rpc_sub_live_db: ServerStreamRpc::new("maestro_pw.Dosimeter/SubscribeToLiveDb"), } } pub async fn fetch_daily_summaries(&mut self) -> Result<DosimeterSummary, Error> { self.rpc_fetch_daily_summaries.call(&mut self.client, self.channel_id, 0, ())? .result().await } pub fn subscribe_to_live_db(&mut self) -> Result<StreamResponse<DosimeterLiveDbMsg>, Error> { self.rpc_sub_live_db.call(&mut self.client, self.channel_id, 0, ()) } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/service/impls/mod.rs
libmaestro/src/service/impls/mod.rs
mod dosimeter; pub use self::dosimeter::DosimeterService; mod maestro; pub use self::maestro::MaestroService; mod multipoint; pub use self::multipoint::MultipointService;
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/pwrpc/id.rs
libmaestro/src/pwrpc/id.rs
pub type Hash = u32; #[derive(Debug, Clone, PartialEq, Eq)] pub struct Id { name: String, } impl Id { pub fn new(id: impl Into<String>) -> Self { Self { name: id.into() } } pub fn name(&self) -> &str { &self.name } pub fn hash(&self) -> Hash { hash::hash_65599(&self.name) } pub fn as_ref(&self) -> IdRef<'_> { IdRef { name: &self.name } } } impl<S> From<S> for Id where S: Into<String> { fn from(name: S) -> Self { Id::new(name) } } impl<'a> From<IdRef<'a>> for Id { fn from(id: IdRef<'a>) -> Self { Id::new(id.name()) } } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct IdRef<'a> { name: &'a str, } impl<'a> IdRef<'a> { pub fn new(name: &'a str) -> Self { Self { name } } pub fn name(&self) -> &'a str { self.name } pub fn hash(&self) -> Hash { hash::hash_65599(self.name) } } impl<'a> From<&'a str> for IdRef<'a> { fn from(name: &'a str) -> Self { IdRef::new(name) } } impl<'a> From<&'a String> for IdRef<'a> { fn from(name: &'a String) -> Self { IdRef::new(name) } } #[derive(Debug, Clone, PartialEq, Eq)] pub struct Path { path: String, split: usize, } impl Path { pub fn new(path: impl Into<String>) -> Self { let path = path.into(); let split = path.rfind('/').unwrap_or(0); Path { path, split } } pub fn service(&self) -> IdRef<'_> { IdRef::new(&self.path[..self.split]) } pub fn method(&self) -> IdRef<'_> { if self.split < self.path.len() { IdRef::new(&self.path[self.split+1..]) } else { IdRef::new(&self.path[0..0]) } } pub fn as_ref(&self) -> PathRef<'_> { PathRef { path: &self.path, split: self.split } } } impl From<&str> for Path { fn from(name: &str) -> Self { Path::new(name) } } impl From<String> for Path { fn from(name: String) -> Self { Path::new(name) } } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct PathRef<'a> { path: &'a str, split: usize, } impl<'a> PathRef<'a> { pub fn new(path: &'a str) -> Self { let split = path.rfind('/').unwrap_or(0); PathRef { path, split } } pub fn service(&self) -> IdRef<'a> { IdRef::new(&self.path[..self.split]) } pub fn method(&self) -> IdRef<'a> { if self.split < self.path.len() { IdRef::new(&self.path[self.split+1..]) } else { IdRef::new(&self.path[0..0]) } } } impl<'a> From<&'a str> for PathRef<'a> { fn from(name: &'a str) -> Self { PathRef::new(name) } } mod hash { const HASH_CONST: u32 = 65599; pub fn hash_65599(id: &str) -> u32 { let mut hash = id.len() as u32; let mut coef = HASH_CONST; for chr in id.chars() { hash = hash.wrapping_add(coef.wrapping_mul(chr as u32)); coef = coef.wrapping_mul(HASH_CONST); } hash } } #[cfg(test)] mod test { use super::*; #[test] fn test_known_id_hashes() { assert_eq!(IdRef::new("maestro_pw.Maestro").hash(), 0x7ede71ea); assert_eq!(IdRef::new("GetSoftwareInfo").hash(), 0x7199fa44); assert_eq!(IdRef::new("SubscribeToSettingsChanges").hash(), 0x2821adf5); } #[test] fn test_path() { let pref = PathRef::new("maestro_pw.Maestro/GetSoftwareInfo"); assert_eq!(pref.service().name(), "maestro_pw.Maestro"); assert_eq!(pref.service().hash(), 0x7ede71ea); assert_eq!(pref.method().name(), "GetSoftwareInfo"); assert_eq!(pref.method().hash(), 0x7199fa44); let pref = PathRef::new("maestro_pw.Maestro/SubscribeToSettingsChanges"); assert_eq!(pref.service().name(), "maestro_pw.Maestro"); assert_eq!(pref.service().hash(), 0x7ede71ea); assert_eq!(pref.method().name(), "SubscribeToSettingsChanges"); assert_eq!(pref.method().hash(), 0x2821adf5); } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/pwrpc/status.rs
libmaestro/src/pwrpc/status.rs
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Status { Ok = 0, Cancelled = 1, Unknown = 2, InvalidArgument = 3, DeadlineExceeded = 4, NotFound = 5, AlreadyExists = 6, PermissionDenied = 7, ResourceExhausted = 8, FailedPrecondition = 9, Aborted = 10, OutOfRange = 11, Unimplemented = 12, Internal = 13, Unavailable = 14, DataLoss = 15, Unauthenticated = 16, } impl Status { pub fn description(&self) -> &'static str { match self { Status::Ok => "The operation completed successfully", Status::Cancelled => "The operation was cancelled", Status::Unknown => "Unknown error", Status::InvalidArgument => "Client specified an invalid argument", Status::DeadlineExceeded => "Deadline expired before operation could complete", Status::NotFound => "Some requested entity was not found", Status::AlreadyExists => "Some entity that we attempted to create already exists", Status::PermissionDenied => "The caller does not have permission to execute the specified operation", Status::ResourceExhausted => "Some resource has been exhausted", Status::FailedPrecondition => "The system is not in a state required for the operation's execution", Status::Aborted => "The operation was aborted", Status::OutOfRange => "Operation was attempted past the valid range", Status::Unimplemented => "Operation is not implemented or not supported", Status::Internal => "Internal error", Status::Unavailable => "The service is currently unavailable", Status::DataLoss => "Unrecoverable data loss or corruption", Status::Unauthenticated => "The request does not have valid authentication credentials", } } } impl std::fmt::Display for Status { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.description()) } } impl From<u32> for Status { fn from(value: u32) -> Self { match value { 0 => Status::Ok, 1 => Status::Cancelled, 2 => Status::Unknown, 3 => Status::InvalidArgument, 4 => Status::DeadlineExceeded, 5 => Status::NotFound, 6 => Status::AlreadyExists, 7 => Status::PermissionDenied, 8 => Status::ResourceExhausted, 9 => Status::FailedPrecondition, 10 => Status::Aborted, 11 => Status::OutOfRange, 12 => Status::Unimplemented, 13 => Status::Internal, 14 => Status::Unavailable, 15 => Status::DataLoss, 16 => Status::Unauthenticated, _ => Status::Unknown, } } } impl From<Status> for u32 { fn from(value: Status) -> Self { value as _ } } #[derive(Debug)] pub struct Error { code: Status, message: String, source: Option<Box<dyn std::error::Error + Send + Sync + 'static>>, } impl Error { pub fn new(code: Status, message: impl Into<String>) -> Self { Self { code, message: message.into(), source: None, } } pub fn cancelled(message: impl Into<String>) -> Self { Self::new(Status::Cancelled, message) } pub fn unknown(message: impl Into<String>) -> Self { Self::new(Status::Unknown, message) } pub fn invalid_argument(message: impl Into<String>) -> Self { Self::new(Status::InvalidArgument, message) } pub fn deadline_exceeded(message: impl Into<String>) -> Self { Self::new(Status::DeadlineExceeded, message) } pub fn not_found(message: impl Into<String>) -> Self { Self::new(Status::NotFound, message) } pub fn already_exists(message: impl Into<String>) -> Self { Self::new(Status::AlreadyExists, message) } pub fn permission_denied(message: impl Into<String>) -> Self { Self::new(Status::PermissionDenied, message) } pub fn resource_exhausted(message: impl Into<String>) -> Self { Self::new(Status::ResourceExhausted, message) } pub fn failed_precondition(message: impl Into<String>) -> Self { Self::new(Status::FailedPrecondition, message) } pub fn aborted(message: impl Into<String>) -> Self { Self::new(Status::Aborted, message) } pub fn out_of_range(message: impl Into<String>) -> Self { Self::new(Status::OutOfRange, message) } pub fn unimplemented(message: impl Into<String>) -> Self { Self::new(Status::Unimplemented, message) } pub fn internal(message: impl Into<String>) -> Self { Self::new(Status::Internal, message) } pub fn unavailable(message: impl Into<String>) -> Self { Self::new(Status::Unavailable, message) } pub fn data_loss(message: impl Into<String>) -> Self { Self::new(Status::DataLoss, message) } pub fn unauthenticated(message: impl Into<String>) -> Self { Self::new(Status::Unauthenticated, message) } pub fn extend( code: Status, message: impl Into<String>, error: impl Into<Box<dyn std::error::Error + Send + Sync + 'static>>, ) -> Self { Self { code, message: message.into(), source: Some(error.into()), } } pub fn code(&self) -> Status { self.code } pub fn message(&self) -> &str { &self.message } } impl From<Status> for Error { fn from(code: Status) -> Self { Self::new(code, code.description()) } } impl From<std::io::Error> for Error { fn from(err: std::io::Error) -> Self { use std::io::ErrorKind; let code = match err.kind() { ErrorKind::BrokenPipe | ErrorKind::WouldBlock | ErrorKind::WriteZero | ErrorKind::Interrupted => Status::Internal, ErrorKind::ConnectionRefused | ErrorKind::ConnectionReset | ErrorKind::NotConnected | ErrorKind::AddrInUse | ErrorKind::AddrNotAvailable => Status::Unavailable, ErrorKind::AlreadyExists => Status::AlreadyExists, ErrorKind::ConnectionAborted => Status::Aborted, ErrorKind::InvalidData => Status::DataLoss, ErrorKind::InvalidInput => Status::InvalidArgument, ErrorKind::NotFound => Status::NotFound, ErrorKind::PermissionDenied => Status::PermissionDenied, ErrorKind::TimedOut => Status::DeadlineExceeded, ErrorKind::UnexpectedEof => Status::OutOfRange, _ => Status::Unknown, }; Error::extend(code, err.to_string(), err) } } impl From<prost::DecodeError> for Error { fn from(error: prost::DecodeError) -> Self { Self::extend(Status::InvalidArgument, "failed to decode message", error) } } impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "status: {:?}, message: {:?}", self.code, self.message) } } impl std::error::Error for Error { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { self.source.as_ref().map(|err| (&**err) as _) } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/pwrpc/client.rs
libmaestro/src/pwrpc/client.rs
use std::pin::Pin; use std::task::Poll; use futures::{Sink, SinkExt, Stream, StreamExt}; use futures::channel::mpsc; use futures::stream::{SplitSink, SplitStream, FusedStream}; use prost::Message; use super::id::Path; use super::status::{Status, Error}; use super::types::{RpcType, RpcPacket, PacketType}; #[derive(Debug)] pub struct Client<S> { /// Stream for lower-level transport. io_rx: SplitStream<S>, /// Sink for lower-level transport. io_tx: SplitSink<S, RpcPacket>, /// Queue receiver for requests to be processed and sent by us. queue_rx: mpsc::UnboundedReceiver<CallRequest>, /// Queue sender for requests to be processed by us. Counter-part for /// `queue_rx`, used by callers via `ClientHandle` to initiate new calls. queue_tx: mpsc::UnboundedSender<CallRequest>, /// Pending RPC calls, waiting for a response. pending: Vec<Call>, } impl<S, E> Client<S> where S: Sink<RpcPacket>, S: Stream<Item = Result<RpcPacket, E>> + Unpin, Error: From<S::Error>, Error: From<E>, { pub fn new(stream: S) -> Client<S> { let (io_tx, io_rx) = stream.split(); let (queue_tx, queue_rx) = mpsc::unbounded(); Client { io_rx, io_tx, queue_rx, queue_tx, pending: Vec::new(), } } pub fn handle(&self) -> ClientHandle { ClientHandle { queue_tx: self.queue_tx.clone(), } } pub async fn run(&mut self) -> Result<(), Error> { // Process the request queue first in case we are trying to catch some // early RPC responses via open() calls. while let Ok(Some(request)) = self.queue_rx.try_next() { self.process_request(request).await?; } loop { tokio::select! { packet = self.io_rx.next() => { let packet = packet .ok_or_else(|| Error::aborted("underlying IO stream closed"))??; self.process_packet(packet).await?; }, request = self.queue_rx.next() => { // SAFETY: We hold both sender and receiver parts and are // the only ones allowed to close this queue. Therefore, it // will always be open here. let request = request.expect("request queue closed unexpectedly"); self.process_request(request).await?; }, } } } pub async fn terminate(&mut self) -> Result<(), Error> { tracing::trace!("terminating client"); // Collect messages to be sent instead of directly sending them. We // process infallible (local) operations first, before we try to // communicate with the RPC peer, which is fallible. let mut send = Vec::new(); // Close our request queue. self.queue_rx.close(); // Process all pending requests. Abort requests for new calls and // send/forward any errors. // // SAFETY: try_next() can only return an error when the channel has not // been closed yet. while let Some(msg) = self.queue_rx.try_next().unwrap() { match msg { CallRequest::New { sender, .. } => { // Drop new requests. Instead, notify caller with status 'aborted'. let update = CallUpdate::Error { status: Status::Aborted }; let _ = sender.unbounded_send(update); sender.close_channel(); }, CallRequest::Error { uid, code, tx } => { // Process error requests as normal: Send error message to // peer, remove and complete call. if let Some(mut call) = self.find_and_remove_call(uid) { call.complete_with_error(code).await; if tx { send.push((uid, code)); } } }, } } // Cancel all pending RPCs and remove them from the list. for call in &mut self.pending { call.complete_with_error(Status::Aborted).await; send.push((call.uid, Status::Cancelled)); } self.pending.clear(); // Define functions because async try-catch blocks aren't a thing yet... async fn do_send<S, E>(client: &mut Client<S>, send: Vec<(CallUid, Status)>) -> Result<(), Error> where S: Sink<RpcPacket>, S: Stream<Item = Result<RpcPacket, E>> + Unpin, Error: From<S::Error>, Error: From<E>, { for (uid, code) in send { client.send_client_error(uid, code).await?; } Ok(()) } async fn do_close<S, E>(client: &mut Client<S>) -> Result<(), Error> where S: Sink<RpcPacket>, S: Stream<Item = Result<RpcPacket, E>> + Unpin, Error: From<S::Error>, Error: From<E>, { client.io_tx.close().await?; Ok(()) } // Try to send cancel/error messages. let res_send = do_send(self, send).await; // Try to close the transport. let res_close = do_close(self).await; // Return the first error. res_send?; res_close } async fn process_packet(&mut self, packet: RpcPacket) -> Result<(), Error> { tracing::trace!( "received packet: type=0x{:02x}, channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}", packet.r#type, packet.channel_id, packet.service_id, packet.method_id, packet.call_id ); let ty = packet.r#type; let ty = PacketType::try_from(ty); match ty { Ok(PacketType::Response) => { self.rpc_complete(packet).await }, Ok(PacketType::ServerError) => { self.rpc_complete_with_error(packet).await }, Ok(PacketType::ServerStream) => { self.rpc_stream_push(packet).await? }, Ok(_) => { tracing::error!( "unsupported packet type: type=0x{:02x}, channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}", packet.r#type, packet.channel_id, packet.service_id, packet.method_id, packet.call_id ); }, Err(_) => { tracing::error!( "unknown packet type: type=0x{:02x}, channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}", packet.r#type, packet.channel_id, packet.service_id, packet.method_id, packet.call_id ); }, } Ok(()) } async fn rpc_complete(&mut self, packet: RpcPacket) { let uid = CallUid::from_packet(&packet); let call = self.find_and_remove_call(uid); match call { Some(mut call) => { // pending call found, complete rpc tracing::trace!( "completing rpc: channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}", packet.channel_id, packet.service_id, packet.method_id, packet.call_id ); if packet.status != 0 { tracing::warn!( "completing rpc with non-zero status: channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}, status={}", packet.channel_id, packet.service_id, packet.method_id, packet.call_id, packet.status ); } let status = Status::from(packet.status); call.complete(packet.payload, status).await; }, None => { // no pending call found, silently drop packet tracing::debug!( "received response for non-pending rpc: channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}", packet.channel_id, packet.service_id, packet.method_id, packet.call_id ); }, } } async fn rpc_complete_with_error(&mut self, packet: RpcPacket) { let uid = CallUid::from_packet(&packet); let call = self.find_and_remove_call(uid); match call { Some(mut call) => { // pending call found, complete rpc with error tracing::trace!( "completing rpc with error: channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}, status={}", packet.channel_id, packet.service_id, packet.method_id, packet.call_id, packet.status ); let status = Status::from(packet.status); call.complete_with_error(status).await; }, None => { // no pending call found, silently drop packet tracing::debug!( "received error for non-pending rpc: channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}, status={}", packet.channel_id, packet.service_id, packet.method_id, packet.call_id, packet.status ); }, } } async fn rpc_stream_push(&mut self, packet: RpcPacket) -> Result<(), Error> { let uid = CallUid::from_packet(&packet); let call = self.find_call_mut(uid); match call { Some(call) => { // pending call found, forward packet to caller tracing::trace!( "pushing server stream packet to caller: channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}", packet.channel_id, packet.service_id, packet.method_id, packet.call_id ); if call.ty.has_server_stream() { // packet was expected, forward it call.push_item(packet.payload).await; } else { // this type of rpc doesn't expect streaming packets from the server // SAFETY: We are the only ones that can add, remove, or // otherwise modify items in-between the above find // operation and this one as we have the lock. let mut call = self.find_and_remove_call(uid).unwrap(); tracing::warn!( "received stream packet for non-stream rpc: channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}", packet.channel_id, packet.service_id, packet.method_id, packet.call_id ); call.complete_with_error(Status::InvalidArgument).await; self.send_client_error(uid, Status::InvalidArgument).await?; } }, None => { // no pending call found, try to notify server tracing::debug!( "received stream packet for non-pending rpc: service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}", packet.service_id, packet.method_id, packet.call_id ); self.send_client_error(uid, Status::FailedPrecondition).await?; }, } Ok(()) } async fn process_request(&mut self, request: CallRequest) -> Result<(), Error> { match request { CallRequest::New { ty, uid, payload, sender, tx } => { let call = Call { ty, uid, sender }; let packet = RpcPacket { r#type: PacketType::Request.into(), channel_id: uid.channel, service_id: uid.service, method_id: uid.method, payload, status: Status::Ok as _, call_id: uid.call, }; let action = if tx { "starting" } else { "opening" }; tracing::trace!( "{} rpc: channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}", action, packet.channel_id, packet.service_id, packet.method_id, packet.call_id, ); self.pending.push(call); if tx { self.send(packet).await?; } Ok(()) }, CallRequest::Error { uid, code, tx } => { match self.find_and_remove_call(uid) { Some(mut call) => { tracing::trace!( "cancelling active rpc with code: channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}, code={}", uid.channel, uid.service, uid.method, uid.call, code as u32, ); call.complete_with_error(code).await; if tx { self.send_client_error(uid, code).await?; } Ok(()) }, None => { tracing::trace!( "received error request for non-pending rpc: channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}, code={}", uid.channel, uid.service, uid.method, uid.call, code as u32, ); Ok(()) }, } }, } } fn find_and_remove_call(&mut self, uid: CallUid) -> Option<Call> { let index = self.pending.iter().position(|call| call.uid == uid); match index { Some(index) => Some(self.pending.remove(index)), None => None, } } fn find_call_mut(&mut self, uid: CallUid) -> Option<&mut Call> { self.pending.iter_mut().find(|call| call.uid == uid) } async fn send_client_error(&mut self, uid: CallUid, status: Status) -> Result<(), Error> { let status: u32 = status.into(); tracing::trace!( "sending client error packet: status={}, channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}", status, uid.channel, uid.service, uid.method, uid.call, ); let error_packet = RpcPacket { r#type: PacketType::ClientError as _, channel_id: uid.channel, service_id: uid.service, method_id: uid.method, call_id: uid.call, payload: Vec::new(), status, }; self.send(error_packet).await } async fn send(&mut self, packet: RpcPacket) -> Result<(), Error> { self.io_tx.send(packet).await?; Ok(()) } } #[derive(Debug, Clone)] pub struct ClientHandle { queue_tx: mpsc::UnboundedSender<CallRequest>, } impl ClientHandle { pub fn call_unary<M1, M2>(&mut self, request: Request<M1>) -> Result<UnaryResponse<M2>, Error> where M1: Message, M2: Message + Default, { let handle = self.call(RpcType::Unary, request)?; let response = UnaryResponse { maker: std::marker::PhantomData, handle, }; Ok(response) } pub fn call_server_stream<M1, M2>(&mut self, request: Request<M1>) -> Result<StreamResponse<M2>, Error> where M1: Message, M2: Message + Default, { let handle = self.call(RpcType::ServerStream, request)?; let stream = StreamResponse { marker: std::marker::PhantomData, handle, }; Ok(stream) } fn call<M>(&mut self, ty: RpcType, request: Request<M>) -> Result<CallHandle, Error> where M: Message, { let (sender, receiver) = mpsc::unbounded(); let uid = CallUid { channel: request.channel_id, service: request.service_id, method: request.method_id, call: request.call_id, }; let payload = request.message.encode_to_vec(); let queue_tx = self.queue_tx.clone(); let request = CallRequest::New { ty, uid, payload, sender, tx: true }; let handle = CallHandle { uid, queue_tx, receiver, cancel_on_drop: true }; self.queue_tx.unbounded_send(request) .map_err(|_| Error::aborted("the channel has been closed, no new calls are allowed"))?; Ok(handle) } pub fn open_unary<M>(&mut self, request: Request<()>) -> Result<UnaryResponse<M>, Error> where M: Message + Default, { let handle = self.open(RpcType::Unary, request)?; let response = UnaryResponse { maker: std::marker::PhantomData, handle, }; Ok(response) } pub fn open_server_stream<M>(&mut self, request: Request<()>) -> Result<StreamResponse<M>, Error> where M: Message + Default, { let handle = self.open(RpcType::ServerStream, request)?; let stream = StreamResponse { marker: std::marker::PhantomData, handle, }; Ok(stream) } fn open<M>(&mut self, ty: RpcType, request: Request<M>) -> Result<CallHandle, Error> where M: Message, { let (sender, receiver) = mpsc::unbounded(); let uid = CallUid { channel: request.channel_id, service: request.service_id, method: request.method_id, call: request.call_id, }; let payload = Vec::new(); let queue_tx = self.queue_tx.clone(); let request = CallRequest::New { ty, uid, payload, sender, tx: false }; let handle = CallHandle { uid, queue_tx, receiver, cancel_on_drop: false }; self.queue_tx.unbounded_send(request) .map_err(|_| Error::aborted("the channel has been closed, no new calls are allowed"))?; Ok(handle) } } #[derive(Debug, Clone, Copy, PartialEq, Eq)] struct CallUid { channel: u32, service: u32, method: u32, call: u32, } impl CallUid { fn from_packet(packet: &RpcPacket) -> Self { Self { channel: packet.channel_id, service: packet.service_id, method: packet.method_id, call: packet.call_id } } } #[derive(Debug)] enum CallRequest { New { ty: RpcType, uid: CallUid, payload: Vec<u8>, sender: mpsc::UnboundedSender<CallUpdate>, tx: bool, }, Error { uid: CallUid, code: Status, tx: bool, }, } #[derive(Debug)] enum CallUpdate { Complete { data: Vec<u8>, status: Status, }, StreamItem { data: Vec<u8>, }, Error { status: Status, } } #[derive(Debug)] struct Call { ty: RpcType, uid: CallUid, sender: mpsc::UnboundedSender<CallUpdate>, } impl Call { pub async fn complete(&mut self, payload: Vec<u8>, status: Status) { let update = CallUpdate::Complete { data: payload, status }; self.push_update(update).await; self.sender.close_channel(); } pub async fn complete_with_error(&mut self, status: Status) { let update = CallUpdate::Error { status }; self.push_update(update).await; self.sender.close_channel(); } pub async fn push_item(&mut self, payload: Vec<u8>) { let update = CallUpdate::StreamItem { data: payload }; self.push_update(update).await; } async fn push_update(&mut self, update: CallUpdate) { if let Err(e) = self.sender.unbounded_send(update) { let update = e.into_inner(); match update { CallUpdate::Complete { .. } => { tracing::warn!( "cannot send call update, caller is gone: channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}, update=complete", self.uid.channel, self.uid.service, self.uid.method, self.uid.call, ) }, CallUpdate::StreamItem { .. } => { tracing::warn!( "cannot send call update, caller is gone: channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}, update=stream", self.uid.channel, self.uid.service, self.uid.method, self.uid.call, ) }, CallUpdate::Error { status } => { let code: u32 = status.into(); tracing::trace!( "cannot send call update, caller is gone: channel_id=0x{:02x}, service_id=0x{:08x}, method_id=0x{:08x}, call_id=0x{:02x}, update=error, error={}", self.uid.channel, self.uid.service, self.uid.method, self.uid.call, code, ) }, } } } } impl Drop for Call { fn drop(&mut self) { // Notify caller that call has been aborted if the call has not been // completed yet. Ignore errors. if !self.sender.is_closed() { let update = CallUpdate::Error { status: Status::Aborted }; let _ = self.sender.unbounded_send(update); self.sender.close_channel(); } } } struct CallHandle { uid: CallUid, queue_tx: mpsc::UnboundedSender<CallRequest>, receiver: mpsc::UnboundedReceiver<CallUpdate>, cancel_on_drop: bool, } impl CallHandle { fn is_complete(&self) -> bool { self.queue_tx.is_closed() } fn error(&mut self, code: Status, tx: bool) -> bool { let request = CallRequest::Error { uid: self.uid, code, tx }; let ok = self.queue_tx.unbounded_send(request).is_ok(); // Sending an error will complete the RPC. Disconnect our queue end to // prevent more errors/cancel-requests to be sent. self.queue_tx.disconnect(); ok } fn abandon(&mut self) -> bool { self.error(Status::Cancelled, false) } fn cancel_on_drop(&mut self, cancel: bool) { self.cancel_on_drop = cancel } fn cancel(&mut self) -> bool { self.error(Status::Cancelled, true) } async fn cancel_and_wait(&mut self) -> Result<(), Error> { if !self.cancel() { return Ok(()) } loop { match self.receiver.next().await { Some(CallUpdate::StreamItem { .. }) => { continue }, Some(CallUpdate::Complete { .. }) => { return Ok(()) }, Some(CallUpdate::Error { status: Status::Cancelled }) => { return Ok(()) }, Some(CallUpdate::Error { status }) => { return Err(Error::from(status)) }, None => { return Ok(()) }, } } } } impl Drop for CallHandle { fn drop(&mut self) { if self.cancel_on_drop { self.cancel(); } else { self.abandon(); } } } pub struct Request<M> { pub channel_id: u32, pub service_id: u32, pub method_id: u32, pub call_id: u32, pub message: M, } pub struct UnaryResponse<M> { maker: std::marker::PhantomData<M>, handle: CallHandle, } impl<M> UnaryResponse<M> where M: Message + Default, { pub async fn result(&mut self) -> Result<M, Error> { let update = match self.handle.receiver.next().await { Some(update) => update, None => return Err(Error::resource_exhausted("cannot fetch result() multiple times")), }; let data = match update { CallUpdate::Complete { data, status: Status::Ok } => data, CallUpdate::Complete { status, .. } => return Err(Error::from(status)), CallUpdate::Error { status } => return Err(Error::from(status)), CallUpdate::StreamItem { .. } => unreachable!("received stream update on unary rpc"), }; self.handle.queue_tx.disconnect(); let message = M::decode(&data[..])?; Ok(message) } pub fn abandon(&mut self) -> bool { self.handle.abandon() } pub fn cancel_on_drop(&mut self, cacnel: bool) { self.handle.cancel_on_drop(cacnel) } pub fn cancel(&mut self) -> bool { self.handle.cancel() } pub async fn cancel_and_wait(&mut self) -> Result<(), Error> { self.handle.cancel_and_wait().await } pub fn is_complete(&self) -> bool { self.handle.is_complete() } } pub struct StreamResponse<M> { marker: std::marker::PhantomData<M>, handle: CallHandle, } impl<M> StreamResponse<M> where M: Message + Default, { pub fn stream(&mut self) -> ServerStream<'_, M> { ServerStream { marker: std::marker::PhantomData, handle: &mut self.handle, } } pub fn abandon(&mut self) -> bool { self.handle.abandon() } pub fn cancel_on_drop(&mut self, cacnel: bool) { self.handle.cancel_on_drop(cacnel) } pub fn cancel(&mut self) -> bool { self.handle.cancel() } pub async fn cancel_and_wait(&mut self) -> Result<(), Error> { self.handle.cancel_and_wait().await } pub fn is_complete(&self) -> bool { self.handle.is_complete() } } pub struct ServerStream<'a, M> { marker: std::marker::PhantomData<&'a mut M>, handle: &'a mut CallHandle, } impl<M> Stream for ServerStream<'_, M> where M: Message + Default, { type Item = Result<M, Error>; fn poll_next(mut self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> Poll<Option<Self::Item>> { let update = match Pin::new(&mut self.handle.receiver).poll_next(cx) { Poll::Ready(Some(update)) => update, Poll::Ready(None) => return Poll::Ready(None), Poll::Pending => return Poll::Pending, }; let data = match update { CallUpdate::StreamItem { data } => { data }, CallUpdate::Complete { .. } => { // This indicates the end of the stream. The payload // should be empty. self.handle.receiver.close(); self.handle.queue_tx.disconnect(); return Poll::Ready(None); }, CallUpdate::Error { status } => { self.handle.receiver.close(); self.handle.queue_tx.disconnect(); return Poll::Ready(Some(Err(Error::from(status)))); }, }; let result = match M::decode(&data[..]) { Ok(message) => { Ok(message) }, Err(e) => { self.handle.error(Status::InvalidArgument, true); Err(e.into()) }, }; Poll::Ready(Some(result)) } fn size_hint(&self) -> (usize, Option<usize>) { self.handle.receiver.size_hint() } } impl<M> FusedStream for ServerStream<'_, M> where M: Message + Default, { fn is_terminated(&self) -> bool { self.handle.receiver.is_terminated() } } #[derive(Debug, Clone)] pub struct UnaryRpc<M1, M2> { marker1: std::marker::PhantomData<*const M1>, marker2: std::marker::PhantomData<*const M2>, path: Path, } impl<M1, M2> UnaryRpc<M1, M2> where M1: Message, M2: Message + Default, { pub fn new(path: impl Into<Path>) -> Self { Self { marker1: std::marker::PhantomData, marker2: std::marker::PhantomData, path: path.into(), } } pub fn call(&self, handle: &mut ClientHandle, channel_id: u32, call_id: u32, message: M1) -> Result<UnaryResponse<M2>, Error> { let req = Request { channel_id, service_id: self.path.service().hash(), method_id: self.path.method().hash(), call_id, message, }; handle.call_unary(req) } pub fn open(&self, handle: &mut ClientHandle, channel_id: u32, call_id: u32) -> Result<UnaryResponse<M2>, Error> { let req = Request { channel_id, service_id: self.path.service().hash(), method_id: self.path.method().hash(), call_id, message: (), }; handle.open_unary(req) } } #[derive(Debug, Clone)] pub struct ServerStreamRpc<M1, M2> { marker1: std::marker::PhantomData<*const M1>, marker2: std::marker::PhantomData<*const M2>, path: Path, } impl<M1, M2> ServerStreamRpc<M1, M2> where M1: Message, M2: Message + Default, { pub fn new(path: impl Into<Path>) -> Self { Self { marker1: std::marker::PhantomData, marker2: std::marker::PhantomData, path: path.into(), } } pub fn call(&self, handle: &mut ClientHandle, channel_id: u32, call_id: u32, message: M1) -> Result<StreamResponse<M2>, Error> { let req = Request { channel_id, service_id: self.path.service().hash(), method_id: self.path.method().hash(), call_id, message, }; handle.call_server_stream(req) } pub fn open(&self, handle: &mut ClientHandle, channel_id: u32, call_id: u32) -> Result<StreamResponse<M2>, Error> { let req = Request { channel_id, service_id: self.path.service().hash(), method_id: self.path.method().hash(), call_id, message: (), }; handle.open_server_stream(req) } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/pwrpc/types.rs
libmaestro/src/pwrpc/types.rs
#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum RpcType { Unary, ServerStream, ClientStream, BidirectionalStream, } impl RpcType { pub fn has_server_stream(&self) -> bool { match *self { RpcType::ServerStream | RpcType::BidirectionalStream => true, RpcType::Unary | RpcType::ClientStream => false, } } pub fn has_client_stream(&self) -> bool { match *self { RpcType::ClientStream | RpcType::BidirectionalStream => true, RpcType::Unary | RpcType::ServerStream => false, } } } mod generated { include!(concat!(env!("OUT_DIR"), "/pw.rpc.packet.rs")); } pub use generated::PacketType; pub use generated::RpcPacket;
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/pwrpc/utils.rs
libmaestro/src/pwrpc/utils.rs
//! Miscellaneous utilities and helpers. use bytes::{Buf, BufMut}; /// An encoded protobuf message. /// /// This type represents an encoded protobuf message. Decoding and encoding are /// essentially no-ops, reading and writing to/from the internal buffer. It is /// a drop-in replacement for any valid (and invalid) protobuf type. /// /// This type is intended for reverse-engineering and testing, e.g., in /// combination with tools like `protoscope`. #[derive(Clone, Default)] pub struct EncodedMessage { pub data: Vec<u8>, } impl std::fmt::Debug for EncodedMessage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{:02x?}", self.data) } } impl prost::Message for EncodedMessage { fn encode_raw(&self, buf: &mut impl BufMut) { buf.put_slice(&self.data[..]) } fn merge_field( &mut self, _tag: u32, _wire_type: prost::encoding::WireType, _buf: &mut impl Buf, _ctx: prost::encoding::DecodeContext, ) -> Result<(), prost::DecodeError> { unimplemented!("use merge() instead") } fn merge(&mut self, mut buf: impl Buf) -> Result<(), prost::DecodeError> { let a = self.data.len(); let b = a + buf.remaining(); self.data.resize(b, 0); buf.copy_to_slice(&mut self.data[a..b]); Ok(()) } fn encoded_len(&self) -> usize { self.data.len() } fn clear(&mut self) { self.data.clear() } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/pwrpc/mod.rs
libmaestro/src/pwrpc/mod.rs
pub mod client; pub mod id; pub mod types; pub mod utils; mod status; pub use status::Error; pub use status::Status;
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/hdlc/consts.rs
libmaestro/src/hdlc/consts.rs
//! Flag bytes and bit masks used in the HDLC encoding. pub mod flags { pub const FRAME: u8 = 0x7E; pub const ESCAPE: u8 = 0x7D; } pub mod escape { pub const MASK: u8 = 0x20; }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/hdlc/encoder.rs
libmaestro/src/hdlc/encoder.rs
use bytes::{BufMut, BytesMut}; use super::{consts, crc::Crc32, varint, Frame}; struct ByteEscape<B: BufMut> { buf: B, } impl<B: BufMut> ByteEscape<B> { fn new(buf: B) -> Self { Self { buf } } fn put_u8(&mut self, byte: u8) { match byte { consts::flags::ESCAPE | consts::flags::FRAME => self.buf.put_slice(&[ consts::flags::ESCAPE, consts::escape::MASK ^ byte ]), _ => self.buf.put_u8(byte), } } fn put_frame_flag(&mut self) { self.buf.put_u8(super::consts::flags::FRAME) } } impl ByteEscape<&mut BytesMut> { fn reserve(&mut self, additional: usize) -> &mut Self { self.buf.reserve(additional); self } } struct Encoder<B: BufMut> { buf: ByteEscape<B>, crc: Crc32, } impl<B: BufMut> Encoder<B> { fn new(buf: B) -> Self { Self { buf: ByteEscape::new(buf), crc: Crc32::new(), } } fn flag(&mut self) -> &mut Self { self.buf.put_frame_flag(); self } fn put_u8(&mut self, byte: u8) -> &mut Self { self.crc.put_u8(byte); self.buf.put_u8(byte); self } fn put_bytes<T: IntoIterator<Item = u8>>(&mut self, bytes: T) -> &mut Self { for b in bytes.into_iter() { self.put_u8(b); } self } fn finalize(&mut self) { self.put_bytes(self.crc.value().to_le_bytes()); self.flag(); } } impl Encoder<&mut BytesMut> { fn reserve(&mut self, additional: usize) -> &mut Self { self.buf.reserve(additional); self } } pub fn encode(buf: &mut BytesMut, frame: &Frame) { Encoder::new(buf) .reserve(frame.data.len() + 8) // reserve at least data-size + min-frame-size .flag() // flag .put_bytes(varint::encode(frame.address)) // address .put_u8(frame.control) // control .put_bytes(frame.data.iter().copied()) // data .reserve(5) // reserve CRC32 + flag .finalize() // checksum and flag } pub fn encode_bytes(frame: &Frame) -> BytesMut { let mut buf = BytesMut::new(); encode(&mut buf, frame); buf } #[cfg(test)] mod test { use super::*; #[test] fn test_escape_bytes() { fn e(src: &[u8]) -> Vec<u8> { let mut dst = Vec::new(); let mut buf = ByteEscape::new(&mut dst); for byte in src { buf.put_u8(*byte); } dst } assert_eq!(e(&[0x00, 0x00]), [0x00, 0x00]); assert_eq!(e(&[0x7D]), [0x7D, 0x5D]); assert_eq!(e(&[0x7E]), [0x7D, 0x5E]); assert_eq!(e(&[0x01, 0x7D, 0x02]), [0x01, 0x7D, 0x5D, 0x02]); assert_eq!(e(&[0x01, 0x7E, 0x02]), [0x01, 0x7D, 0x5E, 0x02]); assert_eq!(e(&[0x7D, 0x7E]), [0x7D, 0x5D, 0x7D, 0x5E]); assert_eq!(e(&[0x7F, 0x5D, 0x7E]), [0x7F, 0x5D, 0x7D, 0x5E]); } #[test] fn test_encode() { assert_eq!([ 0x7e, 0x06, 0x08, 0x09, 0x03, 0x8b, 0x3b, 0xf7, 0x42, 0x7e, ], &encode_bytes(&Frame { address: 0x010203, control: 0x03, data: vec![].into(), })[..]); assert_eq!([ 0x7e, 0x06, 0x08, 0x09, 0x03, 0x05, 0x06, 0x07, 0x7d, 0x5d, 0x7d, 0x5e, 0x7f, 0xff, 0xe6, 0x2d, 0x17, 0xc6, 0x7e, ], &encode_bytes(&Frame { address: 0x010203, control: 0x03, data: vec![0x05, 0x06, 0x07, 0x7d, 0x7e, 0x7f, 0xff].into(), })[..]); } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/hdlc/codec.rs
libmaestro/src/hdlc/codec.rs
use super::{decoder, encoder, Frame}; use bytes::BytesMut; use tokio::io::{AsyncWrite, AsyncRead}; use tokio_util::codec::Framed; #[derive(Debug)] pub enum DecoderError { Io(std::io::Error), Decoder(decoder::Error), } impl From<std::io::Error> for DecoderError { fn from(value: std::io::Error) -> Self { Self::Io(value) } } impl From<decoder::Error> for DecoderError { fn from(value: decoder::Error) -> Self { Self::Decoder(value) } } #[derive(Debug, Default)] pub struct Codec { dec: decoder::Decoder, } impl Codec { pub fn new() -> Self { Self { dec: decoder::Decoder::new() } } pub fn with_capacity(cap: usize) -> Self { Self { dec: decoder::Decoder::with_capacity(cap) } } pub fn wrap<T>(self, io: T) -> Framed<T, Codec> where T: AsyncRead + AsyncWrite, { Framed::with_capacity(io, self, 4096 as _) } } impl tokio_util::codec::Encoder<&Frame> for Codec { type Error = std::io::Error; fn encode(&mut self, frame: &Frame, dst: &mut BytesMut) -> Result<(), Self::Error> { encoder::encode(dst, frame); Ok(()) } } impl tokio_util::codec::Decoder for Codec { type Item = Frame; type Error = std::io::Error; fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> { match self.dec.process(src) { Ok(x) => Ok(x), Err(e) => { tracing::warn!("error decoding data: {e:?}"); Ok(None) }, } } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/hdlc/decoder.rs
libmaestro/src/hdlc/decoder.rs
use bytes::{Buf, BytesMut}; use super::consts; use super::crc; use super::varint; use super::Frame; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Error { UnexpectedData, UnexpectedEndOfFrame, InvalidChecksum, InvalidEncoding, InvalidFrame, InvalidAddress, BufferOverflow, } impl From<varint::DecodeError> for Error { fn from(value: varint::DecodeError) -> Self { match value { varint::DecodeError::Incomplete => Self::InvalidFrame, varint::DecodeError::Overflow => Self::InvalidAddress, } } } #[derive(Debug)] pub struct Decoder { buf: Vec<u8>, state: (State, EscState), current_frame_size: usize, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] enum State { Discard, Frame, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] enum EscState { Normal, Escape, } impl Decoder { pub fn new() -> Self { Self::with_capacity(4096) } pub fn with_capacity(cap: usize) -> Self { Self { buf: Vec::with_capacity(cap), state: (State::Discard, EscState::Normal), current_frame_size: 0, } } pub fn process(&mut self, buf: &mut BytesMut) -> Result<Option<Frame>, Error> { if buf.is_empty() { return Ok(None); } loop { match self.state.0 { State::Discard => { // try to find the start of this frame match find_frame_start(buf) { // expected: immediate start of frame Some(0) => { self.state.0 = State::Frame; buf.advance(1); }, // unexpected: n bytes before start of frame Some(n) => { self.state.0 = State::Frame; buf.advance(n + 1); return Err(Error::UnexpectedData); }, // unexpected: unknown amount of bytes before start of frame None => { // check whether the last byte might indicate a start let n = if buf.last() == Some(&consts::flags::FRAME) { buf.len() - 1 } else { buf.len() }; buf.advance(n); return Err(Error::UnexpectedData); }, } }, State::Frame => { // copy and decode to internal buffer for (i, b) in buf.iter().copied().enumerate() { match (b, self.state.1) { (consts::flags::ESCAPE, EscState::Normal) => { self.state.1 = EscState::Escape; }, (consts::flags::ESCAPE, EscState::Escape) => { buf.advance(i + 1); self.reset(); return Err(Error::InvalidEncoding); }, (consts::flags::FRAME, EscState::Normal) => { buf.advance(i + 1); return self.decode_buffered(); }, (consts::flags::FRAME, EscState::Escape) => { buf.advance(i); self.reset(); return Err(Error::UnexpectedEndOfFrame); }, (b, EscState::Normal) => { self.push_byte(b); }, (b, EscState::Escape) => { self.push_byte(b ^ consts::escape::MASK); self.state.1 = EscState::Normal; }, } } buf.advance(buf.remaining()); return Ok(None); }, } } } fn decode_buffered(&mut self) -> Result<Option<Frame>, Error> { // validate minimum frame size if self.buf.len() < 6 { self.reset(); self.state.0 = State::Frame; // the next frame may already start return Err(Error::InvalidFrame); } // validate checksum let crc_actual = crc::crc32(&self.buf[..self.buf.len()-4]); let crc_expect = self.buf[self.buf.len()-4..].try_into().unwrap(); let crc_expect = u32::from_le_bytes(crc_expect); if crc_expect != crc_actual { self.reset(); self.state.0 = State::Frame; // the next frame may already start return Err(Error::InvalidChecksum); } // check for overflow if self.current_frame_size > self.buf.len() { self.reset(); return Err(Error::BufferOverflow); } // decode address let (address, n) = varint::decode(&self.buf)?; // validate minimum remaining frame size if self.buf.len() < n + 5 { self.reset(); return Err(Error::InvalidFrame); } // get control byte and data let control = self.buf[n]; let data = self.buf[n+1..self.buf.len()-4].into(); let frame = Frame { address, control, data, }; self.reset(); Ok(Some(frame)) } fn push_byte(&mut self, byte: u8) { self.current_frame_size += 1; if self.buf.len() < self.buf.capacity() { self.buf.push(byte); } } fn reset(&mut self) { self.buf.clear(); self.state = (State::Discard, EscState::Normal); self.current_frame_size = 0; } } impl Default for Decoder { fn default() -> Self { Self::new() } } fn find_frame_start(buf: &[u8]) -> Option<usize> { buf.windows(2) .enumerate() .find(|(_, b)| b[0] == consts::flags::FRAME && b[1] != consts::flags::FRAME) .map(|(i, _)| i) } #[cfg(test)] mod test { use bytes::BufMut; use super::*; #[test] fn test_find_frame_start() { let buf = [0x7E, 0x01, 0x02, 0x03]; assert_eq!(find_frame_start(&buf), Some(0)); let buf = [0x03, 0x02, 0x01, 0x00, 0x7E, 0x00, 0x01, 0x02, 0x03]; assert_eq!(find_frame_start(&buf), Some(4)); let buf = [0x03, 0x02, 0x01, 0x00, 0x7E, 0x7E, 0x00, 0x01, 0x02, 0x03]; assert_eq!(find_frame_start(&buf), Some(5)); let buf = [0x03, 0x02, 0x01, 0x00, 0x7E]; assert_eq!(find_frame_start(&buf), None); let buf = [0x03, 0x02, 0x01, 0x00, 0x7E, 0x00]; assert_eq!(find_frame_start(&buf), Some(4)); let buf = [0x7E]; assert_eq!(find_frame_start(&buf), None); let buf = []; assert_eq!(find_frame_start(&buf), None); } #[test] fn test_frame_decode() { let data = [ // message 0x7e, 0x06, 0x08, 0x09, 0x03, 0x05, 0x06, 0x07, 0x7d, 0x5d, 0x7d, 0x5e, 0x7f, 0xff, 0xe6, 0x2d, 0x17, 0xc6, 0x7e, // and trailing bytes 0x02, 0x01 ]; let expect = Frame { address: 0x010203, control: 0x03, data: vec![0x05, 0x06, 0x07, 0x7D, 0x7E, 0x7F, 0xFF].into(), }; let mut dec = Decoder::new(); // test standard decoding let mut buf = BytesMut::from(&data[..data.len()-2]); assert_eq!(dec.process(&mut buf), Ok(Some(expect.clone()))); assert_eq!(buf.remaining(), 0); // test decoding with trailing bytes let mut buf = BytesMut::from(&data[..data.len()]); assert_eq!(dec.process(&mut buf), Ok(Some(expect.clone()))); assert_eq!(buf.remaining(), 2); assert_eq!(dec.process(&mut buf), Err(Error::UnexpectedData)); assert_eq!(buf.remaining(), 0); // test partial decoding / re-entrancy let mut buf = BytesMut::from(&data[..9]); assert_eq!(dec.process(&mut buf), Ok(None)); assert_eq!(buf.remaining(), 0); assert_eq!(dec.state, (State::Frame, EscState::Escape)); let mut buf = BytesMut::from(&data[9..data.len()-2]); assert_eq!(dec.process(&mut buf), Ok(Some(expect.clone()))); assert_eq!(buf.remaining(), 0); // test decoding of subsequent frames let mut buf = BytesMut::new(); buf.put_slice(&data[..data.len()-2]); buf.put_slice(&data[..]); assert_eq!(dec.process(&mut buf), Ok(Some(expect.clone()))); assert_eq!(buf.remaining(), data.len()); assert_eq!(dec.process(&mut buf), Ok(Some(expect.clone()))); assert_eq!(buf.remaining(), 2); // test decoding of cut-off frame / data loss (with frame being too small) let mut buf = BytesMut::new(); buf.put_slice(&data[..5]); buf.put_slice(&data[..]); assert_eq!(dec.process(&mut buf), Err(Error::InvalidFrame)); assert_eq!(dec.process(&mut buf), Ok(Some(expect.clone()))); assert_eq!(buf.remaining(), 2); // test decoding of cut-off frame / data loss (with data being cut off) let mut buf = BytesMut::new(); buf.put_slice(&data[..10]); buf.put_slice(&data[..]); assert_eq!(dec.process(&mut buf), Err(Error::InvalidChecksum)); assert_eq!(dec.process(&mut buf), Ok(Some(expect.clone()))); assert_eq!(buf.remaining(), 2); // test frame flag as escaped byte let mut buf = BytesMut::from(&data[..10]); buf.put_slice(&data[..]); buf[9] = consts::flags::FRAME; assert_eq!(dec.process(&mut buf), Err(Error::UnexpectedEndOfFrame)); assert_eq!(dec.process(&mut buf), Err(Error::UnexpectedData)); assert_eq!(dec.process(&mut buf), Ok(Some(expect.clone()))); assert_eq!(buf.remaining(), 2); } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/hdlc/mod.rs
libmaestro/src/hdlc/mod.rs
//! High-level Data Link Control (HDLC) support library. pub mod codec; pub mod consts; pub mod crc; pub mod decoder; pub mod encoder; pub mod varint; pub use codec::Codec; use bytes::BytesMut; #[derive(Debug, Clone, PartialEq, Eq)] pub struct Frame { pub address: u32, pub control: u8, pub data: Box<[u8]>, } impl Frame { pub fn decode(buf: &mut BytesMut) -> Result<Option<Self>, decoder::Error> { decoder::Decoder::new().process(buf) } pub fn encode(&self, buf: &mut BytesMut) { encoder::encode(buf, self) } pub fn encode_bytes(&self) -> BytesMut { encoder::encode_bytes(self) } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/hdlc/crc.rs
libmaestro/src/hdlc/crc.rs
//! 32-bit CRC implementation. #[derive(Debug)] pub struct Crc32 { state: u32, } impl Crc32 { pub fn new() -> Self { Self::with_state(0xFFFFFFFF) } pub fn with_state(state: u32) -> Self { Self { state } } pub fn reset(&mut self) { self.state = 0xFFFFFFFF; } pub fn value(&self) -> u32 { !self.state } pub fn put_u8(&mut self, byte: u8) -> &mut Self { self.state = tables::CRC32[((self.state as u8) ^ byte) as usize] ^ (self.state >> 8); self } pub fn put_bytes<'a, B: IntoIterator<Item=&'a u8>>(&mut self, bytes: B) -> &mut Self { for b in bytes.into_iter().copied() { self.put_u8(b); } self } } impl Default for Crc32 { fn default() -> Self { Self::new() } } pub fn crc32<'a, B: IntoIterator<Item=&'a u8>>(bytes: B) -> u32 { Crc32::new().put_bytes(bytes).value() } mod tables { pub const CRC32: [u32; 256] = [ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, ]; } #[cfg(test)] mod test { use super::*; #[test] fn test_crc32() { assert_eq!(crc32(b"test test test"), 0x235b6a02); assert_eq!(crc32(b"1234321"), 0xd981751c); } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/hdlc/varint.rs
libmaestro/src/hdlc/varint.rs
//! Support for variable length integer encoding as used in the HDLC frame encoding. use arrayvec::ArrayVec; pub fn decode<'a, S: IntoIterator<Item = &'a u8>>(src: S) -> Result<(u32, usize), DecodeError> { let mut address = 0; for (i, b) in src.into_iter().copied().enumerate() { address |= ((b >> 1) as u64) << (i * 7); if address > u32::MAX as u64 { Err(DecodeError::Overflow)?; } if b & 0x01 == 0x01 { return Ok((address as u32, i + 1)); } } Err(DecodeError::Incomplete) } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum DecodeError { Incomplete, Overflow, } pub fn encode(num: u32) -> Encode { Encode { num, done: false } } pub fn encode_vec(num: u32) -> ArrayVec<u8, { num_bytes(u32::MAX) }> { encode(num).collect() } pub struct Encode { num: u32, done: bool, } impl Iterator for Encode { type Item = u8; fn next(&mut self) -> Option<u8> { if (self.num >> 7) != 0 { let b = ((self.num & 0x7F) as u8) << 1; self.num >>= 7; Some(b) } else if !self.done { let b = (((self.num & 0x7F) as u8) << 1) | 1; self.done = true; Some(b) } else { None } } } pub const fn num_bytes(value: u32) -> usize { if value == 0 { 1 } else { (u32::BITS - value.leading_zeros()).div_ceil(7) as _ } } #[cfg(test)] mod test { use super::*; #[test] fn test_decode() { assert_eq!(decode(&[0x01]).unwrap(), (0x00, 1)); assert_eq!(decode(&[0x00, 0x00, 0x00, 0x01]).unwrap(), (0x00, 4)); assert_eq!(decode(&[0x11, 0x00]).unwrap(), (0x0008, 1)); assert_eq!(decode(&[0x10, 0x21]).unwrap(), (0x0808, 2)); assert_eq!(decode(&[0x01]).unwrap(), (0x00, 1)); assert_eq!(decode(&[0x03]).unwrap(), (0x01, 1)); assert_eq!(decode(&[0xff]).unwrap(), (0x7f, 1)); assert_eq!(decode(&[0x00, 0x03]).unwrap(), (0x80, 2)); assert_eq!(decode(&[0xfe, 0xff]).unwrap(), (0x3fff, 2)); assert_eq!(decode(&[0x00, 0x00, 0x03]).unwrap(), (0x4000, 3)); assert_eq!(decode(&[0xfe, 0xfe, 0xff]).unwrap(), (0x1f_ffff, 3)); assert_eq!(decode(&[0x00, 0x00, 0x00, 0x03]).unwrap(), (0x20_0000, 4)); assert_eq!(decode(&[0xfe, 0xfe, 0xfe, 0xff]).unwrap(), (0x0fff_ffff, 4)); assert_eq!(decode(&[0x00, 0x00, 0x00, 0x00, 0x03]).unwrap(), (0x1000_0000, 5)); assert_eq!(decode(&[0xfe, 0x03]).unwrap(), (u8::MAX as _, 2)); assert_eq!(decode(&[0xfe, 0xfe, 0x07]).unwrap(), (u16::MAX as _, 3)); assert_eq!(decode(&[0xfe, 0xfe, 0xfe, 0xfe, 0x1f]).unwrap(), (u32::MAX, 5)); assert_eq!(decode(&[0xFE]), Err(DecodeError::Incomplete)); assert_eq!(decode(&[0xFE, 0xFE, 0xFE, 0xFE, 0xFF]), Err(DecodeError::Overflow)); } #[test] fn test_encode() { assert_eq!(encode_vec(0x01234)[..], [0x68, 0x49]); assert_eq!(encode_vec(0x87654)[..], [0xa8, 0xd8, 0x43]); assert_eq!(encode_vec(0x00)[..], [0x01]); assert_eq!(encode_vec(0x01)[..], [0x03]); assert_eq!(encode_vec(0x7f)[..], [0xff]); assert_eq!(encode_vec(0x80)[..], [0x00, 0x03]); assert_eq!(encode_vec(0x3fff)[..], [0xfe, 0xff]); assert_eq!(encode_vec(0x4000)[..], [0x00, 0x00, 0x03]); assert_eq!(encode_vec(0x1f_ffff)[..], [0xfe, 0xfe, 0xff]); assert_eq!(encode_vec(0x20_0000)[..], [0x00, 0x00, 0x00, 0x03]); assert_eq!(encode_vec(0x0fff_ffff)[..], [0xfe, 0xfe, 0xfe, 0xff]); assert_eq!(encode_vec(0x1000_0000)[..], [0x00, 0x00, 0x00, 0x00, 0x03]); assert_eq!(encode_vec(u8::MAX as _)[..], [0xfe, 0x03]); assert_eq!(encode_vec(u16::MAX as _)[..], [0xfe, 0xfe, 0x07]); assert_eq!(encode_vec(u32::MAX)[..], [0xfe, 0xfe, 0xfe, 0xfe, 0x1f]); } #[test] fn test_num_bytes() { assert_eq!(num_bytes(0x00), 1); assert_eq!(num_bytes(0x01), 1); assert_eq!(num_bytes(0x7f), 1); assert_eq!(num_bytes(0x80), 2); assert_eq!(num_bytes(0x3fff), 2); assert_eq!(num_bytes(0x4000), 3); assert_eq!(num_bytes(0x1f_ffff), 3); assert_eq!(num_bytes(0x20_0000), 4); assert_eq!(num_bytes(0x0fff_ffff), 4); assert_eq!(num_bytes(0x1000_0000), 5); assert_eq!(num_bytes(u8::MAX as _), 2); assert_eq!(num_bytes(u16::MAX as _), 3); assert_eq!(num_bytes(u32::MAX), 5); } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/protocol/codec.rs
libmaestro/src/protocol/codec.rs
use bytes::BytesMut; use prost::Message; use tokio::io::{AsyncRead, AsyncWrite}; use tokio_util::codec::{Decoder, Framed, Encoder}; use crate::pwrpc::types::RpcPacket; use crate::hdlc; use super::addr; pub struct Codec { hdlc: hdlc::Codec, } impl Codec { pub fn new() -> Self { Self { hdlc: hdlc::Codec::new(), } } pub fn wrap<T>(self, io: T) -> Framed<T, Codec> where T: AsyncRead + AsyncWrite, { Framed::with_capacity(io, self, 4096 as _) } } impl Default for Codec { fn default() -> Self { Self::new() } } impl Decoder for Codec { type Item = RpcPacket; type Error = std::io::Error; fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> { match self.hdlc.decode(src)? { Some(frame) => { if frame.control != 0x03 { tracing::warn!("unexpected control type: {}", frame.control); return Ok(None); } let packet = RpcPacket::decode(&frame.data[..])?; Ok(Some(packet)) } None => Ok(None), } } } impl Encoder<&RpcPacket> for Codec { type Error = std::io::Error; fn encode(&mut self, packet: &RpcPacket, dst: &mut BytesMut) -> Result<(), Self::Error> { let address = addr::address_for_channel(packet.channel_id).unwrap(); let frame = hdlc::Frame { address: address.value(), control: 0x03, data: packet.encode_to_vec().into(), // TODO: can we avoid these allocations? }; self.hdlc.encode(&frame, dst) } } impl Encoder<RpcPacket> for Codec { type Error = std::io::Error; fn encode(&mut self, packet: RpcPacket, dst: &mut BytesMut) -> Result<(), Self::Error> { self.encode(&packet, dst) } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/protocol/utils.rs
libmaestro/src/protocol/utils.rs
use crate::pwrpc::Error; use crate::pwrpc::client::{Client, Request, UnaryResponse, ClientHandle}; use crate::pwrpc::id::PathRef; use crate::pwrpc::types::RpcPacket; use super::addr; use super::addr::Peer; use super::types::SoftwareInfo; pub async fn resolve_channel<S, E>(client: &mut Client<S>) -> Result<u32, Error> where S: futures::Sink<RpcPacket>, S: futures::Stream<Item = Result<RpcPacket, E>> + Unpin, Error: From<E>, Error: From<S::Error>, { tracing::trace!("resolving channel"); let channels = ( addr::channel_id(Peer::MaestroA, Peer::Case).unwrap(), addr::channel_id(Peer::MaestroA, Peer::LeftBtCore).unwrap(), addr::channel_id(Peer::MaestroA, Peer::RightBtCore).unwrap(), addr::channel_id(Peer::MaestroB, Peer::Case).unwrap(), addr::channel_id(Peer::MaestroB, Peer::LeftBtCore).unwrap(), addr::channel_id(Peer::MaestroB, Peer::RightBtCore).unwrap(), ); let tasks = ( try_open_channel(client.handle(), channels.0), try_open_channel(client.handle(), channels.1), try_open_channel(client.handle(), channels.2), try_open_channel(client.handle(), channels.3), try_open_channel(client.handle(), channels.4), try_open_channel(client.handle(), channels.5), ); let channel = tokio::select! { // Ensure that the open() calls are registered before we start running // the client. biased; res = tasks.0 => { res? }, res = tasks.1 => { res? }, res = tasks.2 => { res? }, res = tasks.3 => { res? }, res = tasks.4 => { res? }, res = tasks.5 => { res? }, res = client.run() => { res?; return Err(Error::aborted("client terminated")) } }; tracing::trace!(channel=channel, "channel resolved"); Ok(channel) } async fn try_open_channel(mut handle: ClientHandle, channel_id: u32) -> Result<u32, Error> { let path = PathRef::new("maestro_pw.Maestro/GetSoftwareInfo"); let service_id = path.service().hash(); let method_id = path.method().hash(); let req = Request { channel_id, service_id, method_id, call_id: 0xffffffff, message: (), }; let mut rsp: UnaryResponse<SoftwareInfo> = handle.open_unary(req)?; rsp.result().await?; Ok(channel_id) }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/protocol/mod.rs
libmaestro/src/protocol/mod.rs
pub mod addr; pub mod codec; pub mod utils; pub mod types { include!(concat!(env!("OUT_DIR"), "/maestro_pw.rs")); }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/src/protocol/addr.rs
libmaestro/src/protocol/addr.rs
use num_enum::{FromPrimitive, IntoPrimitive}; #[repr(u8)] #[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, IntoPrimitive)] pub enum Peer { Unknown = 0, Host = 1, Case = 2, LeftBtCore = 3, RightBtCore = 4, LeftSensorHub = 5, RightSensorHub = 6, LeftSpiBridge = 7, RightSpiBridge = 8, DebugApp = 9, MaestroA = 10, LeftTahiti = 11, RightTahiti = 12, MaestroB = 13, #[num_enum(catch_all)] Unrecognized(u8) = 0xff, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Address { value: u32, } impl Address { pub fn from_value(value: u32) -> Self { Address { value } } pub fn from_peers(source: Peer, target: Peer) -> Self { let source: u8 = source.into(); let target: u8 = target.into(); Self::from_value(((source as u32 & 0xf) << 6) | ((target as u32 & 0xf) << 10)) } pub fn value(&self) -> u32 { self.value } pub fn source(&self) -> Peer { Peer::from_primitive(((self.value >> 6) & 0x0f) as u8) } pub fn target(&self) -> Peer { Peer::from_primitive(((self.value >> 10) & 0x0f) as u8) } pub fn swap(&self) -> Self { Self::from_peers(self.target(), self.source()) } pub fn channel_id(&self) -> Option<u32> { let source = self.source(); let target = self.target(); if source == Peer::MaestroA || source == Peer::MaestroB { channel_id(source, target) } else { channel_id(target, source) } } } impl From<u32> for Address { fn from(value: u32) -> Self { Self::from_value(value) } } impl From<(Peer, Peer)> for Address { fn from(peers: (Peer, Peer)) -> Self { Self::from_peers(peers.0, peers.1) } } pub fn channel_id(local: Peer, remote: Peer) -> Option<u32> { match (local, remote) { (Peer::MaestroA, Peer::Case) => Some(18), (Peer::MaestroA, Peer::LeftBtCore) => Some(19), (Peer::MaestroA, Peer::LeftSensorHub) => Some(20), (Peer::MaestroA, Peer::RightBtCore) => Some(21), (Peer::MaestroA, Peer::RightSensorHub) => Some(22), (Peer::MaestroB, Peer::Case) => Some(23), (Peer::MaestroB, Peer::LeftBtCore) => Some(24), (Peer::MaestroB, Peer::LeftSensorHub) => Some(25), (Peer::MaestroB, Peer::RightBtCore) => Some(26), (Peer::MaestroB, Peer::RightSensorHub) => Some(27), (_, _) => None, } } pub fn address_for_channel(channel: u32) -> Option<Address> { match channel { 18 => Some(Address::from_peers(Peer::MaestroA, Peer::Case)), 19 => Some(Address::from_peers(Peer::MaestroA, Peer::LeftBtCore)), 20 => Some(Address::from_peers(Peer::MaestroA, Peer::LeftSensorHub)), 21 => Some(Address::from_peers(Peer::MaestroA, Peer::RightBtCore)), 22 => Some(Address::from_peers(Peer::MaestroA, Peer::RightSensorHub)), 23 => Some(Address::from_peers(Peer::MaestroB, Peer::Case)), 24 => Some(Address::from_peers(Peer::MaestroB, Peer::LeftBtCore)), 25 => Some(Address::from_peers(Peer::MaestroB, Peer::LeftSensorHub)), 26 => Some(Address::from_peers(Peer::MaestroB, Peer::RightBtCore)), 27 => Some(Address::from_peers(Peer::MaestroB, Peer::RightSensorHub)), _ => None, } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/examples/maestro_get_battery.rs
libmaestro/examples/maestro_get_battery.rs
//! Simple example for reading battery info via the Maestro service. //! //! Usage: //! cargo run --example maestro_get_battery -- <bluetooth-device-address> mod common; use std::str::FromStr; use anyhow::bail; use bluer::{Address, Session}; use futures::StreamExt; use maestro::protocol::codec::Codec; use maestro::protocol::types::RuntimeInfo; use maestro::protocol::utils; use maestro::pwrpc::client::{Client, ClientHandle}; use maestro::service::MaestroService; #[tokio::main(flavor = "current_thread")] async fn main() -> Result<(), anyhow::Error> { tracing_subscriber::fmt::init(); // handle command line arguments let addr = std::env::args().nth(1).expect("need device address as argument"); let addr = Address::from_str(&addr)?; // set up session let session = Session::new().await?; let adapter = session.default_adapter().await?; println!("Using adapter '{}'", adapter.name()); // get device let dev = adapter.device(addr)?; let uuids = { let mut uuids = Vec::from_iter(dev.uuids().await? .unwrap_or_default() .into_iter()); uuids.sort_unstable(); uuids }; println!("Found device:"); println!(" alias: {}", dev.alias().await?); println!(" address: {}", dev.address()); println!(" paired: {}", dev.is_paired().await?); println!(" connected: {}", dev.is_connected().await?); println!(" UUIDs:"); for uuid in uuids { println!(" {}", uuid); } println!(); println!("Connecting to Maestro profile"); let stream = common::connect_maestro_rfcomm(&session, &dev).await?; println!("Profile connected"); // set up stream for RPC communication let codec = Codec::new(); let stream = codec.wrap(stream); // set up RPC client let mut client = Client::new(stream); let handle = client.handle(); // retreive the channel numer let channel = utils::resolve_channel(&mut client).await?; let exec_task = common::run_client(client); let battery_task = get_battery(handle, channel); let info = tokio::select! { res = exec_task => { match res { Ok(_) => bail!("client terminated unexpectedly without error"), Err(e) => Err(e), } }, res = battery_task => res, }?; let info = info.battery_info .expect("did not receive battery status in runtime-info-changed event"); println!("Battery status:"); if let Some(info) = info.case { match info.state { 1 => println!(" case: {}% (not charging)", info.level), 2 => println!(" case: {}% (charging)", info.level), x => println!(" case: {}% (unknown state: {})", info.level, x), } } else { println!(" case: unknown"); } if let Some(info) = info.left { match info.state { 1 => println!(" left: {}% (not charging)", info.level), 2 => println!(" left: {}% (charging)", info.level), x => println!(" left: {}% (unknown state: {})", info.level, x), } } else { println!(" left: unknown"); } if let Some(info) = info.right { match info.state { 1 => println!(" right: {}% (not charging)", info.level), 2 => println!(" right: {}% (charging)", info.level), x => println!(" right: {}% (unknown state: {})", info.level, x), } } else { println!(" right: unknown"); } Ok(()) } async fn get_battery(handle: ClientHandle, channel: u32) -> anyhow::Result<RuntimeInfo> { println!("Reading battery info..."); println!(); let mut service = MaestroService::new(handle, channel); let mut call = service.subscribe_to_runtime_info()?; let rt_info = if let Some(msg) = call.stream().next().await { msg? } else { bail!("did not receive any runtime-info event"); }; call.cancel_and_wait().await?; Ok(rt_info) }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/examples/maestro_listen.rs
libmaestro/examples/maestro_listen.rs
//! Simple example for listening to Maestro messages sent via the RFCOMM channel. //! //! Usage: //! cargo run --example maestro_listen -- <bluetooth-device-address> mod common; use std::str::FromStr; use bluer::{Address, Session}; use futures::StreamExt; use maestro::protocol::codec::Codec; use maestro::protocol::utils; use maestro::pwrpc::client::{Client, ClientHandle}; use maestro::service::{MaestroService, DosimeterService}; #[tokio::main(flavor = "current_thread")] async fn main() -> Result<(), anyhow::Error> { tracing_subscriber::fmt::init(); // handle command line arguments let addr = std::env::args().nth(1).expect("need device address as argument"); let addr = Address::from_str(&addr)?; // set up session let session = Session::new().await?; let adapter = session.default_adapter().await?; println!("Using adapter '{}'", adapter.name()); // get device let dev = adapter.device(addr)?; let uuids = { let mut uuids = Vec::from_iter(dev.uuids().await? .unwrap_or_default() .into_iter()); uuids.sort_unstable(); uuids }; println!("Found device:"); println!(" alias: {}", dev.alias().await?); println!(" address: {}", dev.address()); println!(" paired: {}", dev.is_paired().await?); println!(" connected: {}", dev.is_connected().await?); println!(" UUIDs:"); for uuid in uuids { println!(" {}", uuid); } println!(); // try to reconnect if connection is reset loop { println!("Connecting to Maestro profile"); let stream = common::connect_maestro_rfcomm(&session, &dev).await?; println!("Profile connected"); // set up stream for RPC communication let codec = Codec::new(); let stream = codec.wrap(stream); // set up RPC client let mut client = Client::new(stream); let handle = client.handle(); // retreive the channel numer let channel = utils::resolve_channel(&mut client).await?; let exec_task = common::run_client(client); let listen_task = run_listener(handle, channel); tokio::select! { res = exec_task => { match res { Ok(_) => { tracing::trace!("client terminated successfully"); return Ok(()); }, Err(e) => { tracing::error!("client task terminated with error"); let cause = e.root_cause(); if let Some(cause) = cause.downcast_ref::<std::io::Error>() { if cause.raw_os_error() == Some(104) { // The Pixel Buds Pro can hand off processing between each // other. On a switch, the connection is reset. Wait a bit // and then try to reconnect. println!(); println!("Connection reset. Attempting to reconnect..."); tokio::time::sleep(std::time::Duration::from_millis(500)).await; continue; } } return Err(e); }, } }, res = listen_task => { match res { Ok(_) => { tracing::error!("server terminated stream"); return Ok(()); } Err(e) => { tracing::error!("main task terminated with error"); return Err(e); } } }, } } } async fn run_listener(handle: ClientHandle, channel: u32) -> anyhow::Result<()> { println!("Sending GetSoftwareInfo request"); println!(); let mut service = MaestroService::new(handle.clone(), channel); let mut dosimeter = DosimeterService::new(handle, channel); let info = service.get_software_info().await?; println!("{:#?}", info); let info = dosimeter.fetch_daily_summaries().await?; println!("{:#?}", info); println!(); println!("Listening to settings changes..."); println!(); let task_rtinfo = run_listener_rtinfo(service.clone()); let task_settings = run_listener_settings(service.clone()); let task_dosimeter = run_listener_dosimeter(dosimeter.clone()); tokio::select! { res = task_rtinfo => res, res = task_settings => res, res = task_dosimeter => res, } } async fn run_listener_rtinfo(mut service: MaestroService) -> anyhow::Result<()> { let mut call = service.subscribe_to_runtime_info()?; while let Some(msg) = call.stream().next().await { println!("{:#?}", msg?); } Ok(()) } async fn run_listener_settings(mut service: MaestroService) -> anyhow::Result<()> { let mut call = service.subscribe_to_settings_changes()?; while let Some(msg) = call.stream().next().await { println!("{:#?}", msg?); } Ok(()) } async fn run_listener_dosimeter(mut service: DosimeterService) -> anyhow::Result<()> { let mut call = service.subscribe_to_live_db()?; while let Some(msg) = call.stream().next().await { println!("volume: {:#?} dB", (msg.unwrap().intensity.log10() * 10.0).round()); } Ok(()) }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/examples/maestro_read_settings.rs
libmaestro/examples/maestro_read_settings.rs
//! Simple example for reading settings on the Pixel Buds Pro via the Maestro service. //! //! Usage: //! cargo run --example maestro_read_settings -- <bluetooth-device-address> mod common; use std::str::FromStr; use anyhow::bail; use bluer::{Address, Session}; use maestro::protocol::codec::Codec; use maestro::protocol::utils; use maestro::pwrpc::client::{Client, ClientHandle}; use maestro::service::MaestroService; use maestro::service::settings::{self, SettingId}; #[tokio::main(flavor = "current_thread")] async fn main() -> Result<(), anyhow::Error> { tracing_subscriber::fmt::init(); // handle command line arguments let addr = std::env::args().nth(1).expect("need device address as argument"); let addr = Address::from_str(&addr)?; // set up session let session = Session::new().await?; let adapter = session.default_adapter().await?; println!("Using adapter '{}'", adapter.name()); // get device let dev = adapter.device(addr)?; let uuids = { let mut uuids = Vec::from_iter(dev.uuids().await? .unwrap_or_default() .into_iter()); uuids.sort_unstable(); uuids }; println!("Found device:"); println!(" alias: {}", dev.alias().await?); println!(" address: {}", dev.address()); println!(" paired: {}", dev.is_paired().await?); println!(" connected: {}", dev.is_connected().await?); println!(" UUIDs:"); for uuid in uuids { println!(" {}", uuid); } println!(); println!("Connecting to Maestro profile"); let stream = common::connect_maestro_rfcomm(&session, &dev).await?; println!("Profile connected"); // set up stream for RPC communication let codec = Codec::new(); let stream = codec.wrap(stream); // set up RPC client let mut client = Client::new(stream); let handle = client.handle(); // retreive the channel numer let channel = utils::resolve_channel(&mut client).await?; let exec_task = common::run_client(client); let settings_task = read_settings(handle, channel); tokio::select! { res = exec_task => { match res { Ok(_) => bail!("client terminated unexpectedly without error"), Err(e) => Err(e), } }, res = settings_task => res, } } async fn read_settings(handle: ClientHandle, channel: u32) -> anyhow::Result<()> { let mut service = MaestroService::new(handle.clone(), channel); println!(); println!("Read via types:"); // read some typed settings via proxy structs let value = service.read_setting(settings::id::AutoOtaEnable).await?; println!(" Auto-OTA enabled: {}", value); let value = service.read_setting(settings::id::OhdEnable).await?; println!(" OHD enabled: {}", value); let value = service.read_setting(settings::id::OobeIsFinished).await?; println!(" OOBE finished: {}", value); let value = service.read_setting(settings::id::GestureEnable).await?; println!(" Gestures enabled: {}", value); let value = service.read_setting(settings::id::DiagnosticsEnable).await?; println!(" Diagnostics enabled: {}", value); let value = service.read_setting(settings::id::OobeMode).await?; println!(" OOBE mode: {}", value); let value = service.read_setting(settings::id::GestureControl).await?; println!(" Gesture control: {}", value); let value = service.read_setting(settings::id::MultipointEnable).await?; println!(" Multi-point enabled: {}", value); let value = service.read_setting(settings::id::AncrGestureLoop).await?; println!(" ANCR gesture loop: {}", value); let value = service.read_setting(settings::id::CurrentAncrState).await?; println!(" ANC status: {}", value); let value = service.read_setting(settings::id::OttsMode).await?; println!(" OTTS mode: {}", value); let value = service.read_setting(settings::id::VolumeEqEnable).await?; println!(" Volume-EQ enabled: {}", value); let value = service.read_setting(settings::id::CurrentUserEq).await?; println!(" Current user EQ: {}", value); let value = service.read_setting(settings::id::VolumeAsymmetry).await?; println!(" Volume balance/asymmetry: {}", value); let value = service.read_setting(settings::id::SumToMono).await?; println!(" Mono output: {}", value); let value = service.read_setting(settings::id::VolumeExposureNotifications).await?; println!(" Volume level exposure notifications: {}", value); let value = service.read_setting(settings::id::SpeechDetection).await?; println!(" Speech detection: {}", value); // read settings via variant println!(); println!("Read via variants:"); let value = service.read_setting(SettingId::GestureEnable).await?; println!(" Gesture enable: {:?}", value); Ok(()) }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/examples/maestro_write_settings.rs
libmaestro/examples/maestro_write_settings.rs
//! Simple example for changing settings on the Pixel Buds Pro via the Maestro service. //! //! Sets active noise cancelling (ANC) state. 1: off, 2: active, 3: aware, 4: adaptive. //! //! Usage: //! cargo run --example maestro_write_settings -- <bluetooth-device-address> <anc-state> mod common; use std::str::FromStr; use anyhow::bail; use bluer::{Address, Session}; use maestro::protocol::utils; use num_enum::FromPrimitive; use maestro::protocol::codec::Codec; use maestro::pwrpc::client::{Client, ClientHandle}; use maestro::service::MaestroService; use maestro::service::settings::{AncState, SettingValue}; #[tokio::main(flavor = "current_thread")] async fn main() -> Result<(), anyhow::Error> { tracing_subscriber::fmt::init(); // handle command line arguments let addr = std::env::args().nth(1).expect("need device address as argument"); let addr = Address::from_str(&addr)?; let anc_state = std::env::args().nth(2).expect("need ANC state as argument"); let anc_state = i32::from_str(&anc_state)?; let anc_state = AncState::from_primitive(anc_state); if let AncState::Unknown(x) = anc_state { bail!("invalid ANC state {x}"); } // set up session let session = Session::new().await?; let adapter = session.default_adapter().await?; println!("Using adapter '{}'", adapter.name()); // get device let dev = adapter.device(addr)?; let uuids = { let mut uuids = Vec::from_iter(dev.uuids().await? .unwrap_or_default() .into_iter()); uuids.sort_unstable(); uuids }; println!("Found device:"); println!(" alias: {}", dev.alias().await?); println!(" address: {}", dev.address()); println!(" paired: {}", dev.is_paired().await?); println!(" connected: {}", dev.is_connected().await?); println!(" UUIDs:"); for uuid in uuids { println!(" {}", uuid); } println!(); println!("Connecting to Maestro profile"); let stream = common::connect_maestro_rfcomm(&session, &dev).await?; println!("Profile connected"); // set up stream for RPC communication let codec = Codec::new(); let stream = codec.wrap(stream); // set up RPC client let mut client = Client::new(stream); let handle = client.handle(); // retreive the channel numer let channel = utils::resolve_channel(&mut client).await?; let exec_task = common::run_client(client); let settings_task = read_settings(handle, channel, anc_state); tokio::select! { res = exec_task => { match res { Ok(_) => bail!("client terminated unexpectedly without error"), Err(e) => Err(e), } }, res = settings_task => res, } } async fn read_settings(handle: ClientHandle, channel: u32, anc_state: AncState) -> anyhow::Result<()> { let mut service = MaestroService::new(handle.clone(), channel); println!(); println!("Setting ANC status to '{}'", anc_state); service.write_setting(SettingValue::CurrentAncrState(anc_state)).await?; Ok(()) }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libmaestro/examples/common/mod.rs
libmaestro/examples/common/mod.rs
use std::time::Duration; use anyhow::Result; use bluer::{Address, Device, Session}; use bluer::rfcomm::{ProfileHandle, Role, ReqError, Stream, Profile}; use futures::StreamExt; use maestro::pwrpc::Error; use maestro::pwrpc::client::Client; use maestro::pwrpc::types::RpcPacket; pub async fn run_client<S, E>(mut client: Client<S>) -> Result<()> where S: futures::Sink<RpcPacket>, S: futures::Stream<Item = Result<RpcPacket, E>> + Unpin, Error: From<E>, Error: From<S::Error>, { tokio::select! { res = client.run() => { res?; }, sig = tokio::signal::ctrl_c() => { sig?; tracing::trace!("client termination requested"); }, } client.terminate().await?; Ok(()) } pub async fn connect_maestro_rfcomm(session: &Session, dev: &Device) -> Result<Stream> { let maestro_profile = Profile { uuid: maestro::UUID, role: Some(Role::Client), require_authentication: Some(false), require_authorization: Some(false), auto_connect: Some(false), ..Default::default() }; tracing::debug!("registering maestro profile"); let mut handle = session.register_profile(maestro_profile).await?; tracing::debug!("connecting to maestro profile"); let stream = tokio::try_join!( try_connect_profile(dev), handle_requests_for_profile(&mut handle, dev.address()), )?.1; Ok(stream) } async fn try_connect_profile(dev: &Device) -> Result<()> { const RETRY_TIMEOUT: Duration = Duration::from_secs(1); const MAX_TRIES: u32 = 3; let mut i = 0; while let Err(err) = dev.connect_profile(&maestro::UUID).await { if i >= MAX_TRIES { return Err(err.into()) } i += 1; tracing::warn!(error=?err, "connecting to profile failed, trying again ({}/{})", i, MAX_TRIES); tokio::time::sleep(RETRY_TIMEOUT).await; } tracing::debug!(address=%dev.address(), "maestro profile connected"); Ok(()) } async fn handle_requests_for_profile(handle: &mut ProfileHandle, address: Address) -> Result<Stream> { while let Some(req) = handle.next().await { tracing::debug!(address=%req.device(), "received new profile connection request"); if req.device() == address { tracing::debug!(address=%req.device(), "accepting profile connection request"); return Ok(req.accept()?); } else { req.reject(ReqError::Rejected); } } anyhow::bail!("profile terminated without requests") }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/cli/build.rs
cli/build.rs
use std::env; use clap::CommandFactory; use clap_complete::shells; #[allow(dead_code)] #[path = "src/cli.rs"] mod cli; use cli::*; fn main() { let outdir = env::var_os("CARGO_TARGET_DIR") .or_else(|| env::var_os("OUT_DIR")) .unwrap(); let mut cmd = Args::command(); clap_complete::generate_to(shells::Bash, &mut cmd, "pbpctrl", &outdir).unwrap(); clap_complete::generate_to(shells::Zsh, &mut cmd, "pbpctrl", &outdir).unwrap(); clap_complete::generate_to(shells::Fish, &mut cmd, "pbpctrl", &outdir).unwrap(); }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/cli/src/bt.rs
cli/src/bt.rs
use std::time::Duration; use anyhow::Result; use bluer::{Adapter, Address, Device, Session}; use bluer::rfcomm::{ProfileHandle, Role, ReqError, Stream, Profile}; use futures::StreamExt; const PIXEL_BUDS_CLASS: u32 = 0x240404; const PIXEL_BUDS2_CLASS: u32 = 0x244404; pub async fn find_maestro_device(adapter: &Adapter) -> Result<Device> { for addr in adapter.device_addresses().await? { let dev = adapter.device(addr)?; let class = dev.class().await?.unwrap_or(0); if class != PIXEL_BUDS_CLASS && class != PIXEL_BUDS2_CLASS { continue; } let uuids = dev.uuids().await?.unwrap_or_default(); if !uuids.contains(&maestro::UUID) { continue; } tracing::debug!(address=%addr, "found compatible device"); return Ok(dev); } tracing::debug!("no compatible device found"); anyhow::bail!("no compatible device found") } pub async fn connect_maestro_rfcomm(session: &Session, dev: &Device) -> Result<Stream> { let maestro_profile = Profile { uuid: maestro::UUID, role: Some(Role::Client), require_authentication: Some(false), require_authorization: Some(false), auto_connect: Some(false), ..Default::default() }; tracing::debug!("registering maestro profile"); let mut handle = session.register_profile(maestro_profile).await?; tracing::debug!("connecting to maestro profile"); let stream = tokio::try_join!( try_connect_profile(dev), handle_requests_for_profile(&mut handle, dev.address()), )?.1; Ok(stream) } async fn try_connect_profile(dev: &Device) -> Result<()> { const RETRY_TIMEOUT: Duration = Duration::from_secs(1); const MAX_TRIES: u32 = 3; let mut i = 0; while let Err(err) = dev.connect_profile(&maestro::UUID).await { if i >= MAX_TRIES { return Err(err.into()) } i += 1; tracing::warn!(error=?err, "connecting to profile failed, trying again ({}/{})", i, MAX_TRIES); tokio::time::sleep(RETRY_TIMEOUT).await; } tracing::debug!(address=%dev.address(), "maestro profile connected"); Ok(()) } async fn handle_requests_for_profile(handle: &mut ProfileHandle, address: Address) -> Result<Stream> { while let Some(req) = handle.next().await { tracing::debug!(address=%req.device(), "received new profile connection request"); if req.device() == address { tracing::debug!(address=%req.device(), "accepting profile connection request"); return Ok(req.accept()?); } else { req.reject(ReqError::Rejected); } } anyhow::bail!("profile terminated without requests") }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/cli/src/cli.rs
cli/src/cli.rs
use bluer::Address; use clap::{Parser, Subcommand, ValueEnum}; use maestro::service::settings; /// Control Google Pixel Buds Pro from the command line #[derive(Debug, Parser)] #[command(author, version, about, long_about = None)] pub struct Args { /// Device to use (search for compatible device if unspecified) #[arg(short, long, global=true)] pub device: Option<Address>, #[command(subcommand)] pub command: Command } #[derive(Debug, Subcommand)] pub enum Command { /// Show device information Show { #[command(subcommand)] command: ShowCommand }, /// Read settings value Get { #[command(subcommand)] setting: GetSetting }, /// Write settings value Set { #[command(subcommand)] setting: SetSetting }, } #[derive(Debug, Subcommand)] pub enum ShowCommand { /// Show software information. Software, /// Show hardware information. Hardware, /// Show runtime information. Runtime, /// Show battery status. Battery, } #[derive(Debug, Subcommand)] pub enum GetSetting { /// Get automatic over-the-air update status AutoOta, /// Get on-head-detection state (enabled/disabled) Ohd, /// Get the flag indicating whether the out-of-box experience phase is /// finished OobeIsFinished, /// Get gesture state (enabled/disabled) Gestures, /// Get diagnostics state (enabled/disabled) Diagnostics, /// Get out-of-box-experience mode state (enabled/disabled) OobeMode, /// Get hold-gesture action GestureControl, /// Get multipoint audio state (enabled/disabled) Multipoint, /// Get adaptive noise-cancelling gesture loop AncGestureLoop, /// Get adaptive noise-cancelling state Anc, /// Get volume-dependent EQ state (enabled/disabled) VolumeEq, /// Get 5-band EQ Eq, /// Get volume balance Balance, /// Get mono output state Mono, /// Get volume exposure notifications state (enabled/disabled) VolumeExposureNotifications, /// Get automatic transparency mode state (enabled/disabled) SpeechDetection, } #[derive(Debug, Subcommand)] pub enum SetSetting { /// Enable/disable automatic over-the-air updates /// /// Note: Updates are initiated by the Google Buds app on your phone. This /// flag controls whether updates can be done automatically when the device /// is not in use. AutoOta { /// Whether to enable or disable automatic over-the-air (OTA) updates #[arg(action=clap::ArgAction::Set)] value: bool, }, /// Enable/disable on-head detection Ohd { /// Whether to enable or disable on-head detection #[arg(action=clap::ArgAction::Set)] value: bool, }, /// Set the flag indicating whether the out-of-box experience phase is /// finished /// /// Note: You normally do not want to change this flag. It is used to /// indicate whether the out-of-box experience (OOBE) phase has been /// concluded, i.e., the setup wizard has been run and the device has been /// set up. OobeIsFinished { /// Whether the OOBE setup has been finished #[arg(action=clap::ArgAction::Set)] value: bool, }, /// Enable/disable gestures Gestures { /// Whether to enable or disable gestures #[arg(action=clap::ArgAction::Set)] value: bool, }, /// Enable/disable diagnostics /// /// Note: This will also cause the Google Buds app on your phone to send /// diagnostics data to Google. Diagnostics { /// Whether to enable or disable diagnostics #[arg(action=clap::ArgAction::Set)] value: bool, }, /// Enable/disable out-of-box-experience mode /// /// Note: You normally do not want to enable this mode. It is used to /// intercept and block touch gestures during the setup wizard. OobeMode { /// Whether to enable or disable the out-of-box experience mode #[arg(action=clap::ArgAction::Set)] value: bool, }, /// Set hold-gesture action GestureControl { /// Left gesture action #[arg(value_enum)] left: HoldGestureAction, /// Right gesture action #[arg(value_enum)] right: HoldGestureAction, }, /// Enable/disable multipoint audio Multipoint { /// Whether to enable or disable multipoint audio #[arg(action=clap::ArgAction::Set)] value: bool, }, /// Set adaptive noise-cancelling gesture loop AncGestureLoop { /// Enable 'off' mode in loop #[arg(action=clap::ArgAction::Set)] off: bool, /// Enable 'active' mode in loop #[arg(action=clap::ArgAction::Set)] active: bool, /// Enable 'aware' mode in loop #[arg(action=clap::ArgAction::Set)] aware: bool, /// Enable 'adaptive' mode in loop #[arg(action=clap::ArgAction::Set)] adaptive: bool, }, /// Set adaptive noise-cancelling state Anc { /// New ANC state or action to change state #[arg(value_enum)] value: AncState, }, /// Enable/disable volume-dependent EQ VolumeEq { /// Whether to enable or disable volume-dependent EQ #[arg(action=clap::ArgAction::Set)] value: bool, }, /// Set 5-band EQ Eq { /// Low-bass band (min: -6.0, max: 6.0) #[arg(value_parser=parse_eq_value)] low_bass: f32, /// Bass band (min: -6.0, max: 6.0) #[arg(value_parser=parse_eq_value)] bass: f32, /// Mid band (min: -6.0, max: 6.0) #[arg(value_parser=parse_eq_value)] mid: f32, /// Treble band (min: -6.0, max: 6.0) #[arg(value_parser=parse_eq_value)] treble: f32, /// Upper treble band (min: -6.0, max: 6.0) #[arg(value_parser=parse_eq_value)] upper_treble: f32, }, /// Set volume balance Balance { /// Volume balance from -100 (left) to +100 (right) #[arg(value_parser=parse_balance)] value: i32, }, /// Set mono output Mono { /// Whether to force mono output #[arg(action=clap::ArgAction::Set)] value: bool, }, /// Enable/disable volume level exposure notifications VolumeExposureNotifications { /// Whether to enable or disable volume level exposure notifications #[arg(action=clap::ArgAction::Set)] value: bool, }, /// Enable/disable automatic transparency mode via speech detection SpeechDetection { /// Whether to enable or disable the automatic transparency mode via speech detection #[arg(action=clap::ArgAction::Set)] value: bool, }, } #[derive(Debug, ValueEnum, Clone, Copy)] pub enum AncState { Off, Active, Aware, Adaptive, CycleNext, CyclePrev, } #[derive(Debug, ValueEnum, Clone, Copy)] pub enum HoldGestureAction { Anc, Assistant, } impl From<HoldGestureAction> for settings::RegularActionTarget { fn from(value: HoldGestureAction) -> Self { match value { HoldGestureAction::Anc => settings::RegularActionTarget::AncControl, HoldGestureAction::Assistant => settings::RegularActionTarget::AssistantQuery, } } } fn parse_eq_value(s: &str) -> std::result::Result<f32, String> { let val = s.parse().map_err(|e| format!("{e}"))?; if val > settings::EqBands::MAX_VALUE { Err(format!("exceeds maximum of {}", settings::EqBands::MAX_VALUE)) } else if val < settings::EqBands::MIN_VALUE { Err(format!("exceeds minimum of {}", settings::EqBands::MIN_VALUE)) } else { Ok(val) } } fn parse_balance(s: &str) -> std::result::Result<i32, String> { let val = s.parse().map_err(|e| format!("{e}"))?; if val > 100 { Err("exceeds maximum of 100".to_string()) } else if val < -100 { Err("exceeds minimum of -100".to_string()) } else { Ok(val) } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/cli/src/main.rs
cli/src/main.rs
mod bt; mod cli; use anyhow::Result; use clap::{Parser, CommandFactory}; use futures::{Future, StreamExt}; use maestro::protocol::{utils, addr}; use maestro::pwrpc::client::{Client, ClientHandle}; use maestro::protocol::codec::Codec; use maestro::service::MaestroService; use maestro::service::settings::{self, Setting, SettingValue}; use cli::*; #[tokio::main(flavor = "current_thread")] async fn main() -> Result<()> { tracing_subscriber::fmt::init(); let args = Args::parse(); // set up session let session = bluer::Session::new().await?; let adapter = session.default_adapter().await?; // set up device let dev = if let Some(address) = args.device { tracing::debug!("using provided address: {}", address); adapter.device(address)? } else { tracing::debug!("no device specified, searching for compatible one"); bt::find_maestro_device(&adapter).await? }; // set up profile let stream = bt::connect_maestro_rfcomm(&session, &dev).await?; // set up codec let codec = Codec::new(); let stream = codec.wrap(stream); // set up RPC client let mut client = Client::new(stream); let handle = client.handle(); // resolve channel let channel = utils::resolve_channel(&mut client).await?; match args.command { Command::Show { command } => match command { ShowCommand::Software => run(client, cmd_show_software(handle, channel)).await, ShowCommand::Hardware => run(client, cmd_show_hardware(handle, channel)).await, ShowCommand::Runtime => run(client, cmd_show_runtime(handle, channel)).await, ShowCommand::Battery => run(client, cmd_show_battery(handle, channel)).await, }, Command::Get { setting } => match setting { GetSetting::AutoOta => { run(client, cmd_get_setting(handle, channel, settings::id::AutoOtaEnable)).await }, GetSetting::Ohd => { run(client, cmd_get_setting(handle, channel, settings::id::OhdEnable)).await }, GetSetting::OobeIsFinished => { run(client, cmd_get_setting(handle, channel, settings::id::OobeIsFinished)).await }, GetSetting::Gestures => { run(client, cmd_get_setting(handle, channel, settings::id::GestureEnable)).await }, GetSetting::Diagnostics => { run(client, cmd_get_setting(handle, channel, settings::id::DiagnosticsEnable)).await } GetSetting::OobeMode => { run(client, cmd_get_setting(handle, channel, settings::id::OobeMode)).await }, GetSetting::GestureControl => { run(client, cmd_get_setting(handle, channel, settings::id::GestureControl)).await }, GetSetting::Multipoint => { run(client, cmd_get_setting(handle, channel, settings::id::MultipointEnable)).await }, GetSetting::AncGestureLoop => { run(client, cmd_get_setting(handle, channel, settings::id::AncrGestureLoop)).await } GetSetting::Anc => { run(client, cmd_get_setting(handle, channel, settings::id::CurrentAncrState)).await }, GetSetting::VolumeEq => { run(client, cmd_get_setting(handle, channel, settings::id::VolumeEqEnable)).await }, GetSetting::Eq => { run(client, cmd_get_setting(handle, channel, settings::id::CurrentUserEq)).await }, GetSetting::Balance => { run(client, cmd_get_setting(handle, channel, settings::id::VolumeAsymmetry)).await }, GetSetting::Mono => { run(client, cmd_get_setting(handle, channel, settings::id::SumToMono)).await }, GetSetting::VolumeExposureNotifications => { run(client, cmd_get_setting(handle, channel, settings::id::VolumeExposureNotifications)).await }, GetSetting::SpeechDetection => { run(client, cmd_get_setting(handle, channel, settings::id::SpeechDetection)).await }, }, Command::Set { setting } => match setting { SetSetting::AutoOta { value } => { let value = SettingValue::AutoOtaEnable(value); run(client, cmd_set_setting(handle, channel, value)).await }, SetSetting::Ohd { value } => { let value = SettingValue::OhdEnable(value); run(client, cmd_set_setting(handle, channel, value)).await }, SetSetting::OobeIsFinished { value } => { let value = SettingValue::OobeIsFinished(value); run(client, cmd_set_setting(handle, channel, value)).await }, SetSetting::Gestures { value } => { let value = SettingValue::GestureEnable(value); run(client, cmd_set_setting(handle, channel, value)).await }, SetSetting::Diagnostics { value } => { let value = SettingValue::DiagnosticsEnable(value); run(client, cmd_set_setting(handle, channel, value)).await }, SetSetting::OobeMode { value } => { let value = SettingValue::OobeMode(value); run(client, cmd_set_setting(handle, channel, value)).await }, SetSetting::GestureControl { left, right } => { let value = settings::GestureControl { left: left.into(), right: right.into() }; let value = SettingValue::GestureControl(value); run(client, cmd_set_setting(handle, channel, value)).await }, SetSetting::Multipoint { value } => { let value = SettingValue::MultipointEnable(value); run(client, cmd_set_setting(handle, channel, value)).await }, SetSetting::AncGestureLoop { off, active, aware, adaptive } => { let value = settings::AncrGestureLoop { off, active, aware, adaptive }; if !value.is_valid() { use clap::error::ErrorKind; let mut cmd = Args::command(); let err = cmd.error( ErrorKind::InvalidValue, "This command requires at least tow enabled ('true') modes" ); err.exit(); } let value = SettingValue::AncrGestureLoop(value); run(client, cmd_set_setting(handle, channel, value)).await }, SetSetting::Anc { value } => { match value { AncState::Off => { let value = SettingValue::CurrentAncrState(settings::AncState::Off); run(client, cmd_set_setting(handle, channel, value)).await }, AncState::Aware => { let value = SettingValue::CurrentAncrState(settings::AncState::Aware); run(client, cmd_set_setting(handle, channel, value)).await }, AncState::Active => { let value = SettingValue::CurrentAncrState(settings::AncState::Active); run(client, cmd_set_setting(handle, channel, value)).await }, AncState::Adaptive => { let value = SettingValue::CurrentAncrState(settings::AncState::Adaptive); run(client, cmd_set_setting(handle, channel, value)).await }, AncState::CycleNext => { run(client, cmd_anc_cycle(handle, channel, true)).await }, AncState::CyclePrev => { run(client, cmd_anc_cycle(handle, channel, false)).await }, } }, SetSetting::VolumeEq { value } => { let value = SettingValue::VolumeEqEnable(value); run(client, cmd_set_setting(handle, channel, value)).await }, SetSetting::Eq { low_bass, bass, mid, treble, upper_treble } => { let value = settings::EqBands::new(low_bass, bass, mid, treble, upper_treble); let value = SettingValue::CurrentUserEq(value); run(client, cmd_set_setting(handle, channel, value)).await }, SetSetting::Balance { value } => { let value = settings::VolumeAsymmetry::from_normalized(value); let value = SettingValue::VolumeAsymmetry(value); run(client, cmd_set_setting(handle, channel, value)).await }, SetSetting::Mono { value } => { let value = SettingValue::SumToMono(value); run(client, cmd_set_setting(handle, channel, value)).await }, SetSetting::VolumeExposureNotifications { value } => { let value = SettingValue::VolumeExposureNotifications(value); run(client, cmd_set_setting(handle, channel, value)).await }, SetSetting::SpeechDetection { value } => { let value = SettingValue::SpeechDetection(value); run(client, cmd_set_setting(handle, channel, value)).await }, }, } } async fn cmd_show_software(handle: ClientHandle, channel: u32) -> Result<()> { let mut service = MaestroService::new(handle, channel); let info = service.get_software_info().await?; let fw_ver_case = info.firmware.as_ref() .and_then(|fw| fw.case.as_ref()) .map(|fw| fw.version_string.as_str()) .unwrap_or("unknown"); let fw_ver_left = info.firmware.as_ref() .and_then(|fw| fw.left.as_ref()) .map(|fw| fw.version_string.as_str()) .unwrap_or("unknown"); let fw_ver_right = info.firmware.as_ref() .and_then(|fw| fw.right.as_ref()) .map(|fw| fw.version_string.as_str()) .unwrap_or("unknown"); let fw_unk_case = info.firmware.as_ref() .and_then(|fw| fw.case.as_ref()) .map(|fw| fw.unknown.as_str()) .unwrap_or("unknown"); let fw_unk_left = info.firmware.as_ref() .and_then(|fw| fw.left.as_ref()) .map(|fw| fw.unknown.as_str()) .unwrap_or("unknown"); let fw_unk_right = info.firmware.as_ref() .and_then(|fw| fw.right.as_ref()) .map(|fw| fw.unknown.as_str()) .unwrap_or("unknown"); println!("firmware:"); println!(" case: {fw_ver_case} ({fw_unk_case})"); println!(" left bud: {fw_ver_left} ({fw_unk_left})"); println!(" right bud: {fw_ver_right} ({fw_unk_right})"); Ok(()) } async fn cmd_show_hardware(handle: ClientHandle, channel: u32) -> Result<()> { let mut service = MaestroService::new(handle, channel); let info = service.get_hardware_info().await?; let serial_case = info.serial_number.as_ref() .map(|ser| ser.case.as_str()) .unwrap_or("unknown"); let serial_left = info.serial_number.as_ref() .map(|ser| ser.left.as_str()) .unwrap_or("unknown"); let serial_right = info.serial_number.as_ref() .map(|ser| ser.right.as_str()) .unwrap_or("unknown"); println!("serial numbers:"); println!(" case: {serial_case}"); println!(" left bud: {serial_left}"); println!(" right bud: {serial_right}"); Ok(()) } async fn cmd_show_runtime(handle: ClientHandle, channel: u32) -> Result<()> { let mut service = MaestroService::new(handle, channel); let mut call = service.subscribe_to_runtime_info()?; let info = call.stream().next().await .ok_or_else(|| anyhow::anyhow!("stream terminated without item"))??; let bat_level_case = info.battery_info.as_ref() .and_then(|b| b.case.as_ref()) .map(|b| b.level); let bat_state_case = info.battery_info.as_ref() .and_then(|b| b.case.as_ref()) .map(|b| if b.state == 2 { "charging" } else if b.state == 1 { "not charging" } else { "unknown" }) .unwrap_or("unknown"); let bat_level_left = info.battery_info.as_ref() .and_then(|b| b.left.as_ref()) .map(|b| b.level); let bat_state_left = info.battery_info.as_ref() .and_then(|b| b.left.as_ref()) .map(|b| if b.state == 2 { "charging" } else if b.state == 1 { "not charging" } else { "unknown" }) .unwrap_or("unknown"); let bat_level_right = info.battery_info.as_ref() .and_then(|b| b.right.as_ref()) .map(|b| b.level); let bat_state_right = info.battery_info.as_ref() .and_then(|b| b.right.as_ref()) .map(|b| if b.state == 2 { "charging" } else if b.state == 1 { "not charging" } else { "unknown" }) .unwrap_or("unknown"); let place_left = info.placement.as_ref() .map(|p| if p.left_bud_in_case { "in case" } else { "out of case" }) .unwrap_or("unknown"); let place_right = info.placement.as_ref() .map(|p| if p.right_bud_in_case { "in case" } else { "out of case" }) .unwrap_or("unknown"); println!("clock: {} ms", info.timestamp_ms); println!(); println!("battery:"); if let Some(lvl) = bat_level_case { println!(" case: {lvl}% ({bat_state_case})"); } else { println!(" case: unknown"); } if let Some(lvl) = bat_level_left { println!(" left bud: {lvl}% ({bat_state_left})"); } else { println!(" left bud: unknown"); } if let Some(lvl) = bat_level_right { println!(" right bud: {lvl}% ({bat_state_right})"); } else { println!(" right bud: unknown"); } println!(); println!("placement:"); println!(" left bud: {place_left}"); println!(" right bud: {place_right}"); let address = addr::address_for_channel(channel); let peer_local = address.map(|a| a.source()); let peer_remote = address.map(|a| a.target()); println!(); println!("connection:"); if let Some(peer) = peer_local { println!(" local: {peer:?}"); } else { println!(" local: unknown"); } if let Some(peer) = peer_remote { println!(" remote: {peer:?}"); } else { println!(" remote: unknown"); } Ok(()) } async fn cmd_show_battery(handle: ClientHandle, channel: u32) -> Result<()> { let mut service = MaestroService::new(handle, channel); let mut call = service.subscribe_to_runtime_info()?; let info = call.stream().next().await .ok_or_else(|| anyhow::anyhow!("stream terminated without item"))??; let bat_level_case = info.battery_info.as_ref() .and_then(|b| b.case.as_ref()) .map(|b| b.level); let bat_state_case = info.battery_info.as_ref() .and_then(|b| b.case.as_ref()) .map(|b| if b.state == 2 { "charging" } else if b.state == 1 { "not charging" } else { "unknown" }) .unwrap_or("unknown"); let bat_level_left = info.battery_info.as_ref() .and_then(|b| b.left.as_ref()) .map(|b| b.level); let bat_state_left = info.battery_info.as_ref() .and_then(|b| b.left.as_ref()) .map(|b| if b.state == 2 { "charging" } else if b.state == 1 { "not charging" } else { "unknown" }) .unwrap_or("unknown"); let bat_level_right = info.battery_info.as_ref() .and_then(|b| b.right.as_ref()) .map(|b| b.level); let bat_state_right = info.battery_info.as_ref() .and_then(|b| b.right.as_ref()) .map(|b| if b.state == 2 { "charging" } else if b.state == 1 { "not charging" } else { "unknown" }) .unwrap_or("unknown"); if let Some(lvl) = bat_level_case { println!("case: {lvl}% ({bat_state_case})"); } else { println!("case: unknown"); } if let Some(lvl) = bat_level_left { println!("left bud: {lvl}% ({bat_state_left})"); } else { println!("left bud: unknown"); } if let Some(lvl) = bat_level_right { println!("right bud: {lvl}% ({bat_state_right})"); } else { println!("right bud: unknown"); } Ok(()) } async fn cmd_get_setting<T>(handle: ClientHandle, channel: u32, setting: T) -> Result<()> where T: Setting, T::Type: std::fmt::Display, { let mut service = MaestroService::new(handle, channel); let value = service.read_setting(setting).await?; println!("{value}"); Ok(()) } async fn cmd_set_setting(handle: ClientHandle, channel: u32, setting: SettingValue) -> Result<()> { let mut service = MaestroService::new(handle, channel); service.write_setting(setting).await?; Ok(()) } async fn cmd_anc_cycle(handle: ClientHandle, channel: u32, forward: bool) -> Result<()> { let mut service = MaestroService::new(handle, channel); let enabled = service.read_setting(settings::id::AncrGestureLoop).await?; let state = service.read_setting(settings::id::CurrentAncrState).await?; if let settings::AncState::Unknown(x) = state { anyhow::bail!("unknown ANC state: {x}"); } let states = [ (settings::AncState::Active, enabled.active), (settings::AncState::Off, enabled.off), (settings::AncState::Aware, enabled.aware), (settings::AncState::Adaptive, enabled.adaptive), ]; let index = states.iter().position(|(s, _)| *s == state).unwrap(); for offs in 1..states.len() { let next = if forward { index + offs } else { index + states.len() - offs } % states.len(); let (state, enabled) = states[next]; if enabled { service.write_setting(SettingValue::CurrentAncrState(state)).await?; break; } } Ok(()) } pub async fn run<S, E, F>(mut client: Client<S>, task: F) -> Result<()> where S: futures::Sink<maestro::pwrpc::types::RpcPacket>, S: futures::Stream<Item = Result<maestro::pwrpc::types::RpcPacket, E>> + Unpin, maestro::pwrpc::Error: From<E>, maestro::pwrpc::Error: From<S::Error>, F: Future<Output=Result<(), anyhow::Error>>, { tokio::select! { res = client.run() => { res?; anyhow::bail!("client terminated unexpectedly"); }, res = task => { res?; tracing::trace!("task terminated successfully"); } sig = tokio::signal::ctrl_c() => { sig?; tracing::trace!("client termination requested"); }, } client.terminate().await?; tracing::trace!("client terminated successfully"); Ok(()) }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libgfps/src/lib.rs
libgfps/src/lib.rs
//! Library for the Google Fast Pair Service protocol (GFPS). Focussed on //! communication via the dedicated GFPS RFCOMM channel. //! //! See <https://developers.google.com/nearby/fast-pair> for the specification. pub mod msg;
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libgfps/src/msg/codec.rs
libgfps/src/msg/codec.rs
use super::Message; use bytes::{Buf, BytesMut, BufMut}; use tokio::io::{AsyncRead, AsyncWrite}; use tokio_util::codec::{Decoder, Framed, Encoder}; const MAX_FRAME_SIZE: u16 = 4096; pub struct Codec {} impl Codec { pub fn new() -> Self { Self {} } pub fn wrap<T>(self, io: T) -> Framed<T, Codec> where T: AsyncRead + AsyncWrite, { Framed::with_capacity(io, self, MAX_FRAME_SIZE as _) } } impl Default for Codec { fn default() -> Self { Self::new() } } impl Decoder for Codec { type Item = Message; type Error = std::io::Error; fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> { if src.len() < 4 { return Ok(None); } let group = src[0]; let code = src[1]; let mut length = [0; 2]; length.copy_from_slice(&src[2..4]); let length = u16::from_be_bytes(length); if length > MAX_FRAME_SIZE { Err(std::io::Error::new( std::io::ErrorKind::InvalidData, format!("Frame of length {length} is too large (group: {group}, code: {code})."), ))?; } let size = 4 + length as usize; if src.len() < size as _ { src.reserve(size - src.len()); return Ok(None); } let data = src[4..size].into(); src.advance(size); Ok(Some(Message { group, code, data, })) } } impl Encoder<&Message> for Codec { type Error = std::io::Error; fn encode(&mut self, msg: &Message, buf: &mut BytesMut) -> Result<(), Self::Error> { let size = msg.data.len() + 4; if size > MAX_FRAME_SIZE as usize { Err(std::io::Error::new( std::io::ErrorKind::InvalidInput, format!("Frame of length {size} is too large."), ))?; } buf.reserve(size); buf.put_u8(msg.group); buf.put_u8(msg.code); buf.put_slice(&(msg.data.len() as u16).to_be_bytes()); buf.put_slice(&msg.data); Ok(()) } } #[cfg(test)] mod test { use super::*; use crate::msg::{EventGroup, DeviceEventCode, Message}; use bytes::BytesMut; use smallvec::smallvec; #[test] fn test_encode() { let mut buf = BytesMut::new(); let mut codec = Codec::new(); let msg = Message { group: EventGroup::Device.into(), code: DeviceEventCode::ModelId.into(), data: smallvec![0x00, 0x01, 0x02, 0x04, 0x05], }; // try to encode the message codec.encode(&msg, &mut buf) .expect("error encode message"); let raw = [0x03, 0x01, 0x00, 0x05, 0x00, 0x01, 0x02, 0x04, 0x05]; assert_eq!(&buf[..], &raw[..]); } #[test] fn test_decode() { let mut codec = Codec::new(); let raw = [0x03, 0x01, 0x00, 0x03, 0x00, 0x01, 0x02]; let mut buf = BytesMut::from(&raw[..]); let msg = Message { group: EventGroup::Device.into(), code: DeviceEventCode::ModelId.into(), data: smallvec![0x00, 0x01, 0x02], }; // try to encode the message let decoded = codec.decode(&mut buf) .expect("error decoding message") .expect("message incomplete"); assert_eq!(decoded, msg); } #[test] fn test_decode_incomplete() { let mut codec = Codec::new(); let raw = [0x03, 0x01, 0x00, 0x03, 0x00]; let mut buf = BytesMut::from(&raw[..]); // try to encode the message let decoded = codec.decode(&mut buf) .expect("error decoding message"); assert_eq!(decoded, None); } #[test] fn test_encode_decode() { let mut buf = BytesMut::new(); let mut codec = Codec::new(); let msg = Message { group: 0, code: 0, data: smallvec![0x00, 0x01, 0x02], }; // try to encode the message codec.encode(&msg, &mut buf) .expect("error encode message"); // try to decode the message we just encoded let decoded = codec.decode(&mut buf) .expect("error decoding message") .expect("message incomplete"); assert_eq!(decoded, msg); } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libgfps/src/msg/types.rs
libgfps/src/msg/types.rs
//! RFCOMM events and event-related enums. use std::fmt::Display; use num_enum::{IntoPrimitive, FromPrimitive}; use smallvec::SmallVec; #[derive(Debug, Clone, PartialEq, Eq)] pub struct Message { pub group: u8, pub code: u8, pub data: SmallVec<[u8; 8]>, } #[non_exhaustive] #[repr(u8)] #[derive(Debug, Clone, Copy, PartialEq, Eq, IntoPrimitive, FromPrimitive)] pub enum EventGroup { Bluetooth = 0x01, Logging = 0x02, Device = 0x03, DeviceAction = 0x04, DeviceConfiguration = 0x05, DeviceCapabilitySync = 0x06, SmartAudioSourceSwitching = 0x07, Acknowledgement = 0xff, #[num_enum(catch_all)] Unknown(u8) = 0xfe, } #[non_exhaustive] #[repr(u8)] #[derive(Debug, Clone, Copy, PartialEq, Eq, IntoPrimitive, FromPrimitive)] pub enum BluetoothEventCode { EnableSilenceMode = 0x01, DisableSilenceMode = 0x02, #[num_enum(catch_all)] Unknown(u8), } #[non_exhaustive] #[repr(u8)] #[derive(Debug, Clone, Copy, PartialEq, Eq, IntoPrimitive, FromPrimitive)] pub enum LoggingEventCode { LogFull = 0x01, LogSaveToBuffer = 0x02, #[num_enum(catch_all)] Unknown(u8), } #[non_exhaustive] #[repr(u8)] #[derive(Debug, Clone, Copy, PartialEq, Eq, IntoPrimitive, FromPrimitive)] pub enum DeviceEventCode { ModelId = 0x01, BleAddress = 0x02, BatteryInfo = 0x03, BatteryTime = 0x04, ActiveComponentsRequest = 0x05, ActiveComponentsResponse = 0x06, Capability = 0x07, PlatformType = 0x08, FirmwareVersion = 0x09, SectionNonce = 0x0a, #[num_enum(catch_all)] Unknown(u8), } #[non_exhaustive] #[repr(u8)] #[derive(Debug, Clone, Copy, PartialEq, Eq, IntoPrimitive, FromPrimitive)] pub enum DeviceActionEventCode { Ring = 0x01, #[num_enum(catch_all)] Unknown(u8), } #[non_exhaustive] #[repr(u8)] #[derive(Debug, Clone, Copy, PartialEq, Eq, IntoPrimitive, FromPrimitive)] pub enum DeviceConfigurationEventCode { BufferSize = 0x01, #[num_enum(catch_all)] Unknown(u8), } #[non_exhaustive] #[repr(u8)] #[derive(Debug, Clone, Copy, PartialEq, Eq, IntoPrimitive, FromPrimitive)] pub enum DeviceCapabilitySyncEventCode { CapabilityUpdate = 0x01, ConfigurableBufferSizeRange = 0x02, #[num_enum(catch_all)] Unknown(u8), } #[non_exhaustive] #[repr(u8)] #[derive(Debug, Clone, Copy, PartialEq, Eq, IntoPrimitive, FromPrimitive)] pub enum SassEventCode { GetCapabilityOfSass = 0x10, NotifyCapabilityOfSass = 0x11, SetMultiPointState = 0x12, SwitchAudioSourceBetweenConnectedDevices = 0x30, SwitchBack = 0x31, NotifyMultiPointSwitchEvent = 0x32, GetConnectionStatus = 0x33, NotifyConnectionStatus = 0x34, SassInitiatedConnection = 0x40, IndicateInUseAccountKey = 0x41, SetCustomData = 0x42, #[num_enum(catch_all)] Unknown(u8), } #[non_exhaustive] #[repr(u8)] #[derive(Debug, Clone, Copy, PartialEq, Eq, IntoPrimitive, FromPrimitive)] pub enum AcknowledgementEventCode { Ack = 0x01, Nak = 0x02, #[num_enum(catch_all)] Unknown(u8), } #[non_exhaustive] #[repr(u8)] #[derive(Debug, Clone, Copy, PartialEq, Eq, IntoPrimitive, FromPrimitive)] pub enum PlatformType { Android = 0x01, #[num_enum(catch_all)] Unknown(u8), } #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] pub enum BatteryInfo { #[default] Unknown, Known { is_charging: bool, percent: u8, }, } impl BatteryInfo { pub fn from_byte(value: u8) -> Self { if value & 0x7F == 0x7F { BatteryInfo::Unknown } else { BatteryInfo::Known { is_charging: (value & 0x80) != 0, percent: value & 0x7F, } } } pub fn to_byte(&self) -> u8 { match self { BatteryInfo::Unknown => 0xFF, BatteryInfo::Known { is_charging: true, percent } => 0x80 | (0x7F & percent), BatteryInfo::Known { is_charging: false, percent } => 0x7F & percent, } } } impl Display for BatteryInfo { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { BatteryInfo::Unknown => { write!(f, "unknown") } BatteryInfo::Known { is_charging: true, percent } => { write!(f, "{percent}% (charging)") } BatteryInfo::Known { is_charging: false, percent } => { write!(f, "{percent}% (not charging)") } } } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libgfps/src/msg/mod.rs
libgfps/src/msg/mod.rs
//! Types for GFPS Message Stream via RFCOMM. use uuid::{uuid, Uuid}; /// UUID under which the GFPS Message Stream is advertised. /// /// Defined as `df21fe2c-2515-4fdb-8886-f12c4d67927c`. pub const UUID: Uuid = uuid!("df21fe2c-2515-4fdb-8886-f12c4d67927c"); mod codec; pub use codec::Codec; mod types; pub use types::*;
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libgfps/examples/gfps_listen.rs
libgfps/examples/gfps_listen.rs
//! Simple example for listening to GFPS messages sent via the RFCOMM channel. //! //! Usage: //! cargo run --example gfps_listen -- <bluetooth-device-address> use std::str::FromStr; use bluer::{Address, Session, Device}; use bluer::rfcomm::{Profile, ReqError, Role, ProfileHandle}; use futures::StreamExt; use gfps::msg::{ AcknowledgementEventCode, Codec, DeviceActionEventCode, DeviceCapabilitySyncEventCode, DeviceConfigurationEventCode, DeviceEventCode, EventGroup, Message, PlatformType, SassEventCode, LoggingEventCode, BluetoothEventCode, BatteryInfo, }; use num_enum::FromPrimitive; #[tokio::main(flavor = "current_thread")] async fn main() -> bluer::Result<()> { // handle command line arguments let addr = std::env::args().nth(1).expect("need device address as argument"); let addr = Address::from_str(&addr)?; // set up session let session = Session::new().await?; let adapter = session.default_adapter().await?; println!("Using adapter '{}'", adapter.name()); // get device let dev = adapter.device(addr)?; let uuids = { let mut uuids = Vec::from_iter(dev.uuids().await? .unwrap_or_default() .into_iter()); uuids.sort_unstable(); uuids }; println!("Found device:"); println!(" alias: {}", dev.alias().await?); println!(" address: {}", dev.address()); println!(" paired: {}", dev.is_paired().await?); println!(" connected: {}", dev.is_connected().await?); println!(" UUIDs:"); for uuid in uuids { println!(" {}", uuid); } println!(); // try to reconnect if connection is reset loop { let stream = { // register GFPS profile println!("Registering GFPS profile..."); let profile = Profile { uuid: gfps::msg::UUID, role: Some(Role::Client), require_authentication: Some(false), require_authorization: Some(false), auto_connect: Some(false), ..Default::default() }; let mut profile_handle = session.register_profile(profile).await?; // connect profile println!("Connecting GFPS profile..."); connect_device_to_profile(&mut profile_handle, &dev).await? }; println!("Profile connected"); // listen to event messages let codec = Codec::new(); let mut stream = codec.wrap(stream); println!("Listening..."); println!(); while let Some(msg) = stream.next().await { match msg { Ok(msg) => { print_message(&msg); } Err(e) if e.raw_os_error() == Some(104) => { // The Pixel Buds Pro can hand off processing between each // other. On a switch, the connection is reset. Wait a bit // and then try to reconnect. println!(); println!("Connection reset. Attempting to reconnect..."); tokio::time::sleep(std::time::Duration::from_millis(500)).await; break; } Err(e) => { Err(e)?; } } } } } async fn connect_device_to_profile(profile: &mut ProfileHandle, dev: &Device) -> bluer::Result<bluer::rfcomm::Stream> { loop { tokio::select! { res = async { let _ = dev.connect().await; dev.connect_profile(&gfps::msg::UUID).await } => { if let Err(err) = res { println!("Connecting GFPS profile failed: {:?}", err); } tokio::time::sleep(std::time::Duration::from_millis(3000)).await; }, req = profile.next() => { let req = req.expect("no connection request received"); if req.device() == dev.address() { println!("Accepting request..."); break req.accept(); } else { println!("Rejecting unknown device {}", req.device()); req.reject(ReqError::Rejected); } }, } } } fn print_message(msg: &Message) { let group = EventGroup::from_primitive(msg.group); match group { EventGroup::Bluetooth => { let code = BluetoothEventCode::from_primitive(msg.code); println!("Bluetooth (0x{:02X}) :: ", msg.group); match code { BluetoothEventCode::EnableSilenceMode => { println!("Enable Silence Mode (0x{:02X})", msg.code); }, BluetoothEventCode::DisableSilenceMode => { println!("Disable Silence Mode (0x{:02X})", msg.code); }, _ => { println!("Unknown (0x{:02X})", msg.code); }, } print_message_body_unknown(msg); println!(); } EventGroup::Logging => { let code = LoggingEventCode::from_primitive(msg.code); println!("Companion App (0x{:02X}) :: ", msg.group); match code { LoggingEventCode::LogFull => { println!("Log Full (0x{:02X})", msg.code); } LoggingEventCode::LogSaveToBuffer => { println!("Log Save Buffer (0x{:02X})", msg.code); } _ => { println!("Unknown (0x{:02X})", msg.code); } } print_message_body_unknown(msg); println!(); } EventGroup::Device => { let code = DeviceEventCode::from_primitive(msg.code); print!("Device Information (0x{:02X}) :: ", msg.group); match code { DeviceEventCode::ModelId => { println!("Model Id (0x{:02X})", msg.code); println!(" model: {:02X}{:02X}{:02X}", msg.data[0], msg.data[1], msg.data[2]); } DeviceEventCode::BleAddress => { println!("BLE Address (0x{:02X})", msg.code); println!(" address: {}", Address::new(msg.data[0..6].try_into().unwrap())); } DeviceEventCode::BatteryInfo => { println!("Battery Info (0x{:02X})", msg.code); let left = BatteryInfo::from_byte(msg.data[0]); let right = BatteryInfo::from_byte(msg.data[1]); let case = BatteryInfo::from_byte(msg.data[2]); println!(" left bud: {}", left); println!(" right bud: {}", right); println!(" case: {}", case); } DeviceEventCode::BatteryTime => { println!("Remaining Battery Time (0x{:02X})", msg.code); let time = match msg.data.len() { 1 => msg.data[0] as u16, 2 => u16::from_be_bytes(msg.data[0..2].try_into().unwrap()), _ => panic!("invalid format"), }; println!(" time: {} minutes", time); } DeviceEventCode::ActiveComponentsRequest => { println!("Active Components Request (0x{:02X})", msg.code); } DeviceEventCode::ActiveComponentsResponse => { println!("Active Components Response (0x{:02X})", msg.code); println!(" components: {:08b}", msg.data[0]); } DeviceEventCode::Capability => { println!("Capability (0x{:02X})", msg.code); println!(" capabilities: {:08b}", msg.data[0]); } DeviceEventCode::PlatformType => { println!("Platform Type (0x{:02X})", msg.code); let platform = PlatformType::from_primitive(msg.data[0]); match platform { PlatformType::Android => { println!(" platform: Android (0x{:02X})", msg.data[0]); println!(" SDK version: {:02X?})", msg.data[1]); } _ => { println!(" platform: Unknown (0x{:02X})", msg.data[0]); println!(" platform data: 0x{:02X?})", msg.data[1]); } } } DeviceEventCode::FirmwareVersion => { println!("Firmware Version (0x{:02X})", msg.code); if let Ok(ver) = std::str::from_utf8(&msg.data) { println!(" version: {:?}", ver); } else { println!(" version: {:02X?}", msg.data); } } DeviceEventCode::SectionNonce => { println!("Session Nonce (0x{:02X})", msg.code); println!(" nonce: {:02X?}", msg.data); } _ => { println!("Unknown (0x{:02X})", msg.code); print_message_body_unknown(msg); } } println!(); } EventGroup::DeviceAction => { let code = DeviceActionEventCode::from_primitive(msg.code); print!("Device Action (0x{:02X}) :: ", msg.group); match code { DeviceActionEventCode::Ring => { println!("Ring (0x{:02X})", msg.code); } _ => { println!("Unknown (0x{:02X})", msg.code); } } print_message_body_unknown(msg); println!(); } EventGroup::DeviceConfiguration => { let code = DeviceConfigurationEventCode::from_primitive(msg.code); print!("Device Configuration (0x{:02X}) :: ", msg.group); match code { DeviceConfigurationEventCode::BufferSize => { println!("Buffer Size (0x{:02X})", msg.code); } _ => { println!("Unknown (0x{:02X})", msg.code); } } print_message_body_unknown(msg); println!(); } EventGroup::DeviceCapabilitySync => { let code = DeviceCapabilitySyncEventCode::from_primitive(msg.code); print!("Device Cpabilities Sync (0x{:02X}) :: ", msg.group); match code { DeviceCapabilitySyncEventCode::CapabilityUpdate => { println!("Capability Update (0x{:02X})", msg.code); } DeviceCapabilitySyncEventCode::ConfigurableBufferSizeRange => { println!("Configurable Buffer Size Range (0x{:02X})", msg.code); } _ => { println!("Unknown (0x{:02X})", msg.code); } } print_message_body_unknown(msg); println!(); } EventGroup::SmartAudioSourceSwitching => { let code = SassEventCode::from_primitive(msg.code); print!("Smart Audio Source Switching (0x{:02X}) :: ", msg.group); match code { SassEventCode::GetCapabilityOfSass => { println!("Get Capability (0x{:02X})", msg.code); } SassEventCode::NotifyCapabilityOfSass => { println!("Notify Capability (0x{:02X})", msg.code); } SassEventCode::SetMultiPointState => { println!("Set Multi-Point State (0x{:02X})", msg.code); } SassEventCode::SwitchAudioSourceBetweenConnectedDevices => { println!("Switch Audio Source Between Connected Devices (0x{:02X})", msg.code); } SassEventCode::SwitchBack => { println!("Switch Back (0x{:02X})", msg.code); } SassEventCode::NotifyMultiPointSwitchEvent => { println!("Notify Multi-Point (0x{:02X})", msg.code); } SassEventCode::GetConnectionStatus => { println!("Get Connection Status (0x{:02X})", msg.code); } SassEventCode::NotifyConnectionStatus => { println!("Notify Connection Status (0x{:02X})", msg.code); } SassEventCode::SassInitiatedConnection => { println!("SASS Initiated Connection (0x{:02X})", msg.code); } SassEventCode::IndicateInUseAccountKey => { println!("Indicate In-Use Account Key (0x{:02X})", msg.code); } SassEventCode::SetCustomData => { println!("Set Custom Data (0x{:02X})", msg.code); } _ => { println!("Unknown (0x{:02X})", msg.code); } } print_message_body_unknown(msg); println!(); } EventGroup::Acknowledgement => { let code = AcknowledgementEventCode::from_primitive(msg.code); print!("Acknowledgement (0x{:02X}) ::", msg.group); match code { AcknowledgementEventCode::Ack => { println!("ACK (0x{:02X})", msg.code); println!(" group: 0x{:02X}", msg.data[0]); println!(" code: 0x{:02X}", msg.data[1]); println!(); } AcknowledgementEventCode::Nak => { println!("NAK (0x{:02X})", msg.code); match msg.data[0] { 0x00 => println!(" reason: Not supported (0x00)"), 0x01 => println!(" reason: Device busy (0x01)"), 0x02 => println!(" reason: Not allowed due to current state (0x02)"), _ => println!(" reason: Unknown (0x{:02X})", msg.data[0]), } println!(" group: 0x{:02X}", msg.data[1]); println!(" code: 0x{:02X}", msg.data[2]); println!(); } _ => { println!("Unknown (0x{:02X})", msg.code); print_message_body_unknown(msg); println!(); } } } _ => { println!( "Unknown (0x{:02X}) :: Unknown (0x{:02X})", msg.group, msg.code ); print_message_body_unknown(msg); println!(); } } } fn print_message_body_unknown(msg: &Message) { let data = pretty_hex::config_hex( &msg.data, pretty_hex::HexConfig { title: false, ..Default::default() }, ); for line in data.lines() { println!(" {}", line); } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libgfps/examples/ring.rs
libgfps/examples/ring.rs
//! Simple example for "ringing" the buds to locate them. //! //! WARNING: DO NOT RUN THIS EXAMPLE WITH THE BUDS IN YOUR EAR! YOU HAVE BEEN WARNED. //! //! Usage: //! cargo run --example ring -- <bluetooth-device-address> use std::str::FromStr; use bluer::{Address, Session, Device}; use bluer::rfcomm::{Profile, Role, ProfileHandle, ReqError}; use futures::{StreamExt, SinkExt}; use gfps::msg::{Codec, Message, EventGroup, DeviceActionEventCode, AcknowledgementEventCode}; use num_enum::FromPrimitive; use smallvec::smallvec; #[tokio::main(flavor = "current_thread")] async fn main() -> bluer::Result<()> { // handle command line arguments let addr = std::env::args().nth(1).expect("need device address as argument"); let addr = Address::from_str(&addr)?; // set up session let session = Session::new().await?; let adapter = session.default_adapter().await?; // get device let dev = adapter.device(addr)?; // get RFCOMM stream let stream = { // register GFPS profile let profile = Profile { uuid: gfps::msg::UUID, role: Some(Role::Client), require_authentication: Some(false), require_authorization: Some(false), auto_connect: Some(false), ..Default::default() }; let mut profile_handle = session.register_profile(profile).await?; // connect profile connect_device_to_profile(&mut profile_handle, &dev).await? }; // set up message stream let codec = Codec::new(); let mut stream = codec.wrap(stream); // send "ring" message // // Note: Pixel Buds Pro ignore messages with a timeout. So don't specify // one here. let msg = Message { group: EventGroup::DeviceAction.into(), code: DeviceActionEventCode::Ring.into(), data: smallvec![0x03], // 0b01: right, 0b10: left, 0b10|0b01 = 0b11: both }; println!("Ringing buds..."); stream.send(&msg).await?; // An ACK message should come in 1s. Wait for that. let timeout = tokio::time::Instant::now() + tokio::time::Duration::from_secs(1); loop { tokio::select! { msg = stream.next() => { match msg { Some(Ok(msg)) => { println!("{:?}", msg); let group = EventGroup::from_primitive(msg.group); if group != EventGroup::Acknowledgement { continue; } let ack_group = EventGroup::from_primitive(msg.data[0]); if ack_group != EventGroup::DeviceAction { continue; } let ack_code = DeviceActionEventCode::from_primitive(msg.data[1]); if ack_code != DeviceActionEventCode::Ring { continue; } let code = AcknowledgementEventCode::from_primitive(msg.code); if code == AcknowledgementEventCode::Ack { println!("Received ACK for ring command"); break; } else if code == AcknowledgementEventCode::Nak { println!("Received NAK for ring command"); let err = std::io::Error::new( std::io::ErrorKind::Unsupported, "ring has been NAK'ed by device" ); Err(err)?; } }, Some(Err(e)) => { Err(e)?; }, None => { let err = std::io::Error::new( std::io::ErrorKind::ConnectionAborted, "connection closed" ); Err(err)?; } } }, _ = tokio::time::sleep_until(timeout) => { let err = std::io::Error::new( std::io::ErrorKind::TimedOut, "timed out, ring action might be unsupported" ); Err(err)?; }, } } // Next, the device will communicate back status updates. This may include // an initial update to confirm ringing and follow-up updates once the user // has touched the buds and ringing stops. // // Stop this program once we have no more rining or once we have reached a // timeout of 30s. let mut timeout = tokio::time::Instant::now() + tokio::time::Duration::from_secs(30); loop { tokio::select! { msg = stream.next() => { match msg { Some(Ok(msg)) => { println!("{:?}", msg); let group = EventGroup::from_primitive(msg.group); if group != EventGroup::DeviceAction { continue; } // send ACK let ack = Message { group: EventGroup::Acknowledgement.into(), code: AcknowledgementEventCode::Ack.into(), data: smallvec![msg.group, msg.code], }; stream.send(&ack).await?; let status = msg.data[0]; println!("Received ring update:"); if status & 0b01 != 0 { println!(" right: ringing"); } else { println!(" right: not ringing"); } if status & 0b10 != 0 { println!(" left: ringing"); } else { println!(" left: not ringing"); } if status & 0b11 == 0 { println!("Buds stopped ringing, exiting..."); return Ok(()); } }, Some(Err(e)) => { Err(e)?; }, None => { let err = std::io::Error::new( std::io::ErrorKind::ConnectionAborted, "connection closed" ); Err(err)?; } } }, _ = tokio::time::sleep_until(timeout) => { println!("Sending command to stop ringing..."); // send message to stop ringing let msg = Message { group: EventGroup::DeviceAction.into(), code: DeviceActionEventCode::Ring.into(), data: smallvec![0x00], }; stream.send(&msg).await?; timeout = tokio::time::Instant::now() + tokio::time::Duration::from_secs(10); }, } } } async fn connect_device_to_profile(profile: &mut ProfileHandle, dev: &Device) -> bluer::Result<bluer::rfcomm::Stream> { loop { tokio::select! { res = async { let _ = dev.connect().await; dev.connect_profile(&gfps::msg::UUID).await } => { if let Err(err) = res { println!("Connecting GFPS profile failed: {:?}", err); } tokio::time::sleep(std::time::Duration::from_millis(3000)).await; }, req = profile.next() => { let req = req.expect("no connection request received"); if req.device() == dev.address() { // accept our device break req.accept(); } else { // reject unknown devices req.reject(ReqError::Rejected); } }, } } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
qzed/pbpctrl
https://github.com/qzed/pbpctrl/blob/2620367a41f92135059f637d92a2e4f427abb44e/libgfps/examples/gfps_get_battery.rs
libgfps/examples/gfps_get_battery.rs
//! Simple example for receiving battery info via the GFPS RFCOMM channel. //! //! Usage: //! cargo run --example gfps_get_battery -- <bluetooth-device-address> use std::str::FromStr; use bluer::{Address, Session, Device}; use bluer::rfcomm::{Profile, ReqError, Role, ProfileHandle}; use futures::StreamExt; use gfps::msg::{Codec, DeviceEventCode, EventGroup, BatteryInfo}; use num_enum::FromPrimitive; #[tokio::main(flavor = "current_thread")] async fn main() -> bluer::Result<()> { // handle command line arguments let addr = std::env::args().nth(1).expect("need device address as argument"); let addr = Address::from_str(&addr)?; // set up session let session = Session::new().await?; let adapter = session.default_adapter().await?; // get device let dev = adapter.device(addr)?; // get RFCOMM stream let stream = { // register GFPS profile let profile = Profile { uuid: gfps::msg::UUID, role: Some(Role::Client), require_authentication: Some(false), require_authorization: Some(false), auto_connect: Some(false), ..Default::default() }; let mut profile_handle = session.register_profile(profile).await?; // connect profile connect_device_to_profile(&mut profile_handle, &dev).await? }; // listen to event messages let codec = Codec::new(); let mut stream = codec.wrap(stream); // The battery status cannot be queried via a normal command. However, it // is sent right after we connect to the GFPS stream. In addition, multiple // events are often sent in sequence. Therefore we do the following: // - Set a deadline for a general timeout. If this passes, we just return // the current state (and if necessary "unknown"): // - Use a timestamp for checking whether we have received any new updates // in a given interval. If we have not received any, we consider the // state to be "settled" and return the battery info. // - On battery events we simply store the sent information. We retreive // the stored information once either of the timeouts kicks in. let deadline = std::time::Instant::now() + std::time::Duration::from_secs(5); let mut timestamp = deadline; let mut bat_left = BatteryInfo::Unknown; let mut bat_right = BatteryInfo::Unknown; let mut bat_case = BatteryInfo::Unknown; let time_settle = std::time::Duration::from_millis(500); loop { tokio::select! { // receive and handle events msg = stream.next() => { match msg { Some(Ok(msg)) => { let group = EventGroup::from_primitive(msg.group); if group != EventGroup::Device { continue; } let code = DeviceEventCode::from_primitive(msg.code); if code == DeviceEventCode::BatteryInfo { timestamp = std::time::Instant::now(); bat_left = BatteryInfo::from_byte(msg.data[0]); bat_right = BatteryInfo::from_byte(msg.data[1]); bat_case = BatteryInfo::from_byte(msg.data[2]); } }, Some(Err(err)) => { Err(err)?; }, None => { let err = std::io::Error::new( std::io::ErrorKind::ConnectionAborted, "connection closed" ); Err(err)?; } } }, // timeout for determining when the state has "settled" _ = tokio::time::sleep(tokio::time::Duration::from_millis(time_settle.as_millis() as _)) => { let delta = std::time::Instant::now() - timestamp; if delta > time_settle { break } }, // general deadline _ = tokio::time::sleep_until(tokio::time::Instant::from_std(deadline)) => { break }, } } println!("Battery status:"); println!(" left bud: {}", bat_left); println!(" right bud: {}", bat_right); println!(" case: {}", bat_case); Ok(()) } async fn connect_device_to_profile(profile: &mut ProfileHandle, dev: &Device) -> bluer::Result<bluer::rfcomm::Stream> { loop { tokio::select! { res = async { let _ = dev.connect().await; dev.connect_profile(&gfps::msg::UUID).await } => { if let Err(err) = res { println!("Connecting GFPS profile failed: {:?}", err); } tokio::time::sleep(std::time::Duration::from_millis(3000)).await; }, req = profile.next() => { let req = req.expect("no connection request received"); if req.device() == dev.address() { // accept our device break req.accept(); } else { // reject unknown devices req.reject(ReqError::Rejected); } }, } } }
rust
Apache-2.0
2620367a41f92135059f637d92a2e4f427abb44e
2026-01-04T20:22:12.408666Z
false
amPerl/egui-phosphor
https://github.com/amPerl/egui-phosphor/blob/c33b60c40f703ffa3d40d252f1bc911cf531581d/src/lib.rs
src/lib.rs
pub mod variants; pub use variants::*; pub fn add_to_fonts(fonts: &mut egui::FontDefinitions, variant: Variant) { fonts .font_data .insert("phosphor".into(), variant.font_data().into()); if let Some(font_keys) = fonts.families.get_mut(&egui::FontFamily::Proportional) { font_keys.insert(1, "phosphor".into()); } }
rust
Apache-2.0
c33b60c40f703ffa3d40d252f1bc911cf531581d
2026-01-04T20:22:14.235772Z
false
amPerl/egui-phosphor
https://github.com/amPerl/egui-phosphor/blob/c33b60c40f703ffa3d40d252f1bc911cf531581d/src/variants/light.rs
src/variants/light.rs
#![allow(unused)] pub const ACORN: &str = "\u{EB9A}"; pub const ADDRESS_BOOK: &str = "\u{E6F8}"; pub const ADDRESS_BOOK_TABS: &str = "\u{EE4E}"; pub const AIR_TRAFFIC_CONTROL: &str = "\u{ECD8}"; pub const AIRPLANE: &str = "\u{E002}"; pub const AIRPLANE_IN_FLIGHT: &str = "\u{E4FE}"; pub const AIRPLANE_LANDING: &str = "\u{E502}"; pub const AIRPLANE_TAKEOFF: &str = "\u{E504}"; pub const AIRPLANE_TAXIING: &str = "\u{E500}"; pub const AIRPLANE_TILT: &str = "\u{E5D6}"; pub const AIRPLAY: &str = "\u{E004}"; pub const ALARM: &str = "\u{E006}"; pub const ALIEN: &str = "\u{E8A6}"; pub const ALIGN_BOTTOM: &str = "\u{E506}"; pub const ALIGN_BOTTOM_SIMPLE: &str = "\u{EB0C}"; pub const ALIGN_CENTER_HORIZONTAL: &str = "\u{E50A}"; pub const ALIGN_CENTER_HORIZONTAL_SIMPLE: &str = "\u{EB0E}"; pub const ALIGN_CENTER_VERTICAL: &str = "\u{E50C}"; pub const ALIGN_CENTER_VERTICAL_SIMPLE: &str = "\u{EB10}"; pub const ALIGN_LEFT: &str = "\u{E50E}"; pub const ALIGN_LEFT_SIMPLE: &str = "\u{EAEE}"; pub const ALIGN_RIGHT: &str = "\u{E510}"; pub const ALIGN_RIGHT_SIMPLE: &str = "\u{EB12}"; pub const ALIGN_TOP: &str = "\u{E512}"; pub const ALIGN_TOP_SIMPLE: &str = "\u{EB14}"; pub const AMAZON_LOGO: &str = "\u{E96C}"; pub const AMBULANCE: &str = "\u{E572}"; pub const ANCHOR: &str = "\u{E514}"; pub const ANCHOR_SIMPLE: &str = "\u{E5D8}"; pub const ANDROID_LOGO: &str = "\u{E008}"; pub const ANGLE: &str = "\u{E7BC}"; pub const ANGULAR_LOGO: &str = "\u{EB80}"; pub const APERTURE: &str = "\u{E00A}"; pub const APP_STORE_LOGO: &str = "\u{E974}"; pub const APP_WINDOW: &str = "\u{E5DA}"; pub const APPLE_LOGO: &str = "\u{E516}"; pub const APPLE_PODCASTS_LOGO: &str = "\u{EB96}"; pub const APPROXIMATE_EQUALS: &str = "\u{EDAA}"; pub const ARCHIVE: &str = "\u{E00C}"; pub const ARMCHAIR: &str = "\u{E012}"; pub const ARROW_ARC_LEFT: &str = "\u{E014}"; pub const ARROW_ARC_RIGHT: &str = "\u{E016}"; pub const ARROW_BEND_DOUBLE_UP_LEFT: &str = "\u{E03A}"; pub const ARROW_BEND_DOUBLE_UP_RIGHT: &str = "\u{E03C}"; pub const ARROW_BEND_DOWN_LEFT: &str = "\u{E018}"; pub const ARROW_BEND_DOWN_RIGHT: &str = "\u{E01A}"; pub const ARROW_BEND_LEFT_DOWN: &str = "\u{E01C}"; pub const ARROW_BEND_LEFT_UP: &str = "\u{E01E}"; pub const ARROW_BEND_RIGHT_DOWN: &str = "\u{E020}"; pub const ARROW_BEND_RIGHT_UP: &str = "\u{E022}"; pub const ARROW_BEND_UP_LEFT: &str = "\u{E024}"; pub const ARROW_BEND_UP_RIGHT: &str = "\u{E026}"; pub const ARROW_CIRCLE_DOWN: &str = "\u{E028}"; pub const ARROW_CIRCLE_DOWN_LEFT: &str = "\u{E02A}"; pub const ARROW_CIRCLE_DOWN_RIGHT: &str = "\u{E02C}"; pub const ARROW_CIRCLE_LEFT: &str = "\u{E05A}"; pub const ARROW_CIRCLE_RIGHT: &str = "\u{E02E}"; pub const ARROW_CIRCLE_UP: &str = "\u{E030}"; pub const ARROW_CIRCLE_UP_LEFT: &str = "\u{E032}"; pub const ARROW_CIRCLE_UP_RIGHT: &str = "\u{E034}"; pub const ARROW_CLOCKWISE: &str = "\u{E036}"; pub const ARROW_COUNTER_CLOCKWISE: &str = "\u{E038}"; pub const ARROW_DOWN: &str = "\u{E03E}"; pub const ARROW_DOWN_LEFT: &str = "\u{E040}"; pub const ARROW_DOWN_RIGHT: &str = "\u{E042}"; pub const ARROW_ELBOW_DOWN_LEFT: &str = "\u{E044}"; pub const ARROW_ELBOW_DOWN_RIGHT: &str = "\u{E046}"; pub const ARROW_ELBOW_LEFT: &str = "\u{E048}"; pub const ARROW_ELBOW_LEFT_DOWN: &str = "\u{E04A}"; pub const ARROW_ELBOW_LEFT_UP: &str = "\u{E04C}"; pub const ARROW_ELBOW_RIGHT: &str = "\u{E04E}"; pub const ARROW_ELBOW_RIGHT_DOWN: &str = "\u{E050}"; pub const ARROW_ELBOW_RIGHT_UP: &str = "\u{E052}"; pub const ARROW_ELBOW_UP_LEFT: &str = "\u{E054}"; pub const ARROW_ELBOW_UP_RIGHT: &str = "\u{E056}"; pub const ARROW_FAT_DOWN: &str = "\u{E518}"; pub const ARROW_FAT_LEFT: &str = "\u{E51A}"; pub const ARROW_FAT_LINE_DOWN: &str = "\u{E51C}"; pub const ARROW_FAT_LINE_LEFT: &str = "\u{E51E}"; pub const ARROW_FAT_LINE_RIGHT: &str = "\u{E520}"; pub const ARROW_FAT_LINE_UP: &str = "\u{E522}"; pub const ARROW_FAT_LINES_DOWN: &str = "\u{E524}"; pub const ARROW_FAT_LINES_LEFT: &str = "\u{E526}"; pub const ARROW_FAT_LINES_RIGHT: &str = "\u{E528}"; pub const ARROW_FAT_LINES_UP: &str = "\u{E52A}"; pub const ARROW_FAT_RIGHT: &str = "\u{E52C}"; pub const ARROW_FAT_UP: &str = "\u{E52E}"; pub const ARROW_LEFT: &str = "\u{E058}"; pub const ARROW_LINE_DOWN: &str = "\u{E05C}"; pub const ARROW_LINE_DOWN_LEFT: &str = "\u{E05E}"; pub const ARROW_LINE_DOWN_RIGHT: &str = "\u{E060}"; pub const ARROW_LINE_LEFT: &str = "\u{E062}"; pub const ARROW_LINE_RIGHT: &str = "\u{E064}"; pub const ARROW_LINE_UP: &str = "\u{E066}"; pub const ARROW_LINE_UP_LEFT: &str = "\u{E068}"; pub const ARROW_LINE_UP_RIGHT: &str = "\u{E06A}"; pub const ARROW_RIGHT: &str = "\u{E06C}"; pub const ARROW_SQUARE_DOWN: &str = "\u{E06E}"; pub const ARROW_SQUARE_DOWN_LEFT: &str = "\u{E070}"; pub const ARROW_SQUARE_DOWN_RIGHT: &str = "\u{E072}"; pub const ARROW_SQUARE_IN: &str = "\u{E5DC}"; pub const ARROW_SQUARE_LEFT: &str = "\u{E074}"; pub const ARROW_SQUARE_OUT: &str = "\u{E5DE}"; pub const ARROW_SQUARE_RIGHT: &str = "\u{E076}"; pub const ARROW_SQUARE_UP: &str = "\u{E078}"; pub const ARROW_SQUARE_UP_LEFT: &str = "\u{E07A}"; pub const ARROW_SQUARE_UP_RIGHT: &str = "\u{E07C}"; pub const ARROW_U_DOWN_LEFT: &str = "\u{E07E}"; pub const ARROW_U_DOWN_RIGHT: &str = "\u{E080}"; pub const ARROW_U_LEFT_DOWN: &str = "\u{E082}"; pub const ARROW_U_LEFT_UP: &str = "\u{E084}"; pub const ARROW_U_RIGHT_DOWN: &str = "\u{E086}"; pub const ARROW_U_RIGHT_UP: &str = "\u{E088}"; pub const ARROW_U_UP_LEFT: &str = "\u{E08A}"; pub const ARROW_U_UP_RIGHT: &str = "\u{E08C}"; pub const ARROW_UP: &str = "\u{E08E}"; pub const ARROW_UP_LEFT: &str = "\u{E090}"; pub const ARROW_UP_RIGHT: &str = "\u{E092}"; pub const ARROWS_CLOCKWISE: &str = "\u{E094}"; pub const ARROWS_COUNTER_CLOCKWISE: &str = "\u{E096}"; pub const ARROWS_DOWN_UP: &str = "\u{E098}"; pub const ARROWS_HORIZONTAL: &str = "\u{EB06}"; pub const ARROWS_IN: &str = "\u{E09A}"; pub const ARROWS_IN_CARDINAL: &str = "\u{E09C}"; pub const ARROWS_IN_LINE_HORIZONTAL: &str = "\u{E530}"; pub const ARROWS_IN_LINE_VERTICAL: &str = "\u{E532}"; pub const ARROWS_IN_SIMPLE: &str = "\u{E09E}"; pub const ARROWS_LEFT_RIGHT: &str = "\u{E0A0}"; pub const ARROWS_MERGE: &str = "\u{ED3E}"; pub const ARROWS_OUT: &str = "\u{E0A2}"; pub const ARROWS_OUT_CARDINAL: &str = "\u{E0A4}"; pub const ARROWS_OUT_LINE_HORIZONTAL: &str = "\u{E534}"; pub const ARROWS_OUT_LINE_VERTICAL: &str = "\u{E536}"; pub const ARROWS_OUT_SIMPLE: &str = "\u{E0A6}"; pub const ARROWS_SPLIT: &str = "\u{ED3C}"; pub const ARROWS_VERTICAL: &str = "\u{EB04}"; pub const ARTICLE: &str = "\u{E0A8}"; pub const ARTICLE_MEDIUM: &str = "\u{E5E0}"; pub const ARTICLE_NY_TIMES: &str = "\u{E5E2}"; pub const ASCLEPIUS: &str = "\u{EE34}"; pub const CADUCEUS: &str = "\u{EE34}"; pub const ASTERISK: &str = "\u{E0AA}"; pub const ASTERISK_SIMPLE: &str = "\u{E832}"; pub const AT: &str = "\u{E0AC}"; pub const ATOM: &str = "\u{E5E4}"; pub const AVOCADO: &str = "\u{EE04}"; pub const AXE: &str = "\u{E9FC}"; pub const BABY: &str = "\u{E774}"; pub const BABY_CARRIAGE: &str = "\u{E818}"; pub const BACKPACK: &str = "\u{E922}"; pub const BACKSPACE: &str = "\u{E0AE}"; pub const BAG: &str = "\u{E0B0}"; pub const BAG_SIMPLE: &str = "\u{E5E6}"; pub const BALLOON: &str = "\u{E76C}"; pub const BANDAIDS: &str = "\u{E0B2}"; pub const BANK: &str = "\u{E0B4}"; pub const BARBELL: &str = "\u{E0B6}"; pub const BARCODE: &str = "\u{E0B8}"; pub const BARN: &str = "\u{EC72}"; pub const BARRICADE: &str = "\u{E948}"; pub const BASEBALL: &str = "\u{E71A}"; pub const BASEBALL_CAP: &str = "\u{EA28}"; pub const BASEBALL_HELMET: &str = "\u{EE4A}"; pub const BASKET: &str = "\u{E964}"; pub const BASKETBALL: &str = "\u{E724}"; pub const BATHTUB: &str = "\u{E81E}"; pub const BATTERY_CHARGING: &str = "\u{E0BA}"; pub const BATTERY_CHARGING_VERTICAL: &str = "\u{E0BC}"; pub const BATTERY_EMPTY: &str = "\u{E0BE}"; pub const BATTERY_FULL: &str = "\u{E0C0}"; pub const BATTERY_HIGH: &str = "\u{E0C2}"; pub const BATTERY_LOW: &str = "\u{E0C4}"; pub const BATTERY_MEDIUM: &str = "\u{E0C6}"; pub const BATTERY_PLUS: &str = "\u{E808}"; pub const BATTERY_PLUS_VERTICAL: &str = "\u{EC50}"; pub const BATTERY_VERTICAL_EMPTY: &str = "\u{E7C6}"; pub const BATTERY_VERTICAL_FULL: &str = "\u{E7C4}"; pub const BATTERY_VERTICAL_HIGH: &str = "\u{E7C2}"; pub const BATTERY_VERTICAL_LOW: &str = "\u{E7BE}"; pub const BATTERY_VERTICAL_MEDIUM: &str = "\u{E7C0}"; pub const BATTERY_WARNING: &str = "\u{E0C8}"; pub const BATTERY_WARNING_VERTICAL: &str = "\u{E0CA}"; pub const BEACH_BALL: &str = "\u{ED24}"; pub const BEANIE: &str = "\u{EA2A}"; pub const BED: &str = "\u{E0CC}"; pub const BEER_BOTTLE: &str = "\u{E7B0}"; pub const BEER_STEIN: &str = "\u{EB62}"; pub const BEHANCE_LOGO: &str = "\u{E7F4}"; pub const BELL: &str = "\u{E0CE}"; pub const BELL_RINGING: &str = "\u{E5E8}"; pub const BELL_SIMPLE: &str = "\u{E0D0}"; pub const BELL_SIMPLE_RINGING: &str = "\u{E5EA}"; pub const BELL_SIMPLE_SLASH: &str = "\u{E0D2}"; pub const BELL_SIMPLE_Z: &str = "\u{E5EC}"; pub const BELL_SLASH: &str = "\u{E0D4}"; pub const BELL_Z: &str = "\u{E5EE}"; pub const BELT: &str = "\u{EA2C}"; pub const BEZIER_CURVE: &str = "\u{EB00}"; pub const BICYCLE: &str = "\u{E0D6}"; pub const BINARY: &str = "\u{EE60}"; pub const BINOCULARS: &str = "\u{EA64}"; pub const BIOHAZARD: &str = "\u{E9E0}"; pub const BIRD: &str = "\u{E72C}"; pub const BLUEPRINT: &str = "\u{EDA0}"; pub const BLUETOOTH: &str = "\u{E0DA}"; pub const BLUETOOTH_CONNECTED: &str = "\u{E0DC}"; pub const BLUETOOTH_SLASH: &str = "\u{E0DE}"; pub const BLUETOOTH_X: &str = "\u{E0E0}"; pub const BOAT: &str = "\u{E786}"; pub const BOMB: &str = "\u{EE0A}"; pub const BONE: &str = "\u{E7F2}"; pub const BOOK: &str = "\u{E0E2}"; pub const BOOK_BOOKMARK: &str = "\u{E0E4}"; pub const BOOK_OPEN: &str = "\u{E0E6}"; pub const BOOK_OPEN_TEXT: &str = "\u{E8F2}"; pub const BOOK_OPEN_USER: &str = "\u{EDE0}"; pub const BOOKMARK: &str = "\u{E0E8}"; pub const BOOKMARK_SIMPLE: &str = "\u{E0EA}"; pub const BOOKMARKS: &str = "\u{E0EC}"; pub const BOOKMARKS_SIMPLE: &str = "\u{E5F0}"; pub const BOOKS: &str = "\u{E758}"; pub const BOOT: &str = "\u{ECCA}"; pub const BOULES: &str = "\u{E722}"; pub const BOUNDING_BOX: &str = "\u{E6CE}"; pub const BOWL_FOOD: &str = "\u{EAA4}"; pub const BOWL_STEAM: &str = "\u{E8E4}"; pub const BOWLING_BALL: &str = "\u{EA34}"; pub const BOX_ARROW_DOWN: &str = "\u{E00E}"; pub const ARCHIVE_BOX: &str = "\u{E00E}"; pub const BOX_ARROW_UP: &str = "\u{EE54}"; pub const BOXING_GLOVE: &str = "\u{EA36}"; pub const BRACKETS_ANGLE: &str = "\u{E862}"; pub const BRACKETS_CURLY: &str = "\u{E860}"; pub const BRACKETS_ROUND: &str = "\u{E864}"; pub const BRACKETS_SQUARE: &str = "\u{E85E}"; pub const BRAIN: &str = "\u{E74E}"; pub const BRANDY: &str = "\u{E6B4}"; pub const BREAD: &str = "\u{E81C}"; pub const BRIDGE: &str = "\u{EA68}"; pub const BRIEFCASE: &str = "\u{E0EE}"; pub const BRIEFCASE_METAL: &str = "\u{E5F2}"; pub const BROADCAST: &str = "\u{E0F2}"; pub const BROOM: &str = "\u{EC54}"; pub const BROWSER: &str = "\u{E0F4}"; pub const BROWSERS: &str = "\u{E0F6}"; pub const BUG: &str = "\u{E5F4}"; pub const BUG_BEETLE: &str = "\u{E5F6}"; pub const BUG_DROID: &str = "\u{E5F8}"; pub const BUILDING: &str = "\u{E100}"; pub const BUILDING_APARTMENT: &str = "\u{E0FE}"; pub const BUILDING_OFFICE: &str = "\u{E0FF}"; pub const BUILDINGS: &str = "\u{E102}"; pub const BULLDOZER: &str = "\u{EC6C}"; pub const BUS: &str = "\u{E106}"; pub const BUTTERFLY: &str = "\u{EA6E}"; pub const CABLE_CAR: &str = "\u{E49C}"; pub const CACTUS: &str = "\u{E918}"; pub const CAKE: &str = "\u{E780}"; pub const CALCULATOR: &str = "\u{E538}"; pub const CALENDAR: &str = "\u{E108}"; pub const CALENDAR_BLANK: &str = "\u{E10A}"; pub const CALENDAR_CHECK: &str = "\u{E712}"; pub const CALENDAR_DOT: &str = "\u{E7B2}"; pub const CALENDAR_DOTS: &str = "\u{E7B4}"; pub const CALENDAR_HEART: &str = "\u{E8B0}"; pub const CALENDAR_MINUS: &str = "\u{EA14}"; pub const CALENDAR_PLUS: &str = "\u{E714}"; pub const CALENDAR_SLASH: &str = "\u{EA12}"; pub const CALENDAR_STAR: &str = "\u{E8B2}"; pub const CALENDAR_X: &str = "\u{E10C}"; pub const CALL_BELL: &str = "\u{E7DE}"; pub const CAMERA: &str = "\u{E10E}"; pub const CAMERA_PLUS: &str = "\u{EC58}"; pub const CAMERA_ROTATE: &str = "\u{E7A4}"; pub const CAMERA_SLASH: &str = "\u{E110}"; pub const CAMPFIRE: &str = "\u{E9D8}"; pub const CAR: &str = "\u{E112}"; pub const CAR_BATTERY: &str = "\u{EE30}"; pub const CAR_PROFILE: &str = "\u{E8CC}"; pub const CAR_SIMPLE: &str = "\u{E114}"; pub const CARDHOLDER: &str = "\u{E5FA}"; pub const CARDS: &str = "\u{E0F8}"; pub const CARDS_THREE: &str = "\u{EE50}"; pub const CARET_CIRCLE_DOUBLE_DOWN: &str = "\u{E116}"; pub const CARET_CIRCLE_DOUBLE_LEFT: &str = "\u{E118}"; pub const CARET_CIRCLE_DOUBLE_RIGHT: &str = "\u{E11A}"; pub const CARET_CIRCLE_DOUBLE_UP: &str = "\u{E11C}"; pub const CARET_CIRCLE_DOWN: &str = "\u{E11E}"; pub const CARET_CIRCLE_LEFT: &str = "\u{E120}"; pub const CARET_CIRCLE_RIGHT: &str = "\u{E122}"; pub const CARET_CIRCLE_UP: &str = "\u{E124}"; pub const CARET_CIRCLE_UP_DOWN: &str = "\u{E13E}"; pub const CARET_DOUBLE_DOWN: &str = "\u{E126}"; pub const CARET_DOUBLE_LEFT: &str = "\u{E128}"; pub const CARET_DOUBLE_RIGHT: &str = "\u{E12A}"; pub const CARET_DOUBLE_UP: &str = "\u{E12C}"; pub const CARET_DOWN: &str = "\u{E136}"; pub const CARET_LEFT: &str = "\u{E138}"; pub const CARET_LINE_DOWN: &str = "\u{E134}"; pub const CARET_LINE_LEFT: &str = "\u{E132}"; pub const CARET_LINE_RIGHT: &str = "\u{E130}"; pub const CARET_LINE_UP: &str = "\u{E12E}"; pub const CARET_RIGHT: &str = "\u{E13A}"; pub const CARET_UP: &str = "\u{E13C}"; pub const CARET_UP_DOWN: &str = "\u{E140}"; pub const CARROT: &str = "\u{ED38}"; pub const CASH_REGISTER: &str = "\u{ED80}"; pub const CASSETTE_TAPE: &str = "\u{ED2E}"; pub const CASTLE_TURRET: &str = "\u{E9D0}"; pub const CAT: &str = "\u{E748}"; pub const CELL_SIGNAL_FULL: &str = "\u{E142}"; pub const CELL_SIGNAL_HIGH: &str = "\u{E144}"; pub const CELL_SIGNAL_LOW: &str = "\u{E146}"; pub const CELL_SIGNAL_MEDIUM: &str = "\u{E148}"; pub const CELL_SIGNAL_NONE: &str = "\u{E14A}"; pub const CELL_SIGNAL_SLASH: &str = "\u{E14C}"; pub const CELL_SIGNAL_X: &str = "\u{E14E}"; pub const CELL_TOWER: &str = "\u{EBAA}"; pub const CERTIFICATE: &str = "\u{E766}"; pub const CHAIR: &str = "\u{E950}"; pub const CHALKBOARD: &str = "\u{E5FC}"; pub const CHALKBOARD_SIMPLE: &str = "\u{E5FE}"; pub const CHALKBOARD_TEACHER: &str = "\u{E600}"; pub const CHAMPAGNE: &str = "\u{EACA}"; pub const CHARGING_STATION: &str = "\u{E8D0}"; pub const CHART_BAR: &str = "\u{E150}"; pub const CHART_BAR_HORIZONTAL: &str = "\u{E152}"; pub const CHART_DONUT: &str = "\u{EAA6}"; pub const CHART_LINE: &str = "\u{E154}"; pub const CHART_LINE_DOWN: &str = "\u{E8B6}"; pub const CHART_LINE_UP: &str = "\u{E156}"; pub const CHART_PIE: &str = "\u{E158}"; pub const CHART_PIE_SLICE: &str = "\u{E15A}"; pub const CHART_POLAR: &str = "\u{EAA8}"; pub const CHART_SCATTER: &str = "\u{EAAC}"; pub const CHAT: &str = "\u{E15C}"; pub const CHAT_CENTERED: &str = "\u{E160}"; pub const CHAT_CENTERED_DOTS: &str = "\u{E164}"; pub const CHAT_CENTERED_SLASH: &str = "\u{E162}"; pub const CHAT_CENTERED_TEXT: &str = "\u{E166}"; pub const CHAT_CIRCLE: &str = "\u{E168}"; pub const CHAT_CIRCLE_DOTS: &str = "\u{E16C}"; pub const CHAT_CIRCLE_SLASH: &str = "\u{E16A}"; pub const CHAT_CIRCLE_TEXT: &str = "\u{E16E}"; pub const CHAT_DOTS: &str = "\u{E170}"; pub const CHAT_SLASH: &str = "\u{E15E}"; pub const CHAT_TEARDROP: &str = "\u{E172}"; pub const CHAT_TEARDROP_DOTS: &str = "\u{E176}"; pub const CHAT_TEARDROP_SLASH: &str = "\u{E174}"; pub const CHAT_TEARDROP_TEXT: &str = "\u{E178}"; pub const CHAT_TEXT: &str = "\u{E17A}"; pub const CHATS: &str = "\u{E17C}"; pub const CHATS_CIRCLE: &str = "\u{E17E}"; pub const CHATS_TEARDROP: &str = "\u{E180}"; pub const CHECK: &str = "\u{E182}"; pub const CHECK_CIRCLE: &str = "\u{E184}"; pub const CHECK_FAT: &str = "\u{EBA6}"; pub const CHECK_SQUARE: &str = "\u{E186}"; pub const CHECK_SQUARE_OFFSET: &str = "\u{E188}"; pub const CHECKERBOARD: &str = "\u{E8C4}"; pub const CHECKS: &str = "\u{E53A}"; pub const CHEERS: &str = "\u{EA4A}"; pub const CHEESE: &str = "\u{E9FE}"; pub const CHEF_HAT: &str = "\u{ED8E}"; pub const CHERRIES: &str = "\u{E830}"; pub const CHURCH: &str = "\u{ECEA}"; pub const CIGARETTE: &str = "\u{ED90}"; pub const CIGARETTE_SLASH: &str = "\u{ED92}"; pub const CIRCLE: &str = "\u{E18A}"; pub const CIRCLE_DASHED: &str = "\u{E602}"; pub const CIRCLE_HALF: &str = "\u{E18C}"; pub const CIRCLE_HALF_TILT: &str = "\u{E18E}"; pub const CIRCLE_NOTCH: &str = "\u{EB44}"; pub const CIRCLES_FOUR: &str = "\u{E190}"; pub const CIRCLES_THREE: &str = "\u{E192}"; pub const CIRCLES_THREE_PLUS: &str = "\u{E194}"; pub const CIRCUITRY: &str = "\u{E9C2}"; pub const CITY: &str = "\u{EA6A}"; pub const CLIPBOARD: &str = "\u{E196}"; pub const CLIPBOARD_TEXT: &str = "\u{E198}"; pub const CLOCK: &str = "\u{E19A}"; pub const CLOCK_AFTERNOON: &str = "\u{E19C}"; pub const CLOCK_CLOCKWISE: &str = "\u{E19E}"; pub const CLOCK_COUNTDOWN: &str = "\u{ED2C}"; pub const CLOCK_COUNTER_CLOCKWISE: &str = "\u{E1A0}"; pub const CLOCK_USER: &str = "\u{EDEC}"; pub const CLOSED_CAPTIONING: &str = "\u{E1A4}"; pub const CLOUD: &str = "\u{E1AA}"; pub const CLOUD_ARROW_DOWN: &str = "\u{E1AC}"; pub const CLOUD_ARROW_UP: &str = "\u{E1AE}"; pub const CLOUD_CHECK: &str = "\u{E1B0}"; pub const CLOUD_FOG: &str = "\u{E53C}"; pub const CLOUD_LIGHTNING: &str = "\u{E1B2}"; pub const CLOUD_MOON: &str = "\u{E53E}"; pub const CLOUD_RAIN: &str = "\u{E1B4}"; pub const CLOUD_SLASH: &str = "\u{E1B6}"; pub const CLOUD_SNOW: &str = "\u{E1B8}"; pub const CLOUD_SUN: &str = "\u{E540}"; pub const CLOUD_WARNING: &str = "\u{EA98}"; pub const CLOUD_X: &str = "\u{EA96}"; pub const CLOVER: &str = "\u{EDC8}"; pub const CLUB: &str = "\u{E1BA}"; pub const COAT_HANGER: &str = "\u{E7FE}"; pub const CODA_LOGO: &str = "\u{E7CE}"; pub const CODE: &str = "\u{E1BC}"; pub const CODE_BLOCK: &str = "\u{EAFE}"; pub const CODE_SIMPLE: &str = "\u{E1BE}"; pub const CODEPEN_LOGO: &str = "\u{E978}"; pub const CODESANDBOX_LOGO: &str = "\u{EA06}"; pub const COFFEE: &str = "\u{E1C2}"; pub const COFFEE_BEAN: &str = "\u{E1C0}"; pub const COIN: &str = "\u{E60E}"; pub const COIN_VERTICAL: &str = "\u{EB48}"; pub const COINS: &str = "\u{E78E}"; pub const COLUMNS: &str = "\u{E546}"; pub const COLUMNS_PLUS_LEFT: &str = "\u{E544}"; pub const COLUMNS_PLUS_RIGHT: &str = "\u{E542}"; pub const COMMAND: &str = "\u{E1C4}"; pub const COMPASS: &str = "\u{E1C8}"; pub const COMPASS_ROSE: &str = "\u{E1C6}"; pub const COMPASS_TOOL: &str = "\u{EA0E}"; pub const COMPUTER_TOWER: &str = "\u{E548}"; pub const CONFETTI: &str = "\u{E81A}"; pub const CONTACTLESS_PAYMENT: &str = "\u{ED42}"; pub const CONTROL: &str = "\u{ECA6}"; pub const COOKIE: &str = "\u{E6CA}"; pub const COOKING_POT: &str = "\u{E764}"; pub const COPY: &str = "\u{E1CA}"; pub const COPY_SIMPLE: &str = "\u{E1CC}"; pub const COPYLEFT: &str = "\u{E86A}"; pub const COPYRIGHT: &str = "\u{E54A}"; pub const CORNERS_IN: &str = "\u{E1CE}"; pub const CORNERS_OUT: &str = "\u{E1D0}"; pub const COUCH: &str = "\u{E7F6}"; pub const COURT_BASKETBALL: &str = "\u{EE36}"; pub const COW: &str = "\u{EABE}"; pub const COWBOY_HAT: &str = "\u{ED12}"; pub const CPU: &str = "\u{E610}"; pub const CRANE: &str = "\u{ED48}"; pub const CRANE_TOWER: &str = "\u{ED49}"; pub const CREDIT_CARD: &str = "\u{E1D2}"; pub const CRICKET: &str = "\u{EE12}"; pub const CROP: &str = "\u{E1D4}"; pub const CROSS: &str = "\u{E8A0}"; pub const CROSSHAIR: &str = "\u{E1D6}"; pub const CROSSHAIR_SIMPLE: &str = "\u{E1D8}"; pub const CROWN: &str = "\u{E614}"; pub const CROWN_CROSS: &str = "\u{EE5E}"; pub const CROWN_SIMPLE: &str = "\u{E616}"; pub const CUBE: &str = "\u{E1DA}"; pub const CUBE_FOCUS: &str = "\u{ED0A}"; pub const CUBE_TRANSPARENT: &str = "\u{EC7C}"; pub const CURRENCY_BTC: &str = "\u{E618}"; pub const CURRENCY_CIRCLE_DOLLAR: &str = "\u{E54C}"; pub const CURRENCY_CNY: &str = "\u{E54E}"; pub const CURRENCY_DOLLAR: &str = "\u{E550}"; pub const CURRENCY_DOLLAR_SIMPLE: &str = "\u{E552}"; pub const CURRENCY_ETH: &str = "\u{EADA}"; pub const CURRENCY_EUR: &str = "\u{E554}"; pub const CURRENCY_GBP: &str = "\u{E556}"; pub const CURRENCY_INR: &str = "\u{E558}"; pub const CURRENCY_JPY: &str = "\u{E55A}"; pub const CURRENCY_KRW: &str = "\u{E55C}"; pub const CURRENCY_KZT: &str = "\u{EC4C}"; pub const CURRENCY_NGN: &str = "\u{EB52}"; pub const CURRENCY_RUB: &str = "\u{E55E}"; pub const CURSOR: &str = "\u{E1DC}"; pub const CURSOR_CLICK: &str = "\u{E7C8}"; pub const CURSOR_TEXT: &str = "\u{E7D8}"; pub const CYLINDER: &str = "\u{E8FC}"; pub const DATABASE: &str = "\u{E1DE}"; pub const DESK: &str = "\u{ED16}"; pub const DESKTOP: &str = "\u{E560}"; pub const DESKTOP_TOWER: &str = "\u{E562}"; pub const DETECTIVE: &str = "\u{E83E}"; pub const DEV_TO_LOGO: &str = "\u{ED0E}"; pub const DEVICE_MOBILE: &str = "\u{E1E0}"; pub const DEVICE_MOBILE_CAMERA: &str = "\u{E1E2}"; pub const DEVICE_MOBILE_SLASH: &str = "\u{EE46}"; pub const DEVICE_MOBILE_SPEAKER: &str = "\u{E1E4}"; pub const DEVICE_ROTATE: &str = "\u{EDF2}"; pub const DEVICE_TABLET: &str = "\u{E1E6}"; pub const DEVICE_TABLET_CAMERA: &str = "\u{E1E8}"; pub const DEVICE_TABLET_SPEAKER: &str = "\u{E1EA}"; pub const DEVICES: &str = "\u{EBA4}"; pub const DIAMOND: &str = "\u{E1EC}"; pub const DIAMONDS_FOUR: &str = "\u{E8F4}"; pub const DICE_FIVE: &str = "\u{E1EE}"; pub const DICE_FOUR: &str = "\u{E1F0}"; pub const DICE_ONE: &str = "\u{E1F2}"; pub const DICE_SIX: &str = "\u{E1F4}"; pub const DICE_THREE: &str = "\u{E1F6}"; pub const DICE_TWO: &str = "\u{E1F8}"; pub const DISC: &str = "\u{E564}"; pub const DISCO_BALL: &str = "\u{ED98}"; pub const DISCORD_LOGO: &str = "\u{E61A}"; pub const DIVIDE: &str = "\u{E1FA}"; pub const DNA: &str = "\u{E924}"; pub const DOG: &str = "\u{E74A}"; pub const DOOR: &str = "\u{E61C}"; pub const DOOR_OPEN: &str = "\u{E7E6}"; pub const DOT: &str = "\u{ECDE}"; pub const DOT_OUTLINE: &str = "\u{ECE0}"; pub const DOTS_NINE: &str = "\u{E1FC}"; pub const DOTS_SIX: &str = "\u{E794}"; pub const DOTS_SIX_VERTICAL: &str = "\u{EAE2}"; pub const DOTS_THREE: &str = "\u{E1FE}"; pub const DOTS_THREE_CIRCLE: &str = "\u{E200}"; pub const DOTS_THREE_CIRCLE_VERTICAL: &str = "\u{E202}"; pub const DOTS_THREE_OUTLINE: &str = "\u{E204}"; pub const DOTS_THREE_OUTLINE_VERTICAL: &str = "\u{E206}"; pub const DOTS_THREE_VERTICAL: &str = "\u{E208}"; pub const DOWNLOAD: &str = "\u{E20A}"; pub const DOWNLOAD_SIMPLE: &str = "\u{E20C}"; pub const DRESS: &str = "\u{EA7E}"; pub const DRESSER: &str = "\u{E94E}"; pub const DRIBBBLE_LOGO: &str = "\u{E20E}"; pub const DRONE: &str = "\u{ED74}"; pub const DROP: &str = "\u{E210}"; pub const DROP_HALF: &str = "\u{E566}"; pub const DROP_HALF_BOTTOM: &str = "\u{EB40}"; pub const DROP_SIMPLE: &str = "\u{EE32}"; pub const DROP_SLASH: &str = "\u{E954}"; pub const DROPBOX_LOGO: &str = "\u{E7D0}"; pub const EAR: &str = "\u{E70C}"; pub const EAR_SLASH: &str = "\u{E70E}"; pub const EGG: &str = "\u{E812}"; pub const EGG_CRACK: &str = "\u{EB64}"; pub const EJECT: &str = "\u{E212}"; pub const EJECT_SIMPLE: &str = "\u{E6AE}"; pub const ELEVATOR: &str = "\u{ECC0}"; pub const EMPTY: &str = "\u{EDBC}"; pub const ENGINE: &str = "\u{EA80}"; pub const ENVELOPE: &str = "\u{E214}"; pub const ENVELOPE_OPEN: &str = "\u{E216}"; pub const ENVELOPE_SIMPLE: &str = "\u{E218}"; pub const ENVELOPE_SIMPLE_OPEN: &str = "\u{E21A}"; pub const EQUALIZER: &str = "\u{EBBC}"; pub const EQUALS: &str = "\u{E21C}"; pub const ERASER: &str = "\u{E21E}"; pub const ESCALATOR_DOWN: &str = "\u{ECBA}"; pub const ESCALATOR_UP: &str = "\u{ECBC}"; pub const EXAM: &str = "\u{E742}"; pub const EXCLAMATION_MARK: &str = "\u{EE44}"; pub const EXCLUDE: &str = "\u{E882}"; pub const EXCLUDE_SQUARE: &str = "\u{E880}"; pub const EXPORT: &str = "\u{EAF0}"; pub const EYE: &str = "\u{E220}"; pub const EYE_CLOSED: &str = "\u{E222}"; pub const EYE_SLASH: &str = "\u{E224}"; pub const EYEDROPPER: &str = "\u{E568}"; pub const EYEDROPPER_SAMPLE: &str = "\u{EAC4}"; pub const EYEGLASSES: &str = "\u{E7BA}"; pub const EYES: &str = "\u{EE5C}"; pub const FACE_MASK: &str = "\u{E56A}"; pub const FACEBOOK_LOGO: &str = "\u{E226}"; pub const FACTORY: &str = "\u{E760}"; pub const FADERS: &str = "\u{E228}"; pub const FADERS_HORIZONTAL: &str = "\u{E22A}"; pub const FALLOUT_SHELTER: &str = "\u{E9DE}"; pub const FAN: &str = "\u{E9F2}"; pub const FARM: &str = "\u{EC70}"; pub const FAST_FORWARD: &str = "\u{E6A6}"; pub const FAST_FORWARD_CIRCLE: &str = "\u{E22C}"; pub const FEATHER: &str = "\u{E9C0}"; pub const FEDIVERSE_LOGO: &str = "\u{ED66}"; pub const FIGMA_LOGO: &str = "\u{E22E}"; pub const FILE: &str = "\u{E230}"; pub const FILE_ARCHIVE: &str = "\u{EB2A}"; pub const FILE_ARROW_DOWN: &str = "\u{E232}"; pub const FILE_ARROW_UP: &str = "\u{E61E}"; pub const FILE_AUDIO: &str = "\u{EA20}"; pub const FILE_C: &str = "\u{EB32}"; pub const FILE_C_SHARP: &str = "\u{EB30}"; pub const FILE_CLOUD: &str = "\u{E95E}"; pub const FILE_CODE: &str = "\u{E914}"; pub const FILE_CPP: &str = "\u{EB2E}"; pub const FILE_CSS: &str = "\u{EB34}"; pub const FILE_CSV: &str = "\u{EB1C}"; pub const FILE_DASHED: &str = "\u{E704}"; pub const FILE_DOTTED: &str = "\u{E704}"; pub const FILE_DOC: &str = "\u{EB1E}"; pub const FILE_HTML: &str = "\u{EB38}"; pub const FILE_IMAGE: &str = "\u{EA24}"; pub const FILE_INI: &str = "\u{EB33}"; pub const FILE_JPG: &str = "\u{EB1A}"; pub const FILE_JS: &str = "\u{EB24}"; pub const FILE_JSX: &str = "\u{EB3A}"; pub const FILE_LOCK: &str = "\u{E95C}"; pub const FILE_MAGNIFYING_GLASS: &str = "\u{E238}"; pub const FILE_SEARCH: &str = "\u{E238}"; pub const FILE_MD: &str = "\u{ED50}"; pub const FILE_MINUS: &str = "\u{E234}"; pub const FILE_PDF: &str = "\u{E702}"; pub const FILE_PLUS: &str = "\u{E236}"; pub const FILE_PNG: &str = "\u{EB18}"; pub const FILE_PPT: &str = "\u{EB20}"; pub const FILE_PY: &str = "\u{EB2C}"; pub const FILE_RS: &str = "\u{EB28}"; pub const FILE_SQL: &str = "\u{ED4E}"; pub const FILE_SVG: &str = "\u{ED08}"; pub const FILE_TEXT: &str = "\u{E23A}"; pub const FILE_TS: &str = "\u{EB26}"; pub const FILE_TSX: &str = "\u{EB3C}"; pub const FILE_TXT: &str = "\u{EB35}"; pub const FILE_VIDEO: &str = "\u{EA22}"; pub const FILE_VUE: &str = "\u{EB3E}"; pub const FILE_X: &str = "\u{E23C}"; pub const FILE_XLS: &str = "\u{EB22}"; pub const FILE_ZIP: &str = "\u{E958}"; pub const FILES: &str = "\u{E710}"; pub const FILM_REEL: &str = "\u{E8C0}"; pub const FILM_SCRIPT: &str = "\u{EB50}"; pub const FILM_SLATE: &str = "\u{E8C2}"; pub const FILM_STRIP: &str = "\u{E792}"; pub const FINGERPRINT: &str = "\u{E23E}"; pub const FINGERPRINT_SIMPLE: &str = "\u{E240}"; pub const FINN_THE_HUMAN: &str = "\u{E56C}"; pub const FIRE: &str = "\u{E242}"; pub const FIRE_EXTINGUISHER: &str = "\u{E9E8}"; pub const FIRE_SIMPLE: &str = "\u{E620}"; pub const FIRE_TRUCK: &str = "\u{E574}"; pub const FIRST_AID: &str = "\u{E56E}"; pub const FIRST_AID_KIT: &str = "\u{E570}"; pub const FISH: &str = "\u{E728}"; pub const FISH_SIMPLE: &str = "\u{E72A}"; pub const FLAG: &str = "\u{E244}"; pub const FLAG_BANNER: &str = "\u{E622}"; pub const FLAG_BANNER_FOLD: &str = "\u{ECF2}"; pub const FLAG_CHECKERED: &str = "\u{EA38}"; pub const FLAG_PENNANT: &str = "\u{ECF0}"; pub const FLAME: &str = "\u{E624}"; pub const FLASHLIGHT: &str = "\u{E246}"; pub const FLASK: &str = "\u{E79E}"; pub const FLIP_HORIZONTAL: &str = "\u{ED6A}"; pub const FLIP_VERTICAL: &str = "\u{ED6C}"; pub const FLOPPY_DISK: &str = "\u{E248}"; pub const FLOPPY_DISK_BACK: &str = "\u{EAF4}"; pub const FLOW_ARROW: &str = "\u{E6EC}"; pub const FLOWER: &str = "\u{E75E}"; pub const FLOWER_LOTUS: &str = "\u{E6CC}"; pub const FLOWER_TULIP: &str = "\u{EACC}"; pub const FLYING_SAUCER: &str = "\u{EB4A}"; pub const FOLDER: &str = "\u{E24A}"; pub const FOLDER_NOTCH: &str = "\u{E24A}"; pub const FOLDER_DASHED: &str = "\u{E8F8}"; pub const FOLDER_DOTTED: &str = "\u{E8F8}"; pub const FOLDER_LOCK: &str = "\u{EA3C}"; pub const FOLDER_MINUS: &str = "\u{E254}"; pub const FOLDER_NOTCH_MINUS: &str = "\u{E254}"; pub const FOLDER_OPEN: &str = "\u{E256}"; pub const FOLDER_NOTCH_OPEN: &str = "\u{E256}"; pub const FOLDER_PLUS: &str = "\u{E258}"; pub const FOLDER_NOTCH_PLUS: &str = "\u{E258}"; pub const FOLDER_SIMPLE: &str = "\u{E25A}"; pub const FOLDER_SIMPLE_DASHED: &str = "\u{EC2A}"; pub const FOLDER_SIMPLE_DOTTED: &str = "\u{EC2A}"; pub const FOLDER_SIMPLE_LOCK: &str = "\u{EB5E}"; pub const FOLDER_SIMPLE_MINUS: &str = "\u{E25C}"; pub const FOLDER_SIMPLE_PLUS: &str = "\u{E25E}"; pub const FOLDER_SIMPLE_STAR: &str = "\u{EC2E}"; pub const FOLDER_SIMPLE_USER: &str = "\u{EB60}"; pub const FOLDER_STAR: &str = "\u{EA86}"; pub const FOLDER_USER: &str = "\u{EB46}"; pub const FOLDERS: &str = "\u{E260}"; pub const FOOTBALL: &str = "\u{E718}"; pub const FOOTBALL_HELMET: &str = "\u{EE4C}"; pub const FOOTPRINTS: &str = "\u{EA88}"; pub const FORK_KNIFE: &str = "\u{E262}"; pub const FOUR_K: &str = "\u{EA5C}"; pub const FRAME_CORNERS: &str = "\u{E626}"; pub const FRAMER_LOGO: &str = "\u{E264}"; pub const FUNCTION: &str = "\u{EBE4}"; pub const FUNNEL: &str = "\u{E266}"; pub const FUNNEL_SIMPLE: &str = "\u{E268}"; pub const FUNNEL_SIMPLE_X: &str = "\u{E26A}"; pub const FUNNEL_X: &str = "\u{E26C}"; pub const GAME_CONTROLLER: &str = "\u{E26E}"; pub const GARAGE: &str = "\u{ECD6}"; pub const GAS_CAN: &str = "\u{E8CE}"; pub const GAS_PUMP: &str = "\u{E768}"; pub const GAUGE: &str = "\u{E628}"; pub const GAVEL: &str = "\u{EA32}"; pub const GEAR: &str = "\u{E270}"; pub const GEAR_FINE: &str = "\u{E87C}"; pub const GEAR_SIX: &str = "\u{E272}"; pub const GENDER_FEMALE: &str = "\u{E6E0}"; pub const GENDER_INTERSEX: &str = "\u{E6E6}"; pub const GENDER_MALE: &str = "\u{E6E2}"; pub const GENDER_NEUTER: &str = "\u{E6EA}"; pub const GENDER_NONBINARY: &str = "\u{E6E4}"; pub const GENDER_TRANSGENDER: &str = "\u{E6E8}"; pub const GHOST: &str = "\u{E62A}"; pub const GIF: &str = "\u{E274}"; pub const GIFT: &str = "\u{E276}"; pub const GIT_BRANCH: &str = "\u{E278}"; pub const GIT_COMMIT: &str = "\u{E27A}"; pub const GIT_DIFF: &str = "\u{E27C}"; pub const GIT_FORK: &str = "\u{E27E}"; pub const GIT_MERGE: &str = "\u{E280}"; pub const GIT_PULL_REQUEST: &str = "\u{E282}"; pub const GITHUB_LOGO: &str = "\u{E576}"; pub const GITLAB_LOGO: &str = "\u{E694}"; pub const GITLAB_LOGO_SIMPLE: &str = "\u{E696}"; pub const GLOBE: &str = "\u{E288}"; pub const GLOBE_HEMISPHERE_EAST: &str = "\u{E28A}"; pub const GLOBE_HEMISPHERE_WEST: &str = "\u{E28C}"; pub const GLOBE_SIMPLE: &str = "\u{E28E}"; pub const GLOBE_SIMPLE_X: &str = "\u{E284}"; pub const GLOBE_STAND: &str = "\u{E290}"; pub const GLOBE_X: &str = "\u{E286}"; pub const GOGGLES: &str = "\u{ECB4}"; pub const GOLF: &str = "\u{EA3E}"; pub const GOODREADS_LOGO: &str = "\u{ED10}"; pub const GOOGLE_CARDBOARD_LOGO: &str = "\u{E7B6}"; pub const GOOGLE_CHROME_LOGO: &str = "\u{E976}"; pub const GOOGLE_DRIVE_LOGO: &str = "\u{E8F6}"; pub const GOOGLE_LOGO: &str = "\u{E292}"; pub const GOOGLE_PHOTOS_LOGO: &str = "\u{EB92}"; pub const GOOGLE_PLAY_LOGO: &str = "\u{E294}"; pub const GOOGLE_PODCASTS_LOGO: &str = "\u{EB94}"; pub const GPS: &str = "\u{EDD8}"; pub const GPS_FIX: &str = "\u{EDD6}"; pub const GPS_SLASH: &str = "\u{EDD4}"; pub const GRADIENT: &str = "\u{EB42}"; pub const GRADUATION_CAP: &str = "\u{E62C}"; pub const GRAINS: &str = "\u{EC68}"; pub const GRAINS_SLASH: &str = "\u{EC6A}"; pub const GRAPH: &str = "\u{EB58}"; pub const GRAPHICS_CARD: &str = "\u{E612}"; pub const GREATER_THAN: &str = "\u{EDC4}"; pub const GREATER_THAN_OR_EQUAL: &str = "\u{EDA2}"; pub const GRID_FOUR: &str = "\u{E296}"; pub const GRID_NINE: &str = "\u{EC8C}"; pub const GUITAR: &str = "\u{EA8A}"; pub const HAIR_DRYER: &str = "\u{EA66}"; pub const HAMBURGER: &str = "\u{E790}"; pub const HAMMER: &str = "\u{E80E}"; pub const HAND: &str = "\u{E298}"; pub const HAND_ARROW_DOWN: &str = "\u{EA4E}"; pub const HAND_ARROW_UP: &str = "\u{EE5A}"; pub const HAND_COINS: &str = "\u{EA8C}"; pub const HAND_DEPOSIT: &str = "\u{EE82}"; pub const HAND_EYE: &str = "\u{EA4C}"; pub const HAND_FIST: &str = "\u{E57A}"; pub const HAND_GRABBING: &str = "\u{E57C}"; pub const HAND_HEART: &str = "\u{E810}"; pub const HAND_PALM: &str = "\u{E57E}"; pub const HAND_PEACE: &str = "\u{E7CC}"; pub const HAND_POINTING: &str = "\u{E29A}"; pub const HAND_SOAP: &str = "\u{E630}"; pub const HAND_SWIPE_LEFT: &str = "\u{EC94}"; pub const HAND_SWIPE_RIGHT: &str = "\u{EC92}"; pub const HAND_TAP: &str = "\u{EC90}"; pub const HAND_WAVING: &str = "\u{E580}"; pub const HAND_WITHDRAW: &str = "\u{EE80}"; pub const HANDBAG: &str = "\u{E29C}"; pub const HANDBAG_SIMPLE: &str = "\u{E62E}"; pub const HANDS_CLAPPING: &str = "\u{E6A0}"; pub const HANDS_PRAYING: &str = "\u{ECC8}"; pub const HANDSHAKE: &str = "\u{E582}"; pub const HARD_DRIVE: &str = "\u{E29E}"; pub const HARD_DRIVES: &str = "\u{E2A0}";
rust
Apache-2.0
c33b60c40f703ffa3d40d252f1bc911cf531581d
2026-01-04T20:22:14.235772Z
true
amPerl/egui-phosphor
https://github.com/amPerl/egui-phosphor/blob/c33b60c40f703ffa3d40d252f1bc911cf531581d/src/variants/fill.rs
src/variants/fill.rs
#![allow(unused)] pub const ACORN: &str = "\u{EB9A}"; pub const ADDRESS_BOOK: &str = "\u{E6F8}"; pub const ADDRESS_BOOK_TABS: &str = "\u{EE4E}"; pub const AIR_TRAFFIC_CONTROL: &str = "\u{ECD8}"; pub const AIRPLANE: &str = "\u{E002}"; pub const AIRPLANE_IN_FLIGHT: &str = "\u{E4FE}"; pub const AIRPLANE_LANDING: &str = "\u{E502}"; pub const AIRPLANE_TAKEOFF: &str = "\u{E504}"; pub const AIRPLANE_TAXIING: &str = "\u{E500}"; pub const AIRPLANE_TILT: &str = "\u{E5D6}"; pub const AIRPLAY: &str = "\u{E004}"; pub const ALARM: &str = "\u{E006}"; pub const ALIEN: &str = "\u{E8A6}"; pub const ALIGN_BOTTOM: &str = "\u{E506}"; pub const ALIGN_BOTTOM_SIMPLE: &str = "\u{EB0C}"; pub const ALIGN_CENTER_HORIZONTAL: &str = "\u{E50A}"; pub const ALIGN_CENTER_HORIZONTAL_SIMPLE: &str = "\u{EB0E}"; pub const ALIGN_CENTER_VERTICAL: &str = "\u{E50C}"; pub const ALIGN_CENTER_VERTICAL_SIMPLE: &str = "\u{EB10}"; pub const ALIGN_LEFT: &str = "\u{E50E}"; pub const ALIGN_LEFT_SIMPLE: &str = "\u{EAEE}"; pub const ALIGN_RIGHT: &str = "\u{E510}"; pub const ALIGN_RIGHT_SIMPLE: &str = "\u{EB12}"; pub const ALIGN_TOP: &str = "\u{E512}"; pub const ALIGN_TOP_SIMPLE: &str = "\u{EB14}"; pub const AMAZON_LOGO: &str = "\u{E96C}"; pub const AMBULANCE: &str = "\u{E572}"; pub const ANCHOR: &str = "\u{E514}"; pub const ANCHOR_SIMPLE: &str = "\u{E5D8}"; pub const ANDROID_LOGO: &str = "\u{E008}"; pub const ANGLE: &str = "\u{E7BC}"; pub const ANGULAR_LOGO: &str = "\u{EB80}"; pub const APERTURE: &str = "\u{E00A}"; pub const APP_STORE_LOGO: &str = "\u{E974}"; pub const APP_WINDOW: &str = "\u{E5DA}"; pub const APPLE_LOGO: &str = "\u{E516}"; pub const APPLE_PODCASTS_LOGO: &str = "\u{EB96}"; pub const APPROXIMATE_EQUALS: &str = "\u{EDAA}"; pub const ARCHIVE: &str = "\u{E00C}"; pub const ARMCHAIR: &str = "\u{E012}"; pub const ARROW_ARC_LEFT: &str = "\u{E014}"; pub const ARROW_ARC_RIGHT: &str = "\u{E016}"; pub const ARROW_BEND_DOUBLE_UP_LEFT: &str = "\u{E03A}"; pub const ARROW_BEND_DOUBLE_UP_RIGHT: &str = "\u{E03C}"; pub const ARROW_BEND_DOWN_LEFT: &str = "\u{E018}"; pub const ARROW_BEND_DOWN_RIGHT: &str = "\u{E01A}"; pub const ARROW_BEND_LEFT_DOWN: &str = "\u{E01C}"; pub const ARROW_BEND_LEFT_UP: &str = "\u{E01E}"; pub const ARROW_BEND_RIGHT_DOWN: &str = "\u{E020}"; pub const ARROW_BEND_RIGHT_UP: &str = "\u{E022}"; pub const ARROW_BEND_UP_LEFT: &str = "\u{E024}"; pub const ARROW_BEND_UP_RIGHT: &str = "\u{E026}"; pub const ARROW_CIRCLE_DOWN: &str = "\u{E028}"; pub const ARROW_CIRCLE_DOWN_LEFT: &str = "\u{E02A}"; pub const ARROW_CIRCLE_DOWN_RIGHT: &str = "\u{E02C}"; pub const ARROW_CIRCLE_LEFT: &str = "\u{E05A}"; pub const ARROW_CIRCLE_RIGHT: &str = "\u{E02E}"; pub const ARROW_CIRCLE_UP: &str = "\u{E030}"; pub const ARROW_CIRCLE_UP_LEFT: &str = "\u{E032}"; pub const ARROW_CIRCLE_UP_RIGHT: &str = "\u{E034}"; pub const ARROW_CLOCKWISE: &str = "\u{E036}"; pub const ARROW_COUNTER_CLOCKWISE: &str = "\u{E038}"; pub const ARROW_DOWN: &str = "\u{E03E}"; pub const ARROW_DOWN_LEFT: &str = "\u{E040}"; pub const ARROW_DOWN_RIGHT: &str = "\u{E042}"; pub const ARROW_ELBOW_DOWN_LEFT: &str = "\u{E044}"; pub const ARROW_ELBOW_DOWN_RIGHT: &str = "\u{E046}"; pub const ARROW_ELBOW_LEFT: &str = "\u{E048}"; pub const ARROW_ELBOW_LEFT_DOWN: &str = "\u{E04A}"; pub const ARROW_ELBOW_LEFT_UP: &str = "\u{E04C}"; pub const ARROW_ELBOW_RIGHT: &str = "\u{E04E}"; pub const ARROW_ELBOW_RIGHT_DOWN: &str = "\u{E050}"; pub const ARROW_ELBOW_RIGHT_UP: &str = "\u{E052}"; pub const ARROW_ELBOW_UP_LEFT: &str = "\u{E054}"; pub const ARROW_ELBOW_UP_RIGHT: &str = "\u{E056}"; pub const ARROW_FAT_DOWN: &str = "\u{E518}"; pub const ARROW_FAT_LEFT: &str = "\u{E51A}"; pub const ARROW_FAT_LINE_DOWN: &str = "\u{E51C}"; pub const ARROW_FAT_LINE_LEFT: &str = "\u{E51E}"; pub const ARROW_FAT_LINE_RIGHT: &str = "\u{E520}"; pub const ARROW_FAT_LINE_UP: &str = "\u{E522}"; pub const ARROW_FAT_LINES_DOWN: &str = "\u{E524}"; pub const ARROW_FAT_LINES_LEFT: &str = "\u{E526}"; pub const ARROW_FAT_LINES_RIGHT: &str = "\u{E528}"; pub const ARROW_FAT_LINES_UP: &str = "\u{E52A}"; pub const ARROW_FAT_RIGHT: &str = "\u{E52C}"; pub const ARROW_FAT_UP: &str = "\u{E52E}"; pub const ARROW_LEFT: &str = "\u{E058}"; pub const ARROW_LINE_DOWN: &str = "\u{E05C}"; pub const ARROW_LINE_DOWN_LEFT: &str = "\u{E05E}"; pub const ARROW_LINE_DOWN_RIGHT: &str = "\u{E060}"; pub const ARROW_LINE_LEFT: &str = "\u{E062}"; pub const ARROW_LINE_RIGHT: &str = "\u{E064}"; pub const ARROW_LINE_UP: &str = "\u{E066}"; pub const ARROW_LINE_UP_LEFT: &str = "\u{E068}"; pub const ARROW_LINE_UP_RIGHT: &str = "\u{E06A}"; pub const ARROW_RIGHT: &str = "\u{E06C}"; pub const ARROW_SQUARE_DOWN: &str = "\u{E06E}"; pub const ARROW_SQUARE_DOWN_LEFT: &str = "\u{E070}"; pub const ARROW_SQUARE_DOWN_RIGHT: &str = "\u{E072}"; pub const ARROW_SQUARE_IN: &str = "\u{E5DC}"; pub const ARROW_SQUARE_LEFT: &str = "\u{E074}"; pub const ARROW_SQUARE_OUT: &str = "\u{E5DE}"; pub const ARROW_SQUARE_RIGHT: &str = "\u{E076}"; pub const ARROW_SQUARE_UP: &str = "\u{E078}"; pub const ARROW_SQUARE_UP_LEFT: &str = "\u{E07A}"; pub const ARROW_SQUARE_UP_RIGHT: &str = "\u{E07C}"; pub const ARROW_U_DOWN_LEFT: &str = "\u{E07E}"; pub const ARROW_U_DOWN_RIGHT: &str = "\u{E080}"; pub const ARROW_U_LEFT_DOWN: &str = "\u{E082}"; pub const ARROW_U_LEFT_UP: &str = "\u{E084}"; pub const ARROW_U_RIGHT_DOWN: &str = "\u{E086}"; pub const ARROW_U_RIGHT_UP: &str = "\u{E088}"; pub const ARROW_U_UP_LEFT: &str = "\u{E08A}"; pub const ARROW_U_UP_RIGHT: &str = "\u{E08C}"; pub const ARROW_UP: &str = "\u{E08E}"; pub const ARROW_UP_LEFT: &str = "\u{E090}"; pub const ARROW_UP_RIGHT: &str = "\u{E092}"; pub const ARROWS_CLOCKWISE: &str = "\u{E094}"; pub const ARROWS_COUNTER_CLOCKWISE: &str = "\u{E096}"; pub const ARROWS_DOWN_UP: &str = "\u{E098}"; pub const ARROWS_HORIZONTAL: &str = "\u{EB06}"; pub const ARROWS_IN: &str = "\u{E09A}"; pub const ARROWS_IN_CARDINAL: &str = "\u{E09C}"; pub const ARROWS_IN_LINE_HORIZONTAL: &str = "\u{E530}"; pub const ARROWS_IN_LINE_VERTICAL: &str = "\u{E532}"; pub const ARROWS_IN_SIMPLE: &str = "\u{E09E}"; pub const ARROWS_LEFT_RIGHT: &str = "\u{E0A0}"; pub const ARROWS_MERGE: &str = "\u{ED3E}"; pub const ARROWS_OUT: &str = "\u{E0A2}"; pub const ARROWS_OUT_CARDINAL: &str = "\u{E0A4}"; pub const ARROWS_OUT_LINE_HORIZONTAL: &str = "\u{E534}"; pub const ARROWS_OUT_LINE_VERTICAL: &str = "\u{E536}"; pub const ARROWS_OUT_SIMPLE: &str = "\u{E0A6}"; pub const ARROWS_SPLIT: &str = "\u{ED3C}"; pub const ARROWS_VERTICAL: &str = "\u{EB04}"; pub const ARTICLE: &str = "\u{E0A8}"; pub const ARTICLE_MEDIUM: &str = "\u{E5E0}"; pub const ARTICLE_NY_TIMES: &str = "\u{E5E2}"; pub const ASCLEPIUS: &str = "\u{EE34}"; pub const CADUCEUS: &str = "\u{EE34}"; pub const ASTERISK: &str = "\u{E0AA}"; pub const ASTERISK_SIMPLE: &str = "\u{E832}"; pub const AT: &str = "\u{E0AC}"; pub const ATOM: &str = "\u{E5E4}"; pub const AVOCADO: &str = "\u{EE04}"; pub const AXE: &str = "\u{E9FC}"; pub const BABY: &str = "\u{E774}"; pub const BABY_CARRIAGE: &str = "\u{E818}"; pub const BACKPACK: &str = "\u{E922}"; pub const BACKSPACE: &str = "\u{E0AE}"; pub const BAG: &str = "\u{E0B0}"; pub const BAG_SIMPLE: &str = "\u{E5E6}"; pub const BALLOON: &str = "\u{E76C}"; pub const BANDAIDS: &str = "\u{E0B2}"; pub const BANK: &str = "\u{E0B4}"; pub const BARBELL: &str = "\u{E0B6}"; pub const BARCODE: &str = "\u{E0B8}"; pub const BARN: &str = "\u{EC72}"; pub const BARRICADE: &str = "\u{E948}"; pub const BASEBALL: &str = "\u{E71A}"; pub const BASEBALL_CAP: &str = "\u{EA28}"; pub const BASEBALL_HELMET: &str = "\u{EE4A}"; pub const BASKET: &str = "\u{E964}"; pub const BASKETBALL: &str = "\u{E724}"; pub const BATHTUB: &str = "\u{E81E}"; pub const BATTERY_CHARGING: &str = "\u{E0BA}"; pub const BATTERY_CHARGING_VERTICAL: &str = "\u{E0BC}"; pub const BATTERY_EMPTY: &str = "\u{E0BE}"; pub const BATTERY_FULL: &str = "\u{E0C0}"; pub const BATTERY_HIGH: &str = "\u{E0C2}"; pub const BATTERY_LOW: &str = "\u{E0C4}"; pub const BATTERY_MEDIUM: &str = "\u{E0C6}"; pub const BATTERY_PLUS: &str = "\u{E808}"; pub const BATTERY_PLUS_VERTICAL: &str = "\u{EC50}"; pub const BATTERY_VERTICAL_EMPTY: &str = "\u{E7C6}"; pub const BATTERY_VERTICAL_FULL: &str = "\u{E7C4}"; pub const BATTERY_VERTICAL_HIGH: &str = "\u{E7C2}"; pub const BATTERY_VERTICAL_LOW: &str = "\u{E7BE}"; pub const BATTERY_VERTICAL_MEDIUM: &str = "\u{E7C0}"; pub const BATTERY_WARNING: &str = "\u{E0C8}"; pub const BATTERY_WARNING_VERTICAL: &str = "\u{E0CA}"; pub const BEACH_BALL: &str = "\u{ED24}"; pub const BEANIE: &str = "\u{EA2A}"; pub const BED: &str = "\u{E0CC}"; pub const BEER_BOTTLE: &str = "\u{E7B0}"; pub const BEER_STEIN: &str = "\u{EB62}"; pub const BEHANCE_LOGO: &str = "\u{E7F4}"; pub const BELL: &str = "\u{E0CE}"; pub const BELL_RINGING: &str = "\u{E5E8}"; pub const BELL_SIMPLE: &str = "\u{E0D0}"; pub const BELL_SIMPLE_RINGING: &str = "\u{E5EA}"; pub const BELL_SIMPLE_SLASH: &str = "\u{E0D2}"; pub const BELL_SIMPLE_Z: &str = "\u{E5EC}"; pub const BELL_SLASH: &str = "\u{E0D4}"; pub const BELL_Z: &str = "\u{E5EE}"; pub const BELT: &str = "\u{EA2C}"; pub const BEZIER_CURVE: &str = "\u{EB00}"; pub const BICYCLE: &str = "\u{E0D6}"; pub const BINARY: &str = "\u{EE60}"; pub const BINOCULARS: &str = "\u{EA64}"; pub const BIOHAZARD: &str = "\u{E9E0}"; pub const BIRD: &str = "\u{E72C}"; pub const BLUEPRINT: &str = "\u{EDA0}"; pub const BLUETOOTH: &str = "\u{E0DA}"; pub const BLUETOOTH_CONNECTED: &str = "\u{E0DC}"; pub const BLUETOOTH_SLASH: &str = "\u{E0DE}"; pub const BLUETOOTH_X: &str = "\u{E0E0}"; pub const BOAT: &str = "\u{E786}"; pub const BOMB: &str = "\u{EE0A}"; pub const BONE: &str = "\u{E7F2}"; pub const BOOK: &str = "\u{E0E2}"; pub const BOOK_BOOKMARK: &str = "\u{E0E4}"; pub const BOOK_OPEN: &str = "\u{E0E6}"; pub const BOOK_OPEN_TEXT: &str = "\u{E8F2}"; pub const BOOK_OPEN_USER: &str = "\u{EDE0}"; pub const BOOKMARK: &str = "\u{E0E8}"; pub const BOOKMARK_SIMPLE: &str = "\u{E0EA}"; pub const BOOKMARKS: &str = "\u{E0EC}"; pub const BOOKMARKS_SIMPLE: &str = "\u{E5F0}"; pub const BOOKS: &str = "\u{E758}"; pub const BOOT: &str = "\u{ECCA}"; pub const BOULES: &str = "\u{E722}"; pub const BOUNDING_BOX: &str = "\u{E6CE}"; pub const BOWL_FOOD: &str = "\u{EAA4}"; pub const BOWL_STEAM: &str = "\u{E8E4}"; pub const BOWLING_BALL: &str = "\u{EA34}"; pub const BOX_ARROW_DOWN: &str = "\u{E00E}"; pub const ARCHIVE_BOX: &str = "\u{E00E}"; pub const BOX_ARROW_UP: &str = "\u{EE54}"; pub const BOXING_GLOVE: &str = "\u{EA36}"; pub const BRACKETS_ANGLE: &str = "\u{E862}"; pub const BRACKETS_CURLY: &str = "\u{E860}"; pub const BRACKETS_ROUND: &str = "\u{E864}"; pub const BRACKETS_SQUARE: &str = "\u{E85E}"; pub const BRAIN: &str = "\u{E74E}"; pub const BRANDY: &str = "\u{E6B4}"; pub const BREAD: &str = "\u{E81C}"; pub const BRIDGE: &str = "\u{EA68}"; pub const BRIEFCASE: &str = "\u{E0EE}"; pub const BRIEFCASE_METAL: &str = "\u{E5F2}"; pub const BROADCAST: &str = "\u{E0F2}"; pub const BROOM: &str = "\u{EC54}"; pub const BROWSER: &str = "\u{E0F4}"; pub const BROWSERS: &str = "\u{E0F6}"; pub const BUG: &str = "\u{E5F4}"; pub const BUG_BEETLE: &str = "\u{E5F6}"; pub const BUG_DROID: &str = "\u{E5F8}"; pub const BUILDING: &str = "\u{E100}"; pub const BUILDING_APARTMENT: &str = "\u{E0FE}"; pub const BUILDING_OFFICE: &str = "\u{E0FF}"; pub const BUILDINGS: &str = "\u{E102}"; pub const BULLDOZER: &str = "\u{EC6C}"; pub const BUS: &str = "\u{E106}"; pub const BUTTERFLY: &str = "\u{EA6E}"; pub const CABLE_CAR: &str = "\u{E49C}"; pub const CACTUS: &str = "\u{E918}"; pub const CAKE: &str = "\u{E780}"; pub const CALCULATOR: &str = "\u{E538}"; pub const CALENDAR: &str = "\u{E108}"; pub const CALENDAR_BLANK: &str = "\u{E10A}"; pub const CALENDAR_CHECK: &str = "\u{E712}"; pub const CALENDAR_DOT: &str = "\u{E7B2}"; pub const CALENDAR_DOTS: &str = "\u{E7B4}"; pub const CALENDAR_HEART: &str = "\u{E8B0}"; pub const CALENDAR_MINUS: &str = "\u{EA14}"; pub const CALENDAR_PLUS: &str = "\u{E714}"; pub const CALENDAR_SLASH: &str = "\u{EA12}"; pub const CALENDAR_STAR: &str = "\u{E8B2}"; pub const CALENDAR_X: &str = "\u{E10C}"; pub const CALL_BELL: &str = "\u{E7DE}"; pub const CAMERA: &str = "\u{E10E}"; pub const CAMERA_PLUS: &str = "\u{EC58}"; pub const CAMERA_ROTATE: &str = "\u{E7A4}"; pub const CAMERA_SLASH: &str = "\u{E110}"; pub const CAMPFIRE: &str = "\u{E9D8}"; pub const CAR: &str = "\u{E112}"; pub const CAR_BATTERY: &str = "\u{EE30}"; pub const CAR_PROFILE: &str = "\u{E8CC}"; pub const CAR_SIMPLE: &str = "\u{E114}"; pub const CARDHOLDER: &str = "\u{E5FA}"; pub const CARDS: &str = "\u{E0F8}"; pub const CARDS_THREE: &str = "\u{EE50}"; pub const CARET_CIRCLE_DOUBLE_DOWN: &str = "\u{E116}"; pub const CARET_CIRCLE_DOUBLE_LEFT: &str = "\u{E118}"; pub const CARET_CIRCLE_DOUBLE_RIGHT: &str = "\u{E11A}"; pub const CARET_CIRCLE_DOUBLE_UP: &str = "\u{E11C}"; pub const CARET_CIRCLE_DOWN: &str = "\u{E11E}"; pub const CARET_CIRCLE_LEFT: &str = "\u{E120}"; pub const CARET_CIRCLE_RIGHT: &str = "\u{E122}"; pub const CARET_CIRCLE_UP: &str = "\u{E124}"; pub const CARET_CIRCLE_UP_DOWN: &str = "\u{E13E}"; pub const CARET_DOUBLE_DOWN: &str = "\u{E126}"; pub const CARET_DOUBLE_LEFT: &str = "\u{E128}"; pub const CARET_DOUBLE_RIGHT: &str = "\u{E12A}"; pub const CARET_DOUBLE_UP: &str = "\u{E12C}"; pub const CARET_DOWN: &str = "\u{E136}"; pub const CARET_LEFT: &str = "\u{E138}"; pub const CARET_LINE_DOWN: &str = "\u{E134}"; pub const CARET_LINE_LEFT: &str = "\u{E132}"; pub const CARET_LINE_RIGHT: &str = "\u{E130}"; pub const CARET_LINE_UP: &str = "\u{E12E}"; pub const CARET_RIGHT: &str = "\u{E13A}"; pub const CARET_UP: &str = "\u{E13C}"; pub const CARET_UP_DOWN: &str = "\u{E140}"; pub const CARROT: &str = "\u{ED38}"; pub const CASH_REGISTER: &str = "\u{ED80}"; pub const CASSETTE_TAPE: &str = "\u{ED2E}"; pub const CASTLE_TURRET: &str = "\u{E9D0}"; pub const CAT: &str = "\u{E748}"; pub const CELL_SIGNAL_FULL: &str = "\u{E142}"; pub const CELL_SIGNAL_HIGH: &str = "\u{E144}"; pub const CELL_SIGNAL_LOW: &str = "\u{E146}"; pub const CELL_SIGNAL_MEDIUM: &str = "\u{E148}"; pub const CELL_SIGNAL_NONE: &str = "\u{E14A}"; pub const CELL_SIGNAL_SLASH: &str = "\u{E14C}"; pub const CELL_SIGNAL_X: &str = "\u{E14E}"; pub const CELL_TOWER: &str = "\u{EBAA}"; pub const CERTIFICATE: &str = "\u{E766}"; pub const CHAIR: &str = "\u{E950}"; pub const CHALKBOARD: &str = "\u{E5FC}"; pub const CHALKBOARD_SIMPLE: &str = "\u{E5FE}"; pub const CHALKBOARD_TEACHER: &str = "\u{E600}"; pub const CHAMPAGNE: &str = "\u{EACA}"; pub const CHARGING_STATION: &str = "\u{E8D0}"; pub const CHART_BAR: &str = "\u{E150}"; pub const CHART_BAR_HORIZONTAL: &str = "\u{E152}"; pub const CHART_DONUT: &str = "\u{EAA6}"; pub const CHART_LINE: &str = "\u{E154}"; pub const CHART_LINE_DOWN: &str = "\u{E8B6}"; pub const CHART_LINE_UP: &str = "\u{E156}"; pub const CHART_PIE: &str = "\u{E158}"; pub const CHART_PIE_SLICE: &str = "\u{E15A}"; pub const CHART_POLAR: &str = "\u{EAA8}"; pub const CHART_SCATTER: &str = "\u{EAAC}"; pub const CHAT: &str = "\u{E15C}"; pub const CHAT_CENTERED: &str = "\u{E160}"; pub const CHAT_CENTERED_DOTS: &str = "\u{E164}"; pub const CHAT_CENTERED_SLASH: &str = "\u{E162}"; pub const CHAT_CENTERED_TEXT: &str = "\u{E166}"; pub const CHAT_CIRCLE: &str = "\u{E168}"; pub const CHAT_CIRCLE_DOTS: &str = "\u{E16C}"; pub const CHAT_CIRCLE_SLASH: &str = "\u{E16A}"; pub const CHAT_CIRCLE_TEXT: &str = "\u{E16E}"; pub const CHAT_DOTS: &str = "\u{E170}"; pub const CHAT_SLASH: &str = "\u{E15E}"; pub const CHAT_TEARDROP: &str = "\u{E172}"; pub const CHAT_TEARDROP_DOTS: &str = "\u{E176}"; pub const CHAT_TEARDROP_SLASH: &str = "\u{E174}"; pub const CHAT_TEARDROP_TEXT: &str = "\u{E178}"; pub const CHAT_TEXT: &str = "\u{E17A}"; pub const CHATS: &str = "\u{E17C}"; pub const CHATS_CIRCLE: &str = "\u{E17E}"; pub const CHATS_TEARDROP: &str = "\u{E180}"; pub const CHECK: &str = "\u{E182}"; pub const CHECK_CIRCLE: &str = "\u{E184}"; pub const CHECK_FAT: &str = "\u{EBA6}"; pub const CHECK_SQUARE: &str = "\u{E186}"; pub const CHECK_SQUARE_OFFSET: &str = "\u{E188}"; pub const CHECKERBOARD: &str = "\u{E8C4}"; pub const CHECKS: &str = "\u{E53A}"; pub const CHEERS: &str = "\u{EA4A}"; pub const CHEESE: &str = "\u{E9FE}"; pub const CHEF_HAT: &str = "\u{ED8E}"; pub const CHERRIES: &str = "\u{E830}"; pub const CHURCH: &str = "\u{ECEA}"; pub const CIGARETTE: &str = "\u{ED90}"; pub const CIGARETTE_SLASH: &str = "\u{ED92}"; pub const CIRCLE: &str = "\u{E18A}"; pub const CIRCLE_DASHED: &str = "\u{E602}"; pub const CIRCLE_HALF: &str = "\u{E18C}"; pub const CIRCLE_HALF_TILT: &str = "\u{E18E}"; pub const CIRCLE_NOTCH: &str = "\u{EB44}"; pub const CIRCLES_FOUR: &str = "\u{E190}"; pub const CIRCLES_THREE: &str = "\u{E192}"; pub const CIRCLES_THREE_PLUS: &str = "\u{E194}"; pub const CIRCUITRY: &str = "\u{E9C2}"; pub const CITY: &str = "\u{EA6A}"; pub const CLIPBOARD: &str = "\u{E196}"; pub const CLIPBOARD_TEXT: &str = "\u{E198}"; pub const CLOCK: &str = "\u{E19A}"; pub const CLOCK_AFTERNOON: &str = "\u{E19C}"; pub const CLOCK_CLOCKWISE: &str = "\u{E19E}"; pub const CLOCK_COUNTDOWN: &str = "\u{ED2C}"; pub const CLOCK_COUNTER_CLOCKWISE: &str = "\u{E1A0}"; pub const CLOCK_USER: &str = "\u{EDEC}"; pub const CLOSED_CAPTIONING: &str = "\u{E1A4}"; pub const CLOUD: &str = "\u{E1AA}"; pub const CLOUD_ARROW_DOWN: &str = "\u{E1AC}"; pub const CLOUD_ARROW_UP: &str = "\u{E1AE}"; pub const CLOUD_CHECK: &str = "\u{E1B0}"; pub const CLOUD_FOG: &str = "\u{E53C}"; pub const CLOUD_LIGHTNING: &str = "\u{E1B2}"; pub const CLOUD_MOON: &str = "\u{E53E}"; pub const CLOUD_RAIN: &str = "\u{E1B4}"; pub const CLOUD_SLASH: &str = "\u{E1B6}"; pub const CLOUD_SNOW: &str = "\u{E1B8}"; pub const CLOUD_SUN: &str = "\u{E540}"; pub const CLOUD_WARNING: &str = "\u{EA98}"; pub const CLOUD_X: &str = "\u{EA96}"; pub const CLOVER: &str = "\u{EDC8}"; pub const CLUB: &str = "\u{E1BA}"; pub const COAT_HANGER: &str = "\u{E7FE}"; pub const CODA_LOGO: &str = "\u{E7CE}"; pub const CODE: &str = "\u{E1BC}"; pub const CODE_BLOCK: &str = "\u{EAFE}"; pub const CODE_SIMPLE: &str = "\u{E1BE}"; pub const CODEPEN_LOGO: &str = "\u{E978}"; pub const CODESANDBOX_LOGO: &str = "\u{EA06}"; pub const COFFEE: &str = "\u{E1C2}"; pub const COFFEE_BEAN: &str = "\u{E1C0}"; pub const COIN: &str = "\u{E60E}"; pub const COIN_VERTICAL: &str = "\u{EB48}"; pub const COINS: &str = "\u{E78E}"; pub const COLUMNS: &str = "\u{E546}"; pub const COLUMNS_PLUS_LEFT: &str = "\u{E544}"; pub const COLUMNS_PLUS_RIGHT: &str = "\u{E542}"; pub const COMMAND: &str = "\u{E1C4}"; pub const COMPASS: &str = "\u{E1C8}"; pub const COMPASS_ROSE: &str = "\u{E1C6}"; pub const COMPASS_TOOL: &str = "\u{EA0E}"; pub const COMPUTER_TOWER: &str = "\u{E548}"; pub const CONFETTI: &str = "\u{E81A}"; pub const CONTACTLESS_PAYMENT: &str = "\u{ED42}"; pub const CONTROL: &str = "\u{ECA6}"; pub const COOKIE: &str = "\u{E6CA}"; pub const COOKING_POT: &str = "\u{E764}"; pub const COPY: &str = "\u{E1CA}"; pub const COPY_SIMPLE: &str = "\u{E1CC}"; pub const COPYLEFT: &str = "\u{E86A}"; pub const COPYRIGHT: &str = "\u{E54A}"; pub const CORNERS_IN: &str = "\u{E1CE}"; pub const CORNERS_OUT: &str = "\u{E1D0}"; pub const COUCH: &str = "\u{E7F6}"; pub const COURT_BASKETBALL: &str = "\u{EE36}"; pub const COW: &str = "\u{EABE}"; pub const COWBOY_HAT: &str = "\u{ED12}"; pub const CPU: &str = "\u{E610}"; pub const CRANE: &str = "\u{ED48}"; pub const CRANE_TOWER: &str = "\u{ED49}"; pub const CREDIT_CARD: &str = "\u{E1D2}"; pub const CRICKET: &str = "\u{EE12}"; pub const CROP: &str = "\u{E1D4}"; pub const CROSS: &str = "\u{E8A0}"; pub const CROSSHAIR: &str = "\u{E1D6}"; pub const CROSSHAIR_SIMPLE: &str = "\u{E1D8}"; pub const CROWN: &str = "\u{E614}"; pub const CROWN_CROSS: &str = "\u{EE5E}"; pub const CROWN_SIMPLE: &str = "\u{E616}"; pub const CUBE: &str = "\u{E1DA}"; pub const CUBE_FOCUS: &str = "\u{ED0A}"; pub const CUBE_TRANSPARENT: &str = "\u{EC7C}"; pub const CURRENCY_BTC: &str = "\u{E618}"; pub const CURRENCY_CIRCLE_DOLLAR: &str = "\u{E54C}"; pub const CURRENCY_CNY: &str = "\u{E54E}"; pub const CURRENCY_DOLLAR: &str = "\u{E550}"; pub const CURRENCY_DOLLAR_SIMPLE: &str = "\u{E552}"; pub const CURRENCY_ETH: &str = "\u{EADA}"; pub const CURRENCY_EUR: &str = "\u{E554}"; pub const CURRENCY_GBP: &str = "\u{E556}"; pub const CURRENCY_INR: &str = "\u{E558}"; pub const CURRENCY_JPY: &str = "\u{E55A}"; pub const CURRENCY_KRW: &str = "\u{E55C}"; pub const CURRENCY_KZT: &str = "\u{EC4C}"; pub const CURRENCY_NGN: &str = "\u{EB52}"; pub const CURRENCY_RUB: &str = "\u{E55E}"; pub const CURSOR: &str = "\u{E1DC}"; pub const CURSOR_CLICK: &str = "\u{E7C8}"; pub const CURSOR_TEXT: &str = "\u{E7D8}"; pub const CYLINDER: &str = "\u{E8FC}"; pub const DATABASE: &str = "\u{E1DE}"; pub const DESK: &str = "\u{ED16}"; pub const DESKTOP: &str = "\u{E560}"; pub const DESKTOP_TOWER: &str = "\u{E562}"; pub const DETECTIVE: &str = "\u{E83E}"; pub const DEV_TO_LOGO: &str = "\u{ED0E}"; pub const DEVICE_MOBILE: &str = "\u{E1E0}"; pub const DEVICE_MOBILE_CAMERA: &str = "\u{E1E2}"; pub const DEVICE_MOBILE_SLASH: &str = "\u{EE46}"; pub const DEVICE_MOBILE_SPEAKER: &str = "\u{E1E4}"; pub const DEVICE_ROTATE: &str = "\u{EDF2}"; pub const DEVICE_TABLET: &str = "\u{E1E6}"; pub const DEVICE_TABLET_CAMERA: &str = "\u{E1E8}"; pub const DEVICE_TABLET_SPEAKER: &str = "\u{E1EA}"; pub const DEVICES: &str = "\u{EBA4}"; pub const DIAMOND: &str = "\u{E1EC}"; pub const DIAMONDS_FOUR: &str = "\u{E8F4}"; pub const DICE_FIVE: &str = "\u{E1EE}"; pub const DICE_FOUR: &str = "\u{E1F0}"; pub const DICE_ONE: &str = "\u{E1F2}"; pub const DICE_SIX: &str = "\u{E1F4}"; pub const DICE_THREE: &str = "\u{E1F6}"; pub const DICE_TWO: &str = "\u{E1F8}"; pub const DISC: &str = "\u{E564}"; pub const DISCO_BALL: &str = "\u{ED98}"; pub const DISCORD_LOGO: &str = "\u{E61A}"; pub const DIVIDE: &str = "\u{E1FA}"; pub const DNA: &str = "\u{E924}"; pub const DOG: &str = "\u{E74A}"; pub const DOOR: &str = "\u{E61C}"; pub const DOOR_OPEN: &str = "\u{E7E6}"; pub const DOT: &str = "\u{ECDE}"; pub const DOT_OUTLINE: &str = "\u{ECE0}"; pub const DOTS_NINE: &str = "\u{E1FC}"; pub const DOTS_SIX: &str = "\u{E794}"; pub const DOTS_SIX_VERTICAL: &str = "\u{EAE2}"; pub const DOTS_THREE: &str = "\u{E1FE}"; pub const DOTS_THREE_CIRCLE: &str = "\u{E200}"; pub const DOTS_THREE_CIRCLE_VERTICAL: &str = "\u{E202}"; pub const DOTS_THREE_OUTLINE: &str = "\u{E204}"; pub const DOTS_THREE_OUTLINE_VERTICAL: &str = "\u{E206}"; pub const DOTS_THREE_VERTICAL: &str = "\u{E208}"; pub const DOWNLOAD: &str = "\u{E20A}"; pub const DOWNLOAD_SIMPLE: &str = "\u{E20C}"; pub const DRESS: &str = "\u{EA7E}"; pub const DRESSER: &str = "\u{E94E}"; pub const DRIBBBLE_LOGO: &str = "\u{E20E}"; pub const DRONE: &str = "\u{ED74}"; pub const DROP: &str = "\u{E210}"; pub const DROP_HALF: &str = "\u{E566}"; pub const DROP_HALF_BOTTOM: &str = "\u{EB40}"; pub const DROP_SIMPLE: &str = "\u{EE32}"; pub const DROP_SLASH: &str = "\u{E954}"; pub const DROPBOX_LOGO: &str = "\u{E7D0}"; pub const EAR: &str = "\u{E70C}"; pub const EAR_SLASH: &str = "\u{E70E}"; pub const EGG: &str = "\u{E812}"; pub const EGG_CRACK: &str = "\u{EB64}"; pub const EJECT: &str = "\u{E212}"; pub const EJECT_SIMPLE: &str = "\u{E6AE}"; pub const ELEVATOR: &str = "\u{ECC0}"; pub const EMPTY: &str = "\u{EDBC}"; pub const ENGINE: &str = "\u{EA80}"; pub const ENVELOPE: &str = "\u{E214}"; pub const ENVELOPE_OPEN: &str = "\u{E216}"; pub const ENVELOPE_SIMPLE: &str = "\u{E218}"; pub const ENVELOPE_SIMPLE_OPEN: &str = "\u{E21A}"; pub const EQUALIZER: &str = "\u{EBBC}"; pub const EQUALS: &str = "\u{E21C}"; pub const ERASER: &str = "\u{E21E}"; pub const ESCALATOR_DOWN: &str = "\u{ECBA}"; pub const ESCALATOR_UP: &str = "\u{ECBC}"; pub const EXAM: &str = "\u{E742}"; pub const EXCLAMATION_MARK: &str = "\u{EE44}"; pub const EXCLUDE: &str = "\u{E882}"; pub const EXCLUDE_SQUARE: &str = "\u{E880}"; pub const EXPORT: &str = "\u{EAF0}"; pub const EYE: &str = "\u{E220}"; pub const EYE_CLOSED: &str = "\u{E222}"; pub const EYE_SLASH: &str = "\u{E224}"; pub const EYEDROPPER: &str = "\u{E568}"; pub const EYEDROPPER_SAMPLE: &str = "\u{EAC4}"; pub const EYEGLASSES: &str = "\u{E7BA}"; pub const EYES: &str = "\u{EE5C}"; pub const FACE_MASK: &str = "\u{E56A}"; pub const FACEBOOK_LOGO: &str = "\u{E226}"; pub const FACTORY: &str = "\u{E760}"; pub const FADERS: &str = "\u{E228}"; pub const FADERS_HORIZONTAL: &str = "\u{E22A}"; pub const FALLOUT_SHELTER: &str = "\u{E9DE}"; pub const FAN: &str = "\u{E9F2}"; pub const FARM: &str = "\u{EC70}"; pub const FAST_FORWARD: &str = "\u{E6A6}"; pub const FAST_FORWARD_CIRCLE: &str = "\u{E22C}"; pub const FEATHER: &str = "\u{E9C0}"; pub const FEDIVERSE_LOGO: &str = "\u{ED66}"; pub const FIGMA_LOGO: &str = "\u{E22E}"; pub const FILE: &str = "\u{E230}"; pub const FILE_ARCHIVE: &str = "\u{EB2A}"; pub const FILE_ARROW_DOWN: &str = "\u{E232}"; pub const FILE_ARROW_UP: &str = "\u{E61E}"; pub const FILE_AUDIO: &str = "\u{EA20}"; pub const FILE_C: &str = "\u{EB32}"; pub const FILE_C_SHARP: &str = "\u{EB30}"; pub const FILE_CLOUD: &str = "\u{E95E}"; pub const FILE_CODE: &str = "\u{E914}"; pub const FILE_CPP: &str = "\u{EB2E}"; pub const FILE_CSS: &str = "\u{EB34}"; pub const FILE_CSV: &str = "\u{EB1C}"; pub const FILE_DASHED: &str = "\u{E704}"; pub const FILE_DOTTED: &str = "\u{E704}"; pub const FILE_DOC: &str = "\u{EB1E}"; pub const FILE_HTML: &str = "\u{EB38}"; pub const FILE_IMAGE: &str = "\u{EA24}"; pub const FILE_INI: &str = "\u{EB33}"; pub const FILE_JPG: &str = "\u{EB1A}"; pub const FILE_JS: &str = "\u{EB24}"; pub const FILE_JSX: &str = "\u{EB3A}"; pub const FILE_LOCK: &str = "\u{E95C}"; pub const FILE_MAGNIFYING_GLASS: &str = "\u{E238}"; pub const FILE_SEARCH: &str = "\u{E238}"; pub const FILE_MD: &str = "\u{ED50}"; pub const FILE_MINUS: &str = "\u{E234}"; pub const FILE_PDF: &str = "\u{E702}"; pub const FILE_PLUS: &str = "\u{E236}"; pub const FILE_PNG: &str = "\u{EB18}"; pub const FILE_PPT: &str = "\u{EB20}"; pub const FILE_PY: &str = "\u{EB2C}"; pub const FILE_RS: &str = "\u{EB28}"; pub const FILE_SQL: &str = "\u{ED4E}"; pub const FILE_SVG: &str = "\u{ED08}"; pub const FILE_TEXT: &str = "\u{E23A}"; pub const FILE_TS: &str = "\u{EB26}"; pub const FILE_TSX: &str = "\u{EB3C}"; pub const FILE_TXT: &str = "\u{EB35}"; pub const FILE_VIDEO: &str = "\u{EA22}"; pub const FILE_VUE: &str = "\u{EB3E}"; pub const FILE_X: &str = "\u{E23C}"; pub const FILE_XLS: &str = "\u{EB22}"; pub const FILE_ZIP: &str = "\u{E958}"; pub const FILES: &str = "\u{E710}"; pub const FILM_REEL: &str = "\u{E8C0}"; pub const FILM_SCRIPT: &str = "\u{EB50}"; pub const FILM_SLATE: &str = "\u{E8C2}"; pub const FILM_STRIP: &str = "\u{E792}"; pub const FINGERPRINT: &str = "\u{E23E}"; pub const FINGERPRINT_SIMPLE: &str = "\u{E240}"; pub const FINN_THE_HUMAN: &str = "\u{E56C}"; pub const FIRE: &str = "\u{E242}"; pub const FIRE_EXTINGUISHER: &str = "\u{E9E8}"; pub const FIRE_SIMPLE: &str = "\u{E620}"; pub const FIRE_TRUCK: &str = "\u{E574}"; pub const FIRST_AID: &str = "\u{E56E}"; pub const FIRST_AID_KIT: &str = "\u{E570}"; pub const FISH: &str = "\u{E728}"; pub const FISH_SIMPLE: &str = "\u{E72A}"; pub const FLAG: &str = "\u{E244}"; pub const FLAG_BANNER: &str = "\u{E622}"; pub const FLAG_BANNER_FOLD: &str = "\u{ECF2}"; pub const FLAG_CHECKERED: &str = "\u{EA38}"; pub const FLAG_PENNANT: &str = "\u{ECF0}"; pub const FLAME: &str = "\u{E624}"; pub const FLASHLIGHT: &str = "\u{E246}"; pub const FLASK: &str = "\u{E79E}"; pub const FLIP_HORIZONTAL: &str = "\u{ED6A}"; pub const FLIP_VERTICAL: &str = "\u{ED6C}"; pub const FLOPPY_DISK: &str = "\u{E248}"; pub const FLOPPY_DISK_BACK: &str = "\u{EAF4}"; pub const FLOW_ARROW: &str = "\u{E6EC}"; pub const FLOWER: &str = "\u{E75E}"; pub const FLOWER_LOTUS: &str = "\u{E6CC}"; pub const FLOWER_TULIP: &str = "\u{EACC}"; pub const FLYING_SAUCER: &str = "\u{EB4A}"; pub const FOLDER: &str = "\u{E24A}"; pub const FOLDER_NOTCH: &str = "\u{E24A}"; pub const FOLDER_DASHED: &str = "\u{E8F8}"; pub const FOLDER_DOTTED: &str = "\u{E8F8}"; pub const FOLDER_LOCK: &str = "\u{EA3C}"; pub const FOLDER_MINUS: &str = "\u{E254}"; pub const FOLDER_NOTCH_MINUS: &str = "\u{E254}"; pub const FOLDER_OPEN: &str = "\u{E256}"; pub const FOLDER_NOTCH_OPEN: &str = "\u{E256}"; pub const FOLDER_PLUS: &str = "\u{E258}"; pub const FOLDER_NOTCH_PLUS: &str = "\u{E258}"; pub const FOLDER_SIMPLE: &str = "\u{E25A}"; pub const FOLDER_SIMPLE_DASHED: &str = "\u{EC2A}"; pub const FOLDER_SIMPLE_DOTTED: &str = "\u{EC2A}"; pub const FOLDER_SIMPLE_LOCK: &str = "\u{EB5E}"; pub const FOLDER_SIMPLE_MINUS: &str = "\u{E25C}"; pub const FOLDER_SIMPLE_PLUS: &str = "\u{E25E}"; pub const FOLDER_SIMPLE_STAR: &str = "\u{EC2E}"; pub const FOLDER_SIMPLE_USER: &str = "\u{EB60}"; pub const FOLDER_STAR: &str = "\u{EA86}"; pub const FOLDER_USER: &str = "\u{EB46}"; pub const FOLDERS: &str = "\u{E260}"; pub const FOOTBALL: &str = "\u{E718}"; pub const FOOTBALL_HELMET: &str = "\u{EE4C}"; pub const FOOTPRINTS: &str = "\u{EA88}"; pub const FORK_KNIFE: &str = "\u{E262}"; pub const FOUR_K: &str = "\u{EA5C}"; pub const FRAME_CORNERS: &str = "\u{E626}"; pub const FRAMER_LOGO: &str = "\u{E264}"; pub const FUNCTION: &str = "\u{EBE4}"; pub const FUNNEL: &str = "\u{E266}"; pub const FUNNEL_SIMPLE: &str = "\u{E268}"; pub const FUNNEL_SIMPLE_X: &str = "\u{E26A}"; pub const FUNNEL_X: &str = "\u{E26C}"; pub const GAME_CONTROLLER: &str = "\u{E26E}"; pub const GARAGE: &str = "\u{ECD6}"; pub const GAS_CAN: &str = "\u{E8CE}"; pub const GAS_PUMP: &str = "\u{E768}"; pub const GAUGE: &str = "\u{E628}"; pub const GAVEL: &str = "\u{EA32}"; pub const GEAR: &str = "\u{E270}"; pub const GEAR_FINE: &str = "\u{E87C}"; pub const GEAR_SIX: &str = "\u{E272}"; pub const GENDER_FEMALE: &str = "\u{E6E0}"; pub const GENDER_INTERSEX: &str = "\u{E6E6}"; pub const GENDER_MALE: &str = "\u{E6E2}"; pub const GENDER_NEUTER: &str = "\u{E6EA}"; pub const GENDER_NONBINARY: &str = "\u{E6E4}"; pub const GENDER_TRANSGENDER: &str = "\u{E6E8}"; pub const GHOST: &str = "\u{E62A}"; pub const GIF: &str = "\u{E274}"; pub const GIFT: &str = "\u{E276}"; pub const GIT_BRANCH: &str = "\u{E278}"; pub const GIT_COMMIT: &str = "\u{E27A}"; pub const GIT_DIFF: &str = "\u{E27C}"; pub const GIT_FORK: &str = "\u{E27E}"; pub const GIT_MERGE: &str = "\u{E280}"; pub const GIT_PULL_REQUEST: &str = "\u{E282}"; pub const GITHUB_LOGO: &str = "\u{E576}"; pub const GITLAB_LOGO: &str = "\u{E694}"; pub const GITLAB_LOGO_SIMPLE: &str = "\u{E696}"; pub const GLOBE: &str = "\u{E288}"; pub const GLOBE_HEMISPHERE_EAST: &str = "\u{E28A}"; pub const GLOBE_HEMISPHERE_WEST: &str = "\u{E28C}"; pub const GLOBE_SIMPLE: &str = "\u{E28E}"; pub const GLOBE_SIMPLE_X: &str = "\u{E284}"; pub const GLOBE_STAND: &str = "\u{E290}"; pub const GLOBE_X: &str = "\u{E286}"; pub const GOGGLES: &str = "\u{ECB4}"; pub const GOLF: &str = "\u{EA3E}"; pub const GOODREADS_LOGO: &str = "\u{ED10}"; pub const GOOGLE_CARDBOARD_LOGO: &str = "\u{E7B6}"; pub const GOOGLE_CHROME_LOGO: &str = "\u{E976}"; pub const GOOGLE_DRIVE_LOGO: &str = "\u{E8F6}"; pub const GOOGLE_LOGO: &str = "\u{E292}"; pub const GOOGLE_PHOTOS_LOGO: &str = "\u{EB92}"; pub const GOOGLE_PLAY_LOGO: &str = "\u{E294}"; pub const GOOGLE_PODCASTS_LOGO: &str = "\u{EB94}"; pub const GPS: &str = "\u{EDD8}"; pub const GPS_FIX: &str = "\u{EDD6}"; pub const GPS_SLASH: &str = "\u{EDD4}"; pub const GRADIENT: &str = "\u{EB42}"; pub const GRADUATION_CAP: &str = "\u{E62C}"; pub const GRAINS: &str = "\u{EC68}"; pub const GRAINS_SLASH: &str = "\u{EC6A}"; pub const GRAPH: &str = "\u{EB58}"; pub const GRAPHICS_CARD: &str = "\u{E612}"; pub const GREATER_THAN: &str = "\u{EDC4}"; pub const GREATER_THAN_OR_EQUAL: &str = "\u{EDA2}"; pub const GRID_FOUR: &str = "\u{E296}"; pub const GRID_NINE: &str = "\u{EC8C}"; pub const GUITAR: &str = "\u{EA8A}"; pub const HAIR_DRYER: &str = "\u{EA66}"; pub const HAMBURGER: &str = "\u{E790}"; pub const HAMMER: &str = "\u{E80E}"; pub const HAND: &str = "\u{E298}"; pub const HAND_ARROW_DOWN: &str = "\u{EA4E}"; pub const HAND_ARROW_UP: &str = "\u{EE5A}"; pub const HAND_COINS: &str = "\u{EA8C}"; pub const HAND_DEPOSIT: &str = "\u{EE82}"; pub const HAND_EYE: &str = "\u{EA4C}"; pub const HAND_FIST: &str = "\u{E57A}"; pub const HAND_GRABBING: &str = "\u{E57C}"; pub const HAND_HEART: &str = "\u{E810}"; pub const HAND_PALM: &str = "\u{E57E}"; pub const HAND_PEACE: &str = "\u{E7CC}"; pub const HAND_POINTING: &str = "\u{E29A}"; pub const HAND_SOAP: &str = "\u{E630}"; pub const HAND_SWIPE_LEFT: &str = "\u{EC94}"; pub const HAND_SWIPE_RIGHT: &str = "\u{EC92}"; pub const HAND_TAP: &str = "\u{EC90}"; pub const HAND_WAVING: &str = "\u{E580}"; pub const HAND_WITHDRAW: &str = "\u{EE80}"; pub const HANDBAG: &str = "\u{E29C}"; pub const HANDBAG_SIMPLE: &str = "\u{E62E}"; pub const HANDS_CLAPPING: &str = "\u{E6A0}"; pub const HANDS_PRAYING: &str = "\u{ECC8}"; pub const HANDSHAKE: &str = "\u{E582}"; pub const HARD_DRIVE: &str = "\u{E29E}"; pub const HARD_DRIVES: &str = "\u{E2A0}";
rust
Apache-2.0
c33b60c40f703ffa3d40d252f1bc911cf531581d
2026-01-04T20:22:14.235772Z
true
amPerl/egui-phosphor
https://github.com/amPerl/egui-phosphor/blob/c33b60c40f703ffa3d40d252f1bc911cf531581d/src/variants/regular.rs
src/variants/regular.rs
#![allow(unused)] pub const ACORN: &str = "\u{EB9A}"; pub const ADDRESS_BOOK: &str = "\u{E6F8}"; pub const ADDRESS_BOOK_TABS: &str = "\u{EE4E}"; pub const AIR_TRAFFIC_CONTROL: &str = "\u{ECD8}"; pub const AIRPLANE: &str = "\u{E002}"; pub const AIRPLANE_IN_FLIGHT: &str = "\u{E4FE}"; pub const AIRPLANE_LANDING: &str = "\u{E502}"; pub const AIRPLANE_TAKEOFF: &str = "\u{E504}"; pub const AIRPLANE_TAXIING: &str = "\u{E500}"; pub const AIRPLANE_TILT: &str = "\u{E5D6}"; pub const AIRPLAY: &str = "\u{E004}"; pub const ALARM: &str = "\u{E006}"; pub const ALIEN: &str = "\u{E8A6}"; pub const ALIGN_BOTTOM: &str = "\u{E506}"; pub const ALIGN_BOTTOM_SIMPLE: &str = "\u{EB0C}"; pub const ALIGN_CENTER_HORIZONTAL: &str = "\u{E50A}"; pub const ALIGN_CENTER_HORIZONTAL_SIMPLE: &str = "\u{EB0E}"; pub const ALIGN_CENTER_VERTICAL: &str = "\u{E50C}"; pub const ALIGN_CENTER_VERTICAL_SIMPLE: &str = "\u{EB10}"; pub const ALIGN_LEFT: &str = "\u{E50E}"; pub const ALIGN_LEFT_SIMPLE: &str = "\u{EAEE}"; pub const ALIGN_RIGHT: &str = "\u{E510}"; pub const ALIGN_RIGHT_SIMPLE: &str = "\u{EB12}"; pub const ALIGN_TOP: &str = "\u{E512}"; pub const ALIGN_TOP_SIMPLE: &str = "\u{EB14}"; pub const AMAZON_LOGO: &str = "\u{E96C}"; pub const AMBULANCE: &str = "\u{E572}"; pub const ANCHOR: &str = "\u{E514}"; pub const ANCHOR_SIMPLE: &str = "\u{E5D8}"; pub const ANDROID_LOGO: &str = "\u{E008}"; pub const ANGLE: &str = "\u{E7BC}"; pub const ANGULAR_LOGO: &str = "\u{EB80}"; pub const APERTURE: &str = "\u{E00A}"; pub const APP_STORE_LOGO: &str = "\u{E974}"; pub const APP_WINDOW: &str = "\u{E5DA}"; pub const APPLE_LOGO: &str = "\u{E516}"; pub const APPLE_PODCASTS_LOGO: &str = "\u{EB96}"; pub const APPROXIMATE_EQUALS: &str = "\u{EDAA}"; pub const ARCHIVE: &str = "\u{E00C}"; pub const ARMCHAIR: &str = "\u{E012}"; pub const ARROW_ARC_LEFT: &str = "\u{E014}"; pub const ARROW_ARC_RIGHT: &str = "\u{E016}"; pub const ARROW_BEND_DOUBLE_UP_LEFT: &str = "\u{E03A}"; pub const ARROW_BEND_DOUBLE_UP_RIGHT: &str = "\u{E03C}"; pub const ARROW_BEND_DOWN_LEFT: &str = "\u{E018}"; pub const ARROW_BEND_DOWN_RIGHT: &str = "\u{E01A}"; pub const ARROW_BEND_LEFT_DOWN: &str = "\u{E01C}"; pub const ARROW_BEND_LEFT_UP: &str = "\u{E01E}"; pub const ARROW_BEND_RIGHT_DOWN: &str = "\u{E020}"; pub const ARROW_BEND_RIGHT_UP: &str = "\u{E022}"; pub const ARROW_BEND_UP_LEFT: &str = "\u{E024}"; pub const ARROW_BEND_UP_RIGHT: &str = "\u{E026}"; pub const ARROW_CIRCLE_DOWN: &str = "\u{E028}"; pub const ARROW_CIRCLE_DOWN_LEFT: &str = "\u{E02A}"; pub const ARROW_CIRCLE_DOWN_RIGHT: &str = "\u{E02C}"; pub const ARROW_CIRCLE_LEFT: &str = "\u{E05A}"; pub const ARROW_CIRCLE_RIGHT: &str = "\u{E02E}"; pub const ARROW_CIRCLE_UP: &str = "\u{E030}"; pub const ARROW_CIRCLE_UP_LEFT: &str = "\u{E032}"; pub const ARROW_CIRCLE_UP_RIGHT: &str = "\u{E034}"; pub const ARROW_CLOCKWISE: &str = "\u{E036}"; pub const ARROW_COUNTER_CLOCKWISE: &str = "\u{E038}"; pub const ARROW_DOWN: &str = "\u{E03E}"; pub const ARROW_DOWN_LEFT: &str = "\u{E040}"; pub const ARROW_DOWN_RIGHT: &str = "\u{E042}"; pub const ARROW_ELBOW_DOWN_LEFT: &str = "\u{E044}"; pub const ARROW_ELBOW_DOWN_RIGHT: &str = "\u{E046}"; pub const ARROW_ELBOW_LEFT: &str = "\u{E048}"; pub const ARROW_ELBOW_LEFT_DOWN: &str = "\u{E04A}"; pub const ARROW_ELBOW_LEFT_UP: &str = "\u{E04C}"; pub const ARROW_ELBOW_RIGHT: &str = "\u{E04E}"; pub const ARROW_ELBOW_RIGHT_DOWN: &str = "\u{E050}"; pub const ARROW_ELBOW_RIGHT_UP: &str = "\u{E052}"; pub const ARROW_ELBOW_UP_LEFT: &str = "\u{E054}"; pub const ARROW_ELBOW_UP_RIGHT: &str = "\u{E056}"; pub const ARROW_FAT_DOWN: &str = "\u{E518}"; pub const ARROW_FAT_LEFT: &str = "\u{E51A}"; pub const ARROW_FAT_LINE_DOWN: &str = "\u{E51C}"; pub const ARROW_FAT_LINE_LEFT: &str = "\u{E51E}"; pub const ARROW_FAT_LINE_RIGHT: &str = "\u{E520}"; pub const ARROW_FAT_LINE_UP: &str = "\u{E522}"; pub const ARROW_FAT_LINES_DOWN: &str = "\u{E524}"; pub const ARROW_FAT_LINES_LEFT: &str = "\u{E526}"; pub const ARROW_FAT_LINES_RIGHT: &str = "\u{E528}"; pub const ARROW_FAT_LINES_UP: &str = "\u{E52A}"; pub const ARROW_FAT_RIGHT: &str = "\u{E52C}"; pub const ARROW_FAT_UP: &str = "\u{E52E}"; pub const ARROW_LEFT: &str = "\u{E058}"; pub const ARROW_LINE_DOWN: &str = "\u{E05C}"; pub const ARROW_LINE_DOWN_LEFT: &str = "\u{E05E}"; pub const ARROW_LINE_DOWN_RIGHT: &str = "\u{E060}"; pub const ARROW_LINE_LEFT: &str = "\u{E062}"; pub const ARROW_LINE_RIGHT: &str = "\u{E064}"; pub const ARROW_LINE_UP: &str = "\u{E066}"; pub const ARROW_LINE_UP_LEFT: &str = "\u{E068}"; pub const ARROW_LINE_UP_RIGHT: &str = "\u{E06A}"; pub const ARROW_RIGHT: &str = "\u{E06C}"; pub const ARROW_SQUARE_DOWN: &str = "\u{E06E}"; pub const ARROW_SQUARE_DOWN_LEFT: &str = "\u{E070}"; pub const ARROW_SQUARE_DOWN_RIGHT: &str = "\u{E072}"; pub const ARROW_SQUARE_IN: &str = "\u{E5DC}"; pub const ARROW_SQUARE_LEFT: &str = "\u{E074}"; pub const ARROW_SQUARE_OUT: &str = "\u{E5DE}"; pub const ARROW_SQUARE_RIGHT: &str = "\u{E076}"; pub const ARROW_SQUARE_UP: &str = "\u{E078}"; pub const ARROW_SQUARE_UP_LEFT: &str = "\u{E07A}"; pub const ARROW_SQUARE_UP_RIGHT: &str = "\u{E07C}"; pub const ARROW_U_DOWN_LEFT: &str = "\u{E07E}"; pub const ARROW_U_DOWN_RIGHT: &str = "\u{E080}"; pub const ARROW_U_LEFT_DOWN: &str = "\u{E082}"; pub const ARROW_U_LEFT_UP: &str = "\u{E084}"; pub const ARROW_U_RIGHT_DOWN: &str = "\u{E086}"; pub const ARROW_U_RIGHT_UP: &str = "\u{E088}"; pub const ARROW_U_UP_LEFT: &str = "\u{E08A}"; pub const ARROW_U_UP_RIGHT: &str = "\u{E08C}"; pub const ARROW_UP: &str = "\u{E08E}"; pub const ARROW_UP_LEFT: &str = "\u{E090}"; pub const ARROW_UP_RIGHT: &str = "\u{E092}"; pub const ARROWS_CLOCKWISE: &str = "\u{E094}"; pub const ARROWS_COUNTER_CLOCKWISE: &str = "\u{E096}"; pub const ARROWS_DOWN_UP: &str = "\u{E098}"; pub const ARROWS_HORIZONTAL: &str = "\u{EB06}"; pub const ARROWS_IN: &str = "\u{E09A}"; pub const ARROWS_IN_CARDINAL: &str = "\u{E09C}"; pub const ARROWS_IN_LINE_HORIZONTAL: &str = "\u{E530}"; pub const ARROWS_IN_LINE_VERTICAL: &str = "\u{E532}"; pub const ARROWS_IN_SIMPLE: &str = "\u{E09E}"; pub const ARROWS_LEFT_RIGHT: &str = "\u{E0A0}"; pub const ARROWS_MERGE: &str = "\u{ED3E}"; pub const ARROWS_OUT: &str = "\u{E0A2}"; pub const ARROWS_OUT_CARDINAL: &str = "\u{E0A4}"; pub const ARROWS_OUT_LINE_HORIZONTAL: &str = "\u{E534}"; pub const ARROWS_OUT_LINE_VERTICAL: &str = "\u{E536}"; pub const ARROWS_OUT_SIMPLE: &str = "\u{E0A6}"; pub const ARROWS_SPLIT: &str = "\u{ED3C}"; pub const ARROWS_VERTICAL: &str = "\u{EB04}"; pub const ARTICLE: &str = "\u{E0A8}"; pub const ARTICLE_MEDIUM: &str = "\u{E5E0}"; pub const ARTICLE_NY_TIMES: &str = "\u{E5E2}"; pub const ASCLEPIUS: &str = "\u{EE34}"; pub const CADUCEUS: &str = "\u{EE34}"; pub const ASTERISK: &str = "\u{E0AA}"; pub const ASTERISK_SIMPLE: &str = "\u{E832}"; pub const AT: &str = "\u{E0AC}"; pub const ATOM: &str = "\u{E5E4}"; pub const AVOCADO: &str = "\u{EE04}"; pub const AXE: &str = "\u{E9FC}"; pub const BABY: &str = "\u{E774}"; pub const BABY_CARRIAGE: &str = "\u{E818}"; pub const BACKPACK: &str = "\u{E922}"; pub const BACKSPACE: &str = "\u{E0AE}"; pub const BAG: &str = "\u{E0B0}"; pub const BAG_SIMPLE: &str = "\u{E5E6}"; pub const BALLOON: &str = "\u{E76C}"; pub const BANDAIDS: &str = "\u{E0B2}"; pub const BANK: &str = "\u{E0B4}"; pub const BARBELL: &str = "\u{E0B6}"; pub const BARCODE: &str = "\u{E0B8}"; pub const BARN: &str = "\u{EC72}"; pub const BARRICADE: &str = "\u{E948}"; pub const BASEBALL: &str = "\u{E71A}"; pub const BASEBALL_CAP: &str = "\u{EA28}"; pub const BASEBALL_HELMET: &str = "\u{EE4A}"; pub const BASKET: &str = "\u{E964}"; pub const BASKETBALL: &str = "\u{E724}"; pub const BATHTUB: &str = "\u{E81E}"; pub const BATTERY_CHARGING: &str = "\u{E0BA}"; pub const BATTERY_CHARGING_VERTICAL: &str = "\u{E0BC}"; pub const BATTERY_EMPTY: &str = "\u{E0BE}"; pub const BATTERY_FULL: &str = "\u{E0C0}"; pub const BATTERY_HIGH: &str = "\u{E0C2}"; pub const BATTERY_LOW: &str = "\u{E0C4}"; pub const BATTERY_MEDIUM: &str = "\u{E0C6}"; pub const BATTERY_PLUS: &str = "\u{E808}"; pub const BATTERY_PLUS_VERTICAL: &str = "\u{EC50}"; pub const BATTERY_VERTICAL_EMPTY: &str = "\u{E7C6}"; pub const BATTERY_VERTICAL_FULL: &str = "\u{E7C4}"; pub const BATTERY_VERTICAL_HIGH: &str = "\u{E7C2}"; pub const BATTERY_VERTICAL_LOW: &str = "\u{E7BE}"; pub const BATTERY_VERTICAL_MEDIUM: &str = "\u{E7C0}"; pub const BATTERY_WARNING: &str = "\u{E0C8}"; pub const BATTERY_WARNING_VERTICAL: &str = "\u{E0CA}"; pub const BEACH_BALL: &str = "\u{ED24}"; pub const BEANIE: &str = "\u{EA2A}"; pub const BED: &str = "\u{E0CC}"; pub const BEER_BOTTLE: &str = "\u{E7B0}"; pub const BEER_STEIN: &str = "\u{EB62}"; pub const BEHANCE_LOGO: &str = "\u{E7F4}"; pub const BELL: &str = "\u{E0CE}"; pub const BELL_RINGING: &str = "\u{E5E8}"; pub const BELL_SIMPLE: &str = "\u{E0D0}"; pub const BELL_SIMPLE_RINGING: &str = "\u{E5EA}"; pub const BELL_SIMPLE_SLASH: &str = "\u{E0D2}"; pub const BELL_SIMPLE_Z: &str = "\u{E5EC}"; pub const BELL_SLASH: &str = "\u{E0D4}"; pub const BELL_Z: &str = "\u{E5EE}"; pub const BELT: &str = "\u{EA2C}"; pub const BEZIER_CURVE: &str = "\u{EB00}"; pub const BICYCLE: &str = "\u{E0D6}"; pub const BINARY: &str = "\u{EE60}"; pub const BINOCULARS: &str = "\u{EA64}"; pub const BIOHAZARD: &str = "\u{E9E0}"; pub const BIRD: &str = "\u{E72C}"; pub const BLUEPRINT: &str = "\u{EDA0}"; pub const BLUETOOTH: &str = "\u{E0DA}"; pub const BLUETOOTH_CONNECTED: &str = "\u{E0DC}"; pub const BLUETOOTH_SLASH: &str = "\u{E0DE}"; pub const BLUETOOTH_X: &str = "\u{E0E0}"; pub const BOAT: &str = "\u{E786}"; pub const BOMB: &str = "\u{EE0A}"; pub const BONE: &str = "\u{E7F2}"; pub const BOOK: &str = "\u{E0E2}"; pub const BOOK_BOOKMARK: &str = "\u{E0E4}"; pub const BOOK_OPEN: &str = "\u{E0E6}"; pub const BOOK_OPEN_TEXT: &str = "\u{E8F2}"; pub const BOOK_OPEN_USER: &str = "\u{EDE0}"; pub const BOOKMARK: &str = "\u{E0E8}"; pub const BOOKMARK_SIMPLE: &str = "\u{E0EA}"; pub const BOOKMARKS: &str = "\u{E0EC}"; pub const BOOKMARKS_SIMPLE: &str = "\u{E5F0}"; pub const BOOKS: &str = "\u{E758}"; pub const BOOT: &str = "\u{ECCA}"; pub const BOULES: &str = "\u{E722}"; pub const BOUNDING_BOX: &str = "\u{E6CE}"; pub const BOWL_FOOD: &str = "\u{EAA4}"; pub const BOWL_STEAM: &str = "\u{E8E4}"; pub const BOWLING_BALL: &str = "\u{EA34}"; pub const BOX_ARROW_DOWN: &str = "\u{E00E}"; pub const ARCHIVE_BOX: &str = "\u{E00E}"; pub const BOX_ARROW_UP: &str = "\u{EE54}"; pub const BOXING_GLOVE: &str = "\u{EA36}"; pub const BRACKETS_ANGLE: &str = "\u{E862}"; pub const BRACKETS_CURLY: &str = "\u{E860}"; pub const BRACKETS_ROUND: &str = "\u{E864}"; pub const BRACKETS_SQUARE: &str = "\u{E85E}"; pub const BRAIN: &str = "\u{E74E}"; pub const BRANDY: &str = "\u{E6B4}"; pub const BREAD: &str = "\u{E81C}"; pub const BRIDGE: &str = "\u{EA68}"; pub const BRIEFCASE: &str = "\u{E0EE}"; pub const BRIEFCASE_METAL: &str = "\u{E5F2}"; pub const BROADCAST: &str = "\u{E0F2}"; pub const BROOM: &str = "\u{EC54}"; pub const BROWSER: &str = "\u{E0F4}"; pub const BROWSERS: &str = "\u{E0F6}"; pub const BUG: &str = "\u{E5F4}"; pub const BUG_BEETLE: &str = "\u{E5F6}"; pub const BUG_DROID: &str = "\u{E5F8}"; pub const BUILDING: &str = "\u{E100}"; pub const BUILDING_APARTMENT: &str = "\u{E0FE}"; pub const BUILDING_OFFICE: &str = "\u{E0FF}"; pub const BUILDINGS: &str = "\u{E102}"; pub const BULLDOZER: &str = "\u{EC6C}"; pub const BUS: &str = "\u{E106}"; pub const BUTTERFLY: &str = "\u{EA6E}"; pub const CABLE_CAR: &str = "\u{E49C}"; pub const CACTUS: &str = "\u{E918}"; pub const CAKE: &str = "\u{E780}"; pub const CALCULATOR: &str = "\u{E538}"; pub const CALENDAR: &str = "\u{E108}"; pub const CALENDAR_BLANK: &str = "\u{E10A}"; pub const CALENDAR_CHECK: &str = "\u{E712}"; pub const CALENDAR_DOT: &str = "\u{E7B2}"; pub const CALENDAR_DOTS: &str = "\u{E7B4}"; pub const CALENDAR_HEART: &str = "\u{E8B0}"; pub const CALENDAR_MINUS: &str = "\u{EA14}"; pub const CALENDAR_PLUS: &str = "\u{E714}"; pub const CALENDAR_SLASH: &str = "\u{EA12}"; pub const CALENDAR_STAR: &str = "\u{E8B2}"; pub const CALENDAR_X: &str = "\u{E10C}"; pub const CALL_BELL: &str = "\u{E7DE}"; pub const CAMERA: &str = "\u{E10E}"; pub const CAMERA_PLUS: &str = "\u{EC58}"; pub const CAMERA_ROTATE: &str = "\u{E7A4}"; pub const CAMERA_SLASH: &str = "\u{E110}"; pub const CAMPFIRE: &str = "\u{E9D8}"; pub const CAR: &str = "\u{E112}"; pub const CAR_BATTERY: &str = "\u{EE30}"; pub const CAR_PROFILE: &str = "\u{E8CC}"; pub const CAR_SIMPLE: &str = "\u{E114}"; pub const CARDHOLDER: &str = "\u{E5FA}"; pub const CARDS: &str = "\u{E0F8}"; pub const CARDS_THREE: &str = "\u{EE50}"; pub const CARET_CIRCLE_DOUBLE_DOWN: &str = "\u{E116}"; pub const CARET_CIRCLE_DOUBLE_LEFT: &str = "\u{E118}"; pub const CARET_CIRCLE_DOUBLE_RIGHT: &str = "\u{E11A}"; pub const CARET_CIRCLE_DOUBLE_UP: &str = "\u{E11C}"; pub const CARET_CIRCLE_DOWN: &str = "\u{E11E}"; pub const CARET_CIRCLE_LEFT: &str = "\u{E120}"; pub const CARET_CIRCLE_RIGHT: &str = "\u{E122}"; pub const CARET_CIRCLE_UP: &str = "\u{E124}"; pub const CARET_CIRCLE_UP_DOWN: &str = "\u{E13E}"; pub const CARET_DOUBLE_DOWN: &str = "\u{E126}"; pub const CARET_DOUBLE_LEFT: &str = "\u{E128}"; pub const CARET_DOUBLE_RIGHT: &str = "\u{E12A}"; pub const CARET_DOUBLE_UP: &str = "\u{E12C}"; pub const CARET_DOWN: &str = "\u{E136}"; pub const CARET_LEFT: &str = "\u{E138}"; pub const CARET_LINE_DOWN: &str = "\u{E134}"; pub const CARET_LINE_LEFT: &str = "\u{E132}"; pub const CARET_LINE_RIGHT: &str = "\u{E130}"; pub const CARET_LINE_UP: &str = "\u{E12E}"; pub const CARET_RIGHT: &str = "\u{E13A}"; pub const CARET_UP: &str = "\u{E13C}"; pub const CARET_UP_DOWN: &str = "\u{E140}"; pub const CARROT: &str = "\u{ED38}"; pub const CASH_REGISTER: &str = "\u{ED80}"; pub const CASSETTE_TAPE: &str = "\u{ED2E}"; pub const CASTLE_TURRET: &str = "\u{E9D0}"; pub const CAT: &str = "\u{E748}"; pub const CELL_SIGNAL_FULL: &str = "\u{E142}"; pub const CELL_SIGNAL_HIGH: &str = "\u{E144}"; pub const CELL_SIGNAL_LOW: &str = "\u{E146}"; pub const CELL_SIGNAL_MEDIUM: &str = "\u{E148}"; pub const CELL_SIGNAL_NONE: &str = "\u{E14A}"; pub const CELL_SIGNAL_SLASH: &str = "\u{E14C}"; pub const CELL_SIGNAL_X: &str = "\u{E14E}"; pub const CELL_TOWER: &str = "\u{EBAA}"; pub const CERTIFICATE: &str = "\u{E766}"; pub const CHAIR: &str = "\u{E950}"; pub const CHALKBOARD: &str = "\u{E5FC}"; pub const CHALKBOARD_SIMPLE: &str = "\u{E5FE}"; pub const CHALKBOARD_TEACHER: &str = "\u{E600}"; pub const CHAMPAGNE: &str = "\u{EACA}"; pub const CHARGING_STATION: &str = "\u{E8D0}"; pub const CHART_BAR: &str = "\u{E150}"; pub const CHART_BAR_HORIZONTAL: &str = "\u{E152}"; pub const CHART_DONUT: &str = "\u{EAA6}"; pub const CHART_LINE: &str = "\u{E154}"; pub const CHART_LINE_DOWN: &str = "\u{E8B6}"; pub const CHART_LINE_UP: &str = "\u{E156}"; pub const CHART_PIE: &str = "\u{E158}"; pub const CHART_PIE_SLICE: &str = "\u{E15A}"; pub const CHART_POLAR: &str = "\u{EAA8}"; pub const CHART_SCATTER: &str = "\u{EAAC}"; pub const CHAT: &str = "\u{E15C}"; pub const CHAT_CENTERED: &str = "\u{E160}"; pub const CHAT_CENTERED_DOTS: &str = "\u{E164}"; pub const CHAT_CENTERED_SLASH: &str = "\u{E162}"; pub const CHAT_CENTERED_TEXT: &str = "\u{E166}"; pub const CHAT_CIRCLE: &str = "\u{E168}"; pub const CHAT_CIRCLE_DOTS: &str = "\u{E16C}"; pub const CHAT_CIRCLE_SLASH: &str = "\u{E16A}"; pub const CHAT_CIRCLE_TEXT: &str = "\u{E16E}"; pub const CHAT_DOTS: &str = "\u{E170}"; pub const CHAT_SLASH: &str = "\u{E15E}"; pub const CHAT_TEARDROP: &str = "\u{E172}"; pub const CHAT_TEARDROP_DOTS: &str = "\u{E176}"; pub const CHAT_TEARDROP_SLASH: &str = "\u{E174}"; pub const CHAT_TEARDROP_TEXT: &str = "\u{E178}"; pub const CHAT_TEXT: &str = "\u{E17A}"; pub const CHATS: &str = "\u{E17C}"; pub const CHATS_CIRCLE: &str = "\u{E17E}"; pub const CHATS_TEARDROP: &str = "\u{E180}"; pub const CHECK: &str = "\u{E182}"; pub const CHECK_CIRCLE: &str = "\u{E184}"; pub const CHECK_FAT: &str = "\u{EBA6}"; pub const CHECK_SQUARE: &str = "\u{E186}"; pub const CHECK_SQUARE_OFFSET: &str = "\u{E188}"; pub const CHECKERBOARD: &str = "\u{E8C4}"; pub const CHECKS: &str = "\u{E53A}"; pub const CHEERS: &str = "\u{EA4A}"; pub const CHEESE: &str = "\u{E9FE}"; pub const CHEF_HAT: &str = "\u{ED8E}"; pub const CHERRIES: &str = "\u{E830}"; pub const CHURCH: &str = "\u{ECEA}"; pub const CIGARETTE: &str = "\u{ED90}"; pub const CIGARETTE_SLASH: &str = "\u{ED92}"; pub const CIRCLE: &str = "\u{E18A}"; pub const CIRCLE_DASHED: &str = "\u{E602}"; pub const CIRCLE_HALF: &str = "\u{E18C}"; pub const CIRCLE_HALF_TILT: &str = "\u{E18E}"; pub const CIRCLE_NOTCH: &str = "\u{EB44}"; pub const CIRCLES_FOUR: &str = "\u{E190}"; pub const CIRCLES_THREE: &str = "\u{E192}"; pub const CIRCLES_THREE_PLUS: &str = "\u{E194}"; pub const CIRCUITRY: &str = "\u{E9C2}"; pub const CITY: &str = "\u{EA6A}"; pub const CLIPBOARD: &str = "\u{E196}"; pub const CLIPBOARD_TEXT: &str = "\u{E198}"; pub const CLOCK: &str = "\u{E19A}"; pub const CLOCK_AFTERNOON: &str = "\u{E19C}"; pub const CLOCK_CLOCKWISE: &str = "\u{E19E}"; pub const CLOCK_COUNTDOWN: &str = "\u{ED2C}"; pub const CLOCK_COUNTER_CLOCKWISE: &str = "\u{E1A0}"; pub const CLOCK_USER: &str = "\u{EDEC}"; pub const CLOSED_CAPTIONING: &str = "\u{E1A4}"; pub const CLOUD: &str = "\u{E1AA}"; pub const CLOUD_ARROW_DOWN: &str = "\u{E1AC}"; pub const CLOUD_ARROW_UP: &str = "\u{E1AE}"; pub const CLOUD_CHECK: &str = "\u{E1B0}"; pub const CLOUD_FOG: &str = "\u{E53C}"; pub const CLOUD_LIGHTNING: &str = "\u{E1B2}"; pub const CLOUD_MOON: &str = "\u{E53E}"; pub const CLOUD_RAIN: &str = "\u{E1B4}"; pub const CLOUD_SLASH: &str = "\u{E1B6}"; pub const CLOUD_SNOW: &str = "\u{E1B8}"; pub const CLOUD_SUN: &str = "\u{E540}"; pub const CLOUD_WARNING: &str = "\u{EA98}"; pub const CLOUD_X: &str = "\u{EA96}"; pub const CLOVER: &str = "\u{EDC8}"; pub const CLUB: &str = "\u{E1BA}"; pub const COAT_HANGER: &str = "\u{E7FE}"; pub const CODA_LOGO: &str = "\u{E7CE}"; pub const CODE: &str = "\u{E1BC}"; pub const CODE_BLOCK: &str = "\u{EAFE}"; pub const CODE_SIMPLE: &str = "\u{E1BE}"; pub const CODEPEN_LOGO: &str = "\u{E978}"; pub const CODESANDBOX_LOGO: &str = "\u{EA06}"; pub const COFFEE: &str = "\u{E1C2}"; pub const COFFEE_BEAN: &str = "\u{E1C0}"; pub const COIN: &str = "\u{E60E}"; pub const COIN_VERTICAL: &str = "\u{EB48}"; pub const COINS: &str = "\u{E78E}"; pub const COLUMNS: &str = "\u{E546}"; pub const COLUMNS_PLUS_LEFT: &str = "\u{E544}"; pub const COLUMNS_PLUS_RIGHT: &str = "\u{E542}"; pub const COMMAND: &str = "\u{E1C4}"; pub const COMPASS: &str = "\u{E1C8}"; pub const COMPASS_ROSE: &str = "\u{E1C6}"; pub const COMPASS_TOOL: &str = "\u{EA0E}"; pub const COMPUTER_TOWER: &str = "\u{E548}"; pub const CONFETTI: &str = "\u{E81A}"; pub const CONTACTLESS_PAYMENT: &str = "\u{ED42}"; pub const CONTROL: &str = "\u{ECA6}"; pub const COOKIE: &str = "\u{E6CA}"; pub const COOKING_POT: &str = "\u{E764}"; pub const COPY: &str = "\u{E1CA}"; pub const COPY_SIMPLE: &str = "\u{E1CC}"; pub const COPYLEFT: &str = "\u{E86A}"; pub const COPYRIGHT: &str = "\u{E54A}"; pub const CORNERS_IN: &str = "\u{E1CE}"; pub const CORNERS_OUT: &str = "\u{E1D0}"; pub const COUCH: &str = "\u{E7F6}"; pub const COURT_BASKETBALL: &str = "\u{EE36}"; pub const COW: &str = "\u{EABE}"; pub const COWBOY_HAT: &str = "\u{ED12}"; pub const CPU: &str = "\u{E610}"; pub const CRANE: &str = "\u{ED48}"; pub const CRANE_TOWER: &str = "\u{ED49}"; pub const CREDIT_CARD: &str = "\u{E1D2}"; pub const CRICKET: &str = "\u{EE12}"; pub const CROP: &str = "\u{E1D4}"; pub const CROSS: &str = "\u{E8A0}"; pub const CROSSHAIR: &str = "\u{E1D6}"; pub const CROSSHAIR_SIMPLE: &str = "\u{E1D8}"; pub const CROWN: &str = "\u{E614}"; pub const CROWN_CROSS: &str = "\u{EE5E}"; pub const CROWN_SIMPLE: &str = "\u{E616}"; pub const CUBE: &str = "\u{E1DA}"; pub const CUBE_FOCUS: &str = "\u{ED0A}"; pub const CUBE_TRANSPARENT: &str = "\u{EC7C}"; pub const CURRENCY_BTC: &str = "\u{E618}"; pub const CURRENCY_CIRCLE_DOLLAR: &str = "\u{E54C}"; pub const CURRENCY_CNY: &str = "\u{E54E}"; pub const CURRENCY_DOLLAR: &str = "\u{E550}"; pub const CURRENCY_DOLLAR_SIMPLE: &str = "\u{E552}"; pub const CURRENCY_ETH: &str = "\u{EADA}"; pub const CURRENCY_EUR: &str = "\u{E554}"; pub const CURRENCY_GBP: &str = "\u{E556}"; pub const CURRENCY_INR: &str = "\u{E558}"; pub const CURRENCY_JPY: &str = "\u{E55A}"; pub const CURRENCY_KRW: &str = "\u{E55C}"; pub const CURRENCY_KZT: &str = "\u{EC4C}"; pub const CURRENCY_NGN: &str = "\u{EB52}"; pub const CURRENCY_RUB: &str = "\u{E55E}"; pub const CURSOR: &str = "\u{E1DC}"; pub const CURSOR_CLICK: &str = "\u{E7C8}"; pub const CURSOR_TEXT: &str = "\u{E7D8}"; pub const CYLINDER: &str = "\u{E8FC}"; pub const DATABASE: &str = "\u{E1DE}"; pub const DESK: &str = "\u{ED16}"; pub const DESKTOP: &str = "\u{E560}"; pub const DESKTOP_TOWER: &str = "\u{E562}"; pub const DETECTIVE: &str = "\u{E83E}"; pub const DEV_TO_LOGO: &str = "\u{ED0E}"; pub const DEVICE_MOBILE: &str = "\u{E1E0}"; pub const DEVICE_MOBILE_CAMERA: &str = "\u{E1E2}"; pub const DEVICE_MOBILE_SLASH: &str = "\u{EE46}"; pub const DEVICE_MOBILE_SPEAKER: &str = "\u{E1E4}"; pub const DEVICE_ROTATE: &str = "\u{EDF2}"; pub const DEVICE_TABLET: &str = "\u{E1E6}"; pub const DEVICE_TABLET_CAMERA: &str = "\u{E1E8}"; pub const DEVICE_TABLET_SPEAKER: &str = "\u{E1EA}"; pub const DEVICES: &str = "\u{EBA4}"; pub const DIAMOND: &str = "\u{E1EC}"; pub const DIAMONDS_FOUR: &str = "\u{E8F4}"; pub const DICE_FIVE: &str = "\u{E1EE}"; pub const DICE_FOUR: &str = "\u{E1F0}"; pub const DICE_ONE: &str = "\u{E1F2}"; pub const DICE_SIX: &str = "\u{E1F4}"; pub const DICE_THREE: &str = "\u{E1F6}"; pub const DICE_TWO: &str = "\u{E1F8}"; pub const DISC: &str = "\u{E564}"; pub const DISCO_BALL: &str = "\u{ED98}"; pub const DISCORD_LOGO: &str = "\u{E61A}"; pub const DIVIDE: &str = "\u{E1FA}"; pub const DNA: &str = "\u{E924}"; pub const DOG: &str = "\u{E74A}"; pub const DOOR: &str = "\u{E61C}"; pub const DOOR_OPEN: &str = "\u{E7E6}"; pub const DOT: &str = "\u{ECDE}"; pub const DOT_OUTLINE: &str = "\u{ECE0}"; pub const DOTS_NINE: &str = "\u{E1FC}"; pub const DOTS_SIX: &str = "\u{E794}"; pub const DOTS_SIX_VERTICAL: &str = "\u{EAE2}"; pub const DOTS_THREE: &str = "\u{E1FE}"; pub const DOTS_THREE_CIRCLE: &str = "\u{E200}"; pub const DOTS_THREE_CIRCLE_VERTICAL: &str = "\u{E202}"; pub const DOTS_THREE_OUTLINE: &str = "\u{E204}"; pub const DOTS_THREE_OUTLINE_VERTICAL: &str = "\u{E206}"; pub const DOTS_THREE_VERTICAL: &str = "\u{E208}"; pub const DOWNLOAD: &str = "\u{E20A}"; pub const DOWNLOAD_SIMPLE: &str = "\u{E20C}"; pub const DRESS: &str = "\u{EA7E}"; pub const DRESSER: &str = "\u{E94E}"; pub const DRIBBBLE_LOGO: &str = "\u{E20E}"; pub const DRONE: &str = "\u{ED74}"; pub const DROP: &str = "\u{E210}"; pub const DROP_HALF: &str = "\u{E566}"; pub const DROP_HALF_BOTTOM: &str = "\u{EB40}"; pub const DROP_SIMPLE: &str = "\u{EE32}"; pub const DROP_SLASH: &str = "\u{E954}"; pub const DROPBOX_LOGO: &str = "\u{E7D0}"; pub const EAR: &str = "\u{E70C}"; pub const EAR_SLASH: &str = "\u{E70E}"; pub const EGG: &str = "\u{E812}"; pub const EGG_CRACK: &str = "\u{EB64}"; pub const EJECT: &str = "\u{E212}"; pub const EJECT_SIMPLE: &str = "\u{E6AE}"; pub const ELEVATOR: &str = "\u{ECC0}"; pub const EMPTY: &str = "\u{EDBC}"; pub const ENGINE: &str = "\u{EA80}"; pub const ENVELOPE: &str = "\u{E214}"; pub const ENVELOPE_OPEN: &str = "\u{E216}"; pub const ENVELOPE_SIMPLE: &str = "\u{E218}"; pub const ENVELOPE_SIMPLE_OPEN: &str = "\u{E21A}"; pub const EQUALIZER: &str = "\u{EBBC}"; pub const EQUALS: &str = "\u{E21C}"; pub const ERASER: &str = "\u{E21E}"; pub const ESCALATOR_DOWN: &str = "\u{ECBA}"; pub const ESCALATOR_UP: &str = "\u{ECBC}"; pub const EXAM: &str = "\u{E742}"; pub const EXCLAMATION_MARK: &str = "\u{EE44}"; pub const EXCLUDE: &str = "\u{E882}"; pub const EXCLUDE_SQUARE: &str = "\u{E880}"; pub const EXPORT: &str = "\u{EAF0}"; pub const EYE: &str = "\u{E220}"; pub const EYE_CLOSED: &str = "\u{E222}"; pub const EYE_SLASH: &str = "\u{E224}"; pub const EYEDROPPER: &str = "\u{E568}"; pub const EYEDROPPER_SAMPLE: &str = "\u{EAC4}"; pub const EYEGLASSES: &str = "\u{E7BA}"; pub const EYES: &str = "\u{EE5C}"; pub const FACE_MASK: &str = "\u{E56A}"; pub const FACEBOOK_LOGO: &str = "\u{E226}"; pub const FACTORY: &str = "\u{E760}"; pub const FADERS: &str = "\u{E228}"; pub const FADERS_HORIZONTAL: &str = "\u{E22A}"; pub const FALLOUT_SHELTER: &str = "\u{E9DE}"; pub const FAN: &str = "\u{E9F2}"; pub const FARM: &str = "\u{EC70}"; pub const FAST_FORWARD: &str = "\u{E6A6}"; pub const FAST_FORWARD_CIRCLE: &str = "\u{E22C}"; pub const FEATHER: &str = "\u{E9C0}"; pub const FEDIVERSE_LOGO: &str = "\u{ED66}"; pub const FIGMA_LOGO: &str = "\u{E22E}"; pub const FILE: &str = "\u{E230}"; pub const FILE_ARCHIVE: &str = "\u{EB2A}"; pub const FILE_ARROW_DOWN: &str = "\u{E232}"; pub const FILE_ARROW_UP: &str = "\u{E61E}"; pub const FILE_AUDIO: &str = "\u{EA20}"; pub const FILE_C: &str = "\u{EB32}"; pub const FILE_C_SHARP: &str = "\u{EB30}"; pub const FILE_CLOUD: &str = "\u{E95E}"; pub const FILE_CODE: &str = "\u{E914}"; pub const FILE_CPP: &str = "\u{EB2E}"; pub const FILE_CSS: &str = "\u{EB34}"; pub const FILE_CSV: &str = "\u{EB1C}"; pub const FILE_DASHED: &str = "\u{E704}"; pub const FILE_DOTTED: &str = "\u{E704}"; pub const FILE_DOC: &str = "\u{EB1E}"; pub const FILE_HTML: &str = "\u{EB38}"; pub const FILE_IMAGE: &str = "\u{EA24}"; pub const FILE_INI: &str = "\u{EB33}"; pub const FILE_JPG: &str = "\u{EB1A}"; pub const FILE_JS: &str = "\u{EB24}"; pub const FILE_JSX: &str = "\u{EB3A}"; pub const FILE_LOCK: &str = "\u{E95C}"; pub const FILE_MAGNIFYING_GLASS: &str = "\u{E238}"; pub const FILE_SEARCH: &str = "\u{E238}"; pub const FILE_MD: &str = "\u{ED50}"; pub const FILE_MINUS: &str = "\u{E234}"; pub const FILE_PDF: &str = "\u{E702}"; pub const FILE_PLUS: &str = "\u{E236}"; pub const FILE_PNG: &str = "\u{EB18}"; pub const FILE_PPT: &str = "\u{EB20}"; pub const FILE_PY: &str = "\u{EB2C}"; pub const FILE_RS: &str = "\u{EB28}"; pub const FILE_SQL: &str = "\u{ED4E}"; pub const FILE_SVG: &str = "\u{ED08}"; pub const FILE_TEXT: &str = "\u{E23A}"; pub const FILE_TS: &str = "\u{EB26}"; pub const FILE_TSX: &str = "\u{EB3C}"; pub const FILE_TXT: &str = "\u{EB35}"; pub const FILE_VIDEO: &str = "\u{EA22}"; pub const FILE_VUE: &str = "\u{EB3E}"; pub const FILE_X: &str = "\u{E23C}"; pub const FILE_XLS: &str = "\u{EB22}"; pub const FILE_ZIP: &str = "\u{E958}"; pub const FILES: &str = "\u{E710}"; pub const FILM_REEL: &str = "\u{E8C0}"; pub const FILM_SCRIPT: &str = "\u{EB50}"; pub const FILM_SLATE: &str = "\u{E8C2}"; pub const FILM_STRIP: &str = "\u{E792}"; pub const FINGERPRINT: &str = "\u{E23E}"; pub const FINGERPRINT_SIMPLE: &str = "\u{E240}"; pub const FINN_THE_HUMAN: &str = "\u{E56C}"; pub const FIRE: &str = "\u{E242}"; pub const FIRE_EXTINGUISHER: &str = "\u{E9E8}"; pub const FIRE_SIMPLE: &str = "\u{E620}"; pub const FIRE_TRUCK: &str = "\u{E574}"; pub const FIRST_AID: &str = "\u{E56E}"; pub const FIRST_AID_KIT: &str = "\u{E570}"; pub const FISH: &str = "\u{E728}"; pub const FISH_SIMPLE: &str = "\u{E72A}"; pub const FLAG: &str = "\u{E244}"; pub const FLAG_BANNER: &str = "\u{E622}"; pub const FLAG_BANNER_FOLD: &str = "\u{ECF2}"; pub const FLAG_CHECKERED: &str = "\u{EA38}"; pub const FLAG_PENNANT: &str = "\u{ECF0}"; pub const FLAME: &str = "\u{E624}"; pub const FLASHLIGHT: &str = "\u{E246}"; pub const FLASK: &str = "\u{E79E}"; pub const FLIP_HORIZONTAL: &str = "\u{ED6A}"; pub const FLIP_VERTICAL: &str = "\u{ED6C}"; pub const FLOPPY_DISK: &str = "\u{E248}"; pub const FLOPPY_DISK_BACK: &str = "\u{EAF4}"; pub const FLOW_ARROW: &str = "\u{E6EC}"; pub const FLOWER: &str = "\u{E75E}"; pub const FLOWER_LOTUS: &str = "\u{E6CC}"; pub const FLOWER_TULIP: &str = "\u{EACC}"; pub const FLYING_SAUCER: &str = "\u{EB4A}"; pub const FOLDER: &str = "\u{E24A}"; pub const FOLDER_NOTCH: &str = "\u{E24A}"; pub const FOLDER_DASHED: &str = "\u{E8F8}"; pub const FOLDER_DOTTED: &str = "\u{E8F8}"; pub const FOLDER_LOCK: &str = "\u{EA3C}"; pub const FOLDER_MINUS: &str = "\u{E254}"; pub const FOLDER_NOTCH_MINUS: &str = "\u{E254}"; pub const FOLDER_OPEN: &str = "\u{E256}"; pub const FOLDER_NOTCH_OPEN: &str = "\u{E256}"; pub const FOLDER_PLUS: &str = "\u{E258}"; pub const FOLDER_NOTCH_PLUS: &str = "\u{E258}"; pub const FOLDER_SIMPLE: &str = "\u{E25A}"; pub const FOLDER_SIMPLE_DASHED: &str = "\u{EC2A}"; pub const FOLDER_SIMPLE_DOTTED: &str = "\u{EC2A}"; pub const FOLDER_SIMPLE_LOCK: &str = "\u{EB5E}"; pub const FOLDER_SIMPLE_MINUS: &str = "\u{E25C}"; pub const FOLDER_SIMPLE_PLUS: &str = "\u{E25E}"; pub const FOLDER_SIMPLE_STAR: &str = "\u{EC2E}"; pub const FOLDER_SIMPLE_USER: &str = "\u{EB60}"; pub const FOLDER_STAR: &str = "\u{EA86}"; pub const FOLDER_USER: &str = "\u{EB46}"; pub const FOLDERS: &str = "\u{E260}"; pub const FOOTBALL: &str = "\u{E718}"; pub const FOOTBALL_HELMET: &str = "\u{EE4C}"; pub const FOOTPRINTS: &str = "\u{EA88}"; pub const FORK_KNIFE: &str = "\u{E262}"; pub const FOUR_K: &str = "\u{EA5C}"; pub const FRAME_CORNERS: &str = "\u{E626}"; pub const FRAMER_LOGO: &str = "\u{E264}"; pub const FUNCTION: &str = "\u{EBE4}"; pub const FUNNEL: &str = "\u{E266}"; pub const FUNNEL_SIMPLE: &str = "\u{E268}"; pub const FUNNEL_SIMPLE_X: &str = "\u{E26A}"; pub const FUNNEL_X: &str = "\u{E26C}"; pub const GAME_CONTROLLER: &str = "\u{E26E}"; pub const GARAGE: &str = "\u{ECD6}"; pub const GAS_CAN: &str = "\u{E8CE}"; pub const GAS_PUMP: &str = "\u{E768}"; pub const GAUGE: &str = "\u{E628}"; pub const GAVEL: &str = "\u{EA32}"; pub const GEAR: &str = "\u{E270}"; pub const GEAR_FINE: &str = "\u{E87C}"; pub const GEAR_SIX: &str = "\u{E272}"; pub const GENDER_FEMALE: &str = "\u{E6E0}"; pub const GENDER_INTERSEX: &str = "\u{E6E6}"; pub const GENDER_MALE: &str = "\u{E6E2}"; pub const GENDER_NEUTER: &str = "\u{E6EA}"; pub const GENDER_NONBINARY: &str = "\u{E6E4}"; pub const GENDER_TRANSGENDER: &str = "\u{E6E8}"; pub const GHOST: &str = "\u{E62A}"; pub const GIF: &str = "\u{E274}"; pub const GIFT: &str = "\u{E276}"; pub const GIT_BRANCH: &str = "\u{E278}"; pub const GIT_COMMIT: &str = "\u{E27A}"; pub const GIT_DIFF: &str = "\u{E27C}"; pub const GIT_FORK: &str = "\u{E27E}"; pub const GIT_MERGE: &str = "\u{E280}"; pub const GIT_PULL_REQUEST: &str = "\u{E282}"; pub const GITHUB_LOGO: &str = "\u{E576}"; pub const GITLAB_LOGO: &str = "\u{E694}"; pub const GITLAB_LOGO_SIMPLE: &str = "\u{E696}"; pub const GLOBE: &str = "\u{E288}"; pub const GLOBE_HEMISPHERE_EAST: &str = "\u{E28A}"; pub const GLOBE_HEMISPHERE_WEST: &str = "\u{E28C}"; pub const GLOBE_SIMPLE: &str = "\u{E28E}"; pub const GLOBE_SIMPLE_X: &str = "\u{E284}"; pub const GLOBE_STAND: &str = "\u{E290}"; pub const GLOBE_X: &str = "\u{E286}"; pub const GOGGLES: &str = "\u{ECB4}"; pub const GOLF: &str = "\u{EA3E}"; pub const GOODREADS_LOGO: &str = "\u{ED10}"; pub const GOOGLE_CARDBOARD_LOGO: &str = "\u{E7B6}"; pub const GOOGLE_CHROME_LOGO: &str = "\u{E976}"; pub const GOOGLE_DRIVE_LOGO: &str = "\u{E8F6}"; pub const GOOGLE_LOGO: &str = "\u{E292}"; pub const GOOGLE_PHOTOS_LOGO: &str = "\u{EB92}"; pub const GOOGLE_PLAY_LOGO: &str = "\u{E294}"; pub const GOOGLE_PODCASTS_LOGO: &str = "\u{EB94}"; pub const GPS: &str = "\u{EDD8}"; pub const GPS_FIX: &str = "\u{EDD6}"; pub const GPS_SLASH: &str = "\u{EDD4}"; pub const GRADIENT: &str = "\u{EB42}"; pub const GRADUATION_CAP: &str = "\u{E62C}"; pub const GRAINS: &str = "\u{EC68}"; pub const GRAINS_SLASH: &str = "\u{EC6A}"; pub const GRAPH: &str = "\u{EB58}"; pub const GRAPHICS_CARD: &str = "\u{E612}"; pub const GREATER_THAN: &str = "\u{EDC4}"; pub const GREATER_THAN_OR_EQUAL: &str = "\u{EDA2}"; pub const GRID_FOUR: &str = "\u{E296}"; pub const GRID_NINE: &str = "\u{EC8C}"; pub const GUITAR: &str = "\u{EA8A}"; pub const HAIR_DRYER: &str = "\u{EA66}"; pub const HAMBURGER: &str = "\u{E790}"; pub const HAMMER: &str = "\u{E80E}"; pub const HAND: &str = "\u{E298}"; pub const HAND_ARROW_DOWN: &str = "\u{EA4E}"; pub const HAND_ARROW_UP: &str = "\u{EE5A}"; pub const HAND_COINS: &str = "\u{EA8C}"; pub const HAND_DEPOSIT: &str = "\u{EE82}"; pub const HAND_EYE: &str = "\u{EA4C}"; pub const HAND_FIST: &str = "\u{E57A}"; pub const HAND_GRABBING: &str = "\u{E57C}"; pub const HAND_HEART: &str = "\u{E810}"; pub const HAND_PALM: &str = "\u{E57E}"; pub const HAND_PEACE: &str = "\u{E7CC}"; pub const HAND_POINTING: &str = "\u{E29A}"; pub const HAND_SOAP: &str = "\u{E630}"; pub const HAND_SWIPE_LEFT: &str = "\u{EC94}"; pub const HAND_SWIPE_RIGHT: &str = "\u{EC92}"; pub const HAND_TAP: &str = "\u{EC90}"; pub const HAND_WAVING: &str = "\u{E580}"; pub const HAND_WITHDRAW: &str = "\u{EE80}"; pub const HANDBAG: &str = "\u{E29C}"; pub const HANDBAG_SIMPLE: &str = "\u{E62E}"; pub const HANDS_CLAPPING: &str = "\u{E6A0}"; pub const HANDS_PRAYING: &str = "\u{ECC8}"; pub const HANDSHAKE: &str = "\u{E582}"; pub const HARD_DRIVE: &str = "\u{E29E}"; pub const HARD_DRIVES: &str = "\u{E2A0}";
rust
Apache-2.0
c33b60c40f703ffa3d40d252f1bc911cf531581d
2026-01-04T20:22:14.235772Z
true
amPerl/egui-phosphor
https://github.com/amPerl/egui-phosphor/blob/c33b60c40f703ffa3d40d252f1bc911cf531581d/src/variants/bold.rs
src/variants/bold.rs
#![allow(unused)] pub const ACORN: &str = "\u{EB9A}"; pub const ADDRESS_BOOK: &str = "\u{E6F8}"; pub const ADDRESS_BOOK_TABS: &str = "\u{EE4E}"; pub const AIR_TRAFFIC_CONTROL: &str = "\u{ECD8}"; pub const AIRPLANE: &str = "\u{E002}"; pub const AIRPLANE_IN_FLIGHT: &str = "\u{E4FE}"; pub const AIRPLANE_LANDING: &str = "\u{E502}"; pub const AIRPLANE_TAKEOFF: &str = "\u{E504}"; pub const AIRPLANE_TAXIING: &str = "\u{E500}"; pub const AIRPLANE_TILT: &str = "\u{E5D6}"; pub const AIRPLAY: &str = "\u{E004}"; pub const ALARM: &str = "\u{E006}"; pub const ALIEN: &str = "\u{E8A6}"; pub const ALIGN_BOTTOM: &str = "\u{E506}"; pub const ALIGN_BOTTOM_SIMPLE: &str = "\u{EB0C}"; pub const ALIGN_CENTER_HORIZONTAL: &str = "\u{E50A}"; pub const ALIGN_CENTER_HORIZONTAL_SIMPLE: &str = "\u{EB0E}"; pub const ALIGN_CENTER_VERTICAL: &str = "\u{E50C}"; pub const ALIGN_CENTER_VERTICAL_SIMPLE: &str = "\u{EB10}"; pub const ALIGN_LEFT: &str = "\u{E50E}"; pub const ALIGN_LEFT_SIMPLE: &str = "\u{EAEE}"; pub const ALIGN_RIGHT: &str = "\u{E510}"; pub const ALIGN_RIGHT_SIMPLE: &str = "\u{EB12}"; pub const ALIGN_TOP: &str = "\u{E512}"; pub const ALIGN_TOP_SIMPLE: &str = "\u{EB14}"; pub const AMAZON_LOGO: &str = "\u{E96C}"; pub const AMBULANCE: &str = "\u{E572}"; pub const ANCHOR: &str = "\u{E514}"; pub const ANCHOR_SIMPLE: &str = "\u{E5D8}"; pub const ANDROID_LOGO: &str = "\u{E008}"; pub const ANGLE: &str = "\u{E7BC}"; pub const ANGULAR_LOGO: &str = "\u{EB80}"; pub const APERTURE: &str = "\u{E00A}"; pub const APP_STORE_LOGO: &str = "\u{E974}"; pub const APP_WINDOW: &str = "\u{E5DA}"; pub const APPLE_LOGO: &str = "\u{E516}"; pub const APPLE_PODCASTS_LOGO: &str = "\u{EB96}"; pub const APPROXIMATE_EQUALS: &str = "\u{EDAA}"; pub const ARCHIVE: &str = "\u{E00C}"; pub const ARMCHAIR: &str = "\u{E012}"; pub const ARROW_ARC_LEFT: &str = "\u{E014}"; pub const ARROW_ARC_RIGHT: &str = "\u{E016}"; pub const ARROW_BEND_DOUBLE_UP_LEFT: &str = "\u{E03A}"; pub const ARROW_BEND_DOUBLE_UP_RIGHT: &str = "\u{E03C}"; pub const ARROW_BEND_DOWN_LEFT: &str = "\u{E018}"; pub const ARROW_BEND_DOWN_RIGHT: &str = "\u{E01A}"; pub const ARROW_BEND_LEFT_DOWN: &str = "\u{E01C}"; pub const ARROW_BEND_LEFT_UP: &str = "\u{E01E}"; pub const ARROW_BEND_RIGHT_DOWN: &str = "\u{E020}"; pub const ARROW_BEND_RIGHT_UP: &str = "\u{E022}"; pub const ARROW_BEND_UP_LEFT: &str = "\u{E024}"; pub const ARROW_BEND_UP_RIGHT: &str = "\u{E026}"; pub const ARROW_CIRCLE_DOWN: &str = "\u{E028}"; pub const ARROW_CIRCLE_DOWN_LEFT: &str = "\u{E02A}"; pub const ARROW_CIRCLE_DOWN_RIGHT: &str = "\u{E02C}"; pub const ARROW_CIRCLE_LEFT: &str = "\u{E05A}"; pub const ARROW_CIRCLE_RIGHT: &str = "\u{E02E}"; pub const ARROW_CIRCLE_UP: &str = "\u{E030}"; pub const ARROW_CIRCLE_UP_LEFT: &str = "\u{E032}"; pub const ARROW_CIRCLE_UP_RIGHT: &str = "\u{E034}"; pub const ARROW_CLOCKWISE: &str = "\u{E036}"; pub const ARROW_COUNTER_CLOCKWISE: &str = "\u{E038}"; pub const ARROW_DOWN: &str = "\u{E03E}"; pub const ARROW_DOWN_LEFT: &str = "\u{E040}"; pub const ARROW_DOWN_RIGHT: &str = "\u{E042}"; pub const ARROW_ELBOW_DOWN_LEFT: &str = "\u{E044}"; pub const ARROW_ELBOW_DOWN_RIGHT: &str = "\u{E046}"; pub const ARROW_ELBOW_LEFT: &str = "\u{E048}"; pub const ARROW_ELBOW_LEFT_DOWN: &str = "\u{E04A}"; pub const ARROW_ELBOW_LEFT_UP: &str = "\u{E04C}"; pub const ARROW_ELBOW_RIGHT: &str = "\u{E04E}"; pub const ARROW_ELBOW_RIGHT_DOWN: &str = "\u{E050}"; pub const ARROW_ELBOW_RIGHT_UP: &str = "\u{E052}"; pub const ARROW_ELBOW_UP_LEFT: &str = "\u{E054}"; pub const ARROW_ELBOW_UP_RIGHT: &str = "\u{E056}"; pub const ARROW_FAT_DOWN: &str = "\u{E518}"; pub const ARROW_FAT_LEFT: &str = "\u{E51A}"; pub const ARROW_FAT_LINE_DOWN: &str = "\u{E51C}"; pub const ARROW_FAT_LINE_LEFT: &str = "\u{E51E}"; pub const ARROW_FAT_LINE_RIGHT: &str = "\u{E520}"; pub const ARROW_FAT_LINE_UP: &str = "\u{E522}"; pub const ARROW_FAT_LINES_DOWN: &str = "\u{E524}"; pub const ARROW_FAT_LINES_LEFT: &str = "\u{E526}"; pub const ARROW_FAT_LINES_RIGHT: &str = "\u{E528}"; pub const ARROW_FAT_LINES_UP: &str = "\u{E52A}"; pub const ARROW_FAT_RIGHT: &str = "\u{E52C}"; pub const ARROW_FAT_UP: &str = "\u{E52E}"; pub const ARROW_LEFT: &str = "\u{E058}"; pub const ARROW_LINE_DOWN: &str = "\u{E05C}"; pub const ARROW_LINE_DOWN_LEFT: &str = "\u{E05E}"; pub const ARROW_LINE_DOWN_RIGHT: &str = "\u{E060}"; pub const ARROW_LINE_LEFT: &str = "\u{E062}"; pub const ARROW_LINE_RIGHT: &str = "\u{E064}"; pub const ARROW_LINE_UP: &str = "\u{E066}"; pub const ARROW_LINE_UP_LEFT: &str = "\u{E068}"; pub const ARROW_LINE_UP_RIGHT: &str = "\u{E06A}"; pub const ARROW_RIGHT: &str = "\u{E06C}"; pub const ARROW_SQUARE_DOWN: &str = "\u{E06E}"; pub const ARROW_SQUARE_DOWN_LEFT: &str = "\u{E070}"; pub const ARROW_SQUARE_DOWN_RIGHT: &str = "\u{E072}"; pub const ARROW_SQUARE_IN: &str = "\u{E5DC}"; pub const ARROW_SQUARE_LEFT: &str = "\u{E074}"; pub const ARROW_SQUARE_OUT: &str = "\u{E5DE}"; pub const ARROW_SQUARE_RIGHT: &str = "\u{E076}"; pub const ARROW_SQUARE_UP: &str = "\u{E078}"; pub const ARROW_SQUARE_UP_LEFT: &str = "\u{E07A}"; pub const ARROW_SQUARE_UP_RIGHT: &str = "\u{E07C}"; pub const ARROW_U_DOWN_LEFT: &str = "\u{E07E}"; pub const ARROW_U_DOWN_RIGHT: &str = "\u{E080}"; pub const ARROW_U_LEFT_DOWN: &str = "\u{E082}"; pub const ARROW_U_LEFT_UP: &str = "\u{E084}"; pub const ARROW_U_RIGHT_DOWN: &str = "\u{E086}"; pub const ARROW_U_RIGHT_UP: &str = "\u{E088}"; pub const ARROW_U_UP_LEFT: &str = "\u{E08A}"; pub const ARROW_U_UP_RIGHT: &str = "\u{E08C}"; pub const ARROW_UP: &str = "\u{E08E}"; pub const ARROW_UP_LEFT: &str = "\u{E090}"; pub const ARROW_UP_RIGHT: &str = "\u{E092}"; pub const ARROWS_CLOCKWISE: &str = "\u{E094}"; pub const ARROWS_COUNTER_CLOCKWISE: &str = "\u{E096}"; pub const ARROWS_DOWN_UP: &str = "\u{E098}"; pub const ARROWS_HORIZONTAL: &str = "\u{EB06}"; pub const ARROWS_IN: &str = "\u{E09A}"; pub const ARROWS_IN_CARDINAL: &str = "\u{E09C}"; pub const ARROWS_IN_LINE_HORIZONTAL: &str = "\u{E530}"; pub const ARROWS_IN_LINE_VERTICAL: &str = "\u{E532}"; pub const ARROWS_IN_SIMPLE: &str = "\u{E09E}"; pub const ARROWS_LEFT_RIGHT: &str = "\u{E0A0}"; pub const ARROWS_MERGE: &str = "\u{ED3E}"; pub const ARROWS_OUT: &str = "\u{E0A2}"; pub const ARROWS_OUT_CARDINAL: &str = "\u{E0A4}"; pub const ARROWS_OUT_LINE_HORIZONTAL: &str = "\u{E534}"; pub const ARROWS_OUT_LINE_VERTICAL: &str = "\u{E536}"; pub const ARROWS_OUT_SIMPLE: &str = "\u{E0A6}"; pub const ARROWS_SPLIT: &str = "\u{ED3C}"; pub const ARROWS_VERTICAL: &str = "\u{EB04}"; pub const ARTICLE: &str = "\u{E0A8}"; pub const ARTICLE_MEDIUM: &str = "\u{E5E0}"; pub const ARTICLE_NY_TIMES: &str = "\u{E5E2}"; pub const ASCLEPIUS: &str = "\u{EE34}"; pub const CADUCEUS: &str = "\u{EE34}"; pub const ASTERISK: &str = "\u{E0AA}"; pub const ASTERISK_SIMPLE: &str = "\u{E832}"; pub const AT: &str = "\u{E0AC}"; pub const ATOM: &str = "\u{E5E4}"; pub const AVOCADO: &str = "\u{EE04}"; pub const AXE: &str = "\u{E9FC}"; pub const BABY: &str = "\u{E774}"; pub const BABY_CARRIAGE: &str = "\u{E818}"; pub const BACKPACK: &str = "\u{E922}"; pub const BACKSPACE: &str = "\u{E0AE}"; pub const BAG: &str = "\u{E0B0}"; pub const BAG_SIMPLE: &str = "\u{E5E6}"; pub const BALLOON: &str = "\u{E76C}"; pub const BANDAIDS: &str = "\u{E0B2}"; pub const BANK: &str = "\u{E0B4}"; pub const BARBELL: &str = "\u{E0B6}"; pub const BARCODE: &str = "\u{E0B8}"; pub const BARN: &str = "\u{EC72}"; pub const BARRICADE: &str = "\u{E948}"; pub const BASEBALL: &str = "\u{E71A}"; pub const BASEBALL_CAP: &str = "\u{EA28}"; pub const BASEBALL_HELMET: &str = "\u{EE4A}"; pub const BASKET: &str = "\u{E964}"; pub const BASKETBALL: &str = "\u{E724}"; pub const BATHTUB: &str = "\u{E81E}"; pub const BATTERY_CHARGING: &str = "\u{E0BA}"; pub const BATTERY_CHARGING_VERTICAL: &str = "\u{E0BC}"; pub const BATTERY_EMPTY: &str = "\u{E0BE}"; pub const BATTERY_FULL: &str = "\u{E0C0}"; pub const BATTERY_HIGH: &str = "\u{E0C2}"; pub const BATTERY_LOW: &str = "\u{E0C4}"; pub const BATTERY_MEDIUM: &str = "\u{E0C6}"; pub const BATTERY_PLUS: &str = "\u{E808}"; pub const BATTERY_PLUS_VERTICAL: &str = "\u{EC50}"; pub const BATTERY_VERTICAL_EMPTY: &str = "\u{E7C6}"; pub const BATTERY_VERTICAL_FULL: &str = "\u{E7C4}"; pub const BATTERY_VERTICAL_HIGH: &str = "\u{E7C2}"; pub const BATTERY_VERTICAL_LOW: &str = "\u{E7BE}"; pub const BATTERY_VERTICAL_MEDIUM: &str = "\u{E7C0}"; pub const BATTERY_WARNING: &str = "\u{E0C8}"; pub const BATTERY_WARNING_VERTICAL: &str = "\u{E0CA}"; pub const BEACH_BALL: &str = "\u{ED24}"; pub const BEANIE: &str = "\u{EA2A}"; pub const BED: &str = "\u{E0CC}"; pub const BEER_BOTTLE: &str = "\u{E7B0}"; pub const BEER_STEIN: &str = "\u{EB62}"; pub const BEHANCE_LOGO: &str = "\u{E7F4}"; pub const BELL: &str = "\u{E0CE}"; pub const BELL_RINGING: &str = "\u{E5E8}"; pub const BELL_SIMPLE: &str = "\u{E0D0}"; pub const BELL_SIMPLE_RINGING: &str = "\u{E5EA}"; pub const BELL_SIMPLE_SLASH: &str = "\u{E0D2}"; pub const BELL_SIMPLE_Z: &str = "\u{E5EC}"; pub const BELL_SLASH: &str = "\u{E0D4}"; pub const BELL_Z: &str = "\u{E5EE}"; pub const BELT: &str = "\u{EA2C}"; pub const BEZIER_CURVE: &str = "\u{EB00}"; pub const BICYCLE: &str = "\u{E0D6}"; pub const BINARY: &str = "\u{EE60}"; pub const BINOCULARS: &str = "\u{EA64}"; pub const BIOHAZARD: &str = "\u{E9E0}"; pub const BIRD: &str = "\u{E72C}"; pub const BLUEPRINT: &str = "\u{EDA0}"; pub const BLUETOOTH: &str = "\u{E0DA}"; pub const BLUETOOTH_CONNECTED: &str = "\u{E0DC}"; pub const BLUETOOTH_SLASH: &str = "\u{E0DE}"; pub const BLUETOOTH_X: &str = "\u{E0E0}"; pub const BOAT: &str = "\u{E786}"; pub const BOMB: &str = "\u{EE0A}"; pub const BONE: &str = "\u{E7F2}"; pub const BOOK: &str = "\u{E0E2}"; pub const BOOK_BOOKMARK: &str = "\u{E0E4}"; pub const BOOK_OPEN: &str = "\u{E0E6}"; pub const BOOK_OPEN_TEXT: &str = "\u{E8F2}"; pub const BOOK_OPEN_USER: &str = "\u{EDE0}"; pub const BOOKMARK: &str = "\u{E0E8}"; pub const BOOKMARK_SIMPLE: &str = "\u{E0EA}"; pub const BOOKMARKS: &str = "\u{E0EC}"; pub const BOOKMARKS_SIMPLE: &str = "\u{E5F0}"; pub const BOOKS: &str = "\u{E758}"; pub const BOOT: &str = "\u{ECCA}"; pub const BOULES: &str = "\u{E722}"; pub const BOUNDING_BOX: &str = "\u{E6CE}"; pub const BOWL_FOOD: &str = "\u{EAA4}"; pub const BOWL_STEAM: &str = "\u{E8E4}"; pub const BOWLING_BALL: &str = "\u{EA34}"; pub const BOX_ARROW_DOWN: &str = "\u{E00E}"; pub const ARCHIVE_BOX: &str = "\u{E00E}"; pub const BOX_ARROW_UP: &str = "\u{EE54}"; pub const BOXING_GLOVE: &str = "\u{EA36}"; pub const BRACKETS_ANGLE: &str = "\u{E862}"; pub const BRACKETS_CURLY: &str = "\u{E860}"; pub const BRACKETS_ROUND: &str = "\u{E864}"; pub const BRACKETS_SQUARE: &str = "\u{E85E}"; pub const BRAIN: &str = "\u{E74E}"; pub const BRANDY: &str = "\u{E6B4}"; pub const BREAD: &str = "\u{E81C}"; pub const BRIDGE: &str = "\u{EA68}"; pub const BRIEFCASE: &str = "\u{E0EE}"; pub const BRIEFCASE_METAL: &str = "\u{E5F2}"; pub const BROADCAST: &str = "\u{E0F2}"; pub const BROOM: &str = "\u{EC54}"; pub const BROWSER: &str = "\u{E0F4}"; pub const BROWSERS: &str = "\u{E0F6}"; pub const BUG: &str = "\u{E5F4}"; pub const BUG_BEETLE: &str = "\u{E5F6}"; pub const BUG_DROID: &str = "\u{E5F8}"; pub const BUILDING: &str = "\u{E100}"; pub const BUILDING_APARTMENT: &str = "\u{E0FE}"; pub const BUILDING_OFFICE: &str = "\u{E0FF}"; pub const BUILDINGS: &str = "\u{E102}"; pub const BULLDOZER: &str = "\u{EC6C}"; pub const BUS: &str = "\u{E106}"; pub const BUTTERFLY: &str = "\u{EA6E}"; pub const CABLE_CAR: &str = "\u{E49C}"; pub const CACTUS: &str = "\u{E918}"; pub const CAKE: &str = "\u{E780}"; pub const CALCULATOR: &str = "\u{E538}"; pub const CALENDAR: &str = "\u{E108}"; pub const CALENDAR_BLANK: &str = "\u{E10A}"; pub const CALENDAR_CHECK: &str = "\u{E712}"; pub const CALENDAR_DOT: &str = "\u{E7B2}"; pub const CALENDAR_DOTS: &str = "\u{E7B4}"; pub const CALENDAR_HEART: &str = "\u{E8B0}"; pub const CALENDAR_MINUS: &str = "\u{EA14}"; pub const CALENDAR_PLUS: &str = "\u{E714}"; pub const CALENDAR_SLASH: &str = "\u{EA12}"; pub const CALENDAR_STAR: &str = "\u{E8B2}"; pub const CALENDAR_X: &str = "\u{E10C}"; pub const CALL_BELL: &str = "\u{E7DE}"; pub const CAMERA: &str = "\u{E10E}"; pub const CAMERA_PLUS: &str = "\u{EC58}"; pub const CAMERA_ROTATE: &str = "\u{E7A4}"; pub const CAMERA_SLASH: &str = "\u{E110}"; pub const CAMPFIRE: &str = "\u{E9D8}"; pub const CAR: &str = "\u{E112}"; pub const CAR_BATTERY: &str = "\u{EE30}"; pub const CAR_PROFILE: &str = "\u{E8CC}"; pub const CAR_SIMPLE: &str = "\u{E114}"; pub const CARDHOLDER: &str = "\u{E5FA}"; pub const CARDS: &str = "\u{E0F8}"; pub const CARDS_THREE: &str = "\u{EE50}"; pub const CARET_CIRCLE_DOUBLE_DOWN: &str = "\u{E116}"; pub const CARET_CIRCLE_DOUBLE_LEFT: &str = "\u{E118}"; pub const CARET_CIRCLE_DOUBLE_RIGHT: &str = "\u{E11A}"; pub const CARET_CIRCLE_DOUBLE_UP: &str = "\u{E11C}"; pub const CARET_CIRCLE_DOWN: &str = "\u{E11E}"; pub const CARET_CIRCLE_LEFT: &str = "\u{E120}"; pub const CARET_CIRCLE_RIGHT: &str = "\u{E122}"; pub const CARET_CIRCLE_UP: &str = "\u{E124}"; pub const CARET_CIRCLE_UP_DOWN: &str = "\u{E13E}"; pub const CARET_DOUBLE_DOWN: &str = "\u{E126}"; pub const CARET_DOUBLE_LEFT: &str = "\u{E128}"; pub const CARET_DOUBLE_RIGHT: &str = "\u{E12A}"; pub const CARET_DOUBLE_UP: &str = "\u{E12C}"; pub const CARET_DOWN: &str = "\u{E136}"; pub const CARET_LEFT: &str = "\u{E138}"; pub const CARET_LINE_DOWN: &str = "\u{E134}"; pub const CARET_LINE_LEFT: &str = "\u{E132}"; pub const CARET_LINE_RIGHT: &str = "\u{E130}"; pub const CARET_LINE_UP: &str = "\u{E12E}"; pub const CARET_RIGHT: &str = "\u{E13A}"; pub const CARET_UP: &str = "\u{E13C}"; pub const CARET_UP_DOWN: &str = "\u{E140}"; pub const CARROT: &str = "\u{ED38}"; pub const CASH_REGISTER: &str = "\u{ED80}"; pub const CASSETTE_TAPE: &str = "\u{ED2E}"; pub const CASTLE_TURRET: &str = "\u{E9D0}"; pub const CAT: &str = "\u{E748}"; pub const CELL_SIGNAL_FULL: &str = "\u{E142}"; pub const CELL_SIGNAL_HIGH: &str = "\u{E144}"; pub const CELL_SIGNAL_LOW: &str = "\u{E146}"; pub const CELL_SIGNAL_MEDIUM: &str = "\u{E148}"; pub const CELL_SIGNAL_NONE: &str = "\u{E14A}"; pub const CELL_SIGNAL_SLASH: &str = "\u{E14C}"; pub const CELL_SIGNAL_X: &str = "\u{E14E}"; pub const CELL_TOWER: &str = "\u{EBAA}"; pub const CERTIFICATE: &str = "\u{E766}"; pub const CHAIR: &str = "\u{E950}"; pub const CHALKBOARD: &str = "\u{E5FC}"; pub const CHALKBOARD_SIMPLE: &str = "\u{E5FE}"; pub const CHALKBOARD_TEACHER: &str = "\u{E600}"; pub const CHAMPAGNE: &str = "\u{EACA}"; pub const CHARGING_STATION: &str = "\u{E8D0}"; pub const CHART_BAR: &str = "\u{E150}"; pub const CHART_BAR_HORIZONTAL: &str = "\u{E152}"; pub const CHART_DONUT: &str = "\u{EAA6}"; pub const CHART_LINE: &str = "\u{E154}"; pub const CHART_LINE_DOWN: &str = "\u{E8B6}"; pub const CHART_LINE_UP: &str = "\u{E156}"; pub const CHART_PIE: &str = "\u{E158}"; pub const CHART_PIE_SLICE: &str = "\u{E15A}"; pub const CHART_POLAR: &str = "\u{EAA8}"; pub const CHART_SCATTER: &str = "\u{EAAC}"; pub const CHAT: &str = "\u{E15C}"; pub const CHAT_CENTERED: &str = "\u{E160}"; pub const CHAT_CENTERED_DOTS: &str = "\u{E164}"; pub const CHAT_CENTERED_SLASH: &str = "\u{E162}"; pub const CHAT_CENTERED_TEXT: &str = "\u{E166}"; pub const CHAT_CIRCLE: &str = "\u{E168}"; pub const CHAT_CIRCLE_DOTS: &str = "\u{E16C}"; pub const CHAT_CIRCLE_SLASH: &str = "\u{E16A}"; pub const CHAT_CIRCLE_TEXT: &str = "\u{E16E}"; pub const CHAT_DOTS: &str = "\u{E170}"; pub const CHAT_SLASH: &str = "\u{E15E}"; pub const CHAT_TEARDROP: &str = "\u{E172}"; pub const CHAT_TEARDROP_DOTS: &str = "\u{E176}"; pub const CHAT_TEARDROP_SLASH: &str = "\u{E174}"; pub const CHAT_TEARDROP_TEXT: &str = "\u{E178}"; pub const CHAT_TEXT: &str = "\u{E17A}"; pub const CHATS: &str = "\u{E17C}"; pub const CHATS_CIRCLE: &str = "\u{E17E}"; pub const CHATS_TEARDROP: &str = "\u{E180}"; pub const CHECK: &str = "\u{E182}"; pub const CHECK_CIRCLE: &str = "\u{E184}"; pub const CHECK_FAT: &str = "\u{EBA6}"; pub const CHECK_SQUARE: &str = "\u{E186}"; pub const CHECK_SQUARE_OFFSET: &str = "\u{E188}"; pub const CHECKERBOARD: &str = "\u{E8C4}"; pub const CHECKS: &str = "\u{E53A}"; pub const CHEERS: &str = "\u{EA4A}"; pub const CHEESE: &str = "\u{E9FE}"; pub const CHEF_HAT: &str = "\u{ED8E}"; pub const CHERRIES: &str = "\u{E830}"; pub const CHURCH: &str = "\u{ECEA}"; pub const CIGARETTE: &str = "\u{ED90}"; pub const CIGARETTE_SLASH: &str = "\u{ED92}"; pub const CIRCLE: &str = "\u{E18A}"; pub const CIRCLE_DASHED: &str = "\u{E602}"; pub const CIRCLE_HALF: &str = "\u{E18C}"; pub const CIRCLE_HALF_TILT: &str = "\u{E18E}"; pub const CIRCLE_NOTCH: &str = "\u{EB44}"; pub const CIRCLES_FOUR: &str = "\u{E190}"; pub const CIRCLES_THREE: &str = "\u{E192}"; pub const CIRCLES_THREE_PLUS: &str = "\u{E194}"; pub const CIRCUITRY: &str = "\u{E9C2}"; pub const CITY: &str = "\u{EA6A}"; pub const CLIPBOARD: &str = "\u{E196}"; pub const CLIPBOARD_TEXT: &str = "\u{E198}"; pub const CLOCK: &str = "\u{E19A}"; pub const CLOCK_AFTERNOON: &str = "\u{E19C}"; pub const CLOCK_CLOCKWISE: &str = "\u{E19E}"; pub const CLOCK_COUNTDOWN: &str = "\u{ED2C}"; pub const CLOCK_COUNTER_CLOCKWISE: &str = "\u{E1A0}"; pub const CLOCK_USER: &str = "\u{EDEC}"; pub const CLOSED_CAPTIONING: &str = "\u{E1A4}"; pub const CLOUD: &str = "\u{E1AA}"; pub const CLOUD_ARROW_DOWN: &str = "\u{E1AC}"; pub const CLOUD_ARROW_UP: &str = "\u{E1AE}"; pub const CLOUD_CHECK: &str = "\u{E1B0}"; pub const CLOUD_FOG: &str = "\u{E53C}"; pub const CLOUD_LIGHTNING: &str = "\u{E1B2}"; pub const CLOUD_MOON: &str = "\u{E53E}"; pub const CLOUD_RAIN: &str = "\u{E1B4}"; pub const CLOUD_SLASH: &str = "\u{E1B6}"; pub const CLOUD_SNOW: &str = "\u{E1B8}"; pub const CLOUD_SUN: &str = "\u{E540}"; pub const CLOUD_WARNING: &str = "\u{EA98}"; pub const CLOUD_X: &str = "\u{EA96}"; pub const CLOVER: &str = "\u{EDC8}"; pub const CLUB: &str = "\u{E1BA}"; pub const COAT_HANGER: &str = "\u{E7FE}"; pub const CODA_LOGO: &str = "\u{E7CE}"; pub const CODE: &str = "\u{E1BC}"; pub const CODE_BLOCK: &str = "\u{EAFE}"; pub const CODE_SIMPLE: &str = "\u{E1BE}"; pub const CODEPEN_LOGO: &str = "\u{E978}"; pub const CODESANDBOX_LOGO: &str = "\u{EA06}"; pub const COFFEE: &str = "\u{E1C2}"; pub const COFFEE_BEAN: &str = "\u{E1C0}"; pub const COIN: &str = "\u{E60E}"; pub const COIN_VERTICAL: &str = "\u{EB48}"; pub const COINS: &str = "\u{E78E}"; pub const COLUMNS: &str = "\u{E546}"; pub const COLUMNS_PLUS_LEFT: &str = "\u{E544}"; pub const COLUMNS_PLUS_RIGHT: &str = "\u{E542}"; pub const COMMAND: &str = "\u{E1C4}"; pub const COMPASS: &str = "\u{E1C8}"; pub const COMPASS_ROSE: &str = "\u{E1C6}"; pub const COMPASS_TOOL: &str = "\u{EA0E}"; pub const COMPUTER_TOWER: &str = "\u{E548}"; pub const CONFETTI: &str = "\u{E81A}"; pub const CONTACTLESS_PAYMENT: &str = "\u{ED42}"; pub const CONTROL: &str = "\u{ECA6}"; pub const COOKIE: &str = "\u{E6CA}"; pub const COOKING_POT: &str = "\u{E764}"; pub const COPY: &str = "\u{E1CA}"; pub const COPY_SIMPLE: &str = "\u{E1CC}"; pub const COPYLEFT: &str = "\u{E86A}"; pub const COPYRIGHT: &str = "\u{E54A}"; pub const CORNERS_IN: &str = "\u{E1CE}"; pub const CORNERS_OUT: &str = "\u{E1D0}"; pub const COUCH: &str = "\u{E7F6}"; pub const COURT_BASKETBALL: &str = "\u{EE36}"; pub const COW: &str = "\u{EABE}"; pub const COWBOY_HAT: &str = "\u{ED12}"; pub const CPU: &str = "\u{E610}"; pub const CRANE: &str = "\u{ED48}"; pub const CRANE_TOWER: &str = "\u{ED49}"; pub const CREDIT_CARD: &str = "\u{E1D2}"; pub const CRICKET: &str = "\u{EE12}"; pub const CROP: &str = "\u{E1D4}"; pub const CROSS: &str = "\u{E8A0}"; pub const CROSSHAIR: &str = "\u{E1D6}"; pub const CROSSHAIR_SIMPLE: &str = "\u{E1D8}"; pub const CROWN: &str = "\u{E614}"; pub const CROWN_CROSS: &str = "\u{EE5E}"; pub const CROWN_SIMPLE: &str = "\u{E616}"; pub const CUBE: &str = "\u{E1DA}"; pub const CUBE_FOCUS: &str = "\u{ED0A}"; pub const CUBE_TRANSPARENT: &str = "\u{EC7C}"; pub const CURRENCY_BTC: &str = "\u{E618}"; pub const CURRENCY_CIRCLE_DOLLAR: &str = "\u{E54C}"; pub const CURRENCY_CNY: &str = "\u{E54E}"; pub const CURRENCY_DOLLAR: &str = "\u{E550}"; pub const CURRENCY_DOLLAR_SIMPLE: &str = "\u{E552}"; pub const CURRENCY_ETH: &str = "\u{EADA}"; pub const CURRENCY_EUR: &str = "\u{E554}"; pub const CURRENCY_GBP: &str = "\u{E556}"; pub const CURRENCY_INR: &str = "\u{E558}"; pub const CURRENCY_JPY: &str = "\u{E55A}"; pub const CURRENCY_KRW: &str = "\u{E55C}"; pub const CURRENCY_KZT: &str = "\u{EC4C}"; pub const CURRENCY_NGN: &str = "\u{EB52}"; pub const CURRENCY_RUB: &str = "\u{E55E}"; pub const CURSOR: &str = "\u{E1DC}"; pub const CURSOR_CLICK: &str = "\u{E7C8}"; pub const CURSOR_TEXT: &str = "\u{E7D8}"; pub const CYLINDER: &str = "\u{E8FC}"; pub const DATABASE: &str = "\u{E1DE}"; pub const DESK: &str = "\u{ED16}"; pub const DESKTOP: &str = "\u{E560}"; pub const DESKTOP_TOWER: &str = "\u{E562}"; pub const DETECTIVE: &str = "\u{E83E}"; pub const DEV_TO_LOGO: &str = "\u{ED0E}"; pub const DEVICE_MOBILE: &str = "\u{E1E0}"; pub const DEVICE_MOBILE_CAMERA: &str = "\u{E1E2}"; pub const DEVICE_MOBILE_SLASH: &str = "\u{EE46}"; pub const DEVICE_MOBILE_SPEAKER: &str = "\u{E1E4}"; pub const DEVICE_ROTATE: &str = "\u{EDF2}"; pub const DEVICE_TABLET: &str = "\u{E1E6}"; pub const DEVICE_TABLET_CAMERA: &str = "\u{E1E8}"; pub const DEVICE_TABLET_SPEAKER: &str = "\u{E1EA}"; pub const DEVICES: &str = "\u{EBA4}"; pub const DIAMOND: &str = "\u{E1EC}"; pub const DIAMONDS_FOUR: &str = "\u{E8F4}"; pub const DICE_FIVE: &str = "\u{E1EE}"; pub const DICE_FOUR: &str = "\u{E1F0}"; pub const DICE_ONE: &str = "\u{E1F2}"; pub const DICE_SIX: &str = "\u{E1F4}"; pub const DICE_THREE: &str = "\u{E1F6}"; pub const DICE_TWO: &str = "\u{E1F8}"; pub const DISC: &str = "\u{E564}"; pub const DISCO_BALL: &str = "\u{ED98}"; pub const DISCORD_LOGO: &str = "\u{E61A}"; pub const DIVIDE: &str = "\u{E1FA}"; pub const DNA: &str = "\u{E924}"; pub const DOG: &str = "\u{E74A}"; pub const DOOR: &str = "\u{E61C}"; pub const DOOR_OPEN: &str = "\u{E7E6}"; pub const DOT: &str = "\u{ECDE}"; pub const DOT_OUTLINE: &str = "\u{ECE0}"; pub const DOTS_NINE: &str = "\u{E1FC}"; pub const DOTS_SIX: &str = "\u{E794}"; pub const DOTS_SIX_VERTICAL: &str = "\u{EAE2}"; pub const DOTS_THREE: &str = "\u{E1FE}"; pub const DOTS_THREE_CIRCLE: &str = "\u{E200}"; pub const DOTS_THREE_CIRCLE_VERTICAL: &str = "\u{E202}"; pub const DOTS_THREE_OUTLINE: &str = "\u{E204}"; pub const DOTS_THREE_OUTLINE_VERTICAL: &str = "\u{E206}"; pub const DOTS_THREE_VERTICAL: &str = "\u{E208}"; pub const DOWNLOAD: &str = "\u{E20A}"; pub const DOWNLOAD_SIMPLE: &str = "\u{E20C}"; pub const DRESS: &str = "\u{EA7E}"; pub const DRESSER: &str = "\u{E94E}"; pub const DRIBBBLE_LOGO: &str = "\u{E20E}"; pub const DRONE: &str = "\u{ED74}"; pub const DROP: &str = "\u{E210}"; pub const DROP_HALF: &str = "\u{E566}"; pub const DROP_HALF_BOTTOM: &str = "\u{EB40}"; pub const DROP_SIMPLE: &str = "\u{EE32}"; pub const DROP_SLASH: &str = "\u{E954}"; pub const DROPBOX_LOGO: &str = "\u{E7D0}"; pub const EAR: &str = "\u{E70C}"; pub const EAR_SLASH: &str = "\u{E70E}"; pub const EGG: &str = "\u{E812}"; pub const EGG_CRACK: &str = "\u{EB64}"; pub const EJECT: &str = "\u{E212}"; pub const EJECT_SIMPLE: &str = "\u{E6AE}"; pub const ELEVATOR: &str = "\u{ECC0}"; pub const EMPTY: &str = "\u{EDBC}"; pub const ENGINE: &str = "\u{EA80}"; pub const ENVELOPE: &str = "\u{E214}"; pub const ENVELOPE_OPEN: &str = "\u{E216}"; pub const ENVELOPE_SIMPLE: &str = "\u{E218}"; pub const ENVELOPE_SIMPLE_OPEN: &str = "\u{E21A}"; pub const EQUALIZER: &str = "\u{EBBC}"; pub const EQUALS: &str = "\u{E21C}"; pub const ERASER: &str = "\u{E21E}"; pub const ESCALATOR_DOWN: &str = "\u{ECBA}"; pub const ESCALATOR_UP: &str = "\u{ECBC}"; pub const EXAM: &str = "\u{E742}"; pub const EXCLAMATION_MARK: &str = "\u{EE44}"; pub const EXCLUDE: &str = "\u{E882}"; pub const EXCLUDE_SQUARE: &str = "\u{E880}"; pub const EXPORT: &str = "\u{EAF0}"; pub const EYE: &str = "\u{E220}"; pub const EYE_CLOSED: &str = "\u{E222}"; pub const EYE_SLASH: &str = "\u{E224}"; pub const EYEDROPPER: &str = "\u{E568}"; pub const EYEDROPPER_SAMPLE: &str = "\u{EAC4}"; pub const EYEGLASSES: &str = "\u{E7BA}"; pub const EYES: &str = "\u{EE5C}"; pub const FACE_MASK: &str = "\u{E56A}"; pub const FACEBOOK_LOGO: &str = "\u{E226}"; pub const FACTORY: &str = "\u{E760}"; pub const FADERS: &str = "\u{E228}"; pub const FADERS_HORIZONTAL: &str = "\u{E22A}"; pub const FALLOUT_SHELTER: &str = "\u{E9DE}"; pub const FAN: &str = "\u{E9F2}"; pub const FARM: &str = "\u{EC70}"; pub const FAST_FORWARD: &str = "\u{E6A6}"; pub const FAST_FORWARD_CIRCLE: &str = "\u{E22C}"; pub const FEATHER: &str = "\u{E9C0}"; pub const FEDIVERSE_LOGO: &str = "\u{ED66}"; pub const FIGMA_LOGO: &str = "\u{E22E}"; pub const FILE: &str = "\u{E230}"; pub const FILE_ARCHIVE: &str = "\u{EB2A}"; pub const FILE_ARROW_DOWN: &str = "\u{E232}"; pub const FILE_ARROW_UP: &str = "\u{E61E}"; pub const FILE_AUDIO: &str = "\u{EA20}"; pub const FILE_C: &str = "\u{EB32}"; pub const FILE_C_SHARP: &str = "\u{EB30}"; pub const FILE_CLOUD: &str = "\u{E95E}"; pub const FILE_CODE: &str = "\u{E914}"; pub const FILE_CPP: &str = "\u{EB2E}"; pub const FILE_CSS: &str = "\u{EB34}"; pub const FILE_CSV: &str = "\u{EB1C}"; pub const FILE_DASHED: &str = "\u{E704}"; pub const FILE_DOTTED: &str = "\u{E704}"; pub const FILE_DOC: &str = "\u{EB1E}"; pub const FILE_HTML: &str = "\u{EB38}"; pub const FILE_IMAGE: &str = "\u{EA24}"; pub const FILE_INI: &str = "\u{EB33}"; pub const FILE_JPG: &str = "\u{EB1A}"; pub const FILE_JS: &str = "\u{EB24}"; pub const FILE_JSX: &str = "\u{EB3A}"; pub const FILE_LOCK: &str = "\u{E95C}"; pub const FILE_MAGNIFYING_GLASS: &str = "\u{E238}"; pub const FILE_SEARCH: &str = "\u{E238}"; pub const FILE_MD: &str = "\u{ED50}"; pub const FILE_MINUS: &str = "\u{E234}"; pub const FILE_PDF: &str = "\u{E702}"; pub const FILE_PLUS: &str = "\u{E236}"; pub const FILE_PNG: &str = "\u{EB18}"; pub const FILE_PPT: &str = "\u{EB20}"; pub const FILE_PY: &str = "\u{EB2C}"; pub const FILE_RS: &str = "\u{EB28}"; pub const FILE_SQL: &str = "\u{ED4E}"; pub const FILE_SVG: &str = "\u{ED08}"; pub const FILE_TEXT: &str = "\u{E23A}"; pub const FILE_TS: &str = "\u{EB26}"; pub const FILE_TSX: &str = "\u{EB3C}"; pub const FILE_TXT: &str = "\u{EB35}"; pub const FILE_VIDEO: &str = "\u{EA22}"; pub const FILE_VUE: &str = "\u{EB3E}"; pub const FILE_X: &str = "\u{E23C}"; pub const FILE_XLS: &str = "\u{EB22}"; pub const FILE_ZIP: &str = "\u{E958}"; pub const FILES: &str = "\u{E710}"; pub const FILM_REEL: &str = "\u{E8C0}"; pub const FILM_SCRIPT: &str = "\u{EB50}"; pub const FILM_SLATE: &str = "\u{E8C2}"; pub const FILM_STRIP: &str = "\u{E792}"; pub const FINGERPRINT: &str = "\u{E23E}"; pub const FINGERPRINT_SIMPLE: &str = "\u{E240}"; pub const FINN_THE_HUMAN: &str = "\u{E56C}"; pub const FIRE: &str = "\u{E242}"; pub const FIRE_EXTINGUISHER: &str = "\u{E9E8}"; pub const FIRE_SIMPLE: &str = "\u{E620}"; pub const FIRE_TRUCK: &str = "\u{E574}"; pub const FIRST_AID: &str = "\u{E56E}"; pub const FIRST_AID_KIT: &str = "\u{E570}"; pub const FISH: &str = "\u{E728}"; pub const FISH_SIMPLE: &str = "\u{E72A}"; pub const FLAG: &str = "\u{E244}"; pub const FLAG_BANNER: &str = "\u{E622}"; pub const FLAG_BANNER_FOLD: &str = "\u{ECF2}"; pub const FLAG_CHECKERED: &str = "\u{EA38}"; pub const FLAG_PENNANT: &str = "\u{ECF0}"; pub const FLAME: &str = "\u{E624}"; pub const FLASHLIGHT: &str = "\u{E246}"; pub const FLASK: &str = "\u{E79E}"; pub const FLIP_HORIZONTAL: &str = "\u{ED6A}"; pub const FLIP_VERTICAL: &str = "\u{ED6C}"; pub const FLOPPY_DISK: &str = "\u{E248}"; pub const FLOPPY_DISK_BACK: &str = "\u{EAF4}"; pub const FLOW_ARROW: &str = "\u{E6EC}"; pub const FLOWER: &str = "\u{E75E}"; pub const FLOWER_LOTUS: &str = "\u{E6CC}"; pub const FLOWER_TULIP: &str = "\u{EACC}"; pub const FLYING_SAUCER: &str = "\u{EB4A}"; pub const FOLDER: &str = "\u{E24A}"; pub const FOLDER_NOTCH: &str = "\u{E24A}"; pub const FOLDER_DASHED: &str = "\u{E8F8}"; pub const FOLDER_DOTTED: &str = "\u{E8F8}"; pub const FOLDER_LOCK: &str = "\u{EA3C}"; pub const FOLDER_MINUS: &str = "\u{E254}"; pub const FOLDER_NOTCH_MINUS: &str = "\u{E254}"; pub const FOLDER_OPEN: &str = "\u{E256}"; pub const FOLDER_NOTCH_OPEN: &str = "\u{E256}"; pub const FOLDER_PLUS: &str = "\u{E258}"; pub const FOLDER_NOTCH_PLUS: &str = "\u{E258}"; pub const FOLDER_SIMPLE: &str = "\u{E25A}"; pub const FOLDER_SIMPLE_DASHED: &str = "\u{EC2A}"; pub const FOLDER_SIMPLE_DOTTED: &str = "\u{EC2A}"; pub const FOLDER_SIMPLE_LOCK: &str = "\u{EB5E}"; pub const FOLDER_SIMPLE_MINUS: &str = "\u{E25C}"; pub const FOLDER_SIMPLE_PLUS: &str = "\u{E25E}"; pub const FOLDER_SIMPLE_STAR: &str = "\u{EC2E}"; pub const FOLDER_SIMPLE_USER: &str = "\u{EB60}"; pub const FOLDER_STAR: &str = "\u{EA86}"; pub const FOLDER_USER: &str = "\u{EB46}"; pub const FOLDERS: &str = "\u{E260}"; pub const FOOTBALL: &str = "\u{E718}"; pub const FOOTBALL_HELMET: &str = "\u{EE4C}"; pub const FOOTPRINTS: &str = "\u{EA88}"; pub const FORK_KNIFE: &str = "\u{E262}"; pub const FOUR_K: &str = "\u{EA5C}"; pub const FRAME_CORNERS: &str = "\u{E626}"; pub const FRAMER_LOGO: &str = "\u{E264}"; pub const FUNCTION: &str = "\u{EBE4}"; pub const FUNNEL: &str = "\u{E266}"; pub const FUNNEL_SIMPLE: &str = "\u{E268}"; pub const FUNNEL_SIMPLE_X: &str = "\u{E26A}"; pub const FUNNEL_X: &str = "\u{E26C}"; pub const GAME_CONTROLLER: &str = "\u{E26E}"; pub const GARAGE: &str = "\u{ECD6}"; pub const GAS_CAN: &str = "\u{E8CE}"; pub const GAS_PUMP: &str = "\u{E768}"; pub const GAUGE: &str = "\u{E628}"; pub const GAVEL: &str = "\u{EA32}"; pub const GEAR: &str = "\u{E270}"; pub const GEAR_FINE: &str = "\u{E87C}"; pub const GEAR_SIX: &str = "\u{E272}"; pub const GENDER_FEMALE: &str = "\u{E6E0}"; pub const GENDER_INTERSEX: &str = "\u{E6E6}"; pub const GENDER_MALE: &str = "\u{E6E2}"; pub const GENDER_NEUTER: &str = "\u{E6EA}"; pub const GENDER_NONBINARY: &str = "\u{E6E4}"; pub const GENDER_TRANSGENDER: &str = "\u{E6E8}"; pub const GHOST: &str = "\u{E62A}"; pub const GIF: &str = "\u{E274}"; pub const GIFT: &str = "\u{E276}"; pub const GIT_BRANCH: &str = "\u{E278}"; pub const GIT_COMMIT: &str = "\u{E27A}"; pub const GIT_DIFF: &str = "\u{E27C}"; pub const GIT_FORK: &str = "\u{E27E}"; pub const GIT_MERGE: &str = "\u{E280}"; pub const GIT_PULL_REQUEST: &str = "\u{E282}"; pub const GITHUB_LOGO: &str = "\u{E576}"; pub const GITLAB_LOGO: &str = "\u{E694}"; pub const GITLAB_LOGO_SIMPLE: &str = "\u{E696}"; pub const GLOBE: &str = "\u{E288}"; pub const GLOBE_HEMISPHERE_EAST: &str = "\u{E28A}"; pub const GLOBE_HEMISPHERE_WEST: &str = "\u{E28C}"; pub const GLOBE_SIMPLE: &str = "\u{E28E}"; pub const GLOBE_SIMPLE_X: &str = "\u{E284}"; pub const GLOBE_STAND: &str = "\u{E290}"; pub const GLOBE_X: &str = "\u{E286}"; pub const GOGGLES: &str = "\u{ECB4}"; pub const GOLF: &str = "\u{EA3E}"; pub const GOODREADS_LOGO: &str = "\u{ED10}"; pub const GOOGLE_CARDBOARD_LOGO: &str = "\u{E7B6}"; pub const GOOGLE_CHROME_LOGO: &str = "\u{E976}"; pub const GOOGLE_DRIVE_LOGO: &str = "\u{E8F6}"; pub const GOOGLE_LOGO: &str = "\u{E292}"; pub const GOOGLE_PHOTOS_LOGO: &str = "\u{EB92}"; pub const GOOGLE_PLAY_LOGO: &str = "\u{E294}"; pub const GOOGLE_PODCASTS_LOGO: &str = "\u{EB94}"; pub const GPS: &str = "\u{EDD8}"; pub const GPS_FIX: &str = "\u{EDD6}"; pub const GPS_SLASH: &str = "\u{EDD4}"; pub const GRADIENT: &str = "\u{EB42}"; pub const GRADUATION_CAP: &str = "\u{E62C}"; pub const GRAINS: &str = "\u{EC68}"; pub const GRAINS_SLASH: &str = "\u{EC6A}"; pub const GRAPH: &str = "\u{EB58}"; pub const GRAPHICS_CARD: &str = "\u{E612}"; pub const GREATER_THAN: &str = "\u{EDC4}"; pub const GREATER_THAN_OR_EQUAL: &str = "\u{EDA2}"; pub const GRID_FOUR: &str = "\u{E296}"; pub const GRID_NINE: &str = "\u{EC8C}"; pub const GUITAR: &str = "\u{EA8A}"; pub const HAIR_DRYER: &str = "\u{EA66}"; pub const HAMBURGER: &str = "\u{E790}"; pub const HAMMER: &str = "\u{E80E}"; pub const HAND: &str = "\u{E298}"; pub const HAND_ARROW_DOWN: &str = "\u{EA4E}"; pub const HAND_ARROW_UP: &str = "\u{EE5A}"; pub const HAND_COINS: &str = "\u{EA8C}"; pub const HAND_DEPOSIT: &str = "\u{EE82}"; pub const HAND_EYE: &str = "\u{EA4C}"; pub const HAND_FIST: &str = "\u{E57A}"; pub const HAND_GRABBING: &str = "\u{E57C}"; pub const HAND_HEART: &str = "\u{E810}"; pub const HAND_PALM: &str = "\u{E57E}"; pub const HAND_PEACE: &str = "\u{E7CC}"; pub const HAND_POINTING: &str = "\u{E29A}"; pub const HAND_SOAP: &str = "\u{E630}"; pub const HAND_SWIPE_LEFT: &str = "\u{EC94}"; pub const HAND_SWIPE_RIGHT: &str = "\u{EC92}"; pub const HAND_TAP: &str = "\u{EC90}"; pub const HAND_WAVING: &str = "\u{E580}"; pub const HAND_WITHDRAW: &str = "\u{EE80}"; pub const HANDBAG: &str = "\u{E29C}"; pub const HANDBAG_SIMPLE: &str = "\u{E62E}"; pub const HANDS_CLAPPING: &str = "\u{E6A0}"; pub const HANDS_PRAYING: &str = "\u{ECC8}"; pub const HANDSHAKE: &str = "\u{E582}"; pub const HARD_DRIVE: &str = "\u{E29E}"; pub const HARD_DRIVES: &str = "\u{E2A0}";
rust
Apache-2.0
c33b60c40f703ffa3d40d252f1bc911cf531581d
2026-01-04T20:22:14.235772Z
true
amPerl/egui-phosphor
https://github.com/amPerl/egui-phosphor/blob/c33b60c40f703ffa3d40d252f1bc911cf531581d/src/variants/mod.rs
src/variants/mod.rs
#[cfg(feature = "bold")] pub mod bold; #[cfg(feature = "fill")] pub mod fill; #[cfg(feature = "light")] pub mod light; #[cfg(feature = "regular")] pub mod regular; #[cfg(feature = "thin")] pub mod thin; #[cfg(not(any( feature = "thin", feature = "light", feature = "regular", feature = "bold", feature = "fill", )))] compile_error!( "At least one font variant must be selected as a crate feature. When in doubt, use default features." ); #[derive(Debug, Clone, Copy)] pub enum Variant { #[cfg(feature = "thin")] Thin, #[cfg(feature = "light")] Light, #[cfg(feature = "regular")] Regular, #[cfg(feature = "bold")] Bold, #[cfg(feature = "fill")] Fill, } impl Variant { pub fn font_bytes(&self) -> &'static [u8] { match self { #[cfg(feature = "thin")] Variant::Thin => &*include_bytes!("../../res/Phosphor-Thin.ttf"), #[cfg(feature = "light")] Variant::Light => &*include_bytes!("../../res/Phosphor-Light.ttf"), #[cfg(feature = "regular")] Variant::Regular => &*include_bytes!("../../res/Phosphor.ttf"), #[cfg(feature = "bold")] Variant::Bold => &*include_bytes!("../../res/Phosphor-Bold.ttf"), #[cfg(feature = "fill")] Variant::Fill => &*include_bytes!("../../res/Phosphor-Fill.ttf"), } } pub fn font_data(&self) -> egui::FontData { egui::FontData::from_static(self.font_bytes()) } }
rust
Apache-2.0
c33b60c40f703ffa3d40d252f1bc911cf531581d
2026-01-04T20:22:14.235772Z
false
amPerl/egui-phosphor
https://github.com/amPerl/egui-phosphor/blob/c33b60c40f703ffa3d40d252f1bc911cf531581d/src/variants/thin.rs
src/variants/thin.rs
#![allow(unused)] pub const ACORN: &str = "\u{EB9A}"; pub const ADDRESS_BOOK: &str = "\u{E6F8}"; pub const ADDRESS_BOOK_TABS: &str = "\u{EE4E}"; pub const AIR_TRAFFIC_CONTROL: &str = "\u{ECD8}"; pub const AIRPLANE: &str = "\u{E002}"; pub const AIRPLANE_IN_FLIGHT: &str = "\u{E4FE}"; pub const AIRPLANE_LANDING: &str = "\u{E502}"; pub const AIRPLANE_TAKEOFF: &str = "\u{E504}"; pub const AIRPLANE_TAXIING: &str = "\u{E500}"; pub const AIRPLANE_TILT: &str = "\u{E5D6}"; pub const AIRPLAY: &str = "\u{E004}"; pub const ALARM: &str = "\u{E006}"; pub const ALIEN: &str = "\u{E8A6}"; pub const ALIGN_BOTTOM: &str = "\u{E506}"; pub const ALIGN_BOTTOM_SIMPLE: &str = "\u{EB0C}"; pub const ALIGN_CENTER_HORIZONTAL: &str = "\u{E50A}"; pub const ALIGN_CENTER_HORIZONTAL_SIMPLE: &str = "\u{EB0E}"; pub const ALIGN_CENTER_VERTICAL: &str = "\u{E50C}"; pub const ALIGN_CENTER_VERTICAL_SIMPLE: &str = "\u{EB10}"; pub const ALIGN_LEFT: &str = "\u{E50E}"; pub const ALIGN_LEFT_SIMPLE: &str = "\u{EAEE}"; pub const ALIGN_RIGHT: &str = "\u{E510}"; pub const ALIGN_RIGHT_SIMPLE: &str = "\u{EB12}"; pub const ALIGN_TOP: &str = "\u{E512}"; pub const ALIGN_TOP_SIMPLE: &str = "\u{EB14}"; pub const AMAZON_LOGO: &str = "\u{E96C}"; pub const AMBULANCE: &str = "\u{E572}"; pub const ANCHOR: &str = "\u{E514}"; pub const ANCHOR_SIMPLE: &str = "\u{E5D8}"; pub const ANDROID_LOGO: &str = "\u{E008}"; pub const ANGLE: &str = "\u{E7BC}"; pub const ANGULAR_LOGO: &str = "\u{EB80}"; pub const APERTURE: &str = "\u{E00A}"; pub const APP_STORE_LOGO: &str = "\u{E974}"; pub const APP_WINDOW: &str = "\u{E5DA}"; pub const APPLE_LOGO: &str = "\u{E516}"; pub const APPLE_PODCASTS_LOGO: &str = "\u{EB96}"; pub const APPROXIMATE_EQUALS: &str = "\u{EDAA}"; pub const ARCHIVE: &str = "\u{E00C}"; pub const ARMCHAIR: &str = "\u{E012}"; pub const ARROW_ARC_LEFT: &str = "\u{E014}"; pub const ARROW_ARC_RIGHT: &str = "\u{E016}"; pub const ARROW_BEND_DOUBLE_UP_LEFT: &str = "\u{E03A}"; pub const ARROW_BEND_DOUBLE_UP_RIGHT: &str = "\u{E03C}"; pub const ARROW_BEND_DOWN_LEFT: &str = "\u{E018}"; pub const ARROW_BEND_DOWN_RIGHT: &str = "\u{E01A}"; pub const ARROW_BEND_LEFT_DOWN: &str = "\u{E01C}"; pub const ARROW_BEND_LEFT_UP: &str = "\u{E01E}"; pub const ARROW_BEND_RIGHT_DOWN: &str = "\u{E020}"; pub const ARROW_BEND_RIGHT_UP: &str = "\u{E022}"; pub const ARROW_BEND_UP_LEFT: &str = "\u{E024}"; pub const ARROW_BEND_UP_RIGHT: &str = "\u{E026}"; pub const ARROW_CIRCLE_DOWN: &str = "\u{E028}"; pub const ARROW_CIRCLE_DOWN_LEFT: &str = "\u{E02A}"; pub const ARROW_CIRCLE_DOWN_RIGHT: &str = "\u{E02C}"; pub const ARROW_CIRCLE_LEFT: &str = "\u{E05A}"; pub const ARROW_CIRCLE_RIGHT: &str = "\u{E02E}"; pub const ARROW_CIRCLE_UP: &str = "\u{E030}"; pub const ARROW_CIRCLE_UP_LEFT: &str = "\u{E032}"; pub const ARROW_CIRCLE_UP_RIGHT: &str = "\u{E034}"; pub const ARROW_CLOCKWISE: &str = "\u{E036}"; pub const ARROW_COUNTER_CLOCKWISE: &str = "\u{E038}"; pub const ARROW_DOWN: &str = "\u{E03E}"; pub const ARROW_DOWN_LEFT: &str = "\u{E040}"; pub const ARROW_DOWN_RIGHT: &str = "\u{E042}"; pub const ARROW_ELBOW_DOWN_LEFT: &str = "\u{E044}"; pub const ARROW_ELBOW_DOWN_RIGHT: &str = "\u{E046}"; pub const ARROW_ELBOW_LEFT: &str = "\u{E048}"; pub const ARROW_ELBOW_LEFT_DOWN: &str = "\u{E04A}"; pub const ARROW_ELBOW_LEFT_UP: &str = "\u{E04C}"; pub const ARROW_ELBOW_RIGHT: &str = "\u{E04E}"; pub const ARROW_ELBOW_RIGHT_DOWN: &str = "\u{E050}"; pub const ARROW_ELBOW_RIGHT_UP: &str = "\u{E052}"; pub const ARROW_ELBOW_UP_LEFT: &str = "\u{E054}"; pub const ARROW_ELBOW_UP_RIGHT: &str = "\u{E056}"; pub const ARROW_FAT_DOWN: &str = "\u{E518}"; pub const ARROW_FAT_LEFT: &str = "\u{E51A}"; pub const ARROW_FAT_LINE_DOWN: &str = "\u{E51C}"; pub const ARROW_FAT_LINE_LEFT: &str = "\u{E51E}"; pub const ARROW_FAT_LINE_RIGHT: &str = "\u{E520}"; pub const ARROW_FAT_LINE_UP: &str = "\u{E522}"; pub const ARROW_FAT_LINES_DOWN: &str = "\u{E524}"; pub const ARROW_FAT_LINES_LEFT: &str = "\u{E526}"; pub const ARROW_FAT_LINES_RIGHT: &str = "\u{E528}"; pub const ARROW_FAT_LINES_UP: &str = "\u{E52A}"; pub const ARROW_FAT_RIGHT: &str = "\u{E52C}"; pub const ARROW_FAT_UP: &str = "\u{E52E}"; pub const ARROW_LEFT: &str = "\u{E058}"; pub const ARROW_LINE_DOWN: &str = "\u{E05C}"; pub const ARROW_LINE_DOWN_LEFT: &str = "\u{E05E}"; pub const ARROW_LINE_DOWN_RIGHT: &str = "\u{E060}"; pub const ARROW_LINE_LEFT: &str = "\u{E062}"; pub const ARROW_LINE_RIGHT: &str = "\u{E064}"; pub const ARROW_LINE_UP: &str = "\u{E066}"; pub const ARROW_LINE_UP_LEFT: &str = "\u{E068}"; pub const ARROW_LINE_UP_RIGHT: &str = "\u{E06A}"; pub const ARROW_RIGHT: &str = "\u{E06C}"; pub const ARROW_SQUARE_DOWN: &str = "\u{E06E}"; pub const ARROW_SQUARE_DOWN_LEFT: &str = "\u{E070}"; pub const ARROW_SQUARE_DOWN_RIGHT: &str = "\u{E072}"; pub const ARROW_SQUARE_IN: &str = "\u{E5DC}"; pub const ARROW_SQUARE_LEFT: &str = "\u{E074}"; pub const ARROW_SQUARE_OUT: &str = "\u{E5DE}"; pub const ARROW_SQUARE_RIGHT: &str = "\u{E076}"; pub const ARROW_SQUARE_UP: &str = "\u{E078}"; pub const ARROW_SQUARE_UP_LEFT: &str = "\u{E07A}"; pub const ARROW_SQUARE_UP_RIGHT: &str = "\u{E07C}"; pub const ARROW_U_DOWN_LEFT: &str = "\u{E07E}"; pub const ARROW_U_DOWN_RIGHT: &str = "\u{E080}"; pub const ARROW_U_LEFT_DOWN: &str = "\u{E082}"; pub const ARROW_U_LEFT_UP: &str = "\u{E084}"; pub const ARROW_U_RIGHT_DOWN: &str = "\u{E086}"; pub const ARROW_U_RIGHT_UP: &str = "\u{E088}"; pub const ARROW_U_UP_LEFT: &str = "\u{E08A}"; pub const ARROW_U_UP_RIGHT: &str = "\u{E08C}"; pub const ARROW_UP: &str = "\u{E08E}"; pub const ARROW_UP_LEFT: &str = "\u{E090}"; pub const ARROW_UP_RIGHT: &str = "\u{E092}"; pub const ARROWS_CLOCKWISE: &str = "\u{E094}"; pub const ARROWS_COUNTER_CLOCKWISE: &str = "\u{E096}"; pub const ARROWS_DOWN_UP: &str = "\u{E098}"; pub const ARROWS_HORIZONTAL: &str = "\u{EB06}"; pub const ARROWS_IN: &str = "\u{E09A}"; pub const ARROWS_IN_CARDINAL: &str = "\u{E09C}"; pub const ARROWS_IN_LINE_HORIZONTAL: &str = "\u{E530}"; pub const ARROWS_IN_LINE_VERTICAL: &str = "\u{E532}"; pub const ARROWS_IN_SIMPLE: &str = "\u{E09E}"; pub const ARROWS_LEFT_RIGHT: &str = "\u{E0A0}"; pub const ARROWS_MERGE: &str = "\u{ED3E}"; pub const ARROWS_OUT: &str = "\u{E0A2}"; pub const ARROWS_OUT_CARDINAL: &str = "\u{E0A4}"; pub const ARROWS_OUT_LINE_HORIZONTAL: &str = "\u{E534}"; pub const ARROWS_OUT_LINE_VERTICAL: &str = "\u{E536}"; pub const ARROWS_OUT_SIMPLE: &str = "\u{E0A6}"; pub const ARROWS_SPLIT: &str = "\u{ED3C}"; pub const ARROWS_VERTICAL: &str = "\u{EB04}"; pub const ARTICLE: &str = "\u{E0A8}"; pub const ARTICLE_MEDIUM: &str = "\u{E5E0}"; pub const ARTICLE_NY_TIMES: &str = "\u{E5E2}"; pub const ASCLEPIUS: &str = "\u{EE34}"; pub const CADUCEUS: &str = "\u{EE34}"; pub const ASTERISK: &str = "\u{E0AA}"; pub const ASTERISK_SIMPLE: &str = "\u{E832}"; pub const AT: &str = "\u{E0AC}"; pub const ATOM: &str = "\u{E5E4}"; pub const AVOCADO: &str = "\u{EE04}"; pub const AXE: &str = "\u{E9FC}"; pub const BABY: &str = "\u{E774}"; pub const BABY_CARRIAGE: &str = "\u{E818}"; pub const BACKPACK: &str = "\u{E922}"; pub const BACKSPACE: &str = "\u{E0AE}"; pub const BAG: &str = "\u{E0B0}"; pub const BAG_SIMPLE: &str = "\u{E5E6}"; pub const BALLOON: &str = "\u{E76C}"; pub const BANDAIDS: &str = "\u{E0B2}"; pub const BANK: &str = "\u{E0B4}"; pub const BARBELL: &str = "\u{E0B6}"; pub const BARCODE: &str = "\u{E0B8}"; pub const BARN: &str = "\u{EC72}"; pub const BARRICADE: &str = "\u{E948}"; pub const BASEBALL: &str = "\u{E71A}"; pub const BASEBALL_CAP: &str = "\u{EA28}"; pub const BASEBALL_HELMET: &str = "\u{EE4A}"; pub const BASKET: &str = "\u{E964}"; pub const BASKETBALL: &str = "\u{E724}"; pub const BATHTUB: &str = "\u{E81E}"; pub const BATTERY_CHARGING: &str = "\u{E0BA}"; pub const BATTERY_CHARGING_VERTICAL: &str = "\u{E0BC}"; pub const BATTERY_EMPTY: &str = "\u{E0BE}"; pub const BATTERY_FULL: &str = "\u{E0C0}"; pub const BATTERY_HIGH: &str = "\u{E0C2}"; pub const BATTERY_LOW: &str = "\u{E0C4}"; pub const BATTERY_MEDIUM: &str = "\u{E0C6}"; pub const BATTERY_PLUS: &str = "\u{E808}"; pub const BATTERY_PLUS_VERTICAL: &str = "\u{EC50}"; pub const BATTERY_VERTICAL_EMPTY: &str = "\u{E7C6}"; pub const BATTERY_VERTICAL_FULL: &str = "\u{E7C4}"; pub const BATTERY_VERTICAL_HIGH: &str = "\u{E7C2}"; pub const BATTERY_VERTICAL_LOW: &str = "\u{E7BE}"; pub const BATTERY_VERTICAL_MEDIUM: &str = "\u{E7C0}"; pub const BATTERY_WARNING: &str = "\u{E0C8}"; pub const BATTERY_WARNING_VERTICAL: &str = "\u{E0CA}"; pub const BEACH_BALL: &str = "\u{ED24}"; pub const BEANIE: &str = "\u{EA2A}"; pub const BED: &str = "\u{E0CC}"; pub const BEER_BOTTLE: &str = "\u{E7B0}"; pub const BEER_STEIN: &str = "\u{EB62}"; pub const BEHANCE_LOGO: &str = "\u{E7F4}"; pub const BELL: &str = "\u{E0CE}"; pub const BELL_RINGING: &str = "\u{E5E8}"; pub const BELL_SIMPLE: &str = "\u{E0D0}"; pub const BELL_SIMPLE_RINGING: &str = "\u{E5EA}"; pub const BELL_SIMPLE_SLASH: &str = "\u{E0D2}"; pub const BELL_SIMPLE_Z: &str = "\u{E5EC}"; pub const BELL_SLASH: &str = "\u{E0D4}"; pub const BELL_Z: &str = "\u{E5EE}"; pub const BELT: &str = "\u{EA2C}"; pub const BEZIER_CURVE: &str = "\u{EB00}"; pub const BICYCLE: &str = "\u{E0D6}"; pub const BINARY: &str = "\u{EE60}"; pub const BINOCULARS: &str = "\u{EA64}"; pub const BIOHAZARD: &str = "\u{E9E0}"; pub const BIRD: &str = "\u{E72C}"; pub const BLUEPRINT: &str = "\u{EDA0}"; pub const BLUETOOTH: &str = "\u{E0DA}"; pub const BLUETOOTH_CONNECTED: &str = "\u{E0DC}"; pub const BLUETOOTH_SLASH: &str = "\u{E0DE}"; pub const BLUETOOTH_X: &str = "\u{E0E0}"; pub const BOAT: &str = "\u{E786}"; pub const BOMB: &str = "\u{EE0A}"; pub const BONE: &str = "\u{E7F2}"; pub const BOOK: &str = "\u{E0E2}"; pub const BOOK_BOOKMARK: &str = "\u{E0E4}"; pub const BOOK_OPEN: &str = "\u{E0E6}"; pub const BOOK_OPEN_TEXT: &str = "\u{E8F2}"; pub const BOOK_OPEN_USER: &str = "\u{EDE0}"; pub const BOOKMARK: &str = "\u{E0E8}"; pub const BOOKMARK_SIMPLE: &str = "\u{E0EA}"; pub const BOOKMARKS: &str = "\u{E0EC}"; pub const BOOKMARKS_SIMPLE: &str = "\u{E5F0}"; pub const BOOKS: &str = "\u{E758}"; pub const BOOT: &str = "\u{ECCA}"; pub const BOULES: &str = "\u{E722}"; pub const BOUNDING_BOX: &str = "\u{E6CE}"; pub const BOWL_FOOD: &str = "\u{EAA4}"; pub const BOWL_STEAM: &str = "\u{E8E4}"; pub const BOWLING_BALL: &str = "\u{EA34}"; pub const BOX_ARROW_DOWN: &str = "\u{E00E}"; pub const ARCHIVE_BOX: &str = "\u{E00E}"; pub const BOX_ARROW_UP: &str = "\u{EE54}"; pub const BOXING_GLOVE: &str = "\u{EA36}"; pub const BRACKETS_ANGLE: &str = "\u{E862}"; pub const BRACKETS_CURLY: &str = "\u{E860}"; pub const BRACKETS_ROUND: &str = "\u{E864}"; pub const BRACKETS_SQUARE: &str = "\u{E85E}"; pub const BRAIN: &str = "\u{E74E}"; pub const BRANDY: &str = "\u{E6B4}"; pub const BREAD: &str = "\u{E81C}"; pub const BRIDGE: &str = "\u{EA68}"; pub const BRIEFCASE: &str = "\u{E0EE}"; pub const BRIEFCASE_METAL: &str = "\u{E5F2}"; pub const BROADCAST: &str = "\u{E0F2}"; pub const BROOM: &str = "\u{EC54}"; pub const BROWSER: &str = "\u{E0F4}"; pub const BROWSERS: &str = "\u{E0F6}"; pub const BUG: &str = "\u{E5F4}"; pub const BUG_BEETLE: &str = "\u{E5F6}"; pub const BUG_DROID: &str = "\u{E5F8}"; pub const BUILDING: &str = "\u{E100}"; pub const BUILDING_APARTMENT: &str = "\u{E0FE}"; pub const BUILDING_OFFICE: &str = "\u{E0FF}"; pub const BUILDINGS: &str = "\u{E102}"; pub const BULLDOZER: &str = "\u{EC6C}"; pub const BUS: &str = "\u{E106}"; pub const BUTTERFLY: &str = "\u{EA6E}"; pub const CABLE_CAR: &str = "\u{E49C}"; pub const CACTUS: &str = "\u{E918}"; pub const CAKE: &str = "\u{E780}"; pub const CALCULATOR: &str = "\u{E538}"; pub const CALENDAR: &str = "\u{E108}"; pub const CALENDAR_BLANK: &str = "\u{E10A}"; pub const CALENDAR_CHECK: &str = "\u{E712}"; pub const CALENDAR_DOT: &str = "\u{E7B2}"; pub const CALENDAR_DOTS: &str = "\u{E7B4}"; pub const CALENDAR_HEART: &str = "\u{E8B0}"; pub const CALENDAR_MINUS: &str = "\u{EA14}"; pub const CALENDAR_PLUS: &str = "\u{E714}"; pub const CALENDAR_SLASH: &str = "\u{EA12}"; pub const CALENDAR_STAR: &str = "\u{E8B2}"; pub const CALENDAR_X: &str = "\u{E10C}"; pub const CALL_BELL: &str = "\u{E7DE}"; pub const CAMERA: &str = "\u{E10E}"; pub const CAMERA_PLUS: &str = "\u{EC58}"; pub const CAMERA_ROTATE: &str = "\u{E7A4}"; pub const CAMERA_SLASH: &str = "\u{E110}"; pub const CAMPFIRE: &str = "\u{E9D8}"; pub const CAR: &str = "\u{E112}"; pub const CAR_BATTERY: &str = "\u{EE30}"; pub const CAR_PROFILE: &str = "\u{E8CC}"; pub const CAR_SIMPLE: &str = "\u{E114}"; pub const CARDHOLDER: &str = "\u{E5FA}"; pub const CARDS: &str = "\u{E0F8}"; pub const CARDS_THREE: &str = "\u{EE50}"; pub const CARET_CIRCLE_DOUBLE_DOWN: &str = "\u{E116}"; pub const CARET_CIRCLE_DOUBLE_LEFT: &str = "\u{E118}"; pub const CARET_CIRCLE_DOUBLE_RIGHT: &str = "\u{E11A}"; pub const CARET_CIRCLE_DOUBLE_UP: &str = "\u{E11C}"; pub const CARET_CIRCLE_DOWN: &str = "\u{E11E}"; pub const CARET_CIRCLE_LEFT: &str = "\u{E120}"; pub const CARET_CIRCLE_RIGHT: &str = "\u{E122}"; pub const CARET_CIRCLE_UP: &str = "\u{E124}"; pub const CARET_CIRCLE_UP_DOWN: &str = "\u{E13E}"; pub const CARET_DOUBLE_DOWN: &str = "\u{E126}"; pub const CARET_DOUBLE_LEFT: &str = "\u{E128}"; pub const CARET_DOUBLE_RIGHT: &str = "\u{E12A}"; pub const CARET_DOUBLE_UP: &str = "\u{E12C}"; pub const CARET_DOWN: &str = "\u{E136}"; pub const CARET_LEFT: &str = "\u{E138}"; pub const CARET_LINE_DOWN: &str = "\u{E134}"; pub const CARET_LINE_LEFT: &str = "\u{E132}"; pub const CARET_LINE_RIGHT: &str = "\u{E130}"; pub const CARET_LINE_UP: &str = "\u{E12E}"; pub const CARET_RIGHT: &str = "\u{E13A}"; pub const CARET_UP: &str = "\u{E13C}"; pub const CARET_UP_DOWN: &str = "\u{E140}"; pub const CARROT: &str = "\u{ED38}"; pub const CASH_REGISTER: &str = "\u{ED80}"; pub const CASSETTE_TAPE: &str = "\u{ED2E}"; pub const CASTLE_TURRET: &str = "\u{E9D0}"; pub const CAT: &str = "\u{E748}"; pub const CELL_SIGNAL_FULL: &str = "\u{E142}"; pub const CELL_SIGNAL_HIGH: &str = "\u{E144}"; pub const CELL_SIGNAL_LOW: &str = "\u{E146}"; pub const CELL_SIGNAL_MEDIUM: &str = "\u{E148}"; pub const CELL_SIGNAL_NONE: &str = "\u{E14A}"; pub const CELL_SIGNAL_SLASH: &str = "\u{E14C}"; pub const CELL_SIGNAL_X: &str = "\u{E14E}"; pub const CELL_TOWER: &str = "\u{EBAA}"; pub const CERTIFICATE: &str = "\u{E766}"; pub const CHAIR: &str = "\u{E950}"; pub const CHALKBOARD: &str = "\u{E5FC}"; pub const CHALKBOARD_SIMPLE: &str = "\u{E5FE}"; pub const CHALKBOARD_TEACHER: &str = "\u{E600}"; pub const CHAMPAGNE: &str = "\u{EACA}"; pub const CHARGING_STATION: &str = "\u{E8D0}"; pub const CHART_BAR: &str = "\u{E150}"; pub const CHART_BAR_HORIZONTAL: &str = "\u{E152}"; pub const CHART_DONUT: &str = "\u{EAA6}"; pub const CHART_LINE: &str = "\u{E154}"; pub const CHART_LINE_DOWN: &str = "\u{E8B6}"; pub const CHART_LINE_UP: &str = "\u{E156}"; pub const CHART_PIE: &str = "\u{E158}"; pub const CHART_PIE_SLICE: &str = "\u{E15A}"; pub const CHART_POLAR: &str = "\u{EAA8}"; pub const CHART_SCATTER: &str = "\u{EAAC}"; pub const CHAT: &str = "\u{E15C}"; pub const CHAT_CENTERED: &str = "\u{E160}"; pub const CHAT_CENTERED_DOTS: &str = "\u{E164}"; pub const CHAT_CENTERED_SLASH: &str = "\u{E162}"; pub const CHAT_CENTERED_TEXT: &str = "\u{E166}"; pub const CHAT_CIRCLE: &str = "\u{E168}"; pub const CHAT_CIRCLE_DOTS: &str = "\u{E16C}"; pub const CHAT_CIRCLE_SLASH: &str = "\u{E16A}"; pub const CHAT_CIRCLE_TEXT: &str = "\u{E16E}"; pub const CHAT_DOTS: &str = "\u{E170}"; pub const CHAT_SLASH: &str = "\u{E15E}"; pub const CHAT_TEARDROP: &str = "\u{E172}"; pub const CHAT_TEARDROP_DOTS: &str = "\u{E176}"; pub const CHAT_TEARDROP_SLASH: &str = "\u{E174}"; pub const CHAT_TEARDROP_TEXT: &str = "\u{E178}"; pub const CHAT_TEXT: &str = "\u{E17A}"; pub const CHATS: &str = "\u{E17C}"; pub const CHATS_CIRCLE: &str = "\u{E17E}"; pub const CHATS_TEARDROP: &str = "\u{E180}"; pub const CHECK: &str = "\u{E182}"; pub const CHECK_CIRCLE: &str = "\u{E184}"; pub const CHECK_FAT: &str = "\u{EBA6}"; pub const CHECK_SQUARE: &str = "\u{E186}"; pub const CHECK_SQUARE_OFFSET: &str = "\u{E188}"; pub const CHECKERBOARD: &str = "\u{E8C4}"; pub const CHECKS: &str = "\u{E53A}"; pub const CHEERS: &str = "\u{EA4A}"; pub const CHEESE: &str = "\u{E9FE}"; pub const CHEF_HAT: &str = "\u{ED8E}"; pub const CHERRIES: &str = "\u{E830}"; pub const CHURCH: &str = "\u{ECEA}"; pub const CIGARETTE: &str = "\u{ED90}"; pub const CIGARETTE_SLASH: &str = "\u{ED92}"; pub const CIRCLE: &str = "\u{E18A}"; pub const CIRCLE_DASHED: &str = "\u{E602}"; pub const CIRCLE_HALF: &str = "\u{E18C}"; pub const CIRCLE_HALF_TILT: &str = "\u{E18E}"; pub const CIRCLE_NOTCH: &str = "\u{EB44}"; pub const CIRCLES_FOUR: &str = "\u{E190}"; pub const CIRCLES_THREE: &str = "\u{E192}"; pub const CIRCLES_THREE_PLUS: &str = "\u{E194}"; pub const CIRCUITRY: &str = "\u{E9C2}"; pub const CITY: &str = "\u{EA6A}"; pub const CLIPBOARD: &str = "\u{E196}"; pub const CLIPBOARD_TEXT: &str = "\u{E198}"; pub const CLOCK: &str = "\u{E19A}"; pub const CLOCK_AFTERNOON: &str = "\u{E19C}"; pub const CLOCK_CLOCKWISE: &str = "\u{E19E}"; pub const CLOCK_COUNTDOWN: &str = "\u{ED2C}"; pub const CLOCK_COUNTER_CLOCKWISE: &str = "\u{E1A0}"; pub const CLOCK_USER: &str = "\u{EDEC}"; pub const CLOSED_CAPTIONING: &str = "\u{E1A4}"; pub const CLOUD: &str = "\u{E1AA}"; pub const CLOUD_ARROW_DOWN: &str = "\u{E1AC}"; pub const CLOUD_ARROW_UP: &str = "\u{E1AE}"; pub const CLOUD_CHECK: &str = "\u{E1B0}"; pub const CLOUD_FOG: &str = "\u{E53C}"; pub const CLOUD_LIGHTNING: &str = "\u{E1B2}"; pub const CLOUD_MOON: &str = "\u{E53E}"; pub const CLOUD_RAIN: &str = "\u{E1B4}"; pub const CLOUD_SLASH: &str = "\u{E1B6}"; pub const CLOUD_SNOW: &str = "\u{E1B8}"; pub const CLOUD_SUN: &str = "\u{E540}"; pub const CLOUD_WARNING: &str = "\u{EA98}"; pub const CLOUD_X: &str = "\u{EA96}"; pub const CLOVER: &str = "\u{EDC8}"; pub const CLUB: &str = "\u{E1BA}"; pub const COAT_HANGER: &str = "\u{E7FE}"; pub const CODA_LOGO: &str = "\u{E7CE}"; pub const CODE: &str = "\u{E1BC}"; pub const CODE_BLOCK: &str = "\u{EAFE}"; pub const CODE_SIMPLE: &str = "\u{E1BE}"; pub const CODEPEN_LOGO: &str = "\u{E978}"; pub const CODESANDBOX_LOGO: &str = "\u{EA06}"; pub const COFFEE: &str = "\u{E1C2}"; pub const COFFEE_BEAN: &str = "\u{E1C0}"; pub const COIN: &str = "\u{E60E}"; pub const COIN_VERTICAL: &str = "\u{EB48}"; pub const COINS: &str = "\u{E78E}"; pub const COLUMNS: &str = "\u{E546}"; pub const COLUMNS_PLUS_LEFT: &str = "\u{E544}"; pub const COLUMNS_PLUS_RIGHT: &str = "\u{E542}"; pub const COMMAND: &str = "\u{E1C4}"; pub const COMPASS: &str = "\u{E1C8}"; pub const COMPASS_ROSE: &str = "\u{E1C6}"; pub const COMPASS_TOOL: &str = "\u{EA0E}"; pub const COMPUTER_TOWER: &str = "\u{E548}"; pub const CONFETTI: &str = "\u{E81A}"; pub const CONTACTLESS_PAYMENT: &str = "\u{ED42}"; pub const CONTROL: &str = "\u{ECA6}"; pub const COOKIE: &str = "\u{E6CA}"; pub const COOKING_POT: &str = "\u{E764}"; pub const COPY: &str = "\u{E1CA}"; pub const COPY_SIMPLE: &str = "\u{E1CC}"; pub const COPYLEFT: &str = "\u{E86A}"; pub const COPYRIGHT: &str = "\u{E54A}"; pub const CORNERS_IN: &str = "\u{E1CE}"; pub const CORNERS_OUT: &str = "\u{E1D0}"; pub const COUCH: &str = "\u{E7F6}"; pub const COURT_BASKETBALL: &str = "\u{EE36}"; pub const COW: &str = "\u{EABE}"; pub const COWBOY_HAT: &str = "\u{ED12}"; pub const CPU: &str = "\u{E610}"; pub const CRANE: &str = "\u{ED48}"; pub const CRANE_TOWER: &str = "\u{ED49}"; pub const CREDIT_CARD: &str = "\u{E1D2}"; pub const CRICKET: &str = "\u{EE12}"; pub const CROP: &str = "\u{E1D4}"; pub const CROSS: &str = "\u{E8A0}"; pub const CROSSHAIR: &str = "\u{E1D6}"; pub const CROSSHAIR_SIMPLE: &str = "\u{E1D8}"; pub const CROWN: &str = "\u{E614}"; pub const CROWN_CROSS: &str = "\u{EE5E}"; pub const CROWN_SIMPLE: &str = "\u{E616}"; pub const CUBE: &str = "\u{E1DA}"; pub const CUBE_FOCUS: &str = "\u{ED0A}"; pub const CUBE_TRANSPARENT: &str = "\u{EC7C}"; pub const CURRENCY_BTC: &str = "\u{E618}"; pub const CURRENCY_CIRCLE_DOLLAR: &str = "\u{E54C}"; pub const CURRENCY_CNY: &str = "\u{E54E}"; pub const CURRENCY_DOLLAR: &str = "\u{E550}"; pub const CURRENCY_DOLLAR_SIMPLE: &str = "\u{E552}"; pub const CURRENCY_ETH: &str = "\u{EADA}"; pub const CURRENCY_EUR: &str = "\u{E554}"; pub const CURRENCY_GBP: &str = "\u{E556}"; pub const CURRENCY_INR: &str = "\u{E558}"; pub const CURRENCY_JPY: &str = "\u{E55A}"; pub const CURRENCY_KRW: &str = "\u{E55C}"; pub const CURRENCY_KZT: &str = "\u{EC4C}"; pub const CURRENCY_NGN: &str = "\u{EB52}"; pub const CURRENCY_RUB: &str = "\u{E55E}"; pub const CURSOR: &str = "\u{E1DC}"; pub const CURSOR_CLICK: &str = "\u{E7C8}"; pub const CURSOR_TEXT: &str = "\u{E7D8}"; pub const CYLINDER: &str = "\u{E8FC}"; pub const DATABASE: &str = "\u{E1DE}"; pub const DESK: &str = "\u{ED16}"; pub const DESKTOP: &str = "\u{E560}"; pub const DESKTOP_TOWER: &str = "\u{E562}"; pub const DETECTIVE: &str = "\u{E83E}"; pub const DEV_TO_LOGO: &str = "\u{ED0E}"; pub const DEVICE_MOBILE: &str = "\u{E1E0}"; pub const DEVICE_MOBILE_CAMERA: &str = "\u{E1E2}"; pub const DEVICE_MOBILE_SLASH: &str = "\u{EE46}"; pub const DEVICE_MOBILE_SPEAKER: &str = "\u{E1E4}"; pub const DEVICE_ROTATE: &str = "\u{EDF2}"; pub const DEVICE_TABLET: &str = "\u{E1E6}"; pub const DEVICE_TABLET_CAMERA: &str = "\u{E1E8}"; pub const DEVICE_TABLET_SPEAKER: &str = "\u{E1EA}"; pub const DEVICES: &str = "\u{EBA4}"; pub const DIAMOND: &str = "\u{E1EC}"; pub const DIAMONDS_FOUR: &str = "\u{E8F4}"; pub const DICE_FIVE: &str = "\u{E1EE}"; pub const DICE_FOUR: &str = "\u{E1F0}"; pub const DICE_ONE: &str = "\u{E1F2}"; pub const DICE_SIX: &str = "\u{E1F4}"; pub const DICE_THREE: &str = "\u{E1F6}"; pub const DICE_TWO: &str = "\u{E1F8}"; pub const DISC: &str = "\u{E564}"; pub const DISCO_BALL: &str = "\u{ED98}"; pub const DISCORD_LOGO: &str = "\u{E61A}"; pub const DIVIDE: &str = "\u{E1FA}"; pub const DNA: &str = "\u{E924}"; pub const DOG: &str = "\u{E74A}"; pub const DOOR: &str = "\u{E61C}"; pub const DOOR_OPEN: &str = "\u{E7E6}"; pub const DOT: &str = "\u{ECDE}"; pub const DOT_OUTLINE: &str = "\u{ECE0}"; pub const DOTS_NINE: &str = "\u{E1FC}"; pub const DOTS_SIX: &str = "\u{E794}"; pub const DOTS_SIX_VERTICAL: &str = "\u{EAE2}"; pub const DOTS_THREE: &str = "\u{E1FE}"; pub const DOTS_THREE_CIRCLE: &str = "\u{E200}"; pub const DOTS_THREE_CIRCLE_VERTICAL: &str = "\u{E202}"; pub const DOTS_THREE_OUTLINE: &str = "\u{E204}"; pub const DOTS_THREE_OUTLINE_VERTICAL: &str = "\u{E206}"; pub const DOTS_THREE_VERTICAL: &str = "\u{E208}"; pub const DOWNLOAD: &str = "\u{E20A}"; pub const DOWNLOAD_SIMPLE: &str = "\u{E20C}"; pub const DRESS: &str = "\u{EA7E}"; pub const DRESSER: &str = "\u{E94E}"; pub const DRIBBBLE_LOGO: &str = "\u{E20E}"; pub const DRONE: &str = "\u{ED74}"; pub const DROP: &str = "\u{E210}"; pub const DROP_HALF: &str = "\u{E566}"; pub const DROP_HALF_BOTTOM: &str = "\u{EB40}"; pub const DROP_SIMPLE: &str = "\u{EE32}"; pub const DROP_SLASH: &str = "\u{E954}"; pub const DROPBOX_LOGO: &str = "\u{E7D0}"; pub const EAR: &str = "\u{E70C}"; pub const EAR_SLASH: &str = "\u{E70E}"; pub const EGG: &str = "\u{E812}"; pub const EGG_CRACK: &str = "\u{EB64}"; pub const EJECT: &str = "\u{E212}"; pub const EJECT_SIMPLE: &str = "\u{E6AE}"; pub const ELEVATOR: &str = "\u{ECC0}"; pub const EMPTY: &str = "\u{EDBC}"; pub const ENGINE: &str = "\u{EA80}"; pub const ENVELOPE: &str = "\u{E214}"; pub const ENVELOPE_OPEN: &str = "\u{E216}"; pub const ENVELOPE_SIMPLE: &str = "\u{E218}"; pub const ENVELOPE_SIMPLE_OPEN: &str = "\u{E21A}"; pub const EQUALIZER: &str = "\u{EBBC}"; pub const EQUALS: &str = "\u{E21C}"; pub const ERASER: &str = "\u{E21E}"; pub const ESCALATOR_DOWN: &str = "\u{ECBA}"; pub const ESCALATOR_UP: &str = "\u{ECBC}"; pub const EXAM: &str = "\u{E742}"; pub const EXCLAMATION_MARK: &str = "\u{EE44}"; pub const EXCLUDE: &str = "\u{E882}"; pub const EXCLUDE_SQUARE: &str = "\u{E880}"; pub const EXPORT: &str = "\u{EAF0}"; pub const EYE: &str = "\u{E220}"; pub const EYE_CLOSED: &str = "\u{E222}"; pub const EYE_SLASH: &str = "\u{E224}"; pub const EYEDROPPER: &str = "\u{E568}"; pub const EYEDROPPER_SAMPLE: &str = "\u{EAC4}"; pub const EYEGLASSES: &str = "\u{E7BA}"; pub const EYES: &str = "\u{EE5C}"; pub const FACE_MASK: &str = "\u{E56A}"; pub const FACEBOOK_LOGO: &str = "\u{E226}"; pub const FACTORY: &str = "\u{E760}"; pub const FADERS: &str = "\u{E228}"; pub const FADERS_HORIZONTAL: &str = "\u{E22A}"; pub const FALLOUT_SHELTER: &str = "\u{E9DE}"; pub const FAN: &str = "\u{E9F2}"; pub const FARM: &str = "\u{EC70}"; pub const FAST_FORWARD: &str = "\u{E6A6}"; pub const FAST_FORWARD_CIRCLE: &str = "\u{E22C}"; pub const FEATHER: &str = "\u{E9C0}"; pub const FEDIVERSE_LOGO: &str = "\u{ED66}"; pub const FIGMA_LOGO: &str = "\u{E22E}"; pub const FILE: &str = "\u{E230}"; pub const FILE_ARCHIVE: &str = "\u{EB2A}"; pub const FILE_ARROW_DOWN: &str = "\u{E232}"; pub const FILE_ARROW_UP: &str = "\u{E61E}"; pub const FILE_AUDIO: &str = "\u{EA20}"; pub const FILE_C: &str = "\u{EB32}"; pub const FILE_C_SHARP: &str = "\u{EB30}"; pub const FILE_CLOUD: &str = "\u{E95E}"; pub const FILE_CODE: &str = "\u{E914}"; pub const FILE_CPP: &str = "\u{EB2E}"; pub const FILE_CSS: &str = "\u{EB34}"; pub const FILE_CSV: &str = "\u{EB1C}"; pub const FILE_DASHED: &str = "\u{E704}"; pub const FILE_DOTTED: &str = "\u{E704}"; pub const FILE_DOC: &str = "\u{EB1E}"; pub const FILE_HTML: &str = "\u{EB38}"; pub const FILE_IMAGE: &str = "\u{EA24}"; pub const FILE_INI: &str = "\u{EB33}"; pub const FILE_JPG: &str = "\u{EB1A}"; pub const FILE_JS: &str = "\u{EB24}"; pub const FILE_JSX: &str = "\u{EB3A}"; pub const FILE_LOCK: &str = "\u{E95C}"; pub const FILE_MAGNIFYING_GLASS: &str = "\u{E238}"; pub const FILE_SEARCH: &str = "\u{E238}"; pub const FILE_MD: &str = "\u{ED50}"; pub const FILE_MINUS: &str = "\u{E234}"; pub const FILE_PDF: &str = "\u{E702}"; pub const FILE_PLUS: &str = "\u{E236}"; pub const FILE_PNG: &str = "\u{EB18}"; pub const FILE_PPT: &str = "\u{EB20}"; pub const FILE_PY: &str = "\u{EB2C}"; pub const FILE_RS: &str = "\u{EB28}"; pub const FILE_SQL: &str = "\u{ED4E}"; pub const FILE_SVG: &str = "\u{ED08}"; pub const FILE_TEXT: &str = "\u{E23A}"; pub const FILE_TS: &str = "\u{EB26}"; pub const FILE_TSX: &str = "\u{EB3C}"; pub const FILE_TXT: &str = "\u{EB35}"; pub const FILE_VIDEO: &str = "\u{EA22}"; pub const FILE_VUE: &str = "\u{EB3E}"; pub const FILE_X: &str = "\u{E23C}"; pub const FILE_XLS: &str = "\u{EB22}"; pub const FILE_ZIP: &str = "\u{E958}"; pub const FILES: &str = "\u{E710}"; pub const FILM_REEL: &str = "\u{E8C0}"; pub const FILM_SCRIPT: &str = "\u{EB50}"; pub const FILM_SLATE: &str = "\u{E8C2}"; pub const FILM_STRIP: &str = "\u{E792}"; pub const FINGERPRINT: &str = "\u{E23E}"; pub const FINGERPRINT_SIMPLE: &str = "\u{E240}"; pub const FINN_THE_HUMAN: &str = "\u{E56C}"; pub const FIRE: &str = "\u{E242}"; pub const FIRE_EXTINGUISHER: &str = "\u{E9E8}"; pub const FIRE_SIMPLE: &str = "\u{E620}"; pub const FIRE_TRUCK: &str = "\u{E574}"; pub const FIRST_AID: &str = "\u{E56E}"; pub const FIRST_AID_KIT: &str = "\u{E570}"; pub const FISH: &str = "\u{E728}"; pub const FISH_SIMPLE: &str = "\u{E72A}"; pub const FLAG: &str = "\u{E244}"; pub const FLAG_BANNER: &str = "\u{E622}"; pub const FLAG_BANNER_FOLD: &str = "\u{ECF2}"; pub const FLAG_CHECKERED: &str = "\u{EA38}"; pub const FLAG_PENNANT: &str = "\u{ECF0}"; pub const FLAME: &str = "\u{E624}"; pub const FLASHLIGHT: &str = "\u{E246}"; pub const FLASK: &str = "\u{E79E}"; pub const FLIP_HORIZONTAL: &str = "\u{ED6A}"; pub const FLIP_VERTICAL: &str = "\u{ED6C}"; pub const FLOPPY_DISK: &str = "\u{E248}"; pub const FLOPPY_DISK_BACK: &str = "\u{EAF4}"; pub const FLOW_ARROW: &str = "\u{E6EC}"; pub const FLOWER: &str = "\u{E75E}"; pub const FLOWER_LOTUS: &str = "\u{E6CC}"; pub const FLOWER_TULIP: &str = "\u{EACC}"; pub const FLYING_SAUCER: &str = "\u{EB4A}"; pub const FOLDER: &str = "\u{E24A}"; pub const FOLDER_NOTCH: &str = "\u{E24A}"; pub const FOLDER_DASHED: &str = "\u{E8F8}"; pub const FOLDER_DOTTED: &str = "\u{E8F8}"; pub const FOLDER_LOCK: &str = "\u{EA3C}"; pub const FOLDER_MINUS: &str = "\u{E254}"; pub const FOLDER_NOTCH_MINUS: &str = "\u{E254}"; pub const FOLDER_OPEN: &str = "\u{E256}"; pub const FOLDER_NOTCH_OPEN: &str = "\u{E256}"; pub const FOLDER_PLUS: &str = "\u{E258}"; pub const FOLDER_NOTCH_PLUS: &str = "\u{E258}"; pub const FOLDER_SIMPLE: &str = "\u{E25A}"; pub const FOLDER_SIMPLE_DASHED: &str = "\u{EC2A}"; pub const FOLDER_SIMPLE_DOTTED: &str = "\u{EC2A}"; pub const FOLDER_SIMPLE_LOCK: &str = "\u{EB5E}"; pub const FOLDER_SIMPLE_MINUS: &str = "\u{E25C}"; pub const FOLDER_SIMPLE_PLUS: &str = "\u{E25E}"; pub const FOLDER_SIMPLE_STAR: &str = "\u{EC2E}"; pub const FOLDER_SIMPLE_USER: &str = "\u{EB60}"; pub const FOLDER_STAR: &str = "\u{EA86}"; pub const FOLDER_USER: &str = "\u{EB46}"; pub const FOLDERS: &str = "\u{E260}"; pub const FOOTBALL: &str = "\u{E718}"; pub const FOOTBALL_HELMET: &str = "\u{EE4C}"; pub const FOOTPRINTS: &str = "\u{EA88}"; pub const FORK_KNIFE: &str = "\u{E262}"; pub const FOUR_K: &str = "\u{EA5C}"; pub const FRAME_CORNERS: &str = "\u{E626}"; pub const FRAMER_LOGO: &str = "\u{E264}"; pub const FUNCTION: &str = "\u{EBE4}"; pub const FUNNEL: &str = "\u{E266}"; pub const FUNNEL_SIMPLE: &str = "\u{E268}"; pub const FUNNEL_SIMPLE_X: &str = "\u{E26A}"; pub const FUNNEL_X: &str = "\u{E26C}"; pub const GAME_CONTROLLER: &str = "\u{E26E}"; pub const GARAGE: &str = "\u{ECD6}"; pub const GAS_CAN: &str = "\u{E8CE}"; pub const GAS_PUMP: &str = "\u{E768}"; pub const GAUGE: &str = "\u{E628}"; pub const GAVEL: &str = "\u{EA32}"; pub const GEAR: &str = "\u{E270}"; pub const GEAR_FINE: &str = "\u{E87C}"; pub const GEAR_SIX: &str = "\u{E272}"; pub const GENDER_FEMALE: &str = "\u{E6E0}"; pub const GENDER_INTERSEX: &str = "\u{E6E6}"; pub const GENDER_MALE: &str = "\u{E6E2}"; pub const GENDER_NEUTER: &str = "\u{E6EA}"; pub const GENDER_NONBINARY: &str = "\u{E6E4}"; pub const GENDER_TRANSGENDER: &str = "\u{E6E8}"; pub const GHOST: &str = "\u{E62A}"; pub const GIF: &str = "\u{E274}"; pub const GIFT: &str = "\u{E276}"; pub const GIT_BRANCH: &str = "\u{E278}"; pub const GIT_COMMIT: &str = "\u{E27A}"; pub const GIT_DIFF: &str = "\u{E27C}"; pub const GIT_FORK: &str = "\u{E27E}"; pub const GIT_MERGE: &str = "\u{E280}"; pub const GIT_PULL_REQUEST: &str = "\u{E282}"; pub const GITHUB_LOGO: &str = "\u{E576}"; pub const GITLAB_LOGO: &str = "\u{E694}"; pub const GITLAB_LOGO_SIMPLE: &str = "\u{E696}"; pub const GLOBE: &str = "\u{E288}"; pub const GLOBE_HEMISPHERE_EAST: &str = "\u{E28A}"; pub const GLOBE_HEMISPHERE_WEST: &str = "\u{E28C}"; pub const GLOBE_SIMPLE: &str = "\u{E28E}"; pub const GLOBE_SIMPLE_X: &str = "\u{E284}"; pub const GLOBE_STAND: &str = "\u{E290}"; pub const GLOBE_X: &str = "\u{E286}"; pub const GOGGLES: &str = "\u{ECB4}"; pub const GOLF: &str = "\u{EA3E}"; pub const GOODREADS_LOGO: &str = "\u{ED10}"; pub const GOOGLE_CARDBOARD_LOGO: &str = "\u{E7B6}"; pub const GOOGLE_CHROME_LOGO: &str = "\u{E976}"; pub const GOOGLE_DRIVE_LOGO: &str = "\u{E8F6}"; pub const GOOGLE_LOGO: &str = "\u{E292}"; pub const GOOGLE_PHOTOS_LOGO: &str = "\u{EB92}"; pub const GOOGLE_PLAY_LOGO: &str = "\u{E294}"; pub const GOOGLE_PODCASTS_LOGO: &str = "\u{EB94}"; pub const GPS: &str = "\u{EDD8}"; pub const GPS_FIX: &str = "\u{EDD6}"; pub const GPS_SLASH: &str = "\u{EDD4}"; pub const GRADIENT: &str = "\u{EB42}"; pub const GRADUATION_CAP: &str = "\u{E62C}"; pub const GRAINS: &str = "\u{EC68}"; pub const GRAINS_SLASH: &str = "\u{EC6A}"; pub const GRAPH: &str = "\u{EB58}"; pub const GRAPHICS_CARD: &str = "\u{E612}"; pub const GREATER_THAN: &str = "\u{EDC4}"; pub const GREATER_THAN_OR_EQUAL: &str = "\u{EDA2}"; pub const GRID_FOUR: &str = "\u{E296}"; pub const GRID_NINE: &str = "\u{EC8C}"; pub const GUITAR: &str = "\u{EA8A}"; pub const HAIR_DRYER: &str = "\u{EA66}"; pub const HAMBURGER: &str = "\u{E790}"; pub const HAMMER: &str = "\u{E80E}"; pub const HAND: &str = "\u{E298}"; pub const HAND_ARROW_DOWN: &str = "\u{EA4E}"; pub const HAND_ARROW_UP: &str = "\u{EE5A}"; pub const HAND_COINS: &str = "\u{EA8C}"; pub const HAND_DEPOSIT: &str = "\u{EE82}"; pub const HAND_EYE: &str = "\u{EA4C}"; pub const HAND_FIST: &str = "\u{E57A}"; pub const HAND_GRABBING: &str = "\u{E57C}"; pub const HAND_HEART: &str = "\u{E810}"; pub const HAND_PALM: &str = "\u{E57E}"; pub const HAND_PEACE: &str = "\u{E7CC}"; pub const HAND_POINTING: &str = "\u{E29A}"; pub const HAND_SOAP: &str = "\u{E630}"; pub const HAND_SWIPE_LEFT: &str = "\u{EC94}"; pub const HAND_SWIPE_RIGHT: &str = "\u{EC92}"; pub const HAND_TAP: &str = "\u{EC90}"; pub const HAND_WAVING: &str = "\u{E580}"; pub const HAND_WITHDRAW: &str = "\u{EE80}"; pub const HANDBAG: &str = "\u{E29C}"; pub const HANDBAG_SIMPLE: &str = "\u{E62E}"; pub const HANDS_CLAPPING: &str = "\u{E6A0}"; pub const HANDS_PRAYING: &str = "\u{ECC8}"; pub const HANDSHAKE: &str = "\u{E582}"; pub const HARD_DRIVE: &str = "\u{E29E}"; pub const HARD_DRIVES: &str = "\u{E2A0}";
rust
Apache-2.0
c33b60c40f703ffa3d40d252f1bc911cf531581d
2026-01-04T20:22:14.235772Z
true