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.