BrowserResourceLoader

Struct BrowserResourceLoader 

Source
pub struct BrowserResourceLoader {
    pub network: Option<Rc<NetworkCore>>,
    pub immediate_pool: Vec<BrowserNetworkMessage>,
}
Expand description

BrowserResourceLoader

High-level resource loading abstraction used by the browser core to obtain content for tabs and internal resources.

Responsibilities:

  • Resolve and fetch resources from resource:/// scheme (bundled/local) and from standard HTTP/HTTPS URLs.
  • Provide a small synchronous/queuing abstraction over the platform network core so callers in the engine/browser can request resources without dealing with the network implementation details.

Processing flow (overview):

  1. Caller requests a URL (either resource:///... or http(s)://...).
  2. If the URL scheme is resource, loader resolves it to a local path or embedded asset and returns the bytes immediately when available.
  3. For HTTP/HTTPS, loader forwards the request to NetworkCore and manages request ids / pending responses. When the network reply is ready, the loader hands the response back to the browser/tab via the expected callback or message path.

Example usage:

use orinium_browser::browser::core::resource_loader::BrowserResourceLoader;
use std::rc::Rc;
use orinium_browser::platform::network::NetworkCore;

let network = Some(Rc::new(NetworkCore::new()));
let loader = BrowserResourceLoader::new(network);

// Typical call (pseudocode):
// let body = loader.fetch(&url)?;
// process body...

Notes for contributors:

  • Keep the loader focused on scheme resolution, simple caching/pooling, and delegation to NetworkCore. Avoid adding heavy parsing logic here.
  • Unit tests should validate resource:/// resolution and HTTP request delegation semantics (e.g. mapping of request IDs to responses).

Fields§

§network: Option<Rc<NetworkCore>>

Optional platform network core used for HTTP/HTTPS requests.

§immediate_pool: Vec<BrowserNetworkMessage>

Immediate pool / internal queue for messages produced by the loader. The concrete type BrowserNetworkMessage represents internal network events; see the network module for details.

Implementations§

Source§

impl BrowserResourceLoader

Source

pub fn new(network: Option<Rc<NetworkCore>>) -> Self

Construct a new resource loader.

network is optional to allow operating in environments where the network stack is not available (tests, limited examples, or when only resource:/// is needed).

Source

pub fn fetch_async(&mut self, url: Url, id: usize)

非同期 fetch: URL と ID を送信するだけ

Source

pub fn fetch_blocking(&self, url: Url) -> Result<BrowserResponse>

Source

pub fn try_receive(&mut self) -> Vec<BrowserNetworkMessage>

UIスレッドから呼ぶ: 受信済みネットワーク結果を取り込む

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,