Originally filed on GitLab.com
https://www.mediawiki.org/wiki/API:Protect - note that any new errors need to be added to mwapi_errors.
Ideally the function would be named mwbot::Page::protect(...).
You be able to borrow some code from https://github.com/legoktm/tfa-protector-bot/blob/f1a933552ce790cbcf2fa9318988da51aff04a2a/src/main.rs#L207
Also take a look at mwbot-rs's contributing instructions.