mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-24 04:36:10 +03:00
Add type to Item tagged union to enable decoding of session object
This commit is contained in:
@ -278,6 +278,7 @@ pub const ItemType = enum {
|
||||
pub const Item = union(enum) {
|
||||
encoded: EncodedItem,
|
||||
attachment: Attachment,
|
||||
session: Session,
|
||||
|
||||
/// Convert the item to an encoded item. This modify the item
|
||||
/// in place.
|
||||
@ -288,6 +289,7 @@ pub const Item = union(enum) {
|
||||
const result: EncodedItem = switch (self.*) {
|
||||
.encoded => |v| return v,
|
||||
.attachment => |*v| try v.encode(alloc),
|
||||
.session => |*v| try v.encode(alloc),
|
||||
};
|
||||
self.* = .{ .encoded = result };
|
||||
return result;
|
||||
@ -299,6 +301,7 @@ pub const Item = union(enum) {
|
||||
return switch (self) {
|
||||
.encoded => |v| v.type,
|
||||
.attachment => .attachment,
|
||||
.session => .session,
|
||||
};
|
||||
}
|
||||
|
||||
@ -335,6 +338,10 @@ pub const Item = union(enum) {
|
||||
alloc,
|
||||
encoded,
|
||||
) },
|
||||
.session => .{ .session = try .decode(
|
||||
alloc,
|
||||
encoded,
|
||||
) },
|
||||
else => return error.UnsupportedType,
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user