feat(plugin-api): add display impl for uuid (#2497)

This commit is contained in:
Mettwasser
2026-07-30 14:24:19 +02:00
committed by GitHub
parent cbc8af5d2d
commit 98fd79b57e
3 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
//! WIT-generated plugin type extensions belong in here. For example [Display](std::fmt::Display) implementations.
mod uuid;

View File

@@ -0,0 +1,32 @@
use std::fmt;
use crate::wit::pumpkin::plugin::uuid::Uuid;
impl fmt::Display for Uuid {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{:08x}-{:04x}-{:04x}-{:04x}-{:012x}",
(self.high >> 32) as u32,
((self.high >> 16) & 0xffff) as u16,
(self.high & 0xffff) as u16,
(self.low >> 48) as u16,
self.low & 0x0000_ffff_ffff_ffff,
)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn formats_uuid_correctly() {
let uuid = Uuid {
high: 0x0011223344556677,
low: 0x8899aabbccddeeff,
};
assert_eq!(uuid.to_string(), "00112233-4455-6677-8899-aabbccddeeff");
}
}

View File

@@ -35,6 +35,7 @@ use crate::{
pub mod commands;
pub mod events;
mod ext;
pub mod forms;
/// Constants for plugin permissions.
///