all repos — omglolrs @ 9535448b3a70e382bf2254a18a4037faac432bb7

A Rust wrapper for api.omg.lol.

Initial commit
Gil Poiares-Oliveira gil@poiares-oliveira.com
Sun, 23 Apr 2023 21:53:17 +0000
commit

9535448b3a70e382bf2254a18a4037faac432bb7

9 files changed, 2861 insertions(+), 0 deletions(-)

jump to
A .gitignore

@@ -0,0 +1,5 @@

+target +secretvars.sh +.DS_Store +.nova +.env
A Cargo.lock

@@ -0,0 +1,1200 @@

+# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bumpalo" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" + +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + +[[package]] +name = "dotenv" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" + +[[package]] +name = "email_address" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2153bd83ebc09db15bcbdc3e2194d901804952e3dc96967e1cd3b0c5c32d112" +dependencies = [ + "serde", +] + +[[package]] +name = "encoding_rs" +version = "0.8.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "errno" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" + +[[package]] +name = "futures-sink" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" + +[[package]] +name = "futures-task" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" + +[[package]] +name = "futures-util" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "h2" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17f8a914c2987b688368b5138aa05321db91f4090cf26118185672ad588bce21" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + +[[package]] +name = "http" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "hyper" +version = "0.14.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "ipnet" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" + +[[package]] +name = "itoa" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" + +[[package]] +name = "js-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.142" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" + +[[package]] +name = "linux-raw-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b085a4f2cde5781fc4b1717f2e86c62f5cda49de7ba99a7c2eae02b61c9064c" + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mio" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.45.0", +] + +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi 0.2.6", + "libc", +] + +[[package]] +name = "omglol" +version = "0.0.1" +dependencies = [ + "dotenv", + "email_address", + "reqwest", + "serde", + "serde_json", + "tokio", +] + +[[package]] +name = "once_cell" +version = "1.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" + +[[package]] +name = "openssl" +version = "0.10.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97ea2d98598bf9ada7ea6ee8a30fb74f9156b63bbe495d64ec2b87c269d2dda3" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "992bac49bdbab4423199c654a5515bd2a6c6a23bf03f2dd3bdb7e5ae6259bc69" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.2.16", + "smallvec", + "windows-sys 0.45.0", +] + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + +[[package]] +name = "proc-macro2" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + +[[package]] +name = "reqwest" +version = "0.11.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b71749df584b7f4cac2c426c127a7c785a5106cc98f7a8feb044115f0fa254" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rustix" +version = "0.37.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f79bef90eb6d984c72722595b5b1348ab39275a5e5123faca6863bf07d75a4e0" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.48.0", +] + +[[package]] +name = "ryu" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" + +[[package]] +name = "schannel" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +dependencies = [ + "windows-sys 0.42.0", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "security-framework" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.160" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.160" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "serde_json" +version = "1.0.96" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "socket2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall 0.3.5", + "rustix", + "windows-sys 0.45.0", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" +dependencies = [ + "autocfg", + "bytes", + "libc", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.45.0", +] + +[[package]] +name = "tokio-macros" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 1.0.109", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" + +[[package]] +name = "web-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +]
A Cargo.toml

@@ -0,0 +1,20 @@

+[package] +name = "omglol" +authors = ["Gil Poiares-Oliveira <gil@poiares-oliveira.com>"] +version = "0.0.1" +edition = "2021" +repository = "https://git.sr.ht/~gpo/omglolrs" +readme = "README.md" +description = """ +A wraper for api.omg.lol for your Rust masterpieces. +""" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +reqwest = { version = "0.11", features = ["json"] } +tokio = { version = "1", features = ["full"] } +serde = { version = "1.0", features = ["derive"] } +serde_json = { version = "1.0"} +email_address = { version = "0.2.4" } +dotenv = { version = "0.15.0" }
A LICENSE

@@ -0,0 +1,373 @@

+Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at https://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0.
A README.md

@@ -0,0 +1,37 @@

+# omglol crate for Rust +A asynchronous Rust wrapper for the omg.lol API by [Gil](https://gil.lol). + +> **Warning**: **This is a work in progress** +> +> Unstable and bug-prone. Endpoints may change. Upstream endpoints under development. + +Repos: [sourcehut (canonical)](https://git.sr.ht/~gpo/omglolrs) | [GitLab](https://gitlab.com/GilOliveira/omg.lol.rs) | [GitHub](https://github.com/GilOliveira/omglolrs) + +LICENSE: MPL 2.0 (see [`LICENSE`](LICENSE)) + +## Examples + +### Get service status + +```rust +use omglol::client::OmglolClient; + +fn main() { + let response = OmglolClient::new(None()) + .get_service_status() + .await; + println!("{:#?}", response); +} +``` + +### Fetch a webpage +```rust +use omglol::client::OmglolClient; + +fn main() { + let response = OmglolClient::new(Some("YOUR_API_KEY_HERE")) + .get_web_page("your-address") + .await(); + println!("{:#?}", response); +} +```
A src/client.rs

@@ -0,0 +1,550 @@

+// SPDX-LICENSE-IDENTIFIER: MPL-2.0 + +/* +Client - omglol crate for Rust + +Copyright © 2023 Gil Poiares-Oliveira <gil@poiares-oliveira.com>. +All rights reserved. + +This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + If a copy of the MPL was not distributed with this file, + You can obtain one at https://mozilla.org/MPL/2.0/. +*/ + +use crate::email::format_addresses_string; +use crate::structures::*; +use email_address::EmailAddress; +use reqwest::{Client, Method}; +use serde::de::DeserializeOwned; +use serde_json; + +macro_rules! api_endpoint ( + ($path: expr) => ( + format!("{}{}", "https://api.omg.lol/", $path) + ); +); + +pub(crate) use api_endpoint; + +#[derive(Clone)] +pub struct OmglolClient { + client: Client, + api_key: Option<String>, +} + +/// OmglolClient allows you to make authenticated or unauthenticated REST API +/// requests. +impl OmglolClient { + /// Create a new OmglolClient. + /// + /// For an unauthenticated client (restricted to public endpoints only), use: + /// ```rust + /// let client = OmglolClient::new(None) + /// ``` + /// + /// For an authenticated client, use: + /// ```rust + /// let client = OmglolClient::new(Some("your_api_key_here".toString())) + pub fn new(api_key: Option<String>) -> OmglolClient { + OmglolClient { + client: Client::new(), + api_key, + } + } + + async fn send_request<T>( + &self, + authenticate: bool, + method: Method, + uri: &str, + body: Option<String>, + ) -> Result<RequestResponse<T>, Box<dyn std::error::Error>> + where + T: DeserializeOwned, + { + let reqwest_client = &self.client; + let mut req = reqwest_client.request(method, api_endpoint!(uri)); + + if authenticate { + req = req.bearer_auth(&self.api_key.as_ref().unwrap().to_string()); + } + + if body.is_some() { + req = req.body(body.unwrap()); + } + + #[cfg(debug_assertions)] + dbg!(&req); + + let resp = req.send().await?; + + let raw_res = match &resp.status().as_u16() { + _status_code @ 200 => resp.text().await?, + status_code => { + return Err(Box::new(RequestError { + status_code: *status_code, + })) + } + }; + + #[cfg(debug_assertions)] + dbg!(&raw_res); + + let res: RequestResponse<T> = serde_json::from_str(&raw_res).unwrap(); + + Ok(res) + } + + // Themes + pub async fn get_profile_themes( + &self, + ) -> Result<RequestResponse<ProfileThemes>, Box<dyn std::error::Error>> { + self.send_request::<ProfileThemes>(false, Method::GET, "theme/list", None) + .await + } + + pub async fn service_status( + &self, + ) -> Result<RequestResponse<ServiceStatus>, Box<dyn std::error::Error>> { + self.send_request::<ServiceStatus>(false, Method::GET, "service/info", None) + .await + } + + pub async fn get_dns_records( + &self, + address: &str, + ) -> Result<RequestResponse<DNSrecords>, Box<dyn std::error::Error>> { + self.send_request::<DNSrecords>( + true, + Method::GET, + format!("address/{}/dns", &address).as_ref(), + None, + ) + .await + } + + pub async fn delete_dns_record( + &self, + address: &str, + id: &str, + ) -> Result<RequestResponse<DNSrecords>, Box<dyn std::error::Error>> { + self.send_request::<DNSrecords>( + true, + Method::DELETE, + format!("address/{address}/dns/{id}").as_ref(), + None, + ) + .await + } + + // Statuslog + + pub async fn get_all_statuses( + &self, + address: &str, + ) -> Result<RequestResponse<StatuslogAllStatuses>, Box<dyn std::error::Error>> { + self.send_request::<StatuslogAllStatuses>( + true, + Method::GET, + format!("address/{}/statuses", &address).as_ref(), + None, + ) + .await + } + + pub async fn get_status( + &self, + address: &str, + id: &str, + ) -> Result<RequestResponse<StatuslogResponseArray>, Box<dyn std::error::Error>> { + self.send_request::<StatuslogResponseArray>( + true, + Method::GET, + format!("address/{}/statuses/{}", &address, &id).as_ref(), + None, + ) + .await + } + + pub async fn post_status( + &self, + status: &Status, + ) -> Result<RequestResponse<StatuslogResponseArray>, Box<dyn std::error::Error>> { + self.send_request::<StatuslogResponseArray>( + true, + Method::POST, + format!("address/{}/statuses", &status.address).as_ref(), + Some(serde_json::to_string(&status)?), + ) + .await + } + + pub async fn update_status( + &self, + status: &Status, + ) -> Result<RequestResponse<StatuslogUpdateResponse>, Box<dyn std::error::Error>> { + self.send_request::<StatuslogUpdateResponse>( + true, + Method::POST, + format!("address/{}/status", &status.address).as_ref(), + Some(serde_json::to_string(&status)?), + ) + .await + } + + pub async fn get_statuslog_bio( + &self, + address: &str, + ) -> Result<RequestResponse<StatuslogBio>, Box<dyn std::error::Error>> { + self.send_request::<StatuslogBio>( + false, + Method::GET, + format!("address/{}/statuses/bio", &address).as_ref(), + None, + ) + .await + } + + pub async fn update_statuslog_bio<T: ContentAsJSON>( + &self, + bio: T, + address: &str, + ) -> Result<RequestResponse<StatuslogBio>, Box<dyn std::error::Error>> { + self.send_request::<StatuslogBio>( + true, + Method::POST, + format!("address/{}/statuses/bio", &address).as_ref(), + Some(bio.json_content()), + ) + .await + } + + // Email + + pub async fn get_forwarding_addresses( + &self, + address: &str, + ) -> Result<RequestResponse<ForwardingAddresses>, Box<dyn std::error::Error>> { + self.send_request::<ForwardingAddresses>( + true, + Method::GET, + format!("address/{}/email", &address).as_ref(), + None, + ) + .await + } + + pub async fn set_forwarding_addresses( + &self, + address: &str, + destination: &Vec<EmailAddress>, + ) -> Result<RequestResponse<ForwardingAddresses>, Box<dyn std::error::Error>> { + self.send_request::<ForwardingAddresses>( + true, + Method::GET, + format!("address/{}/email", &address).as_ref(), + Some(format_addresses_string(destination)), + ) + .await + } + + // Pastebin + + pub async fn get_pastebin( + &self, + address: &str, + ) -> Result<RequestResponse<PastebinResponse>, Box<dyn std::error::Error>> { + self.send_request::<PastebinResponse>( + true, + Method::GET, + format!("address/{}/pastebin", &address).as_ref(), + None, + ) + .await + } + + pub async fn get_listed_pastes( + &self, + address: &str, + ) -> Result<RequestResponse<PastebinResponse>, Box<dyn std::error::Error>> { + self.send_request::<PastebinResponse>( + false, + Method::GET, + format!("address/{}/pastebin", &address).as_ref(), + None, + ) + .await + } + + pub async fn get_paste( + &self, + address: &str, + title: &str, + ) -> Result<RequestResponse<PasteResponse>, Box<dyn std::error::Error>> { + self.send_request::<PasteResponse>( + false, + Method::GET, + format!("address/{}/pastebin/{title}", &address).as_ref(), + None, + ) + .await + } + + pub async fn upload_paste( + &self, + address: &str, + paste: Paste, + ) -> Result<RequestResponse<PasteResponse>, Box<dyn std::error::Error>> { + self.send_request::<PasteResponse>( + false, + Method::POST, + format!("address/{}/pastebin", &address).as_ref(), + Some(serde_json::to_string(&paste)?), + ) + .await + } + + pub async fn delete_paste( + &self, + address: &str, + title: &str, + ) -> Result<RequestResponse<MessageResponse>, Box<dyn std::error::Error>> { + self.send_request::<MessageResponse>( + false, + Method::DELETE, + format!("address/{}/pastebin/{title}", &address).as_ref(), + None, + ) + .await + } + + pub async fn get_purl( + &self, + address: &str, + purl_address: &str, + ) -> Result<RequestResponse<PurlResponse>, Box<dyn std::error::Error>> { + self.send_request::<PurlResponse>( + true, + Method::GET, + format!("address/{}/purl/{purl_address}", &address).as_ref(), + None, + ) + .await + } + + pub async fn get_all_purls( + &self, + address: &str, + ) -> Result<RequestResponse<PurlsResponse>, Box<dyn std::error::Error>> { + self.send_request::<PurlsResponse>( + true, + Method::GET, + format!("address/{}/purls", &address).as_ref(), + None, + ) + .await + } + + pub async fn delete_purl( + &self, + address: &str, + purl_address: &str, + ) -> Result<RequestResponse<MessageResponse>, Box<dyn std::error::Error>> { + self.send_request::<MessageResponse>( + true, + Method::DELETE, + format!("address/{}/purl/{purl_address}", &address).as_ref(), + None, + ) + .await + } + + pub async fn get_account_info( + &self, + email: &EmailAddress, + ) -> Result<RequestResponse<AcccountResponse>, Box<dyn std::error::Error>> { + self.send_request::<AcccountResponse>( + true, + Method::GET, + format!("account/{}/info", email).as_ref(), + None, + ) + .await + } + + pub async fn get_public_address_info( + &self, + address: &str, + ) -> Result<RequestResponse<Address>, Box<dyn std::error::Error>> { + self.send_request::<Address>( + false, + Method::GET, + format!("account/{}/info", address).as_ref(), + None, + ) + .await + } + + pub async fn get_private_address_info( + &self, + address: &str, + ) -> Result<RequestResponse<Address>, Box<dyn std::error::Error>> { + self.send_request::<Address>( + true, + Method::GET, + format!("account/{}/info", address).as_ref(), + None, + ) + .await + } + + pub async fn get_address_expiration( + &self, + address: &str, + ) -> Result<RequestResponse<Expiration>, Box<dyn std::error::Error>> { + self.send_request::<Expiration>( + true, + Method::GET, + format!("account/{}/expiration", address).as_ref(), + None, + ) + .await + } + + pub async fn get_web_page( + &self, + address: &str, + ) -> Result<RequestResponse<Web>, Box<dyn std::error::Error>> { + self.send_request::<Web>( + true, + Method::GET, + format!("address/{}/web", address).as_ref(), + None, + ) + .await + } + + pub async fn update_web_page( + &self, + web: &Web, + address: &str, + ) -> Result<RequestResponse<MessageResponse>, Box<dyn std::error::Error>> { + self.send_request::<MessageResponse>( + true, + Method::POST, + format!("address/{}/web", address).as_ref(), + Some(serde_json::to_string(&web)?), + ) + .await + } + + pub async fn get_weblog_entry( + &self, + entry_id: &str, + address: &str, + ) -> Result<RequestResponse<WeblogEntryResponse>, Box<dyn std::error::Error>> { + self.send_request::<WeblogEntryResponse>( + true, + Method::GET, + format!("address/{}/weblog/entry/{}", address, entry_id).as_ref(), + None, + ) + .await + } + + pub async fn delete_weblog_entry( + &self, + entry_id: &str, + address: &str, + ) -> Result<RequestResponse<MessageResponse>, Box<dyn std::error::Error>> { + self.send_request::<MessageResponse>( + true, + Method::DELETE, + format!("address/{}/weblog/delete/{}", address, entry_id).as_ref(), + None, + ) + .await + } + + pub async fn get_weblog_configuration( + &self, + address: &str, + ) -> Result<RequestResponse<WeblogConfigurationResponse>, Box<dyn std::error::Error>> { + self.send_request::<WeblogConfigurationResponse>( + true, + Method::GET, + format!("address/{}/weblog/configuration", address).as_ref(), + None, + ) + .await + } + + pub async fn get_weblog_template( + &self, + address: &str, + ) -> Result<RequestResponse<WeblogTemplateResponse>, Box<dyn std::error::Error>> { + self.send_request::<WeblogTemplateResponse>( + true, + Method::GET, + format!("address/{}/weblog/template", address).as_ref(), + None, + ) + .await + } + + pub async fn update_weblog_template( + &self, + template: &str, + address: &str, + ) -> Result<RequestResponse<WeblogTemplateResponse>, Box<dyn std::error::Error>> { + self.send_request::<WeblogTemplateResponse>( + true, + Method::POST, + format!("address/{}/weblog/template", address).as_ref(), + Some(template.to_string()), + ) + .await + } + + pub async fn get_latest_weblog_post( + &self, + address: &str, + ) -> Result<RequestResponse<WeblogEntryResponse>, Box<dyn std::error::Error>> { + self.send_request::<WeblogEntryResponse>( + true, + Method::GET, + format!("address/{}/weblog/post/latest", address).as_ref(), + None, + ) + .await + } + + pub async fn create_weblog_entry( + &self, + content: &str, + entry_id: &str, + address: &str, + ) -> Result<RequestResponse<WeblogEntryResponse>, Box<dyn std::error::Error>> { + self.send_request::<WeblogEntryResponse>( + true, + Method::POST, + format!("address/{}/weblog/entry/{}", address, entry_id).as_ref(), + Some(content.to_string()), + ) + .await + } + + pub async fn update_weblog_configuration( + &self, + configuration: &str, + address: &str, + ) -> Result<RequestResponse<WeblogEntryResponse>, Box<dyn std::error::Error>> { + self.send_request::<WeblogEntryResponse>( + true, + Method::POST, + format!("address/{}/weblog/template", address).as_ref(), + Some(configuration.to_string()), + ) + .await + } +}
A src/email.rs

@@ -0,0 +1,38 @@

+// SPDX-LICENSE-IDENTIFIER: MPL-2.0 + +/* +Email - omglol crate for Rust + +Copyright © 2023 Gil Poiares-Oliveira <gil@poiares-oliveira.com>. +All rights reserved. + +This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + If a copy of the MPL was not distributed with this file, + You can obtain one at https://mozilla.org/MPL/2.0/. +*/ + +use email_address::EmailAddress; + +/// Format a `Vec<EmailAddress>` to a String in the JSON format the API expects +/// +/// # Arguments +/// * `addresses` - A `Vec<EmailAddress>` containing the forwarding email address(es) +/// # Output +/// `String` in the JSON format the API endpoint expects +pub fn format_addresses_string(addresses: &Vec<EmailAddress>) -> String { + // This code is will probably make any serious Rust developer hide in shame + // but the endpoint expects a weird format and... well, if it works... + let mut body_string = String::from(format!("{{\"destination\": \"")); + body_string.push_str(&addresses[0].to_string().as_str()); + + if addresses.len() > 1 { + for address in addresses { + body_string.push_str(", "); + body_string.push_str(&address.as_str()); + } + } + + body_string.push_str("\"}"); + + return body_string; +}
A src/lib.rs

@@ -0,0 +1,108 @@

+// SPDX-LICENSE-IDENTIFIER: MPL-2.0 + +/* +omglol crate for Rust + +Copyright © 2023 Gil Poiares-Oliveira <gil@poiares-oliveira.com>. +All rights reserved. + +This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + If a copy of the MPL was not distributed with this file, + You can obtain one at https://mozilla.org/MPL/2.0/. +*/ + +#![doc = include_str!("../README.md")] + +//pub mod requests; +pub mod client; +pub mod email; + +#[allow(dead_code)] +pub mod structures; + +pub use client::OmglolClient; + +#[cfg(test)] +mod tests { + use super::*; + use std::env; + + // These tests are just for debugging, no proper test-driven development here + // don't use this for anything + + fn init_client() -> (OmglolClient, String) { + use dotenv::dotenv; + dotenv().ok(); + let address = env::var("OMGLOL_ADDRESS").unwrap_or("foobar".to_string()); + let api_key = env::var("OMGLOL_API_KEY").unwrap_or("".to_string()); + let client = OmglolClient::new(Some(api_key)); + println!("Using account {} for testing", &address); + + return (client, address); + } + + #[tokio::test] + async fn main() { + // If you're learning Rust best practices, maybe you should ignore the next + // 2 lines. This is a test function so does anyone *actually* care? + + //let info = client.get_profile_themes().await; + + //println!("{:#?}", info); + + //let info = requests::dns::get_dns_records(&address, &api_key).await; + // let info = requests::themes::get_profile_themes().await; + // let info = get_statuslog_status(&address, "63a8a6b3cbdc5").await; + // let info = get_all_statuslog_statuses(&address).await; + + //let my_client = OmglolClient::new(address, api_key=api_key); + + // let destinations = vec![ + // EmailAddress::from_str("foo@example.net").unwrap(), + // EmailAddress::from_str("bar@example.net").unwrap(), + // ]; + // let info = + // requests::email::set_forwarding_addresses(&address, &destinations, &api_key).await; + //println!("response = {:#?}", info); + } + + #[tokio::test] + async fn get_service_status() { + let (client, _) = init_client(); + let service_status = client.service_status().await; + println!("{:#?}", service_status); + } + + #[tokio::test] + async fn get_profile_themes() { + let (client, _) = init_client(); + let info = client.get_profile_themes().await; + println!("{:#?}", info); + } + + #[tokio::test] + async fn get_dns_records() { + let (client, address) = init_client(); + let response = client.get_dns_records(&address).await; + println!("{:#?}", response); + } + + #[tokio::test] + async fn get_web_page() { + let (client, address) = init_client(); + let response = client.get_web_page(&address).await; + println!("{:#?}", response); + } + + #[tokio::test] + async fn query_unauthorized_endpoint() { + let (client, _) = init_client(); + let response = client.get_web_page("foobar").await; + println!("{:#?}", response); + } + + #[test] + fn dns_display() { + assert!(format!("{}", structures::DNStype::A) == "A"); + } +}
A src/structures.rs

@@ -0,0 +1,530 @@

+// SPDX-LICENSE-IDENTIFIER: MPL-2.0 + +/* +Strucutures - omglol crate for Rust + +Copyright © 2023 Gil Poiares-Oliveira <gil@poiares-oliveira.com>. +All rights reserved. + +This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. + If a copy of the MPL was not distributed with this file, + You can obtain one at https://mozilla.org/MPL/2.0/. +*/ + +//! Structures corresponding to various API elements + +use serde::{Deserialize, Serialize}; +use std::{collections::HashMap, error::Error, fmt, fmt::Display}; + +// fn return_true() -> bool { +// // This is the world's more useful function /s +// // #[serde(default)] needs a function to be supplied. +// true + +#[derive(Deserialize, Debug)] +pub struct AcccountResponse { + message: String, + email: String, + name: String, + api_key: String, + created: TimeStrings, + settings: AccountSettings, +} + +#[derive(Deserialize, Debug)] +pub struct AccountSettings { + owner: String, + communication: Option<String>, // IMPROVEMENT: Remove "Option" if patched upstream + date_format: Option<String>, // https://github.com/neatnik/omg.lol/issues/613 + web_editor: String, +} + +#[derive(Deserialize, Debug)] +pub struct Verification { + message: String, + pub verified: bool, +} + +/// Address expiration time in different string formats +#[derive(Deserialize, Debug)] +pub struct Expiration { + message: String, + pub expired: bool, + pub will_expire: Option<bool>, + pub unix_epoch_time: Option<String>, + pub iso_8601_time: Option<String>, + pub rfc_2822_time: Option<String>, + pub relative_time: Option<String>, +} + +/// omg.lol address +#[derive(Deserialize, Debug)] +pub struct Address { + address: String, + message: String, + registration: TimeStrings, + expiration: Expiration, + verification: Verification, + owner: Option<String>, +} + +/// Successful DNS records request response +#[derive(Deserialize, Debug)] +pub struct DNSrecords { + message: String, + dns: Vec<DNSrecord>, +} + +/// DNS record +#[derive(Deserialize, Debug)] +pub struct DNSrecord { + pub id: i32, + pub name: String, + pub data: String, + pub priority: Option<i32>, + pub ttl: i32, + pub created_at: Option<String>, + pub updated_at: Option<String>, + + #[serde(rename = "type")] + pub record_type: DNStype, +} + +/// DNS record types supported by omg.lol DNS routing. +#[derive(Deserialize, Debug)] +pub enum DNStype { + A, + AAA, + CAA, + CNAME, + MX, + NS, + SRV, + TXT, +} + +impl Display for DNStype { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{:?}", &self) + } +} + +/// Forwarding addresses for your @omg.lol email address +#[derive(Deserialize, Debug)] +pub struct ForwardingAddresses { + message: String, + destination_string: String, + destination_array: Vec<String>, + address: String, + email_address: String, +} + +#[derive(Deserialize, Debug)] +pub struct MessageResponse { + message: String, +} + +/// Response to a REST API request. +#[derive(Deserialize, Debug)] +pub struct RequestResponse<T> { + pub request: RequestStatus, + pub response: T, +} + +#[derive(Deserialize, Debug)] +pub struct RequestStatus { + /// HTTP status code of the request response + pub status_code: u16, + /// `true` if request completed successfully, `false` otherwise. + pub success: bool, +} + +/// String representations of a moment in time according to different protocols. +#[derive(Deserialize, Debug)] +pub struct TimeStrings { + /// String of seconds elapsed since the UNIX epoch (1970-01-01 00:00:00 UTC) + pub unix_epoch_time: String, + /// Time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. + pub iso_8601_time: String, + /// Time in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. + pub rfc_2822_time: String, + /// Relative time string, e.g. "20 minutes ago". + pub relative_time: String, + /// Message provided by the API server in respnse to some requests. + pub message: Option<String>, +} + +#[derive(Deserialize, Debug)] +pub struct NowResponse { + message: String, + now: Vec<NowPage>, +} + +#[derive(Deserialize, Debug)] +pub struct NowPage { + content: String, + updated: u32, + listed: u8, + nudge: u8, + metadata: String, +} + +#[derive(Deserialize, Debug)] +pub struct NowGardenResponse { + message: String, + garden: Vec<NowGarden>, +} + +#[derive(Deserialize, Debug)] +pub struct NowGarden { + address: String, + url: String, + updated: TimeStrings, +} + +#[derive(Deserialize, Debug)] +pub struct Token { + access_token: String, + token_type: String, + scope: String, +} + +#[derive(Deserialize, Debug)] +pub struct PasteResponse { + message: String, + pastebin: Paste, +} + +#[derive(Deserialize, Debug)] +pub struct PastebinResponse { + message: String, + success: Vec<Paste>, +} + +/// Pastebin paste +#[derive(Deserialize, Serialize, Debug)] +pub struct Paste { + pub title: String, + pub content: String, + + #[serde(skip_serializing)] + modified_on: Option<String>, +} + +impl Paste { + /// New instance of `Paste` + pub fn new(title: String, content: String) -> Paste { + Paste { + title, + content, + modified_on: None, + } + } +} + +#[derive(Deserialize, Debug)] +pub struct PurlResponse { + message: String, + purl: Purl, +} + +#[derive(Deserialize, Debug)] +pub struct PurlsResponse { + message: String, + purls: Vec<Purl>, +} + +#[derive(Deserialize, Debug)] +pub struct Purl { + name: String, + url: String, + counter: Option<i32>, +} + +#[derive(Deserialize, Debug)] +pub struct ServiceStatus { + message: String, + members: i32, + addresses: i32, + profiles: i32, +} + +pub trait ContentAsJSON { + fn json_content(&self) -> String { + panic!("Error converting to JSON content.") + } +} + +impl ContentAsJSON for String { + fn json_content(&self) -> String { + format!("{{\"content\": \"{}\"}}", &self) + } +} + +#[derive(Deserialize, Debug)] +pub struct StatuslogResponseArray { + message: String, + id: String, + status: Status, +} + +#[derive(Deserialize, Debug)] +pub struct StatuslogUpdateResponse { + message: String, + id: String, + url: String, +} + +/// Response struct for a successful statuslog query all statuses request +#[derive(Deserialize, Debug)] +pub struct StatuslogAllStatuses { + message: String, + statuses: Vec<Status>, +} + +#[derive(Deserialize, Serialize, Debug)] +pub struct Status { + /// A status log entry. + pub emoji: char, + pub content: String, + pub external_url: Option<String>, + + #[serde(skip_serializing)] + id: String, + + #[serde(skip_serializing)] + pub address: String, + + #[serde(skip_serializing)] + created: String, + + #[serde(skip_serializing)] + relative_time: String, +} + +impl Status { + /// Create a new instance of `Status` + /// + /// Arguments: + /// * `emoji`, your status' emoji + /// * `content`, The text content of your status + /// * `external_url`, An optional external URL for your status + pub fn new(emoji: char, content: String, external_url: Option<String>) -> Status { + Status { + emoji, + content, + external_url, + id: "".to_string(), + address: "".to_string(), + created: "".to_string(), + relative_time: "".to_string(), + } + } +} + +/// Your statuslog's bio. +#[derive(Deserialize, Serialize, Debug)] +pub struct StatuslogBio { + bio: String, + + #[serde(skip_serializing)] + css: String, + + #[serde(skip_serializing)] + message: String, +} + +impl StatuslogBio { + /// Create a new `StatuslogBio` struct. + /// + /// Arguments: + /// * `bio: String` the text content of your bio + pub fn new(bio: String) -> StatuslogBio { + StatuslogBio { + bio, + css: "".to_string(), + message: "".to_string(), + } + } +} + +impl ContentAsJSON for StatuslogBio { + fn json_content(&self) -> String { + format!("{{\"content\": \"{}\"}}", &self.message) + } +} + +#[derive(Deserialize, Debug)] +pub struct StatusPostResponse { + message: String, + id: String, + status: String, + url: String, + external_url: String, +} + +#[derive(Deserialize, Debug)] +pub struct ProfileThemes { + message: String, + themes: HashMap<String, Theme>, +} + +#[derive(Deserialize, Debug)] +pub struct Theme { + id: String, + name: String, + created: String, + updated: String, + author: String, + author_url: String, + version: String, + license: String, + description: String, + preview_css: String, + sample_profile: String, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct Web { + pub content: String, + + /// Status message provided by the API + #[serde(skip_serializing)] + pub message: String, + + /// CSS profile code + #[serde(skip_serializing)] + pub css: String, + + /// Additional `<head>` elements + #[serde(skip_serializing)] + pub head: String, + + /// Weather the profile has been [verified](https://home.omg.lol/info/profile-verification). + #[serde(skip_serializing)] + pub verified: Option<i8>, + + /// Profile picture, `Some` with a URL `String` or `None` if not defined. + #[serde(skip_serializing)] + pub pfp: Option<String>, + + #[serde(skip_serializing)] + pub metadata: String, + + #[serde(skip_serializing)] + pub branding: String, + + #[serde(rename(deserialize = "type"), skip_serializing)] + pub page_type: String, + // Publish currently does not do anything + //#[serde(skip_deserializing, default = "return_true")] + //pub publish: bool, +} + +impl Web { + /// Create a new `Web` struct. + /// + /// Arguments: + /// * `content: String` with the web page content. + pub fn new(content: String) -> Web { + Web { + //publish, + content, + message: " ".to_string(), + css: "".to_string(), + head: "".to_string(), + verified: None, + pfp: None, + metadata: "".to_string(), + branding: "".to_string(), + page_type: "".to_string(), + } + } +} + +#[derive(Deserialize, Debug)] +pub struct WeblogEntriesResponse { + message: String, + entries: Vec<WeblogEntry>, +} + +#[derive(Deserialize, Debug)] +pub struct WeblogEntryResponse { + message: String, + + #[serde(alias = "post")] + entry: WeblogEntry, +} + +#[derive(Deserialize, Debug)] +pub struct WeblogEntry { + location: String, + title: String, + date: u32, + status: String, + body: String, + source: String, + metadata: WeblogMetadata, + output: String, + entry: String, + + #[serde(rename(deserialize = "type"))] + entry_type: String, +} + +#[derive(Deserialize, Debug)] +pub struct WeblogMetadata { + date: String, + slug: String, +} + +#[derive(Deserialize, Debug)] +pub struct WeblogConfigurationResponse { + message: String, + configuration: WeblogConfigurationFormats, +} + +#[derive(Deserialize, Debug)] +pub struct WeblogConfigurationFormats { + object: WeblogConfiguration, + json: String, + raw: String, +} + +#[derive(Deserialize, Debug)] +pub struct WeblogConfiguration { + pub weblog_title: String, + pub weblog_description: String, + pub author: String, + pub separator: String, + pub tag_path: String, + pub timezone: String, + pub date_format: String, + pub default_post: String, + pub feed_post_count: String, + pub recents_posts_format: String, + pub post_list_format: String, + pub search_satus: String, + pub search_status_success_message: String, + pub search_results_failure_message: String, + pub search_results_format: String, +} + +#[derive(Deserialize, Debug)] +pub struct WeblogTemplateResponse { + pub message: String, + pub template: String, +} + +#[derive(Debug, Clone)] +pub struct RequestError { + pub status_code: u16, +} + +impl Error for RequestError {} + +impl fmt::Display for RequestError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Request error. HTTP status code: {}.", &self.status_code) + } +}