A bijective mapping between metric spaces is open iff it is closed
Hint: Since the map is one-to-one and onto, it respects complements: for all subsets $A \subset X$, $f(X \setminus A) = D \setminus f(A)$.
In fact, $f : X \to D$ is bijective iff $f(X \backslash A)=D \backslash f(A)$ for every $A \subset X$.
Indeed, if $f$ is injective, $f(X \backslash A)=f(X) \backslash f(A)$, and if $f$ is surjective, $f(X)=D$, hence $f(X \backslash A)=D \backslash f(A)$. For the converse, for $A= \emptyset$, you get $f(X)=D$ so $f$ is surjective; if $x \neq y \in X$, then $f(x) \in f(X \backslash \{y\})=D \backslash \{f(y)\}$ so $f(x) \neq f(y)$: $f$ is injective.
If you only suppose that $f(X \backslash A)=D \backslash f(A)$ for every open set $A \subset X$, the result depends on the topology on $X$. However, since $\emptyset$ and $X$ are always open, $f$ is necessarly surjective.
Of course, $f$ is still bijective for the discrete topology. But for the trivial topology, you only have $f(X)=D$ so $f$ only needs to be surjective.