Skip to content

Commit

Permalink
Drop ImmutableBuffer usage
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanMartinez committed Jun 16, 2023
1 parent 01c1744 commit 6780e30
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
9 changes: 4 additions & 5 deletions src/Node/Http2/Session.purs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ import Effect (Effect)
import Effect.Exception (Error)
import Effect.Uncurried (EffectFn1, EffectFn2, EffectFn3, EffectFn4, mkEffectFn1, mkEffectFn2, mkEffectFn3, mkEffectFn4, runEffectFn1, runEffectFn2, runEffectFn3, runEffectFn4)
import Node.Buffer (Buffer)
import Node.Buffer.Immutable (ImmutableBuffer)
import Node.EventEmitter (EventEmitter, EventHandle(..))
import Node.EventEmitter.UtilTypes (EventHandle0, EventHandle1, EventHandle2, EventHandle3, EventHandle4)
import Node.Http2.ErrorCode (ErrorCode)
Expand Down Expand Up @@ -193,17 +192,17 @@ pendingSettingsAck s = runEffectFn1 pendingSettingsAckImpl s

foreign import pendingSettingsAckImpl :: forall endpoint. EffectFn1 (Http2Session endpoint) (Boolean)

ping :: forall endpoint. Http2Session endpoint -> (Maybe Error -> Milliseconds -> ImmutableBuffer -> Effect Unit) -> Effect Boolean
ping :: forall endpoint. Http2Session endpoint -> (Maybe Error -> Milliseconds -> Buffer -> Effect Unit) -> Effect Boolean
ping s cb = runEffectFn2 pingImpl s $ mkEffectFn3 \err dur payload ->
cb (toMaybe err) dur payload

foreign import pingImpl :: forall endpoint. EffectFn2 (Http2Session endpoint) (EffectFn3 (Nullable Error) Milliseconds ImmutableBuffer Unit) (Boolean)
foreign import pingImpl :: forall endpoint. EffectFn2 (Http2Session endpoint) (EffectFn3 (Nullable Error) Milliseconds Buffer Unit) (Boolean)

pingPayload :: forall endpoint. Http2Session endpoint -> ImmutableBuffer -> (Maybe Error -> Milliseconds -> ImmutableBuffer -> Effect Unit) -> Effect Boolean
pingPayload :: forall endpoint. Http2Session endpoint -> Buffer -> (Maybe Error -> Milliseconds -> Buffer -> Effect Unit) -> Effect Boolean
pingPayload s buf cb = runEffectFn3 pingPayloadImpl s buf $ mkEffectFn3 \err dur payload ->
cb (toMaybe err) dur payload

foreign import pingPayloadImpl :: forall endpoint. EffectFn3 (Http2Session endpoint) ImmutableBuffer (EffectFn3 (Nullable Error) Milliseconds ImmutableBuffer Unit) (Boolean)
foreign import pingPayloadImpl :: forall endpoint. EffectFn3 (Http2Session endpoint) Buffer (EffectFn3 (Nullable Error) Milliseconds Buffer Unit) (Boolean)

ref :: forall endpoint. Http2Session endpoint -> Effect (Socket TCP)
ref s = runEffectFn1 refImpl s
Expand Down
10 changes: 5 additions & 5 deletions src/Node/Http2/Settings.purs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Node.Http2.Settings

import Effect (Effect)
import Effect.Uncurried (EffectFn1, runEffectFn1)
import Node.Buffer.Immutable (ImmutableBuffer)
import Node.Buffer (Buffer)
import Node.Http2.Types (Settings)

defaultSettings :: Settings
Expand All @@ -23,12 +23,12 @@ defaultSettings =

foreign import getDefaultSettings :: Effect (Settings)

getPackedSettings :: Settings -> Effect ImmutableBuffer
getPackedSettings :: Settings -> Effect Buffer
getPackedSettings s = runEffectFn1 getPackedSettingsImpl s

foreign import getPackedSettingsImpl :: EffectFn1 (Settings) (ImmutableBuffer)
foreign import getPackedSettingsImpl :: EffectFn1 (Settings) (Buffer)

getUnpackedSettings :: ImmutableBuffer -> Effect Settings
getUnpackedSettings :: Buffer -> Effect Settings
getUnpackedSettings buf = runEffectFn1 getUnpackedSettingsImpl buf

foreign import getUnpackedSettingsImpl :: EffectFn1 (ImmutableBuffer) (Settings)
foreign import getUnpackedSettingsImpl :: EffectFn1 (Buffer) (Settings)
3 changes: 0 additions & 3 deletions test/Test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ import Node.Path as Path
import Node.Stream as Stream
import Unsafe.Coerce (unsafeCoerce)

unsafeToImmutableBuffer :: Buffer.Buffer -> Effect ImmutableBuffer
unsafeToImmutableBuffer = Buffer.unsafeFreeze

logWith :: String -> String -> Effect Unit
logWith msg x = log $ msg <> ": " <> x

Expand Down

0 comments on commit 6780e30

Please sign in to comment.