stream

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2023 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFile

func ReadFile(s *Stream) (*fileinfo.FileInfo, io.Reader, error)

func ReadHeader

func ReadHeader(s *Stream) (*pb.Header, error)

func ReadMessage

func ReadMessage(s *Stream) ([]byte, error)

func ReadTransaction

func ReadTransaction(s *Stream) (*pb.Transaction, error)

func WriteFile

func WriteFile(s *Stream, filePath string) error

func WriteHeader

func WriteHeader(s *Stream, requestType pb.RequestType, requestId []byte, errorMsg string) error

func WriteMessage

func WriteMessage(s *Stream, data []byte) error

func WriteTransaction

func WriteTransaction(s *Stream, transactionName string, transactionID []byte) error

Types

type Stream

type Stream struct {
	Stream quic.Stream
	// contains filtered or unexported fields
}

Stream is a stream instance that is created when a transaction is opened. You can send and receive messages and files multiple times within a single transaction.

func New

func New(logLevel int, stream quic.Stream) (*Stream, error)

New creates a new stream instance. This method is used internally by quics-protocol. So, you may don't need to use it directly.

func (*Stream) Close

func (s *Stream) Close() error

Close closes the stream. Stream is closed automatically when the transaction is closed. So, you may don't need to use it directly.

func (*Stream) RecvBMessage

func (s *Stream) RecvBMessage() ([]byte, error)

RecvBMessage receives a bytes message through the connection. The message data is returned as a result. This method must be used in pairs with SendBMessage.

func (*Stream) RecvFile

func (s *Stream) RecvFile() (*fileinfo.FileInfo, io.Reader, error)

RecvFile receives a file through the connection. The file metadata and file data are returned as a result. This method must be used in pairs with SendFile.

func (*Stream) RecvFileBMessage

func (s *Stream) RecvFileBMessage() ([]byte, *fileinfo.FileInfo, io.Reader, error)

RecvFileBMessage receives a file with bytes message through the connection. The message data, file metadata, and file data are returned as a result. This method must be used in pairs with SendFileBMessage.

func (*Stream) SendBMessage

func (s *Stream) SendBMessage(data []byte) error

SendBMessage sends a bytes message through the connection. The message data needs to be passed as a parameter. This method must be used in pairs with RecvBMessage.

func (*Stream) SendError

func (s *Stream) SendError(errorMsg string) error

Send error sending error message through stream. This method tells the Recv method to receive and return any message. This allows the receiving party to handle errors or close the stream. Even when an error is returned within transactionHandleFunc, this method is used internally to close the stream.

func (*Stream) SendFile

func (s *Stream) SendFile(filePath string) error

SendFile sends a file through the connection. The file path needs to be passed as a parameter. The metadata of the file is automatically sent to the receiving side. If the filePath is a directory, the directory is sent as a file. This method must be used in pairs with RecvFile.

func (*Stream) SendFileBMessage

func (s *Stream) SendFileBMessage(data []byte, filePath string) error

SendFileBMessage sends a file with bytes message through the connection. The message data and file path need to be passed as parameters. The metadata of the file is automatically sent to the receiving side. If the filePath is a directory, the directory is sent as a file. This method must be used in pairs with RecvFileBMessage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL