swayipc-rs
swayipc-rs copied to clipboard
Enums instead of Strings
What do you think about replacing the strings for things like layout with enums?
This would allow a better typed experience writing code for this. The only issue I see is, that there might be an invalid variant returned, but that could be solved by adding a fallback to the enum like so:
enum WorkspaceLayout {
Splith,
Splitv,
Stacked,
Tabbed,
Other(String)
}
Well after looking a little further seems like only the on Workspace
there is no Enum for the layout.
Yep, this is definitely an oversight on my part when I added the layout in 8af9ba21251699699fb9c510b58d383beb824342 😅
Looking at the relevant section in sway's ipc-json.c the ipc_json_layout_description function is called which matches the NodeLayout
enum.