pub struct Origin { /* private fields */ }Expand description
The origin of a document or a fetch initiator.
Network schemes (http, https, ftp, ws, wss) become tuple origins
whose equality ignores default ports. Everything else (resource:, data:,
about:, file:, custom schemes) is opaque: it serializes as "null" in
JavaScript and never compares equal to another origin.
An origin may also carry internal/privileged status. Only browser-created
origins (Origin::internal) hold internal privileges. No URL scheme grants
it: loading resource:// content does not make a page internal.
Implementations§
Source§impl Origin
impl Origin
Sourcepub fn from_url(url: &Url) -> Self
pub fn from_url(url: &Url) -> Self
Computes the origin of a parsed URL.
No URL grants internal privilege: a resource:// page is an ordinary
opaque origin. Internal status is only ever conferred explicitly by the
browser through Origin::internal for chrome-created origins.
Sourcepub fn from_url_string(url: &str) -> Self
pub fn from_url_string(url: &str) -> Self
Computes the origin of a URL string, falling back to a fresh opaque origin when the string does not parse.
Sourcepub fn internal() -> Self
pub fn internal() -> Self
A fresh internal privileged origin (for browser-internal components).
Sourcepub fn opaque() -> Self
pub fn opaque() -> Self
A fresh opaque origin (sandboxed contexts, parse failures, unprivileged opaque origins).
Sourcepub fn ascii_serialization(&self) -> String
pub fn ascii_serialization(&self) -> String
Serialization exposed to JavaScript: scheme://host[:port] or "null".
Sourcepub fn is_network(&self) -> bool
pub fn is_network(&self) -> bool
Whether this is an http(s):// tuple origin that proxies a real web page.
Sourcepub fn is_internal(&self) -> bool
pub fn is_internal(&self) -> bool
Whether this origin is internal and holds browser privileges (access to resource:, file:).
Sourcepub fn same_origin(&self, other: &Self) -> bool
pub fn same_origin(&self, other: &Self) -> bool
Same-origin check. Opaque origins are never equal to any other origin.
Trait Implementations§
impl Eq for Origin
impl StructuralPartialEq for Origin
Auto Trait Implementations§
impl Freeze for Origin
impl RefUnwindSafe for Origin
impl Send for Origin
impl Sync for Origin
impl Unpin for Origin
impl UnsafeUnpin for Origin
impl UnwindSafe for Origin
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more