Skip to content

Commit

Permalink
newline_style = "Unix" (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
ctaggart authored Nov 10, 2020
1 parent 26feeb7 commit 6b966fb
Show file tree
Hide file tree
Showing 15 changed files with 611 additions and 603 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Don't allow people to merge changes to these generated files, because the result
# may be invalid. You need to run "cargo update" again.
Cargo.lock merge=binary

# Use unix line endings everywhere, even on Windows
* text=auto eol=lf
1 change: 1 addition & 0 deletions sdk/rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
newline_style = "Unix"
180 changes: 90 additions & 90 deletions sdk/storage/src/adls_gen2/filesystem/mod.rs
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
pub mod requests;
pub mod responses;

use azure_core::errors::AzureError;
use azure_core::headers::{CONTINUATION, PROPERTIES};
use azure_core::incompletevector::IncompleteVector;
use azure_core::util::HeaderMapExt;
use http::{request::Builder, HeaderMap};
use serde::Deserialize;

pub trait FilesystemRequired<'a> {
fn filesystem(&self) -> &'a str;
}

pub trait FilesystemSupport<'a> {
type O;
fn with_filesystem(self, filesystem: &'a str) -> Self::O;
}

pub trait PropertiesOption<'a> {
fn properties(&self) -> Option<&'a str>;

#[must_use]
fn add_header(&self, mut builder: Builder) -> Builder {
if let Some(properties) = self.properties() {
builder = builder.header(PROPERTIES, properties);
}
builder
}
}

pub trait PropertiesSupport<'a> {
type O;
fn with_properties(self, properties: &'a str) -> Self::O;
}

pub(crate) fn properties_from_headers(headers: &HeaderMap) -> Result<String, AzureError> {
let properties = headers
.get_as_str(azure_core::headers::PROPERTIES)
.ok_or_else(|| AzureError::HeaderNotFound(azure_core::headers::PROPERTIES.to_owned()))?;
Ok(properties.to_owned())
}

pub(crate) fn namespace_enabled_from_headers(headers: &HeaderMap) -> Result<bool, AzureError> {
let namespace_enabled = headers
.get(azure_core::headers::NAMESPACE_ENABLED)
.ok_or_else(|| {
AzureError::HeaderNotFound(azure_core::headers::NAMESPACE_ENABLED.to_owned())
})?
.to_str()?;

let namespace_enabled = namespace_enabled.parse::<bool>()?;
Ok(namespace_enabled)
}

#[derive(Debug, Clone, Deserialize)]
pub struct Filesystem {
pub etag: String,
#[serde(rename = "lastModified")]
pub last_modified: String,
pub name: String,
}

#[inline]
pub(crate) fn incomplete_vector_from_response(
headers: &HeaderMap,
body: &str,
) -> Result<IncompleteVector<Filesystem>, AzureError> {
trace!("body = {}", body);

let continuation = match headers.get_as_string(CONTINUATION) {
Some(ref ct) if ct == "" => None,
Some(ct) => Some(ct),
None => None,
};

debug!("continuation == {:?}", continuation);

#[derive(Deserialize)]
struct Filesystems {
filesystems: Vec<Filesystem>,
}

let Filesystems { filesystems } = serde_json::from_str(&body)?;

Ok(IncompleteVector::<Filesystem>::new(
continuation,
filesystems,
))
}
pub mod requests;
pub mod responses;

use azure_core::errors::AzureError;
use azure_core::headers::{CONTINUATION, PROPERTIES};
use azure_core::incompletevector::IncompleteVector;
use azure_core::util::HeaderMapExt;
use http::{request::Builder, HeaderMap};
use serde::Deserialize;

pub trait FilesystemRequired<'a> {
fn filesystem(&self) -> &'a str;
}

pub trait FilesystemSupport<'a> {
type O;
fn with_filesystem(self, filesystem: &'a str) -> Self::O;
}

pub trait PropertiesOption<'a> {
fn properties(&self) -> Option<&'a str>;

#[must_use]
fn add_header(&self, mut builder: Builder) -> Builder {
if let Some(properties) = self.properties() {
builder = builder.header(PROPERTIES, properties);
}
builder
}
}

pub trait PropertiesSupport<'a> {
type O;
fn with_properties(self, properties: &'a str) -> Self::O;
}

pub(crate) fn properties_from_headers(headers: &HeaderMap) -> Result<String, AzureError> {
let properties = headers
.get_as_str(azure_core::headers::PROPERTIES)
.ok_or_else(|| AzureError::HeaderNotFound(azure_core::headers::PROPERTIES.to_owned()))?;
Ok(properties.to_owned())
}

pub(crate) fn namespace_enabled_from_headers(headers: &HeaderMap) -> Result<bool, AzureError> {
let namespace_enabled = headers
.get(azure_core::headers::NAMESPACE_ENABLED)
.ok_or_else(|| {
AzureError::HeaderNotFound(azure_core::headers::NAMESPACE_ENABLED.to_owned())
})?
.to_str()?;

let namespace_enabled = namespace_enabled.parse::<bool>()?;
Ok(namespace_enabled)
}

#[derive(Debug, Clone, Deserialize)]
pub struct Filesystem {
pub etag: String,
#[serde(rename = "lastModified")]
pub last_modified: String,
pub name: String,
}

#[inline]
pub(crate) fn incomplete_vector_from_response(
headers: &HeaderMap,
body: &str,
) -> Result<IncompleteVector<Filesystem>, AzureError> {
trace!("body = {}", body);

let continuation = match headers.get_as_string(CONTINUATION) {
Some(ref ct) if ct == "" => None,
Some(ct) => Some(ct),
None => None,
};

debug!("continuation == {:?}", continuation);

#[derive(Deserialize)]
struct Filesystems {
filesystems: Vec<Filesystem>,
}

let Filesystems { filesystems } = serde_json::from_str(&body)?;

Ok(IncompleteVector::<Filesystem>::new(
continuation,
filesystems,
))
}
Loading

0 comments on commit 6b966fb

Please sign in to comment.