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

org.plasmalabs.sdk.display.package.scala Maven / Gradle / Ivy

The newest version!
package org.plasmalabs.sdk

package object display
    extends UtxoDisplayOps
    with StxoDisplayOps
    with ValueDisplayOps
    with StructDisplayOps
    with AssetDisplayOps
    with GroupDisplayOps
    with SeriesDisplayOps
    with TransactionDisplayOps
    with QuivrDisplayOps
    with TypeIdentifierDisplayOps
    with ValidationErrorDisplayOps
    with BlockDisplayOps {

  val LabelLength = 27
  val Indent = 2

  def displayIndent(txt: String, indent: Int, prefix: String = " "): String = " " * indent + prefix + " " + txt

  def padLabel(label: String): String = {
    val padding = " " * (LabelLength - label.length).max(0)
    s"${label}${padding}: "
  }

  trait DisplayOps[T] {
    def display(t: T): String
  }

  object DisplayOps {
    def apply[T](implicit ev: DisplayOps[T]): DisplayOps[T] = ev

    implicit class DisplayTOps[T: DisplayOps](t: T) {
      def display: String = DisplayOps[T].display(t)
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy