pub struct Bundle { /* private fields */ }Expand description
In-memory immutable byte blob registered at boot.
See the crate-level docs for the builder chain and ordering.
Implementations§
Source§impl Bundle
impl Bundle
Sourcepub fn new(name: &str, bytes: &'static [u8]) -> Self
pub fn new(name: &str, bytes: &'static [u8]) -> Self
Register a new bundle. Hashes the bytes (SHA-256), inserts an entry into the
process-global registry keyed by the hashed URL, and returns a Bundle handle.
§Panics
Panics if a bundle with the same name is already registered (D-06). Duplicate
registration is developer error caught at boot.
Sourcepub fn content_type(self, ct: &str) -> Self
pub fn content_type(self, ct: &str) -> Self
Set the content-type. Re-keys the bundle’s hashed URL (appends the extension
derived from the content-type). Call BEFORE .with_alias(...) so aliases
capture the final hashed URL.
Sourcepub fn with_alias(self, alias_path: &str) -> Self
pub fn with_alias(self, alias_path: &str) -> Self
Register a stable plain URL that 301-redirects to the current hashed URL. Multiple aliases per bundle are allowed; each call adds one entry.
Sourcepub fn hashed_url(&self) -> String
pub fn hashed_url(&self) -> String
Return the current hashed URL (/bundles/{name}.{sha8}.{ext} or
/bundles/{name}.{sha8} if the content-type has no known extension).
Sourcepub fn serve(req: Request) -> HttpResponse
pub fn serve(req: Request) -> HttpResponse
Dispatch a request to the bundle registry. Mount this as the handler for
/bundles/{filename} and for each registered alias path.
Order of checks (D-03):
- Alias check → 301 redirect.
- Bundle check → 304 fast-path on
If-None-Matchmatch, else 200 with bytes. - Otherwise → 404.
Auto Trait Implementations§
impl Freeze for Bundle
impl RefUnwindSafe for Bundle
impl Send for Bundle
impl Sync for Bundle
impl Unpin for Bundle
impl UnsafeUnpin for Bundle
impl UnwindSafe for Bundle
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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