Skip to main content

AudD

Struct AudD 

Source
pub struct AudD { /* private fields */ }
Expand description

Async client for the AudD music recognition API.

Construct with AudD::new for the common case, or AudD::builder to override retries, timeouts, base URLs, or supply a configured reqwest::Client.

AudD holds an internal connection pool. Drop it (or call AudD::close) once you’re done. Cloning AudD is cheap.

Implementations§

Source§

impl AudD

Source

pub fn new(api_token: impl Into<String>) -> Self

Build a client with the standard defaults. Pass "" to fall back on the AUDD_API_TOKEN environment variable.

§Panics

Panics if no token is resolvable (use Self::try_new / Self::from_env for a Result-returning sibling) or if reqwest::Client::build() fails — exceedingly rare on a system with a working TLS stack.

Source

pub fn try_new(api_token: impl Into<String>) -> Result<Self, AudDError>

Result-returning sibling of Self::new: build a client with defaults, falling back to AUDD_API_TOKEN when api_token is empty.

§Errors
Source

pub fn from_env() -> Result<Self, AudDError>

Build a client whose token comes from the AUDD_API_TOKEN environment variable. Equivalent to Self::try_new with an empty argument.

§Errors
Source

pub fn builder(api_token: impl Into<String>) -> AudDBuilder

Begin building an AudD.

Source

pub fn streams(&self) -> Streams<'_>

streams.* namespace.

Source

pub fn custom_catalog(&self) -> CustomCatalog<'_>

custom_catalog.* namespace. Read the warning on CustomCatalog::add before using.

Source

pub fn advanced(&self) -> Advanced<'_>

advanced.* namespace — lyrics search and a generic raw-request escape hatch.

Source

pub async fn recognize( &self, source: impl Into<Source>, ) -> Result<Option<RecognitionResult>, AudDError>

Recognize a song from a URL, file path, raw bytes, or async reader.

Returns Ok(None) when the server returns status=success with result=null — i.e. no match was found.

return_ accepts a slice of metadata service names (e.g. &["apple_music".into(), "spotify".into()]).

§Errors

Returns AudDError for transport, server, or parse failures.

Source

pub async fn recognize_with( &self, source: impl Into<Source>, opts: RecognizeOptions<'_>, ) -> Result<Option<RecognitionResult>, AudDError>

Like Self::recognize but with the optional knobs explicit.

§Errors

Same as Self::recognize.

Source

pub async fn recognize_enterprise( &self, source: impl Into<Source>, opts: EnterpriseOptions<'_>, ) -> Result<Vec<EnterpriseMatch>, AudDError>

Recognize a long file via the enterprise endpoint. Returns all matches across all chunks. Default read/write timeout is 1 hour.

§Errors

Returns AudDError for transport, server, or parse failures.

Source

pub async fn close(self)

Drop the underlying HTTP transport explicitly. Equivalent to dropping the AudD value (provided here for parity with the sibling SDKs’ context-manager protocol).

Source

pub fn api_token(&self) -> String

Snapshot the in-effect api_token (after any rotations).

Returns an owned String because the token sits behind an Arc<RwLock> to support Self::set_api_token.

Source

pub fn set_api_token( &self, new_token: impl Into<String>, ) -> Result<(), AudDError>

Atomically rotate the api_token used for subsequent requests.

In-flight requests continue with the previous snapshot — there’s no abort. Thread-safe across concurrent recognize, streams.*, etc. calls; backed by a shared Arc<RwLock<String>> so the standard and enterprise transports both pick up the new token immediately.

§Errors

Returns AudDError::Configuration when new_token is empty.

Trait Implementations§

Source§

impl Clone for AudD

Source§

fn clone(&self) -> AudD

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AudD

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for AudD

§

impl !UnwindSafe for AudD

§

impl Freeze for AudD

§

impl Send for AudD

§

impl Sync for AudD

§

impl Unpin for AudD

§

impl UnsafeUnpin for AudD

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more