Class AsyncFile

    • Constructor Detail

      • AsyncFile

        public AsyncFile​(io.vertx.core.file.AsyncFile delegate)
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • end

        public io.smallrye.mutiny.Uni<Void> end​(Buffer data)
        Same as but with an handler called when the operation completes

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        end in interface WriteStream<Buffer>
        Parameters:
        data -
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • endAndAwait

        public Void endAndAwait​(Buffer data)
        Blocking variant of io.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        endAndAwait in interface WriteStream<Buffer>
        Parameters:
        data -
        Returns:
        the Void instance produced by the operation
      • pipeTo

        public io.smallrye.mutiny.Uni<Void> pipeTo​(WriteStream<Buffer> dst)
        Pipe this ReadStream to the WriteStream.

        Elements emitted by this stream will be written to the write stream until this stream ends or fails.

        Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        pipeTo in interface ReadStream<Buffer>
        Parameters:
        dst - the destination write stream
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • pipeToAndAwait

        public Void pipeToAndAwait​(WriteStream<Buffer> dst)
        Blocking variant of io.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStream).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        pipeToAndAwait in interface ReadStream<Buffer>
        Parameters:
        dst - the destination write stream
        Returns:
        the Void instance produced by the operation
      • pause

        public AsyncFile pause()
        Specified by:
        pause in interface ReadStream<Buffer>
        Returns:
        a reference to this, so the API can be used fluently
      • write

        public io.smallrye.mutiny.Uni<Void> write​(Buffer data)
        Same as write(io.vertx.mutiny.core.buffer.Buffer) but with an handler called when the operation completes

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        write in interface WriteStream<Buffer>
        Parameters:
        data -
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • writeAndAwait

        public Void writeAndAwait​(Buffer data)
        Blocking variant of write(io.vertx.mutiny.core.buffer.Buffer).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        writeAndAwait in interface WriteStream<Buffer>
        Parameters:
        data -
        Returns:
        the Void instance produced by the operation
      • setWriteQueueMaxSize

        public AsyncFile setWriteQueueMaxSize​(int maxSize)
        Specified by:
        setWriteQueueMaxSize in interface WriteStream<Buffer>
        Parameters:
        maxSize - the max size of the write stream
        Returns:
        a reference to this, so the API can be used fluently
      • fetch

        public AsyncFile fetch​(long amount)
        Specified by:
        fetch in interface ReadStream<Buffer>
        Returns:
        a reference to this, so the API can be used fluently
      • end

        public io.smallrye.mutiny.Uni<Void> end()
        Close the file, see close().

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        end in interface WriteStream<Buffer>
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • endAndAwait

        public Void endAndAwait()
        Blocking variant of end(io.vertx.mutiny.core.buffer.Buffer).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        endAndAwait in interface WriteStream<Buffer>
        Returns:
        the Void instance produced by the operation
      • close

        public io.smallrye.mutiny.Uni<Void> close()
        Close the file. The actual close happens asynchronously. The handler will be called when the close is complete, or an error occurs.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • closeAndAwait

        public Void closeAndAwait()
        Blocking variant of close().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Returns:
        the Void instance produced by the operation
      • write

        public io.smallrye.mutiny.Uni<Void> write​(Buffer buffer,
                                                  long position)
        Write a Buffer to the file at position position in the file, asynchronously.

        If position lies outside of the current size of the file, the file will be enlarged to encompass it.

        When multiple writes are invoked on the same file there are no guarantees as to order in which those writes actually occur

        The handler will be called when the write is complete, or if an error occurs.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Parameters:
        buffer - the buffer to write
        position - the position in the file to write it at
        Returns:
        a reference to this, so the API can be used fluently
      • writeAndAwait

        public Void writeAndAwait​(Buffer buffer,
                                  long position)
        Blocking variant of write(io.vertx.mutiny.core.buffer.Buffer,long).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Parameters:
        buffer - the buffer to write
        position - the position in the file to write it at
        Returns:
        a reference to this, so the API can be used fluently
      • read

        public io.smallrye.mutiny.Uni<Buffer> read​(Buffer buffer,
                                                   int offset,
                                                   long position,
                                                   int length)
        Reads length bytes of data from the file at position position in the file, asynchronously.

        The read data will be written into the specified Buffer buffer at position offset.

        If data is read past the end of the file then zero bytes will be read.

        When multiple reads are invoked on the same file there are no guarantees as to order in which those reads actually occur.

        The handler will be called when the close is complete, or if an error occurs.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Parameters:
        buffer - the buffer to read into
        offset - the offset into the buffer where the data will be read
        position - the position in the file where to start reading
        length - the number of bytes to read
        Returns:
        a reference to this, so the API can be used fluently
      • readAndAwait

        public Buffer readAndAwait​(Buffer buffer,
                                   int offset,
                                   long position,
                                   int length)
        Blocking variant of read(io.vertx.mutiny.core.buffer.Buffer,int,long,int).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Parameters:
        buffer - the buffer to read into
        offset - the offset into the buffer where the data will be read
        position - the position in the file where to start reading
        length - the number of bytes to read
        Returns:
        a reference to this, so the API can be used fluently
      • flush

        public io.smallrye.mutiny.Uni<Void> flush()
        Same as flush() but the handler will be called when the flush is complete or if an error occurs

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • flushAndAwait

        public Void flushAndAwait()
        Blocking variant of flush().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Returns:
        the Void instance produced by the operation
      • setReadPos

        public AsyncFile setReadPos​(long readPos)
        Parameters:
        readPos - the position in the file
        Returns:
        a reference to this, so the API can be used fluently
      • setReadLength

        public AsyncFile setReadLength​(long readLength)
        Parameters:
        readLength - the bytes that will be read from the file
        Returns:
        a reference to this, so the API can be used fluently
      • setWritePos

        public AsyncFile setWritePos​(long writePos)
        Parameters:
        writePos - the position in the file
        Returns:
        a reference to this, so the API can be used fluently
      • getWritePos

        public long getWritePos()
        Returns:
        the current write position the file is at
      • setReadBufferSize

        public AsyncFile setReadBufferSize​(int readBufferSize)
        Parameters:
        readBufferSize - the buffer size
        Returns:
        a reference to this, so the API can be used fluently
      • endAndForget

        public void endAndForget​(Buffer data)
        Variant of io.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer) that ignores the result of the operation.

        This method subscribes on the result of io.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from io.vertx.mutiny.core.streams.WriteStream#end(io.vertx.mutiny.core.buffer.Buffer) but you don't need to compose it with other operations.

        Parameters:
        data - the data to write
      • pipeToAndForget

        public void pipeToAndForget​(WriteStream<Buffer> dst)
        Variant of io.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStream) that ignores the result of the operation.

        This method subscribes on the result of io.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStream), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from io.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStream) but you don't need to compose it with other operations.

        Parameters:
        dst -
      • closeAndForget

        public void closeAndForget()
        Variant of close() that ignores the result of the operation.

        This method subscribes on the result of close(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from close() but you don't need to compose it with other operations.

      • flushAndForget

        public AsyncFile flushAndForget()
        Variant of flush() that ignores the result of the operation.

        This method subscribes on the result of flush(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from flush() but you don't need to compose it with other operations.

        Returns:
        a reference to this, so the API can be used fluently
      • toBlockingStream

        public Stream<Buffer> toBlockingStream()
      • newInstance

        public static AsyncFile newInstance​(io.vertx.core.file.AsyncFile arg)