Skip to content

Commit

Permalink
More typing of messages
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Dec 21, 2023
1 parent fa1aaeb commit 31402bf
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/core/socket.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import nettlesome.*
import parasite.*
import fulminate.*
import hieroglyph.*
import spectacular.*
import turbulence.*
import gossamer.*
import rudiments.*
Expand Down Expand Up @@ -276,14 +277,26 @@ trait Transmissible[-MessageType]:
object Transmissible:
given bytes: Transmissible[Bytes] = identity(_)
given text(using CharEncoder): Transmissible[Text] = _.bytes
given encoder[MessageType: Encoder](using CharEncoder): Transmissible[MessageType] = _.encode.bytes

trait Receivable[+MessageType]:
def deserialize(message: Bytes): MessageType

object Receivable:
given bytes: Receivable[Bytes] = identity(_)
given text(using CharDecoder): Receivable[Text] = _.text
given decoder[MessageType: Decoder](using CharDecoder): Receivable[MessageType] = _.text.decodeAs[MessageType]

trait SocketService:
def stop(): Unit



extension [SocketType](socket: SocketType)
def listen
[ResultType]
[InputType]
(using bindable: Bindable[SocketType], monitor: Monitor)
[ResultType]
(fn: bindable.Input => bindable.Output)
: SocketService raises BindError =

Expand Down

0 comments on commit 31402bf

Please sign in to comment.