pub struct Rule { /* private fields */ }
Expand description
A Rule
can be used to re-write parts of a AbsolutePackageUrl
.
Implementations§
Source§impl Rule
impl Rule
Sourcepub fn new(
host_match: impl Into<String>,
host_replacement: impl Into<String>,
path_prefix_match: impl Into<String>,
path_prefix_replacement: impl Into<String>,
) -> Result<Self, RuleParseError>
pub fn new( host_match: impl Into<String>, host_replacement: impl Into<String>, path_prefix_match: impl Into<String>, path_prefix_replacement: impl Into<String>, ) -> Result<Self, RuleParseError>
Creates a new Rule
.
Sourcepub fn host_match(&self) -> &str
pub fn host_match(&self) -> &str
The exact hostname to match.
Sourcepub fn host_replacement(&self) -> &str
pub fn host_replacement(&self) -> &str
The new hostname to replace the matched host_match
with.
Sourcepub fn path_prefix_match(&self) -> &str
pub fn path_prefix_match(&self) -> &str
The absolute path to a package or directory to match against.
Sourcepub fn path_prefix_replacement(&self) -> &str
pub fn path_prefix_replacement(&self) -> &str
The absolute path to a single package or a directory to replace the
matched path_prefix_match
with.
Sourcepub fn apply(
&self,
uri: &AbsolutePackageUrl,
) -> Option<Result<AbsolutePackageUrl, ParseError>>
pub fn apply( &self, uri: &AbsolutePackageUrl, ) -> Option<Result<AbsolutePackageUrl, ParseError>>
Apply this Rule
to the given AbsolutePackageUrl
.
In order for a Rule
to match a particular fuchsia-pkg:// URI, host
must match uri
’s
host exactly and path
must prefix match the uri
’s path at a ‘/’ boundary. If path
doesn’t end in a ‘/’, it must match the entire uri
path.
When a Rule
does match the given uri
, it will replace the matched hostname and path
with the given replacement strings, preserving the unmatched part of the path, the hash
query parameter, and any fragment.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Rule
impl<'de> Deserialize<'de> for Rule
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
impl Eq for Rule
impl StructuralPartialEq for Rule
Auto Trait Implementations§
impl Freeze for Rule
impl RefUnwindSafe for Rule
impl Send for Rule
impl Sync for Rule
impl Unpin for Rule
impl UnwindSafe for Rule
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)