Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
func Decode[T ~string](encoder *base64.Encoding) func(ro.Observable[T]) ro.Observable[[]byte]
Decode decodes the input from a base64 string.
Example:
ro.Pipe1(
ro.Just("aGVsbG8="),
robase64.Decode(base64.StdEncoding),
)
Play: https://go.dev/play/p/dTPmEzSHgi7
Example ¶
// Decode base64 strings to byte slices
observable := ro.Pipe1(
ro.Just("aGVsbG8=", "d29ybGQ=", "Z29sYW5n"),
Decode[string](base64.StdEncoding),
)
subscription := observable.Subscribe(ro.PrintObserver[[]byte]())
defer subscription.Unsubscribe()
Output: Next: [104 101 108 108 111] Next: [119 111 114 108 100] Next: [103 111 108 97 110 103] Completed
Example (WithError) ¶
// Decode with potential errors
observable := ro.Pipe1(
ro.Just("aGVsbG8=", "invalid-base64", "d29ybGQ="),
Decode[string](base64.StdEncoding),
)
subscription := observable.Subscribe(ro.PrintObserver[[]byte]())
defer subscription.Unsubscribe()
Output: Next: [104 101 108 108 111] Error: illegal base64 data at input byte 7
Example (WithURLEncoding) ¶
// Decode using URL-safe base64 encoding
observable := ro.Pipe1(
ro.Just("aGVsbG8gd29ybGQ=", "Z29sYW5nIHByb2dyYW1taW5n"),
Decode[string](base64.URLEncoding),
)
subscription := observable.Subscribe(ro.PrintObserver[[]byte]())
defer subscription.Unsubscribe()
Output: Next: [104 101 108 108 111 32 119 111 114 108 100] Next: [103 111 108 97 110 103 32 112 114 111 103 114 97 109 109 105 110 103] Completed
func Encode ¶
func Encode[T ~[]byte](encoder *base64.Encoding) func(ro.Observable[T]) ro.Observable[string]
Encode encodes the input into a base64 string.
Example:
ro.Pipe1(
ro.Just([]byte("hello")),
robase64.Encode(base64.StdEncoding),
)
Play: https://go.dev/play/p/PZCXxLxn5AF
Example ¶
// Encode byte slices to base64 strings
observable := ro.Pipe1(
ro.Just([]byte("hello"), []byte("world"), []byte("golang")),
Encode[[]byte](base64.StdEncoding),
)
subscription := observable.Subscribe(ro.PrintObserver[string]())
defer subscription.Unsubscribe()
Output: Next: aGVsbG8= Next: d29ybGQ= Next: Z29sYW5n Completed
Example (WithURLEncoding) ¶
// Encode using URL-safe base64 encoding
observable := ro.Pipe1(
ro.Just([]byte("hello world"), []byte("golang programming")),
Encode[[]byte](base64.URLEncoding),
)
subscription := observable.Subscribe(ro.PrintObserver[string]())
defer subscription.Unsubscribe()
Output: Next: aGVsbG8gd29ybGQ= Next: Z29sYW5nIHByb2dyYW1taW5n Completed
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.