save work

This commit is contained in:
Evan Simkowitz 2024-02-20 14:50:50 -08:00
parent fe3ffd1545
commit 523eafd85a
No known key found for this signature in database
4 changed files with 19 additions and 0 deletions

View File

@ -126,4 +126,7 @@ type CleanableUpdateItem interface {
func init() {
// Register the model update packet type
packet.RegisterPacketType(ModelUpdateStr, reflect.TypeOf(ModelUpdatePacketType{}))
// Enforce the UpdatePacket interface
var _ UpdatePacket = (*ModelUpdatePacketType)(nil)
}

View File

@ -47,4 +47,7 @@ func MakePtyDataUpdate(update *PtyDataUpdate) *PtyDataUpdatePacketType {
func init() {
// Register the PtyDataUpdatePacketType with the packet package
packet.RegisterPacketType(PtyDataUpdateStr, reflect.TypeOf(PtyDataUpdatePacketType{}))
// Enforce the UpdatePacket interface
var _ UpdatePacket = (*PtyDataUpdatePacketType)(nil)
}

View File

@ -67,6 +67,9 @@ type UpdatePacket interface {
IsEmpty() bool
}
// Enforce that UpdatePacket is a packet.PacketType
var _ packet.PacketType = (UpdatePacket)(nil)
// A channel for sending model updates to the client
type UpdateChannel struct {
ScreenId string
@ -89,6 +92,9 @@ func (sch *UpdateChannel) Match(screenId string) bool {
return screenId == sch.ScreenId
}
// Enforce that UpdateChannel is a Channel
var _ Channel[UpdatePacket] = (*UpdateChannel)(nil)
// A collection of channels that can transmit updates
type UpdateBus struct {
Bus[UpdatePacket]
@ -206,6 +212,9 @@ func (ch *RpcChannel) Match(string) bool {
return true
}
// Enforce that RpcChannel is a Channel
var _ Channel[RpcResponse] = (*RpcChannel)(nil)
// Send a user input request to the frontend and wait for a response
func (bus *RpcBus) DoRpc(ctx context.Context, pk RpcPacket) (RpcResponse, error) {
id := uuid.New().String()

View File

@ -74,4 +74,8 @@ func GetUserInput(ctx context.Context, bus *scbus.RpcBus, userInputRequest *User
func init() {
// Register the user input request packet type
packet.RegisterPacketType(UserInputResponsePacketStr, reflect.TypeOf(UserInputResponsePacketType{}))
// Enforce the interfaces
var _ scbus.RpcResponse = (*UserInputResponsePacketType)(nil)
var _ scbus.RpcPacket = (*UserInputRequestType)(nil)
}