usestd::{
fs,path::{Path, PathBuf},};usefile_type_enum::FileType as FileTypeEnum;usecrate::error::*;/// Follow symlink at `path` in one level, and return the new path.
////// # Errors:
/// - If `path` does not exist
/// - If `path` is not a symlink
/// - If `Io::Error` from `fs::read_link(path)`
pubfnsymlink_follow<P:AsRef<Path>>(path: P)->Result<PathBuf>{let path = path.as_ref();if!path.exists(){returnErr(Error::NotFoundError(path.to_path_buf()));// "while trying to read symlink target path",
}if!FileTypeEnum::from_path(path)?.is_symlink(){returnErr(Error::NotASymlinkError(path.to_path_buf()));// "while trying to read symlink target path",
}let target =fs::read_link(&path)?;Ok(target)}