transport.gleam
1 //// Transport abstractions. 2 3 /// Supported transport families. 4 pub type Transport { 5 WebSocket 6 ServerSentEvents 7 LongPolling 8 InProcess 9 } 10 11 /// Return a stable transport label. 12 pub fn label(transport: Transport) -> String { 13 case transport { 14 WebSocket -> "websocket" 15 ServerSentEvents -> "sse" 16 LongPolling -> "long_polling" 17 InProcess -> "in_process" 18 } 19 } 20 21 /// True when the transport can send client and server messages over one channel. 22 pub fn bidirectional(transport: Transport) -> Bool { 23 case transport { 24 WebSocket -> True 25 InProcess -> True 26 ServerSentEvents -> False 27 LongPolling -> False 28 } 29 }