NewDocumentFromReader returns a Document from a generic reader. It does *not* check if the reader is also an io.Closer, so the provided reader is never closed by this call, it is the responsibility of the caller to close it if required.
(r io.Reader)
| 47 | // provided reader is never closed by this call, it is the responsibility |
| 48 | // of the caller to close it if required. |
| 49 | func NewDocumentFromReader(r io.Reader) result.Result[*Document] { |
| 50 | root, e := html.Parse(r) |
| 51 | if e != nil { |
| 52 | return result.TryErr[*Document](e) |
| 53 | } |
| 54 | return result.Ok(newDocument(root, nil)) |
| 55 | } |
| 56 | |
| 57 | // NewDocumentFromResponse is another Document constructor that takes an http response as argument. |
| 58 | // It loads the specified response's document, parses it, and stores the root Document |