pub struct Closure { /* private fields */ }Expand description
A Load implementation whose behaviour is supplied by a closure.
Reach for this instead of a full impl Load when the loader is small, stateless, or a one-off
adapter. See the module docs for a complete example.
Implementations§
Source§impl Closure
impl Closure
Sourcepub fn new<N, L, S>(name: N, loader: L, source: S) -> Self
pub fn new<N, L, S>(name: N, loader: L, source: S) -> Self
Build a closure-backed loader.
name— the loadernameused in error messages.loader— the closure run byload; same shape as the trait method.source— the single source string this loader handles (widen later withClosure::with_supported_source_list).
Sourcepub fn with_name<N: AsRef<str>>(self, name: N) -> Self
pub fn with_name<N: AsRef<str>>(self, name: N) -> Self
Override the loader name reported by Load::name.
Sourcepub fn with_supported_source_list<S: AsRef<str>>(
self,
supported_source_list: Vec<S>,
) -> Self
pub fn with_supported_source_list<S: AsRef<str>>( self, supported_source_list: Vec<S>, ) -> Self
Replace the list of source strings this loader handles (e.g. ["http", "https"]).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Closure
impl !UnwindSafe for Closure
impl Freeze for Closure
impl Send for Closure
impl Sync for Closure
impl Unpin for Closure
impl UnsafeUnpin for Closure
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
Mutably borrows from an owned value. Read more