In this question, the answerers prove that every separable zero-dimensional metric space can be topologically embedded into $\mathbb{N}^\mathbb{N}$, but I think more is true. I think I have a proof that a topological space can be topologically embedded into the Cantor set (or rather, its topological equivalent $\{0,1\}^\mathbb{N}$) if and only if it is a separable zero-dimensional metrizable space.
First every subspace of the Cantor set is clearly a separable zero-dimensional metrizable space. Conversely, let $X$ be any separable zero-dimensional metrizable space. Then $X$ has a basis consisting of clopen sets $\mathscr{B}$. Since $X$ is separable and metrizable, it is second-countable, so $\mathscr{B}$ has a countable subset $\{B_0,B_1,\ldots\}$ which is also a basis (see here or here).
Define a function $f:X\to\{0,1\}^\mathbb{N}$ by $f(x)=(a_i)_{i\in\mathbb{N}}$ where $a_i=1$ if and only if $x\in B_i$. To see that $f$ is continuous, it is sufficient to check product topology prebasis elements. Indeed, if $\pi_j:\{0,1\}^\mathbb{N}\to\{0,1\}$ is the $j$th projection map, then $f^{-1}(\pi_j^{-1}(\{1\}))=B_j$ and $f^{-1}(\pi_j^{-1}(\{0\}))=X\setminus B_j$ which are both open. Finally, to see that $f$ is a topological embedding, simply note that $f(B_j)=\pi_j^{-1}(\{1\})\cap f(X)$ which is open in $f(X)$.
My proof feels remarkably simpler than the ones I saw in the first question I linked, so I am left to wonder if I made an error somewhere. Additionally, being metrizable only seemed necessary in my proof to guarantee second-countability, so I think the "separable zero-dimensional metrizable" condition could be replaced with "second-countable zero-dimensional".
Is my reasoning correct?