mirror of
https://github.com/encounter/rust-sdl2.git
synced 2026-07-10 21:18:41 -07:00
34 lines
15 KiB
HTML
34 lines
15 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `AudioFormatNum` trait in crate `sdl2`."><meta name="keywords" content="rust, rustlang, rust-lang, AudioFormatNum"><title>sdl2::audio::AudioFormatNum - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="shortcut icon" href="../../favicon.ico"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../sdl2/index.html'><div class='logo-container'><img src='../../rust-logo.png' alt='logo'></div></a><p class='location'>Trait AudioFormatNum</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-const">Associated Constants</a><div class="sidebar-links"><a href="#associatedconstant.SILENCE">SILENCE</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.audio_format">audio_format</a></div><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-AudioFormatNum-for-f32">f32</a><a href="#impl-AudioFormatNum-for-i16">i16</a><a href="#impl-AudioFormatNum-for-i32">i32</a><a href="#impl-AudioFormatNum-for-i8">i8</a><a href="#impl-AudioFormatNum-for-u16">u16</a><a href="#impl-AudioFormatNum-for-u8">u8</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='../index.html'>sdl2</a>::<wbr><a href='index.html'>audio</a></p><script>window.sidebarCurrent = {name: 'AudioFormatNum', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../../src/sdl2/audio.rs.html#343-367' title='goto source code'>[src]</a></span><span class='in-band'>Trait <a href='../index.html'>sdl2</a>::<wbr><a href='index.html'>audio</a>::<wbr><a class="trait" href=''>AudioFormatNum</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust trait'>pub trait AudioFormatNum {
|
||
const <a href='#associatedconstant.SILENCE' class="constant"><b>SILENCE</b></a>: Self;
|
||
|
||
fn <a href='#tymethod.audio_format' class='fnname'>audio_format</a>() -> <a class="enum" href="../../sdl2/audio/enum.AudioFormat.html" title="enum sdl2::audio::AudioFormat">AudioFormat</a>;
|
||
}</pre></div><div class='docblock'><p>A phantom type for retrieving the <code>SDL_AudioFormat</code> of a given generic type.
|
||
All format types are returned as native-endian.</p>
|
||
</div>
|
||
<h2 id='associated-const' class='small-section-header'>Associated Constants<a href='#associated-const' class='anchor'></a></h2><div class='methods'><h3 id='associatedconstant.SILENCE' class='method'><code id='SILENCE.v'>const <a href='#associatedconstant.SILENCE' class="constant"><b>SILENCE</b></a>: Self</code></h3><div class='docblock'><p>The appropriately typed silence value for the audio format used.</p>
|
||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="comment">// The AudioFormatNum trait has to be imported for the Channel::SILENCE part to work.</span>
|
||
<span class="kw">use</span> <span class="ident">sdl2</span>::<span class="ident">audio</span>::{<span class="ident">AudioCallback</span>, <span class="ident">AudioFormatNum</span>};
|
||
|
||
<span class="kw">struct</span> <span class="ident">Silence</span>;
|
||
|
||
<span class="kw">impl</span> <span class="ident">AudioCallback</span> <span class="kw">for</span> <span class="ident">Silence</span> {
|
||
<span class="kw">type</span> <span class="ident">Channel</span> <span class="op">=</span> <span class="ident">u16</span>;
|
||
|
||
<span class="kw">fn</span> <span class="ident">callback</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">out</span>: <span class="kw-2">&</span><span class="kw-2">mut</span> [<span class="ident">u16</span>]) {
|
||
<span class="kw">for</span> <span class="ident">dst</span> <span class="kw">in</span> <span class="ident">out</span>.<span class="ident">iter_mut</span>() {
|
||
<span class="kw-2">*</span><span class="ident">dst</span> <span class="op">=</span> <span class="self">Self</span>::<span class="ident">Channel</span>::<span class="ident">SILENCE</span>;
|
||
}
|
||
}
|
||
}</pre></div>
|
||
</div></div><span class='loading-content'>Loading content...</span>
|
||
<h2 id='required-methods' class='small-section-header'>Required methods<a href='#required-methods' class='anchor'></a></h2><div class='methods'><h3 id='tymethod.audio_format' class='method'><code id='audio_format.v'>fn <a href='#tymethod.audio_format' class='fnname'>audio_format</a>() -> <a class="enum" href="../../sdl2/audio/enum.AudioFormat.html" title="enum sdl2::audio::AudioFormat">AudioFormat</a></code></h3></div><span class='loading-content'>Loading content...</span>
|
||
<h2 id='foreign-impls' class='small-section-header'>Implementations on Foreign Types<a href='#foreign-impls' class='anchor'></a></h2><h3 id='impl-AudioFormatNum-for-i8' class='impl'><code class='in-band'>impl <a class="trait" href="../../sdl2/audio/trait.AudioFormatNum.html" title="trait sdl2::audio::AudioFormatNum">AudioFormatNum</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a></code><a href='#impl-AudioFormatNum-for-i8' class='anchor'></a><a class='srclink' href='../../src/sdl2/audio.rs.html#370-373' title='goto source code'>[src]</a></h3><div class='docblock'><p><code>AUDIO_S8</code></p>
|
||
</div><div class='impl-items'><h4 id='method.audio_format' class="method hidden"><code id='audio_format.v-1'>fn <a href='#method.audio_format' class='fnname'>audio_format</a>() -> <a class="enum" href="../../sdl2/audio/enum.AudioFormat.html" title="enum sdl2::audio::AudioFormat">AudioFormat</a></code><a class='srclink' href='../../src/sdl2/audio.rs.html#371' title='goto source code'>[src]</a></h4><h4 id='associatedconstant.SILENCE-1' class="associatedconstant hidden"><code id='SILENCE.v-1'>const <a href='#associatedconstant.SILENCE' class="constant"><b>SILENCE</b></a>: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a></code><a class='srclink' href='../../src/sdl2/audio.rs.html#372' title='goto source code'>[src]</a></h4></div><h3 id='impl-AudioFormatNum-for-u8' class='impl'><code class='in-band'>impl <a class="trait" href="../../sdl2/audio/trait.AudioFormatNum.html" title="trait sdl2::audio::AudioFormatNum">AudioFormatNum</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a></code><a href='#impl-AudioFormatNum-for-u8' class='anchor'></a><a class='srclink' href='../../src/sdl2/audio.rs.html#375-378' title='goto source code'>[src]</a></h3><div class='docblock'><p><code>AUDIO_U8</code></p>
|
||
</div><div class='impl-items'><h4 id='method.audio_format-1' class="method hidden"><code id='audio_format.v-2'>fn <a href='#method.audio_format' class='fnname'>audio_format</a>() -> <a class="enum" href="../../sdl2/audio/enum.AudioFormat.html" title="enum sdl2::audio::AudioFormat">AudioFormat</a></code><a class='srclink' href='../../src/sdl2/audio.rs.html#376' title='goto source code'>[src]</a></h4><h4 id='associatedconstant.SILENCE-2' class="associatedconstant hidden"><code id='SILENCE.v-2'>const <a href='#associatedconstant.SILENCE' class="constant"><b>SILENCE</b></a>: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a></code><a class='srclink' href='../../src/sdl2/audio.rs.html#377' title='goto source code'>[src]</a></h4></div><h3 id='impl-AudioFormatNum-for-i16' class='impl'><code class='in-band'>impl <a class="trait" href="../../sdl2/audio/trait.AudioFormatNum.html" title="trait sdl2::audio::AudioFormatNum">AudioFormatNum</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a></code><a href='#impl-AudioFormatNum-for-i16' class='anchor'></a><a class='srclink' href='../../src/sdl2/audio.rs.html#380-383' title='goto source code'>[src]</a></h3><div class='docblock'><p><code>AUDIO_S16</code></p>
|
||
</div><div class='impl-items'><h4 id='method.audio_format-2' class="method hidden"><code id='audio_format.v-3'>fn <a href='#method.audio_format' class='fnname'>audio_format</a>() -> <a class="enum" href="../../sdl2/audio/enum.AudioFormat.html" title="enum sdl2::audio::AudioFormat">AudioFormat</a></code><a class='srclink' href='../../src/sdl2/audio.rs.html#381' title='goto source code'>[src]</a></h4><h4 id='associatedconstant.SILENCE-3' class="associatedconstant hidden"><code id='SILENCE.v-3'>const <a href='#associatedconstant.SILENCE' class="constant"><b>SILENCE</b></a>: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a></code><a class='srclink' href='../../src/sdl2/audio.rs.html#382' title='goto source code'>[src]</a></h4></div><h3 id='impl-AudioFormatNum-for-u16' class='impl'><code class='in-band'>impl <a class="trait" href="../../sdl2/audio/trait.AudioFormatNum.html" title="trait sdl2::audio::AudioFormatNum">AudioFormatNum</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></code><a href='#impl-AudioFormatNum-for-u16' class='anchor'></a><a class='srclink' href='../../src/sdl2/audio.rs.html#385-388' title='goto source code'>[src]</a></h3><div class='docblock'><p><code>AUDIO_U16</code></p>
|
||
</div><div class='impl-items'><h4 id='method.audio_format-3' class="method hidden"><code id='audio_format.v-4'>fn <a href='#method.audio_format' class='fnname'>audio_format</a>() -> <a class="enum" href="../../sdl2/audio/enum.AudioFormat.html" title="enum sdl2::audio::AudioFormat">AudioFormat</a></code><a class='srclink' href='../../src/sdl2/audio.rs.html#386' title='goto source code'>[src]</a></h4><h4 id='associatedconstant.SILENCE-4' class="associatedconstant hidden"><code id='SILENCE.v-4'>const <a href='#associatedconstant.SILENCE' class="constant"><b>SILENCE</b></a>: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></code><a class='srclink' href='../../src/sdl2/audio.rs.html#387' title='goto source code'>[src]</a></h4></div><h3 id='impl-AudioFormatNum-for-i32' class='impl'><code class='in-band'>impl <a class="trait" href="../../sdl2/audio/trait.AudioFormatNum.html" title="trait sdl2::audio::AudioFormatNum">AudioFormatNum</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a></code><a href='#impl-AudioFormatNum-for-i32' class='anchor'></a><a class='srclink' href='../../src/sdl2/audio.rs.html#390-393' title='goto source code'>[src]</a></h3><div class='docblock'><p><code>AUDIO_S32</code></p>
|
||
</div><div class='impl-items'><h4 id='method.audio_format-4' class="method hidden"><code id='audio_format.v-5'>fn <a href='#method.audio_format' class='fnname'>audio_format</a>() -> <a class="enum" href="../../sdl2/audio/enum.AudioFormat.html" title="enum sdl2::audio::AudioFormat">AudioFormat</a></code><a class='srclink' href='../../src/sdl2/audio.rs.html#391' title='goto source code'>[src]</a></h4><h4 id='associatedconstant.SILENCE-5' class="associatedconstant hidden"><code id='SILENCE.v-5'>const <a href='#associatedconstant.SILENCE' class="constant"><b>SILENCE</b></a>: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a></code><a class='srclink' href='../../src/sdl2/audio.rs.html#392' title='goto source code'>[src]</a></h4></div><h3 id='impl-AudioFormatNum-for-f32' class='impl'><code class='in-band'>impl <a class="trait" href="../../sdl2/audio/trait.AudioFormatNum.html" title="trait sdl2::audio::AudioFormatNum">AudioFormatNum</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code><a href='#impl-AudioFormatNum-for-f32' class='anchor'></a><a class='srclink' href='../../src/sdl2/audio.rs.html#395-398' title='goto source code'>[src]</a></h3><div class='docblock'><p><code>AUDIO_F32</code></p>
|
||
</div><div class='impl-items'><h4 id='method.audio_format-5' class="method hidden"><code id='audio_format.v-6'>fn <a href='#method.audio_format' class='fnname'>audio_format</a>() -> <a class="enum" href="../../sdl2/audio/enum.AudioFormat.html" title="enum sdl2::audio::AudioFormat">AudioFormat</a></code><a class='srclink' href='../../src/sdl2/audio.rs.html#396' title='goto source code'>[src]</a></h4><h4 id='associatedconstant.SILENCE-6' class="associatedconstant hidden"><code id='SILENCE.v-6'>const <a href='#associatedconstant.SILENCE' class="constant"><b>SILENCE</b></a>: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a></code><a class='srclink' href='../../src/sdl2/audio.rs.html#397' title='goto source code'>[src]</a></h4></div><span class='loading-content'>Loading content...</span>
|
||
<h2 id='implementors' class='small-section-header'>Implementors<a href='#implementors' class='anchor'></a></h2><div class='item-list' id='implementors-list'></div><span class='loading-content'>Loading content...</span><script type="text/javascript" src="../../implementors/sdl2/audio/trait.AudioFormatNum.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../";window.currentCrate = "sdl2";</script><script src="../../aliases.js"></script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html> |