You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dev/devnotes/index.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -3,4 +3,4 @@
3
3
user <--- |state.buffer1| <--- <stream.codec> <--- |state.buffer2| <--- stream
4
4
5
5
When writing data (`state.mode == :write`):
6
-
user ---> |state.buffer1| ---> <stream.codec> ---> |state.buffer2| ---> stream</code></pre><p>In the read mode, a user pull out data from <code>state.buffer1</code> and pre-transcoded data are filled in <code>state.buffer2</code>. In the write mode, a user will push data into <code>state.buffer1</code> and transcoded data are filled in <code>state.buffer2</code>. The default buffer size is 16KiB for each.</p><p><code>State</code> (defined in src/state.jl) has five fields:</p><ul><li><code>mode</code>: current stream mode (<code><:Symbol</code>)</li><li><code>code</code>: return code of the last codec's method call (<code><:Symbol</code>)</li><li><code>error</code>: exception returned by the codec (<code><:Error</code>)</li><li><code>buffer1</code>: data buffer that is closer to the user (<code><:Buffer</code>)</li><li><code>buffer2</code>: data buffer that is farther to the user (<code><:Buffer</code>)</li><li><code>bytes_written_out</code>: number of bytes written to the underlying stream (<code><:Int64</code>)</li></ul><p>The <code>mode</code> field may be one of the following value:</p><ul><li><code>:idle</code> : initial and intermediate mode, no buffered data</li><li><code>:read</code> : being ready to read data, data may be buffered</li><li><code>:write</code>: being ready to write data, data may be buffered</li><li><code>:stop</code> : transcoding is stopped after read, data may be buffered</li><li><code>:close</code>: closed, no buffered data</li><li><code>:panic</code>: an exception has been thrown in codec, data may be buffered but we cannot do anything</li></ul><p>Note that <code>mode=:stop</code> does not mean there is no data available in the stream. This is because transcoded data may be left in the buffer.</p><p>The initial mode is <code>:idle</code> and mode transition happens as shown in the following diagram: <imgsrc="../assets/modes.svg" alt="Mode transition"/></p><p>Modes surrounded by a bold circle are a state in which the transcoding stream has released resources by calling <code>finalize(codec)</code>. The mode transition should happen in the <code>changemode!(stream, newmode)</code> function in src/stream.jl. Trying an undefined transition will thrown an exception.</p><p>A transition happens according to internal or external events of the transcoding stream. The status code and the error object returned by codec methods are internal events, and user's method calls are external events. For example, calling <code>read(stream)</code> will change the mode from <code>:init</code> to <code>:read</code> and then calling <code>close(stream)</code> will change the mode from <code>:read</code> to <code>:close</code>. When data processing fails in the codec, a codec will return <code>:error</code> and the stream will result in <code>:panic</code>.</p><h2id="Shared-buffers"><aclass="docs-heading-anchor" href="#Shared-buffers">Shared buffers</a><aid="Shared-buffers-1"></a><aclass="docs-heading-anchor-permalink" href="#Shared-buffers" title="Permalink"></a></h2><p>Adjacent transcoding streams may share their buffers. This will reduce memory allocation and eliminate data copy between buffers.</p><p>If <code>buffer2</code> is shared it is considered to be owned by the underlying stream by the <code>stats</code> and <code>position</code> functions.</p><p><code>readdata!(input::IO, output::Buffer)</code> and <code>flush_buffer2(stream::TranscodingStream)</code> do the actual work of read/write data from/to the underlying stream. These methods have a special pass for shared buffers.</p><h2id="Noop-codec"><aclass="docs-heading-anchor" href="#Noop-codec"><code>Noop</code> codec</a><aid="Noop-codec-1"></a><aclass="docs-heading-anchor-permalink" href="#Noop-codec" title="Permalink"></a></h2><p><code>Noop</code> (<code>NoopStream</code>) is a codec that does <em>nothing</em>. It works as a buffering layer on top of the underlying stream. Since <code>NoopStream</code> does not need to have two distinct buffers, <code>buffer1</code> and <code>buffer2</code> in the <code>State</code> object are shared and some specialized methods are defined for the type. All of these are defined in src/noop.jl.</p></article><navclass="docs-footer"><aclass="docs-footer-prevpage" href="../migrating/">« Migration</a><divclass="flexbox-break"></div><pclass="footer-message">Powered by <ahref="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <ahref="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><divclass="modal" id="documenter-settings"><divclass="modal-background"></div><divclass="modal-card"><headerclass="modal-card-head"><pclass="modal-card-title">Settings</p><buttonclass="delete"></button></header><sectionclass="modal-card-body"><p><labelclass="label">Theme</label><divclass="select"><selectid="documenter-themepicker"><optionvalue="auto">Automatic (OS)</option><optionvalue="documenter-light">documenter-light</option><optionvalue="documenter-dark">documenter-dark</option><optionvalue="catppuccin-latte">catppuccin-latte</option><optionvalue="catppuccin-frappe">catppuccin-frappe</option><optionvalue="catppuccin-macchiato">catppuccin-macchiato</option><optionvalue="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <ahref="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.16.1 on <spanclass="colophon-date" title="Friday 13 February 2026 21:47">Friday 13 February 2026</span>. Using Julia version 1.12.5.</p></section><footerclass="modal-card-foot"></footer></div></div></div></body></html>
6
+
user ---> |state.buffer1| ---> <stream.codec> ---> |state.buffer2| ---> stream</code></pre><p>In the read mode, a user pull out data from <code>state.buffer1</code> and pre-transcoded data are filled in <code>state.buffer2</code>. In the write mode, a user will push data into <code>state.buffer1</code> and transcoded data are filled in <code>state.buffer2</code>. The default buffer size is 16KiB for each.</p><p><code>State</code> (defined in src/state.jl) has five fields:</p><ul><li><code>mode</code>: current stream mode (<code><:Symbol</code>)</li><li><code>code</code>: return code of the last codec's method call (<code><:Symbol</code>)</li><li><code>error</code>: exception returned by the codec (<code><:Error</code>)</li><li><code>buffer1</code>: data buffer that is closer to the user (<code><:Buffer</code>)</li><li><code>buffer2</code>: data buffer that is farther to the user (<code><:Buffer</code>)</li><li><code>bytes_written_out</code>: number of bytes written to the underlying stream (<code><:Int64</code>)</li></ul><p>The <code>mode</code> field may be one of the following value:</p><ul><li><code>:idle</code> : initial and intermediate mode, no buffered data</li><li><code>:read</code> : being ready to read data, data may be buffered</li><li><code>:write</code>: being ready to write data, data may be buffered</li><li><code>:stop</code> : transcoding is stopped after read, data may be buffered</li><li><code>:close</code>: closed, no buffered data</li><li><code>:panic</code>: an exception has been thrown in codec, data may be buffered but we cannot do anything</li></ul><p>Note that <code>mode=:stop</code> does not mean there is no data available in the stream. This is because transcoded data may be left in the buffer.</p><p>The initial mode is <code>:idle</code> and mode transition happens as shown in the following diagram: <imgsrc="../assets/modes.svg" alt="Mode transition"/></p><p>Modes surrounded by a bold circle are a state in which the transcoding stream has released resources by calling <code>finalize(codec)</code>. The mode transition should happen in the <code>changemode!(stream, newmode)</code> function in src/stream.jl. Trying an undefined transition will thrown an exception.</p><p>A transition happens according to internal or external events of the transcoding stream. The status code and the error object returned by codec methods are internal events, and user's method calls are external events. For example, calling <code>read(stream)</code> will change the mode from <code>:init</code> to <code>:read</code> and then calling <code>close(stream)</code> will change the mode from <code>:read</code> to <code>:close</code>. When data processing fails in the codec, a codec will return <code>:error</code> and the stream will result in <code>:panic</code>.</p><h2id="Shared-buffers"><aclass="docs-heading-anchor" href="#Shared-buffers">Shared buffers</a><aid="Shared-buffers-1"></a><aclass="docs-heading-anchor-permalink" href="#Shared-buffers" title="Permalink"></a></h2><p>Adjacent transcoding streams may share their buffers. This will reduce memory allocation and eliminate data copy between buffers.</p><p>If <code>buffer2</code> is shared it is considered to be owned by the underlying stream by the <code>stats</code> and <code>position</code> functions.</p><p><code>readdata!(input::IO, output::Buffer)</code> and <code>flush_buffer2(stream::TranscodingStream)</code> do the actual work of read/write data from/to the underlying stream. These methods have a special pass for shared buffers.</p><h2id="Noop-codec"><aclass="docs-heading-anchor" href="#Noop-codec"><code>Noop</code> codec</a><aid="Noop-codec-1"></a><aclass="docs-heading-anchor-permalink" href="#Noop-codec" title="Permalink"></a></h2><p><code>Noop</code> (<code>NoopStream</code>) is a codec that does <em>nothing</em>. It works as a buffering layer on top of the underlying stream. Since <code>NoopStream</code> does not need to have two distinct buffers, <code>buffer1</code> and <code>buffer2</code> in the <code>State</code> object are shared and some specialized methods are defined for the type. All of these are defined in src/noop.jl.</p></article><navclass="docs-footer"><aclass="docs-footer-prevpage" href="../migrating/">« Migration</a><divclass="flexbox-break"></div><pclass="footer-message">Powered by <ahref="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <ahref="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><divclass="modal" id="documenter-settings"><divclass="modal-background"></div><divclass="modal-card"><headerclass="modal-card-head"><pclass="modal-card-title">Settings</p><buttonclass="delete"></button></header><sectionclass="modal-card-body"><p><labelclass="label">Theme</label><divclass="select"><selectid="documenter-themepicker"><optionvalue="auto">Automatic (OS)</option><optionvalue="documenter-light">documenter-light</option><optionvalue="documenter-dark">documenter-dark</option><optionvalue="catppuccin-latte">catppuccin-latte</option><optionvalue="catppuccin-frappe">catppuccin-frappe</option><optionvalue="catppuccin-macchiato">catppuccin-macchiato</option><optionvalue="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <ahref="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.17.0 on <spanclass="colophon-date" title="Monday 20 April 2026 14:43">Monday 20 April 2026</span>. Using Julia version 1.12.6.</p></section><footerclass="modal-card-foot"></footer></div></div></div></body></html>
0 commit comments