{"size": 1335, "ext": "scrbl", "max_stars_repo_path": "share/pkgs/racket-doc/scribblings/guide/module-protect.scrbl", "max_stars_repo_name": "takikawa/racket-ppa", "max_stars_repo_stars_event_min_datetime": "2018-07-29T04:13:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-14T16:11:17.000Z", "max_issues_repo_path": "share/pkgs/racket-doc/scribblings/guide/module-protect.scrbl", "max_issues_repo_name": "takikawa/racket-ppa", "max_issues_repo_issues_event_min_datetime": "2017-08-25T20:26:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T17:48:40.000Z", "max_forks_repo_path": "share/pkgs/racket-doc/scribblings/guide/module-protect.scrbl", "max_forks_repo_name": "takikawa/racket-ppa", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 10, "max_issues_count": 15, "max_forks_count": null, "avg_line_length": 47.6785714286, "max_line_length": 70, "alphanum_fraction": 0.8029962547}
#lang scribble/doc
@(require scribble/manual scribble/eval "guide-utils.rkt")

@title[#:tag "protect-out"]{Protected Exports}

Sometimes, a module needs to export bindings to other modules that are
at the same trust level as the exporting module, while at the same
time preventing access from untrusted modules. Such exports should use
the @racket[protect-out] form in @racket[provide]. For example,
@racketmodname[ffi/unsafe] exports all of its unsafe bindings as
@deftech{protected} in this sense.

Levels of trust are implemented with @tech{code inspectors} (see
@secref["code-inspectors+protect"]).
Only modules loaded with an equally strong code inspector as an
exporting module can use protected bindings from the exporting module.
Operations like @racket[dynamic-require] are granted access depending
on the current code inspector as determined by
@racket[current-code-inspector].

When a module re-exports a protected binding, it does not need to use
@racket[protect-out] again. Access is always determined by the code
inspector of the module that originally defines a protected binding.
When using a protected binding within a module, take care to either
provide new bindings from the module with @racket[protect-out] or
ensure that no provided bindings expose functionality that was meant
to be protected in the first place.
