44pub ( crate ) mod auto_embed;
55pub ( crate ) mod embed_provider;
66
7- use crate :: { error:: InputManifestError , hash_algorithm:: HashAlgorithm } ;
7+ use crate :: { error:: InputManifestError , hash_algorithm:: HashAlgorithm , util :: sealed :: Sealed } ;
88use std:: { marker:: PhantomData , path:: Path } ;
99
1010pub use crate :: embed:: embed_provider:: EmbedProvider ;
@@ -13,7 +13,7 @@ pub use crate::embed::embed_provider::EmbedProvider;
1313use crate :: embed:: auto_embed:: embed_manifest_in_target;
1414
1515/// Defines how embedding should be handled in target artifacts.
16- pub trait Embed < H >
16+ pub trait Embed < H > : Sealed
1717where
1818 H : HashAlgorithm ,
1919{
@@ -26,12 +26,19 @@ where
2626 target_path : & Path ,
2727 embed_provider : EmbedProvider < H > ,
2828 ) -> Option < Result < ( ) , InputManifestError > > ;
29+
30+ /// Indicates if the embedder will attempt to embed.
31+ fn will_embed ( & self ) -> bool {
32+ true
33+ }
2934}
3035
3136/// Do not embed in the target file.
3237#[ derive( Debug , Copy , Clone ) ]
3338pub struct NoEmbed ;
3439
40+ impl Sealed for NoEmbed { }
41+
3542impl < H : HashAlgorithm > Embed < H > for NoEmbed {
3643 // Do nothing, as we're not actually embedding.
3744 fn try_embed (
@@ -41,13 +48,20 @@ impl<H: HashAlgorithm> Embed<H> for NoEmbed {
4148 ) -> Option < Result < ( ) , InputManifestError > > {
4249 None
4350 }
51+
52+ fn will_embed ( & self ) -> bool {
53+ false
54+ }
4455}
4556
4657#[ cfg( feature = "infer-filetypes" ) ]
4758/// Automatically infer the filetype of the target file, and attempt to embed.
4859#[ derive( Debug , Copy , Clone ) ]
4960pub struct AutoEmbed ;
5061
62+ #[ cfg( feature = "infer-filetypes" ) ]
63+ impl Sealed for AutoEmbed { }
64+
5165#[ cfg( feature = "infer-filetypes" ) ]
5266impl < H : HashAlgorithm > Embed < H > for AutoEmbed {
5367 fn try_embed (
8397 }
8498}
8599
100+ impl < H , F > Sealed for CustomEmbed < H , F >
101+ where
102+ H : HashAlgorithm ,
103+ F : Fn ( & Path , EmbedProvider < H > ) -> Result < ( ) , InputManifestError > ,
104+ {
105+ }
106+
86107impl < H , F > Embed < H > for CustomEmbed < H , F >
87108where
88109 H : HashAlgorithm ,
0 commit comments