pub struct SamConfig { /* private fields */ }Expand description
How to reach sam-3.1.
The key and base URL are Muse’s (spec 3.7 Q5: one Meta Model API key authorises both, confirmed live on 2026-11-19).
§Example
use adk_vision::SamConfig;
let config = SamConfig::new("meta-key").with_confidence(true);
assert_eq!(config.host().unwrap(), "api.meta.ai");
assert!(!format!("{config:?}").contains("meta-key"));Implementations§
Source§impl SamConfig
impl SamConfig
Sourcepub fn from_muse(muse: &MuseConfig) -> Self
pub fn from_muse(muse: &MuseConfig) -> Self
The key and base URL of a Muse configuration.
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
The key from META_API_KEY, else MODEL_API_KEY, as Muse reads it.
§Errors
VisionError::InvalidInput when neither is set.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> Self
pub fn with_base_url(self, base_url: impl Into<String>) -> Self
Calls base_url (ending in /v1) instead of Meta’s.
Sourcepub fn with_max_retries(self, retries: u32) -> Self
pub fn with_max_retries(self, retries: u32) -> Self
Retries a rate-limited request up to retries times.
Sourcepub fn with_confidence(self, include: bool) -> Self
pub fn with_confidence(self, include: bool) -> Self
Asks for each object’s confidence, returned as the region’s score.
Sourcepub fn with_one_bit_masks(self, one_bit: bool) -> Self
pub fn with_one_bit_masks(self, one_bit: bool) -> Self
Asks for one_bit masks, several times smaller than the default lossless ones.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Ends a request that takes longer than timeout.
Sourcepub fn with_mask_decoder(self, choice: MaskDecoderChoice) -> Self
pub fn with_mask_decoder(self, choice: MaskDecoderChoice) -> Self
Chooses how masks are decoded; MaskDecoderChoice::None, boxes only, by default.
SamSegmenter::new builds and checks the decoder.
§Example
use adk_vision::{MaskDecoderChoice, SamConfig, SamSegmenter};
// A program that is not installed is refused when the segmenter is built.
let config = SamConfig::new("meta-key")
.with_mask_decoder(MaskDecoderChoice::external("no-such-sam-decoder", ["--json"]));
let refused = SamSegmenter::new(config).unwrap_err().to_string();
assert!(refused.contains("`no-such-sam-decoder` was not found on PATH"), "{refused}");Sourcepub fn with_licence_acceptances(self, store: Arc<dyn AcceptanceStore>) -> Self
pub fn with_licence_acceptances(self, store: Arc<dyn AcceptanceStore>) -> Self
Where MaskDecoderChoice::Licensed looks for a person’s acceptance of the SAM
License, such as the project’s FileAcceptanceStore. Without one, the licensed
decoder is refused.
Sourcepub fn mask_decoder(&self) -> &MaskDecoderChoice
pub fn mask_decoder(&self) -> &MaskDecoderChoice
The mask decoder this configuration chooses.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SamConfig
impl !UnwindSafe for SamConfig
impl Forget for SamConfig
impl Freeze for SamConfigwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
*const ArcInner<dyn AcceptanceStore> is !null: Freeze,
PhantomData<ArcInner<dyn AcceptanceStore>>: Freeze,
impl Move for SamConfig
impl Send for SamConfig
impl Sync for SamConfig
impl Unpin for SamConfig
impl UnsafeUnpin for SamConfigwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const ArcInner<dyn AcceptanceStore> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn AcceptanceStore>>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for T
impl<T> Downcast for T
impl<T> ErasedDestructor for Twhere
T: 'static,
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
impl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.