diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ffd0bf..c5cf3be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# v0.10.0 + +- Updated for Gleam v0.33.0. +- The `options.to_map` function has been renamed to `options.to_dict`. + # v0.9.1 - Pass state value to `on_close` handler diff --git a/gleam.toml b/gleam.toml index fd0eee0..609e71a 100644 --- a/gleam.toml +++ b/gleam.toml @@ -1,5 +1,5 @@ name = "glisten" -version = "0.9.2" +version = "0.10.0" description = "a shiny Gleam TCP/SSL server" licences = ["Apache-2.0"] repository = { type = "github", user = "rawhat", repo = "glisten" } diff --git a/src/glisten/socket/options.gleam b/src/glisten/socket/options.gleam index c7983e5..79468d0 100644 --- a/src/glisten/socket/options.gleam +++ b/src/glisten/socket/options.gleam @@ -1,7 +1,7 @@ import gleam/dynamic.{type Dynamic} import gleam/erlang/atom import gleam/list -import gleam/map.{type Map} +import gleam/dict.{type Dict} import gleam/pair /// Mode for the socket. Currently `list` is not supported @@ -36,7 +36,7 @@ pub type TcpOption { Inet6 } -pub fn to_map(options: List(TcpOption)) -> Map(atom.Atom, Dynamic) { +pub fn to_dict(options: List(TcpOption)) -> Dict(atom.Atom, Dynamic) { let opt_decoder = dynamic.tuple2(dynamic.dynamic, dynamic.dynamic) options @@ -58,7 +58,7 @@ pub fn to_map(options: List(TcpOption)) -> Map(atom.Atom, Dynamic) { }) |> list.filter_map(opt_decoder) |> list.map(pair.map_first(_, dynamic.unsafe_coerce)) - |> map.from_list + |> dict.from_list } const default_options = [ @@ -73,12 +73,12 @@ const default_options = [ ] pub fn merge_with_defaults(options: List(TcpOption)) -> List(TcpOption) { - let overrides = to_map(options) + let overrides = to_dict(options) default_options - |> to_map - |> map.merge(overrides) - |> map.to_list + |> to_dict + |> dict.merge(overrides) + |> dict.to_list |> list.map(dynamic.from) |> list.map(dynamic.unsafe_coerce) |> list.append([Inet6]) diff --git a/src/glisten/socket/transport.gleam b/src/glisten/socket/transport.gleam index fe14169..9d69d29 100644 --- a/src/glisten/socket/transport.gleam +++ b/src/glisten/socket/transport.gleam @@ -2,7 +2,7 @@ import gleam/bit_builder.{type BitBuilder} import gleam/dynamic.{type Dynamic} import gleam/erlang/atom.{type Atom} import gleam/erlang/process.{type Pid} -import gleam/map.{type Map} +import gleam/dict.{type Dict} import glisten/socket/options import glisten/socket.{type ListenSocket, type Socket, type SocketReason} import glisten/ssl @@ -30,7 +30,7 @@ type Send = fn(Socket, BitBuilder) -> Result(Nil, SocketReason) type SocketInfo = - fn(Socket) -> Map(Atom, Dynamic) + fn(Socket) -> Dict(Atom, Dynamic) type Close = fn(Socket) -> Result(Nil, SocketReason) @@ -126,4 +126,4 @@ pub fn ssl() -> Transport { } @external(erlang, "socket", "info") -pub fn socket_info(socket: Socket) -> Map(a, b) +pub fn socket_info(socket: Socket) -> Dict(a, b) diff --git a/src/glisten/ssl.gleam b/src/glisten/ssl.gleam index 5bf2863..beb2fa6 100644 --- a/src/glisten/ssl.gleam +++ b/src/glisten/ssl.gleam @@ -3,7 +3,7 @@ import gleam/dynamic.{type Dynamic} import gleam/erlang/atom.{type Atom} import gleam/erlang/process.{type Pid} import gleam/list -import gleam/map +import gleam/dict import glisten/socket.{type ListenSocket, type Socket, type SocketReason} import glisten/socket/options @@ -58,8 +58,8 @@ pub fn set_opts( opts: List(options.TcpOption), ) -> Result(Nil, Nil) { opts - |> options.to_map - |> map.to_list + |> options.to_dict + |> dict.to_list |> list.map(dynamic.from) |> do_set_opts(socket, _) } diff --git a/src/glisten/tcp.gleam b/src/glisten/tcp.gleam index 08fce68..dc71183 100644 --- a/src/glisten/tcp.gleam +++ b/src/glisten/tcp.gleam @@ -3,7 +3,7 @@ import gleam/dynamic.{type Dynamic} import gleam/erlang/atom.{type Atom} import gleam/erlang/process.{type Pid} import gleam/list -import gleam/map.{type Map} +import gleam/dict.{type Dict} import glisten/socket.{type ListenSocket, type Socket, type SocketReason} import glisten/socket/options.{type TcpOption} @@ -39,7 +39,7 @@ pub fn receive(socket: Socket, length: Int) -> Result(BitArray, SocketReason) pub fn send(socket: Socket, packet: BitBuilder) -> Result(Nil, SocketReason) @external(erlang, "socket", "info") -pub fn socket_info(socket: Socket) -> Map(a, b) +pub fn socket_info(socket: Socket) -> Dict(a, b) @external(erlang, "glisten_tcp_ffi", "close") pub fn close(socket: a) -> Result(Nil, SocketReason) @@ -58,8 +58,8 @@ fn do_set_opts(socket: Socket, opts: List(Dynamic)) -> Result(Nil, Nil) /// Update the optons for a socket (mutates the socket) pub fn set_opts(socket: Socket, opts: List(TcpOption)) -> Result(Nil, Nil) { opts - |> options.to_map - |> map.to_list + |> options.to_dict + |> dict.to_list |> list.map(dynamic.from) |> do_set_opts(socket, _) }