Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4e8a7d6
chore(quest): claim quest/m1/ffi-refusals/moq-pin.md
kixelated Nov 12, 2026
f21ae87
feat(ffi): export a type the root does not reach by its public path i…
kixelated Nov 12, 2026
1b01081
fix(ffi): name a reached crate's types through the glue's own depende…
kixelated Nov 12, 2026
11d8c73
fix(ffi): keep a reached git dependency's reference, its targets, and…
kixelated Nov 12, 2026
ab877c5
test(ffi): merge a staged API whose reached crate only the exporting …
kixelated Nov 12, 2026
9f78c9b
test(ffi): compare the reached path as the manifest escapes it
kixelated Nov 12, 2026
a87fc44
Merge main; move census comment back above exclude
kixelated Nov 13, 2026
f013ff6
Resolve driver.rs merge: keep both crates and baseline
kixelated Nov 13, 2026
41e2691
fix(ffi): refuse a facade module named as another target's reached cr…
kixelated Nov 13, 2026
6f12f51
style: restore unrelated formatting
kixelated Nov 13, 2026
8fc9dee
fix(ffi): decode a git source's percent-encoded reference
kixelated Nov 13, 2026
71c8196
feat(ffi): reach a type from a crate the facade exports nothing else …
kixelated Nov 13, 2026
5ec628d
test(ffi): drive the reached tls session from every binding
kixelated Nov 13, 2026
5f6fb5e
fix(ffi): never reach another crate's error, and depend on a reached …
kixelated Nov 13, 2026
1049087
docs(ffi): say why the stand-in leaves out mp4_atom
kixelated Nov 13, 2026
9be1612
quest(moq-pin): record the decision to reach signature-only crates
kixelated Nov 13, 2026
439d687
Merge remote-tracking branch 'origin/main' into HEAD
kixelated Nov 13, 2026
fb1dc1a
fix(ffi): an impl Trait + '_ return holds its lifetime, and the stand…
kixelated Nov 13, 2026
f4a3618
quest(moq-pin): what the reach exports at the pin
kixelated Nov 13, 2026
e7a89b4
style(ffi): format the fixture
kixelated Nov 13, 2026
3a86970
fix(ffi): an impl Trait return holds what its hidden type holds, not …
kixelated Nov 13, 2026
e629898
fix(ffi): hold an impl Trait's lifetimes only when its hidden type is…
kixelated Nov 13, 2026
f61f40f
fix(ffi): an impl Trait return crosses only as an object, holding eve…
kixelated Nov 13, 2026
00f6758
docs(ffi): an impl Trait return crosses only as an object; record the…
kixelated Nov 13, 2026
17fed2b
fix(ffi): check an impl Trait a future outputs or a collected iterato…
kixelated Nov 13, 2026
39a91e8
Merge origin/main into quest/m1/ffi-refusals/moq-pin
kixelated Nov 13, 2026
983c3fb
fix(ffi): give main's new test Apis the reached field
kixelated Nov 13, 2026
bb2af3d
fix(ffi): reveal a delegated impl Trait in full, and reach an Into ta…
kixelated Nov 13, 2026
d1fd86f
style(ffi): rustfmt the fixture
kixelated Nov 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions ffi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ is a nightly. The package is the facade: once rustc has checked its library, it
reachable from the crate root, following `pub use` re-exports of other crates' items and
modules, and exports it by fixed rules, or refuses it with a compile error at its span.
So a facade such as moq-ffi exports several crates into one library by re-exporting what
it ships, and a type no path from its root reaches is refused. The prefix of every C name
it ships; a type a signature names that no path from its root reaches exports by its
public path in its own crate ([Rules](#rules)). The prefix of every C name
is the library's crate name, Cargo's `[lib] name`, which defaults to the package's name in
snake case. `--out` writes a crate of `extern "C"` functions over the facade, its runtime
beside it, and the header in `include/<prefix>.h`; `cargo build` on that crate makes a
Expand Down Expand Up @@ -69,7 +70,19 @@ export nothing of their own. A re-export of the standard library's item is refus
its types map by role. A `pub use` of a whole crate, as in `pub use rustls;` or
`pub use web_transport_proto as proto;`, is refused once at that `pub use`, since it puts
every release of that crate in the facade's API; a glob of its root, `pub use dep::*;`,
re-exports its items instead, which export. A type no path reaches is refused.
re-exports its items instead, which export.

A type an export's signature names that no path from the root reaches, as moq-net's
`dial_tcp` returns kio's `Pending`, exports by its shortest public path in its own crate,
`<prefix>::<crate>::<path>`, through that crate's modules and re-exports, with what its own
signatures name in turn. This holds whether or not the facade re-exports anything else of
that crate. The glue depends on that crate directly, as the facade resolves it; a crate
another of its name shares, the facade's root names, or another registry serves is not
reached. A crate only signatures reach keeps the roles of one no export is: its error in a
`Result` crosses as its message, and its type behind an `Arc` as an opaque handle, refused
bare. Its errors, the types implementing `std::error::Error`, are never reached, so an
exported error holding one is an object, as it was. A type no public path names stays
refused.

| Rust | C |
| --- | --- |
Expand Down Expand Up @@ -108,6 +121,7 @@ re-exports its items instead, which export. A type no path reaches is refused.
| `Vec<T>`, `&[T]`, and `Box<[T]>` of any other `T` | `<prefix>_vec_<T>`: an array of `T`'s C values, viewed passed in and owned returned, a slice as a clone; of references only returned; a boxed slice of bytes is refused |
| `BTreeSet<T>`, `BTreeMap<K, V>`, and `serde_json::Map` | as `Vec<T>`, `Vec<(K, V)>`, and `Vec<(String, serde_json::Value)>`: its items in order, from which Rust builds it, keeping the last of a key |
| a returned iterator, such as `slice::Iter` or an `impl Iterator`, that no other rule maps, outside a future, made of core's and alloc's iterators over a slice, string, `Option`, `Result`, or collection, or serde_json's `map::Iter`, `IntoIter`, `Keys`, or `Values`, through `rev`, `chain`, `flatten`, `fuse`, `enumerate`, `peekable`, `copied`, `cloned`, or `filter`, with no trait object inside; a closure or function inside, such as `filter`'s predicate or `split`'s pattern, must drop nothing, and a `filter` only items whose drop runs nothing | what `collect::<Vec<_>>()` makes of it: every item, taken at the call, so a closure inside runs on every item, not only those a caller stopping early would reach |
| a returned `impl Trait`, or one a returned future outputs or a collected iterator yields, other than that future or iterator itself, whose hidden type is an object | that object's handle, which keeps the `impl Trait` itself, so every lifetime it captures must be `'static`: one capturing a borrow, as `impl Clone + '_` does, is refused, and `+ use<>` captures none; one hiding any other type, such as an `Option`, is refused, since the glue cannot name it |
| `Waker`, taken by value | `<prefix>_waker`, as a future's poll takes it |
| a returned `Waker` or `&Waker`, or a returned `Context`, which is only a waker lent for a call | `<prefix>_waker` of a clone of the waker, or the context's: the caller's, to wake through Rust and drop once |
| `&Context` or `&mut Context` of a function returning no `Poll` and no future | `<prefix>_waker`, which the context is made of for the call |
Expand Down
5 changes: 5 additions & 0 deletions ffi/fixtures/api/examples/transcript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ fn main() {
.map(|(name, counter)| format!("{name} {} {}", counter.name(), counter.get()))
.collect();
println!("ranked {}", ranked.join(", "));
let best: Counter = board.best().into();
println!("best {} {}", best.name(), best.get());
let atlas = api::Atlas {
points: [("b", 1, 1), ("ab", 2, 3), ("b", 4, 4)]
.into_iter()
Expand Down Expand Up @@ -583,6 +585,9 @@ fn main() {
println!("nudge {} {}", point.x, point.y);
let config = api::secure("h3");
println!("secure {} {}", api::alpn_lent(&config), api::alpn(config.clone()));
let session = api::resume("h3", 60).unwrap();
println!("resume {} {}", session.alpn(), session.lifetime().seconds);
println!("resume err {}", api::resume("", 60).err().unwrap());
let mut meters = api::Meters::new();
let first = meters.first();
first.add(2);
Expand Down
16 changes: 14 additions & 2 deletions ffi/fixtures/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,12 @@ impl Board {
ranked.sort_by_key(|(_, counter)| std::cmp::Reverse(counter.get()));
ranked.into_iter()
}

/// Its highest counter, through an `impl Trait` that captures no borrow of the board, so
/// it crosses as the counter's handle.
pub fn best(&self) -> impl Into<Counter> + use<> {
(self.counters.values().max_by_key(|counter| counter.get()).cloned()).unwrap_or_default()
}
}

/// Points by name and the ids in use, as hang's renditions and moq-mux's selections: a map
Expand Down Expand Up @@ -2244,8 +2250,8 @@ pub fn nudge(point: &mut Point, by: i32) {
point.y += by;
}

/// A config of a crate no export is, behind an `Arc`, as moq-tokio's listener returns
/// rustls's: an opaque handle, which Rust takes back.
/// A config of a crate the facade re-exports nothing from, behind an `Arc`, as moq-tokio's
/// listener returns rustls's: an opaque handle, which Rust takes back.
pub fn secure(alpn: &str) -> Arc<tls::Config> {
Arc::new(tls::Config::new(alpn))
}
Expand All @@ -2260,6 +2266,12 @@ pub fn alpn_lent(config: &Arc<tls::Config>) -> String {
config.alpn().to_string()
}

/// A session of `alpn` lasting `seconds`, from a crate the facade re-exports nothing from:
/// its type exports by its path there, and its error crosses as its message.
pub fn resume(alpn: &str, seconds: u32) -> Result<tls::Session, tls::Error> {
tls::resume(alpn, seconds)
}

/// `text`'s length, or 0 for none: an optional borrow, lent as the borrow alone is.
pub fn either(text: Option<&str>) -> usize {
text.map_or(0, str::len)
Expand Down
5 changes: 4 additions & 1 deletion ffi/fixtures/reject/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ fixtures/reject/src/lib.rs:1016:1: rust2-ffi: cannot export fn `trust`: trait ob
fixtures/reject/src/lib.rs:1021:1: rust2-ffi: cannot export fn `hazard`: trait object `dyn Hazard`; exclude it in the config to leave it out
fixtures/reject/src/lib.rs:1011:1: note: C cannot implement `Hazard`: unsafe fn `risk`
fixtures/reject/src/lib.rs:1026:1: rust2-ffi: cannot export fn `wide_non_zero`: NonZero `u128`; exclude it in the config to leave it out
fixtures/reject/src/lib.rs:1031:1: rust2-ffi: cannot export fn `boxed_bytes`: boxed slice of bytes `std::boxed::Box<[u8]>`; exclude it in the config to leave it out
fixtures/reject/src/lib.rs:1031:1: rust2-ffi: cannot export fn `hidden_answer`: opaque type `impl std::marker::Copy`; exclude it in the config to leave it out
fixtures/reject/src/lib.rs:1036:1: rust2-ffi: cannot export fn `hidden_items`: opaque type `impl std::marker::Copy`; exclude it in the config to leave it out
fixtures/reject/src/lib.rs:1041:1: rust2-ffi: cannot export fn `hidden_option`: opaque type `impl std::clone::Clone`; exclude it in the config to leave it out
fixtures/reject/src/lib.rs:1046:1: rust2-ffi: cannot export fn `boxed_bytes`: boxed slice of bytes `std::boxed::Box<[u8]>`; exclude it in the config to leave it out
fixtures/reject/src/lib.rs:106:2: rust2-ffi: cannot export method `Text::later`: returned object that borrows `impl std::future::Future<Output = Text<'_>>`; exclude it in the config to leave it out
fixtures/reject/src/lib.rs:112:1: rust2-ffi: cannot export fn `forever`: 'static borrow `&'static [u8]`; exclude it in the config to leave it out
fixtures/reject/src/lib.rs:118:1: rust2-ffi: cannot export fn `boxed`: reference inside a parameter `std::boxed::Box<&str>`; exclude it in the config to leave it out
Expand Down
15 changes: 15 additions & 0 deletions ffi/fixtures/reject/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,21 @@ pub fn wide_non_zero(n: std::num::NonZero<u128>) -> u128 {
n.get()
}

/// A future whose output is an `impl Trait` hiding no object, which the glue cannot name.
pub async fn hidden_answer() -> impl Copy {
1_u32
}

/// A collected iterator whose items are an `impl Trait` hiding no object.
pub fn hidden_items() -> impl Iterator<Item = impl Copy> {
[1_u32].into_iter()
}

/// An `impl Trait` hiding an `Option`, which the glue cannot take apart.
pub fn hidden_option() -> impl Clone {
Some(1_u32)
}

/// A boxed slice of bytes, which no buffer form takes.
pub fn boxed_bytes(bytes: Box<[u8]>) -> usize {
bytes.len()
Expand Down
58 changes: 56 additions & 2 deletions ffi/fixtures/tls/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! A crate the api fixture names behind an `Arc` but does not re-export, as moq-tokio's
//! listener names rustls's server config.
//! A crate the api fixture names in signatures but re-exports nothing from, as moq-tokio's
//! listener names rustls's server config and moq-net's `dial_tcp` names kio's `Pending`.

/// A config: an opaque handle wherever the api fixture returns or takes an `Arc` of it.
#[derive(Debug)]
Expand All @@ -16,3 +16,57 @@ impl Config {
&self.alpn
}
}

mod session {
use crate::policy::Lifetime;

/// A session: an object of a private module, which the api fixture returns bare and no
/// re-export names, so it exports by its path in this crate.
pub struct Session {
alpn: String,
lifetime: Lifetime,
}

impl Session {
pub fn alpn(&self) -> String {
self.alpn.clone()
}

/// A record only this method names, which exports once the session does.
pub fn lifetime(&self) -> Lifetime {
self.lifetime
}
}

/// A session of `alpn` lasting `seconds`, or an error when `alpn` is empty.
pub fn resume(alpn: &str, seconds: u32) -> Result<Session, crate::Error> {
if alpn.is_empty() {
return Err(crate::Error("no protocol to resume".to_string()));
}
Ok(Session {
alpn: alpn.to_string(),
lifetime: Lifetime { seconds },
})
}
}

pub use session::{Session, resume};

pub mod policy {
/// How long a session lasts.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Lifetime {
pub seconds: u32,
}
}

/// An error, which the api fixture returns only as a `Result`'s, so it crosses as its
/// message.
#[derive(Debug)]
pub struct Error(String);

impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.0)
}
}
60 changes: 29 additions & 31 deletions ffi/moq/ffi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,28 @@ exclude = [
"clock::Entered",
"clock::Rng",
"clock::rng",
"frame::Buffer::drain",
"hang::moq_net",
"kio",
"moq_quic::VarInt::from_u64_unchecked",
"moq_sock::demux::Discard::ALL",
"moq_tokio::accept::Failure::classify",
"moq_tokio::accept::Health::failed",
"moq_tokio::quic::Controller::0",
"moq_tokio::quic::demux::Datagram::local",
"moq_tokio::quic::driver::connection::Connection::close_reason",
"moq_tokio::quic::driver::connection::Connection::closed",
"moq_tokio::quic::driver::connection::Connection::congestion_state",
"moq_tokio::quic::driver::connection::Connection::poll_closed",
"moq_tokio::quic::driver::connection::Connection::read_datagram",
"moq_tokio::quic::driver::recv::Stream::read",
"moq_tokio::quic::driver::recv::Stream::read_exact",
"moq_tokio::quic::driver::send::Options::group",
"moq_tokio::quic::driver::send::Stream::stopped",
"moq_tokio::quic::driver::send::Stream::write",
"moq_tokio::tcp::TlsAcceptor::accept",
"moq_tokio::tcp::TlsAcceptor::offered",
"mp4_atom::TrunSamples::iter",
"mp4_atom::Tx3g::box_record",
"mux::catalog::Guard",
"mux::catalog::Producer::modify",
"mux::catalog::Producer<moq::mux::catalog::hang::Extra>::modify",
Expand Down Expand Up @@ -40,39 +59,18 @@ exclude = [
"mux::container::Producer<moq::mux::container::loc::Wire, moq::hang::catalog::TextConfig>::modify",
"mux::container::Producer<moq::mux::container::loc::Wire, moq::hang::catalog::VideoConfig>::modify",
"mux::container::Producer<moq::mux::container::loc::Wire>::modify",
"mux::container::fmp4::Wire::new",
"mux::container::fmp4::Wire::trak",
"mux::container::fmp4::mp4_atom",
"tokio::Server::accept_health",
"tokio::Server::tls_acceptor",
"tokio::connect::Config::deprecated",
"tokio::connect::Config::goaway",
"tokio::connect::Config::resolve",
"tokio::connect::Config::websocket",
"tokio::connection::Monitor::snapshot",
"tokio::connection::Monitor::state",
"tokio::connection::Monitor::state_changed",
"tokio::listen::Config::deprecated",
"tokio::listen::Config::lb",
"tokio::listen::Config::reset",
"tokio::listen::Config::resolve",
"tokio::listen::Config::tcp",
"tokio::listen::Config::unix",
"tokio::quic::Config::congestion_control",
"tokio::quic::Config::controller",
"tokio::quic::Config::deprecated",
"tokio::quic::Config::resolve",
"tokio::server::Config::demux",
"rustls::ClientConfig::cert_compressors",
"rustls::ClientConfig::cert_decompressors",
"rustls::ClientConfig::client_auth_cert_resolver",
"rustls::ClientConfig::key_log",
"rustls::ClientConfig::time_provider",
"rustls::ConfigBuilder<moq_tokio::rustls::ServerConfig, moq::rustls::WantsVerifier>",
"rustls::ConfigBuilder<moq_tokio::rustls::ServerConfig, moq_tokio::rustls::server::WantsServerCert>",
"rustls::client::Resumption::store",
"rustls_pki_types::CertificateDer::from_slice",
"tokio::server::Config::websocket",
"tokio::server::Listener::accept_health",
"tokio::server::Request::quic",
"tokio::server::Request::with_quic_limits",
"tokio::server::Request::within",
"tokio::tls::Connect::build",
"tokio::tls::Connect::deprecated",
"tokio::tls::Listen::deprecated",
"tokio::tls::Listen::load_roots",
"tokio::tls::PeerIdentity::chain",
"tokio::tls::PeerIdentity::from_chain",
"tokio::tls::Serve::resolver",
]
98 changes: 98 additions & 0 deletions ffi/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ fn try_run(args: &[String]) -> Result<ExitCode, String> {
let dir = args.manifest.parent().expect("a manifest path has a parent");
let picks = Picks::parse(&args.cargo, dir)?;
let (facade, patch, checked) = facade(&args.manifest, &targets[0], &picks)?;
let crates = crates(&checked.metadata, &checked.top)?;
let line = facade.line();
// A staged API's spans are relative to the workspace and cargo's home, which hold the
// same files at other paths on another host.
Expand All @@ -105,6 +106,7 @@ fn try_run(args: &[String]) -> Result<ExitCode, String> {
(config::env::CONFIG, args.config.as_os_str()),
(config::env::PACKAGE, line.as_ref()),
(config::env::PATCH, patch.as_ref()),
(config::env::CRATES, crates.as_ref()),
(config::env::MERGE, merge),
(config::env::BASELINE, baseline.as_os_str()),
(config::env::ROOTS, roots.as_ref()),
Expand Down Expand Up @@ -314,6 +316,102 @@ fn facade(manifest: &Path, target: &str, picks: &Picks<'_>) -> Result<(config::P
Ok((facade, patch, checked))
}

/// Each crate the facade builds with, by its library's crate name, as the glue would depend
/// on the very package: by its directory, its exact crates.io version, or its git commit.
/// A name two packages share, or one from another registry, is left out, so a type of its
/// crate the facade does not re-export stays refused.
fn crates(metadata: &Metadata, top: &str) -> Result<String, String> {
let packages: BTreeMap<&str, &Package> = metadata.packages.iter().map(|p| (p.id.as_str(), p)).collect();
let nodes: BTreeMap<&str, &Node> = metadata.resolve.nodes.iter().map(|n| (n.id.as_str(), n)).collect();
let mut named: BTreeMap<String, Option<String>> = BTreeMap::new();
let mut seen = BTreeSet::new();
let mut queue = vec![top];
while let Some(id) = queue.pop() {
let (true, Some(package), Some(node)) = (seen.insert(id), packages.get(id), nodes.get(id)) else {
continue;
};
if id != top
&& let Some(lib) = (package.targets.iter()).find(|t| t.kind.iter().any(|k| k.contains("lib")))
{
let keys = dependency(package);
let lib = lib.name.replace('-', "_");
match named.get(&lib) {
Some(other) if *other != keys => {
named.insert(lib, None);
}
Some(_) => {}
None => {
named.insert(lib, keys);
}
}
}
let built = |kind: &Option<String>| kind.as_deref() != Some("dev");
for dep in node.deps.iter().filter(|d| d.dep_kinds.iter().any(|k| built(&k.kind))) {
queue.push(&dep.pkg);
}
}
let table: toml::Table = (named.into_iter())
.filter_map(|(lib, keys)| Some((lib, toml::Value::String(keys?))))
.collect();
toml::to_string(&table).map_err(|err| format!("writing the crates: {err}"))
}

/// The TOML keys of a dependency on exactly `package`, if the glue can name it.
fn dependency(package: &Package) -> Option<String> {
let name = &package.name;
match package.source.as_deref() {
None => {
let dir = package.manifest_path.parent().expect("a manifest path has a parent");
Some(format!("package = {name:?}, path = {:?}", dir.display().to_string()))
}
Some("registry+https://github.com/rust-lang/crates.io-index" | "sparse+https://index.crates.io/") => {
Some(format!("package = {name:?}, version = \"={}\"", package.version))
}
// By the reference the facade names it by, which is part of its source's identity:
// `?branch=`, `?tag=`, or `?rev=`, or none for the default branch. The lockfile
// pins the commit as the facade's does.
Some(git) if git.starts_with("git+") => {
let url = git["git+".len()..].split('#').next().unwrap_or(git);
let (url, reference) = url.split_once('?').unwrap_or((url, ""));
let reference = match reference.split_once('=') {
Some((key @ ("branch" | "tag" | "rev"), value)) => format!(", {key} = {:?}", decode(value)?),
Some(_) => return None,
None => String::new(),
};
Some(format!("package = {name:?}, git = {url:?}{reference}"))
}
Some(_) => None,
}
}

/// `value` with each `%XX` cargo's source id escapes, as in `?branch=feature%2Fpending`,
/// decoded, or `None` if it is malformed.
fn decode(value: &str) -> Option<String> {
let mut bytes = Vec::with_capacity(value.len());
let mut rest = value.as_bytes();
while let [first, tail @ ..] = rest {
if *first == b'%' {
let hex = std::str::from_utf8(tail.get(..2)?).ok()?;
bytes.push(u8::from_str_radix(hex, 16).ok()?);
rest = &tail[2..];
} else {
bytes.push(*first);
rest = tail;
}
}
String::from_utf8(bytes).ok()
}

#[cfg(test)]
mod decode_tests {
#[test]
fn decodes_a_branch() {
assert_eq!(super::decode("feature%2Fpending").as_deref(), Some("feature/pending"));
assert_eq!(super::decode("main").as_deref(), Some("main"));
assert_eq!(super::decode("bad%2"), None);
}
}

/// The `[patch]` the glue's workspace resolves the exports by as the check did, wherever
/// it builds, as TOML with each path absolute.
fn overrides(metadata: &Metadata, top: &Package) -> Result<String, String> {
Expand Down
Loading