midas/task
Types
pub type Effect(a, key) {
Done(a)
Abort(Snag)
Bundle(
module: String,
function: String,
resume: fn(Result(String, String)) -> Effect(a, key),
)
ExportJsonWebKey(
key: key,
resume: fn(Result(json.Json, String)) -> Effect(a, key),
)
Follow(
uri: String,
resume: fn(Result(Uri, Nil)) -> Effect(a, key),
)
Fetch(
request: Request(BitArray),
resume: fn(Result(Response(BitArray), FetchError)) ->
Effect(a, key),
)
GenerateKeyPair(
algorithm: KeyPairAlgorithm,
extractable: Bool,
usages: List(KeyUsage),
resume: fn(Result(KeyPair(key), String)) -> Effect(a, key),
)
Hash(
algorithm: HashAlgorithm,
bytes: BitArray,
resume: fn(Result(BitArray, String)) -> Effect(a, key),
)
List(
directory: String,
resume: fn(Result(List(String), String)) -> Effect(a, key),
)
Log(
message: String,
resume: fn(Result(Nil, Nil)) -> Effect(a, key),
)
Read(
file: String,
resume: fn(Result(BitArray, String)) -> Effect(a, key),
)
Serve(
port: Option(Int),
handle: fn(Request(BitArray)) -> Response(BitArray),
resume: fn(Result(Nil, String)) -> Effect(a, key),
)
Sign(
algorithm: SignAlgorithm,
key: key,
data: BitArray,
resume: fn(Result(BitArray, String)) -> Effect(a, key),
)
StrongRandom(
length: Int,
resume: fn(Result(BitArray, String)) -> Effect(a, key),
)
Write(
file: String,
bytes: BitArray,
resume: fn(Result(Nil, String)) -> Effect(a, key),
)
Visit(
uri: Uri,
resume: fn(Result(Nil, String)) -> Effect(a, key),
)
Zip(
files: List(#(String, BitArray)),
resume: fn(Result(BitArray, Nil)) -> Effect(a, key),
)
UnixNow(resume: fn(Int) -> Effect(a, key))
}
Constructors
-
Done(a)
-
Abort(Snag)
-
Bundle( module: String, function: String, resume: fn(Result(String, String)) -> Effect(a, key), )
-
ExportJsonWebKey( key: key, resume: fn(Result(json.Json, String)) -> Effect(a, key), )
-
Follow( uri: String, resume: fn(Result(Uri, Nil)) -> Effect(a, key), )
-
Fetch( request: Request(BitArray), resume: fn(Result(Response(BitArray), FetchError)) -> Effect(a, key), )
-
GenerateKeyPair( algorithm: KeyPairAlgorithm, extractable: Bool, usages: List(KeyUsage), resume: fn(Result(KeyPair(key), String)) -> Effect(a, key), )
-
Hash( algorithm: HashAlgorithm, bytes: BitArray, resume: fn(Result(BitArray, String)) -> Effect(a, key), )
-
List( directory: String, resume: fn(Result(List(String), String)) -> Effect(a, key), )
-
Log( message: String, resume: fn(Result(Nil, Nil)) -> Effect(a, key), )
-
Read( file: String, resume: fn(Result(BitArray, String)) -> Effect(a, key), )
-
Serve( port: Option(Int), handle: fn(Request(BitArray)) -> Response(BitArray), resume: fn(Result(Nil, String)) -> Effect(a, key), )
-
Sign( algorithm: SignAlgorithm, key: key, data: BitArray, resume: fn(Result(BitArray, String)) -> Effect(a, key), )
-
StrongRandom( length: Int, resume: fn(Result(BitArray, String)) -> Effect(a, key), )
-
Write( file: String, bytes: BitArray, resume: fn(Result(Nil, String)) -> Effect(a, key), )
-
Visit( uri: Uri, resume: fn(Result(Nil, String)) -> Effect(a, key), )
-
Zip( files: List(#(String, BitArray)), resume: fn(Result(BitArray, Nil)) -> Effect(a, key), )
-
UnixNow(resume: fn(Int) -> Effect(a, key))
pub type FetchError {
NetworkError(String)
UnableToReadBody
NotImplemented
}
Constructors
-
NetworkError(String)
-
UnableToReadBody
-
NotImplemented
pub type HashAlgorithm {
SHA1
SHA256
SHA384
SHA512
}
Constructors
-
SHA1
-
SHA256
-
SHA384
-
SHA512
pub type KeyPair(key) {
KeyPair(public: key, private: key)
}
Constructors
-
KeyPair(public: key, private: key)
pub type KeyPairAlgorithm {
EcKeyGenParams(name: String, named_curve: String)
}
Constructors
-
EcKeyGenParams(name: String, named_curve: String)
pub type KeyUsage {
CanEncrypt
CanDecrypt
CanSign
CanVerify
CanDeriveKey
CanDeriveBits
CanWrapKey
CanUnwrapKey
}
Constructors
-
CanEncrypt
-
CanDecrypt
-
CanSign
-
CanVerify
-
CanDeriveKey
-
CanDeriveBits
-
CanWrapKey
-
CanUnwrapKey
pub type SignAlgorithm {
EcdsaParams(hash: HashAlgorithm)
}
Constructors
-
EcdsaParams(hash: HashAlgorithm)
Values
pub fn expect_abort(
task: Effect(a, b),
) -> Result(Snag, Effect(a, b))
pub fn expect_bundle(
task: Effect(a, b),
) -> Result(
#(String, String, fn(Result(String, String)) -> Effect(a, b)),
Effect(a, b),
)
pub fn expect_done(task: Effect(a, b)) -> Result(a, Effect(a, b))
pub fn expect_export_jwk(
task: Effect(a, b),
) -> Result(
#(b, fn(Result(Json, String)) -> Effect(a, b)),
Effect(a, b),
)
pub fn expect_fetch(
task: Effect(a, b),
) -> Result(
#(
Request(BitArray),
fn(Result(Response(BitArray), FetchError)) -> Effect(a, b),
),
Effect(a, b),
)
pub fn expect_follow(
task: Effect(a, b),
) -> Result(
#(String, fn(Result(Uri, Nil)) -> Effect(a, b)),
Effect(a, b),
)
pub fn expect_generate_keypair(
task: Effect(a, b),
) -> Result(
#(
KeyPairAlgorithm,
Bool,
List(KeyUsage),
fn(Result(KeyPair(b), String)) -> Effect(a, b),
),
Effect(a, b),
)
pub fn expect_hash(
task: Effect(a, b),
) -> Result(
#(
HashAlgorithm,
BitArray,
fn(Result(BitArray, String)) -> Effect(a, b),
),
Effect(a, b),
)
pub fn expect_list(
task: Effect(a, b),
) -> Result(
#(String, fn(Result(List(String), String)) -> Effect(a, b)),
Effect(a, b),
)
pub fn expect_log(
task: Effect(a, b),
) -> Result(
#(String, fn(Result(Nil, Nil)) -> Effect(a, b)),
Effect(a, b),
)
pub fn expect_read(
task: Effect(a, b),
) -> Result(
#(String, fn(Result(BitArray, String)) -> Effect(a, b)),
Effect(a, b),
)
pub fn expect_serve(
task: Effect(a, b),
) -> Result(
#(
Option(Int),
fn(Request(BitArray)) -> Response(BitArray),
fn(Result(Nil, String)) -> Effect(a, b),
),
Effect(a, b),
)
pub fn expect_sign(
task: Effect(a, b),
) -> Result(
#(
SignAlgorithm,
b,
BitArray,
fn(Result(BitArray, String)) -> Effect(a, b),
),
Effect(a, b),
)
pub fn expect_strong_random(
task: Effect(a, b),
) -> Result(
#(Int, fn(Result(BitArray, String)) -> Effect(a, b)),
Effect(a, b),
)
pub fn expect_unix_now(
task: Effect(a, b),
) -> Result(fn(Int) -> Effect(a, b), Effect(a, b))
pub fn expect_visit(
task: Effect(a, b),
) -> Result(
#(Uri, fn(Result(Nil, String)) -> Effect(a, b)),
Effect(a, b),
)
pub fn expect_write(
task: Effect(a, b),
) -> Result(
#(String, BitArray, fn(Result(Nil, String)) -> Effect(a, b)),
Effect(a, b),
)
pub fn expect_zip(
task: Effect(a, b),
) -> Result(
#(
List(#(String, BitArray)),
fn(Result(BitArray, Nil)) -> Effect(a, b),
),
Effect(a, b),
)
pub fn export_jwk(key: a) -> Effect(Json, a)
pub fn generate_keypair(
algorithm: KeyPairAlgorithm,
extractable: Bool,
usages: List(KeyUsage),
) -> Effect(KeyPair(a), a)
pub fn proxy(
task: Effect(a, b),
scheme: Scheme,
host: String,
port: Option(Int),
prefix: String,
) -> Effect(a, b)
pub fn sequential(
tasks: List(Effect(a, b)),
) -> Effect(List(a), b)
pub fn serve(
port: Option(Int),
handle: fn(Request(BitArray)) -> Response(BitArray),
) -> Effect(Nil, a)
pub fn serve_static(
port: Option(Int),
files: List(#(String, BitArray)),
) -> Effect(Nil, a)
pub fn strong_random(length: Int) -> Effect(BitArray, a)