Updated odcs
All checks were successful
/ Build and Test Library Snapshot (pull_request) Successful in 1m17s
All checks were successful
/ Build and Test Library Snapshot (pull_request) Successful in 1m17s
This commit is contained in:
parent
9bd5fbb92e
commit
95abad880d
2 changed files with 57 additions and 2 deletions
|
@ -48,5 +48,6 @@ jobs:
|
||||||
sbtn coverageReport
|
sbtn coverageReport
|
||||||
- name: 'Publish Snapshot'
|
- name: 'Publish Snapshot'
|
||||||
run: |
|
run: |
|
||||||
|
echo "Testing env var propagation = '$GS_RELEASE_TYPE'"
|
||||||
sbtn clean
|
sbtn clean
|
||||||
sbtn publish
|
sbtn publish
|
||||||
|
|
58
README.md
58
README.md
|
@ -1,13 +1,20 @@
|
||||||
# gs-hex
|
# gs-hex
|
||||||
|
|
||||||
[License (Apache 2.0)](./LICENSE)
|
[GS Open Source](https://garrity.co/oss.html) |
|
||||||
|
[License (MIT)](./LICENSE)
|
||||||
|
|
||||||
Hexadecimal conversions for Scala 3. Provides support for standard types.
|
Hexadecimal conversions for Scala 3. Provides support for standard types.
|
||||||
|
|
||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
|
- [Dependency](#dependency)
|
||||||
|
- [Byte Array Conversion](#byte-array-conversion)
|
||||||
|
- [Type Classes](#type-classes)
|
||||||
|
- [Donate](#donate)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
### Dependency
|
||||||
|
|
||||||
This artifact is available in the Garrity Software Maven repository.
|
This artifact is available in the Garrity Software Maven repository.
|
||||||
|
|
||||||
```scala
|
```scala
|
||||||
|
@ -15,5 +22,52 @@ externalResolvers +=
|
||||||
"Garrity Software Releases" at "https://maven.garrity.co/releases"
|
"Garrity Software Releases" at "https://maven.garrity.co/releases"
|
||||||
|
|
||||||
val GsHex: ModuleID =
|
val GsHex: ModuleID =
|
||||||
"gs" %% "gs-hex-v0" % "0.1.0"
|
"gs" %% "gs-hex-v0" % "$VERSION"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Byte Array Conversion
|
||||||
|
|
||||||
|
This library is based on two functions: `Hex.toHexString(Array[Byte])` and
|
||||||
|
`Hex.fromHexString(String)`.
|
||||||
|
|
||||||
|
```scala
|
||||||
|
import gs.hex.v0.Hex
|
||||||
|
|
||||||
|
val data: Array[Byte] = ???
|
||||||
|
val encoded: String = Hex.toHexString(data)
|
||||||
|
val decoded: Option[Array[Byte]] = Hex.fromHexString(encoded)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Type Classes
|
||||||
|
|
||||||
|
This library provides `HexEncode[A]` and `HexDecode[A]` for encoding and
|
||||||
|
decoding arbitrary types as Hexadecimal strings. The types `Array[Byte]`,
|
||||||
|
`String`, `Boolean`, `Int` and `Long` are supported by default.
|
||||||
|
|
||||||
|
#### Example Type Class Implementations
|
||||||
|
|
||||||
|
```scala
|
||||||
|
given HexEncode[Array[Byte]] = new HexEncode[Array[Byte]] {
|
||||||
|
def toHexString(data: Array[Byte]): String = Hex.toHexString(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
given HexDecode[Array[Byte]] = new HexDecode[Array[Byte]] {
|
||||||
|
def fromHexString(data: String): Option[Array[Byte]] =
|
||||||
|
Hex.fromHexString(data)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Example Type Class Usage
|
||||||
|
|
||||||
|
```scala
|
||||||
|
def encode[A](data: A)(using HexEncode[A]): String =
|
||||||
|
data.toHex()
|
||||||
|
|
||||||
|
def decode[A](data: String)(using HexDecode[A]): Option[A] =
|
||||||
|
data.fromHex()
|
||||||
|
```
|
||||||
|
|
||||||
|
## Donate
|
||||||
|
|
||||||
|
Enjoy this project or want to help me achieve my [goals](https://garrity.co)?
|
||||||
|
Consider [Donating to Pat on Ko-fi](https://ko-fi.com/gspfm).
|
||||||
|
|
Loading…
Add table
Reference in a new issue