mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +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) {
|
pub const Item = union(enum) {
|
||||||
encoded: EncodedItem,
|
encoded: EncodedItem,
|
||||||
attachment: Attachment,
|
attachment: Attachment,
|
||||||
|
session: Session,
|
||||||
|
|
||||||
/// Convert the item to an encoded item. This modify the item
|
/// Convert the item to an encoded item. This modify the item
|
||||||
/// in place.
|
/// in place.
|
||||||
@ -288,6 +289,7 @@ pub const Item = union(enum) {
|
|||||||
const result: EncodedItem = switch (self.*) {
|
const result: EncodedItem = switch (self.*) {
|
||||||
.encoded => |v| return v,
|
.encoded => |v| return v,
|
||||||
.attachment => |*v| try v.encode(alloc),
|
.attachment => |*v| try v.encode(alloc),
|
||||||
|
.session => |*v| try v.encode(alloc),
|
||||||
};
|
};
|
||||||
self.* = .{ .encoded = result };
|
self.* = .{ .encoded = result };
|
||||||
return result;
|
return result;
|
||||||
@ -299,6 +301,7 @@ pub const Item = union(enum) {
|
|||||||
return switch (self) {
|
return switch (self) {
|
||||||
.encoded => |v| v.type,
|
.encoded => |v| v.type,
|
||||||
.attachment => .attachment,
|
.attachment => .attachment,
|
||||||
|
.session => .session,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,6 +338,10 @@ pub const Item = union(enum) {
|
|||||||
alloc,
|
alloc,
|
||||||
encoded,
|
encoded,
|
||||||
) },
|
) },
|
||||||
|
.session => .{ .session = try .decode(
|
||||||
|
alloc,
|
||||||
|
encoded,
|
||||||
|
) },
|
||||||
else => return error.UnsupportedType,
|
else => return error.UnsupportedType,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user