Encode the specified non‐modifiable object to the specified formatter. Return 0 on success, and a non‐zero value otherwise. Note that encoder will use encoder options, error and warning streams specified at the construction time.