All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.message.Describe.scala Maven / Gradle / Ivy

The newest version!
// Copyright (c) 2018-2021 by Rob Norris
// This software is licensed under the MIT License (MIT).
// For more information see LICENSE or https://opensource.org/licenses/MIT

package skunk.net.message

import cats.syntax.all._
import scodec.codecs._
import scodec.Encoder

sealed abstract case class Describe(variant: Byte, name: String) extends TaggedFrontendMessage('D') {
  override def toString = s"Describe(${variant.toChar}, $name)"
  def encodeBody = Describe.encoder.encode(this)
}

object Describe {

  def statement(name: String): Describe =
    new Describe('S', name) {}

  def portal(name: String): Describe =
    new Describe('P', name) {}

  val encoder: Encoder[Describe] =
    (byte.asEncoder, utf8z.asEncoder).contramapN[Describe] { d => (d.variant, d.name) }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy