Spec-Zone.ru › Haskell 9

GHC.IO.BufferedIO

Copyright (c) The University of Glasgow 2008
License see libraries/base/LICENSE
Maintainer ghc-devs@haskell.org
Stability internal
Portability non-portable (GHC Extensions)
Safe Haskell Safe
Language Haskell2010

Description

Class of buffered IO devices

class BufferedIO dev where Source

The purpose of BufferedIO is to provide a common interface for I/O devices that can read and write data through a buffer. Devices that implement BufferedIO include ordinary files, memory-mapped files, and bytestrings. The underlying device implementing a Handle must provide BufferedIO.

Minimal complete definition

newBuffer, fillReadBuffer, fillReadBuffer0, flushWriteBuffer, flushWriteBuffer0

Methods

newBuffer :: dev -> BufferState -> IO (Buffer Word8) Source

allocate a new buffer. The size of the buffer is at the discretion of the device; e.g. for a memory-mapped file the buffer will probably cover the entire file.

fillReadBuffer :: dev -> Buffer Word8 -> IO (Int, Buffer Word8) Source

reads bytes into the buffer, blocking if there are no bytes available. Returns the number of bytes read (zero indicates end-of-file), and the new buffer.

fillReadBuffer0 :: dev -> Buffer Word8 -> IO (Maybe Int, Buffer Word8) Source

reads bytes into the buffer without blocking. Returns the number of bytes read (Nothing indicates end-of-file), and the new buffer.

emptyWriteBuffer :: dev -> Buffer Word8 -> IO (Buffer Word8) Source

Prepares an empty write buffer. This lets the device decide how to set up a write buffer: the buffer may need to point to a specific location in memory, for example. This is typically used by the client when switching from reading to writing on a buffered read/write device.

There is no corresponding operation for read buffers, because before reading the client will always call fillReadBuffer.

flushWriteBuffer :: dev -> Buffer Word8 -> IO (Buffer Word8) Source

Flush all the data from the supplied write buffer out to the device. The returned buffer should be empty, and ready for writing.

flushWriteBuffer0 :: dev -> Buffer Word8 -> IO (Int, Buffer Word8) Source

Flush data from the supplied write buffer out to the device without blocking. Returns the number of bytes written and the remaining buffer.

Instances
Instances details
BufferedIO FD Source

Since: base-4.1.0.0

Instance details

Defined in GHC.Internal.IO.FD

Methods

newBuffer :: FD -> BufferState -> IO (Buffer Word8) Source

fillReadBuffer :: FD -> Buffer Word8 -> IO (Int, Buffer Word8) Source

fillReadBuffer0 :: FD -> Buffer Word8 -> IO (Maybe Int, Buffer Word8) Source

emptyWriteBuffer :: FD -> Buffer Word8 -> IO (Buffer Word8) Source

flushWriteBuffer :: FD -> Buffer Word8 -> IO (Buffer Word8) Source

flushWriteBuffer0 :: FD -> Buffer Word8 -> IO (Int, Buffer Word8) Source

readBuf :: RawIO dev => dev -> Buffer Word8 -> IO (Int, Buffer Word8) Source

readBufNonBlocking :: RawIO dev => dev -> Buffer Word8 -> IO (Maybe Int, Buffer Word8) Source

writeBuf :: RawIO dev => dev -> Buffer Word8 -> IO (Buffer Word8) Source

writeBufNonBlocking :: RawIO dev => dev -> Buffer Word8 -> IO (Int, Buffer Word8) Source

© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/9.14.1/docs/libraries/base-4.22.0.0-66f8/GHC-IO-BufferedIO.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API