Skip to content

Commit

Permalink
Move unit_to_null to the utils module
Browse files Browse the repository at this point in the history
  • Loading branch information
milliams committed Oct 7, 2023
1 parent 40ee8f6 commit 90676da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
9 changes: 1 addition & 8 deletions src/compute/servers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use super::super::common::{
#[cfg(feature = "image")]
use super::super::image::Image;
use super::super::session::Session;
use super::super::utils::Query;
use super::super::utils::{unit_to_null, Query};
use super::super::waiter::{DeletionWaiter, Waiter};
use super::super::{Error, ErrorKind, Result, Sort};
use super::{api, protocol, BlockDevice, KeyPair};
Expand Down Expand Up @@ -324,13 +324,6 @@ impl Server {
}
}

/// Serialize an enum unit variant into a None
/// This is used to turn [ServerAction::Start] into
/// `"os-start": null` instead of just `"os-start"`
fn unit_to_null<S: serde::Serializer>(s: S) -> std::result::Result<S::Ok, S::Error> {
s.serialize_none()
}

/// An action to perform on a server.
#[derive(Clone, Copy, Debug, Serialize)]
pub enum ServerAction {
Expand Down
7 changes: 7 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ where
}
}

/// Serialize an enum unit variant into a None
/// This is used to turn [ServerAction::Start] into
/// `"os-start": null` instead of just `"os-start"`
pub fn unit_to_null<S: Serializer>(s: S) -> std::result::Result<S::Ok, S::Error> {
s.serialize_none()
}

pub mod url {
//! Handy primitives for working with URLs.

Expand Down

0 comments on commit 90676da

Please sign in to comment.