Comments (3)
Oops. That actually won't work because of the while
conditional read.count < size
. Perhaps instead of writing directly to a Data
index like read[position]
, the UInt8
value could be appended to the empty Data
object instead...?
from thrift-swift.
I think it'll work if the object is constructed the same as Data(capacity: size)
, but within the read loop, it is filled with:
read.append(nextChar)
from thrift-swift.
Hmm good catch, I've not tested the TFileTransport extensively (just barely)
Could you replace the read method with this one and let me know if it fixes your issues?
After a quick test it seems that index addressing doesn't play nice with Data(capacity:)
because it just reserved space, instead of fully allocating it to the Data object, so while it has n-bytes capacity to write to, it technically only has 0 bytes (reported by count), and index replacements on Data
since its a value type use replaceBytesInRange:withBytes
, since the range is {0,0} that obviously doesn't work well does it?
public func read(size: Int) throws -> Data {
// set up read buffer, position 0
var read = Data(capacity: size)
// read character buffer
var nextChar: UInt8 = 0
// continue until we've read size bytes
while read.count < size {
if fread(&nextChar, 1, 1, self.fileHandle) == 1 {
read.append(nextChar)
} else {
throw TTransportError(error: .endOfFile)
}
}
return read
}
from thrift-swift.
Related Issues (20)
- 'thrift --gen swift_3 thrift_file' not working HOT 4
- [noob question] where is the thrift binary? HOT 7
- Thrift not compiles on Xcode 8 HOT 4
- Swift 4 support? HOT 7
- Swift-Nio lightweight HTTPServer implementation HOT 2
- Swift 4.1: '_rawValue' is inaccessible due to 'private' protection level HOT 4
- Talking to the RPC via UDP? HOT 5
- Let all socket communication go through a 3rd party library.
- /opt/local/dev/Thrift-Swift: error: package at '/opt/local/dev/Thrift-Swift' is using Swift tools version 3.1.0 which is no longer supported; use 4.0.0 or newer instead HOT 2
- Using Swift 4.2 with Thrift
- how to make rpc call via TAsyncClient HOT 6
- Contributing
- question on getting started with clients HOT 1
- TJSONProtocol support to Thrift-Swift package HOT 1
- Deploy new release with latest updates
- Invalid redeclaration of 'description' / tag 1.0.7 HOT 2
- Enum failable initialization / tag 1.0.7 HOT 2
- Enum property access level / tag 1.0.7 HOT 2
- optional keyword is ignored in argument lists HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thrift-swift.