Skip to content

Commit 3660e7d

Browse files
authored
Remove fs module (#2877)
* Remove fs module Resolves #2860 and resolves #2318 * Also remove dependency on tokio/io-util
1 parent 2ba36cd commit 3660e7d

File tree

10 files changed

+31
-34
lines changed

10 files changed

+31
-34
lines changed

sdk/core/azure_core/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Release History
22

3+
## 0.28.0 (Unreleased)
4+
5+
### Breaking Changes
6+
7+
- Removed the `fs` module including the `FileStream` and `FileStreamBuilder` types. Moved to `examples/` for `typespec_client_core` to copy if needed.
8+
39
## 0.27.0 (2025-08-01)
410

511
### Features Added

sdk/core/azure_core/src/fs/mod.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

sdk/core/azure_core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ mod macros;
1111

1212
mod constants;
1313
pub mod credentials;
14-
pub mod fs;
1514
pub mod hmac;
1615
pub mod http;
1716

sdk/typespec/typespec_client_core/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Release History
22

3+
## 0.7.0 (Unreleased)
4+
5+
### Breaking Changes
6+
7+
- Removed the `fs` module including the `FileStream` and `FileStreamBuilder` types. Moved to `examples/` to copy if needed.
8+
39
## 0.6.0 (2025-08-01)
410

511
### Features Added

sdk/typespec/typespec_client_core/Cargo.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ getrandom.workspace = true
3939
tokio = { workspace = true, features = ["macros", "rt", "time"] }
4040

4141
[dev-dependencies]
42-
tokio.workspace = true
42+
tokio = { workspace = true, features = ["fs"] }
4343
tracing.workspace = true
4444
tracing-subscriber.workspace = true
4545
typespec_macros.path = "../typespec_macros"
@@ -58,13 +58,9 @@ reqwest_rustls = [
5858
"reqwest/rustls-tls-native-roots-no-provider",
5959
] # Remove dependency on banned `ring` crate; requires manually configuring crypto provider.
6060
test = [] # Enables extra tracing including error bodies that may contain PII.
61-
tokio = ["tokio/fs", "tokio/sync", "tokio/time", "tokio/io-util"]
61+
tokio = ["tokio/sync", "tokio/time"]
6262
xml = ["dep:quick-xml"]
6363

64-
[[example]]
65-
name = "core_binary_data_request"
66-
required-features = ["tokio"]
67-
6864
[[example]]
6965
name = "core_stream_response"
7066
required-features = ["derive"]

sdk/typespec/typespec_client_core/src/fs/tokio.rs renamed to sdk/typespec/typespec_client_core/examples/common/fs.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
use crate::{
5-
http::{Body, RequestContent},
6-
setters,
7-
stream::{SeekableStream, DEFAULT_BUFFER_SIZE},
8-
};
94
use futures::{task::Poll, Future};
105
use std::{cmp::min, io::SeekFrom, pin::Pin, sync::Arc, task::Context};
116
use tokio::{
@@ -14,6 +9,12 @@ use tokio::{
149
sync::Mutex,
1510
};
1611
use tracing::debug;
12+
use typespec_client_core::{
13+
error::Result,
14+
http::{Body, RequestContent},
15+
setters,
16+
stream::{SeekableStream, DEFAULT_BUFFER_SIZE},
17+
};
1718

1819
#[derive(Debug)]
1920
pub struct FileStreamBuilder {
@@ -45,7 +46,7 @@ impl FileStreamBuilder {
4546
buffer_size: usize => Some(buffer_size),
4647
}
4748

48-
pub async fn build(mut self) -> crate::Result<FileStream> {
49+
pub async fn build(mut self) -> Result<FileStream> {
4950
let stream_size = self.handle.metadata().await?.len();
5051

5152
let buffer_size = self.buffer_size.unwrap_or(DEFAULT_BUFFER_SIZE);
@@ -102,7 +103,7 @@ impl FileStream {
102103
/// `stream_size`
103104
///
104105
/// This is useful if you want to read the stream in multiple blocks
105-
pub async fn next_block(&mut self) -> crate::Result<()> {
106+
pub async fn next_block(&mut self) -> Result<()> {
106107
debug!("setting limit to {}", self.block_size);
107108
let mut handle = self.handle.clone().lock_owned().await;
108109
{
@@ -120,7 +121,7 @@ impl SeekableStream for FileStream {
120121
/// Seek to the specified offset into the file and reset the number of bytes to read
121122
///
122123
/// This is useful upon encountering an error to reset the stream to the last
123-
async fn reset(&mut self) -> crate::Result<()> {
124+
async fn reset(&mut self) -> Result<()> {
124125
debug!(
125126
"resetting stream to offset {} and limit to {}",
126127
self.offset, self.block_size
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
pub mod fs;

sdk/typespec/typespec_client_core/examples/core_binary_data_request.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
mod common;
5+
6+
use common::fs::FileStreamBuilder;
47
use tokio::fs;
58
use tracing::level_filters::LevelFilter;
69
use tracing_subscriber::fmt::format::FmtSpan;
7-
use typespec_client_core::{fs::FileStreamBuilder, http::RequestContent};
10+
use typespec_client_core::http::RequestContent;
811

912
#[tokio::main]
1013
async fn main() -> Result<(), Box<dyn std::error::Error>> {

sdk/typespec/typespec_client_core/src/fs/mod.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

sdk/typespec/typespec_client_core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub mod async_runtime;
1010
pub mod base64;
1111
pub mod error;
1212
pub mod fmt;
13-
pub mod fs;
1413
#[cfg(feature = "http")]
1514
pub mod http;
1615
#[cfg(feature = "json")]

0 commit comments

Comments
 (0)