#ifndef SWIFT_BUFFER_STREAM_H
#define SWIFT_BUFFER_STREAM_H

#include <swift/net/api.h>
#include <swift/io.h>
#include <swift/data.h>

typedef struct swift_buffer_stream_t swift_buffer_stream_t;

struct swift_buffer_stream_t {
	swift_stream_t stream;
	unsigned char *data;
	size_t pos, count, size;
};

#define SWIFT_BUFFER_STREAM(ptr) \
	(SWIFT_CONTAINER_OF((ptr), swift_buffer_stream_t, stream))

SWIFT_NET_API swift_stream_t *swift_create_buffer_stream(size_t size);
SWIFT_NET_API void *swift_get_buffer_stream_data(swift_stream_t *stream);
SWIFT_NET_API size_t swift_get_buffer_stream_count(swift_stream_t *stream);
SWIFT_NET_API bool swift_resize_buffer_stream(swift_stream_t *stream,
	size_t size);
SWIFT_NET_API bool swift_expand_buffer_stream(swift_stream_t *stream,
	size_t count);

#endif /* SWIFT_BUFFER_STREAM_H */
