pub trait FromOptionalField<T> {
// Required methods
fn optional(self) -> Result<Option<T>, Error>;
fn required(self, field: impl Into<String>) -> Result<T, Error>;
}
Expand description
An extension trait that adds the methods optional and required to any
Option containing a type implementing TryInto<U, Error = Error>
Converts an optional protobuf field to an option of a different type
Returns None if the option is None, otherwise calls TryInto::try_into
on the contained data, returning any error encountered
Converts an optional protobuf field to a different type, returning an error if None
Returns Error::MissingRequiredField if None, otherwise calls TryInto::try_into
on the contained data, returning any error encountered