pax_global_header00006660000000000000000000000064150124354140014511gustar00rootroot0000000000000052 comment=4177e028f3947064f272d3c33627bb7e9b4c98af edu-sync-0.3.2/000077500000000000000000000000001501243541400132425ustar00rootroot00000000000000edu-sync-0.3.2/.github/000077500000000000000000000000001501243541400146025ustar00rootroot00000000000000edu-sync-0.3.2/.github/workflows/000077500000000000000000000000001501243541400166375ustar00rootroot00000000000000edu-sync-0.3.2/.github/workflows/ci.yml000066400000000000000000000015551501243541400177630ustar00rootroot00000000000000name: CI on: push: pull_request: env: RUSTFLAGS: -Dwarnings RUSTDOCFLAGS: -Dwarnings jobs: clippy: name: Clippy runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - run: cargo clippy --all-targets --all-features doc: name: Check documentation runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - run: cargo doc --no-deps fmt: name: Check format runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly with: components: rustfmt - run: cargo fmt -- --check test: name: Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - run: cargo test edu-sync-0.3.2/.github/workflows/release.yml000066400000000000000000000021321501243541400210000ustar00rootroot00000000000000name: Release on: push: tags: - 'v*.*.*' env: GH_TOKEN: ${{ github.token }} defaults: run: shell: bash jobs: release: runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-22.04, macos-14, macos-13, windows-2019] steps: - uses: actions/checkout@v4 - run: gh release create ${GITHUB_REF#refs/tags/} --draft --title ${GITHUB_REF#refs/tags/v} if: startsWith(matrix.os, 'ubuntu') - uses: dtolnay/rust-toolchain@stable - run: cargo build --release - name: Create archive run: | VERSION=${GITHUB_REF#refs/tags/} HOST=$(rustc -vV | sed -n 's|host: ||p') DIST=edu-sync-cli-$VERSION-$HOST mkdir $DIST if [ "${{ matrix.os }}" = windows-2019 ]; then mv target/release/edu-sync-cli.exe $DIST 7z a $DIST.zip $DIST echo "FILE=$DIST.zip" >> $GITHUB_ENV else mv target/release/edu-sync-cli $DIST tar czf $DIST.tar.gz $DIST echo "FILE=$DIST.tar.gz" >> $GITHUB_ENV fi - run: gh release upload ${GITHUB_REF#refs/tags/} $FILE edu-sync-0.3.2/.gitignore000066400000000000000000000000101501243541400152210ustar00rootroot00000000000000/target edu-sync-0.3.2/Cargo.lock000066400000000000000000001750461501243541400151640ustar00rootroot00000000000000# This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 4 [[package]] name = "addr2line" version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] name = "adler2" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aho-corasick" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "android-tzdata" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" [[package]] name = "android_system_properties" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" dependencies = [ "libc", ] [[package]] name = "anstream" version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", "once_cell", "windows-sys 0.59.0", ] [[package]] name = "anyhow" version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "autocfg" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" version = "0.3.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" dependencies = [ "addr2line", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", "windows-targets 0.52.6", ] [[package]] name = "base64" version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" [[package]] name = "bstr" version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234113d19d0d7d613b40e86fb654acf958910802bcceab913a4f9e7cda03b1a4" dependencies = [ "memchr", "regex-automata 0.4.9", "serde", ] [[package]] name = "bumpalo" version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "bytes" version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cc" version = "1.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f4ac86a9e5bc1e2b3449ab9d7d3a6a405e3d1bb28d7b9be8614f55846ae3766" dependencies = [ "shlex", ] [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cfg_aliases" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chrono" version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", "serde", "windows-link", ] [[package]] name = "clap" version = "4.5.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed93b9805f8ba930df42c2590f05453d5ec36cbb85d018868a5b24d31f6ac000" dependencies = [ "clap_builder", "clap_derive", ] [[package]] name = "clap_builder" version = "4.5.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "379026ff283facf611b0ea629334361c4211d1b12ee01024eec1591133b04120" dependencies = [ "anstream", "anstyle", "clap_lex", "strsim", ] [[package]] name = "clap_complete" version = "4.5.50" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c91d3baa3bcd889d60e6ef28874126a0b384fd225ab83aa6d8a801c519194ce1" dependencies = [ "clap", "clap_lex", "is_executable", "shlex", ] [[package]] name = "clap_derive" version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" dependencies = [ "heck", "proc-macro2", "quote", "syn", ] [[package]] name = "clap_lex" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "colorchoice" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "console" version = "0.15.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" dependencies = [ "encode_unicode", "libc", "once_cell", "unicode-width", "windows-sys 0.59.0", ] [[package]] name = "core-foundation-sys" version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "darling" version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" dependencies = [ "darling_core", "darling_macro", ] [[package]] name = "darling_core" version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", "syn", ] [[package]] name = "darling_macro" version = "0.20.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", "syn", ] [[package]] name = "deranged" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" dependencies = [ "powerfmt", "serde", ] [[package]] name = "dialoguer" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "658bce805d770f407bc62102fca7c2c64ceef2fbcb2b8bd19d2765ce093980de" dependencies = [ "console", "shell-words", "tempfile", "thiserror 1.0.69", "zeroize", ] [[package]] name = "directories" version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" dependencies = [ "dirs-sys", ] [[package]] name = "dirs" version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" dependencies = [ "dirs-sys", ] [[package]] name = "dirs-sys" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" dependencies = [ "libc", "option-ext", "redox_users", "windows-sys 0.59.0", ] [[package]] name = "displaydoc" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "edu-sync" version = "0.3.2" dependencies = [ "directories", "edu-ws", "regex", "reqwest", "serde", "serde_with", "shellexpand", "thiserror 2.0.12", "tokio", "toml", "tracing", "url", ] [[package]] name = "edu-sync-cli" version = "0.3.2" dependencies = [ "anyhow", "clap", "clap_complete", "dialoguer", "edu-sync", "futures-util", "human-panic", "indicatif", "tokio", "tracing", "tracing-subscriber", "url", ] [[package]] name = "edu-ws" version = "0.3.2" dependencies = [ "base64", "edu-ws-derive", "hex", "html-escape", "md5", "rand", "reqwest", "serde", "serde_json", "serde_path_to_error", "serde_repr", "serde_with", "thiserror 2.0.12", "time", "tracing", "url", ] [[package]] name = "edu-ws-derive" version = "0.3.2" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "encode_unicode" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" [[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18" dependencies = [ "libc", "windows-sys 0.59.0", ] [[package]] name = "fastrand" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] [[package]] name = "futures-channel" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", ] [[package]] name = "futures-core" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-io" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "futures-sink" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", "futures-io", "futures-macro", "futures-sink", "futures-task", "memchr", "pin-project-lite", "pin-utils", "slab", ] [[package]] name = "getrandom" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ "cfg-if", "js-sys", "libc", "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", ] [[package]] name = "getrandom" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" dependencies = [ "cfg-if", "js-sys", "libc", "r-efi", "wasi 0.14.2+wasi-0.2.4", "wasm-bindgen", ] [[package]] name = "gimli" version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" dependencies = [ "serde", ] [[package]] name = "html-escape" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d1ad449764d627e22bfd7cd5e8868264fc9236e07c752972b4080cd351cb476" dependencies = [ "utf8-width", ] [[package]] name = "http" version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" dependencies = [ "bytes", "fnv", "itoa", ] [[package]] name = "http-body" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", "http", ] [[package]] name = "http-body-util" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" dependencies = [ "bytes", "futures-core", "http", "http-body", "pin-project-lite", ] [[package]] name = "httparse" version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" [[package]] name = "human-panic" version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80b84a66a325082740043a6c28bbea400c129eac0d3a27673a1de971e44bf1f7" dependencies = [ "anstream", "anstyle", "backtrace", "os_info", "serde", "serde_derive", "toml", "uuid", ] [[package]] name = "hyper" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" dependencies = [ "bytes", "futures-channel", "futures-util", "http", "http-body", "httparse", "itoa", "pin-project-lite", "smallvec", "tokio", "want", ] [[package]] name = "hyper-rustls" version = "0.27.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" dependencies = [ "futures-util", "http", "hyper", "hyper-util", "rustls", "rustls-pki-types", "tokio", "tokio-rustls", "tower-service", "webpki-roots 0.26.11", ] [[package]] name = "hyper-util" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497bbc33a26fdd4af9ed9c70d63f61cf56a938375fbb32df34db9b1cd6d643f2" dependencies = [ "bytes", "futures-channel", "futures-util", "http", "http-body", "hyper", "libc", "pin-project-lite", "socket2", "tokio", "tower-service", "tracing", ] [[package]] name = "iana-time-zone" version = "0.1.63" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "log", "wasm-bindgen", "windows-core", ] [[package]] name = "iana-time-zone-haiku" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ "cc", ] [[package]] name = "icu_collections" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" dependencies = [ "displaydoc", "potential_utf", "yoke", "zerofrom", "zerovec", ] [[package]] name = "icu_locale_core" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" dependencies = [ "displaydoc", "litemap", "tinystr", "writeable", "zerovec", ] [[package]] name = "icu_normalizer" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" dependencies = [ "displaydoc", "icu_collections", "icu_normalizer_data", "icu_properties", "icu_provider", "smallvec", "zerovec", ] [[package]] name = "icu_normalizer_data" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" [[package]] name = "icu_properties" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2549ca8c7241c82f59c80ba2a6f415d931c5b58d24fb8412caa1a1f02c49139a" dependencies = [ "displaydoc", "icu_collections", "icu_locale_core", "icu_properties_data", "icu_provider", "potential_utf", "zerotrie", "zerovec", ] [[package]] name = "icu_properties_data" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8197e866e47b68f8f7d95249e172903bec06004b18b2937f1095d40a0c57de04" [[package]] name = "icu_provider" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" dependencies = [ "displaydoc", "icu_locale_core", "stable_deref_trait", "tinystr", "writeable", "yoke", "zerofrom", "zerotrie", "zerovec", ] [[package]] name = "ident_case" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ "idna_adapter", "smallvec", "utf8_iter", ] [[package]] name = "idna_adapter" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" dependencies = [ "icu_normalizer", "icu_properties", ] [[package]] name = "indexmap" version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", "serde", ] [[package]] name = "indexmap" version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", "hashbrown 0.15.3", "serde", ] [[package]] name = "indicatif" version = "0.17.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "183b3088984b400f4cfac3620d5e076c84da5364016b4f49473de574b2586235" dependencies = [ "console", "number_prefix", "portable-atomic", "unicode-width", "web-time", ] [[package]] name = "ipnet" version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] name = "is_executable" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4a1b5bad6f9072935961dfbf1cced2f3d129963d091b6f69f007fe04e758ae2" dependencies = [ "winapi", ] [[package]] name = "is_terminal_polyfill" version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "js-sys" version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ "once_cell", "wasm-bindgen", ] [[package]] name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "libredox" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags", "libc", ] [[package]] name = "linux-raw-sys" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" [[package]] name = "litemap" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" [[package]] name = "log" version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "lru-slab" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" [[package]] name = "matchers" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" dependencies = [ "regex-automata 0.1.10", ] [[package]] name = "md5" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771" [[package]] name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "mime" version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" dependencies = [ "adler2", ] [[package]] name = "mio" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", ] [[package]] name = "nu-ansi-term" version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" dependencies = [ "overload", "winapi", ] [[package]] name = "num-conv" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" [[package]] name = "num-traits" version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "number_prefix" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] [[package]] name = "once_cell" version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "option-ext" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "os_info" version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41fc863e2ca13dc2d5c34fb22ea4a588248ac14db929616ba65c45f21744b1e9" dependencies = [ "log", "serde", "windows-sys 0.52.0", ] [[package]] name = "os_str_bytes" version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" dependencies = [ "memchr", ] [[package]] name = "overload" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "percent-encoding" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "portable-atomic" version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" [[package]] name = "potential_utf" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585" dependencies = [ "zerovec", ] [[package]] name = "powerfmt" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" dependencies = [ "zerocopy", ] [[package]] name = "proc-macro2" version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] [[package]] name = "quinn" version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "626214629cda6781b6dc1d316ba307189c85ba657213ce642d9c77670f8202c8" dependencies = [ "bytes", "cfg_aliases", "pin-project-lite", "quinn-proto", "quinn-udp", "rustc-hash", "rustls", "socket2", "thiserror 2.0.12", "tokio", "tracing", "web-time", ] [[package]] name = "quinn-proto" version = "0.11.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49df843a9161c85bb8aae55f101bc0bac8bcafd637a620d9122fd7e0b2f7422e" dependencies = [ "bytes", "getrandom 0.3.3", "lru-slab", "rand", "ring", "rustc-hash", "rustls", "rustls-pki-types", "slab", "thiserror 2.0.12", "tinyvec", "tracing", "web-time", ] [[package]] name = "quinn-udp" version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee4e529991f949c5e25755532370b8af5d114acae52326361d68d47af64aa842" dependencies = [ "cfg_aliases", "libc", "once_cell", "socket2", "tracing", "windows-sys 0.59.0", ] [[package]] name = "quote" version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] [[package]] name = "r-efi" version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" [[package]] name = "rand" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" dependencies = [ "rand_chacha", "rand_core", ] [[package]] name = "rand_chacha" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", "rand_core", ] [[package]] name = "rand_core" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ "getrandom 0.3.3", ] [[package]] name = "redox_users" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" dependencies = [ "getrandom 0.2.16", "libredox", "thiserror 2.0.12", ] [[package]] name = "regex" version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", "regex-automata 0.4.9", "regex-syntax 0.8.5", ] [[package]] name = "regex-automata" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ "regex-syntax 0.6.29", ] [[package]] name = "regex-automata" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", "regex-syntax 0.8.5", ] [[package]] name = "regex-syntax" version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" version = "0.12.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb" dependencies = [ "base64", "bytes", "futures-core", "futures-util", "http", "http-body", "http-body-util", "hyper", "hyper-rustls", "hyper-util", "ipnet", "js-sys", "log", "mime", "once_cell", "percent-encoding", "pin-project-lite", "quinn", "rustls", "rustls-pemfile", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", "tokio", "tokio-rustls", "tokio-util", "tower", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "wasm-streams", "web-sys", "webpki-roots 0.26.11", "windows-registry", ] [[package]] name = "ring" version = "0.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", "cfg-if", "getrandom 0.2.16", "libc", "untrusted", "windows-sys 0.52.0", ] [[package]] name = "rustc-demangle" version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustix" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", "windows-sys 0.59.0", ] [[package]] name = "rustls" version = "0.23.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "730944ca083c1c233a75c09f199e973ca499344a2b7ba9e755c457e86fb4a321" dependencies = [ "once_cell", "ring", "rustls-pki-types", "rustls-webpki", "subtle", "zeroize", ] [[package]] name = "rustls-pemfile" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ "rustls-pki-types", ] [[package]] name = "rustls-pki-types" version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" dependencies = [ "web-time", "zeroize", ] [[package]] name = "rustls-webpki" version = "0.103.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a72fe2bcf7a6ac6fd7d0b9e5cb68aeb7d4c0a0271730218b3e92d43b4eb435" dependencies = [ "ring", "rustls-pki-types", "untrusted", ] [[package]] name = "rustversion" version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" [[package]] name = "ryu" version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "serde" version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_json" version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", "ryu", "serde", ] [[package]] name = "serde_path_to_error" version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59fab13f937fa393d08645bf3a84bdfe86e296747b506ada67bb15f10f218b2a" dependencies = [ "itoa", "serde", ] [[package]] name = "serde_repr" version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_spanned" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "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 = "serde_with" version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" dependencies = [ "base64", "chrono", "hex", "indexmap 1.9.3", "indexmap 2.9.0", "serde", "serde_derive", "serde_json", "serde_with_macros", "time", ] [[package]] name = "serde_with_macros" version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e" dependencies = [ "darling", "proc-macro2", "quote", "syn", ] [[package]] name = "sharded-slab" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ "lazy_static", ] [[package]] name = "shell-words" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] name = "shellexpand" version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b1fdf65dd6331831494dd616b30351c38e96e45921a27745cf98490458b90bb" dependencies = [ "bstr", "dirs", "os_str_bytes", ] [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "slab" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "smallvec" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" [[package]] name = "socket2" version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" dependencies = [ "libc", "windows-sys 0.52.0", ] [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "strsim" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" version = "2.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "sync_wrapper" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" dependencies = [ "futures-core", ] [[package]] name = "synstructure" version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tempfile" version = "3.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" dependencies = [ "fastrand", "getrandom 0.3.3", "once_cell", "rustix", "windows-sys 0.59.0", ] [[package]] name = "thiserror" version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl 1.0.69", ] [[package]] name = "thiserror" version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ "thiserror-impl 2.0.12", ] [[package]] name = "thiserror-impl" version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "thiserror-impl" version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "thread_local" version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ "cfg-if", "once_cell", ] [[package]] name = "time" version = "0.3.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" dependencies = [ "deranged", "itoa", "num-conv", "powerfmt", "serde", "time-core", "time-macros", ] [[package]] name = "time-core" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" [[package]] name = "time-macros" version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" dependencies = [ "num-conv", "time-core", ] [[package]] name = "tinystr" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" dependencies = [ "displaydoc", "zerovec", ] [[package]] name = "tinyvec" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" 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.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2513ca694ef9ede0fb23fe71a4ee4107cb102b9dc1930f6d0fd77aae068ae165" dependencies = [ "backtrace", "bytes", "libc", "mio", "pin-project-lite", "socket2", "tokio-macros", "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tokio-rustls" version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" dependencies = [ "rustls", "tokio", ] [[package]] name = "tokio-util" version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", ] [[package]] name = "toml" version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae" dependencies = [ "serde", "serde_spanned", "toml_datetime", "toml_edit", ] [[package]] name = "toml_datetime" version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3" dependencies = [ "serde", ] [[package]] name = "toml_edit" version = "0.22.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e" dependencies = [ "indexmap 2.9.0", "serde", "serde_spanned", "toml_datetime", "toml_write", "winnow", ] [[package]] name = "toml_write" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076" [[package]] name = "tower" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" dependencies = [ "futures-core", "futures-util", "pin-project-lite", "sync_wrapper", "tokio", "tower-layer", "tower-service", ] [[package]] name = "tower-layer" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tracing-core" version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", "valuable", ] [[package]] name = "tracing-log" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ "log", "once_cell", "tracing-core", ] [[package]] name = "tracing-subscriber" version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" dependencies = [ "matchers", "nu-ansi-term", "once_cell", "regex", "sharded-slab", "smallvec", "thread_local", "tracing", "tracing-core", "tracing-log", ] [[package]] name = "try-lock" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "unicode-ident" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unicode-width" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" [[package]] name = "untrusted" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", "percent-encoding", "serde", ] [[package]] name = "utf8-width" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" [[package]] name = "utf8_iter" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] name = "utf8parse" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9" dependencies = [ "getrandom 0.3.3", ] [[package]] name = "valuable" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" [[package]] name = "want" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" dependencies = [ "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 = "wasi" version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" dependencies = [ "wit-bindgen-rt", ] [[package]] name = "wasm-bindgen" version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", "proc-macro2", "quote", "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" dependencies = [ "unicode-ident", ] [[package]] name = "wasm-streams" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" dependencies = [ "futures-util", "js-sys", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", ] [[package]] name = "web-sys" version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", ] [[package]] name = "web-time" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" dependencies = [ "js-sys", "wasm-bindgen", ] [[package]] name = "webpki-roots" version = "0.26.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" dependencies = [ "webpki-roots 1.0.0", ] [[package]] name = "webpki-roots" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2853738d1cc4f2da3a225c18ec6c3721abb31961096e9dbf5ab35fa88b19cfdb" dependencies = [ "rustls-pki-types", ] [[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-core" version = "0.61.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46ec44dc15085cea82cf9c78f85a9114c463a369786585ad2882d1ff0b0acf40" dependencies = [ "windows-implement", "windows-interface", "windows-link", "windows-result", "windows-strings 0.4.1", ] [[package]] name = "windows-implement" version = "0.60.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "windows-interface" version = "0.59.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "windows-link" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" [[package]] name = "windows-registry" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" dependencies = [ "windows-result", "windows-strings 0.3.1", "windows-targets 0.53.0", ] [[package]] name = "windows-result" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b895b5356fc36103d0f64dd1e94dfa7ac5633f1c9dd6e80fe9ec4adef69e09d" dependencies = [ "windows-link", ] [[package]] name = "windows-strings" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87fa48cc5d406560701792be122a10132491cff9d0aeb23583cc2dcafc847319" dependencies = [ "windows-link", ] [[package]] name = "windows-strings" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a7ab927b2637c19b3dbe0965e75d8f2d30bdd697a1516191cad2ec4df8fb28a" dependencies = [ "windows-link", ] [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets 0.52.6", ] [[package]] name = "windows-sys" version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets 0.52.6", ] [[package]] name = "windows-targets" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm 0.52.6", "windows_aarch64_msvc 0.52.6", "windows_i686_gnu 0.52.6", "windows_i686_gnullvm 0.52.6", "windows_i686_msvc 0.52.6", "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm 0.52.6", "windows_x86_64_msvc 0.52.6", ] [[package]] name = "windows-targets" version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1e4c7e8ceaaf9cb7d7507c974735728ab453b67ef8f18febdd7c11fe59dca8b" dependencies = [ "windows_aarch64_gnullvm 0.53.0", "windows_aarch64_msvc 0.53.0", "windows_i686_gnu 0.53.0", "windows_i686_gnullvm 0.53.0", "windows_i686_msvc 0.53.0", "windows_x86_64_gnu 0.53.0", "windows_x86_64_gnullvm 0.53.0", "windows_x86_64_msvc 0.53.0", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_gnullvm" version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_aarch64_msvc" version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnu" version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_gnullvm" version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_i686_msvc" version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnu" version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_gnullvm" version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "windows_x86_64_msvc" version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" [[package]] name = "winnow" version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06928c8748d81b05c9be96aad92e1b6ff01833332f281e8cfca3be4b35fc9ec" dependencies = [ "memchr", ] [[package]] name = "wit-bindgen-rt" version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ "bitflags", ] [[package]] name = "writeable" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" [[package]] name = "yoke" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" dependencies = [ "serde", "stable_deref_trait", "yoke-derive", "zerofrom", ] [[package]] name = "yoke-derive" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", "syn", "synstructure", ] [[package]] name = "zerocopy" version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "zerofrom" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", "syn", "synstructure", ] [[package]] name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" [[package]] name = "zerotrie" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" dependencies = [ "displaydoc", "yoke", "zerofrom", ] [[package]] name = "zerovec" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" dependencies = [ "yoke", "zerofrom", "zerovec-derive", ] [[package]] name = "zerovec-derive" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", "syn", ] edu-sync-0.3.2/Cargo.toml000066400000000000000000000002201501243541400151640ustar00rootroot00000000000000[workspace] members = [ "edu-sync", "edu-sync-cli", "edu-ws", "edu-ws-derive", ] resolver = "2" [profile.release] lto = "thin" edu-sync-0.3.2/LICENSE000066400000000000000000001045151501243541400142550ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . edu-sync-0.3.2/README.md000066400000000000000000000054031501243541400145230ustar00rootroot00000000000000# Edu Sync [![CI](https://github.com/mkroening/edu-sync/actions/workflows/ci.yml/badge.svg)](https://github.com/mkroening/edu-sync/actions/workflows/ci.yml) Edu Sync is a command line application that synchronizes the contents of Moodle instances to your computer. It accesses the Moodle instance via the Moodle mobile web services API, which is also used by the official Moodle mobile app. To be able to use Edu Sync with a Moodle instance, the Moodle mobile web services must explicitly be enabled by the instance. This application is written in Rust with a focus on speed. Downloads are performed concurrently, which is beneficial when syncing many small files. ## Usage You can view more detailed help information with: ```bash $ edu-sync-cli help ``` 1. Add an account: * Using username and password: ```bash $ edu-sync-cli add --username https://example.com ~/download-dir # You will be prompted to enter your password ``` * Using a token for the Moodle mobile web service. This could be obtained in some instances inside preferences/security keys. It could also be obtained using [SSO parameter on Moodle-DL](https://github.com/C0D3D3V/Moodle-DL) as shown [here](https://github.com/mkroening/edu-sync/issues/9#issuecomment-2446564050) ```bash $ edu-sync-cli add https://example.com ~/download-dir # You will be prompted to enter your token ``` 2. Fetch available courses (populates the config file with courses): ```bash $ edu-sync-cli fetch ``` 3. Configure which courses to sync in the config file. Get the config path with: ```bash $ edu-sync-cli config ``` 4. Sync: ```bash $ edu-sync-cli sync ``` ## Installation The binary name for Edu Sync is `edu-sync-cli`. [Archives of precompiled binaries](https://github.com/mkroening/edu-sync/releases) for Edu Sync are available for Windows, macOS and Linux. If you're an Arch Linux user, then you can install Edu Sync from the [Arch User Repository](https://aur.archlinux.org/packages/edu-sync/). ### Shell completions Edu Sync uses clap's dynamic completions. To generate the completion stub, use: ```sh COMPLETE= edu-sync-cli ``` Where `` is one of `bash`, `elvish`, `fish`, `powershell` or `zsh` If you use the AUR package, the completions for `bash`, `fish` and `zsh` should get installed automatically. ## Licensing This project is licensed under * The GNU General Public License v3.0 only ([LICENSE](LICENSE), or https://www.gnu.org/licenses/gpl-3.0.html) ### Trademark Notice Moodle™ is a [registered trademark](https://moodle.com/trademarks/) of Moodle Pty Ltd in many countries. Edu Sync is not sponsored, endorsed, licensed by, or affiliated with Moodle Pty Ltd. edu-sync-0.3.2/edu-sync-cli/000077500000000000000000000000001501243541400155365ustar00rootroot00000000000000edu-sync-0.3.2/edu-sync-cli/Cargo.toml000066400000000000000000000015141501243541400174670ustar00rootroot00000000000000[package] name = "edu-sync-cli" version = "0.3.2" authors = ["Martin Kröning "] edition = "2021" description = "Moodle synchronization utility (CLI)." repository = "https://github.com/mkroening/edu-sync" license = "GPL-3.0-only" keywords = ["moodle", "synchronization", "download"] categories = ["command-line-utilities"] [dependencies] edu-sync = { path = "../edu-sync" } anyhow = "1.0" clap = { version = "4", features = ["derive"] } dialoguer = "0.11" futures-util = { version = "0.3", default-features = false, features = ["alloc"] } human-panic = "2" indicatif = "0.17" tokio = { version = "1", features = ["macros", "rt-multi-thread", "time"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } url = "2.2" clap_complete = { version = "4.5.47", features = ["unstable-dynamic"] } edu-sync-0.3.2/edu-sync-cli/README.md000066400000000000000000000000661501243541400170170ustar00rootroot00000000000000# Edu Sync CLI Moodle synchronization utility (CLI). edu-sync-0.3.2/edu-sync-cli/src/000077500000000000000000000000001501243541400163255ustar00rootroot00000000000000edu-sync-0.3.2/edu-sync-cli/src/add.rs000066400000000000000000000043711501243541400174300ustar00rootroot00000000000000use std::path::PathBuf; use dialoguer::Password; use edu_sync::{ account::Account, config::{self, AccountConfig, Config}, }; use tokio::task; use url::Url; /// Adds a new account to the configuration. #[derive(Debug, clap::Parser)] pub struct Subcommand { /// The username of the account. /// /// If set, you will be prompted the corresponding password which will be /// used to retrieve the token. If unset, you must supply the token /// yourself. /// /// Find the token on your Moodle instance's website in your user account /// settings as the security key for the Moodle mobile web service. If you /// cannot find it, make sure that your Moodle instance supports the Moodle /// mobile web service, which is also required for the official Moodle app. /// The token is being saved your config file. #[structopt(short, long)] username: Option, /// A language to force for resource retrieval. #[structopt(short, long)] lang: Option, /// The URL of the Moodle instance. #[arg(value_hint = clap::ValueHint::Hostname)] url: Url, /// The path to download resources to. #[arg(value_hint = clap::ValueHint::DirPath)] path: PathBuf, } impl Subcommand { pub async fn run(self) -> anyhow::Result<()> { let config_task = tokio::spawn(Config::read()); let token = if let Some(username) = self.username { let password = task::spawn_blocking(|| Password::new().with_prompt("Password").interact()) .await??; Account::login(&self.url, &username, &password).await?.token } else { task::spawn_blocking(|| Password::new().with_prompt("Token").interact()) .await?? .parse()? }; let expanded_path = config::expand_path(&self.path)?; let account_config = AccountConfig::new(self.url, token, expanded_path, self.lang).await?; let mut config = config_task.await??; let account_name = account_config.to_string(); config .accounts .insert(account_config.id.to_string(), account_config); config.write().await?; eprintln!("Successfully added {}", account_name); Ok(()) } } edu-sync-0.3.2/edu-sync-cli/src/config.rs000066400000000000000000000004251501243541400201410ustar00rootroot00000000000000use edu_sync::config::Config; /// Prints the path of the configuration file. #[derive(Debug, clap::Parser)] pub struct Subcommand {} impl Subcommand { pub async fn run(self) -> anyhow::Result<()> { println!("{}", Config::path().display()); Ok(()) } } edu-sync-0.3.2/edu-sync-cli/src/fetch.rs000066400000000000000000000017101501243541400177630ustar00rootroot00000000000000use edu_sync::{account::Account, config::Config}; use crate::util; /// Updates the available courses in the configuration. #[derive(Debug, clap::Parser)] pub struct Subcommand {} impl Subcommand { pub async fn run(self) -> anyhow::Result<()> { let mut config = Config::read().await?; if util::check_accounts(&config) { let results = config .accounts .values_mut() .map(|account_config| { let account = Account::new(account_config.id.clone(), account_config.token); let courses = tokio::spawn(async move { account.get_courses().await }); (account_config, courses) }) .collect::>(); for (account_config, courses) in results { account_config.courses.update(courses.await??); } config.write().await?; } Ok(()) } } edu-sync-0.3.2/edu-sync-cli/src/main.rs000066400000000000000000000026131501243541400176210ustar00rootroot00000000000000//! Moodle synchronization utility (CLI). #![warn(rust_2018_idioms)] #![warn(clippy::default_trait_access)] #![warn(clippy::inconsistent_struct_constructor)] #![warn(clippy::semicolon_if_nothing_returned)] #![deny(rustdoc::all)] mod add; mod config; mod fetch; mod sync; mod util; use std::env; use clap::{CommandFactory, Parser}; use human_panic::setup_panic; use tracing_subscriber::EnvFilter; #[derive(Debug, clap::Parser)] #[clap(name = "edu-sync-cli", author, about)] enum Subcommand { Add(add::Subcommand), Config(config::Subcommand), Fetch(fetch::Subcommand), Sync(sync::Subcommand), } impl Subcommand { async fn run(self) -> anyhow::Result<()> { match self { Subcommand::Add(command) => command.run().await, Subcommand::Config(command) => command.run().await, Subcommand::Fetch(command) => command.run().await, Subcommand::Sync(command) => command.run().await, } } } #[tokio::main] async fn main() -> anyhow::Result<()> { clap_complete::CompleteEnv::with_factory(crate::Subcommand::command).complete(); let fmt = tracing_subscriber::fmt().with_writer(std::io::stderr); if env::var_os(EnvFilter::DEFAULT_ENV).is_some() { fmt.with_env_filter(EnvFilter::try_from_default_env()?) .init(); } else { fmt.init(); } setup_panic!(); Subcommand::parse().run().await } edu-sync-0.3.2/edu-sync-cli/src/sync.rs000066400000000000000000000435731501243541400176630ustar00rootroot00000000000000use std::{ borrow::Cow, future::Future, io, sync::{ atomic::{AtomicU64, Ordering}, Arc, }, time::Duration, }; use dialoguer::{ console::{self, Alignment}, Confirm, }; use edu_sync::{ account::{Account, Token}, config::{AccountConfig, Config}, content::{Content, Download, FileDownload, SyncStatus}, }; use futures_util::{ future, stream::{self, FuturesOrdered, FuturesUnordered}, StreamExt, TryFutureExt, }; use indicatif::{BinaryBytes, MultiProgress, ProgressBar, ProgressStyle}; use tokio::{ task, time::{self, sleep}, }; use tracing::{info, trace}; use crate::util; /// Synchronizes available content from the configured courses. #[derive(Debug, clap::Parser)] pub struct Subcommand { /// Bypass any and all “Are you sure?” messages. It’s not a good idea to do /// this unless you want to run edu-sync-cli from a script. #[clap(long)] no_confirm: bool, } impl Subcommand { pub async fn run(self) -> anyhow::Result<()> { let config = Config::read().await?; if util::check_active_courses(&config) { let syncer = Syncer::from(config).await; syncer.sync(self.no_confirm).await?; } Ok(()) } } struct Syncer { parallel_downloads: usize, outdated_courses: Vec, } impl Syncer { async fn from(config: Config) -> Self { eprintln!("Requesting content databases..."); let parallel_downloads = config.parallel_downloads; let outdated_courses = config .accounts .into_iter() .flat_map(|(_account_name, account_config)| { let AccountConfig { path, courses, id, token, .. } = account_config; let account = Account::new(id, token); let account = Arc::new(account); courses .0 .into_iter() .rev() .filter(|(_, course_config)| course_config.sync) .map(move |(course_id, course_config)| { let course_path = path.join(course_config.name_as_path_component().as_ref()); (account.clone(), course_id, course_config.name, course_path) }) }) .map(|(account, course_id, course_name, course_path)| { tokio::spawn(async move { let fetch_status = |course_path, course_name| async { account .get_contents(course_id, course_path) .and_then(|contents| async { let status = CourseStatus::from_contents( contents, account.token(), course_name, ) .await; Ok(status) }) .await }; let account_id = account.id(); let mut status = fetch_status(course_path.clone(), course_name.clone()).await; for _ in 0..4 { match &status { Ok(_) => break, Err(err) if err.is_http() => { sleep(Duration::from_millis(100)).await; eprintln!( "Could not get contents for {course_name} from {account_id} \ ({err}). Retrying." ); status = fetch_status(course_path.clone(), course_name.clone()).await; } Err(_) => break, } } match status { Ok(ok) => Some(ok), Err(err) => { eprintln!( "Could not get contents for {course_name} from {account_id} \ ({err}). Giving up." ); None } } }) }) .collect::>() .filter_map(|res| async move { res.inspect_err(|err| eprintln!("{err}")).ok() }) .filter_map(|res| async move { res }) .filter(|course_status| future::ready(!course_status.downloads.is_empty())) .collect::>() .await; Self { parallel_downloads, outdated_courses, } } async fn sync(self, no_confirm: bool) -> anyhow::Result<()> { if self.outdated_courses.is_empty() { eprintln!("All resources are up to date."); } else { eprintln!(); let size_width = 9; let pad_course_name = |course_name| { let width = 80 - size_width - 4 - 19; console::pad_str(course_name, width, Alignment::Left, Some("...")) }; let pad_size = |size| { let message = if size > 0 { Cow::from(BinaryBytes(size).to_string()) } else { Cow::from("N/A") }; console::pad_str(message.as_ref(), size_width, Alignment::Right, None).into_owned() }; let (count, size) = self .outdated_courses .iter() .map(|course| { let count = course.downloads.len(); let size = course.downloads.iter().map(Download::size).sum(); let name = &course.name; (count, size, name) }) .inspect(|(count, size, name)| { eprintln!( "{} {:>4} items, totalling {}", pad_course_name(name), count, pad_size(*size) ); }) .map(|(count, size, _name)| (count, size)) .reduce(|(count_a, size_a), (count_b, size_b)| (count_a + count_b, size_a + size_b)) .unwrap(); let size = if size > 0 { Cow::from(BinaryBytes(size).to_string()) } else { Cow::from("N/A") }; eprintln!(); eprintln!("Total: {} items, totalling {}", count, size); eprintln!(); let proceed = no_confirm || task::spawn_blocking(|| { Confirm::new() .with_prompt("Proceed with synchronization?") .default(true) .interact() }) .await??; if proceed { eprintln!("Downloading missing files..."); self.download().await?; } } Ok(()) } async fn download(self) -> io::Result<()> { let multi_progress = Arc::new(MultiProgress::new()); let content_progress_style = ProgressStyle::default_bar() .template("[{pos}/{len}] {wide_msg}") .unwrap(); let size_progress_style = ProgressStyle::default_bar() .template( "└──── {binary_bytes:>9} / {binary_total_bytes:>9} [{bar:25}] \ {binary_bytes_per_sec:>11} in {elapsed:>3} ETA: {eta:>3}", ) .unwrap() .progress_chars("=> "); let multi_progress_clone = multi_progress.clone(); let download_tasks = self .outdated_courses .into_iter() .map( |CourseStatus { token, name, downloads, }| { let multi_progress = multi_progress_clone.clone(); let content_progress_style = content_progress_style.clone(); let size_progress_style = size_progress_style.clone(); let content_progress = multi_progress.add( ProgressBar::new(0) .with_style(content_progress_style) .with_message(name), ); let size_progress = multi_progress.add(ProgressBar::new(0).with_style(size_progress_style)); tokio::spawn(async move { CourseDownload { downloads, token, content_progress, size_progress, } .run() .await }) }, ) .collect::>(); let total_bar = multi_progress.add( ProgressBar::new(0).with_style( ProgressStyle::default_bar() .template( "Total {binary_bytes:>9} / {binary_total_bytes:>9} [{bar:25}] \ {binary_bytes_per_sec:>11} in {elapsed:>3} ETA: {eta:>3}", ) .unwrap() .progress_chars("=> "), ), ); let (file_downloads, content_downloads, size_progress, content_progress, size) = download_tasks .filter_map(|res| future::ready(res.map_err(|err| eprintln!("{}", err)).ok())) .filter_map(|res| future::ready(res.map_err(|err| eprintln!("{}", err)).ok())) .fold( (Vec::new(), Vec::new(), Vec::new(), Vec::new(), 0), |( mut file_downloads, mut content_downloads, mut size_progress, mut content_progress, size, ), mut download| async move { file_downloads.append(&mut download.file_downloads); content_downloads.append(&mut download.content_downloads); size_progress.push((download.download_progresses, download.size_progress)); content_progress.push(download.content_progress); ( file_downloads, content_downloads, size_progress, content_progress, size + download.size, ) }, ) .await; total_bar.set_length(size); let size_progresses = size_progress .iter() .map(|(_, bar)| bar) .cloned() .collect::>(); let file_downloads = stream::iter(file_downloads) .map(tokio::spawn) .buffer_unordered(self.parallel_downloads) .collect::>(); let total_bar_clone = total_bar.clone(); let size = tokio::spawn(async move { let mut timer = time::interval(Duration::from_millis(200)); loop { let mut total = 0; for (progresses, size_progress) in &size_progress { let progress = progresses .iter() .map(|progress| progress.load(Ordering::Relaxed)) .sum(); size_progress.set_position(progress); total += progress; } total_bar_clone.set_position(total); timer.tick().await; } }); let content_downloads = content_downloads .into_iter() .map(tokio::spawn) .collect::>(); let file_downloads = file_downloads.await; for content_download in content_downloads { content_download.await?; } size.abort(); for size_progress in size_progresses { size_progress.finish(); } for content_progress in content_progress { content_progress.finish(); } total_bar.finish(); for file_download in file_downloads { file_download??; } Ok(()) } } struct CourseStatus { token: Token, name: String, downloads: Vec, } impl CourseStatus { async fn from_contents( contents: impl Iterator + Send, token: Token, name: String, ) -> Self { let downloads = contents .map(|content| { tokio::spawn(async move { match content.sync().await { SyncStatus::Downloadable(download) => Some(download), SyncStatus::NotSupported(content_type, path) => { info!( "Not supported: ContentType::{:?} at {}", content_type, path.display() ); None } SyncStatus::UpToDate(path) => { trace!("Up to date: {}", path.display()); None } } }) }) .collect::>() .filter_map(|res| future::ready(res.map_err(|err| eprintln!("{}", err)).ok())) .collect::>() .await .into_iter() .flatten() .collect::>(); Self { token, name, downloads, } } } struct CourseDownload { downloads: Vec, token: Token, content_progress: ProgressBar, size_progress: ProgressBar, } struct CourseDownloads { file_downloads: Vec, content_downloads: Vec, download_progresses: Vec>, size_progress: ProgressBar, size: u64, content_progress: ProgressBar, } impl CourseDownload { async fn run( self, ) -> io::Result>, impl Future>> { let Self { downloads, token, content_progress, size_progress, } = self; content_progress.set_length(downloads.len() as u64); let (file_downloads, content_downloads) = downloads .into_iter() .partition::, _>(|download| matches!(download, Download::File(_))); let file_downloads = file_downloads .into_iter() .map(|file_download| match file_download { Download::File(file_download) => file_download, _ => unreachable!(), }) .collect::>(); let download_size = file_downloads.iter().map(FileDownload::size).sum(); size_progress.set_length(download_size); let progresses = file_downloads .iter() .map(|_| Arc::new(AtomicU64::new(0))) .collect::>(); let content_progress_clone = content_progress.clone(); let file_downloads = file_downloads .into_iter() .zip(progresses.iter().cloned()) .map(|(mut file_download, progress)| { let content_progress = content_progress_clone.clone(); async move { file_download .run(&token, |val| progress.store(val, Ordering::Relaxed)) .await .map(|()| { content_progress.inc(1); let path = file_download.path().display(); content_progress.println(path.to_string()); }) .inspect_err(|err| { let path = file_download.path().display(); content_progress .println(format!("error while downloading {path}: {err}")); }) } }) .collect::>(); let content_progress_clone = content_progress.clone(); let content_downloads = content_downloads .into_iter() .map(|download| { let content_progress = content_progress_clone.clone(); async move { match download { Download::File(_) => unreachable!(), Download::Url(mut url_download) => { url_download.run().await.unwrap(); content_progress.inc(1); let path = url_download.path().display().to_string(); content_progress.println(path); } Download::Content(mut content_download) => { content_download.run().await.unwrap(); content_progress.inc(1); let path = content_download.path().display().to_string(); content_progress.println(path); } } } }) .collect::>(); Ok(CourseDownloads { file_downloads, content_downloads, download_progresses: progresses, size_progress, size: download_size, content_progress, }) } } edu-sync-0.3.2/edu-sync-cli/src/util.rs000066400000000000000000000013631501243541400176530ustar00rootroot00000000000000use edu_sync::config::Config; pub fn check_accounts(config: &Config) -> bool { let sucess = config.has_accounts(); if !sucess { eprintln!("No accounts configured. To add an account, use the add subcommand."); } sucess } pub fn check_active_courses(config: &Config) -> bool { if !check_accounts(config) { false } else if !config.has_courses() { eprintln!("No courses known. To fetch available courses, use the fetch subcommand."); false } else if !config.has_active_courses() { eprintln!( "No courses activated. To activate synchronization for courses, edit the config at\n{}", Config::path().display() ); false } else { true } } edu-sync-0.3.2/edu-sync/000077500000000000000000000000001501243541400147715ustar00rootroot00000000000000edu-sync-0.3.2/edu-sync/Cargo.toml000066400000000000000000000014121501243541400167170ustar00rootroot00000000000000[package] name = "edu-sync" version = "0.3.2" authors = ["Martin Kröning "] edition = "2021" description = "Moodle synchronization library." repository = "https://github.com/mkroening/edu-sync" license = "GPL-3.0-only" keywords = ["moodle", "synchronization", "download"] categories = ["asynchronous", "web-programming"] [dependencies] edu-ws = { path = "../edu-ws" } directories = "6" regex = "1.5" reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "stream"] } serde = { version = "1.0", features = ["derive"] } serde_with = "3" shellexpand = { version = "3", features = ["path"] } thiserror = "2" tokio = { version = "1", default-features = false, features = ["fs", "macros"] } toml = "0.8" tracing = "0.1" url = "2.2" edu-sync-0.3.2/edu-sync/README.md000066400000000000000000000000651501243541400162510ustar00rootroot00000000000000# Edu Sync (common) Moodle synchronization library. edu-sync-0.3.2/edu-sync/src/000077500000000000000000000000001501243541400155605ustar00rootroot00000000000000edu-sync-0.3.2/edu-sync/src/account.rs000066400000000000000000000102201501243541400175550ustar00rootroot00000000000000use std::{fmt, path::PathBuf}; pub use edu_ws::token::Token; use edu_ws::{ ajax, response::{course::Course, info::Info}, token::{ login, sso::{self, SSOTokenBuilder}, }, ws, }; use serde::{Deserialize, Serialize}; use url::Url; use crate::{ content::Content, util::{self, sanitize_path_component}, }; #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(rename_all = "kebab-case")] pub struct Id { pub site_url: Url, pub user_id: u64, pub lang: Option, } impl fmt::Display for Id { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}@{}", self.user_id, self.site_url.host_str().unwrap()) } } #[derive(Debug, Clone)] pub struct Account { id: Id, token: Token, } impl Account { pub async fn login( site_url: &Url, username: &str, password: &str, ) -> login::Result { login::Client::new(util::shared_http(), site_url) .login(username, password) .await } #[must_use] pub const fn id(&self) -> &Id { &self.id } #[must_use] pub const fn token(&self) -> Token { self.token } #[must_use] pub const fn new(id: Id, token: Token) -> Self { Self { id, token } } fn ws_client(&self) -> ws::Client { ws::Client::new( util::shared_http(), &self.id.site_url, self.token, self.id.lang.clone(), ) } pub async fn get_courses(&self) -> ws::Result> { let ws_client = self.ws_client(); ws_client.get_courses(self.id.user_id, false).await } pub async fn get_contents( &self, course_id: u64, course_path: PathBuf, ) -> ws::Result> { let contents = self .ws_client() .get_contents(course_id) .await? .into_iter() .flat_map(move |section| { let section_name = format!("{} {}", section.id, section.name); let course_path = course_path.clone(); section.modules.into_iter().map(move |module| { ( module, course_path.join(sanitize_path_component(§ion_name).as_ref()), ) }) }) .filter_map(|(module, section_name)| { let module_name = format!("{} {}", module.id, module.name); module.contents.map(move |contents| { ( section_name.join(sanitize_path_component(&module_name).as_ref()), contents, ) }) }) .flat_map(|(dir, contents)| { contents .into_iter() .map(move |content| Content::new(content, dir.clone())) }); Ok(contents) } } pub struct Builder { site_url: Url, lang: Option, token_builder: SSOTokenBuilder, } impl Builder { pub async fn new(site_url: Url, url_scheme: &str, lang: Option) -> (Url, Self) { let ajax_client = ajax::Client::new(util::shared_http(), &site_url); let site_config = ajax_client.get_config().await.unwrap(); let (sso_url, token_builder) = SSOTokenBuilder::prepare_sso(&site_url, site_config.launch_url.unwrap(), url_scheme); ( sso_url, Self { site_url, lang, token_builder, }, ) } pub async fn validate(self, token_url: &Url) -> Result { let token = self.token_builder.validate(token_url)?; let ws_client = ws::Client::new( util::shared_http(), &self.site_url, token, self.lang.clone(), ); let Info { site_url, user_id, .. } = ws_client.get_info().await.unwrap(); let id = Id { site_url, user_id, lang: self.lang, }; Ok(Account::new(id, token)) } } edu-sync-0.3.2/edu-sync/src/config.rs000066400000000000000000000151621501243541400174000ustar00rootroot00000000000000use std::{ borrow::Cow, collections::BTreeMap, convert::Infallible, fmt::{self, Display}, io::{self, ErrorKind}, path::{Path, PathBuf}, sync::OnceLock, }; use edu_ws::{ response::{course::Course, info::Info}, token::Token, ws, }; use reqwest::Url; use serde::{Deserialize, Deserializer, Serialize}; use serde_with::{serde_as, serde_conv, DisplayFromStr}; use thiserror::Error; use tokio::{ fs::{self, File}, io::AsyncWriteExt, }; use tracing::warn; use crate::{account::Id, util}; #[derive(Error, Debug)] pub enum TomlReadError { #[error("I/O error")] IoError(#[from] io::Error), #[error("TOML deserialization error")] TomlError(#[from] toml::de::Error), } #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(rename_all = "kebab-case")] pub struct CourseConfig { pub name: String, pub sync: bool, } impl CourseConfig { #[must_use] pub fn name_as_path_component(&self) -> Cow<'_, str> { util::sanitize_path_component(&self.name) } } impl From for CourseConfig { fn from(course: Course) -> Self { Self { name: format!("{} {}", course.id, course.full_name), sync: false, } } } impl CourseConfig { fn apply(&mut self, other: &Self) { self.sync = other.sync; } } #[serde_as] #[derive(Serialize, Deserialize)] struct SortedCourseConfigs( #[serde_as(as = "BTreeMap")] Vec<(u64, CourseConfig)>, ); serde_conv!( CourseConfigsSorter, BTreeMap, |source: &BTreeMap| { let mut course_configs = source .iter() .map(|(&k, v)| (k, v.clone())) .collect::>(); course_configs.sort_unstable_by(|(a, _), (b, _)| a.cmp(b).reverse()); SortedCourseConfigs(course_configs) }, |value: SortedCourseConfigs| -> Result<_, Infallible> { Ok(value.0.into_iter().collect()) } ); #[serde_as] #[derive(Serialize, Deserialize, Debug, Default)] pub struct CourseConfigs(#[serde_as(as = "CourseConfigsSorter")] pub BTreeMap); impl CourseConfigs { pub fn update(&mut self, courses: Vec) { let mut new_configs = courses .into_iter() .map(|course| (course.id, CourseConfig::from(course))) .collect::>(); for (id, config) in &self.0 { if let Some(new_config) = new_configs.get_mut(id) { new_config.apply(config); } else { warn!("Course \"{}\" ({}) is unavailable", config.name, id); } } self.0 = new_configs; } } // Expand Tilde to home folder, create the directory if it does not exist and // then canonicalize the path. pub fn expand_path(path: &Path) -> io::Result { let expanded_path = shellexpand::path::tilde(&path); if !expanded_path.try_exists()? { std::fs::create_dir(&expanded_path)?; } std::fs::canonicalize(expanded_path) } // Custom deserializer function to check if the path is absolute and to // canonicalize the path fn deserialize_absolute_path<'de, D>(deserializer: D) -> Result where D: Deserializer<'de>, { let path = PathBuf::deserialize(deserializer)?; expand_path(&path).map_err(serde::de::Error::custom) } #[derive(Serialize, Deserialize, Debug)] #[serde(rename_all = "kebab-case")] pub struct AccountConfig { pub user: String, pub site: String, #[serde(flatten)] pub id: Id, pub token: Token, #[serde(deserialize_with = "deserialize_absolute_path")] pub path: PathBuf, #[serde(default)] pub courses: CourseConfigs, } impl Display for AccountConfig { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{} ({}) at {}", self.user, self.id, self.path.display()) } } impl AccountConfig { pub async fn new( site_url: Url, token: Token, path: PathBuf, lang: Option, ) -> Result { let ws_client = ws::Client::new(util::shared_http(), &site_url, token, lang.clone()); let Info { site_url, user_id, full_name, site_name, .. } = ws_client.get_info().await.map_err(|err| match err { ws::RequestError::WsError(err) => err, err => panic!("{err:?}"), })?; let id = Id { site_url, user_id, lang, }; Ok(Self { user: full_name, site: site_name, id, token, path, courses: CourseConfigs(BTreeMap::new()), }) } } #[derive(Serialize, Deserialize, Debug)] #[serde(rename_all = "kebab-case")] pub struct Config { pub parallel_downloads: usize, #[serde(default)] pub accounts: BTreeMap, } impl Config { #[must_use] pub fn path() -> &'static Path { static CONFIG_PATH: OnceLock = OnceLock::new(); CONFIG_PATH .get_or_init(|| { let project_dirs = util::project_dirs(); let mut config_path = project_dirs.config_dir().join(project_dirs.project_path()); config_path.set_extension("toml"); config_path }) .as_path() } pub fn has_accounts(&self) -> bool { !self.accounts.is_empty() } pub fn has_courses(&self) -> bool { self.accounts .values() .any(|account_config| !account_config.courses.0.is_empty()) } pub fn has_active_courses(&self) -> bool { self.accounts .values() .flat_map(|account_config| account_config.courses.0.values()) .any(|course_config| course_config.sync) } pub async fn read() -> Result { let string_result = fs::read_to_string(Self::path()).await; if matches!(&string_result, Err(err) if err.kind() == ErrorKind::NotFound) { return Ok(Self::default()); } let config = toml::from_str(&string_result?)?; Ok(config) } pub async fn write(&self) -> io::Result<()> { fs::create_dir_all(util::project_dirs().config_dir()).await?; let mut config_file = File::create(Self::path()).await?; let toml = toml::to_string_pretty(self).unwrap(); config_file.write_all(toml.as_bytes()).await?; config_file.flush().await?; Ok(()) } } impl Default for Config { fn default() -> Self { Self { parallel_downloads: 5, accounts: BTreeMap::default(), } } } edu-sync-0.3.2/edu-sync/src/content.rs000066400000000000000000000223231501243541400176020ustar00rootroot00000000000000use std::{ borrow::Cow, cmp::Ordering, path::{Path, PathBuf}, time::SystemTime, }; use edu_ws::{ response::content::{Content as WsContent, Type}, token::Token, }; use reqwest::Url; use tokio::{ fs::{self, File}, io::{self, AsyncBufReadExt, AsyncSeekExt, AsyncWriteExt, BufReader}, task, }; use crate::util::{self, sanitize_path_component, PathBufExt}; #[derive(Debug, Clone)] pub struct Content { ws_content: WsContent, path: PathBuf, } #[derive(Debug)] pub enum SyncStatus { Downloadable(Download), NotSupported(Type, PathBuf), UpToDate(PathBuf), } impl Content { #[must_use] pub fn new(ws_content: WsContent, module_path: PathBuf) -> Self { let path = { let mut path = module_path; if let Some(content_path) = &ws_content.path { if let Ok(content_path) = content_path.strip_prefix("/") { path.push(content_path); } else { path.push(content_path); } } if !<&str>::try_from(path.file_name().unwrap()) .unwrap() .ends_with(&ws_content.name) { path.push(&ws_content.name); } if ws_content.ty == Type::Url { path.push_file_name_suffix(".html"); } let file_name = path.file_name().unwrap().to_str().unwrap(); if let Cow::Owned(sanitized_file_name) = sanitize_path_component(file_name) { path.set_file_name(sanitized_file_name); } path }; Self { ws_content, path } } fn mtime(&self) -> SystemTime { self.ws_content.modified.into() } fn download(self) -> SyncStatus { let mtime = self.mtime(); match self.ws_content.ty { Type::File => { let common = CommonDownload::new(self.path, mtime); let url = self.ws_content.url.unwrap(); let size = self.ws_content.size; SyncStatus::Downloadable(Download::File(FileDownload { url, size, common })) } Type::Url => { let common = CommonDownload::new(self.path, mtime); let url = self.ws_content.url.unwrap(); SyncStatus::Downloadable(Download::Url(UrlDownload { url, common })) } Type::Content => { let common = CommonDownload::new(self.path, mtime); let content = self.ws_content.content.unwrap(); SyncStatus::Downloadable(Download::Content(ContentDownload { content, common })) } Type::Folder => SyncStatus::NotSupported(Type::Folder, self.path), } } pub async fn sync(self) -> SyncStatus { let latest_path = latest_path(self.path.clone()).await.unwrap(); match cmp_mtime(&latest_path, &self.mtime()).await.ok() { None | Some(Ordering::Less) | Some(Ordering::Greater) => self.download(), Some(Ordering::Equal) => SyncStatus::UpToDate(latest_path), } } } #[derive(Debug)] pub enum Download { File(FileDownload), Url(UrlDownload), Content(ContentDownload), } impl Download { pub fn size(&self) -> u64 { match self { Download::File(file_download) => file_download.size(), Download::Url(url_download) => url_download.size() as u64, Download::Content(content_download) => content_download.size() as u64, } } } #[derive(Debug)] pub struct ContentDownload { content: String, common: CommonDownload, } impl ContentDownload { pub async fn run(&mut self) -> io::Result<()> { let (mut file, path) = self.common.create_file().await?; file.write_all(self.content.as_bytes()).await?; self.common.finish(file, path).await?; Ok(()) } #[must_use] pub fn path(&self) -> &Path { self.common.dst_path.as_path() } pub fn size(&self) -> usize { self.content.len() } } #[derive(Debug)] pub struct FileDownload { url: Url, size: u64, common: CommonDownload, } impl FileDownload { pub async fn run( &mut self, token: &Token, mut report_progress: impl FnMut(u64) + Send, ) -> io::Result<()> { let (mut file, path) = self.common.create_file().await?; token.apply(&mut self.url); let mut response = util::shared_http() .get(self.url.clone()) .send() .await .unwrap(); let mut progress = 0; while let Some(chunk) = response.chunk().await.unwrap() { file.write_all(&chunk).await?; progress += chunk.len() as u64; report_progress(progress); } self.common.finish(file, path).await?; Ok(()) } #[must_use] pub const fn size(&self) -> u64 { self.size } #[must_use] pub fn path(&self) -> &Path { self.common.dst_path.as_path() } } #[derive(Debug)] pub struct UrlDownload { url: Url, common: CommonDownload, } impl UrlDownload { pub async fn run(&mut self) -> io::Result<()> { let (mut file, path) = self.common.create_file().await?; let buf = format!(include_str!("url_format.html"), url = self.url); file.write_all(buf.as_bytes()).await?; self.common.finish(file, path).await?; Ok(()) } #[must_use] pub fn path(&self) -> &Path { self.common.dst_path.as_path() } #[must_use] pub fn size(&self) -> usize { include_str!("url_format.html").len() - "{url}".len() + self.url.as_str().len() } } #[derive(Debug)] pub struct CommonDownload { dst_path: PathBuf, mtime: SystemTime, } impl CommonDownload { fn new(dst_path: PathBuf, mtime: SystemTime) -> Self { Self { dst_path, mtime } } async fn create_file(&self) -> io::Result<(File, PathBuf)> { let dl_path = { let mut dl_path = self.dst_path.clone(); dl_path.push_file_name_suffix(".tmp"); dl_path }; if let Some(parent) = dl_path.parent() { fs::create_dir_all(parent).await?; } let file = File::options() .read(true) .write(true) .create(true) .truncate(true) .open(&dl_path) .await?; Ok((file, dl_path)) } async fn finish(&mut self, mut file: File, dl_path: PathBuf) -> io::Result<()> { let latest_path = latest_path(self.dst_path.clone()).await?; match cmp_mtime(&latest_path, &self.mtime).await.ok() { Some(Ordering::Equal) => unreachable!(), Some(Ordering::Less) | Some(Ordering::Greater) => { let mut dst_file = File::open(&latest_path).await?; if file_eq(&mut file, &mut dst_file).await? { file_set_modified(dst_file, self.mtime).await?; fs::remove_file(&dl_path).await?; return Ok(()); } else { self.dst_path = next_path(self.dst_path.clone()).await?; } } None => {} } file_set_modified(file, self.mtime).await?; fs::rename(dl_path, &self.dst_path).await?; Ok(()) } } async fn cmp_mtime(path: &Path, mtime: &SystemTime) -> io::Result { fs::metadata(path).await.map(|metadata| { let file_mtime = metadata.modified().unwrap(); file_mtime.cmp(mtime) }) } async fn file_eq(file_a: &mut File, file_b: &mut File) -> io::Result { let (metadata_a, metadata_b) = tokio::join!(file_a.metadata(), file_b.metadata()); if metadata_a?.len() != metadata_b?.len() { return Ok(false); } let (seek_a, seek_b) = tokio::join!(file_a.rewind(), file_b.rewind()); seek_a?; seek_b?; let mut reader_a = BufReader::new(file_a); let mut reader_b = BufReader::new(file_b); loop { let (buf_a, buf_b) = tokio::join!(reader_a.fill_buf(), reader_b.fill_buf()); let (buf_a, buf_b) = (buf_a?, buf_b?); if buf_a != buf_b { return Ok(false); } if buf_a.is_empty() { return Ok(buf_b.is_empty()); } let (len_a, len_b) = (buf_a.len(), buf_b.len()); reader_a.consume(len_a); reader_b.consume(len_b); } } async fn file_set_modified(file: File, mtime: SystemTime) -> io::Result<()> { let file = file.into_std().await; task::spawn_blocking(move || file.set_modified(mtime)).await??; Ok(()) } fn alt_paths(path: &Path) -> impl Iterator + '_ { (0..).map(|i| { let mut path = path.to_path_buf(); path.push_file_prefix_suffix(format!("_new-{i}")); path }) } async fn latest_path(path: PathBuf) -> io::Result { let mut latest_path = path.clone(); for path in alt_paths(&path) { if fs::try_exists(&path).await? { latest_path = path; } else { break; } } Ok(latest_path) } async fn next_path(path: PathBuf) -> io::Result { for path in alt_paths(&path) { if !fs::try_exists(&path).await? { return Ok(path); } } unreachable!() } edu-sync-0.3.2/edu-sync/src/lib.rs000066400000000000000000000004501501243541400166730ustar00rootroot00000000000000//! Moodle synchronization library. #![warn(rust_2018_idioms)] #![warn(clippy::default_trait_access)] #![warn(clippy::inconsistent_struct_constructor)] #![warn(clippy::semicolon_if_nothing_returned)] #![deny(rustdoc::all)] pub mod account; pub mod config; pub mod content; pub(crate) mod util; edu-sync-0.3.2/edu-sync/src/url_format.html000066400000000000000000000001301501243541400206120ustar00rootroot00000000000000 edu-sync-0.3.2/edu-sync/src/util.rs000066400000000000000000000100011501243541400170730ustar00rootroot00000000000000use std::{borrow::Cow, ffi::OsStr, mem, path::PathBuf, sync::OnceLock}; use directories::ProjectDirs; use regex::{NoExpand, Regex}; pub fn project_dirs() -> &'static ProjectDirs { static PROJECT_DIRS: OnceLock = OnceLock::new(); PROJECT_DIRS.get_or_init(|| { ProjectDirs::from("org", "Edu Sync", "Edu Sync") .expect("no valid home directory path could be retrieved from the operating system") }) } pub fn shared_http() -> reqwest::Client { static SHARED: OnceLock = OnceLock::new(); SHARED.get_or_init(reqwest::Client::new).clone() } // From https://github.com/rust-lang/rust/blob/1.78.0/library/std/src/path.rs#L342-L364 fn split_file_at_dot(file: &OsStr) -> (&OsStr, Option<&OsStr>) { let slice = file.as_encoded_bytes(); if slice == b".." { return (file, None); } // The unsafety here stems from converting between &OsStr and &[u8] // and back. This is safe to do because (1) we only look at ASCII // contents of the encoding and (2) new &OsStr values are produced // only from ASCII-bounded slices of existing &OsStr values. let i = match slice[1..].iter().position(|b| *b == b'.') { Some(i) => i + 1, None => return (file, None), }; let before = &slice[..i]; let after = &slice[i + 1..]; unsafe { ( OsStr::from_encoded_bytes_unchecked(before), Some(OsStr::from_encoded_bytes_unchecked(after)), ) } } pub trait PathBufExt { fn push_file_name_suffix(&mut self, path: impl AsRef); fn push_file_prefix_suffix(&mut self, path: impl AsRef); } impl PathBufExt for PathBuf { fn push_file_name_suffix(&mut self, suffix: impl AsRef) { if self.file_name().is_some() { let mut path = mem::take(self).into_os_string(); path.push(suffix); *self = path.into(); } } fn push_file_prefix_suffix(&mut self, suffix: impl AsRef) { if let Some(file_name) = self.file_name() { let (before, after) = split_file_at_dot(file_name); let mut file_name = before.to_os_string(); file_name.push(suffix); if let Some(after) = after { file_name.push("."); file_name.push(after); } self.set_file_name(file_name); } } } pub fn sanitize_path_component(path_component: &str) -> Cow<'_, str> { static RE: OnceLock = OnceLock::new(); RE.get_or_init(|| Regex::new(r#"["*/:<>?\\|]|^\.\.??$"#).unwrap()) .replace_all(path_component, NoExpand("_")) } #[cfg(test)] mod tests { use super::*; #[test] fn sanitize_filename_test() { assert_eq!(sanitize_path_component(r"/a//b/\c\\d\"), "_a__b__c__d_"); assert_eq!(sanitize_path_component(".a.b."), ".a.b."); assert_eq!(sanitize_path_component("."), "_"); assert_eq!(sanitize_path_component(".."), "_"); assert_eq!(sanitize_path_component("..."), "..."); assert_eq!( sanitize_path_component(r#"0"1*2/3:4<5>6?7\8|9"#), "0_1_2_3_4_5_6_7_8_9" ); assert_eq!(sanitize_path_component(r#"a**<>b"#), "a____b"); } #[test] fn push_extension_test() { let mut path = PathBuf::from("foo.rs"); path.push_file_name_suffix(".txt"); assert_eq!(path, PathBuf::from("foo.rs.txt")); let mut path = PathBuf::from("foo"); path.push_file_name_suffix(".txt"); assert_eq!(path, PathBuf::from("foo.txt")); } #[test] fn push_prefix_suffix_test() { let mut path = PathBuf::from("foo"); path.push_file_prefix_suffix("-1"); assert_eq!(path, PathBuf::from("foo-1")); let mut path = PathBuf::from("foo.rs"); path.push_file_prefix_suffix("-1"); assert_eq!(path, PathBuf::from("foo-1.rs")); let mut path = PathBuf::from("foo.tar.gz"); path.push_file_prefix_suffix("-1"); assert_eq!(path, PathBuf::from("foo-1.tar.gz")); } } edu-sync-0.3.2/edu-ws-derive/000077500000000000000000000000001501243541400157225ustar00rootroot00000000000000edu-sync-0.3.2/edu-ws-derive/Cargo.toml000066400000000000000000000005731501243541400176570ustar00rootroot00000000000000[package] name = "edu-ws-derive" version = "0.3.2" authors = ["Martin Kröning "] edition = "2021" description = "Proc macros for edu-ws." repository = "https://github.com/mkroening/edu-sync" license = "GPL-3.0-only" keywords = ["derive"] categories = ["rust-patterns"] [dependencies] proc-macro2 = "1.0" quote = "1.0" syn = "2.0" [lib] proc-macro = true edu-sync-0.3.2/edu-ws-derive/README.md000066400000000000000000000000541501243541400172000ustar00rootroot00000000000000# Edu WS (derives) Proc macros for edu-ws. edu-sync-0.3.2/edu-ws-derive/src/000077500000000000000000000000001501243541400165115ustar00rootroot00000000000000edu-sync-0.3.2/edu-ws-derive/src/lib.rs000066400000000000000000000103011501243541400176200ustar00rootroot00000000000000//! Proc macros for edu-ws. #![warn(rust_2018_idioms)] #![warn(clippy::default_trait_access)] #![warn(clippy::inconsistent_struct_constructor)] #![warn(clippy::semicolon_if_nothing_returned)] #![deny(rustdoc::all)] use quote::quote; use syn::{parse_macro_input, Data, DeriveInput, Fields, Ident, Type}; #[proc_macro_derive(HexWrapper)] pub fn hex_wrapper_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let input = parse_macro_input!(input as DeriveInput); let name = &input.ident; let (_, inner) = inner(&input.data); let inner_expr = inner_expr(inner); let debug_impl = match inner { Some(_) => quote! { f.debug_struct(stringify!(#name)) .field(stringify!(#inner_expr), &format!("{:x}", self)) .finish() }, None => quote! { f.debug_tuple(stringify!(#name)) .field(&format!("{:x}", self)) .finish() }, }; let expanded = quote! { impl #name { pub fn parse(s: &str) -> Result { let raw = hex::FromHex::from_hex(s)?; Ok(Self{ #inner_expr: raw }) } } impl std::fmt::LowerHex for #name { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", hex::encode(self.#inner_expr)) } } impl std::fmt::UpperHex for #name { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", hex::encode_upper(self.#inner_expr)) } } impl std::fmt::Debug for #name { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { #debug_impl } } impl std::fmt::Display for #name { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{:x}", self) } } impl std::str::FromStr for #name { type Err = hex::FromHexError; fn from_str(s: &str) -> Result { #name::parse(s) } } }; proc_macro::TokenStream::from(expanded) } #[proc_macro_derive(DerefWrapper)] pub fn deref_wrapper_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let input = parse_macro_input!(input as DeriveInput); let name = &input.ident; let (ty, inner) = inner(&input.data); let inner_expr = inner_expr(inner); let expanded = quote! { impl std::ops::Deref for #name { type Target = #ty; fn deref(&self) -> &Self::Target { &self.#inner_expr } } impl std::ops::DerefMut for #name { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.#inner_expr } } }; proc_macro::TokenStream::from(expanded) } #[proc_macro_derive(FromWrapper)] pub fn from_wrapper_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let input = parse_macro_input!(input as DeriveInput); let name = &input.ident; let (ty, inner) = inner(&input.data); let inner_expr = inner_expr(inner); let expanded = quote! { impl From<#name> for #ty { fn from(wrapper: #name) -> Self { wrapper.#inner_expr } } }; proc_macro::TokenStream::from(expanded) } fn inner(data: &Data) -> (&Type, &Option) { let fields = match *data { Data::Struct(ref data) => match data.fields { Fields::Unnamed(ref fields) => &fields.unnamed, Fields::Named(ref fields) => &fields.named, Fields::Unit => unimplemented!("struct needs to have exactly one field"), }, Data::Enum(_) | Data::Union(_) => unimplemented!("can only derive for structs"), }; if fields.len() != 1 { unimplemented!("struct needs to have exactly one field"); } let field = &fields.first().unwrap(); (&field.ty, &field.ident) } fn inner_expr(inner: &Option) -> proc_macro2::TokenStream { match inner { Some(ident) => quote! { #ident }, None => quote! { 0 }, } } edu-sync-0.3.2/edu-ws/000077500000000000000000000000001501243541400144465ustar00rootroot00000000000000edu-sync-0.3.2/edu-ws/Cargo.toml000066400000000000000000000017261501243541400164040ustar00rootroot00000000000000[package] name = "edu-ws" version = "0.3.2" authors = ["Martin Kröning "] edition = "2021" description = "Moodle web service HTTP API wrapper." repository = "https://github.com/mkroening/edu-sync" license = "GPL-3.0-only" keywords = ["moodle", "web service", "client", "http"] categories = ["api-bindings", "asynchronous", "authentication", "web-programming"] [dependencies] edu-ws-derive = { path = "../edu-ws-derive" } html-escape = "0.2" reqwest = { version = "0.12", default-features = false, features = ["json"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde_path_to_error = "0.1" serde_repr = "0.1" serde_with = "3" thiserror = "2" time = { version = "0.3", features = ["serde"] } tracing = "0.1" url = { version = "2.2", features = ["serde"] } # SSO base64 = "0.22" hex = { version = "0.4", features = ["serde"] } md5 = "0.7" rand = "0.9" [dev-dependencies] time = { version = "0.3", features = ["macros", "serde"] } edu-sync-0.3.2/edu-ws/README.md000066400000000000000000000000571501243541400157270ustar00rootroot00000000000000# Edu WS Moodle web service HTTP API wrapper. edu-sync-0.3.2/edu-ws/src/000077500000000000000000000000001501243541400152355ustar00rootroot00000000000000edu-sync-0.3.2/edu-ws/src/ajax.rs000066400000000000000000000074311501243541400165330ustar00rootroot00000000000000//! A client for Axaj requests. use std::collections::HashMap; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use thiserror::Error; use url::Url; use crate::{response::config::Config, serde::UntaggedResultHelper}; #[derive(Debug)] pub struct Client { http_client: reqwest::Client, ajax_url: Url, } #[derive(Error, Deserialize, Debug, PartialEq)] #[serde(tag = "errorcode")] pub enum Exception { #[error("{message}")] #[serde(rename = "invalidparameter")] InvalidParameter { message: String, #[serde(rename = "link")] url: Url, #[serde(rename = "moreinfourl")] info_url: Url, }, } #[derive(Deserialize, Debug, PartialEq)] #[serde(untagged)] enum AjaxResult { Ok { data: T }, Err { exception: Exception }, } impl From> for Result { fn from(res: AjaxResult) -> Self { match res { AjaxResult::Ok { data } => Ok(data), AjaxResult::Err { exception } => Err(exception), } } } #[derive(Serialize)] struct Request<'a> { #[serde(rename = "methodname")] method: &'a str, #[serde(rename = "args")] arguments: HashMap, } impl Client { #[must_use] pub fn new(http_client: reqwest::Client, site_url: &Url) -> Self { let ajax_url = site_url.join("lib/ajax/service-nologin.php").unwrap(); Self { http_client, ajax_url, } } async fn call_ajax( &self, requests: &[Request<'_>], ) -> Result>, ReceiveError> where T: DeserializeOwned, { let res = self .http_client .post(self.ajax_url.clone()) .json(&requests) .send() .await? .json::>, RequestError>>() .await? .0? .into_iter() .map(Into::into) .collect(); Ok(res) } pub async fn get_config(&self) -> Result { let config = self .call_ajax(&[Request { method: "tool_mobile_get_public_config", arguments: HashMap::new(), }]) .await? .into_iter() .next() .unwrap()?; Ok(config) } } #[derive(Error, Deserialize, Debug, PartialEq)] #[serde(tag = "errorcode")] pub enum RequestError { #[error("{message}")] #[serde(rename = "invalidrecord")] InvalidRecord { #[serde(rename = "error")] message: String, }, } #[derive(Error, Debug)] pub enum Error { #[error(transparent)] ReceiveError(#[from] ReceiveError), #[error(transparent)] Exception(#[from] Exception), } #[derive(Error, Debug)] pub enum ReceiveError { #[error(transparent)] RequestError(#[from] RequestError), #[error(transparent)] HttpError(#[from] reqwest::Error), } #[cfg(test)] mod tests { use serde_json::json; use super::*; #[test] fn test_ajax_result_deserialization() -> serde_json::Result<()> { assert_eq!( AjaxResult::Err::<()> { exception: Exception::InvalidParameter { message: "message".to_string(), url: "https://example.com".parse().unwrap(), info_url: "https://example.com/info".parse().unwrap(), } }, serde_json::from_value(json!({ "error": true, "exception": { "errorcode": "invalidparameter", "link": "https://example.com", "message": "message", "moreinfourl": "https://example.com/info" } }))? ); Ok(()) } } edu-sync-0.3.2/edu-ws/src/lib.rs000066400000000000000000000004541501243541400163540ustar00rootroot00000000000000//! Moodle web service HTTP API wrapper. #![warn(rust_2018_idioms)] #![warn(clippy::default_trait_access)] #![warn(clippy::inconsistent_struct_constructor)] #![warn(clippy::semicolon_if_nothing_returned)] #![deny(rustdoc::all)] pub mod ajax; pub mod response; mod serde; pub mod token; pub mod ws; edu-sync-0.3.2/edu-ws/src/response/000077500000000000000000000000001501243541400170735ustar00rootroot00000000000000edu-sync-0.3.2/edu-ws/src/response/config.rs000066400000000000000000000256551501243541400207230ustar00rootroot00000000000000//! Response from `tool_mobile_get_public_config`. use serde::Deserialize; use serde_repr::Deserialize_repr; use serde_with::{serde_as, NoneAsEmptyString}; use url::Url; use crate::serde::NumBool; #[serde_as] #[derive(Deserialize, PartialEq, Debug)] pub struct Config { #[serde(rename = "wwwroot")] pub url: Url, #[serde(rename = "httpswwwroot")] pub https_url: Url, #[serde(rename = "sitename")] pub site_name: String, #[serde_as(as = "NumBool")] #[serde(rename = "guestlogin")] pub guest_login: bool, #[serde(rename = "rememberusername")] pub remember_username: RememberUsername, #[serde_as(as = "NumBool")] #[serde(rename = "authloginviaemail")] pub log_in_via_email: bool, #[serde(rename = "registerauth")] pub register_auth: String, #[serde_as(as = "NoneAsEmptyString")] #[serde(rename = "forgottenpasswordurl")] pub forgotten_password_url: Option, #[serde(rename = "authinstructions")] pub auth_instructions: String, #[serde_as(as = "NumBool")] #[serde(rename = "authnoneenabled")] pub auth_none: bool, #[serde_as(as = "NumBool")] #[serde(rename = "enablewebservices")] pub web_services: bool, #[serde_as(as = "NumBool")] #[serde(rename = "enablemobilewebservice")] pub mobile_service: bool, #[serde_as(as = "NumBool")] #[serde(rename = "maintenanceenabled")] pub maintenance: bool, #[serde(rename = "maintenancemessage")] pub maintenance_message: String, #[serde(rename = "logourl")] pub logo_url: Option, #[serde(rename = "compactlogourl")] pub compact_logo_url: Option, #[serde(rename = "typeoflogin")] pub login_type: LoginType, #[serde(rename = "launchurl")] pub launch_url: Option, #[serde_as(as = "NoneAsEmptyString")] #[serde(default, rename = "mobilecssurl")] pub mobile_css_url: Option, #[serde(rename = "tool_mobile_disabledfeatures")] pub disabled_mobile_features: Option, #[serde(rename = "identityproviders")] pub identity_providers: Option>, pub country: Option, #[serde(rename = "agedigitalconsentverification")] pub age_digital_consent_verification: Option, #[serde(rename = "supportname")] pub support_name: Option, #[serde(rename = "supportemail")] pub support_email: Option, #[serde_as(as = "Option")] #[serde(default, rename = "autolang")] pub auto_lang: Option, pub lang: Option, #[serde_as(as = "Option")] #[serde(default, rename = "langmenu")] pub lang_menu: Option, #[serde(rename = "langlist")] pub lang_list: Option, pub locale: Option, pub warnings: Option>, } #[derive(Deserialize_repr, PartialEq, Debug)] #[repr(u8)] pub enum RememberUsername { No = 0, Yes = 1, Optional = 2, } #[derive(Deserialize_repr, PartialEq, Debug)] #[repr(u8)] pub enum LoginType { App = 1, Browser = 2, Embedded = 3, } #[serde_as] #[derive(Deserialize, PartialEq, Debug)] pub struct IdentityProvider { name: String, #[serde_as(as = "NoneAsEmptyString")] #[serde(rename = "iconurl")] icon_url: Option, url: Url, } #[derive(Deserialize, PartialEq, Debug)] pub struct Warning { item: Option, #[serde(rename = "itemid")] item_id: Option, #[serde(rename = "warningcode")] warning_code: String, message: String, } #[cfg(test)] mod tests { use serde_json::json; use super::*; #[test] fn test_config_deserialization() -> serde_json::Result<()> { assert_eq!( Config { url: "http://example.com".parse().unwrap(), https_url: "https://example.com".parse().unwrap(), site_name: "site_name".to_string(), guest_login: true, remember_username: RememberUsername::Optional, log_in_via_email: false, register_auth: "register_auth".to_string(), forgotten_password_url: Some( "https://example.com/forgotten_password".parse().unwrap() ), auth_instructions: "auth_instructions".to_string(), auth_none: false, web_services: true, mobile_service: true, maintenance: false, maintenance_message: "maintenance_message".to_string(), logo_url: Some("https://example.com/logo".parse().unwrap()), compact_logo_url: Some("https://example.com/compact_logo".parse().unwrap()), login_type: LoginType::Browser, launch_url: Some("https://example.com/launch".parse().unwrap()), mobile_css_url: Some("https://example.com/mobile_css".parse().unwrap()), disabled_mobile_features: Some("disabled_mobile_features".to_string()), identity_providers: Some(Vec::new()), country: Some("country".to_string()), age_digital_consent_verification: Some(false), support_name: Some("support_name".to_string()), support_email: Some("support@example.com".to_string()), auto_lang: Some(true), lang: Some("en".to_string()), lang_menu: Some(true), lang_list: Some("en, de".to_string()), locale: Some("en_US.UTF-8".to_string()), warnings: Some(Vec::new()), }, serde_json::from_value(json!({ "wwwroot": "http://example.com", "httpswwwroot": "https://example.com", "sitename": "site_name", "guestlogin": 1, "rememberusername": 2, "authloginviaemail": 0, "registerauth": "register_auth", "forgottenpasswordurl": "https://example.com/forgotten_password", "authinstructions": "auth_instructions", "authnoneenabled": 0, "enablewebservices": 1, "enablemobilewebservice": 1, "maintenanceenabled": 0, "maintenancemessage": "maintenance_message", "logourl": "https://example.com/logo", "compactlogourl": "https://example.com/compact_logo", "typeoflogin": 2, "launchurl": "https://example.com/launch", "mobilecssurl": "https://example.com/mobile_css", "tool_mobile_disabledfeatures": "disabled_mobile_features", "identityproviders": [], "country": "country", "agedigitalconsentverification": false, "supportname": "support_name", "supportemail": "support@example.com", "autolang": 1, "lang": "en", "langmenu": 1, "langlist": "en, de", "locale": "en_US.UTF-8", "warnings": [] }))? ); assert_eq!( Config { url: "http://example.com".parse().unwrap(), https_url: "https://example.com".parse().unwrap(), site_name: "site_name".to_string(), guest_login: true, remember_username: RememberUsername::Optional, log_in_via_email: false, register_auth: "register_auth".to_string(), forgotten_password_url: None, auth_instructions: "auth_instructions".to_string(), auth_none: false, web_services: true, mobile_service: true, maintenance: false, maintenance_message: "maintenance_message".to_string(), logo_url: None, compact_logo_url: None, login_type: LoginType::Browser, launch_url: None, mobile_css_url: None, disabled_mobile_features: None, identity_providers: None, country: None, age_digital_consent_verification: None, support_name: None, support_email: None, auto_lang: None, lang: None, lang_menu: None, lang_list: None, locale: None, warnings: None, }, serde_json::from_value(json!({ "wwwroot": "http://example.com", "httpswwwroot": "https://example.com", "sitename": "site_name", "guestlogin": 1, "rememberusername": 2, "authloginviaemail": 0, "registerauth": "register_auth", "forgottenpasswordurl": "", "authinstructions": "auth_instructions", "authnoneenabled": 0, "enablewebservices": 1, "enablemobilewebservice": 1, "maintenanceenabled": 0, "maintenancemessage": "maintenance_message", "typeoflogin": 2 }))? ); Ok(()) } #[test] fn test_identity_provider_deserialization() -> serde_json::Result<()> { assert_eq!( IdentityProvider { name: "name".to_string(), icon_url: Some("https://example.com/icon".parse().unwrap()), url: "https://example.com".parse().unwrap(), }, serde_json::from_value(json!({ "name": "name", "iconurl": "https://example.com/icon", "url": "https://example.com" }))? ); assert_eq!( IdentityProvider { name: "name".to_string(), icon_url: None, url: "https://example.com".parse().unwrap(), }, serde_json::from_value(json!({ "name": "name", "iconurl": "", "url": "https://example.com" }))? ); Ok(()) } #[test] fn test_warning_deserialization() -> serde_json::Result<()> { assert_eq!( Warning { item: Some("item".to_string()), item_id: Some(1), warning_code: "warning_code".to_string(), message: "message".to_string(), }, serde_json::from_value(json!({ "item": "item", "itemid": 1, "warningcode": "warning_code", "message": "message" }))? ); assert_eq!( Warning { item: None, item_id: None, warning_code: "warning_code".to_string(), message: "message".to_string(), }, serde_json::from_value(json!({ "warningcode": "warning_code", "message": "message" }))? ); Ok(()) } } edu-sync-0.3.2/edu-ws/src/response/content.rs000066400000000000000000000376361501243541400211320ustar00rootroot00000000000000//! Response from `core_course_get_contents`. use std::path::PathBuf; use serde::Deserialize; use serde_repr::Deserialize_repr; use serde_with::serde_as; use time::{serde::timestamp, OffsetDateTime}; use url::Url; use crate::{ response::SummaryFormat, serde::{NumBool, StringAsHtml}, }; #[serde_as] #[derive(Deserialize, PartialEq, Debug)] pub struct Section { pub id: i64, #[serde_as(as = "StringAsHtml")] pub name: String, #[serde_as(as = "Option")] #[serde(default)] pub visible: Option, pub summary: String, #[serde(rename = "summaryformat")] pub summary_format: SummaryFormat, pub section: Option, #[serde_as(as = "Option")] #[serde(default, rename = "hiddenbynumsections")] pub hidden_by_num_sections: Option, #[serde(rename = "uservisible")] pub user_visible: Option, #[serde(rename = "availabilityinfo")] pub availability_info: Option, pub modules: Vec, } #[serde_as] #[derive(Deserialize, PartialEq, Debug)] pub struct Module { pub id: u64, pub url: Option, #[serde_as(as = "StringAsHtml")] pub name: String, pub instance: Option, pub description: Option, #[serde_as(as = "Option")] #[serde(default)] pub visible: Option, #[serde(rename = "uservisible")] pub user_visible: Option, #[serde(rename = "availabilityinfo")] pub availability_info: Option, #[serde_as(as = "Option")] #[serde(default, rename = "visibleoncoursepage")] pub visible_on_course_page: Option, #[serde(rename = "modicon")] pub icon: Url, #[serde(rename = "modname")] pub ty: String, #[serde(rename = "modplural")] pub type_plural: String, pub availability: Option, pub indent: i64, #[serde(rename = "onclick")] pub on_click: Option, #[serde(rename = "afterlink")] pub after_link_info: Option, #[serde(rename = "customdata")] pub custom_data: Option, #[serde(rename = "completion")] pub completion_type: Option, #[serde(rename = "completiondata")] pub completion_data: Option, pub contents: Option>, #[serde(rename = "contentsinfo")] pub contents_info: Option, } #[derive(Deserialize_repr, PartialEq, Debug)] #[repr(u8)] pub enum CompletionType { None = 0, Manual = 1, Automatic = 2, } #[derive(Deserialize, PartialEq, Debug)] pub struct CompletionData { pub state: CompletionState, #[serde(with = "timestamp", rename = "timecompleted")] pub time_completed: OffsetDateTime, #[serde(rename = "overrideby")] pub override_by: Option, #[serde(rename = "valueused")] pub value_used: Option, } #[derive(Deserialize_repr, PartialEq, Debug)] #[repr(u8)] pub enum CompletionState { Incomplete = 0, Complete = 1, CompletePass = 2, CompleteFail = 3, } #[serde_as] #[derive(Deserialize, PartialEq, Debug, Clone)] pub struct Content { #[serde(rename = "type")] pub ty: Type, #[serde_as(as = "StringAsHtml")] #[serde(rename = "filename")] pub name: String, #[serde(rename = "filepath")] pub path: Option, #[serde(rename = "filesize")] pub size: u64, #[serde(rename = "fileurl")] pub url: Option, pub content: Option, #[serde(with = "timestamp::option", default, rename = "timecreated")] pub created: Option, #[serde(with = "timestamp", rename = "timemodified")] pub modified: OffsetDateTime, pub sortorder: Option, #[serde(default, rename = "mimetype")] pub media_type: Option, #[serde(rename = "isexternalfile")] pub external_file: Option, #[serde(rename = "repositorytype")] pub repository_type: Option, #[serde(rename = "userid")] pub user_id: Option, pub author: Option, pub license: Option, pub tags: Option>, } #[derive(Deserialize, PartialEq, Debug, Copy, Clone)] #[repr(u8)] #[serde(rename_all = "lowercase")] pub enum Type { File, Folder, Url, Content, } #[derive(Deserialize, PartialEq, Debug, Clone)] pub struct Tag { pub id: u64, pub name: String, #[serde(rename = "rawname")] pub raw_name: String, #[serde(rename = "isstandard")] pub standard: bool, #[serde(rename = "tagcollid")] pub collection_id: u64, #[serde(rename = "taginstanceid")] pub instance_id: u64, #[serde(rename = "taginstancecontextid")] pub instance_context_id: u64, #[serde(rename = "itemid")] pub item_id: u64, pub ordering: u64, pub flag: bool, } #[serde_as] #[derive(Deserialize, PartialEq, Debug)] pub struct ContentsInfo { #[serde(rename = "filescount")] pub count: u64, #[serde(rename = "filessize")] pub size: u64, #[serde(with = "timestamp", rename = "lastmodified")] pub modified: OffsetDateTime, #[serde(rename = "mimetypes")] pub media_types: Vec, #[serde(rename = "repositorytype")] pub repository_type: Option, } #[cfg(test)] mod tests { use serde_json::json; use time::macros::datetime; use super::*; #[test] fn test_section_deserialization() -> serde_json::Result<()> { assert_eq!( Section { id: -1, name: "a > b && a < c".to_string(), visible: Some(true), summary: "summary".to_string(), summary_format: SummaryFormat::Plain, section: Some(0), hidden_by_num_sections: Some(false), user_visible: Some(true), availability_info: Some("availability_info".to_string()), modules: Vec::new(), }, serde_json::from_value(json!({ "id": -1, "name": "a > b && a < c", "visible": 1, "summary": "summary", "summaryformat": 2, "section": 0, "hiddenbynumsections": 0, "uservisible": true, "availabilityinfo": "availability_info", "modules": [] }))? ); assert_eq!( Section { id: 1, name: "section_name".to_string(), visible: None, summary: "summary".to_string(), summary_format: SummaryFormat::Plain, section: None, hidden_by_num_sections: None, user_visible: None, availability_info: None, modules: Vec::new(), }, serde_json::from_value(json!({ "id": 1, "name": "section_name", "summary": "summary", "summaryformat": 2, "modules": [] }))? ); Ok(()) } #[test] fn test_module_deserialization() -> serde_json::Result<()> { assert_eq!( Module { id: 1, url: Some( "https://example.com/mod/folder/view.php?id=1" .parse() .unwrap() ), name: "a > b && a < c".to_string(), instance: Some(1), description: Some("module_description".to_string()), visible: Some(true), user_visible: Some(true), availability_info: Some("availability_info".to_string()), visible_on_course_page: Some(true), icon: "https://example.com/icon".parse().unwrap(), ty: "resource".to_string(), type_plural: "resources".to_string(), availability: Some("availability".to_string()), indent: 0, on_click: Some("on_click".to_string()), after_link_info: Some("after_link_info".to_string()), custom_data: Some(serde_json::to_string(&json!({ "an": "object" })).unwrap()), completion_type: Some(CompletionType::Manual), completion_data: None, contents: Some(Vec::new()), contents_info: None, }, serde_json::from_value(json!({ "id": 1, "url": "https://example.com/mod/folder/view.php?id=1", "name": "a > b && a < c", "instance": 1, "description": "module_description", "visible": 1, "uservisible": true, "availabilityinfo": "availability_info", "visibleoncoursepage": 1, "modicon": "https://example.com/icon", "modname": "resource", "modplural": "resources", "availability": "availability", "indent": 0, "onclick": "on_click", "afterlink": "after_link_info", "customdata": "{\"an\":\"object\"}", "completion": 1, "completiondata": null, "contents": [], "contentsinfo": null }))? ); assert_eq!( Module { id: 1, url: None, name: "module_name".to_string(), instance: None, description: None, visible: None, user_visible: None, availability_info: None, visible_on_course_page: None, icon: "https://example.com/icon".parse().unwrap(), ty: "resource".to_string(), type_plural: "resources".to_string(), availability: None, indent: 0, on_click: None, after_link_info: None, custom_data: None, completion_type: None, completion_data: None, contents: None, contents_info: None, }, serde_json::from_value(json!({ "id": 1, "name": "module_name", "modicon": "https://example.com/icon", "modname": "resource", "modplural": "resources", "indent": 0 }))? ); Ok(()) } #[test] fn test_completion_data_deserialization() -> serde_json::Result<()> { assert_eq!( CompletionData { state: CompletionState::Incomplete, time_completed: datetime!(2002 - 08 - 20 0:00 UTC), override_by: Some(1), value_used: Some(false), }, serde_json::from_value(json!({ "state": 0, "timecompleted": 1029801600, "overrideby": 1, "valueused": false }))? ); assert_eq!( CompletionData { state: CompletionState::Incomplete, time_completed: datetime!(2002 - 08 - 20 0:00 UTC), override_by: None, value_used: None, }, serde_json::from_value(json!({ "state": 0, "timecompleted": 1029801600 }))? ); Ok(()) } #[test] fn test_content_deserialization() -> serde_json::Result<()> { assert_eq!( Content { ty: Type::File, name: "a > b && a < c.pdf".to_string(), path: Some(PathBuf::from("/")), size: 4096, url: Some("https://example.com/".parse().unwrap()), content: Some("content".to_string()), created: Some(datetime!(2002 - 08 - 20 0:00 UTC)), modified: datetime!(2002 - 11 - 20 0:00 UTC), sortorder: Some(0), media_type: Some("application/pdf".to_string()), external_file: Some(false), repository_type: Some("repository_type".to_string()), user_id: Some(1), author: Some("author".to_string()), license: Some("license".to_string()), tags: Some(Vec::new()), }, serde_json::from_value(json!({ "type": "file", "filename": "a > b && a < c.pdf", "filepath": "/", "filesize": 4096, "fileurl": "https://example.com/", "content": "content", "timecreated": 1029801600, "timemodified": 1037750400, "sortorder": 0, "mimetype": "application/pdf", "isexternalfile": false, "repositorytype": "repository_type", "userid": 1, "author": "author", "license": "license", "tags": [] }))? ); assert_eq!( Content { ty: Type::File, name: "file.pdf".to_string(), path: None, size: 4096, url: None, content: None, created: None, modified: datetime!(2002 - 11 - 20 0:00 UTC), sortorder: None, media_type: None, external_file: None, repository_type: None, user_id: None, author: None, license: None, tags: None, }, serde_json::from_value(json!({ "type": "file", "filename": "file.pdf", "filesize": 4096, "timemodified": 1_037_750_400 }))? ); Ok(()) } #[test] fn test_tag_deserialization() -> serde_json::Result<()> { assert_eq!( Tag { id: 1, name: "name".to_string(), raw_name: "raw_name".to_string(), standard: false, collection_id: 1, instance_id: 1, instance_context_id: 1, item_id: 1, ordering: 1, flag: false, }, serde_json::from_value(json!({ "id": 1, "name": "name", "rawname": "raw_name", "isstandard": false, "tagcollid": 1, "taginstanceid": 1, "taginstancecontextid": 1, "itemid": 1, "ordering": 1, "flag": false }))? ); Ok(()) } #[test] fn test_contents_info_deserialization() -> serde_json::Result<()> { assert_eq!( ContentsInfo { count: 2, size: 8192, modified: datetime!(2002 - 11 - 20 0:00 UTC), media_types: vec!["application/pdf".to_string(), "text/plain".to_string(),], repository_type: Some("repository_type".to_string()), }, serde_json::from_value(json!({ "filescount": 2, "filessize": 8192, "lastmodified": 1_037_750_400, "mimetypes": ["application/pdf", "text/plain"], "repositorytype": "repository_type" }))? ); assert_eq!( ContentsInfo { count: 2, size: 8192, modified: datetime!(2002 - 11 - 20 0:00 UTC), media_types: vec!["application/pdf".to_string(), "text/plain".to_string(),], repository_type: None, }, serde_json::from_value(json!({ "filescount": 2, "filessize": 8192, "lastmodified": 1_037_750_400, "mimetypes": ["application/pdf", "text/plain"] }))? ); Ok(()) } } edu-sync-0.3.2/edu-ws/src/response/course.rs000066400000000000000000000177471501243541400207610ustar00rootroot00000000000000//! Response from `core_enrol_get_users_courses`. use std::path::PathBuf; use serde::Deserialize; use serde_with::serde_as; use time::{serde::timestamp, OffsetDateTime}; use url::Url; use crate::{ response::SummaryFormat, serde::{NumBool, StringAsHtml}, }; #[serde_as] #[derive(Deserialize, PartialEq, Debug)] pub struct Course { pub id: u64, #[serde_as(as = "StringAsHtml")] #[serde(rename = "shortname")] pub short_name: String, #[serde_as(as = "StringAsHtml")] #[serde(rename = "fullname")] pub full_name: String, #[serde_as(as = "Option")] #[serde(default, rename = "displayname")] pub display_name: Option, #[serde(rename = "enrolledusercount")] pub enrolled_user_count: Option, #[serde(rename = "idnumber")] pub id_number: String, #[serde_as(as = "NumBool")] pub visible: bool, pub summary: Option, #[serde(rename = "summaryformat")] pub summary_format: Option, pub format: Option, #[serde(rename = "showgrades")] pub show_grades: Option, pub lang: Option, #[serde(rename = "enablecompletion")] pub enable_completion: Option, #[serde(rename = "completionhascriteria")] pub completion_has_criteria: Option, #[serde(rename = "completionusertracked")] pub completion_user_tracked: Option, pub category: Option, pub progress: Option, pub completed: Option, #[serde(with = "timestamp::option", default, rename = "startdate")] pub start_date: Option, #[serde(with = "timestamp::option", default, rename = "enddate")] pub end_date: Option, pub marker: Option, #[serde(with = "timestamp::option", default, rename = "lastaccess")] pub last_access: Option, #[serde(rename = "isfavourite")] pub favourite: Option, pub hidden: Option, #[serde(rename = "overviewfiles")] pub overview_files: Option>, } #[serde_as] #[derive(Deserialize, PartialEq, Debug)] pub struct OverviewFile { #[serde(rename = "filename")] pub name: Option, #[serde(rename = "filepath")] pub path: Option, #[serde(rename = "filesize")] pub size: Option, /// Downloadable file url. #[serde(rename = "fileurl")] pub url: Option, #[serde(with = "timestamp::option", default, rename = "timemodified")] pub modified: Option, #[serde(default, rename = "mimetype")] pub media_type: Option, #[serde(rename = "isexternalfile")] pub external: Option, /// The repository type for external files. #[serde(rename = "repositorytype")] pub repository_type: Option, } #[cfg(test)] mod tests { use serde_json::json; use time::macros::datetime; use super::*; #[test] fn test_course_deserialization() -> serde_json::Result<()> { assert_eq!( Course { id: 1, short_name: "a > b && a < c".to_string(), full_name: "a > b && a < c".to_string(), display_name: Some("a > b && a < c".to_string()), enrolled_user_count: Some(100), id_number: "02ws-00001".to_string(), visible: true, summary: Some("summary".to_string()), summary_format: Some(SummaryFormat::Plain), format: Some("format".to_string()), show_grades: Some(true), lang: Some("en".to_string()), enable_completion: Some(true), completion_has_criteria: Some(false), completion_user_tracked: Some(true), category: Some(1), progress: Some(0.0), completed: Some(false), start_date: Some(datetime!(2002 - 08 - 20 0:00 UTC)), end_date: Some(datetime!(2003 - 02 - 20 0:00 UTC)), marker: Some(0), last_access: Some(datetime!(2002 - 11 - 20 0:00 UTC)), favourite: Some(false), hidden: Some(false), overview_files: Some(Vec::new()), }, serde_json::from_value(json!({ "id": 1, "shortname": "a > b && a < c", "fullname": "a > b && a < c", "displayname": "a > b && a < c", "enrolledusercount": 100, "idnumber": "02ws-00001", "visible": 1, "summary": "summary", "summaryformat": 2, "format": "format", "showgrades": true, "lang": "en", "enablecompletion": true, "completionhascriteria": false, "completionusertracked": true, "category": 1, "progress": 0.0, "completed": false, "startdate": 1029801600, "enddate": 1045699200, "marker": 0, "lastaccess": 1037750400, "isfavourite": false, "hidden": false, "overviewfiles": [] }))? ); assert_eq!( Course { id: 1, short_name: "short_name".to_string(), full_name: "full_name".to_string(), display_name: None, enrolled_user_count: None, id_number: "02ws-00001".to_string(), visible: true, summary: None, summary_format: None, format: None, show_grades: None, lang: None, enable_completion: None, completion_has_criteria: None, completion_user_tracked: None, category: None, progress: None, completed: None, start_date: None, end_date: None, marker: None, last_access: None, favourite: None, hidden: None, overview_files: None, }, serde_json::from_value(json!({ "id": 1, "shortname": "short_name", "fullname": "full_name", "idnumber": "02ws-00001", "visible": 1 }))? ); Ok(()) } #[test] fn test_overview_file_deserialization() -> serde_json::Result<()> { assert_eq!( OverviewFile { name: Some("logo.png".to_string()), path: Some(PathBuf::from("/")), size: Some(4096), url: Some("https://example.com/webservice/pluginfile.php/00001/course/overviewfiles/file.png".parse().unwrap()), modified: Some(datetime!(2002-08-20 0:00 UTC)), media_type: Some("image/png".to_string()), external: Some(true), repository_type: Some("repository_type".to_string()) }, serde_json::from_value( json!({ "filename": "logo.png", "filepath": "/", "filesize": 4096, "fileurl": "https://example.com/webservice/pluginfile.php/00001/course/overviewfiles/file.png", "timemodified": 1029801600, "mimetype": "image/png", "isexternalfile": true, "repositorytype": "repository_type" }) )? ); assert_eq!( OverviewFile { name: None, path: None, size: None, url: None, modified: None, media_type: None, external: None, repository_type: None, }, serde_json::from_value(json!({}))? ); Ok(()) } } edu-sync-0.3.2/edu-ws/src/response/info.rs000066400000000000000000000155241501243541400204030ustar00rootroot00000000000000//! Response from `core_webservice_get_site_info`. use serde::Deserialize; use serde_with::{serde_as, NoneAsEmptyString}; use url::Url; use crate::serde::NumBool; #[serde_as] #[derive(Deserialize, PartialEq, Debug)] pub struct Info { #[serde(rename = "sitename")] pub site_name: String, pub username: String, #[serde(rename = "firstname")] pub first_name: String, #[serde(rename = "lastname")] pub last_name: String, #[serde(rename = "fullname")] pub full_name: String, #[serde(rename = "lang")] pub language: String, #[serde(rename = "userid")] pub user_id: u64, #[serde(rename = "siteurl")] pub site_url: Url, #[serde(rename = "userpictureurl")] pub user_picture_url: Url, pub functions: Vec, #[serde_as(as = "Option")] #[serde(default, rename = "downloadfiles")] pub can_download_files: Option, #[serde_as(as = "Option")] #[serde(default, rename = "uploadfiles")] pub can_upload_files: Option, pub release: Option, pub version: Option, #[serde_as(as = "NoneAsEmptyString")] #[serde(default, rename = "mobilecssurl")] pub mobile_css_url: Option, #[serde(rename = "advancedfeatures")] pub advanced_features: Vec, #[serde(rename = "usercanmanageownfiles")] pub can_manage_own_files: Option, #[serde(rename = "userquota")] pub user_quota: Option, #[serde(rename = "usermaxuploadfilesize")] pub max_upload_file_size: Option, #[serde(rename = "userhomepage")] pub user_homepage: Option, #[serde(rename = "siteid")] pub site_id: Option, #[serde(rename = "sitecalendartype")] pub site_calendar_type: Option, #[serde(rename = "usercalendartype")] pub user_calendar_type: Option, pub theme: Option, } #[derive(Deserialize, PartialEq, Debug)] pub struct Function { pub name: String, pub version: String, } #[serde_as] #[derive(Deserialize, PartialEq, Debug)] pub struct Feature { pub name: String, #[serde_as(as = "NumBool")] #[serde(rename = "value")] pub enabled: bool, } #[cfg(test)] mod tests { use serde_json::json; use super::*; #[test] fn test_info_deserialization() -> serde_json::Result<()> { assert_eq!( Info { site_name: "site_name".into(), username: "username".into(), first_name: "first_name".into(), last_name: "last_name".into(), full_name: "full_name".into(), language: "language".into(), user_id: 0, site_url: "https://example.com".parse().unwrap(), user_picture_url: "https://example.com/user_picture".parse().unwrap(), functions: Vec::new(), can_download_files: Some(true), can_upload_files: Some(true), release: Some("release".into()), version: Some("version".into()), mobile_css_url: Some("https://example.com/mobile_css".parse().unwrap()), advanced_features: Vec::new(), can_manage_own_files: Some(true), user_quota: Some(0), max_upload_file_size: Some(-1), user_homepage: Some(1), site_id: Some(0), site_calendar_type: Some("gregorian".into()), user_calendar_type: Some("gregorian".into()), theme: Some("theme".into()), }, serde_json::from_value(json!({ "sitename": "site_name", "username": "username", "firstname": "first_name", "lastname": "last_name", "fullname": "full_name", "lang": "language", "userid": 0, "siteurl": "https://example.com", "userpictureurl": "https://example.com/user_picture", "functions": [], "downloadfiles": 1, "uploadfiles": 1, "release": "release", "version": "version", "mobilecssurl": "https://example.com/mobile_css", "advancedfeatures": [], "usercanmanageownfiles": true, "userquota": 0, "usermaxuploadfilesize": -1, "userhomepage": 1, "siteid": 0, "sitecalendartype": "gregorian", "usercalendartype": "gregorian", "theme": "theme", }))?, ); assert_eq!( Info { site_name: "site_name".into(), username: "username".into(), first_name: "first_name".into(), last_name: "last_name".into(), full_name: "full_name".into(), language: "language".into(), user_id: 0, site_url: "https://example.com".parse().unwrap(), user_picture_url: "https://example.com/user_picture".parse().unwrap(), functions: Vec::new(), can_download_files: None, can_upload_files: None, release: None, version: None, mobile_css_url: None, advanced_features: Vec::new(), can_manage_own_files: None, user_quota: None, max_upload_file_size: None, user_homepage: None, site_id: None, site_calendar_type: None, user_calendar_type: None, theme: None, }, serde_json::from_value(json!({ "sitename": "site_name", "username": "username", "firstname": "first_name", "lastname": "last_name", "fullname": "full_name", "lang": "language", "userid": 0, "siteurl": "https://example.com", "userpictureurl": "https://example.com/user_picture", "functions": [], "mobilecssurl": "", "advancedfeatures": [], }))?, ); Ok(()) } #[test] fn test_function_deserialization() -> serde_json::Result<()> { assert_eq!( Function { name: "name".into(), version: "version".into() }, serde_json::from_value(json!({"name": "name", "version": "version"}))? ); Ok(()) } #[test] fn test_feature_deserialization() -> serde_json::Result<()> { assert_eq!( Feature { name: "name".into(), enabled: true, }, serde_json::from_value(json!({"name": "name", "value": 1}))? ); Ok(()) } } edu-sync-0.3.2/edu-ws/src/response/mod.rs000066400000000000000000000004761501243541400202270ustar00rootroot00000000000000//! Responses to several web service requests. pub mod config; pub mod content; pub mod course; pub mod info; use serde_repr::Deserialize_repr; #[derive(Deserialize_repr, Copy, Clone, Debug, Eq, Hash, PartialEq)] #[repr(u8)] pub enum SummaryFormat { Html = 1, Moodle = 0, Plain = 2, Markdown = 4, } edu-sync-0.3.2/edu-ws/src/serde.rs000066400000000000000000000017501501243541400167100ustar00rootroot00000000000000//! Utilities for serde. use std::{borrow::Cow, convert::Infallible}; use serde::{de::DeserializeOwned, Deserialize}; use serde_with::serde_conv; #[derive(Deserialize, Debug, PartialEq)] #[serde(untagged, remote = "Result")] pub enum UntaggedResult { Ok(T), Err(E), } #[derive(Deserialize)] pub struct UntaggedResultHelper( #[serde(with = "UntaggedResult")] pub Result, ); serde_conv!( pub NumBool, bool, |source: &bool| *source as u8, |value| match value { 0 => Ok(false), 1 => Ok(true), value => Err(format!("bool out of range: {}", value)), } ); serde_with::serde_conv!( pub StringAsHtml, String, |string: &str| html_escape::encode_text(string).into_owned(), |html: String| -> Result<_, Infallible> { match html_escape::decode_html_entities(&html) { Cow::Owned(string) => Ok(string), Cow::Borrowed(_) => Ok(html), } } ); edu-sync-0.3.2/edu-ws/src/token/000077500000000000000000000000001501243541400163555ustar00rootroot00000000000000edu-sync-0.3.2/edu-ws/src/token/login.rs000066400000000000000000000100211501243541400200250ustar00rootroot00000000000000//! Login-based token requesting. use std::result; use serde::{Deserialize, Serialize}; use thiserror::Error; use url::Url; use crate::{serde::UntaggedResultHelper, token::Token}; #[derive(Debug)] pub struct Client { http_client: reqwest::Client, login_url: Url, } #[derive(Error, Deserialize, Debug, PartialEq)] #[error("{error}")] pub struct Error { error: String, #[serde(rename = "errorcode")] error_code: ErrorCode, #[serde(rename = "stacktrace")] stack_trace: String, #[serde(rename = "debuginfo")] debug_info: String, #[serde(rename = "reproductionlink")] reproduction_url: Url, } #[derive(Deserialize, Debug, PartialEq)] pub enum ErrorCode { #[serde(rename = "invalidlogin")] InvalidLogin, #[serde(rename = "enablewsdescription")] WsDisabled, } #[derive(Deserialize, Debug, PartialEq)] pub struct Response { pub token: Token, #[serde(default, rename = "privatetoken")] pub private_token: Option, } impl Client { #[must_use] pub fn new(http_client: reqwest::Client, site_url: &Url) -> Self { let login_url = site_url.join("login/token.php").unwrap(); Self { http_client, login_url, } } pub async fn login(&self, username: &str, password: &str) -> Result { #[derive(Serialize)] struct LoginRequest<'a> { username: &'a str, password: &'a str, service: &'a str, } let response = self .http_client .post(self.login_url.clone()) .query(&LoginRequest { username, password, service: "moodle_mobile_app", }) .send() .await? .json::>() .await? .0?; Ok(response) } } #[derive(Error, Debug)] pub enum ReceiveError { #[error(transparent)] LoginRequestError(#[from] Error), #[error(transparent)] HttpError(#[from] reqwest::Error), } pub type Result = result::Result; #[cfg(test)] mod tests { use serde_json::json; use super::*; #[test] fn test_login_response_deserialization() -> serde_json::Result<()> { assert_eq!( Response { token: "9859148a89546f0efe716a58e340849b".parse().unwrap(), private_token: Some( "8RpHJevJ42W7QN23OMkeYcdOYw3YfWgWGKsak7WB3Z88wcApSCVZ9TgY6M5fEO1m".to_string() ), }, serde_json::from_value(json!({ "token": "9859148a89546f0efe716a58e340849b", "privatetoken": "8RpHJevJ42W7QN23OMkeYcdOYw3YfWgWGKsak7WB3Z88wcApSCVZ9TgY6M5fEO1m" }))? ); assert_eq!( Response { token: "9859148a89546f0efe716a58e340849b".parse().unwrap(), private_token: None, }, serde_json::from_value(json!({ "token": "9859148a89546f0efe716a58e340849b", "privatetoken": null }))? ); Ok(()) } #[test] fn test_login_error_deserialization() -> serde_json::Result<()> { assert_eq!( Error { error: "Invalid login, please try again".to_string(), error_code: ErrorCode::InvalidLogin, stack_trace: "* line 113 of /login/token.php: moodle_exception thrown\n" .to_string(), debug_info: "\nError code: invalidlogin".to_string(), reproduction_url: "https://example.com/".parse().unwrap(), }, serde_json::from_value(json!({ "error": "Invalid login, please try again", "errorcode": "invalidlogin", "stacktrace": "* line 113 of /login/token.php: moodle_exception thrown\n", "debuginfo": "\nError code: invalidlogin", "reproductionlink": "https://example.com/" }))? ); Ok(()) } } edu-sync-0.3.2/edu-ws/src/token/mod.rs000066400000000000000000000020261501243541400175020ustar00rootroot00000000000000//! Tokens and SSO. pub mod login; pub mod sso; use std::{str, string::ToString}; use edu_ws_derive::{DerefWrapper, FromWrapper, HexWrapper}; use serde::{Deserialize, Serialize}; use url::Url; #[derive( HexWrapper, DerefWrapper, FromWrapper, Serialize, Deserialize, Clone, Copy, Eq, Hash, PartialEq, )] pub struct Token(#[serde(with = "hex")] pub [u8; 16]); impl Token { pub fn apply(&self, url: &mut Url) { url.query_pairs_mut() .append_pair("token", &self.to_string()); } } #[cfg(test)] mod tests { use super::*; #[test] fn test_token_deserialization() -> serde_json::Result<()> { assert_eq!( "6191f7ea9da0a4aed1cc9ddb23bf4aa7".parse::().unwrap(), serde_json::from_value(serde_json::json!("6191f7ea9da0a4aed1cc9ddb23bf4aa7"))? ); assert_eq!( "\"6191f7ea9da0a4aed1cc9ddb23bf4aa7\"".to_string(), serde_json::to_string(&"6191f7ea9da0a4aed1cc9ddb23bf4aa7".parse::().unwrap())? ); Ok(()) } } edu-sync-0.3.2/edu-ws/src/token/sso.rs000066400000000000000000000056011501243541400175310ustar00rootroot00000000000000//! SSO-based token creation. use std::{str, string::ToString}; use base64::prelude::*; use edu_ws_derive::{DerefWrapper, FromWrapper, HexWrapper}; use serde::{Deserialize, Serialize}; use thiserror::Error; use url::Url; use super::Token; #[derive( HexWrapper, DerefWrapper, FromWrapper, Serialize, Deserialize, Clone, Copy, Eq, Hash, PartialEq, )] pub struct Signature(#[serde(with = "hex")] pub [u8; 16]); impl Signature { fn from(site_url: &Url, passport: f64) -> Self { let mut context = md5::Context::new(); context.consume(site_url.as_str().trim_end_matches('/')); context.consume(passport.to_string()); Self(context.compute().into()) } } #[derive(PartialEq, Debug)] pub struct SSOTokenBuilder { expected_signature: Signature, } #[derive(Error, Debug)] pub enum Error { #[error("invalid signature (expected {expected:?}, found {found:?})")] InvalidSignature { expected: Signature, found: Signature, }, #[error("invalid token url")] InvalidTokenUrl, } impl SSOTokenBuilder { #[must_use] pub fn prepare_sso(site_url: &Url, launch_url: Url, url_scheme: &str) -> (Url, Self) { let passport = rand::random::() * 1000.0; let mut login_url = launch_url; login_url .query_pairs_mut() .append_pair("service", "moodle_mobile_app") .append_pair("passport", &passport.to_string()) .append_pair("urlscheme", url_scheme); let expected_signature = Signature::from(site_url, passport); (login_url, Self { expected_signature }) } fn parse_token_url(token_url: &Url) -> Result<(Signature, Token), Error> { let validation_token = token_url .domain() .ok_or(Error::InvalidTokenUrl)? .trim_start_matches("token="); // Validation String Format: ::: const VALIDATION_LEN: usize = 32 + ":::".len() + 32; let mut validation_bytes = [0_u8; VALIDATION_LEN]; BASE64_STANDARD .decode_slice(validation_token, &mut validation_bytes) .or(Err(Error::InvalidTokenUrl))?; let validation_str = str::from_utf8(&validation_bytes).or(Err(Error::InvalidTokenUrl))?; let signature_hex = &validation_str[..32]; let token_hex = &validation_str[32 + ":::".len()..]; Ok((signature_hex.parse().unwrap(), token_hex.parse().unwrap())) } /// This required token is received in the form `edu-sync://token=TOKEN` pub fn validate(self, token_url: &Url) -> Result { let (found_signature, token) = Self::parse_token_url(token_url)?; if self.expected_signature == found_signature { Ok(token) } else { Err(Error::InvalidSignature { expected: self.expected_signature, found: found_signature, }) } } } edu-sync-0.3.2/edu-ws/src/ws.rs000066400000000000000000000221761501243541400162440ustar00rootroot00000000000000//! A client for web service requests. use std::{fmt, result}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde_with::serde_as; use thiserror::Error; use tracing::{debug, error}; use url::Url; use crate::{ response::{content::Section, course::Course, info::Info}, serde::NumBool, token::Token, }; #[derive(Error, Deserialize, Debug, PartialEq)] #[serde(tag = "errorcode")] pub enum Error { #[error("access exception: {message}")] #[serde(rename = "accessexception")] AccessException { message: String }, #[error("course context not valid: {message}")] #[serde(rename = "errorcoursecontextnotvalid")] CourseContextNotValid { message: String }, #[error("invalid token: {message}")] #[serde(rename = "invalidtoken")] InvalidToken { message: String }, #[error("invalid param: {message}{}", { match debuginfo { Some(debuginfo) => format!(", debuginfo: {debuginfo}"), None => String::new(), } })] #[serde(rename = "errorinvalidparam")] #[serde(alias = "invalidparameter")] InvalidParam { message: String, debuginfo: Option, }, } #[derive(Error, Debug)] pub enum RequestError { #[error(transparent)] WsError(#[from] Error), #[error(transparent)] HttpError(#[from] reqwest::Error), #[error(transparent)] Decode(#[from] serde_path_to_error::Error), } impl RequestError { pub fn is_http(&self) -> bool { matches!(self, Self::HttpError(_)) } } pub type Result = result::Result; #[derive(Debug)] pub struct Client { http_client: reqwest::Client, ws_url: Url, token: Token, lang: Option, } impl Client { #[must_use] pub fn new( http_client: reqwest::Client, site_url: &Url, token: Token, lang: Option, ) -> Self { let ws_url = site_url.join("webservice/rest/server.php").unwrap(); Self { http_client, ws_url, token, lang, } } async fn call_web_service(&self, function: &str, params: Option<&P>) -> Result where T: DeserializeOwned, P: Serialize + Sync + fmt::Debug + ?Sized, { #[derive(Serialize)] struct WsQuery<'a> { #[serde(rename = "wstoken")] token: &'a Token, #[serde(rename = "wsfunction")] function: &'a str, #[serde(rename = "moodlewsrestformat")] rest_format: &'a str, } #[derive(Serialize)] struct Params<'a, P: ?Sized> { #[serde(flatten)] params: Option<&'a P>, /// Filter text /// /// When deactivated, localization fails and versions in multiple /// languages are being concatenated. #[serde(rename = "moodlewssettingfilter")] filter: bool, /// Force a session language #[serde(rename = "moodlewssettinglang")] lang: Option<&'a str>, } debug!(function, params = tracing::field::debug(params)); let response = self .http_client .post(self.ws_url.clone()) .query(&WsQuery { token: &self.token, function, rest_format: "json", }) .form(&Params { filter: true, params, lang: self.lang.as_deref(), }) .send() .await? .text() .await .unwrap(); debug!(response); let de = &mut serde_json::Deserializer::from_str(&response); let ok_err = match serde_path_to_error::deserialize(de) { Ok(value) => return Ok(value), Err(err) => err, }; let de = &mut serde_json::Deserializer::from_str(&response); match serde_path_to_error::deserialize(de) { Ok(value) => Err(RequestError::WsError(value)), Err(err) => { error!(%ok_err, "Could not deserialize response"); error!(%err, "Could not deserialize error"); Err(RequestError::Decode(ok_err)) } } } pub async fn get_info(&self) -> Result { self.call_web_service::<_, ()>("core_webservice_get_site_info", None) .await } pub async fn get_courses(&self, user_id: u64, return_user_count: bool) -> Result> { #[serde_as] #[derive(Serialize, Debug)] struct Params { #[serde(rename = "userid")] user_id: u64, #[serde_as(as = "Option")] #[serde(rename = "returnusercount")] return_user_count: Option, } let mut res = self .call_web_service::, _>( "core_enrol_get_users_courses", Some(&Params { user_id, return_user_count: Some(return_user_count), }), ) .await; // moodle has introduced `includestealthmodules` in version 3.7: // https://tracker.moodle.org/browse/MDL-64886 // If the current moodle instance rejects the parameter, we try again without // it. if let Err(RequestError::WsError(Error::InvalidParam { debuginfo: Some(debuginfo), .. })) = &res { if debuginfo.contains("returnusercount") { debug!("retrying without returnusercount"); res = self .call_web_service::, _>( "core_enrol_get_users_courses", Some(&Params { user_id, return_user_count: None, }), ) .await; } } res } pub async fn get_contents(&self, course_id: u64) -> Result> { #[serde_as] #[derive(Serialize, Debug)] struct Params<'a> { #[serde(rename = "courseid")] course_id: u64, #[serde(rename = "options[0][name]")] include_stealth_modules_name: Option<&'a str>, #[serde_as(as = "Option")] #[serde(rename = "options[0][value]")] include_stealth_modules_value: Option, } let mut res = self .call_web_service( "core_course_get_contents", Some(&Params { course_id, include_stealth_modules_name: Some("includestealthmodules"), include_stealth_modules_value: Some(true), }), ) .await; // moodle has introduced `includestealthmodules` in version 3.5.3: // https://tracker.moodle.org/browse/MDL-63542 // If the current moodle instance complains rejects parameter, we try again // without it. if let Err(RequestError::WsError(Error::InvalidParam { message, .. })) = &res { if message.contains("includestealthmodules") { res = self .call_web_service( "core_course_get_contents", Some(&Params { course_id, include_stealth_modules_name: None, include_stealth_modules_value: None, }), ) .await; } } res } } #[cfg(test)] mod tests { use serde_json::json; use super::*; #[test] fn test_ws_result_deserialization() -> serde_json::Result<()> { assert_eq!( Error::InvalidToken { message: "message".to_string() }, serde_json::from_value(json!({ "errorcode": "invalidtoken", "exception": "moodle_exception", "message": "message", }))? ); assert_eq!( Error::InvalidParam { message: "The param \"includestealthmodules\" is invalid.".to_string(), debuginfo: None, }, serde_json::from_value(json!({ "errorcode": "errorinvalidparam", "exception": "moodle_exception", "message": "The param \"includestealthmodules\" is invalid.", }))? ); assert_eq!( Error::InvalidParam { message: "Invalid parameter value detected".to_string(), debuginfo: Some( "Unexpected keys (returnusercount) detected in parameter array.".to_string() ), }, serde_json::from_value(json!({ "errorcode": "invalidparameter", "exception": "invalid_parameter_exception", "message": "Invalid parameter value detected", "debuginfo": "Unexpected keys (returnusercount) detected in parameter array.", }))? ); Ok(()) } } edu-sync-0.3.2/rustfmt.toml000066400000000000000000000006221501243541400156430ustar00rootroot00000000000000unstable_features = true condense_wildcard_suffixes = true error_on_line_overflow = true format_code_in_doc_comments = true format_macro_matchers = true format_strings = true group_imports = "StdExternalCrate" imports_granularity = "Crate" normalize_comments = true normalize_doc_attributes = true reorder_impl_items = true use_field_init_shorthand = true use_try_shorthand = true wrap_comments = true