pub struct PartName(/* private fields */);Expand description
Part 逻辑路径,形式如 /ppt/slides/slide1.xml。
字符串以 / 开头,不含 ..,以 / 分隔。NewType 包装确保
调用方不会“误用相对路径“。
Implementations§
Source§impl PartName
impl PartName
Sourcepub fn from_unchecked(s: impl Into<String>) -> Self
pub fn from_unchecked(s: impl Into<String>) -> Self
用裸路径字符串构造,不做合法性校验。
适用于内部已知合法的场景;外部输入请用 PartName::new。
Sourcepub fn new(s: &str) -> Result<Self, PartNameError>
pub fn new(s: &str) -> Result<Self, PartNameError>
校验并构造。
§错误
PartNameError::NotAbsolute:不以/开头;PartNameError::EmptySegment:含空段(双斜杠);PartNameError::RelSegment:含.或..段。
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
取出内部字符串(消费 self)。
Sourcepub fn to_zip_path(&self) -> &str
pub fn to_zip_path(&self) -> &str
转成 zip 内的相对路径(去掉前导 /)。
Trait Implementations§
impl Eq for PartName
Source§impl Ord for PartName
impl Ord for PartName
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for PartName
impl PartialOrd for PartName
impl StructuralPartialEq for PartName
Auto Trait Implementations§
impl Freeze for PartName
impl RefUnwindSafe for PartName
impl Send for PartName
impl Sync for PartName
impl Unpin for PartName
impl UnsafeUnpin for PartName
impl UnwindSafe for PartName
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.