I'm converting something to use anyhow! type errors everywhere. I have some things that return Result<usefulvalue, &'static str>. About 10,000 such things, because they're generated by a code generator that generates marshaling code from a specification file. I want to return something that can still be 'static, preferably a constant because so many are the same message. anyhow! calls format!, which I don't need here.
Is there some static struct which implements all the traits needed for std::io::error for which the structure is public, so it can just be created with something like:
Also, don't confuse the std::error::Error trait with the std::io::Error type. The first one is what anyhow is built on; the second one is used by the standard library primarily to represent error conditions reported by the OS.
[edit: fixed the write! invocation, sorry about that]
Generally the expectation in Rust is that you will define custom error types to be returned from your own functions, not use prefab types. (Box<dyn std::error::Error> and anyhow::Error are exceptions.) Crates like thiserror can help streamline the process.