Added dedicated error for `std::path::Path` encoding. Fixed broken link in documentation.
This commit is contained in:
parent
6ff33cd8c2
commit
f70e94a427
|
|
@ -18,6 +18,10 @@ pub enum EncodeError {
|
||||||
/// An uncommon error occured, see the inner text for more information
|
/// An uncommon error occured, see the inner text for more information
|
||||||
Other(&'static str),
|
Other(&'static str),
|
||||||
|
|
||||||
|
/// A `std::path::Path` was being encoded but did not contain a valid `&str` representation
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
InvalidPathCharacters,
|
||||||
|
|
||||||
/// The targetted writer encountered an `std::io::Error`
|
/// The targetted writer encountered an `std::io::Error`
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
Io {
|
Io {
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ impl Encode for &'_ Path {
|
||||||
fn encode<E: Encoder>(&self, encoder: E) -> Result<(), EncodeError> {
|
fn encode<E: Encoder>(&self, encoder: E) -> Result<(), EncodeError> {
|
||||||
match self.to_str() {
|
match self.to_str() {
|
||||||
Some(str) => str.encode(encoder),
|
Some(str) => str.encode(encoder),
|
||||||
None => Err(EncodeError::Other("Path contains invalid UTF-8 characters")),
|
None => Err(EncodeError::InvalidPathCharacters),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@ use config::Config;
|
||||||
|
|
||||||
/// Encode the given value into the given slice. Returns the amount of bytes that have been written.
|
/// Encode the given value into the given slice. Returns the amount of bytes that have been written.
|
||||||
///
|
///
|
||||||
/// Will take the [Default] configuration. See the [config] module for more information.
|
/// Will take the [standard] configuration. See the [config] module for more information.
|
||||||
///
|
///
|
||||||
/// [Default]: config/struct.Default.html
|
/// [standard]: config/struct.Configuration.html#method.standard
|
||||||
pub fn encode_into_slice<E: enc::Encode>(
|
pub fn encode_into_slice<E: enc::Encode>(
|
||||||
val: E,
|
val: E,
|
||||||
dst: &mut [u8],
|
dst: &mut [u8],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue