pub enum ComponentAddress {
Absolute {
url: Url,
},
RelativePath {
scheme: String,
url: Url,
context: ComponentResolutionContext,
},
}
Expand description
Indicates the kind of ComponentAddress
, and holds ComponentAddress
properties specific to
its kind. Note that there is no kind for a relative resource component URL (a URL that only
contains a resource fragment, such as #meta/comp.cm
) because ComponentAddress::from_url()
and ComponentAddress::from_url_and_context()
will translate a resource fragment component URL
into one of the fully-resolvable ComponentAddress
s.
Variants§
Absolute
A fully-qualified component URL.
RelativePath
A relative Component URL, starting with the package path; for example a subpackage relative URL such as “needed_package#meta/dep_component.cm”.
Fields
scheme: String
This is the scheme of the ancestor component’s absolute URL, used to identify the
Resolver
in a ResolverRegistry
.
url: Url
The relative URL, represented as a url::Url
with the relative:///
base prefix.
url::Url
cannot represent relative urls directly.
context: ComponentResolutionContext
An opaque value (from the perspective of component resolution)
required by the resolver when resolving a relative package path.
For a given child component, this property is populated from a
parent component’s resolution_context
, as returned by the parent
component’s resolver.
Implementations§
Source§impl ComponentAddress
impl ComponentAddress
Sourcepub fn from_absolute_url(component_url: &Url) -> Result<Self, ResolverError>
pub fn from_absolute_url(component_url: &Url) -> Result<Self, ResolverError>
Parse the given absolute component_url
and create a ComponentAddress
with kind Absolute
.
Sourcepub async fn from_url<C: ComponentInstanceInterface>(
component_url: &Url,
component: &Arc<C>,
) -> Result<Self, ResolverError>
pub async fn from_url<C: ComponentInstanceInterface>( component_url: &Url, component: &Arc<C>, ) -> Result<Self, ResolverError>
Parse the given component_url
to determine if it is an absolute URL, a relative
subpackage URL, or a relative resource URL, and return the corresponding ComponentAddress
enum variant and value. If the URL is relative, use the component instance to get the
required resolution context from the component’s parent.
Sourcepub async fn from_url_and_context<C: ComponentInstanceInterface>(
component_url: &Url,
context: ComponentResolutionContext,
component: &Arc<C>,
) -> Result<Self, ResolverError>
pub async fn from_url_and_context<C: ComponentInstanceInterface>( component_url: &Url, context: ComponentResolutionContext, component: &Arc<C>, ) -> Result<Self, ResolverError>
Parse the given component_url
to determine if it is an absolute URL, a relative
subpackage URL, or a relative resource URL, and return the corresponding ComponentAddress
enum variant and value. If the URL is relative, the provided context is used.
Sourcepub fn clone_with_new_resource(
&self,
some_resource: Option<&str>,
) -> Result<Self, ResolverError>
pub fn clone_with_new_resource( &self, some_resource: Option<&str>, ) -> Result<Self, ResolverError>
Creates a new ComponentAddress
from self
by replacing only the
component URL resource.
Sourcepub fn is_absolute(&self) -> bool
pub fn is_absolute(&self) -> bool
True if the address is Absolute
.
Sourcepub fn is_relative_path(&self) -> bool
pub fn is_relative_path(&self) -> bool
True if the address is RelativePath
.
Sourcepub fn context(&self) -> &ComponentResolutionContext
pub fn context(&self) -> &ComponentResolutionContext
Returns the ComponentResolutionContext
value required to resolve for a
RelativePath
component URL.
Panics if called for an Absolute
component address.
Sourcepub fn scheme(&self) -> &str
pub fn scheme(&self) -> &str
Returns the URL scheme either provided for an Absolute
URL or derived
from the component’s parent. The scheme is used to look up a registered
resolver, when resolving the component.
Sourcepub fn query(&self) -> Option<&str>
pub fn query(&self) -> Option<&str>
Returns the optional query value for an Absolute
component URL.
Always returns None
for Relative
component URLs.
Sourcepub fn resource(&self) -> Option<&str>
pub fn resource(&self) -> Option<&str>
Returns the optional component resource, from the URL fragment.
Sourcepub fn url(&self) -> &str
pub fn url(&self) -> &str
Returns the resolver-ready URL string and, if it is a RelativePath
,
Some(context)
, or None
for an Absolute
address.
Sourcepub fn to_url_and_context(&self) -> (&str, Option<&ComponentResolutionContext>)
pub fn to_url_and_context(&self) -> (&str, Option<&ComponentResolutionContext>)
Returns the url()
and Some(context)
for resolving the URL,
if the kind is RelativePath
(or None
if Absolute
).
Trait Implementations§
Source§impl Clone for ComponentAddress
impl Clone for ComponentAddress
Source§fn clone(&self) -> ComponentAddress
fn clone(&self) -> ComponentAddress
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ComponentAddress
impl Debug for ComponentAddress
Source§impl PartialEq for ComponentAddress
impl PartialEq for ComponentAddress
impl Eq for ComponentAddress
impl StructuralPartialEq for ComponentAddress
Auto Trait Implementations§
impl Freeze for ComponentAddress
impl RefUnwindSafe for ComponentAddress
impl Send for ComponentAddress
impl Sync for ComponentAddress
impl Unpin for ComponentAddress
impl UnwindSafe for ComponentAddress
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
)