use std::fmt::Debug; use gpui::Axis; use serde::{Deserialize, Serialize}; /// A enum for defining the side of the element. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum Side { #[serde(rename = "left")] Left, #[serde(rename = "right")] Right, } impl Side { /// Returns true if the side is left. #[inline] pub fn is_left(&self) -> bool { matches!(self, Self::Left) } /// Returns true if the side is right. #[inline] pub fn is_right(&self) -> bool { matches!(self, Self::Right) } } /// A trait to extend the [`Axis`] enum with utility methods. pub trait AxisExt { #[allow(clippy::wrong_self_convention)] fn is_horizontal(self) -> bool; #[allow(clippy::wrong_self_convention)] fn is_vertical(self) -> bool; } impl AxisExt for Axis { #[inline] fn is_horizontal(self) -> bool { self == Axis::Horizontal } #[inline] fn is_vertical(self) -> bool { self == Axis::Vertical } } /// A struct for defining the edges of an element. /// /// A extend version of [`gpui::Edges`] to serialize/deserialize. #[derive(Debug, Clone, Default, Serialize, Deserialize, Eq, PartialEq)] #[repr(C)] pub struct Edges { /// The size of the top edge. pub top: T, /// The size of the right edge. pub right: T, /// The size of the bottom edge. pub bottom: T, /// The size of the left edge. pub left: T, }