pub struct Interface {
pub module: String,
pub imports: Vec<String>,
pub types: Vec<TyDecl>,
pub traits: Vec<TraitSig>,
pub impls: Vec<ImplSig>,
pub items: Vec<Item>,
}Expand description
A module’s published signature.
Fields§
§module: String§imports: Vec<String>The modules this contract was checked against, rendered as import lines.
A .becki is read back as a module, so a name it uses but does not declare has to be
resolvable from the file itself. A published impl Priced for Book, or a bound
def total[T: Priced], names a trait that may live in another module — and without the
import line the reader has nothing to resolve Priced against and reports B0383, which
made beck iface write a file beck check refused.
Deliberately not in Interface::digest: the digest is about the signatures published,
and this is provenance for resolving the names in them. Hashing it would report an API
change to every consumer when a module gained an import its contract never mentions.
types: Vec<TyDecl>Types in declaration order, so the rendered file is stable.
traits: Vec<TraitSig>The trait declarations this module owns.
impls: Vec<ImplSig>The impl headers this module owns — the bodies stay behind, and what crosses is that the
implementation exists and what it promises. Without these, a call in an importing module has
a trait and nothing to resolve it to.
items: Vec<Item>Implementations§
Source§impl Interface
impl Interface
pub fn item(&self, name: &str) -> Option<&Item>
Sourcepub fn digest(&self) -> String
pub fn digest(&self) -> String
A content hash of everything a downstream module can depend on.
Deliberately not a hash of the rendered file: a comment, or a change of field order in the printer, must not invalidate a build. It is a hash of the meaning.
Sourcepub fn parse(
module: &str,
src: &str,
map: &mut SourceMap,
diags: &mut Diagnostics,
) -> Interface
pub fn parse( module: &str, src: &str, map: &mut SourceMap, diags: &mut Diagnostics, ) -> Interface
Read a .becki back.
The caller’s SourceMap, for the same reason crate::project gives one to every
module it loads: a diagnostic about orders.becki has to point into orders.becki. A map
made and dropped here would leave every diagnostic carrying a FileId the renderer resolves
against somebody else’s file, which is worse than no span at all — it points confidently at
an unrelated line.
Sourcepub fn parse_with(
module: &str,
src: &str,
imports: &[(String, Interface)],
map: &mut SourceMap,
diags: &mut Diagnostics,
) -> Interface
pub fn parse_with( module: &str, src: &str, imports: &[(String, Interface)], map: &mut SourceMap, diags: &mut Diagnostics, ) -> Interface
The same, against the interfaces of the modules this one imports.
A .becki is checked as a module, so a name it uses but does not declare needs the same
thing a .beck needs: the contract of whatever declares it. A published impl Priced for Book or a bound def total[T: Priced] names a trait that may live elsewhere, and reading
the file with nothing to resolve against reported B0383 — beck iface wrote a file
beck check refused. crate::project has every dependency’s interface in hand by the
time it reads this one, because it works in dependency order, deepest first.
Interface::parse passing none is still right for a caller that has none — comparing an
old contract to a new one for --wire-compat reads signatures, and a trait it cannot
resolve is reported rather than silently accepted.