Skip to content

Commit

Permalink
Fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Apr 21, 2024
1 parent ab02db5 commit 737918d
Show file tree
Hide file tree
Showing 106 changed files with 218 additions and 138 deletions.
89 changes: 89 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Expand Up @@ -6,3 +6,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1.0.198", features = ["derive"] }
serde_json = "1.0.116"

[dev-dependencies]
anyhow = "1.0.82"
22 changes: 13 additions & 9 deletions src/lib.rs
@@ -1,14 +1,18 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}
pub mod v1;

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
pub(crate) fn test_serde<
T: std::fmt::Debug + PartialEq + serde::Serialize + serde::de::DeserializeOwned,
>(
s: &str,
v: T,
) -> anyhow::Result<()> {
assert_eq!(serde_json::from_str::<'_, T>(s)?, v);
assert_eq!(
serde_json::from_str::<'_, serde_json::Value>(&serde_json::to_string(&v)?)?,
serde_json::from_str::<'_, serde_json::Value>(s)?
);
Ok(())
}
}
2 changes: 1 addition & 1 deletion src/v1/documents/alignment.rs
Expand Up @@ -24,7 +24,7 @@ pub enum Alignment {

#[cfg(test)]
mod tests {
use crate::google_docs_client::tests::test_serde;
use crate::tests::test_serde;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/auto_text.rs
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use crate::google_docs_client::v1::documents::{SuggestedTextStyle, TextStyle, Type};
use crate::v1::documents::{SuggestedTextStyle, TextStyle, Type};

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#autotext>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/background.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::OptionalColor;
use crate::v1::documents::OptionalColor;

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#background>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/body.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::StructuralElement;
use crate::v1::documents::StructuralElement;

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#body>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/bullet.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::TextStyle;
use crate::v1::documents::TextStyle;

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#bullet>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/bullet_alignment.rs
Expand Up @@ -23,7 +23,7 @@ pub enum BulletAlignment {

#[cfg(test)]
mod tests {
use crate::google_docs_client::tests::test_serde;
use crate::tests::test_serde;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/bullet_suggestion_state.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::TextStyleSuggestionState;
use crate::v1::documents::TextStyleSuggestionState;

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#bulletsuggestionstate>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/color.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::RgbColor;
use crate::v1::documents::RgbColor;

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#color>
#[derive(Clone, Debug, Default, PartialEq, PartialOrd, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/column_break.rs
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use crate::google_docs_client::v1::documents::{SuggestedTextStyle, TextStyle};
use crate::v1::documents::{SuggestedTextStyle, TextStyle};

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#columnbreak>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/column_separator_style.rs
Expand Up @@ -22,7 +22,7 @@ pub enum ColumnSeparatorStyle {

#[cfg(test)]
mod tests {
use crate::google_docs_client::tests::test_serde;
use crate::tests::test_serde;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/content_alignment.rs
Expand Up @@ -25,7 +25,7 @@ pub enum ContentAlignment {

#[cfg(test)]
mod tests {
use crate::google_docs_client::tests::test_serde;
use crate::tests::test_serde;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/content_direction.rs
Expand Up @@ -22,7 +22,7 @@ pub enum ContentDirection {

#[cfg(test)]
mod tests {
use crate::google_docs_client::tests::test_serde;
use crate::tests::test_serde;

use super::*;

Expand Down
10 changes: 5 additions & 5 deletions src/v1/documents/dash_style.rs
Expand Up @@ -23,20 +23,20 @@ pub enum DashStyle {

#[cfg(test)]
mod tests {
use crate::google_docs_client::tests::test_serde;
use crate::tests::test_serde;

use super::*;

#[test]
fn test() -> anyhow::Result<()> {
for (s, v) in [
(
r#""DASH_STYLE_UNSPECIFIED"#,
r#""DASH_STYLE_UNSPECIFIED""#,
DashStyle::DashStyleUnspecified,
),
(r#""SOLID"#, DashStyle::Solid),
(r#""DOT"#, DashStyle::Dot),
(r#""DASH"#, DashStyle::Dash),
(r#""SOLID""#, DashStyle::Solid),
(r#""DOT""#, DashStyle::Dot),
(r#""DASH""#, DashStyle::Dash),
] {
test_serde(s, v)?;
}
Expand Down
4 changes: 2 additions & 2 deletions src/v1/documents/dimension.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::Unit;
use crate::v1::documents::Unit;

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#dimension>
#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
Expand All @@ -13,7 +13,7 @@ pub struct Dimension {
mod tests {
use anyhow::Context as _;

use crate::google_docs_client::tests::test_serde;
use crate::tests::test_serde;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/document.rs
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use crate::google_docs_client::v1::documents::{
use crate::v1::documents::{
Body, DocumentStyle, Footer, Footnote, Header, InlineObject, List, NamedRanges, NamedStyles,
PositionedObject, SuggestedDocumentStyle, SuggestedNamedStyles, SuggestionsViewMode,
};
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/document_style.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::{Background, Dimension, Size};
use crate::v1::documents::{Background, Dimension, Size};

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#documentstyle>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/document_style_suggestion_state.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::{BackgroundSuggestionState, SizeSuggestionState};
use crate::v1::documents::{BackgroundSuggestionState, SizeSuggestionState};

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#documentstylesuggestionstate>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/embedded_object.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::{
use crate::v1::documents::{
Dimension, EmbeddedObjectBorder, EmbeddedObjectProperties, LinkedContentReference, Size,
};

Expand Down
4 changes: 1 addition & 3 deletions src/v1/documents/embedded_object_border.rs
@@ -1,6 +1,4 @@
use crate::google_docs_client::v1::documents::{
DashStyle, Dimension, OptionalColor, PropertyState,
};
use crate::v1::documents::{DashStyle, Dimension, OptionalColor, PropertyState};

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#embeddedobjectborder>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/embedded_object_properties.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::{EmbeddedDrawingProperties, ImageProperties};
use crate::v1::documents::{EmbeddedDrawingProperties, ImageProperties};

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#embeddedobject>
#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/embedded_object_suggestion_state.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::{
use crate::v1::documents::{
EmbeddedDrawingPropertiesSuggestionState, EmbeddedObjectBorderSuggestionState,
ImagePropertiesSuggestionState, LinkedContentReferenceSuggestionState, SizeSuggestionState,
};
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/footer.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::StructuralElement;
use crate::v1::documents::StructuralElement;

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#footer>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/footnote.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::StructuralElement;
use crate::v1::documents::StructuralElement;

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#footnote>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/footnote_reference.rs
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use crate::google_docs_client::v1::documents::{SuggestedTextStyle, TextStyle};
use crate::v1::documents::{SuggestedTextStyle, TextStyle};

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#footnotereference>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/glyph_type.rs
Expand Up @@ -27,7 +27,7 @@ pub enum GlyphType {

#[cfg(test)]
mod tests {
use crate::google_docs_client::tests::test_serde;
use crate::tests::test_serde;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/header.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::StructuralElement;
use crate::v1::documents::StructuralElement;

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#header>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/horizontal_rule.rs
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use crate::google_docs_client::v1::documents::{SuggestedTextStyle, TextStyle};
use crate::v1::documents::{SuggestedTextStyle, TextStyle};

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#horizontalrule>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/image_properties.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::CropProperties;
use crate::v1::documents::CropProperties;

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#imageproperties>
#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/image_properties_suggestion_state.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::CropPropertiesSuggestionState;
use crate::v1::documents::CropPropertiesSuggestionState;

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#imagepropertiessuggestionstate>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
4 changes: 1 addition & 3 deletions src/v1/documents/inline_object.rs
@@ -1,8 +1,6 @@
use std::collections::HashMap;

use crate::google_docs_client::v1::documents::{
InlineObjectProperties, SuggestedInlineObjectProperties,
};
use crate::v1::documents::{InlineObjectProperties, SuggestedInlineObjectProperties};

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#inlineobject>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/inline_object_element.rs
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use crate::google_docs_client::v1::documents::{SuggestedTextStyle, TextStyle};
use crate::v1::documents::{SuggestedTextStyle, TextStyle};

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#inlineobjectelement>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion src/v1/documents/inline_object_properties.rs
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::EmbeddedObject;
use crate::v1::documents::EmbeddedObject;

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#inlineobjectproperties>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down
@@ -1,4 +1,4 @@
use crate::google_docs_client::v1::documents::EmbeddedObjectSuggestionState;
use crate::v1::documents::EmbeddedObjectSuggestionState;

/// <https://developers.google.com/docs/api/reference/rest/v1/documents#inlineobjectpropertiessuggestionstate>
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down

0 comments on commit 737918d

Please sign in to comment.