Function time::util::local_offset::set_soundness
source · pub unsafe fn set_soundness(soundness: Soundness)
Expand description
Set whether obtaining the local UTC offset is allowed to invoke undefined behavior.
Safety
If this method is called with Soundness::Sound
, the call is always sound. If this method
is called with Soundness::Unsound
, the following conditions apply.
- If the operating system is not Unix-like, the call is sound.
- If the process is single-threaded, the call is sound.
- If the process is multi-threaded, no other thread may mutate the environment in any way at the same time a call to a method that obtains the local UTC offset. This includes adding, removing, or modifying an environment variable.
Note that you must not only verify this safety condition for your code, but for all code
that will be included in the final binary. Notably, it applies to both direct and transitive
dependencies and to both Rust and non-Rust code. For this reason it is not possible to
soundly pass Soundness::Unsound
to this method if you are writing a library that may
used by others.
The following methods currently obtain the local UTC offset: